niceeval 0.9.1 → 0.10.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 (428) hide show
  1. package/INDEX.md +31 -33
  2. package/dist/agents/types.d.ts +20 -17
  3. package/dist/context/types.d.ts +21 -21
  4. package/dist/i18n/en.d.ts +10 -2
  5. package/dist/i18n/zh-CN.d.ts +14 -6
  6. package/dist/o11y/execution-tree.d.ts +103 -0
  7. package/dist/o11y/otlp/select.d.ts +22 -0
  8. package/dist/report/{react → assets}/colors.d.ts +8 -0
  9. package/dist/report/{react → assets}/colors.js +23 -0
  10. package/dist/report/built-in/index.d.ts +2 -2
  11. package/dist/report/built-in/index.js +2 -2
  12. package/dist/report/built-in/standard.d.ts +8 -1
  13. package/dist/report/built-in/standard.js +17 -7
  14. package/dist/report/components/attempt-detail/AttemptAssertions.d.ts +6 -0
  15. package/dist/report/components/attempt-detail/AttemptAssertions.js +17 -0
  16. package/dist/report/components/attempt-detail/AttemptConversation.d.ts +6 -0
  17. package/dist/report/components/attempt-detail/AttemptConversation.js +34 -0
  18. package/dist/report/components/attempt-detail/AttemptDiagnostics.d.ts +6 -0
  19. package/dist/report/components/attempt-detail/AttemptDiagnostics.js +7 -0
  20. package/dist/report/components/attempt-detail/AttemptDiff.d.ts +6 -0
  21. package/dist/report/components/attempt-detail/AttemptDiff.js +11 -0
  22. package/dist/report/components/attempt-detail/AttemptError.d.ts +6 -0
  23. package/dist/report/components/attempt-detail/AttemptError.js +16 -0
  24. package/dist/report/components/attempt-detail/AttemptFixPrompt.d.ts +6 -0
  25. package/dist/report/components/attempt-detail/AttemptFixPrompt.js +7 -0
  26. package/dist/report/components/attempt-detail/AttemptSource.d.ts +6 -0
  27. package/dist/report/components/attempt-detail/AttemptSource.js +27 -0
  28. package/dist/report/components/attempt-detail/AttemptSummary.d.ts +8 -0
  29. package/dist/report/components/attempt-detail/AttemptSummary.js +20 -0
  30. package/dist/report/components/attempt-detail/AttemptTimeline.d.ts +6 -0
  31. package/dist/report/components/attempt-detail/AttemptTimeline.js +28 -0
  32. package/dist/report/components/attempt-detail/AttemptTrace.d.ts +6 -0
  33. package/dist/report/components/attempt-detail/AttemptTrace.js +29 -0
  34. package/dist/report/components/attempt-detail/AttemptUsage.d.ts +6 -0
  35. package/dist/report/components/attempt-detail/AttemptUsage.js +20 -0
  36. package/dist/report/components/attempt-detail/compute.d.ts +24 -0
  37. package/dist/report/components/attempt-detail/compute.js +254 -0
  38. package/dist/report/components/attempt-detail/faces.d.ts +14 -0
  39. package/dist/report/components/attempt-detail/faces.js +235 -0
  40. package/dist/report/components/attempt-detail/index.d.ts +38 -0
  41. package/dist/report/components/attempt-detail/index.js +527 -0
  42. package/dist/report/{react → components}/cell.d.ts +5 -3
  43. package/dist/report/{react → components}/cell.js +3 -3
  44. package/dist/report/{react → components/entity-lists}/AttemptList.d.ts +8 -4
  45. package/dist/report/{react → components/entity-lists}/AttemptList.js +16 -10
  46. package/dist/report/{react → components/entity-lists}/EvalList.d.ts +3 -3
  47. package/dist/report/{react → components/entity-lists}/EvalList.js +0 -0
  48. package/dist/report/{react → components/entity-lists}/ExperimentList.d.ts +3 -3
  49. package/dist/report/{react → components/entity-lists}/ExperimentList.js +10 -10
  50. package/dist/report/components/entity-lists/compute.d.ts +23 -0
  51. package/dist/report/components/entity-lists/compute.js +171 -0
  52. package/dist/report/components/entity-lists/faces.d.ts +5 -0
  53. package/dist/report/components/entity-lists/faces.js +174 -0
  54. package/dist/report/components/entity-lists/index.d.ts +51 -0
  55. package/dist/report/components/entity-lists/index.js +165 -0
  56. package/dist/report/{react → components}/fixtures.d.ts +2 -2
  57. package/dist/report/{react → components}/fixtures.js +1 -1
  58. package/dist/report/{react → components/metric-views}/DeltaTable.d.ts +2 -2
  59. package/dist/report/{react → components/metric-views}/DeltaTable.js +4 -4
  60. package/dist/report/{react → components/metric-views}/MetricBars.d.ts +3 -3
  61. package/dist/report/{react → components/metric-views}/MetricBars.js +3 -3
  62. package/dist/report/{react → components/metric-views}/MetricLine.d.ts +2 -2
  63. package/dist/report/{react → components/metric-views}/MetricLine.js +8 -5
  64. package/dist/report/{react → components/metric-views}/MetricMatrix.d.ts +3 -3
  65. package/dist/report/{react → components/metric-views}/MetricMatrix.js +4 -4
  66. package/dist/report/components/metric-views/MetricScatter.d.ts +11 -0
  67. package/dist/report/{react → components/metric-views}/MetricScatter.js +26 -23
  68. package/dist/report/{react → components/metric-views}/MetricTable.d.ts +3 -3
  69. package/dist/report/{react → components/metric-views}/MetricTable.js +4 -4
  70. package/dist/report/{react → components/metric-views}/Scoreboard.d.ts +2 -2
  71. package/dist/report/{react → components/metric-views}/Scoreboard.js +3 -3
  72. package/dist/report/components/metric-views/compute.d.ts +89 -0
  73. package/dist/report/{compute.js → components/metric-views/compute.js} +32 -415
  74. package/dist/report/components/metric-views/faces.d.ts +13 -0
  75. package/dist/report/components/metric-views/faces.js +381 -0
  76. package/dist/report/components/metric-views/index.d.ts +50 -0
  77. package/dist/report/components/metric-views/index.js +273 -0
  78. package/dist/report/{text → components/metric-views}/plot.js +1 -1
  79. package/dist/report/components/shared-compute.d.ts +22 -0
  80. package/dist/report/components/shared-compute.js +47 -0
  81. package/dist/report/components/shared-faces.d.ts +9 -0
  82. package/dist/report/components/shared-faces.js +26 -0
  83. package/dist/report/components/shared.d.ts +68 -0
  84. package/dist/report/components/shared.js +125 -0
  85. package/dist/report/{react → components/site-components}/CopyFixPrompt.d.ts +2 -2
  86. package/dist/report/{react → components/site-components}/CopyFixPrompt.js +2 -2
  87. package/dist/report/{react → components/site-components}/HeroCard.d.ts +2 -2
  88. package/dist/report/{react → components/site-components}/HeroCard.js +2 -2
  89. package/dist/report/{react → components/site-components}/ScopeWarnings.d.ts +2 -2
  90. package/dist/report/{react → components/site-components}/ScopeWarnings.js +3 -3
  91. package/dist/report/{react → components/site-components}/TraceWaterfall.d.ts +3 -3
  92. package/dist/report/{react → components/site-components}/TraceWaterfall.js +5 -5
  93. package/dist/report/components/site-components/compute.d.ts +28 -0
  94. package/dist/report/components/site-components/compute.js +132 -0
  95. package/dist/report/components/site-components/faces.d.ts +21 -0
  96. package/dist/report/components/site-components/faces.js +75 -0
  97. package/dist/report/components/site-components/index.d.ts +74 -0
  98. package/dist/report/components/site-components/index.js +220 -0
  99. package/dist/report/{scope-warnings.d.ts → components/site-components/scope-warnings.d.ts} +2 -2
  100. package/dist/report/{scope-warnings.js → components/site-components/scope-warnings.js} +2 -2
  101. package/dist/report/{react → components/summaries}/ScopeSummary.d.ts +2 -2
  102. package/dist/report/{react → components/summaries}/ScopeSummary.js +17 -8
  103. package/dist/report/components/summaries/compute.d.ts +7 -0
  104. package/dist/report/components/summaries/compute.js +51 -0
  105. package/dist/report/components/summaries/faces.d.ts +7 -0
  106. package/dist/report/components/summaries/faces.js +38 -0
  107. package/dist/report/components/summaries/index.d.ts +27 -0
  108. package/dist/report/components/summaries/index.js +78 -0
  109. package/dist/report/definition/grid-layout.d.ts +50 -0
  110. package/dist/report/definition/grid-layout.js +89 -0
  111. package/dist/report/{primitives.d.ts → definition/primitives.d.ts} +34 -4
  112. package/dist/report/{primitives.js → definition/primitives.js} +101 -10
  113. package/dist/report/{report.d.ts → definition/report.d.ts} +36 -65
  114. package/dist/report/{report.js → definition/report.js} +58 -90
  115. package/dist/report/{text/table.d.ts → definition/table-text.d.ts} +2 -2
  116. package/dist/report/{text/table.js → definition/table-text.js} +2 -2
  117. package/dist/report/{tree.d.ts → definition/tree.d.ts} +43 -11
  118. package/dist/report/{tree.js → definition/tree.js} +9 -11
  119. package/dist/report/index.d.ts +33 -18
  120. package/dist/report/index.js +23 -14
  121. package/dist/report/{aggregate.d.ts → model/aggregate.d.ts} +12 -4
  122. package/dist/report/{aggregate.js → model/aggregate.js} +28 -8
  123. package/dist/report/{flag.d.ts → model/flag.d.ts} +14 -1
  124. package/dist/report/{flag.js → model/flag.js} +35 -0
  125. package/dist/report/{format.d.ts → model/format.d.ts} +11 -5
  126. package/dist/report/{format.js → model/format.js} +48 -4
  127. package/dist/report/{locale.d.ts → model/locale.d.ts} +17 -17
  128. package/dist/report/{locale.js → model/locale.js} +31 -33
  129. package/dist/report/{metrics.d.ts → model/metrics.d.ts} +2 -2
  130. package/dist/report/{metrics.js → model/metrics.js} +2 -2
  131. package/dist/report/{types.d.ts → model/types.d.ts} +140 -20
  132. package/dist/report/react/index.d.ts +32 -21
  133. package/dist/report/react/index.js +33 -21
  134. package/dist/report/{load.d.ts → runtime/load.d.ts} +1 -1
  135. package/dist/report/{load.js → runtime/load.js} +1 -1
  136. package/dist/report/runtime/text.d.ts +67 -0
  137. package/dist/report/runtime/text.js +114 -0
  138. package/dist/report/runtime/web.d.ts +35 -0
  139. package/dist/report/runtime/web.js +70 -0
  140. package/dist/results/annotated-source.d.ts +87 -0
  141. package/dist/results/attempt-evidence.d.ts +74 -0
  142. package/dist/results/attempt-source.d.ts +15 -0
  143. package/dist/results/select.d.ts +11 -1
  144. package/dist/results/select.js +27 -5
  145. package/dist/runner/eval-selection.d.ts +26 -0
  146. package/dist/runner/feedback/sink.d.ts +26 -1
  147. package/dist/runner/types.d.ts +149 -23
  148. package/dist/sandbox/docker.d.ts +6 -0
  149. package/dist/sandbox/types.d.ts +23 -21
  150. package/dist/scoring/display.d.ts +7 -2
  151. package/dist/scoring/display.js +42 -4
  152. package/dist/scoring/types.d.ts +3 -3
  153. package/dist/shared/aggregate.d.ts +14 -0
  154. package/dist/shared/aggregate.js +31 -0
  155. package/dist/shared/types.d.ts +6 -1
  156. package/docs-site/images/logo-dark.svg +7 -0
  157. package/docs-site/images/logo.svg +6 -5
  158. package/docs-site/zh/README.md +8 -7
  159. package/docs-site/zh/examples/ai-agent-application.mdx +5 -5
  160. package/docs-site/zh/examples/coding-agent-extensions.mdx +4 -4
  161. package/docs-site/zh/examples/index.mdx +3 -3
  162. package/docs-site/zh/examples/integrations/ai-sdk-v7.mdx +1 -1
  163. package/docs-site/zh/examples/integrations/claude-sdk.mdx +3 -3
  164. package/docs-site/zh/examples/integrations/codex-sdk.mdx +3 -3
  165. package/docs-site/zh/examples/integrations/langgraph.mdx +3 -3
  166. package/docs-site/zh/examples/integrations/pi-sdk.mdx +2 -2
  167. package/docs-site/zh/explanation/adapter.mdx +19 -19
  168. package/docs-site/zh/explanation/assert.mdx +9 -9
  169. package/docs-site/zh/explanation/drive.mdx +4 -4
  170. package/docs-site/zh/explanation/evals.mdx +8 -8
  171. package/docs-site/zh/explanation/experiment.mdx +8 -8
  172. package/docs-site/zh/explanation/hitl.mdx +13 -13
  173. package/docs-site/zh/explanation/judge.mdx +3 -3
  174. package/docs-site/zh/explanation/overview.mdx +7 -7
  175. package/docs-site/zh/explanation/runner.mdx +11 -11
  176. package/docs-site/zh/explanation/tier.mdx +6 -6
  177. package/docs-site/zh/index.mdx +14 -14
  178. package/docs-site/zh/introduction.mdx +13 -16
  179. package/docs-site/zh/reference/builtin-agents.mdx +61 -28
  180. package/docs-site/zh/reference/capabilities.mdx +7 -27
  181. package/docs-site/zh/reference/cli.mdx +35 -32
  182. package/docs-site/zh/reference/define-agent.mdx +32 -31
  183. package/docs-site/zh/reference/define-config.mdx +6 -6
  184. package/docs-site/zh/reference/define-eval.mdx +33 -20
  185. package/docs-site/zh/reference/events.mdx +4 -4
  186. package/docs-site/zh/reference/expect.mdx +3 -3
  187. package/docs-site/zh/reference/official-adapters.mdx +17 -17
  188. package/docs-site/zh/reference/report-components.mdx +193 -121
  189. package/docs-site/zh/reference/results-data.mdx +13 -13
  190. package/docs-site/zh/troubleshooting/debug-sandbox.mdx +11 -11
  191. package/docs-site/zh/troubleshooting/debugging.mdx +40 -16
  192. package/docs-site/zh/{how-to → tutorials}/agent-feedback-loop.mdx +38 -38
  193. package/docs-site/zh/tutorials/agent-onboarding.mdx +100 -0
  194. package/docs-site/zh/tutorials/authoring.mdx +211 -0
  195. package/docs-site/zh/{how-to → tutorials}/ci-integration.mdx +8 -8
  196. package/docs-site/zh/{how-to → tutorials}/connect-otel.mdx +22 -22
  197. package/docs-site/zh/{how-to → tutorials}/connect-your-agent.mdx +58 -63
  198. package/docs-site/zh/tutorials/custom-reports.mdx +453 -0
  199. package/docs-site/zh/{how-to → tutorials}/dataset-fanout.mdx +4 -4
  200. package/docs-site/zh/tutorials/experiments.mdx +103 -0
  201. package/docs-site/zh/{how-to → tutorials}/fixtures.mdx +9 -9
  202. package/docs-site/zh/{how-to → tutorials}/publish-report.mdx +6 -6
  203. package/docs-site/zh/tutorials/quickstart.mdx +18 -18
  204. package/docs-site/zh/{how-to → tutorials}/reporters.mdx +6 -6
  205. package/docs-site/zh/{how-to → tutorials}/sandbox-agent.mdx +6 -6
  206. package/docs-site/zh/{how-to → tutorials}/sandbox-providers.mdx +41 -19
  207. package/docs-site/zh/{how-to → tutorials}/scoring-guide.mdx +4 -4
  208. package/docs-site/zh/{how-to → tutorials}/viewing-results.mdx +49 -49
  209. package/docs-site/zh/tutorials/write-experiment.mdx +355 -0
  210. package/docs-site/zh/{how-to → tutorials}/write-send.mdx +40 -40
  211. package/package.json +8 -4
  212. package/src/agents/bub.ts +21 -8
  213. package/src/agents/claude-code.ts +23 -10
  214. package/src/agents/codex.test.ts +22 -7
  215. package/src/agents/codex.ts +22 -9
  216. package/src/agents/index.ts +2 -2
  217. package/src/agents/openai-compat.ts +1 -1
  218. package/src/agents/post-setup.ts +45 -22
  219. package/src/agents/streaming.ts +1 -1
  220. package/src/agents/types.ts +20 -17
  221. package/src/agents/ui-message-stream.test.ts +10 -0
  222. package/src/agents/ui-message-stream.ts +12 -1
  223. package/src/cli.ts +71 -57
  224. package/src/context/types.ts +21 -21
  225. package/src/define.ts +13 -0
  226. package/src/i18n/en.ts +27 -12
  227. package/src/i18n/zh-CN.ts +27 -12
  228. package/src/index.ts +2 -0
  229. package/src/report/{react → assets}/colors.ts +22 -0
  230. package/src/report/{react → assets}/enhance.js +1 -33
  231. package/src/report/{react → assets}/styles.css +124 -106
  232. package/src/report/built-in/index.tsx +2 -2
  233. package/src/report/built-in/standard.tsx +18 -6
  234. package/src/report/components/attempt-detail/AttemptAssertions.tsx +67 -0
  235. package/src/report/components/attempt-detail/AttemptConversation.tsx +110 -0
  236. package/src/report/components/attempt-detail/AttemptDiagnostics.tsx +38 -0
  237. package/src/report/components/attempt-detail/AttemptDiff.tsx +35 -0
  238. package/src/report/components/attempt-detail/AttemptError.tsx +31 -0
  239. package/src/report/components/attempt-detail/AttemptFixPrompt.tsx +26 -0
  240. package/src/report/components/attempt-detail/AttemptSource.tsx +80 -0
  241. package/src/report/components/attempt-detail/AttemptSummary.tsx +74 -0
  242. package/src/report/components/attempt-detail/AttemptTimeline.tsx +108 -0
  243. package/src/report/components/attempt-detail/AttemptTrace.tsx +63 -0
  244. package/src/report/components/attempt-detail/AttemptUsage.tsx +29 -0
  245. package/src/report/components/attempt-detail/attempt-components.test.tsx +680 -0
  246. package/src/report/components/attempt-detail/compute.ts +287 -0
  247. package/src/report/components/attempt-detail/faces.ts +257 -0
  248. package/src/report/components/attempt-detail/index.tsx +583 -0
  249. package/src/report/components/attempt-detail/validate.test.ts +235 -0
  250. package/src/report/{react → components}/cell.tsx +6 -3
  251. package/src/report/{report.test.ts → components/compute.test.ts} +316 -46
  252. package/src/report/{react → components/entity-lists}/AttemptList.tsx +24 -16
  253. package/src/report/{react → components/entity-lists}/EvalList.tsx +0 -0
  254. package/src/report/{react → components/entity-lists}/ExperimentList.tsx +23 -20
  255. package/src/report/components/entity-lists/compute.ts +196 -0
  256. package/src/report/components/entity-lists/faces.ts +207 -0
  257. package/src/report/components/entity-lists/index.tsx +241 -0
  258. package/src/report/components/entity-lists/validate.test.ts +114 -0
  259. package/src/report/{react → components}/fixtures.ts +2 -2
  260. package/src/report/{react → components/metric-views}/DeltaTable.tsx +5 -5
  261. package/src/report/{react → components/metric-views}/MetricBars.tsx +5 -5
  262. package/src/report/{react → components/metric-views}/MetricLine.tsx +9 -6
  263. package/src/report/{react → components/metric-views}/MetricMatrix.tsx +6 -6
  264. package/src/report/{react → components/metric-views}/MetricScatter.tsx +41 -33
  265. package/src/report/{react → components/metric-views}/MetricTable.tsx +6 -6
  266. package/src/report/{react → components/metric-views}/Scoreboard.tsx +4 -4
  267. package/src/report/{compute.ts → components/metric-views/compute.ts} +51 -477
  268. package/src/report/components/metric-views/faces.ts +423 -0
  269. package/src/report/components/metric-views/index.tsx +352 -0
  270. package/src/report/{text → components/metric-views}/plot.ts +1 -1
  271. package/src/report/components/metric-views/validate.test.ts +211 -0
  272. package/src/report/{react → components}/render.test.tsx +47 -17
  273. package/src/report/components/shared-compute.ts +59 -0
  274. package/src/report/components/shared-faces.ts +30 -0
  275. package/src/report/components/shared.ts +192 -0
  276. package/src/report/{react → components/site-components}/CopyFixPrompt.tsx +3 -3
  277. package/src/report/{react → components/site-components}/HeroCard.tsx +3 -3
  278. package/src/report/{react → components/site-components}/ScopeWarnings.tsx +4 -4
  279. package/src/report/{react → components/site-components}/TraceWaterfall.tsx +13 -10
  280. package/src/report/components/site-components/compute.ts +144 -0
  281. package/src/report/components/site-components/faces.ts +80 -0
  282. package/src/report/components/site-components/index.tsx +265 -0
  283. package/src/report/{scope-warnings.ts → components/site-components/scope-warnings.ts} +3 -3
  284. package/src/report/{site-components.test.tsx → components/site-components/site-components.test.tsx} +23 -21
  285. package/src/report/components/site-components/validate.test.ts +89 -0
  286. package/src/report/{react → components/summaries}/ScopeSummary.tsx +26 -11
  287. package/src/report/components/summaries/compute.ts +56 -0
  288. package/src/report/components/summaries/faces.ts +48 -0
  289. package/src/report/components/summaries/index.tsx +127 -0
  290. package/src/report/components/summaries/validate.test.ts +49 -0
  291. package/src/report/definition/grid-layout.test.ts +124 -0
  292. package/src/report/definition/grid-layout.ts +146 -0
  293. package/src/report/{primitives.tsx → definition/primitives.tsx} +168 -18
  294. package/src/report/{report.ts → definition/report.ts} +98 -165
  295. package/src/report/{shell-head.test.ts → definition/shell-head.test.ts} +2 -2
  296. package/src/report/{text/table.ts → definition/table-text.ts} +4 -4
  297. package/src/report/{tree.ts → definition/tree.ts} +56 -20
  298. package/src/report/index.ts +126 -66
  299. package/src/report/{aggregate.ts → model/aggregate.ts} +31 -9
  300. package/src/report/{flag.ts → model/flag.ts} +39 -1
  301. package/src/report/{format.ts → model/format.ts} +59 -5
  302. package/src/report/{locale.ts → model/locale.ts} +34 -36
  303. package/src/report/{metrics.ts → model/metrics.ts} +3 -3
  304. package/src/report/{types.ts → model/types.ts} +143 -22
  305. package/src/report/react/index.tsx +52 -26
  306. package/src/report/{dual-render.test.tsx → runtime/dual-render.test.tsx} +564 -49
  307. package/src/report/runtime/host.test.ts +44 -0
  308. package/src/report/runtime/host.ts +138 -0
  309. package/src/report/{load.ts → runtime/load.ts} +1 -1
  310. package/src/report/runtime/text.ts +192 -0
  311. package/src/report/runtime/web.ts +106 -0
  312. package/src/results/attempt-evidence.ts +5 -1
  313. package/src/results/host-equivalence.test.ts +53 -2
  314. package/src/results/select.ts +29 -5
  315. package/src/runner/attempt.test.ts +48 -1
  316. package/src/runner/attempt.ts +62 -42
  317. package/src/runner/cleanup-timeout.test.ts +16 -0
  318. package/src/runner/cleanup-timeout.ts +23 -0
  319. package/src/runner/discover.ts +1 -2
  320. package/src/runner/eval-selection.test.ts +187 -0
  321. package/src/runner/eval-selection.ts +109 -0
  322. package/src/runner/experiment-cleanup-registry.test.ts +89 -0
  323. package/src/runner/experiment-cleanup-registry.ts +39 -0
  324. package/src/runner/experiment-labels.test.ts +71 -0
  325. package/src/runner/feedback/agent.test.ts +33 -1
  326. package/src/runner/feedback/agent.ts +12 -16
  327. package/src/runner/feedback/ci.test.ts +35 -1
  328. package/src/runner/feedback/ci.ts +16 -18
  329. package/src/runner/feedback/coordinator.ts +28 -0
  330. package/src/runner/feedback/human.test.ts +108 -1
  331. package/src/runner/feedback/human.ts +71 -21
  332. package/src/runner/feedback/reducer.test.ts +64 -0
  333. package/src/runner/feedback/reducer.ts +26 -0
  334. package/src/runner/feedback/sink.ts +40 -1
  335. package/src/runner/fingerprint.ts +2 -1
  336. package/src/runner/report.test.ts +14 -0
  337. package/src/runner/report.ts +3 -1
  338. package/src/runner/run.test.ts +390 -12
  339. package/src/runner/run.ts +259 -26
  340. package/src/runner/sandbox-selection.test.ts +13 -3
  341. package/src/runner/sandbox-selection.ts +4 -2
  342. package/src/runner/types.ts +158 -23
  343. package/src/sandbox/docker.ts +7 -0
  344. package/src/sandbox/e2b.ts +12 -13
  345. package/src/sandbox/types.ts +23 -21
  346. package/src/scoring/display.test.ts +28 -2
  347. package/src/scoring/display.ts +38 -5
  348. package/src/scoring/types.ts +3 -3
  349. package/src/shared/aggregate.test.ts +52 -0
  350. package/src/shared/aggregate.ts +29 -0
  351. package/src/shared/types.ts +6 -1
  352. package/src/show/command.test.ts +34 -0
  353. package/src/show/command.ts +16 -0
  354. package/src/show/compose.ts +1 -1
  355. package/src/show/index.ts +56 -20
  356. package/src/show/render.ts +15 -239
  357. package/src/show/show.test.ts +127 -34
  358. package/src/view/app/App.test.tsx +1 -1
  359. package/src/view/app/App.tsx +119 -47
  360. package/src/view/app/i18n.ts +7 -147
  361. package/src/view/app/lib/attempt-dialog.test.ts +65 -0
  362. package/src/view/app/lib/attempt-dialog.ts +69 -0
  363. package/src/view/app/main.tsx +0 -1
  364. package/src/view/app/types.ts +3 -86
  365. package/src/view/artifact-serving.test.ts +22 -38
  366. package/src/view/client-dist/app.css +1 -1
  367. package/src/view/client-dist/app.js +15 -22
  368. package/src/view/data.test.ts +48 -36
  369. package/src/view/data.ts +105 -83
  370. package/src/view/index.ts +1 -1
  371. package/src/view/server.ts +32 -2
  372. package/src/view/shared/types.ts +6 -31
  373. package/src/view/site-parity.test.ts +24 -1
  374. package/src/view/site.ts +144 -17
  375. package/src/view/styles.css +0 -805
  376. package/src/view/view-report.test.ts +141 -22
  377. package/dist/report/components.d.ts +0 -179
  378. package/dist/report/components.js +0 -544
  379. package/dist/report/compute.d.ts +0 -139
  380. package/dist/report/react/ExperimentComparison.d.ts +0 -10
  381. package/dist/report/react/ExperimentComparison.js +0 -12
  382. package/dist/report/react/MetricScatter.d.ts +0 -9
  383. package/dist/report/react/format.d.ts +0 -3
  384. package/dist/report/react/format.js +0 -7
  385. package/dist/report/text/faces.d.ts +0 -45
  386. package/dist/report/text/faces.js +0 -671
  387. package/dist/report/web.d.ts +0 -32
  388. package/dist/report/web.js +0 -48
  389. package/docs-site/zh/how-to/authoring.mdx +0 -162
  390. package/docs-site/zh/how-to/custom-reports.mdx +0 -414
  391. package/docs-site/zh/how-to/experiments.mdx +0 -86
  392. package/docs-site/zh/how-to/write-experiment.mdx +0 -164
  393. package/src/report/components.tsx +0 -925
  394. package/src/report/react/ExperimentComparison.tsx +0 -73
  395. package/src/report/react/format.ts +0 -9
  396. package/src/report/text/faces.ts +0 -767
  397. package/src/report/web.ts +0 -77
  398. package/src/show/report-host.test.ts +0 -205
  399. package/src/show/report-host.ts +0 -389
  400. package/src/view/app/components/AttemptModal.tsx +0 -496
  401. package/src/view/app/components/CodeView.test.tsx +0 -142
  402. package/src/view/app/components/CodeView.tsx +0 -310
  403. package/src/view/app/components/CopyControls.tsx +0 -106
  404. package/src/view/app/components/Trace.tsx +0 -100
  405. package/src/view/app/components/Transcript.tsx +0 -157
  406. package/src/view/app/components/ui/badge.tsx +0 -21
  407. package/src/view/app/lib/artifact-url.ts +0 -17
  408. package/src/view/app/lib/attempt-route.test.ts +0 -80
  409. package/src/view/app/lib/attempt-route.ts +0 -52
  410. package/src/view/app/lib/format.ts +0 -70
  411. package/src/view/app/lib/guards.test.ts +0 -108
  412. package/src/view/app/lib/guards.ts +0 -71
  413. package/src/view/app/lib/rows.ts +0 -22
  414. package/src/view/app/lib/transcript-data.tsx +0 -151
  415. package/src/view/app/lib/verdict.ts +0 -23
  416. package/src/view/app/shared.ts +0 -8
  417. /package/dist/report/{react → components/metric-views}/chart-math.d.ts +0 -0
  418. /package/dist/report/{react → components/metric-views}/chart-math.js +0 -0
  419. /package/dist/report/{text → components/metric-views}/plot.d.ts +0 -0
  420. /package/dist/report/{react → components/site-components}/PoweredBy.d.ts +0 -0
  421. /package/dist/report/{react → components/site-components}/PoweredBy.js +0 -0
  422. /package/dist/report/{text/layout.d.ts → model/text-layout.d.ts} +0 -0
  423. /package/dist/report/{text/layout.js → model/text-layout.js} +0 -0
  424. /package/dist/report/{types.js → model/types.js} +0 -0
  425. /package/src/report/{react → components/metric-views}/chart-math.test.ts +0 -0
  426. /package/src/report/{react → components/metric-views}/chart-math.ts +0 -0
  427. /package/src/report/{react → components/site-components}/PoweredBy.tsx +0 -0
  428. /package/src/report/{text/layout.ts → model/text-layout.ts} +0 -0
