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
@@ -3,13 +3,22 @@
3
3
  // MetricBars.data 就是 MetricMatrix.data(同一份矩阵数据的另一种摆法),别名显式化。
4
4
  //
5
5
  // 官方组件在宿主里自动接上证据室:web 面的 attemptHref 缺省取 ctx.attemptHref
6
- // (宿主注入的证据室深链);显式传 prop 可覆盖(嵌进自己应用时自定去处)
6
+ // (宿主注入的证据室深链);显式传 prop 可覆盖(嵌进自己应用时自定去处)。三个实体列表
7
+ // (ExperimentList / EvalList / AttemptList)没有这个覆盖口子——它们的 locator 徽标恒经
8
+ // ctx.attemptHref / ctx.attemptCommand,不接受 attemptHref/attemptCommand prop(docs/feature/reports/library.md
9
+ // 「嵌入自己的 React 页面」的函数签名没有这个参数),证据室深链在这三个组件上不是可选行为。
7
10
 
8
11
  import { defineComponent, isHostWebContextActive } from "./tree.ts";
9
- import type { AttemptRef } from "../results/index.ts";
12
+ import type { ReportComponent } from "./tree.ts";
13
+ import type { ReportLocale } from "./locale.ts";
14
+ import type { AttemptLocator } from "../results/locator.ts";
15
+ import type { Selection } from "../results/types.ts";
10
16
  import type {
11
- CaseListData,
17
+ AttemptListItem,
12
18
  DeltaData,
19
+ EvalListItem,
20
+ ExperimentListItem,
21
+ GroupSummaryData,
13
22
  LineData,
14
23
  MatrixData,
15
24
  OverviewData,
@@ -18,8 +27,11 @@ import type {
18
27
  TableData,
19
28
  } from "./types.ts";
20
29
  import {
21
- caseListData,
30
+ attemptListData,
22
31
  deltaData,
32
+ evalListData,
33
+ experimentListData,
34
+ groupSummaryData,
23
35
  lineData,
24
36
  matrixData,
25
37
  overviewData,
@@ -27,10 +39,14 @@ import {
27
39
  scoreboardData,
28
40
  tableData,
29
41
  } from "./compute.ts";
42
+ import type { ScatterDataOptions } from "./compute.ts";
30
43
  import {
44
+ attemptListText,
31
45
  barsText,
32
- caseListText,
33
46
  deltaText,
47
+ evalListText,
48
+ experimentListText,
49
+ groupSummaryText,
34
50
  lineText,
35
51
  matrixText,
36
52
  overviewText,
@@ -39,6 +55,10 @@ import {
39
55
  tableText,
40
56
  } from "./text/faces.ts";
41
57
  import { RunOverview as RunOverviewWeb } from "./react/RunOverview.tsx";
58
+ import { GroupSummary as GroupSummaryWeb } from "./react/GroupSummary.tsx";
59
+ import { ExperimentList as ExperimentListWeb } from "./react/ExperimentList.tsx";
60
+ import { EvalList as EvalListWeb } from "./react/EvalList.tsx";
61
+ import { AttemptList as AttemptListWeb } from "./react/AttemptList.tsx";
42
62
  import { MetricTable as MetricTableWeb } from "./react/MetricTable.tsx";
43
63
  import { MetricMatrix as MetricMatrixWeb } from "./react/MetricMatrix.tsx";
44
64
  import { MetricBars as MetricBarsWeb } from "./react/MetricBars.tsx";
@@ -46,93 +66,248 @@ import { Scoreboard as ScoreboardWeb } from "./react/Scoreboard.tsx";
46
66
  import { MetricScatter as MetricScatterWeb } from "./react/MetricScatter.tsx";
47
67
  import { MetricLine as MetricLineWeb } from "./react/MetricLine.tsx";
48
68
  import { DeltaTable as DeltaTableWeb } from "./react/DeltaTable.tsx";
49
- import { CaseList as CaseListWeb } from "./react/CaseList.tsx";
50
69
 
51
70
  // ───────────────────────── props ─────────────────────────
52
71
 
53
72
  export interface RunOverviewProps {
54
73
  data: OverviewData;
74
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
75
+ locale?: ReportLocale;
76
+ className?: string;
77
+ }
78
+
79
+ export interface GroupSummaryProps {
80
+ data: GroupSummaryData;
81
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
82
+ locale?: ReportLocale;
83
+ className?: string;
84
+ }
85
+
86
+ /**
87
+ * 三个实体列表都只收算好的 `items`(`.data(selection)` 的产物,报告作者先 `.filter()`/
88
+ * `.slice()` 再传入)——没有 selection-form,组件不提供另一套过滤 DSL
89
+ * (docs/feature/reports/library.md「实体列表」)。
90
+ */
91
+ export interface ExperimentListProps {
92
+ items: ExperimentListItem[];
93
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
94
+ locale?: ReportLocale;
95
+ className?: string;
96
+ }
97
+
98
+ export interface EvalListProps {
99
+ items: EvalListItem[];
100
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
101
+ locale?: ReportLocale;
102
+ className?: string;
103
+ }
104
+
105
+ export interface AttemptListProps {
106
+ items: AttemptListItem[];
107
+ /** items 被 slice 时如实显示剩余数量;省略即 items.length(未截断)。 */
108
+ total?: number;
109
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
110
+ locale?: ReportLocale;
55
111
  className?: string;
56
112
  }
57
113
 
58
114
  export interface MetricTableProps {
59
115
  data: TableData;
60
116
  /** 传了,格子可点、下钻去处你定;不传,宿主里走证据室深链,宿主外纯展示。 */
61
- attemptHref?: (ref: AttemptRef) => string;
117
+ attemptHref?: (locator: AttemptLocator) => string;
118
+ /**
119
+ * web 面在表格前渲染一个过滤输入框(`<input class="nre-filter" data-nre-filter>`),
120
+ * 由渐进增强 runtime(enhance.js)接管:输入过滤行 textContent。无 JS 时输入框
121
+ * 静默无功能,表格内容依旧完整可读。默认 false;text 面不受影响。
122
+ */
123
+ filter?: boolean;
124
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
125
+ locale?: ReportLocale;
62
126
  className?: string;
63
127
  }
64
128
 
65
129
  export interface MetricMatrixProps {
66
130
  data: MatrixData;
67
- attemptHref?: (ref: AttemptRef) => string;
131
+ attemptHref?: (locator: AttemptLocator) => string;
132
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
133
+ locale?: ReportLocale;
68
134
  className?: string;
69
135
  }
70
136
 
71
137
  export interface ScoreboardProps {
72
138
  data: ScoreboardData;
139
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
140
+ locale?: ReportLocale;
73
141
  className?: string;
74
142
  }
75
143
 
76
- export interface MetricScatterProps {
77
- data: ScatterData;
144
+ /** MetricScatter 两臂共享的纯渲染选项(不含数据来源)。 */
145
+ interface MetricScatterRenderProps {
78
146
  /** 点一个点 → 该配置的下钻页。 */
79
147
  pointHref?: (row: ScatterData["rows"][number]) => string;
148
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
149
+ locale?: ReportLocale;
80
150
  className?: string;
81
151
  }
82
152
 
153
+ /** resolve 之后 web / text 面看到的形态:数据已备好,零 IO。 */
154
+ export interface MetricScatterResolvedProps extends MetricScatterRenderProps {
155
+ data: ScatterData;
156
+ }
157
+
158
+ /**
159
+ * 互斥两臂:要么直接给算好的 `data`(用于用户自己的 React 页面 / 预计算 / 跨边界序列化),
160
+ * 要么给 `selection` + 计算选项让宿主在渲染前解析(见 tree.ts 的 resolveReportTree)。
161
+ * 同时传 `data` 与 `selection`、或两者都不传,都在 typecheck 阶段失败。计算选项复用
162
+ * `ScatterDataOptions`,不手写会漂移的副本。
163
+ */
164
+ export type MetricScatterProps =
165
+ | (MetricScatterResolvedProps & {
166
+ selection?: never;
167
+ points?: never;
168
+ series?: never;
169
+ x?: never;
170
+ y?: never;
171
+ })
172
+ | ({ data?: never } & ScatterDataOptions & MetricScatterRenderProps & { selection: Selection });
173
+
83
174
  export interface MetricLineProps {
84
175
  data: LineData;
85
176
  pointHref?: (row: LineData["rows"][number]) => string;
177
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
178
+ locale?: ReportLocale;
86
179
  className?: string;
87
180
  }
88
181
 
89
182
  export interface DeltaTableProps {
90
183
  data: DeltaData;
91
- className?: string;
92
- }
93
-
94
- export interface CaseListProps {
95
- data: CaseListData;
96
- attemptHref?: (ref: AttemptRef) => string;
184
+ /** chrome 文案 locale;省略时随宿主上下文(宿主外默认 "en")。 */
185
+ locale?: ReportLocale;
97
186
  className?: string;
98
187
  }
99
188
 
100
189
  // ───────────────────────── 装配 ─────────────────────────
101
190
 
102
- /** 页头 KPI 条:何时跑的、几个配置、几道题、通过率、总成本;选集的警告随行显示在条内。 */
103
- export const RunOverview = Object.assign(
191
+ const SCATTER_UNRESOLVED_MESSAGE =
192
+ "MetricScatter received unresolved (selection-form) props outside the report host pipeline. " +
193
+ "Render through defineReport + niceeval show/view (or renderReportToText/renderReportToStaticHtml), " +
194
+ "or precompute with `await MetricScatter.data(selection, options)` and pass the result as `data`.";
195
+
196
+ /** 渲染面(web / text)只吃已解析的数据形态;selection 形态漏解析时直说,而不是画一张空组件。 */
197
+ function requireScatterData(props: { data?: ScatterData }): ScatterData {
198
+ if (props.data === undefined) throw new Error(SCATTER_UNRESOLVED_MESSAGE);
199
+ return props.data;
200
+ }
201
+
202
+ /** 页头 KPI 条:何时跑的、几个配置、几道题、通过率、总成本;Selection 的警告随行显示在条内。 */
203
+ export const RunOverview: ReportComponent<RunOverviewProps> & { data: typeof overviewData } = Object.assign(
104
204
  defineComponent<RunOverviewProps>({
105
- web: (props) => <RunOverviewWeb {...props} />,
106
- text: ({ data }) => overviewText(data),
205
+ web: (props, ctx) => <RunOverviewWeb {...props} locale={props.locale ?? ctx.locale} />,
206
+ text: ({ data }, ctx) => overviewText(data, ctx),
107
207
  }),
108
208
  { data: overviewData },
109
209
  );
110
210
  RunOverview.displayName = "RunOverview";
111
211
 
212
+ /**
213
+ * 组摘要:一组 experiment(典型用法是同一 `<Section>` 内的全部 experiment)的紧凑统计——
214
+ * 通过率(旧 GroupSelector 卡片口径)、experiment/eval/attempt 数、eval 级折叠计票、
215
+ * 总成本、最后运行时间。
216
+ */
217
+ export const GroupSummary: ReportComponent<GroupSummaryProps> & { data: typeof groupSummaryData } = Object.assign(
218
+ defineComponent<GroupSummaryProps>({
219
+ web: (props, ctx) => <GroupSummaryWeb {...props} locale={props.locale ?? ctx.locale} />,
220
+ text: ({ data }, ctx) => groupSummaryText(data, ctx),
221
+ }),
222
+ { data: groupSummaryData },
223
+ );
224
+ GroupSummary.displayName = "GroupSummary";
225
+
226
+ /**
227
+ * 实验列表:每项一个 experiment,固定展示身份、配置(flags)、Eval 判定构成和官方两级聚合
228
+ * 汇总指标;展开到这个 experiment 的 Eval,每道题内联该题全部 Attempt 的 locator 徽标。
229
+ * 没有 selection-form:`ExperimentList.data(selection)` 产出普通数组,过滤由报告作者对
230
+ * 数组调用 `.filter()`。
231
+ */
232
+ export const ExperimentList: ReportComponent<ExperimentListProps> & { data: typeof experimentListData } =
233
+ Object.assign(
234
+ defineComponent<ExperimentListProps>({
235
+ web: (props, ctx) => <ExperimentListWeb {...props} locale={props.locale ?? ctx.locale} attemptHref={ctx.attemptHref} />,
236
+ text: ({ items }, ctx) => experimentListText(items, ctx),
237
+ }),
238
+ { data: experimentListData },
239
+ );
240
+ ExperimentList.displayName = "ExperimentList";
241
+
242
+ /**
243
+ * Eval 列表:每项一个 `experimentId + evalId`,固定展示判定、Attempt 数、分数、成本、耗时
244
+ * 与失败原因;展开到这道题的 Attempt(与 AttemptList 同一份 AttemptListItem)。
245
+ */
246
+ export const EvalList: ReportComponent<EvalListProps> & { data: typeof evalListData } = Object.assign(
247
+ defineComponent<EvalListProps>({
248
+ web: (props, ctx) => <EvalListWeb {...props} locale={props.locale ?? ctx.locale} attemptHref={ctx.attemptHref} />,
249
+ text: ({ items }, ctx) => evalListText(items, ctx),
250
+ }),
251
+ { data: evalListData },
252
+ );
253
+ EvalList.displayName = "EvalList";
254
+
255
+ /**
256
+ * Attempt 列表:实体列表的叶子层,每项一个 Attempt,固定展示判定、断言、error、Judge 评语
257
+ * (assertions 的 detail/evidence)与证据引用(locator + 证据能力标记)。它不预设只看失败;
258
+ * 报告作者过滤 `AttemptListItem[]`、用 `.slice()` 限量,`total` 让渲染面如实报告剩余数量。
259
+ */
260
+ export const AttemptList: ReportComponent<AttemptListProps> & { data: typeof attemptListData } = Object.assign(
261
+ defineComponent<AttemptListProps>({
262
+ web: (props, ctx) => <AttemptListWeb {...props} locale={props.locale ?? ctx.locale} attemptHref={ctx.attemptHref} />,
263
+ text: ({ items, total }, ctx) => attemptListText(items, total, ctx),
264
+ }),
265
+ { data: attemptListData },
266
+ );
267
+ AttemptList.displayName = "AttemptList";
268
+
112
269
  /** 榜单:一行一个维度值、一列一个指标,回答「谁整体更好」。 */
113
- export const MetricTable = Object.assign(
270
+ export const MetricTable: ReportComponent<MetricTableProps> & { data: typeof tableData } = Object.assign(
114
271
  defineComponent<MetricTableProps>({
115
- web: (props, ctx) => <MetricTableWeb {...props} attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)} />,
116
- text: ({ data }) => tableText(data),
272
+ web: (props, ctx) => (
273
+ <MetricTableWeb
274
+ {...props}
275
+ locale={props.locale ?? ctx.locale}
276
+ attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)}
277
+ />
278
+ ),
279
+ text: ({ data }, ctx) => tableText(data, ctx),
117
280
  }),
118
281
  { data: tableData },
119
282
  );
120
283
  MetricTable.displayName = "MetricTable";
121
284
 
122
285
  /** 逐题格子:行 × 列两个维度、格子里一个指标,回答「哪道题谁挂了」。 */
123
- export const MetricMatrix = Object.assign(
286
+ export const MetricMatrix: ReportComponent<MetricMatrixProps> & { data: typeof matrixData } = Object.assign(
124
287
  defineComponent<MetricMatrixProps>({
125
- web: (props, ctx) => <MetricMatrixWeb {...props} attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)} />,
126
- text: ({ data }) => matrixText(data),
288
+ web: (props, ctx) => (
289
+ <MetricMatrixWeb
290
+ {...props}
291
+ locale={props.locale ?? ctx.locale}
292
+ attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)}
293
+ />
294
+ ),
295
+ text: ({ data }, ctx) => matrixText(data, ctx),
127
296
  }),
