niceeval 0.5.0 → 0.5.2

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.
@@ -82,9 +82,9 @@ niceeval show fixtures/button --diff # sandbox 里的文件改动
82
82
 
83
83
  榜单、单个 eval 与各证据切面的输出长什么样、历史与抖动怎么看(`--history`)、多次 run 的合成口径,都在[查看结果](/zh/guides/viewing-results);要项目自己的口径(考试成绩单、代码行数榜),写一个打到 stdout 的报告脚本,见[自定义报告](/zh/guides/custom-reports)——给 agent 的指引只多一行:跑 `npx tsx scripts/report.ts`,读 stdout。
84
84
 
85
- ## AGENTS.md 指引区块
85
+ ## AGENTS.md / CLAUDE.md 指引区块
86
86
 
87
- 模型的训练数据里没有 NiceEval。`npx niceeval init` 会在项目的 `AGENTS.md` 里写入一个托管区块,告诉 agent 先读随包文档再动手:
87
+ 模型的训练数据里没有 NiceEval。`npx niceeval init` 会写入一个托管区块,告诉 agent 先读随包文档再动手:项目已有 `AGENTS.md` 就写那份;只有 `CLAUDE.md`(没有 `AGENTS.md`)就直接写进 `CLAUDE.md`,不另建重复文件;两者都没有则新建 `AGENTS.md`。`CLAUDE.md` 是指向 `AGENTS.md` 的符号链接时,写入自动落到链接目标,不会分裂成两份内容。
88
88
 
89
89
  ```md
90
90
  <!-- BEGIN:niceeval-agent-rules -->
@@ -100,7 +100,7 @@ artifact files it references are the structured source of truth.
100
100
  <!-- END:niceeval-agent-rules -->
101
101
  ```
102
102
 
103
- 标记之外的内容不会被改动;升级 NiceEval 后重跑 `npx niceeval init` 会刷新标记之内的指引。npm 包只随包发布中文文档(`node_modules/niceeval/docs-site/zh/`)——中文是唯一始终与代码同步的准绳版本,agent 读中文没有障碍,读到的永远是和安装版本一致的行为,而不是训练数据里的旧记忆。
103
+ 标记之外的内容不会被改动;升级 NiceEval 后重跑 `npx niceeval init` 会刷新标记之内的指引,且每次都会重新按上述规则判断该写哪份文件。npm 包只随包发布中文文档(`node_modules/niceeval/docs-site/zh/`)——中文是唯一始终与代码同步的准绳版本,agent 读中文没有障碍,读到的永远是和安装版本一致的行为,而不是训练数据里的旧记忆。
104
104
 
105
105
  ## 报错自带修法
106
106
 
@@ -13,7 +13,7 @@ description: "NiceEval CLI 参考:exp、init、list、clean 和 view 命令,
13
13
  运行命名实验组或配置。可选尾随位置参数按 eval ID 前缀过滤。
14
14
  </Card>
15
15
  <Card title="npx niceeval init" icon="wand-magic-sparkles">
16
- 创建空的 `evals/` 目录和最小的 `niceeval.config.ts`;不生成示例 eval 文件。同时在 `AGENTS.md` 写入/刷新 niceeval 指引区块(见[Agent 反馈闭环](/zh/guides/agent-feedback-loop))。
16
+ 创建空的 `evals/` 目录和最小的 `niceeval.config.ts`;不生成示例 eval 文件。同时写入/刷新 niceeval 指引区块——项目已有 `AGENTS.md` 就写那份,只有 `CLAUDE.md` 就写进 `CLAUDE.md`,都没有则新建 `AGENTS.md`(见[Agent 反馈闭环](/zh/guides/agent-feedback-loop))。
17
17
  </Card>
18
18
  <Card title="npx niceeval list" icon="list">
19
19
  发现并打印所有 eval,不运行。
@@ -87,6 +87,7 @@ npx niceeval exp compare-models weather
87
87
  | `--early-exit` / `--no-early-exit` | boolean | 某个 eval 的一次 attempt 通过后,停止该 eval 剩余的 attempts。 |