@@ -0,0 +1,381 @@
1
+ // 指标图形族(MetricTable / MetricMatrix / MetricBars / Scoreboard / MetricScatter /
2
+ // MetricLine / DeltaTable)的 text 面:同一份算好的数据,渲染成终端字符
3
+ // (niceeval show 的形态)。与 web 面共守诚实契约:排序随 better、samples < total 角标、
4
+ // 缺数据 — 不补 0、截断报剩余。零 react、零 IO、纯同步。
5
+ import { formatMetricValue, formatPlainNumber } from "../../model/format.js";
6
+ import { countText, localeText, resolveLocalizedText, resolveMetricLabel } from "../../model/locale.js";
7
+ import { padDisplay, stringWidth, textBar } from "../../model/text-layout.js";
8
+ import { renderTableText } from "../../definition/table-text.js";
9
+ import { renderCharPlot, renderCoordinateTable } from "./plot.js";
10
+ import { cellText, missingText, MISSING_MARK } from "../shared-faces.js";
11
+ // ───────────────────────── MetricTable ─────────────────────────
12
+ export function tableText(data, ctx) {
13
+ const locale = ctx.locale;
14
+ const columns = [
15
+ { key: "dimension", header: data.rowDimension },
16
+ // 指标列的键用序号,不用 metric name —— 维度名和指标名在同一个命名空间里,可能撞键。
17
+ ...data.columns.map((c, i) => ({ key: `metric${i}`, header: resolveMetricLabel(c.label, locale, c.key) })),
18
+ ];
19
+ const rows = data.rows.map((row) => {
20
+ const cells = { dimension: row.key };
21
+ data.columns.forEach((col, i) => {
22
+ const cell = row.cells[col.key];
23
+ cells[`metric${i}`] = cell ? cellText(cell, locale) : null;
24
+ });
25
+ return { key: row.key, cells };
26
+ });
27
+ return renderTableText({ columns: columns, rows, locale }, ctx);
28
+ }
29
+ // ───────────────────────── MetricMatrix ─────────────────────────
30
+ export function matrixText(data, ctx) {
31
+ // 表体全是维度键与 display,没有 chrome 文案;"next:" 是命令提示,不本地化。
32
+ const locale = ctx.locale;
33
+ const rowKeys = [];
34
+ const columnKeys = [];
35
+ const byPosition = new Map();
36
+ for (const entry of data.cells) {
37
+ if (!rowKeys.includes(entry.row))
38
+ rowKeys.push(entry.row);
39
+ if (!columnKeys.includes(entry.column))
40
+ columnKeys.push(entry.column);
41
+ byPosition.set(JSON.stringify([entry.row, entry.column]), entry.cell);
42
+ }
43
+ const columns = [
44
+ { key: "dimension", header: data.rowDimension },
45
+ ...columnKeys.map((column, i) => ({ key: `column${i}`, header: column })),
46
+ ];
47
+ const rows = rowKeys.map((row) => {
48
+ const cells = { dimension: row };
49
+ columnKeys.forEach((column, i) => {
50
+ const cell = byPosition.get(JSON.stringify([row, column]));
51
+ cells[`column${i}`] = cell ? cellText(cell, locale) : null; // 稀疏格子在文本里以 — 呈现,不编数
52
+ });
53
+ return { key: row, cells };
54
+ });
55
+ const table = renderTableText({ columns: columns, rows, locale }, ctx);
56
+ // 下钻命令:行维度是 eval 时,指向最值得看的一行(先挑有缺格的,再挑按 better 最差的)
57
+ if (data.rowDimension !== "eval" || rowKeys.length === 0)
58
+ return table;
59
+ const better = data.metric.better ?? "higher";
60
+ let next;
61
+ let worst;
62
+ for (const row of rowKeys) {
63
+ let sum = 0;
64
+ let count = 0;
65
+ for (const column of columnKeys) {
66
+ const cell = byPosition.get(JSON.stringify([row, column]));
67
+ if (!cell || cell.value === null) {
68
+ next ??= row;
69
+ continue;
70
+ }
71
+ sum += cell.value;
72
+ count += 1;
73
+ }
74
+ if (count > 0) {
75
+ const value = sum / count;
76
+ const isWorse = worst === undefined || (better === "higher" ? value < worst.value : value > worst.value);
77
+ if (isWorse)
78
+ worst = { key: row, value };
79
+ }
80
+ }
81
+ next ??= worst?.key;
82
+ return next === undefined ? table : `${table}\n\nnext: niceeval show ${next}`;
83
+ }
84
+ // ───────────────────────── MetricBars(矩阵数据的另一种摆法)─────────────────────────
85
+ const BAR_WIDTH = 20;
86
+ export function barsText(data, ctx) {
87
+ const locale = ctx.locale;
88
+ const groupKeys = [];
89
+ const seriesKeys = [];
90
+ const byPosition = new Map();
91
+ for (const entry of data.cells) {
92
+ if (!groupKeys.includes(entry.row))
93
+ groupKeys.push(entry.row);
94
+ if (!seriesKeys.includes(entry.column))
95
+ seriesKeys.push(entry.column);
96
+ byPosition.set(JSON.stringify([entry.row, entry.column]), entry.cell);
97
+ }
98
+ const better = data.metric.better ?? "higher";
99
+ // 条长刻度:% 的天然域是 [0,1],其余以全图最大值为满条
100
+ const values = data.cells.map((c) => c.cell.value).filter((v) => v !== null);
101
+ const maxValue = values.length > 0 ? Math.max(...values) : 0;
102
+ const ratioOf = (value) => (data.metric.unit === "%" ? value : maxValue === 0 ? 0 : value / maxValue);
103
+ const seriesWidth = Math.max(...seriesKeys.map((k) => stringWidth(k)), 0);
104
+ const lines = [];
105
+ for (const group of groupKeys) {
106
+ lines.push(group);
107
+ const entries = seriesKeys.map((series) => ({
108
+ series,
109
+ cell: byPosition.get(JSON.stringify([group, series])),
110
+ }));
111
+ // 组内按值排序,方向随 better(缺数据沉底)
112
+ entries.sort((a, b) => {
113
+ const va = a.cell?.value ?? null;
114
+ const vb = b.cell?.value ?? null;
115
+ if (va === null && vb === null)
116
+ return 0;
117
+ if (va === null)
118
+ return 1;
119
+ if (vb === null)
120
+ return -1;
121
+ return better === "lower" ? va - vb : vb - va;
122
+ });
123
+ for (const { series, cell } of entries) {
124
+ const label = padDisplay(series, seriesWidth);
125
+ if (!cell || cell.value === null) {
126
+ lines.push(` ${label} ${MISSING_MARK}`);
127
+ continue;
128
+ }
129
+ lines.push(` ${label} ${textBar(ratioOf(cell.value), BAR_WIDTH)} ${cellText(cell, locale)}`);
130
+ }
131
+ }
132
+ return lines.join("\n");
133
+ }
134
+ // ───────────────────────── Scoreboard ─────────────────────────
135
+ export function scoreboardText(data, ctx) {
136
+ const locale = ctx.locale;
137
+ const subjectKeys = [];
138
+ for (const row of data.rows) {
139
+ for (const subject of row.subjects) {
140
+ if (!subjectKeys.includes(subject.key))
141
+ subjectKeys.push(subject.key);
142
+ }
143
+ }
144
+ const columns = [
145
+ { key: "dimension", header: data.rowDimension },
146
+ { key: "total", header: localeText(locale, "scoreboard.totalText") },
147
+ ...subjectKeys.map((key, i) => ({ key: `subject${i}`, header: key })),
148
+ ];
149
+ const rows = data.rows.map((row) => {
150
+ const totalNotes = [
151
+ ...(row.total.notRun > 0 ? [localeText(locale, "scoreboard.notRunText", { n: row.total.notRun })] : []),
152
+ ...(row.total.unscorable > 0 ? [localeText(locale, "scoreboard.unscorableText", { n: row.total.unscorable })] : []),
153
+ ];
154
+ const cells = {
155
+ dimension: row.key,
156
+ total: `${resolveLocalizedText(row.total.display, locale)}/${data.fullMarks}${totalNotes.length > 0 ? ` ${totalNotes.join(" ")}` : ""}`,
157
+ };
158
+ subjectKeys.forEach((key, i) => {
159
+ const subject = row.subjects.find((s) => s.key === key);
160
+ if (!subject) {
161
+ cells[`subject${i}`] = null;
162
+ return;
163
+ }
164
+ const score = `${formatPlainNumber(subject.earned)}/${formatPlainNumber(subject.possible)}`;
165
+ const notes = [
166
+ ...(subject.notRun > 0 ? [localeText(locale, "scoreboard.notRunText", { n: subject.notRun })] : []),
167
+ ...(subject.unscorable > 0 ? [localeText(locale, "scoreboard.unscorableText", { n: subject.unscorable })] : []),
168
+ ];
169
+ cells[`subject${i}`] = notes.length > 0 ? `${score} ${notes.join(" ")}` : score;
170
+ });
171
+ return { key: row.key, cells };
172
+ });
173
+ const table = renderTableText({ columns: columns, rows, locale }, ctx);
174
+ const footnotes = [];
175
+ if (data.weights.length > 0) {
176
+ const weights = data.weights.map((w) => `${w.prefix} ×${w.weight}`).join(" · ");
177
+ footnotes.push(`${localeText(locale, "scoreboard.weights")} ${weights} · ${localeText(locale, "scoreboard.othersWeight")}`);
178
+ }
179
+ if (data.ignoredEvals > 0)
180
+ footnotes.push(countText(locale, "scoreboard.ignored", data.ignoredEvals));
181
+ return footnotes.length > 0 ? `${table}\n${footnotes.join("\n")}` : table;
182
+ }
183
+ // ───────────────────────── MetricScatter ─────────────────────────
184
+ const POINT_MARKS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
185
+ function axisLabel(col, locale) {
186
+ return resolveMetricLabel(col.label, locale, col.key);
187
+ }
188
+ /**
189
+ * 方向提示:轴向已随 better 反正(lower 反向),「更好」恒指向右上,文案恒为
190
+ * 「越靠右上越好」;仅当 x、y 都声明 better 时显示——任一轴未声明,组件不猜
191
+ * 「更好」朝哪边,整图无提示(返回 undefined)。
192
+ */
193
+ function betterCornerText(x, y, locale) {
194
+ if (x.better === undefined || y.better === undefined)
195
+ return undefined;
196
+ return localeText(locale, "scatter.betterUpperRight");
197
+ }
198
+ /** 轴标题行:"<x label>(越低越好) × <y label>"——better 方向如实标注,不虚构轴向。 */
199
+ function scatterHeading(data, locale) {
200
+ const withBetter = (col) => {
201
+ const label = axisLabel(col, locale);
202
+ if (col.better === undefined)
203
+ return label;
204
+ return `${label}(${localeText(locale, col.better === "lower" ? "table.lowerBetter" : "table.higherBetter")})`;
205
+ };
206
+ return `${withBetter(data.x)} × ${withBetter(data.y)}`;
207
+ }
208
+ /** 位移摘要里的带符号差值;`%` 的差是百分点,单位写 pt(docs/feature/reports/show/default-report.md)。 */
209
+ function signedDelta(value, unit) {
210
+ const text = formatMetricValue(value, unit);
211
+ const signed = value >= 0 ? `+${text}` : text;
212
+ return unit === "%" ? signed.replace("%", "pt") : signed;
213
+ }
214
+ export function scatterText(data, ctx, opts) {
215
+ const locale = ctx.locale;
216
+ const connect = opts?.connect === true && data.seriesDimension !== undefined;
217
+ const drawable = data.rows.filter((r) => r.x.value !== null && r.y.value !== null);
218
+ const missing = data.rows.length - drawable.length;
219
+ const footnotes = [];
220
+ if (missing > 0)
221
+ footnotes.push(countText(locale, "pointsMissing", missing));
222
+ const axes = { x: axisLabel(data.x, locale), y: axisLabel(data.y, locale) };
223
+ // 0 个可画点:x/y 指标没有可用数据(与 web 面同一事实)。
224
+ if (drawable.length === 0) {
225
+ return [localeText(locale, "scatter.noData", axes), ...footnotes].join("\n");
226
+ }
227
+ // 标题行尾标注归类维度(· 按 <series> 归类)。
228
+ const heading = data.seriesDimension !== undefined
229
+ ? `${scatterHeading(data, locale)} · ${localeText(locale, "scatter.groupedBy", { dim: data.seriesDimension })}`
230
+ : scatterHeading(data, locale);
231
+ // 标记分配顺序即图例顺序:series 按显示键字典序、series 内按 x 原始值升序;
232
+ // 无 series 时保持点键字典序(rows 本身已按维度 key 排序)。
233
+ const ordered = data.seriesDimension === undefined
234
+ ? drawable
235
+ : [...drawable].sort((a, b) => {
236
+ const sa = a.series ?? "";
237
+ const sb = b.series ?? "";
238
+ if (sa !== sb)
239
+ return sa < sb ? -1 : 1;
240
+ return a.x.value - b.x.value;
241
+ });
242
+ // 点太密排不下时降级为坐标表,不硬挤
243
+ if (ordered.length > POINT_MARKS.length || ctx.width < 44) {
244
+ const table = renderCoordinateTable(ordered.map((r) => ({
245
+ key: r.key,
246
+ x: resolveLocalizedText(r.x.display, locale),
247
+ y: resolveLocalizedText(r.y.display, locale),
248
+ })), { key: data.pointDimension, x: axes.x, y: axes.y });
249
+ return [heading, "", table, ...footnotes].join("\n");
250
+ }
251
+ const points = ordered.map((r, i) => ({
252
+ mark: POINT_MARKS[i],
253
+ x: r.x.value,
254
+ y: r.y.value,
255
+ }));
256
+ // series 分组(ordered 已按 series、x 排好序);connect 的折线只进 web 面,
257
+ // text 面用图例的 → 串联 + 位移摘要表达同一条线,坐标图内不画折线。
258
+ const rowsBySeries = new Map();
259
+ for (const r of ordered) {
260
+ if (r.series === undefined)
261
+ continue;
262
+ const list = rowsBySeries.get(r.series) ?? [];
263
+ list.push(r);
264
+ rowsBySeries.set(r.series, list);
265
+ }
266
+ const plot = renderCharPlot({
267
+ width: ctx.width,
268
+ points,
269
+ lines: [],
270
+ xLabel: axes.x,
271
+ yLabel: axes.y,
272
+ formatX: (v) => formatMetricValue(v, data.x.unit),
273
+ formatY: (v) => formatMetricValue(v, data.y.unit),
274
+ // 轴方向跟随 better(与 web 面同规则):lower 反向,higher 与未声明正向。
275
+ invertX: data.x.better === "lower",
276
+ invertY: data.y.better === "lower",
277
+ });
278
+ const markByKey = new Map(ordered.map((r, i) => [r.key, POINT_MARKS[i]]));
279
+ let legend;
280
+ if (data.seriesDimension === undefined) {
281
+ legend = ordered.map((r) => `${markByKey.get(r.key)} ${r.key}`).join(" ");
282
+ }
283
+ else {
284
+ // 图例一行一个 series:行首 series 显示键,后接线上各点;connect 用 → 串联并给逐段位移摘要。
285
+ const seriesWidth = Math.max(...[...rowsBySeries.keys()].map(stringWidth));
286
+ const lines = [];
287
+ for (const [series, list] of rowsBySeries) {
288
+ const parts = list.map((r) => `${markByKey.get(r.key)} ${r.key}`);
289
+ lines.push(`${padDisplay(series, seriesWidth)} ${parts.join(connect ? " → " : " ")}`);
290
+ if (connect) {
291
+ for (let i = 1; i < list.length; i++) {
292
+ const a = list[i - 1];
293
+ const b = list[i];
294
+ const dy = signedDelta(b.y.value - a.y.value, data.y.unit);
295
+ const dx = signedDelta(b.x.value - a.x.value, data.x.unit);
296
+ lines.push(`${" ".repeat(seriesWidth + 2)}└ ${axes.y} ${dy} · ${axes.x} ${dx}`);
297
+ }
298
+ }
299
+ }
300
+ legend = lines.join("\n");
301
+ }
302
+ const hint = betterCornerText(data.x, data.y, locale);
303
+ return [heading, plot, "", ...(hint !== undefined ? [hint] : []), legend, ...footnotes].join("\n");
304
+ }
305
+ // ───────────────────────── MetricLine ─────────────────────────
306
+ export function lineText(data, ctx) {
307
+ const locale = ctx.locale;
308
+ const drawable = data.rows.filter((r) => r.x !== null && r.y.value !== null);
309
+ const missing = data.rows.length - drawable.length;
310
+ const footnotes = [];
311
+ if (missing > 0)
312
+ footnotes.push(countText(locale, "pointsMissing", missing));
313
+ if (drawable.length === 0)
314
+ return [missingText(locale), ...footnotes].join("\n");
315
+ const xLabel = resolveMetricLabel(data.x.label, locale, data.x.key);
316
+ // 系列 → 字母;无系列 = 单系列
317
+ const seriesKeys = [];
318
+ for (const r of drawable) {
319
+ const key = r.series ?? "";
320
+ if (!seriesKeys.includes(key))
321
+ seriesKeys.push(key);
322
+ }
323
+ if (seriesKeys.length > POINT_MARKS.length || ctx.width < 44) {
324
+ const table = renderCoordinateTable(drawable.map((r) => ({
325
+ key: r.series !== undefined ? `${r.series} (${r.key})` : r.key,
326
+ x: resolveLocalizedText(r.xDisplay, locale),
327
+ y: resolveLocalizedText(r.y.display, locale),
328
+ })), { key: data.seriesDimension ?? xLabel, x: xLabel, y: axisLabel(data.y, locale) });
329
+ return [table, ...footnotes].join("\n");
330
+ }
331
+ const markOf = (r) => POINT_MARKS[seriesKeys.indexOf(r.series ?? "")];
332
+ const points = drawable.map((r) => ({
333
+ mark: markOf(r),
334
+ x: r.x,
335
+ y: r.y.value,
336
+ }));
337
+ const lines = seriesKeys.map((key) => drawable
338
+ .filter((r) => (r.series ?? "") === key)
339
+ .map((r) => ({ x: r.x, y: r.y.value }))
340
+ .sort((a, b) => a.x - b.x));
341
+ const plot = renderCharPlot({
342
+ width: ctx.width,
343
+ points,
344
+ lines: lines.filter((l) => l.length > 1),
345
+ xLabel,
346
+ yLabel: axisLabel(data.y, locale),
347
+ formatX: (v) => formatMetricValue(v, data.x.unit),
348
+ formatY: (v) => formatMetricValue(v, data.y.unit),
349
+ });
350
+ const legend = seriesKeys
351
+ .map((key, i) => `${POINT_MARKS[i]} ${key === "" ? axisLabel(data.y, locale) : key}`)
352
+ .join(" ");
353
+ return [plot, "", legend, ...footnotes].join("\n");
354
+ }
355
+ // ───────────────────────── DeltaTable ─────────────────────────
356
+ export function deltaText(data, ctx) {
357
+ const locale = ctx.locale;
358
+ // 0 对不是错误:明确空态并报告配对域实验数(派生形态携带;字面形态缺省按 0)。
359
+ if (data.rows.length === 0) {
360
+ return localeText(locale, "delta.empty", { experiments: data.experiments ?? 0 });
361
+ }
362
+ const columns = [
363
+ { key: "pair", header: localeText(locale, "delta.pairHeader") },
364
+ ...data.columns.map((c, i) => ({ key: `metric${i}`, header: resolveMetricLabel(c.label, locale, c.key) })),
365
+ ];
366
+ const rows = data.rows.map((row) => {
367
+ const cells = { pair: resolveLocalizedText(row.label, locale) };
368
+ data.columns.forEach((col, i) => {
369
+ const cell = row.cells[col.key];
370
+ if (!cell) {
371
+ cells[`metric${i}`] = null;
372
+ return;
373
+ }
374
+ const a = cell.a.value === null ? MISSING_MARK : resolveLocalizedText(cell.a.display, locale);
375
+ const b = cell.b.value === null ? MISSING_MARK : resolveLocalizedText(cell.b.display, locale);
376
+ cells[`metric${i}`] = `${a} → ${b} ${resolveLocalizedText(cell.display, locale)}`;
377
+ });
378
+ return { key: row.key, cells };
379
+ });
380
+ return renderTableText({ columns: columns, rows, locale }, ctx);
381
+ }
@@ -0,0 +1,50 @@
1
+ import type { ReportComponent } from "../../definition/tree.ts";
2
+ import type { DeltaData, LineData, MatrixData, ScatterData, ScoreboardData, TableData } from "../../model/types.ts";
3
+ import type { AttemptLocator } from "../../../results/locator.ts";
4
+ import { type ChromeProps, type DataProps, type Validator } from "../shared.ts";
5
+ import { type DeltaTableOptions, type MetricLineOptions, type MetricMatrixOptions, type MetricScatterOptions, type MetricTableOptions, type ScoreboardOptions } from "./compute.ts";
6
+ export declare const validateTableData: Validator;
7
+ export declare const validateMatrixData: Validator;
8
+ export declare const validateScatterData: Validator;
9
+ export declare const validateLineData: Validator;
10
+ export declare const validateScoreboardData: Validator;
11
+ export declare const validateDeltaData: Validator;
12
+ export type MetricTableProps = DataProps<TableData, MetricTableOptions, ChromeProps & {
13
+ /** web 面在表格前渲染过滤输入框(enhance.js 接管);无 JS 时表格内容依旧完整。 */
14
+ filter?: boolean;
15
+ attemptHref?: (locator: AttemptLocator) => string;
16
+ }>;
17
+ /** 榜单:一行一个维度值、一列一个指标,回答「谁整体更好」。 */
18
+ export declare const MetricTable: ReportComponent<MetricTableProps>;
19
+ export type MetricMatrixProps = DataProps<MatrixData, MetricMatrixOptions, ChromeProps & {
20
+ attemptHref?: (locator: AttemptLocator) => string;
21
+ }>;
22
+ export type MetricBarsProps = MetricMatrixProps;
23
+ /** 逐题格子:行 × 列两个维度、格子里一个指标,回答「哪道题谁挂了」。 */
24
+ export declare const MetricMatrix: ReportComponent<MetricMatrixProps>;
25
+ /** 分组条形:同一份矩阵数据的另一种摆法;与 MetricMatrix 写同一份 spec 时只计算一次。 */
26
+ export declare const MetricBars: ReportComponent<MetricBarsProps>;
27
+ export type ScoreboardProps = DataProps<ScoreboardData, ScoreboardOptions, ChromeProps & {
28
+ attemptHref?: (locator: AttemptLocator) => string;
29
+ }>;
30
+ /** 考试成绩单:总分 + 分科小计,固定分母、notRun / unscorable 分开如实报。 */
31
+ export declare const Scoreboard: ReportComponent<ScoreboardProps>;
32
+ type ScatterChrome = ChromeProps & {
33
+ /** series 内按 x 升序成线(呈现,不改变 ScatterData):web 面画折线,text 面在图例给逐段位移摘要;默认 false。 */
34
+ connect?: boolean;
35
+ pointHref?: (row: ScatterData["rows"][number]) => string;
36
+ };
37
+ export type MetricScatterProps = DataProps<ScatterData, MetricScatterOptions, ScatterChrome>;
38
+ /** 两个指标之间的取舍:每个点一个维度值,x / y 各一个指标,series 决定颜色和图例归类。 */
39
+ export declare const MetricScatter: ReportComponent<MetricScatterProps>;
40
+ export type MetricLineProps = DataProps<LineData, MetricLineOptions, ChromeProps & {
41
+ pointHref?: (row: LineData["rows"][number]) => string;
42
+ }>;
43
+ /** 趋势线:x 是 NumericAxis(参数轴),点身份 = (series, x)。 */
44
+ export declare const MetricLine: ReportComponent<MetricLineProps>;
45
+ export type DeltaTableProps = DataProps<DeltaData, DeltaTableOptions, ChromeProps & {
46
+ attemptHref?: (locator: AttemptLocator) => string;
47
+ }>;
48
+ /** 成对对比:每行一对(字面声明或 pairsByFlag 派生),格子里 A、B、Δ 三个值。 */
49
+ export declare const DeltaTable: ReportComponent<DeltaTableProps>;
50
+ export {};