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.
- package/INDEX.md +55 -0
- package/dist/agents/types.d.ts +317 -0
- package/dist/context/types.d.ts +335 -0
- package/dist/i18n/core.d.ts +11 -0
- package/dist/i18n/en.d.ts +181 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/zh-CN.d.ts +183 -0
- package/dist/o11y/execution-tree.d.ts +103 -0
- package/dist/o11y/otlp/parse.d.ts +3 -0
- package/dist/o11y/otlp/receiver.d.ts +21 -0
- package/dist/o11y/otlp/select.d.ts +22 -0
- package/dist/o11y/otlp/turn-otel.d.ts +43 -0
- package/dist/o11y/types.d.ts +190 -0
- package/dist/report/aggregate.d.ts +57 -0
- package/dist/report/aggregate.js +212 -0
- package/dist/report/built-ins/cost-pass-rate-comparison.d.ts +1 -0
- package/dist/report/built-ins/cost-pass-rate-comparison.js +17 -0
- package/dist/report/built-ins/index.d.ts +1 -0
- package/dist/report/built-ins/index.js +2 -0
- package/dist/report/components.d.ts +178 -0
- package/dist/report/components.js +132 -0
- package/dist/report/compute.d.ts +106 -0
- package/dist/report/compute.js +618 -0
- package/dist/report/flag.d.ts +6 -0
- package/dist/report/flag.js +8 -0
- package/dist/report/format.d.ts +32 -0
- package/dist/report/format.js +126 -0
- package/dist/report/index.d.ts +19 -0
- package/dist/report/index.js +30 -0
- package/dist/report/load.d.ts +12 -0
- package/dist/report/load.js +56 -0
- package/dist/report/locale.d.ts +83 -0
- package/dist/report/locale.js +160 -0
- package/dist/report/metrics.d.ts +21 -0
- package/dist/report/metrics.js +115 -0
- package/dist/report/primitives.d.ts +64 -0
- package/dist/report/primitives.js +113 -0
- package/dist/report/react/AttemptList.d.ts +23 -0
- package/dist/report/react/AttemptList.js +20 -0
- package/dist/report/react/DeltaTable.d.ts +8 -0
- package/dist/report/react/DeltaTable.js +24 -0
- package/dist/report/react/EvalList.d.ts +10 -0
- package/dist/report/react/EvalList.js +0 -0
- package/dist/report/react/ExperimentList.d.ts +10 -0
- package/dist/report/react/ExperimentList.js +15 -0
- package/dist/report/react/GroupSummary.d.ts +8 -0
- package/dist/report/react/GroupSummary.js +8 -0
- package/dist/report/react/MetricBars.d.ts +10 -0
- package/dist/report/react/MetricBars.js +48 -0
- package/dist/report/react/MetricLine.d.ts +9 -0
- package/dist/report/react/MetricLine.js +68 -0
- package/dist/report/react/MetricMatrix.d.ts +10 -0
- package/dist/report/react/MetricMatrix.js +23 -0
- package/dist/report/react/MetricScatter.d.ts +9 -0
- package/dist/report/react/MetricScatter.js +100 -0
- package/dist/report/react/MetricTable.d.ts +11 -0
- package/dist/report/react/MetricTable.js +26 -0
- package/dist/report/react/RunOverview.d.ts +8 -0
- package/dist/report/react/RunOverview.js +12 -0
- package/dist/report/react/Scoreboard.d.ts +8 -0
- package/dist/report/react/Scoreboard.js +26 -0
- package/dist/report/react/cell.d.ts +9 -0
- package/dist/report/react/cell.js +9 -0
- package/dist/report/react/chart-math.d.ts +14 -0
- package/dist/report/react/chart-math.js +68 -0
- package/dist/report/react/colors.d.ts +14 -0
- package/dist/report/react/colors.js +45 -0
- package/dist/report/react/fixtures.d.ts +19 -0
- package/dist/report/react/fixtures.js +393 -0
- package/dist/report/react/format.d.ts +3 -0
- package/dist/report/react/format.js +7 -0
- package/dist/report/react/index.d.ts +6 -0
- package/dist/report/react/index.js +14 -0
- package/dist/report/report.d.ts +24 -0
- package/dist/report/report.js +49 -0
- package/dist/report/text/faces.d.ts +29 -0
- package/dist/report/text/faces.js +503 -0
- package/dist/report/text/layout.d.ts +75 -0
- package/dist/report/text/layout.js +173 -0
- package/dist/report/text/plot.d.ts +37 -0
- package/dist/report/text/plot.js +81 -0
- package/dist/report/text/table.d.ts +8 -0
- package/dist/report/text/table.js +86 -0
- package/dist/report/tree.d.ts +99 -0
- package/dist/report/tree.js +228 -0
- package/dist/report/types.d.ts +420 -0
- package/dist/report/types.js +4 -0
- package/dist/report/web.d.ts +15 -0
- package/dist/report/web.js +37 -0
- package/dist/results/annotated-source.d.ts +61 -0
- package/dist/results/attempt-evidence.d.ts +69 -0
- package/dist/results/attempt-source.d.ts +15 -0
- package/dist/results/locator.d.ts +75 -0
- package/dist/results/locator.js +0 -0
- package/dist/results/select.d.ts +45 -0
- package/dist/results/select.js +230 -0
- package/dist/results/source-hash.d.ts +9 -0
- package/dist/results/types.d.ts +204 -0
- package/dist/runner/eval-source.d.ts +22 -0
- package/dist/runner/fingerprint.d.ts +23 -0
- package/dist/runner/types.d.ts +332 -0
- package/dist/sandbox/docker-stream.d.ts +24 -0
- package/dist/sandbox/docker.d.ts +84 -0
- package/dist/sandbox/e2b.d.ts +31 -0
- package/dist/sandbox/errors.d.ts +4 -0
- package/dist/sandbox/local-files.d.ts +6 -0
- package/dist/sandbox/paths.d.ts +4 -0
- package/dist/sandbox/registry.d.ts +13 -0
- package/dist/sandbox/resolve.d.ts +40 -0
- package/dist/sandbox/retry.d.ts +10 -0
- package/dist/sandbox/shell.d.ts +11 -0
- package/dist/sandbox/source-files.d.ts +13 -0
- package/dist/sandbox/types.d.ts +203 -0
- package/dist/sandbox/vercel.d.ts +37 -0
- package/dist/scoring/types.d.ts +70 -0
- package/dist/shared/aggregate.d.ts +29 -0
- package/dist/shared/aggregate.js +55 -0
- package/dist/shared/types.d.ts +27 -0
- package/dist/shared/verdict.d.ts +27 -0
- package/dist/shared/verdict.js +34 -0
- package/dist/tty-line.d.ts +6 -0
- package/dist/types.d.ts +7 -0
- package/dist/util.d.ts +22 -0
- package/docs-site/zh/concepts/adapter.mdx +9 -4
- package/docs-site/zh/concepts/assert.mdx +8 -8
- package/docs-site/zh/concepts/evals.mdx +5 -5
- package/docs-site/zh/concepts/experiment.mdx +3 -1
- package/docs-site/zh/concepts/judge.mdx +9 -9
- package/docs-site/zh/concepts/overview.mdx +2 -2
- package/docs-site/zh/concepts/tier.mdx +6 -6
- package/docs-site/zh/example/claude-code-codex-plugin.mdx +9 -5
- package/docs-site/zh/example/claude-code-codex-skill.mdx +12 -7
- package/docs-site/zh/guides/agent-feedback-loop.mdx +235 -78
- package/docs-site/zh/guides/connect-otel.mdx +3 -3
- package/docs-site/zh/guides/connect-your-agent.mdx +2 -2
- package/docs-site/zh/guides/custom-reports.mdx +196 -36
- package/docs-site/zh/guides/experiments.mdx +7 -0
- package/docs-site/zh/guides/fixtures.mdx +1 -1
- package/docs-site/zh/guides/official-adapters.mdx +31 -9
- package/docs-site/zh/guides/publish-report.mdx +4 -4
- package/docs-site/zh/guides/report-components.mdx +194 -55
- package/docs-site/zh/guides/reporters.mdx +2 -2
- package/docs-site/zh/guides/results-data.mdx +35 -34
- package/docs-site/zh/guides/runner.mdx +2 -2
- package/docs-site/zh/guides/sandbox-agent.mdx +10 -5
- package/docs-site/zh/guides/sandbox-providers.mdx +102 -0
- package/docs-site/zh/guides/viewing-results.mdx +199 -79
- package/docs-site/zh/guides/write-experiment.mdx +23 -1
- package/docs-site/zh/guides/write-send.mdx +2 -2
- package/docs-site/zh/index.mdx +4 -3
- package/docs-site/zh/introduction.mdx +2 -1
- package/docs-site/zh/quickstart.mdx +5 -3
- package/docs-site/zh/reference/builtin-agents.mdx +38 -13
- package/docs-site/zh/reference/capabilities.mdx +1 -1
- package/docs-site/zh/reference/cli.mdx +36 -13
- package/docs-site/zh/reference/define-agent.mdx +24 -12
- package/docs-site/zh/reference/define-config.mdx +1 -1
- package/docs-site/zh/reference/define-eval.mdx +3 -3
- package/docs-site/zh/reference/events.mdx +7 -1
- package/docs-site/zh/reference/expect.mdx +3 -3
- package/package.json +10 -6
- package/src/agents/bub.ts +134 -43
- package/src/agents/claude-code.test.ts +152 -0
- package/src/agents/claude-code.ts +127 -13
- package/src/agents/codex.test.ts +192 -0
- package/src/agents/codex.ts +151 -12
- package/src/agents/index.ts +11 -3
- package/src/agents/manifest.ts +41 -0
- package/src/agents/plugin-config.test.ts +94 -0
- package/src/agents/shared.ts +33 -2
- package/src/agents/skills.test.ts +214 -0
- package/src/agents/skills.ts +304 -0
- package/src/agents/streaming.ts +5 -5
- package/src/agents/types.ts +62 -2
- package/src/cli.ts +74 -47
- package/src/context/context.test.ts +20 -2
- package/src/context/context.ts +3 -0
- package/src/context/control-flow.ts +1 -1
- package/src/context/session.test.ts +92 -1
- package/src/context/session.ts +26 -1
- package/src/context/types.ts +4 -4
- package/src/define.test.ts +82 -0
- package/src/define.ts +72 -11
- package/src/expect/index.ts +5 -5
- package/src/i18n/en.ts +36 -15
- package/src/i18n/zh-CN.ts +39 -21
- package/src/index.ts +1 -1
- package/src/o11y/execution-tree.test.ts +452 -0
- package/src/o11y/execution-tree.ts +367 -0
- package/src/o11y/otlp/receiver.ts +1 -1
- package/src/o11y/otlp/select.ts +7 -3
- package/src/o11y/parsers/claude-code.test.ts +175 -0
- package/src/o11y/parsers/claude-code.ts +32 -0
- package/src/o11y/types.ts +6 -1
- package/src/report/aggregate.ts +26 -20
- package/src/report/built-in-user-parity.test.tsx +643 -0
- package/src/report/built-ins/cost-pass-rate-comparison.tsx +23 -0
- package/src/report/built-ins/index.ts +2 -0
- package/src/report/components.tsx +223 -50
- package/src/report/compute.ts +358 -53
- package/src/report/dual-render.test.tsx +1125 -0
- package/src/report/flag.ts +1 -1
- package/src/report/format.ts +50 -2
- package/src/report/index.ts +48 -14
- package/src/report/load.ts +1 -1
- package/src/report/locale.ts +206 -0
- package/src/report/metrics.ts +39 -15
- package/src/report/primitives.tsx +100 -2
- package/src/report/react/AttemptList.tsx +115 -0
- package/src/report/react/DeltaTable.tsx +9 -6
- package/src/report/react/EvalList.tsx +0 -0
- package/src/report/react/ExperimentList.tsx +108 -0
- package/src/report/react/GroupSummary.tsx +66 -0
- package/src/report/react/MetricBars.tsx +24 -13
- package/src/report/react/MetricLine.tsx +21 -21
- package/src/report/react/MetricMatrix.tsx +8 -4
- package/src/report/react/MetricScatter.tsx +136 -96
- package/src/report/react/MetricTable.tsx +115 -15
- package/src/report/react/RunOverview.tsx +48 -26
- package/src/report/react/Scoreboard.tsx +15 -7
- package/src/report/react/cell.tsx +18 -9
- package/src/{view/app/lib/chart.ts → report/react/chart-math.ts} +2 -6
- package/src/report/react/colors.ts +24 -15
- package/src/report/react/enhance.js +129 -0
- package/src/report/react/fixtures.ts +163 -34
- package/src/report/react/format.ts +1 -1
- package/src/report/react/index.tsx +22 -6
- package/src/report/react/render.test.tsx +164 -31
- package/src/report/react/styles.css +405 -213
- package/src/report/report.test.ts +403 -94
- package/src/report/report.ts +29 -11
- package/src/report/text/faces.ts +303 -95
- package/src/report/text/layout.ts +76 -11
- package/src/report/text/table.ts +98 -0
- package/src/report/tree.ts +103 -20
- package/src/report/types.ts +196 -25
- package/src/report/web.ts +46 -19
- package/src/results/annotated-source.test.ts +146 -0
- package/src/results/annotated-source.ts +128 -0
- package/src/results/attempt-evidence.test.ts +158 -0
- package/src/results/attempt-evidence.ts +158 -0
- package/src/results/attempt-source.ts +48 -0
- package/src/results/copy.ts +154 -139
- package/src/results/format.ts +54 -47
- package/src/results/host-equivalence.test.ts +527 -0
- package/src/results/index.ts +56 -14
- package/src/results/locator.test.ts +198 -0
- package/src/results/locator.ts +0 -0
- package/src/results/open.ts +392 -175
- package/src/results/results.test.ts +943 -494
- package/src/results/select.ts +129 -23
- package/src/results/skipped-notice.ts +0 -0
- package/src/results/source-hash.ts +28 -0
- package/src/results/types.ts +98 -62
- package/src/results/writer.ts +304 -176
- package/src/runner/attempt.test.ts +170 -0
- package/src/runner/attempt.ts +97 -15
- package/src/runner/discover.test.ts +65 -0
- package/src/runner/discover.ts +6 -2
- package/src/runner/eval-source.test.ts +121 -0
- package/src/runner/eval-source.ts +45 -0
- package/src/runner/fingerprint.ts +54 -1
- package/src/runner/remote-sandbox.ts +1 -1
- package/src/runner/report.test.ts +6 -8
- package/src/runner/report.ts +5 -4
- package/src/runner/reporters/artifacts.ts +27 -41
- package/src/runner/reporters/braintrust.test.ts +3 -3
- package/src/runner/reporters/braintrust.ts +1 -1
- package/src/runner/reporters/console.ts +6 -6
- package/src/runner/reporters/json.ts +4 -4
- package/src/runner/reporters/live.test.ts +56 -0
- package/src/runner/reporters/live.ts +36 -10
- package/src/runner/reporters/quiet.test.ts +66 -0
- package/src/runner/reporters/quiet.ts +49 -0
- package/src/runner/reporters/shared.ts +5 -5
- package/src/runner/reporters/table.ts +17 -17
- package/src/runner/run.ts +61 -102
- package/src/runner/types.ts +43 -32
- package/src/sandbox/checkpoint.ts +1 -1
- package/src/sandbox/docker.ts +15 -2
- package/src/sandbox/e2b.ts +11 -5
- package/src/sandbox/errors.ts +13 -0
- package/src/sandbox/index.ts +3 -3
- package/src/sandbox/local-files.ts +1 -1
- package/src/sandbox/registry.ts +6 -5
- package/src/sandbox/resolve.ts +38 -23
- package/src/sandbox/retry.test.ts +68 -0
- package/src/sandbox/retry.ts +44 -0
- package/src/sandbox/types.ts +69 -28
- package/src/sandbox/vercel.ts +17 -3
- package/src/scoring/collector.ts +3 -3
- package/src/scoring/judge.ts +2 -2
- package/src/scoring/scoped.ts +13 -1
- package/src/scoring/types.ts +7 -7
- package/src/scoring/verdict.ts +4 -4
- package/src/shared/aggregate.ts +23 -3
- package/src/shared/types.ts +2 -2
- package/src/shared/{outcome.ts → verdict.ts} +15 -15
- package/src/show/compose.ts +12 -132
- package/src/show/index.ts +125 -94
- package/src/show/render.ts +660 -160
- package/src/show/show.test.ts +472 -253
- package/src/source-loc.ts +1 -1
- package/src/tty-line.ts +32 -0
- package/src/types.ts +2 -2
- package/src/util.test.ts +21 -1
- package/src/util.ts +5 -1
- package/src/view/app/App.tsx +33 -198
- package/src/view/app/components/AttemptModal.tsx +6 -6
- package/src/view/app/components/CodeView.tsx +2 -2
- package/src/view/app/components/CopyControls.tsx +32 -36
- package/src/view/app/components/SkippedRunsBanner.tsx +140 -0
- package/src/view/app/components/ui/badge.tsx +1 -1
- package/src/view/app/components/ui/dialog.tsx +2 -2
- package/src/view/app/i18n.ts +40 -31
- package/src/view/app/lib/artifact-url.ts +1 -1
- package/src/view/app/lib/attempt-route.test.ts +37 -47
- package/src/view/app/lib/attempt-route.ts +26 -26
- package/src/view/app/lib/rows.ts +9 -112
- package/src/view/app/lib/verdict.ts +25 -0
- package/src/view/app/main.tsx +9 -12
- package/src/view/app/pages/RunsPage.tsx +4 -4
- package/src/view/app/pages/TracesPage.tsx +3 -3
- package/src/view/app/shared.ts +0 -1
- package/src/view/app/types.ts +6 -51
- package/src/view/artifact-serving.test.ts +136 -0
- package/src/view/client-dist/app.css +1 -1
- package/src/view/client-dist/app.js +21 -21
- package/src/view/data.test.ts +214 -143
- package/src/view/data.ts +166 -120
- package/src/view/index.ts +23 -11
- package/src/view/server.ts +52 -17
- package/src/view/shared/types.ts +22 -31
- package/src/view/styles.css +117 -327
- package/src/view/view-report.test.ts +146 -98
- package/docs-site/zh/guides/sandbox-backends.mdx +0 -75
- package/src/report/default-report.tsx +0 -222
- package/src/report/dual-face.test.tsx +0 -527
- package/src/report/react/CaseList.tsx +0 -70
- package/src/view/app/components/CostScoreChart.tsx +0 -147
- package/src/view/app/components/ExperimentTable.tsx +0 -284
- package/src/view/app/components/GroupSelector.tsx +0 -61
- package/src/view/app/components/primitives.tsx +0 -43
- package/src/view/app/lib/outcome.ts +0 -82
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
// DefaultReport:官方水位整块 —— 官方两扇门裸跑时渲染的就是它,零 props、纯声明。
|
|
2
|
-
// 「渲染面纯同步」与它不冲突,靠的是一个数据事实:官方水位(overview、榜单、失败清单)
|
|
3
|
-
// 只读瘦身条目、不碰任何懒加载工件,宿主对着已挑好的选集总是把这份数据备好、经上下文
|
|
4
|
-
// 注入(renderReportToText / renderReportToStaticHtml 里 prepareDefaultReportData)。
|
|
5
|
-
// 它渲染的口径钉死为宿主注入的那份选集 —— 零 props 意味着没有跟随的通道,这是锚点语义:
|
|
6
|
-
// 官方口径与自定义口径并排对照。默认无特权:数据全部来自公开计算函数。
|
|
7
|
-
//
|
|
8
|
-
// text 面即 `niceeval show` 的榜单(docs-site/zh/guides/viewing-results.mdx 的示例块是
|
|
9
|
-
// 行为规范):`Current verdicts` 头标注合成自几个 run、experiment 表带 eval 级折叠的
|
|
10
|
-
// evals 列、Failing 清单每条带判决时间与下钻命令。
|
|
11
|
-
|
|
12
|
-
import { basename } from "node:path";
|
|
13
|
-
import type { Selection } from "../results/index.ts";
|
|
14
|
-
import { foldEvalOutcome } from "../shared/outcome.ts";
|
|
15
|
-
import { defineComponent } from "./tree.ts";
|
|
16
|
-
import type { CaseListData, OverviewData, TableData } from "./types.ts";
|
|
17
|
-
import { caseListData, overviewData, tableData } from "./compute.ts";
|
|
18
|
-
import { attemptCostUSD, costUSD, durationMs, passRate } from "./metrics.ts";
|
|
19
|
-
import { RunOverview, MetricTable, CaseList } from "./components.tsx";
|
|
20
|
-
import { cellText } from "./text/faces.ts";
|
|
21
|
-
import { renderAlignedRows } from "./text/layout.ts";
|
|
22
|
-
|
|
23
|
-
/** 榜单的合成标注与 eval 级折叠(text 面用;与 verdicts/cases 出自同一选集)。 */
|
|
24
|
-
export interface VerdictBoardData {
|
|
25
|
-
/** 判决合成自几个物理 run。 */
|
|
26
|
-
composedFromRuns: number;
|
|
27
|
-
/** 参与合成的最新 run(目录名,即时间戳)。 */
|
|
28
|
-
latestRun?: string;
|
|
29
|
-
/** experiment → eval 级折叠计票(evals 列的 13/15)。 */
|
|
30
|
-
tallies: Record<string, { passedEvals: number; totalEvals: number }>;
|
|
31
|
-
/** eval 级折叠后失败/出错的题,带判决时间;新失败在前。 */
|
|
32
|
-
failing: {
|
|
33
|
-
evalId: string;
|
|
34
|
-
experimentId: string;
|
|
35
|
-
outcome: "failed" | "errored";
|
|
36
|
-
/** 最新 attempt 的第一条失败断言("gate calledTool(...)")或错误摘要。 */
|
|
37
|
-
reason?: string;
|
|
38
|
-
/** 判决产生的时刻(最新 attempt 的 startedAt,缺失退快照时刻)。 */
|
|
39
|
-
verdictAt?: string;
|
|
40
|
-
}[];
|
|
41
|
-
/** limit 之外还有几条,如实报。 */
|
|
42
|
-
failingTruncated: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface DefaultReportData {
|
|
46
|
-
overview: OverviewData;
|
|
47
|
-
/** 现刻榜单:experiment × (passRate, costUSD, durationMs)。 */
|
|
48
|
-
verdicts: TableData;
|
|
49
|
-
cases: CaseListData;
|
|
50
|
-
board: VerdictBoardData;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** 失败清单的出厂截断;完整清单自己摆 <CaseList>(截断如实报剩余)。 */
|
|
54
|
-
const DEFAULT_CASE_LIMIT = 10;
|
|
55
|
-
|
|
56
|
-
function buildBoard(selection: Selection): VerdictBoardData {
|
|
57
|
-
const tallies: VerdictBoardData["tallies"] = {};
|
|
58
|
-
const failing: VerdictBoardData["failing"] = [];
|
|
59
|
-
const runs = new Set<string>();
|
|
60
|
-
let latestRunDir = "";
|
|
61
|
-
|
|
62
|
-
for (const snapshot of selection.snapshots) {
|
|
63
|
-
let passedEvals = 0;
|
|
64
|
-
for (const ev of snapshot.evals) {
|
|
65
|
-
for (const attempt of ev.attempts) {
|
|
66
|
-
runs.add(attempt.runDir.dir);
|
|
67
|
-
if (attempt.runDir.dir > latestRunDir) latestRunDir = attempt.runDir.dir;
|
|
68
|
-
}
|
|
69
|
-
const outcome = foldEvalOutcome(ev.attempts.map((a) => a.result));
|
|
70
|
-
if (outcome === "passed") {
|
|
71
|
-
passedEvals += 1;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (outcome !== "failed" && outcome !== "errored") continue;
|
|
75
|
-
const latest = ev.attempts.reduce((a, b) => (b.result.attempt >= a.result.attempt ? b : a));
|
|
76
|
-
const failedAssertion = latest.result.assertions.find((a) => !a.passed);
|
|
77
|
-
const reason = failedAssertion
|
|
78
|
-
? `${failedAssertion.severity} ${failedAssertion.name}`
|
|
79
|
-
: latest.result.error !== undefined
|
|
80
|
-
? `error: ${latest.result.error}`
|
|
81
|
-
: undefined;
|
|
82
|
-
failing.push({
|
|
83
|
-
evalId: ev.id,
|
|
84
|
-
experimentId: snapshot.experimentId,
|
|
85
|
-
outcome,
|
|
86
|
-
...(reason !== undefined ? { reason } : {}),
|
|
87
|
-
...(latest.result.startedAt !== undefined || snapshot.startedAt
|
|
88
|
-
? { verdictAt: latest.result.startedAt ?? snapshot.startedAt }
|
|
89
|
-
: {}),
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
tallies[snapshot.experimentId] = { passedEvals, totalEvals: snapshot.evals.length };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
failing.sort((a, b) => (b.verdictAt ?? "").localeCompare(a.verdictAt ?? ""));
|
|
96
|
-
const shown = failing.slice(0, DEFAULT_CASE_LIMIT);
|
|
97
|
-
return {
|
|
98
|
-
composedFromRuns: runs.size,
|
|
99
|
-
...(latestRunDir ? { latestRun: basename(latestRunDir) } : {}),
|
|
100
|
-
tallies,
|
|
101
|
-
failing: shown,
|
|
102
|
-
failingTruncated: failing.length - shown.length,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** 宿主渲染前备好官方水位:只读瘦身条目,代价可忽略。 */
|
|
107
|
-
export async function prepareDefaultReportData(selection: Selection): Promise<DefaultReportData> {
|
|
108
|
-
return {
|
|
109
|
-
overview: await overviewData(selection),
|
|
110
|
-
verdicts: await tableData(selection, {
|
|
111
|
-
rows: "experiment",
|
|
112
|
-
columns: [passRate, costUSD, durationMs],
|
|
113
|
-
sort: passRate,
|
|
114
|
-
}),
|
|
115
|
-
cases: await caseListData(selection, { limit: DEFAULT_CASE_LIMIT }),
|
|
116
|
-
board: buildBoard(selection),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let activeData: DefaultReportData | null = null;
|
|
121
|
-
|
|
122
|
-
/** 宿主(与渲染入口)用:在注入好的官方水位下同步渲染。 */
|
|
123
|
-
export function runWithDefaultReportData<T>(data: DefaultReportData, fn: () => T): T {
|
|
124
|
-
const prev = activeData;
|
|
125
|
-
activeData = data;
|
|
126
|
-
try {
|
|
127
|
-
return fn();
|
|
128
|
-
} finally {
|
|
129
|
-
activeData = prev;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function requireData(): DefaultReportData {
|
|
134
|
-
if (!activeData) {
|
|
135
|
-
throw new Error(
|
|
136
|
-
"<DefaultReport /> renders the host-injected selection; render the report via " +
|
|
137
|
-
"`niceeval show --report` / `niceeval view --report` (or renderReportToText / renderReportToStaticHtml). " +
|
|
138
|
-
"Outside a host, compose the same blocks yourself: RunOverview, MetricTable, CaseList.",
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
return activeData;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** 判决时间的相对标注(text 面的 "41s ago";渲染面纯同步,Date.now 不算 IO)。 */
|
|
145
|
-
function agoText(iso: string | undefined, now: number): string {
|
|
146
|
-
if (!iso) return "";
|
|
147
|
-
const ms = now - Date.parse(iso);
|
|
148
|
-
if (!Number.isFinite(ms) || ms < 10_000) return "just now";
|
|
149
|
-
const seconds = Math.floor(ms / 1000);
|
|
150
|
-
if (seconds < 120) return `${seconds}s ago`;
|
|
151
|
-
const minutes = Math.floor(seconds / 60);
|
|
152
|
-
if (minutes < 120) return `${minutes}m ago`;
|
|
153
|
-
const hours = Math.floor(minutes / 60);
|
|
154
|
-
if (hours < 48) return `${hours}h ago`;
|
|
155
|
-
return `${Math.floor(hours / 24)}d ago`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** show 榜单(viewing-results.mdx「榜单」块):头 + experiment 表 + Failing 清单。 */
|
|
159
|
-
function boardText(data: DefaultReportData): string {
|
|
160
|
-
const { verdicts, board, overview } = data;
|
|
161
|
-
const experiments = verdicts.rows.length;
|
|
162
|
-
const head = [
|
|
163
|
-
"Current verdicts",
|
|
164
|
-
`${experiments} ${experiments === 1 ? "experiment" : "experiments"}`,
|
|
165
|
-
`composed from ${board.composedFromRuns} ${board.composedFromRuns === 1 ? "run" : "runs"}`,
|
|
166
|
-
...(board.latestRun ? [`latest ${board.latestRun}`] : []),
|
|
167
|
-
].join(" · ");
|
|
168
|
-
const headBlock = [head, ...overview.warnings.map((w) => `! ${w.message}`)].join("\n");
|
|
169
|
-
|
|
170
|
-
// 表:experiment | evals(eval 级折叠计票)| pass | cost | duration(顺序随 verdicts 预排)
|
|
171
|
-
const header = [verdicts.dimension, "evals", "pass", "cost", "duration"];
|
|
172
|
-
const rows = verdicts.rows.map((row) => {
|
|
173
|
-
const tally = board.tallies[row.key];
|
|
174
|
-
const cells = row.cells as Record<string, TableData["rows"][number]["cells"][string]>;
|
|
175
|
-
return [
|
|
176
|
-
row.key,
|
|
177
|
-
tally ? `${tally.passedEvals}/${tally.totalEvals}` : "—",
|
|
178
|
-
cells[passRate.name] ? cellText(cells[passRate.name]) : "—",
|
|
179
|
-
cells[costUSD.name] ? cellText(cells[costUSD.name]) : "—",
|
|
180
|
-
cells[durationMs.name] ? cellText(cells[durationMs.name]) : "—",
|
|
181
|
-
];
|
|
182
|
-
});
|
|
183
|
-
const table = renderAlignedRows([header, ...rows]);
|
|
184
|
-
|
|
185
|
-
const blocks = [headBlock, table];
|
|
186
|
-
if (board.failing.length > 0) {
|
|
187
|
-
const now = Date.now();
|
|
188
|
-
const aligned = renderAlignedRows(
|
|
189
|
-
board.failing.map((f) => [
|
|
190
|
-
`✗ ${f.evalId}`,
|
|
191
|
-
f.experimentId,
|
|
192
|
-
f.reason ?? f.outcome,
|
|
193
|
-
agoText(f.verdictAt, now),
|
|
194
|
-
]),
|
|
195
|
-
).split("\n");
|
|
196
|
-
const lines: string[] = ["Failing:"];
|
|
197
|
-
board.failing.forEach((f, i) => {
|
|
198
|
-
lines.push(` ${aligned[i]}`);
|
|
199
|
-
lines.push(` → niceeval show ${f.evalId}`);
|
|
200
|
-
});
|
|
201
|
-
if (board.failingTruncated > 0) lines.push(` (${board.failingTruncated} more not shown)`);
|
|
202
|
-
blocks.push(lines.join("\n"));
|
|
203
|
-
}
|
|
204
|
-
return blocks.join("\n\n");
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export const DefaultReport = defineComponent<Record<string, never>>({
|
|
208
|
-
web() {
|
|
209
|
-
const data = requireData();
|
|
210
|
-
return (
|
|
211
|
-
<div className="nre nre-default-report">
|
|
212
|
-
<RunOverview data={data.overview} />
|
|
213
|
-
<MetricTable data={data.verdicts} />
|
|
214
|
-
{data.cases.rows.length > 0 && <CaseList data={data.cases} />}
|
|
215
|
-
</div>
|
|
216
|
-
);
|
|
217
|
-
},
|
|
218
|
-
text() {
|
|
219
|
-
return boardText(requireData());
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
DefaultReport.displayName = "DefaultReport";
|