niceeval 0.1.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/README.md +164 -0
- package/README.zh.md +160 -0
- package/bin/niceeval.js +11 -0
- package/package.json +96 -0
- package/src/agents/bub.ts +223 -0
- package/src/agents/builtin.ts +6 -0
- package/src/agents/claude-code.ts +96 -0
- package/src/agents/codex.ts +122 -0
- package/src/agents/index.ts +25 -0
- package/src/agents/shared.ts +145 -0
- package/src/cli.ts +421 -0
- package/src/context/context.test.ts +96 -0
- package/src/context/context.ts +427 -0
- package/src/context/control-flow.ts +27 -0
- package/src/context/session.ts +124 -0
- package/src/define.ts +112 -0
- package/src/expect/index.ts +243 -0
- package/src/i18n/en.ts +131 -0
- package/src/i18n/index.ts +39 -0
- package/src/i18n/zh-CN.ts +132 -0
- package/src/index.ts +39 -0
- package/src/loaders/index.ts +56 -0
- package/src/o11y/cost.ts +57 -0
- package/src/o11y/derive.ts +304 -0
- package/src/o11y/otlp/canonical.ts +112 -0
- package/src/o11y/otlp/mappers/bub.ts +30 -0
- package/src/o11y/otlp/mappers/codex.ts +38 -0
- package/src/o11y/otlp/mappers/index.ts +25 -0
- package/src/o11y/otlp/parse.ts +330 -0
- package/src/o11y/otlp/receiver.ts +100 -0
- package/src/o11y/otlp/sandbox-receiver.ts +113 -0
- package/src/o11y/otlp/select.ts +82 -0
- package/src/o11y/parsers/bub.ts +240 -0
- package/src/o11y/parsers/claude-code.ts +270 -0
- package/src/o11y/parsers/codex.ts +480 -0
- package/src/o11y/parsers/index.ts +37 -0
- package/src/o11y/prices.json +9873 -0
- package/src/runner/discover.ts +77 -0
- package/src/runner/reporters/artifacts.ts +81 -0
- package/src/runner/reporters/console.ts +76 -0
- package/src/runner/reporters/index.ts +5 -0
- package/src/runner/reporters/json.ts +52 -0
- package/src/runner/reporters/live.ts +178 -0
- package/src/runner/reporters/table.ts +328 -0
- package/src/runner/run.ts +860 -0
- package/src/runner/sandbox-prep.ts +91 -0
- package/src/sandbox/checkpoint.ts +39 -0
- package/src/sandbox/docker.ts +539 -0
- package/src/sandbox/e2b.ts +203 -0
- package/src/sandbox/index.ts +25 -0
- package/src/sandbox/registry.ts +60 -0
- package/src/sandbox/resolve.ts +131 -0
- package/src/sandbox/source-files.ts +30 -0
- package/src/sandbox/vercel.ts +236 -0
- package/src/scoring/collector.ts +113 -0
- package/src/scoring/judge.ts +236 -0
- package/src/scoring/scoped.ts +289 -0
- package/src/scoring/verdict.ts +20 -0
- package/src/source-loc.ts +53 -0
- package/src/types.ts +913 -0
- package/src/util.test.ts +31 -0
- package/src/util.ts +50 -0
- package/src/view/app/App.tsx +189 -0
- package/src/view/app/components/AttemptModal.tsx +66 -0
- package/src/view/app/components/CodeView.tsx +272 -0
- package/src/view/app/components/CopyControls.tsx +89 -0
- package/src/view/app/components/ExperimentTable.tsx +266 -0
- package/src/view/app/components/GroupSelector.tsx +61 -0
- package/src/view/app/components/LazyArtifact.tsx +50 -0
- package/src/view/app/components/Trace.tsx +100 -0
- package/src/view/app/components/Transcript.tsx +130 -0
- package/src/view/app/components/primitives.tsx +43 -0
- package/src/view/app/components/ui/badge.tsx +21 -0
- package/src/view/app/components/ui/dialog.tsx +34 -0
- package/src/view/app/components/ui/tabs.tsx +30 -0
- package/src/view/app/i18n.ts +341 -0
- package/src/view/app/index.html +13 -0
- package/src/view/app/lib/cn.ts +7 -0
- package/src/view/app/lib/format.ts +73 -0
- package/src/view/app/lib/guards.ts +61 -0
- package/src/view/app/lib/outcome.ts +96 -0
- package/src/view/app/lib/rows.ts +63 -0
- package/src/view/app/lib/transcript-data.tsx +121 -0
- package/src/view/app/main.tsx +17 -0
- package/src/view/app/pages/RunsPage.tsx +83 -0
- package/src/view/app/pages/TracesPage.tsx +40 -0
- package/src/view/app/shared.ts +10 -0
- package/src/view/app/types.ts +114 -0
- package/src/view/app/vite.config.ts +26 -0
- package/src/view/client-dist/app.css +2 -0
- package/src/view/client-dist/app.js +56 -0
- package/src/view/index.ts +406 -0
- package/src/view/styles.css +1074 -0
- package/src/view/template.html +15 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// 源码位置回溯:在 `t.send` / 断言落地时(collector.record / SessionManager.send)抓一次
|
|
2
|
+
// 调用栈,挑出**第一帧不属于 niceeval 自身**的位置——也就是用户 eval 里那一行。view 据此把
|
|
3
|
+
// 运行结果(回复 / 分数 / 判决)叠回真实源码行,渲染成 github-diff 式代码视图。
|
|
4
|
+
//
|
|
5
|
+
// 为什么靠栈而不是改 API:这样 `t` 的表面一个字不用动,作者照常写 `t.judge.autoevals...`,
|
|
6
|
+
// 位置在底层免费拿到。tsx 直接跑 .ts,栈里就是真实 .ts 路径+行号(ESM 下是 file:// URL)。
|
|
7
|
+
|
|
8
|
+
import { dirname, relative } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import type { SourceLoc } from "./types.ts";
|
|
11
|
+
|
|
12
|
+
/** niceeval 自身的 src 目录(本文件所在目录);用于把内部帧排除掉。 */
|
|
13
|
+
const SRC_ROOT = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
15
|
+
/** 取 `at … (/abs/file.ts:line:col)` 或 `at file:///abs/file.ts:line:col` 末尾的 路径:行:列。 */
|
|
16
|
+
const FRAME_RE = /(?:\()?([^()]+):(\d+):(\d+)\)?$/;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 回溯当前调用栈,返回第一帧用户代码的位置(相对项目根 cwd 的路径 + 行列)。
|
|
20
|
+
* 抓不到(无栈 / 全是内部帧)返回 undefined——调用方据此优雅降级(loc 可选)。
|
|
21
|
+
*/
|
|
22
|
+
export function captureLoc(): SourceLoc | undefined {
|
|
23
|
+
const stack = new Error().stack;
|
|
24
|
+
if (!stack) return undefined;
|
|
25
|
+
const cwd = process.cwd();
|
|
26
|
+
for (const raw of stack.split("\n")) {
|
|
27
|
+
const line = raw.trim();
|
|
28
|
+
if (!line.startsWith("at ")) continue;
|
|
29
|
+
const m = FRAME_RE.exec(line);
|
|
30
|
+
if (!m) continue;
|
|
31
|
+
let file = m[1]!.trim();
|
|
32
|
+
if (file.startsWith("file://")) {
|
|
33
|
+
try {
|
|
34
|
+
file = fileURLToPath(file);
|
|
35
|
+
} catch {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (isInternalFrame(file)) continue;
|
|
40
|
+
const rel = relative(cwd, file);
|
|
41
|
+
const display = rel && !rel.startsWith("..") ? rel : file;
|
|
42
|
+
return { file: display.split("\\").join("/"), line: Number(m[2]), column: Number(m[3]) };
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 内部帧:node 内建、依赖、niceeval 自身 src、loader 注入的过渡帧。 */
|
|
48
|
+
function isInternalFrame(file: string): boolean {
|
|
49
|
+
if (!file || file.startsWith("node:")) return true;
|
|
50
|
+
if (file.includes("node_modules")) return true;
|
|
51
|
+
if (file === SRC_ROOT || file.startsWith(SRC_ROOT + "/") || file.startsWith(SRC_ROOT + "\\")) return true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|