88
88
  | `--open` / `--no-open` | boolean | `view` 命令专用:启动后自动打开浏览器(默认行为)。 |
89
89
  | `--help` | boolean | 打印用法说明并退出。 |
90
+ | `--version` | boolean | 打印 niceeval 的版本号并退出。 |
90
91
 
91
92
  {/* GENERATED:END cli-flags */}
92
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niceeval",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Agent-native eval tool — eval agents, services, functions, and coding-agent fixtures",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -64,6 +64,7 @@ interface Flags {
64
64
  out?: string;
65
65
  port?: number;
66
66
  help: boolean;
67
+ version: boolean;
67
68
  // ── show 专属(位置参数仍是 eval id 前缀;这些 flag 选「怎么看」)──
68
69
  transcript: boolean;
69
70
  trace: boolean;
@@ -116,6 +117,7 @@ const FLAG_OPTIONS = {
116
117
  open: { type: "boolean" },
117
118
  "no-open": { type: "boolean" },
118
119
  help: { type: "boolean", short: "h" },
120
+ version: { type: "boolean", short: "v" },
119
121
  } as const;
120
122
 
121
123
  function numberFlag(name: string, raw: string | undefined): number | undefined {
@@ -185,6 +187,7 @@ function parseArgs(argv: string[]): { command: string; positionals: string[]; fl
185
187
  earlyExit: values["no-early-exit"] === true ? false : values["early-exit"] === true ? true : undefined,
186
188
  open: values["no-open"] === true ? false : values.open === true ? true : undefined,
187
189
  help: values.help === true,
190
+ version: values.version === true,
188
191
  transcript: values.transcript === true,
189
192
  trace: values.trace === true,
190
193
  diff: values.diff === true && diffPath === undefined,
@@ -239,7 +242,7 @@ async function loadConfig(cwd: string): Promise<Config> {
239
242
  return mod.default;
240
243
  }
241
244
 
242
- // AGENTS.md 托管区块:告诉在这个项目里干活的 coding agent「niceeval 不在你的训练数据里,
245
+ // AGENTS.md/CLAUDE.md 托管区块:告诉在这个项目里干活的 coding agent「niceeval 不在你的训练数据里,
243
246
  // 先读随包文档,跑完读结构化结果」。随包只发中文准绳版文档(英文站是手工同步、可能滞后,
244
247
  // 不进包,见 package.json 的 files);init 时写入/刷新;标记之外的用户内容永不触碰。
245
248
  const AGENT_RULES_BEGIN = "<!-- BEGIN:niceeval-agent-rules -->";
@@ -256,6 +259,18 @@ const AGENT_RULES_CONTENT = [
256
259
  "artifact files it references are the structured source of truth.",
257
260
  ].join("\n");
258
261
 
262
+ // 优先复用已有的 AGENTS.md;项目只有 CLAUDE.md(没有 AGENTS.md)时改写 CLAUDE.md 本身,
263
+ // 不再另建一份重复文件;两者都没有则新建 AGENTS.md。CLAUDE.md 是指向 AGENTS.md 的符号链接时,
264
+ // existsSync 会 follow 链接——目标存在则直接算作「AGENTS.md 已存在」,写入的还是同一份内容,
265
+ // 不会产生分裂;目标不存在(悬空链接)则落回新建 AGENTS.md,写入后链接自然生效。
266
+ function resolveAgentDocPath(cwd: string): string {
267
+ const agentsPath = join(cwd, "AGENTS.md");
268
+ if (existsSync(agentsPath)) return agentsPath;
269
+ const claudePath = join(cwd, "CLAUDE.md");
270
+ if (existsSync(claudePath)) return claudePath;
271
+ return agentsPath;
272
+ }
273
+
259
274
  async function initProject(cwd: string): Promise<void> {
260
275
  await mkdir(join(cwd, "evals"), { recursive: true });
261
276
  const configPath = join(cwd, "niceeval.config.ts");
@@ -273,10 +288,10 @@ async function initProject(cwd: string): Promise<void> {
273
288
  "utf-8",
274
289
  );
275
290
  }
276
- const agentsPath = join(cwd, "AGENTS.md");
277
- const existing = existsSync(agentsPath) ? await readFile(agentsPath, "utf-8") : "";
291
+ const agentDocPath = resolveAgentDocPath(cwd);
292
+ const existing = existsSync(agentDocPath) ? await readFile(agentDocPath, "utf-8") : "";
278
293
  const next = upsertManagedBlock(existing, AGENT_RULES_BEGIN, AGENT_RULES_END, AGENT_RULES_CONTENT);
279
- if (next !== existing) await writeFile(agentsPath, next, "utf-8");
294
+ if (next !== existing) await writeFile(agentDocPath, next, "utf-8");
280
295
  }
281
296
 
282
297
  async function openBrowser(url: string): Promise<boolean> {
@@ -312,17 +327,28 @@ function evalsFilterFromExperiment(
312
327
  return (id) => expFilter(id) && patternFilter(id);
313
328
  }
314
329
 
330
+ /** package.json 的 version 字段;-v/--version 直接回显这个号。 */
331
+ async function packageVersion(): Promise<string> {
332
+ const raw = await readFile(new URL("../package.json", import.meta.url), "utf-8");
333
+ return (JSON.parse(raw) as { version: string }).version;
334
+ }
335
+
315
336
  async function main(): Promise<void> {
316
337
  const cwd = process.cwd();
317
338
  await loadDotenv(cwd);
318
339
  const { command, positionals, flags } = parseArgs(process.argv.slice(2));
319
340
 
320
- // --help 不需要 config,先于一切命令处理。
341
+ // --help / --version 不需要 config,先于一切命令处理。
321
342
  if (flags.help) {
322
343
  process.stdout.write(t("cli.help"));
323
344
  process.exit(0);
324
345
  }
325
346
 
347
+ if (flags.version) {
348
+ process.stdout.write(`${await packageVersion()}\n`);
349
+ process.exit(0);
350
+ }
351
+
326
352
  if (command === "view") {
327
353
  // 位置参数 = eval id 前缀(收窄报告槽选集);存在的文件路径 = 单文件模式;
328
354
  // 结果目录经 --run 递入;--report 整槽替换报告槽(与 show --report 吃同一个文件)。
package/src/i18n/en.ts CHANGED
@@ -59,7 +59,7 @@ export const en = {
59
59
  "Flags:\n" +
60
60
  " --runs n --max-concurrency n --timeout ms --budget usd --tag t\n" +
61
61
  " --early-exit / --no-early-exit --strict --force --dry --quiet\n" +
62
- " --junit path --out dir --port n --open / --no-open -h, --help\n\n" +
62
+ " --junit path --out dir --port n --open / --no-open -h, --help -v, --version\n\n" +
63
63
  "Positional args only select which evals to run (id prefixes); which agent and\n" +
64
64
  "how to run come from experiments/ + flags. Env overrides (flag > env > config):\n" +
65
65
  " NICEEVAL_RUNS NICEEVAL_MAX_CONCURRENCY NICEEVAL_TIMEOUT NICEEVAL_BUDGET\n",
package/src/i18n/zh-CN.ts CHANGED
@@ -55,7 +55,7 @@ export const zhCN = {
55
55
  "标志:\n" +
56
56
  " --runs n --max-concurrency n --timeout ms --budget usd --tag t\n" +
57
57
  " --early-exit / --no-early-exit --strict --force --dry --quiet\n" +
58
- " --junit path --out dir --port n --open / --no-open -h, --help\n\n" +
58
+ " --junit path --out dir --port n --open / --no-open -h, --help -v, --version\n\n" +
59
59
  "位置参数只选「跑哪些 eval」(id 前缀);对着哪个 agent、怎么跑来自 experiments/ 与\n" +
60
60
  "标志。环境变量覆盖(标志 > 环境变量 > config):\n" +
61
61
  " NICEEVAL_RUNS NICEEVAL_MAX_CONCURRENCY NICEEVAL_TIMEOUT NICEEVAL_BUDGET\n",