128
297
  { data: matrixData },
129
298
  );
130
299
  MetricMatrix.displayName = "MetricMatrix";
131
300
 
132
301
  /** 分组条形:同一份矩阵数据的另一种摆法;MetricBars.data 就是 MetricMatrix.data 的别名。 */
133
- export const MetricBars = Object.assign(
302
+ export const MetricBars: ReportComponent<MetricMatrixProps> & { data: typeof matrixData } = Object.assign(
134
303
  defineComponent<MetricMatrixProps>({
135
- web: (props, ctx) => <MetricBarsWeb {...props} attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)} />,
304
+ web: (props, ctx) => (
305
+ <MetricBarsWeb
306
+ {...props}
307
+ locale={props.locale ?? ctx.locale}
308
+ attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)}
309
+ />
310
+ ),
136
311
  text: ({ data }) => barsText(data),
137
312
  }),
138
313
  { data: matrixData },
@@ -140,29 +315,37 @@ export const MetricBars = Object.assign(
140
315
  MetricBars.displayName = "MetricBars";
141
316
 
142
317
  /** 考试成绩单:总分 + 分科小计,固定分母、missing 如实报。 */
143
- export const Scoreboard = Object.assign(
318
+ export const Scoreboard: ReportComponent<ScoreboardProps> & { data: typeof scoreboardData } = Object.assign(
144
319
  defineComponent<ScoreboardProps>({
145
- web: (props) => <ScoreboardWeb {...props} />,
146
- text: ({ data }) => scoreboardText(data),
320
+ web: (props, ctx) => <ScoreboardWeb {...props} locale={props.locale ?? ctx.locale} />,
321
+ text: ({ data }, ctx) => scoreboardText(data, ctx),
147
322
  }),
148
323
  { data: scoreboardData },
149
324
  );
150
325
  Scoreboard.displayName = "Scoreboard";
151
326
 
152
327
  /** 质量 × 成本 frontier:每个点一个配置、两个指标各占一轴,「好」的角落恒在右上。 */
153
- export const MetricScatter = Object.assign(
154
- defineComponent<MetricScatterProps>({
155
- web: (props) => <MetricScatterWeb {...props} />,
156
- text: ({ data }, ctx) => scatterText(data, ctx),
328
+ export const MetricScatter: ReportComponent<MetricScatterProps> & { data: typeof scatterData } = Object.assign(
329
+ defineComponent<MetricScatterProps, MetricScatterResolvedProps>({
330
+ resolve: async (props) => {
331
+ if ("data" in props && props.data !== undefined) return props;
332
+ const { selection, points, series, x, y, ...rest } = props;
333
+ return { ...rest, data: await scatterData(selection, { points, series, x, y }) };
334
+ },
335
+ web: (props, ctx) => {
336
+ requireScatterData(props);
337
+ return <MetricScatterWeb {...props} locale={props.locale ?? ctx.locale} />;
338
+ },
339
+ text: (props, ctx) => scatterText(requireScatterData(props), ctx),
157
340
  }),
158
341
  { data: scatterData },
159
342
  );
160
343
  MetricScatter.displayName = "MetricScatter";
161
344
 
162
345
  /** 趋势线:x 是 experiment 声明的 flag(flag()),同系列按 x 排序连线。 */
163
- export const MetricLine = Object.assign(
346
+ export const MetricLine: ReportComponent<MetricLineProps> & { data: typeof lineData } = Object.assign(
164
347
  defineComponent<MetricLineProps>({
165
- web: (props) => <MetricLineWeb {...props} />,
348
+ web: (props, ctx) => <MetricLineWeb {...props} locale={props.locale ?? ctx.locale} />,
166
349
  text: ({ data }, ctx) => lineText(data, ctx),
167
350
  }),
168
351
  { data: lineData },
@@ -170,21 +353,11 @@ export const MetricLine = Object.assign(
170
353
  MetricLine.displayName = "MetricLine";
171
354
 
172
355
  /** 成对对比:每行一对配置、格子里 A、B、Δ 三个值,涨跌好坏由 better 判定。 */
173
- export const DeltaTable = Object.assign(
356
+ export const DeltaTable: ReportComponent<DeltaTableProps> & { data: typeof deltaData } = Object.assign(
174
357
  defineComponent<DeltaTableProps>({
175
- web: (props) => <DeltaTableWeb {...props} />,
176
- text: ({ data }) => deltaText(data),
358
+ web: (props, ctx) => <DeltaTableWeb {...props} locale={props.locale ?? ctx.locale} />,
359
+ text: ({ data }, ctx) => deltaText(data, ctx),
177
360
  }),
178
361
  { data: deltaData },
179
362
  );
180
363
  DeltaTable.displayName = "DeltaTable";
181
-
182
- /** 失败案例清单:榜单回答「多少」,它回答「为什么」;truncated 如实报剩余。 */
183
- export const CaseList = Object.assign(
184
- defineComponent<CaseListProps>({
185
- web: (props, ctx) => <CaseListWeb {...props} attemptHref={props.attemptHref ?? (isHostWebContextActive() ? ctx.attemptHref : undefined)} />,
186
- text: (props, ctx) => caseListText(props.data, ctx),
187
- }),
188
- { data: caseListData },
189
- );
190
- CaseList.displayName = "CaseList";