oh-my-knowledge 0.18.0 → 0.19.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 (47) hide show
  1. package/README.md +399 -326
  2. package/README.zh.md +724 -0
  3. package/dist/src/cli.js +21 -13
  4. package/dist/src/cli.js.map +1 -1
  5. package/dist/src/eval-core/evaluation-job.d.ts +3 -1
  6. package/dist/src/eval-core/evaluation-job.d.ts.map +1 -1
  7. package/dist/src/eval-core/evaluation-job.js +3 -1
  8. package/dist/src/eval-core/evaluation-job.js.map +1 -1
  9. package/dist/src/eval-workflows/each-evaluation-workflow.d.ts +7 -3
  10. package/dist/src/eval-workflows/each-evaluation-workflow.d.ts.map +1 -1
  11. package/dist/src/eval-workflows/each-evaluation-workflow.js +7 -2
  12. package/dist/src/eval-workflows/each-evaluation-workflow.js.map +1 -1
  13. package/dist/src/eval-workflows/evaluation-pipeline.d.ts +5 -1
  14. package/dist/src/eval-workflows/evaluation-pipeline.d.ts.map +1 -1
  15. package/dist/src/eval-workflows/evaluation-pipeline.js +6 -2
  16. package/dist/src/eval-workflows/evaluation-pipeline.js.map +1 -1
  17. package/dist/src/eval-workflows/run-evaluation.d.ts +8 -2
  18. package/dist/src/eval-workflows/run-evaluation.d.ts.map +1 -1
  19. package/dist/src/eval-workflows/run-evaluation.js +11 -3
  20. package/dist/src/eval-workflows/run-evaluation.js.map +1 -1
  21. package/dist/src/observability/{production-analyzer.d.ts → skill-health-analyzer.d.ts} +24 -2
  22. package/dist/src/observability/skill-health-analyzer.d.ts.map +1 -0
  23. package/dist/src/observability/{production-analyzer.js → skill-health-analyzer.js} +61 -6
  24. package/dist/src/observability/skill-health-analyzer.js.map +1 -0
  25. package/dist/src/observability/trace-adapter.d.ts.map +1 -1
  26. package/dist/src/observability/trace-adapter.js +27 -1
  27. package/dist/src/observability/trace-adapter.js.map +1 -1
  28. package/dist/src/renderer/html-renderer.d.ts.map +1 -1
  29. package/dist/src/renderer/html-renderer.js +25 -3
  30. package/dist/src/renderer/html-renderer.js.map +1 -1
  31. package/dist/src/renderer/layout.d.ts.map +1 -1
  32. package/dist/src/renderer/layout.js +106 -0
  33. package/dist/src/renderer/layout.js.map +1 -1
  34. package/dist/src/renderer/skill-health-renderer.d.ts +2 -2
  35. package/dist/src/renderer/skill-health-renderer.d.ts.map +1 -1
  36. package/dist/src/renderer/skill-health-renderer.js +39 -4
  37. package/dist/src/renderer/skill-health-renderer.js.map +1 -1
  38. package/dist/src/renderer/summary.js +1 -1
  39. package/dist/src/server/report-server.d.ts +2 -1
  40. package/dist/src/server/report-server.d.ts.map +1 -1
  41. package/dist/src/server/report-server.js +397 -2
  42. package/dist/src/server/report-server.js.map +1 -1
  43. package/dist/src/types.d.ts +6 -0
  44. package/dist/src/types.d.ts.map +1 -1
  45. package/package.json +10 -3
  46. package/dist/src/observability/production-analyzer.d.ts.map +0 -1
  47. package/dist/src/observability/production-analyzer.js.map +0 -1
package/README.md CHANGED
@@ -1,103 +1,118 @@
1
1
  # oh-my-knowledge
2
2
 
3
- 知识载体评测工具 — 用客观数据衡量你的 artifact 质量。
3
+ [![npm version](https://img.shields.io/npm/v/oh-my-knowledge.svg)](https://www.npmjs.com/package/oh-my-knowledge)
4
+ [![CI](https://github.com/lizhiyao/oh-my-knowledge/actions/workflows/ci.yml/badge.svg)](https://github.com/lizhiyao/oh-my-knowledge/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
6
+ [![Node.js Version](https://img.shields.io/node/v/oh-my-knowledge.svg)](https://nodejs.org)
4
7
 
5
- **固定模型,只变知识载体,数据说话。**
8
+ **English** | [简体中文](./README.zh.md)
6
9
 
7
- ## 为什么需要这个工具
10
+ Knowledge-artifact evaluation toolkit — measure your artifact's quality with objective data.
8
11
 
9
- 做知识工程的团队会产出大量知识载体(当前常见是 skill,也包括 prompt、agent、workflow 等)。当被问到"v2 v1 好在哪"时,需要客观数据而非主观判断。`oh-my-knowledge` 通过控制变量实验解决这个问题:相同模型、相同测试样本,只改变知识载体。
12
+ **Fix the model, vary the knowledge artifact, let the data speak.**
10
13
 
11
- ## 快速开始
14
+ ## Why this tool
15
+
16
+ Teams doing knowledge engineering produce lots of knowledge artifacts (skills today, but also prompts, agents, workflows…). When someone asks "why is v2 better than v1", you need objective data instead of gut feeling. `oh-my-knowledge` solves this with controlled experiments: **same model, same test samples, only the knowledge artifact changes.**
17
+
18
+ ## Key features
19
+
20
+ - **Controlled-variable offline bench** — fix the model and samples, vary only the artifact; works with Claude Code skills, CLAUDE.md prompts, RAG knowledge bases, or any markdown-based instruction
21
+ - **Six-dimension scoring** — separate signals for Fact / Behavior / LLM-judge / Cost / Efficiency / Stability, so a regression in one axis isn't hidden by gains in another
22
+ - **Production session observability** — parse Claude Code session JSONL traces, measure per-skill failure rate, latency, token cost, and knowledge-gap signals on real user sessions
23
+ - **Knowledge-gap detection** — severity-weighted signals (explicit markers / failed searches / hedging language / repeated failures) quantify risk exposure instead of claiming completeness
24
+ - **Pre-merge CI gate** — `omk bench ci` enforces three-layer all-pass (fact + behavior + llm-judge) semantics, catching single-layer regressions a composite score would hide
25
+
26
+ ## Quick start
12
27
 
13
28
  ```bash
14
- # 安装
29
+ # install
15
30
  npm i oh-my-knowledge -g
16
31
 
17
- # 生成评测项目脚手架
32
+ # scaffold an eval project
18
33
  omk bench init my-eval
19
34
  cd my-eval
20
35
 
21
- # 把要对比的 artifact 放到 skills/ 目录
22
- # 方式一:直接放 .md 文件(skills/v1.md, skills/v2.md
23
- # 方式二:放完整 artifact 目录(skills/my-skill-v1/SKILL.md, ...)
24
- # 只放一个 artifact 也行,会自动加 baseline 对照
36
+ # drop the artifacts you want to compare into skills/
37
+ # option 1: plain .md files (skills/v1.md, skills/v2.md)
38
+ # option 2: full artifact dirs (skills/my-skill-v1/SKILL.md, ...)
39
+ # a single artifact also works — baseline is auto-added as control
25
40
 
26
- # 预览评测计划
41
+ # preview the plan
27
42
  omk bench run --dry-run
28
43
 
29
- # 运行评测(自动发现 skills/ 目录下的所有 artifact)
44
+ # run the evaluation (auto-discovers everything under skills/)
30
45
  omk bench run
31
46
  ```
32
47
 
33
- ## Claude Code 中使用
48
+ ## Use inside Claude Code
34
49
 
35
- 安装 omk 后,在 Claude Code 中直接用自然语言交互:
50
+ After installing omk, talk to it in natural language from Claude Code:
36
51
 
37
52
  ```
38
- /omk eval # 评测当前项目的 artifact
39
- /omk evolve # 自动迭代改进 artifact
40
- /omk gen-samples # 生成测试用例
53
+ /omk eval # evaluate the artifact(s) in the current project
54
+ /omk evolve # auto-iterate to improve an artifact
55
+ /omk gen-samples # generate test cases
41
56
  ```
42
57
 
43
- 或直接说"帮我评测 v1 v2 的差异""改进一下这个 artifact"omk 会自动理解意图并调用对应命令。
58
+ You can also just say "compare v1 vs v2 for me" or "improve this artifact"omk picks the right command.
44
59
 
45
- ## 特性
60
+ ## Features
46
61
 
47
- | 特性 | 说明 |
48
- |------|------|
49
- | **18 种断言** | 包含子串、正则、JSON Schema、语义相似度、自定义函数等 |
50
- | **四维评估** | 质量、成本、效率、稳定性四个维度对比 |
51
- | **多执行器** | 支持 Claude CLI / Claude SDK / OpenAI / Gemini 及自定义命令 |
52
- | **MCP URL 获取** | 通过 MCP Server 获取私有文档 URL 内容(SSO 保护的知识库等) |
53
- | **盲测 A/B** | `--blind` 隐藏变体名称,HTML 报告有揭晓按钮 |
54
- | **并行执行** | `--concurrency N` 并行 N 个任务 |
55
- | **多轮方差分析** | `--repeat N` 重复 N 次,计算均值/标准差/置信区间/t 检验 |
56
- | **自动分析** | 检测低区分度断言、均匀分数、全通过/全失败、高成本样本 |
57
- | **可追溯性** | 报告含 CLI 版本、Node 版本、artifact 哈希 |
58
- | **中英切换** | HTML 报告右上角一键切换语言 |
62
+ | Feature | What it does |
63
+ |---|---|
64
+ | **18 assertion types** | substring, regex, JSON Schema, semantic similarity, custom JS function, and more |
65
+ | **Six-dim evaluation** | Fact / Behavior / LLM-judge / Cost / Efficiency / Stability shown independently |
66
+ | **Multi-executor** | Claude CLI / Claude SDK / OpenAI / Gemini / any custom command |
67
+ | **MCP URL fetching** | pull content from private-doc URLs via an MCP server (SSO-protected knowledge bases, etc.) |
68
+ | **Blind A/B** | `--blind` hides variant names; HTML report has a reveal button |
69
+ | **Parallel execution** | `--concurrency N` runs N tasks at once |
70
+ | **Multi-run variance** | `--repeat N` repeats the eval and computes mean / SD / CI / t-test |
71
+ | **Auto analysis** | detects low-discrimination assertions, flat scores, all-pass / all-fail, expensive samples |
72
+ | **Traceability** | reports carry CLI version, Node version, artifact version fingerprint |
73
+ | **EN / ZH switch** | one-click language toggle in the HTML report |
59
74
 
60
- ## 工作原理
75
+ ## How it works
61
76
 
62
- 核心思路:**固定模型 + 固定样本,只变 artifact runtime context**,通过交错调度消除时间漂移,用断言 + LLM 评委双通道评分,再叠加知识缺口信号量化风险敞口。
77
+ Core idea: **fix the model and the samples, vary only the artifact and runtime context**, use interleaved scheduling to cancel time drift, score via assertions + LLM judge (dual channel), then layer on knowledge-gap signals to quantify risk exposure.
63
78
 
64
79
  ```mermaid
65
80
  flowchart TD
66
- subgraph Input["① 输入"]
81
+ subgraph Input["① Input"]
67
82
  S["eval-samples<br/>(JSON / YAML)"]
68
83
  A["artifacts<br/>skills/*.md · SKILL.md<br/>baseline · git:name · @cwd"]
69
84
  end
70
85
 
71
- subgraph Prep["② 预处理(解析与抓取)"]
72
- V["变体解析<br/>variant → artifact + runtime context<br/>(cwd / 项目级 CLAUDE.md / 本地 skills)"]
73
- U["URL 抓取<br/>prompt / context 中的 URL<br/>MCP Server(私有文档) → HTTP"]
86
+ subgraph Prep["② Preprocess (resolve & fetch)"]
87
+ V["variant resolution<br/>variant → artifact + runtime context<br/>(cwd / project CLAUDE.md / local skills)"]
88
+ U["URL fetching<br/>URLs in prompt / context<br/>MCP Server(private docs) → HTTP"]
74
89
  end
75
90
 
76
- subgraph Schedule["③ 交错调度 + 并发"]
91
+ subgraph Schedule["③ Interleaved + concurrent scheduling"]
77
92
  Q["s1-v1 → s1-v2 → s2-v1 → s2-v2 …<br/>--concurrency N · --repeat N"]
78
93
  end
79
94
 
80
- subgraph Exec["④ 执行器(固定模型)"]
81
- E["claude / claude-sdk / openai / gemini<br/>anthropic-api / openai-api / 自定义命令"]
82
- T["claude-sdk 抽取<br/>turns / toolCalls trace"]
95
+ subgraph Exec["④ Executor (fixed model)"]
96
+ E["claude / claude-sdk / openai / gemini<br/>anthropic-api / openai-api / custom"]
97
+ T["claude-sdk extracts<br/>turns / toolCalls trace"]
83
98
  E -.-> T
84
99
  end
85
100
 
86
- subgraph Score["⑤ 双通道评分"]
87
- AS["断言(18 )<br/>内容 / 结构 / 成本 / 延迟<br/>agent: tools_called · turns_min …"]
88
- LS["LLM 评委<br/>rubric · dimensions(多维独立打分)"]
89
- CS["综合分数<br/>断言 & LLM 有则均值"]
101
+ subgraph Score["⑤ Dual-channel scoring"]
102
+ AS["assertions (18 types)<br/>content / structure / cost / latency<br/>agent: tools_called · turns_min …"]
103
+ LS["LLM judge<br/>rubric · dimensions (independent per-dim scores)"]
104
+ CS["composite score<br/>mean of assertion & LLM when both present"]
90
105
  AS --> CS
91
106
  LS --> CS
92
107
  end
93
108
 
94
- subgraph Analyze["⑥ 自动分析 + 知识缺口"]
95
- D["低区分度断言 / 均匀分 / 全通过全失败<br/>高成本样本 · 方差 · t 检验"]
96
- G["知识缺口信号<br/>(风险敞口量化, 不证明完备)"]
109
+ subgraph Analyze["⑥ Auto analysis + knowledge gaps"]
110
+ D["low-discrimination / flat scores / all-pass or all-fail<br/>expensive samples · variance · t-test"]
111
+ G["knowledge-gap signals<br/>(quantify risk exposure, not completeness proof)"]
97
112
  end
98
113
 
99
- subgraph Report["⑦ 报告"]
100
- R["四维: 质量 / 成本 / 效率 / 稳定性<br/>JSON + HTML · 盲测揭晓<br/>CLI/Node/artifact 哈希可追溯"]
114
+ subgraph Report["⑦ Report"]
115
+ R["Six dims: Fact / Behavior / LLM-judge / Cost / Efficiency / Stability<br/>JSON + HTML · blind reveal<br/>CLI/Node/version fingerprint traceable"]
101
116
  end
102
117
 
103
118
  S --> U
@@ -114,72 +129,72 @@ flowchart TD
114
129
  G --> R
115
130
  ```
116
131
 
117
- **关键设计:**
132
+ **Key design choices:**
118
133
 
119
- - **交错调度**消除时间漂移:同一样本的不同 variant 交替发出,而非 v1 全跑完再跑 v2,避免模型负载/网络波动被错误归因给 artifact
120
- - **variant = artifact + runtime context**:`name@cwd` 让对照组可以显式声明"项目目录"这个隐性输入,把"项目级沉淀""显式 artifact 注入"拆开测。
121
- - **双通道评分互补**:断言抓确定性缺陷(必须调用某工具/必须包含某字段),LLM 评委抓主观质量(可读性/完整性),两者都存在时取均值。
122
- - **知识缺口信号**不是评分的一部分,而是一个独立追踪项:它告诉你"这次评测覆盖了多少风险敞口",用于追踪收敛,而非断言知识"完备"。
134
+ - **Interleaved scheduling** removes time drift: different variants of the same sample are dispatched alternately rather than "all of v1 then all of v2", so model load / network jitter can't be mis-attributed to the artifact.
135
+ - **variant = artifact + runtime context**: `name@cwd` lets control groups explicitly declare the "project directory" input, separating "project-level accumulated knowledge" from "explicit artifact injection".
136
+ - **Dual-channel scoring is complementary**: assertions catch deterministic defects (must call tool X, must contain field Y); the LLM judge catches subjective quality (readability, completeness). Mean is taken when both are present.
137
+ - **Knowledge-gap signals** are not part of the score — they are an independent tracking channel that tells you "how much risk exposure this evaluation covered", for convergence tracking, not as a completeness proof.
123
138
 
124
- ## 评测样本格式
139
+ ## Eval sample format
125
140
 
126
- 支持 JSON YAML(`eval-samples.json`、`eval-samples.yaml`、`eval-samples.yml`)。
141
+ Supports JSON and YAML (`eval-samples.json`, `eval-samples.yaml`, `eval-samples.yml`).
127
142
 
128
143
  ```json
129
144
  [
130
145
  {
131
146
  "sample_id": "s001",
132
- "prompt": "审查这段代码的安全性",
147
+ "prompt": "Review this code for security issues",
133
148
  "context": "function auth(u, p) { db.query('SELECT * FROM users WHERE name=' + u); }",
134
- "rubric": "应识别 SQL 注入风险并建议参数化查询",
149
+ "rubric": "Should identify SQL injection risk and recommend parameterized queries",
135
150
  "assertions": [
136
- { "type": "contains", "value": "SQL 注入", "weight": 1 },
137
- { "type": "contains", "value": "参数化", "weight": 1 },
138
- { "type": "not_contains", "value": "没有问题", "weight": 0.5 }
151
+ { "type": "contains", "value": "SQL injection", "weight": 1 },
152
+ { "type": "contains", "value": "parameterized", "weight": 1 },
153
+ { "type": "not_contains", "value": "looks fine", "weight": 0.5 }
139
154
  ],
140
155
  "dimensions": {
141
- "security": "是否识别出注入漏洞",
142
- "actionability": "是否给出可直接使用的修复代码"
156
+ "security": "did it identify the injection vulnerability?",
157
+ "actionability": "did it give directly usable fix code?"
143
158
  }
144
159
  }
145
160
  ]
146
161
  ```
147
162
 
148
- ### 字段说明
163
+ ### Fields
149
164
 
150
- | 字段 | 类型 | 必填 | 说明 |
151
- |------|------|------|------|
152
- | `sample_id` | `string` | **是** | 样本唯一标识 |
153
- | `prompt` | `string` | **是** | 发送给模型的用户提示词 |
154
- | `context` | `string` | | 附加上下文(代码片段等),会被包裹在代码块中拼接到 prompt 后。也支持 URL,运行时自动抓取内容 |
155
- | `rubric` | `string` | | LLM 评委的评分标准(1-5 分) |
156
- | `assertions` | `array` | | 断言检查列表,详见[断言类型](#断言类型) |
157
- | `assertions[].type` | `string` | **是** | 断言类型 |
158
- | `assertions[].value` | `string\|number` | 视类型 | 检查值(`contains`、`min_length`、`cost_max` 等必填) |
159
- | `assertions[].values` | `array` | 视类型 | 字符串数组(`contains_all`、`contains_any` 必填) |
160
- | `assertions[].pattern` | `string` | 视类型 | 正则表达式(`regex` 必填) |
161
- | `assertions[].flags` | `string` | | 正则标志(默认 `"i"`) |
162
- | `assertions[].schema` | `object` | 视类型 | JSON Schema 对象(`json_schema` 必填,基于 [ajv](https://ajv.js.org/) |
163
- | `assertions[].reference` | `string` | 视类型 | 参考文本(`semantic_similarity` 必填) |
164
- | `assertions[].threshold` | `number` | | 语义相似度通过阈值(默认 3 |
165
- | `assertions[].fn` | `string` | 视类型 | 自定义断言 JS 文件路径(`custom` 必填) |
166
- | `assertions[].weight` | `number` | | 权重(默认 1 |
167
- | `dimensions` | `object` | | 多维度评分,key 为维度名,value 为评分标准文本 |
165
+ | Field | Type | Required | Description |
166
+ |---|---|---|---|
167
+ | `sample_id` | `string` | **yes** | Unique sample ID |
168
+ | `prompt` | `string` | **yes** | User prompt sent to the model |
169
+ | `context` | `string` | no | Extra context (e.g. code). Wrapped in a code block and appended to the prompt. URLs are auto-fetched at runtime. |
170
+ | `rubric` | `string` | no | Scoring guideline for the LLM judge (1-5 scale) |
171
+ | `assertions` | `array` | no | Assertion checks; see [assertion types](#assertion-types) |
172
+ | `assertions[].type` | `string` | **yes** | Assertion type |
173
+ | `assertions[].value` | `string\|number` | depends | Check value (required for `contains`, `min_length`, `cost_max`, etc.) |
174
+ | `assertions[].values` | `array` | depends | String array (required for `contains_all`, `contains_any`) |
175
+ | `assertions[].pattern` | `string` | depends | Regex pattern (required for `regex`) |
176
+ | `assertions[].flags` | `string` | no | Regex flags (default `"i"`) |
177
+ | `assertions[].schema` | `object` | depends | JSON Schema object (required for `json_schema`, via [ajv](https://ajv.js.org/)) |
178
+ | `assertions[].reference` | `string` | depends | Reference text (required for `semantic_similarity`) |
179
+ | `assertions[].threshold` | `number` | no | Pass threshold for semantic similarity (default 3) |
180
+ | `assertions[].fn` | `string` | depends | Path to a custom assertion JS file (required for `custom`) |
181
+ | `assertions[].weight` | `number` | no | Weight (default 1) |
182
+ | `dimensions` | `object` | no | Multi-dimension scoring; key = dimension name, value = scoring guideline |
168
183
 
169
- ### URL 自动抓取
184
+ ### URL auto-fetching
170
185
 
171
- `prompt` `context` 中的 URL 会在评测前自动抓取内容并内联到文本中。适用于引用在线文档、API 文档等场景:
186
+ URLs in `prompt` and `context` are auto-fetched before evaluation and inlined into the text. Useful when referencing online docs, API references, etc.:
172
187
 
173
188
  ```json
174
189
  {
175
190
  "sample_id": "s001",
176
- "prompt": "请根据以下 PRD 文档生成测试用例:https://wiki.example.com/prd/feature-x"
191
+ "prompt": "Generate test cases from this PRD: https://wiki.example.com/prd/feature-x"
177
192
  }
178
193
  ```
179
194
 
180
- 运行时,URL 会被替换为实际文档内容。获取顺序:先通过 MCP Server 获取匹配的 URL(如 SSO 保护的私有文档),再通过 HTTP 获取剩余 URL。MCP 已成功的 URL 不会重复 HTTP 抓取。
195
+ At runtime, URLs are replaced with the actual content. Fetch order: MCP Server first for matching URLs (e.g. SSO-protected private docs), then plain HTTP for the rest. URLs already resolved by MCP are not re-fetched via HTTP.
181
196
 
182
- **私有文档 URL**:在项目目录放一个 `.mcp.json` 配置文件,或通过 `--mcp-config` 指定路径:
197
+ **Private-doc URLs**: drop a `.mcp.json` config file into the project dir, or pass `--mcp-config <path>`:
183
198
 
184
199
  ```json
185
200
  {
@@ -202,452 +217,510 @@ flowchart TD
202
217
  }
203
218
  ```
204
219
 
205
- **公网 URL**:直接 HTTP 获取,如果需要认证请确保命令行环境已配置好网络访问(VPN、代理等)。
220
+ **Public URLs**: fetched via plain HTTP. If they require auth, make sure the shell already has network access configured (VPN, proxy, etc.).
206
221
 
207
- ### 评分策略
222
+ ### Scoring strategy
208
223
 
209
- #### 1. 断言评分
224
+ #### 1. Assertion score
210
225
 
211
- 基于规则的本地检查,每个断言产生通过/失败结果。
226
+ Rule-based local checks; each assertion yields pass/fail.
212
227
 
213
- **计算方式:**
228
+ **Formula:**
214
229
 
215
- - 通过率 = 通过断言的权重之和 / 总权重(0~1
216
- - 分数 = 1 + 通过率 × 4(映射到 1~5 分)
217
- - 示例:3 个断言(权重各 1),2 个通过通过率 = 2/3 → 分数 = 1 + 0.67 × 4 = **3.67**
230
+ - Pass rate = sum of passed assertion weights / total weight (01)
231
+ - Score = 1 + pass_rate × 4 (mapped to 15)
232
+ - Example: 3 assertions (weight 1 each), 2 passpass rate 2/3 → score = 1 + 0.67 × 4 = **3.67**
218
233
 
219
- #### 2. Rubric / Dimensions 评分
234
+ #### 2. Rubric / Dimensions score
220
235
 
221
- 评委模型(默认 `haiku`)按标准打 1-5 分。`dimensions` 模式下各维度独立评分后取平均。
236
+ The judge model (default `haiku`) scores 15 against the rubric. In `dimensions` mode, each dimension is scored independently and then averaged.
222
237
 
223
- #### 3. 综合分数
238
+ #### 3. Composite score
224
239
 
225
- | 条件 | 公式 |
226
- |------|------|
227
- | 仅断言 | `assertionScore` |
228
- | LLM | `llmScore` |
229
- | 两者都有 | `(assertionScore + llmScore) / 2` |
230
- | 都没有 | `0` |
240
+ | Condition | Formula |
241
+ |---|---|
242
+ | Only assertions | `assertionScore` |
243
+ | Only LLM judge | `llmScore` |
244
+ | Both present | `(assertionScore + llmScore) / 2` |
245
+ | Neither | `0` |
231
246
 
232
- ### 断言类型
247
+ ### Assertion types
233
248
 
234
- **确定性断言(18 种):**
249
+ **Deterministic assertions (18 total):**
235
250
 
236
- | 类型 | 说明 |
237
- |------|------|
238
- | `contains` / `not_contains` | 包含/不包含子串 |
239
- | `regex` | 正则匹配 |
240
- | `min_length` / `max_length` | 长度范围 |
241
- | `json_valid` / `json_schema` | JSON 校验 |
242
- | `starts_with` / `ends_with` | 前缀/后缀匹配 |
243
- | `equals` / `not_equals` | 精确匹配 |
244
- | `word_count_min` / `word_count_max` | 词数范围 |
245
- | `contains_all` / `contains_any` | 多值匹配 |
246
- | `cost_max` / `latency_max` | 成本/延迟限制 |
247
- | `semantic_similarity` | LLM 语义相似度 |
248
- | `custom` | 自定义 JS 函数(30s 超时) |
251
+ | Type | Description |
252
+ |---|---|
253
+ | `contains` / `not_contains` | substring must / must-not appear |
254
+ | `regex` | regex match |
255
+ | `min_length` / `max_length` | length bounds |
256
+ | `json_valid` / `json_schema` | JSON validation |
257
+ | `starts_with` / `ends_with` | prefix / suffix |
258
+ | `equals` / `not_equals` | exact match |
259
+ | `word_count_min` / `word_count_max` | word-count bounds |
260
+ | `contains_all` / `contains_any` | multi-value match |
261
+ | `cost_max` / `latency_max` | cost / latency caps |
262
+ | `semantic_similarity` | LLM-based semantic similarity |
263
+ | `custom` | custom JS function (30 s timeout) |
249
264
 
250
- ### 自定义断言
265
+ ### Custom assertion
251
266
 
252
267
  ```js
253
268
  // my-assertion.mjs
254
269
  export default function(output, { sample, assertion }) {
255
- return { pass: output.includes('SQL'), message: '检查了 SQL 关键字' };
270
+ return { pass: output.includes('SQL'), message: 'checked for SQL keyword' };
256
271
  }
257
272
  ```
258
273
 
259
- ## 四维评估指标
274
+ ## Six-dim evaluation
260
275
 
261
- 评测报告从四个维度展示结果:
276
+ Reports display results across six independent dimensions. The three scoring layers — Fact / Behavior / LLM-judge — are shown separately so you see **which layer regressed** instead of a single composite number:
262
277
 
263
- | 维度 | 指标 | 说明 |
264
- |------|------|------|
265
- | 📊 **质量** | 综合分数、断言分、LLM 评分、min/max | 基于断言和 LLM 评委的综合评分 |
266
- | 💰 **成本** | 总成本、输入/输出 Token | 基于 Token 消耗和模型定价的 API 费用 |
267
- | **效率** | 平均延迟 (ms) | 从发送请求到收到完整响应的端到端耗时 |
268
- | 🛡️ **稳定性** | 成功率 (%) | 模型调用成功率,失败包括超时、API 错误等 |
278
+ | Dimension | Metric | Description |
279
+ |---|---|---|
280
+ | 📋 **Fact** | fact-assertion pass rate | rule-verifiable assertions like `contains` / `json_schema` / `fact_check`, mapped to 1-5 |
281
+ | 🛠️ **Behavior** | behavior-assertion pass rate | execution-compliance assertions like `tools_called` / `tool_output_contains` / `turns_max` |
282
+ | 💬 **LLM-judge** | rubric score | 1-5 scored by the judge model against a predefined rubric; subjective, catches what rules miss |
283
+ | 💰 **Cost** | total cost, input/output tokens | API cost based on token usage and model pricing |
284
+ | ⚡ **Efficiency** | average latency (ms) | end-to-end latency from request to full response |
285
+ | 🛡️ **Stability** | CV (coefficient of variation) | score consistency across repeated runs (`--repeat ≥ 2`); single-run shows `—`, **honestly acknowledging what can't be measured** |
269
286
 
270
- ## CLI 参考
287
+ ## CLI reference
271
288
 
272
289
  ### `omk bench run`
273
290
 
274
291
  ```bash
275
- omk bench run [选项]
276
-
277
- 选项:
278
- --samples <路径> 样本文件(默认:eval-samples.json,自动检测 .yaml/.yml
279
- --skill-dir <路径> artifact 目录(参数名沿用历史写法,默认:skills
280
- --variants <a,b> 变体名称,不指定时自动从 artifact 目录发现
281
- 只有一个 artifact 时自动加 baseline 对照
282
- 特殊值:baseline(空 artifact)、git:name(git 历史版本)、
283
- git:ref:name(指定 commit)、含 / 的路径(直接读取文件)
284
- --model <名称> 被测模型(默认:sonnet)
285
- --judge-model <名称> 评委模型(默认:haiku)
286
- --output-dir <路径> 输出目录(默认:~/.oh-my-knowledge/reports/)
287
- --no-judge 跳过 LLM 评分
288
- --no-cache 禁用结果缓存(默认开启,相同输入自动复用)
289
- --dry-run 仅预览
290
- --blind 盲测模式
291
- --concurrency <n> 并行任务数(默认:1)
292
- --timeout <秒> 单个任务的执行器超时时间(默认:120)
293
- --repeat <n> 重复 N 次做方差分析(默认:1)
294
- --executor <名称> 执行器(默认:claude),支持自定义命令
295
- --skip-preflight 跳过评测前的模型连通性检查
296
- --mcp-config <路径> MCP 配置文件,用于通过 MCP Server 获取私有文档 URL 内容
297
- (默认:当前目录的 .mcp.json)
298
- --no-serve 评测完成后不自动启动报告服务
299
- --verbose 打印每个样本的详细执行结果(耗时、tokens、输出预览)
300
- --each 批量评测:每个 artifact 独立和 baseline 对比
301
- 需要每个 artifact 配对 {name}.eval-samples.json
302
- ```
303
-
304
- ### `omk bench run --each`(批量评测)
305
-
306
- skills/ 下放了多个**独立的** artifact 时,使用 `--each` 逐个评测,每个 artifact 独立和 baseline 对比,生成一份合并报告。
292
+ omk bench run [options]
293
+
294
+ options:
295
+ --samples <path> sample file (default: eval-samples.json, also detects .yaml/.yml)
296
+ --skill-dir <path> artifact dir (default: skills)
297
+ --control <expr> control-group variant expression (experiment role = control)
298
+ --treatment <v1,v2> treatment-group variant expressions, comma-separated
299
+ at least one of --control / --treatment is required
300
+ (unless you use --config or --each)
301
+ special values: baseline (empty artifact), git:name (git HEAD),
302
+ git:ref:name (specific commit), path with "/" (read file directly)
303
+ --config <path> YAML/JSON config file (evaluation-as-code); declares
304
+ samples + variants + model + executor in one file; CLI
305
+ flags override config fields when both are provided
306
+ --model <name> model under test (default: sonnet)
307
+ --judge-model <name> judge model (default: haiku)
308
+ --output-dir <path> output dir (default: ~/.oh-my-knowledge/reports/)
309
+ --no-judge skip the LLM judge
310
+ --no-cache disable result cache (on by default; identical inputs reuse)
311
+ --dry-run preview only
312
+ --blind blind mode
313
+ --concurrency <n> parallel tasks (default: 1)
314
+ --timeout <sec> per-task executor timeout (default: 120)
315
+ --repeat <n> repeat N times for variance analysis (default: 1)
316
+ --executor <name> executor (default: claude); supports custom commands
317
+ --skip-preflight skip pre-evaluation model reachability check
318
+ --mcp-config <path> MCP config for fetching private-doc URLs via MCP Server
319
+ (default: .mcp.json in cwd)
320
+ --no-serve don't auto-start the report server after the run
321
+ --verbose print per-sample details (duration, tokens, output preview)
322
+ --each batch mode: evaluate each artifact independently vs baseline
323
+ requires {name}.eval-samples.json paired with each artifact
324
+ ```
325
+
326
+ ### `omk bench run --each` (batch mode)
327
+
328
+ When `skills/` contains several **independent** artifacts, use `--each` to evaluate each one against baseline and produce a merged report.
307
329
 
308
330
  ```
309
331
  skills/
310
- ├── asset.md ← artifact 文件
311
- ├── asset.eval-samples.json ← 配对的测试集
332
+ ├── asset.md ← artifact file
333
+ ├── asset.eval-samples.json ← paired samples
312
334
  ├── home.md
313
335
  ├── home.eval-samples.json
314
- └── product/ ← 目录格式也支持
336
+ └── product/ ← directory format also supported
315
337
  ├── SKILL.md
316
338
  └── eval-samples.json
317
339
  ```
318
340
 
319
- 配对规则:
341
+ Pairing rules:
320
342
 
321
- - `{name}.md` → 查找同目录下的 `{name}.eval-samples.json`
322
- - `{name}/SKILL.md` → 查找 `{name}/eval-samples.json`
323
- - 没有配对 eval-samples artifact 会被跳过并打印警告
343
+ - `{name}.md` → looks for `{name}.eval-samples.json` in the same dir
344
+ - `{name}/SKILL.md` → looks for `{name}/eval-samples.json`
345
+ - artifacts without paired samples are skipped with a warning
324
346
 
325
347
  ```bash
326
348
  omk bench run --each
327
349
  omk bench run --each --dry-run
328
350
  ```
329
351
 
330
- ### `omk bench gen-samples`(生成测评用例)
352
+ ### `omk bench gen-samples` (generate test cases)
331
353
 
332
- 读取 artifact 内容,通过 LLM 自动生成 eval-samples。生成后请审查编辑再跑评测。
354
+ Reads an artifact's content and uses an LLM to auto-generate eval-samples. Review and edit them before running eval.
333
355
 
334
356
  ```bash
335
- # 为指定 artifact 生成测试集(输出到 eval-samples.json
357
+ # generate for a specific artifact (writes eval-samples.json)
336
358
  omk bench gen-samples skills/my-skill.md
337
359
 
338
- # skills/ 下所有缺少测试集的 artifact 批量生成
360
+ # batch-generate for every artifact under skills/ that lacks samples
339
361
  omk bench gen-samples --each
340
362
 
341
- # 指定生成数量
363
+ # specify sample count
342
364
  omk bench gen-samples skills/my-skill.md --count 10
343
365
  ```
344
366
 
345
- 选项:
367
+ Options:
346
368
 
347
369
  ```
348
- --each 为所有缺少 eval-samples artifact 批量生成
349
- --count <n> 每个 artifact 生成的样本数(默认:5
350
- --model <名称> 生成用的模型(默认:sonnet
351
- --skill-dir <路径> artifact 目录(参数名沿用历史写法,默认:skills),配合 --each 使用
370
+ --each batch-generate for every artifact missing samples
371
+ --count <n> samples per artifact (default: 5)
372
+ --model <name> model used for generation (default: sonnet)
373
+ --skill-dir <path> artifact dir (default: skills), used with --each
352
374
  ```
353
375
 
354
- ### `omk bench evolve`(自我循环改进)
376
+ ### `omk bench evolve` (self-iterating improvement)
355
377
 
356
- AI 自动迭代 artifact:评测分析弱点 → LLM 改进再评测分数涨了留、没涨扔重复。
378
+ Lets the AI iterate an artifact automatically: evaluate analyze weak spots → LLM rewritesevaluate again keep if the score went up, drop otherwise repeat.
357
379
 
358
380
  ```bash
359
- # 基本用法:迭代 5
381
+ # basic: iterate 5 rounds
360
382
  omk bench evolve skills/my-skill.md
361
383
 
362
- # 指定轮数和目标分数
384
+ # set rounds and target score
363
385
  omk bench evolve skills/my-skill.md --rounds 10 --target 4.5
364
386
  ```
365
387
 
366
- 选项:
388
+ Options:
367
389
 
368
390
  ```
369
- --rounds <n> 最大迭代轮数(默认:5
370
- --target <分数> 目标分数,达到即停
371
- --samples <路径> 样本文件(默认:eval-samples.json
372
- --improve-model <名称> 改进用模型(默认:sonnet
391
+ --rounds <n> max iteration rounds (default: 5)
392
+ --target <score> stop early when the score reaches this threshold
393
+ --samples <path> sample file (default: eval-samples.json)
394
+ --improve-model <name> model used for rewrites (default: sonnet)
373
395
  ```
374
396
 
375
- 每轮产出保存在 `skills/evolve/` 目录(`my-skill.r0.md`、`my-skill.r1.md`...),可以 diff 查看 AI 改了什么。最佳版本自动写回原始文件。
397
+ Each round's output is saved under `skills/evolve/` (`my-skill.r0.md`, `my-skill.r1.md`…), so you can `diff` to see what the AI changed. The best round is written back to the original file.
376
398
 
377
399
  ### `omk bench ci`
378
400
 
379
- 在自动化流水线中运行评测。评分达标则退出码为 0(通过),否则为 1(失败),可直接用于卡点判断。
401
+ Run the evaluation inside CI. Exit code 0 on pass, 1 on fail — can be wired into gates directly.
402
+
403
+ The gate is **three-layer all-pass**: `avgFactScore >= threshold AND avgBehaviorScore >= threshold AND avgJudgeScore >= threshold`. Any layer below threshold is FAIL, and the output shows which layer broke. This stops cases like `fact 4.5→2.5 but judge 3→5` from passing via composite averaging — if one layer regresses, the gate catches it.
380
404
 
381
405
  ```bash
382
- omk bench ci [选项]
383
- --threshold <数值> 达标的最低综合分数(默认:3.5
406
+ omk bench ci [options]
407
+ --threshold <number> per-layer minimum score (default: 3.5); applied
408
+ independently to fact / behavior / judge
384
409
  ```
385
410
 
386
411
  ### `omk bench report`
387
412
 
388
- 启动报告服务,浏览历史报告、提交反馈、删除报告。
413
+ Start the report server to browse historical reports, submit feedback, and delete reports.
389
414
 
390
415
  ```bash
391
- omk bench report [选项]
392
- --port <端口号> 服务端口(默认:7799
416
+ omk bench report [options]
417
+ --port <number> server port (default: 7799)
393
418
  ```
394
419
 
395
420
  ### `omk bench init`
396
421
 
397
422
  ```bash
398
- omk bench init [目录] # 生成评测项目脚手架
423
+ omk bench init [dir] # scaffold an eval project
399
424
  ```
400
425
 
401
- ## 执行器
426
+ ## `omk analyze` — production observability
427
+
428
+ `omk bench run` is **offline evaluation** (fixed controls, repeatable, scored). Production is different — no control group, no ground truth, no repetition, so scoring isn't valid there. `omk analyze` turns existing Claude Code session traces into **skill-health reports** (coverage, gap signals, execution stability, tokens/latency per skill). It gives you clues about **which skill is worth re-evaluating offline**, not a production score.
402
429
 
403
- ### 内置执行器
430
+ ```bash
431
+ # analyze all cc sessions of the current project (auto-infers kb from the trace)
432
+ omk analyze ~/.claude/projects/-Users-you-Documents-my-project
433
+
434
+ # restrict to the last 7 days / 24 hours / 30 minutes
435
+ omk analyze ~/.claude/projects/my-project --last 7d
436
+
437
+ # absolute time window
438
+ omk analyze ~/.claude/projects/my-project --from 2026-04-01T00:00:00Z --to 2026-04-15T23:59:59Z
439
+
440
+ # whitelist specific skills
441
+ omk analyze ~/.claude/projects/my-project --skills audit,polish
442
+
443
+ # override the inferred knowledge-base root
444
+ omk analyze ~/.claude/projects/my-project --kb /path/to/project
445
+ ```
404
446
 
405
- | 执行器 | 适用场景 | 说明 |
406
- |--------|----------|------|
407
- | `claude` | 默认 | 通过 `claude -p` 调用 Claude CLI |
408
- | `claude-sdk` | 结构化输出 | 通过 Claude Agent SDK 调用,无 stdout 解析,避免 buffer 截断 |
409
- | `openai` | 跨厂商对比 | 通过 `openai api` CLI 调用 |
410
- | `gemini` | 跨厂商对比 | 通过 `gemini` CLI 调用 |
411
- | `anthropic-api` | 无需 CLI | 直接调用 Anthropic HTTP API(需 `ANTHROPIC_API_KEY`) |
412
- | `openai-api` | 无需 CLI | 直接调用 OpenAI HTTP API(需 `OPENAI_API_KEY`) |
447
+ The command writes `~/.oh-my-knowledge/analyses/<timestamp>-skill-health.json`. Browse results alongside bench reports with `omk bench report` — the homepage has a "📊 Skill Health Reports" link, and each skill card also has a "trend →" link to its time-series view. For two reports side-by-side, use the compare selector on `/analyses`.
413
448
 
414
- API 直调执行器支持通过环境变量自定义 Base URL:`ANTHROPIC_BASE_URL`、`OPENAI_BASE_URL`。
449
+ **What you get per skill:**
415
450
 
416
- ### 自定义执行器
451
+ - **Knowledge usage** — which KB files this skill actually read (coverage %)
452
+ - **Knowledge gaps** — four weighted signals (failed search / model-flagged gap / hedging / repeated miss); hedging goes through an LLM-assisted classifier to filter out business-possibility hedging vs genuine knowledge uncertainty
453
+ - **Execution stability** — tool-failure rate; a skill with > 20% failures gets a warning that its gap signals may be environmental noise rather than real knowledge gaps
454
+ - **Usage cost** — billable tokens (input+output) separate from cached tokens, total duration
417
455
 
418
- 任何 shell 命令都可以作为执行器,通过 stdin/stdout JSON 协议通信:
456
+ **What this is NOT:**
457
+
458
+ - Not a general APM (request/response/latency tracing is Langfuse / Datadog territory)
459
+ - Not streaming / alerting (batch only — run on a cron if you want periodic snapshots)
460
+ - Not a production score (no control group, no ground truth — use `omk bench run` for scoring)
461
+
462
+ ## Executors
463
+
464
+ ### Built-in executors
465
+
466
+ | Executor | When to use | Description |
467
+ |---|---|---|
468
+ | `claude` | default | invokes `claude -p` via Claude CLI |
469
+ | `claude-sdk` | structured output | uses Claude Agent SDK — no stdout parsing, avoids buffer truncation |
470
+ | `openai` | cross-vendor comparison | invokes `openai api` CLI |
471
+ | `gemini` | cross-vendor comparison | invokes `gemini` CLI |
472
+ | `anthropic-api` | no CLI needed | calls Anthropic HTTP API directly (needs `ANTHROPIC_API_KEY`) |
473
+ | `openai-api` | no CLI needed | calls OpenAI HTTP API directly (needs `OPENAI_API_KEY`) |
474
+
475
+ API-direct executors support custom base URLs via env: `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`.
476
+
477
+ ### Custom executor
478
+
479
+ Any shell command can serve as an executor, communicating via stdin/stdout JSON:
419
480
 
420
481
  ```bash
421
482
  omk bench run --executor "python my_provider.py"
422
483
  omk bench run --executor "./my-executor.sh"
423
484
  ```
424
485
 
425
- **协议约定:**
486
+ **Protocol:**
426
487
 
427
- - **输入**(stdin):JSON `{"model":"...","system":"...","prompt":"..."}`
428
- - **输出**(stdout):JSON `{"output":"模型回复","inputTokens":0,"outputTokens":0,"costUSD":0}`
429
- - stdout 中只需返回有值的字段,其余默认为 0;也可以直接输出纯文本(不解析 token/成本)
430
- - 非零退出码视为执行失败
488
+ - **input** (stdin): JSON `{"model":"...","system":"...","prompt":"..."}`
489
+ - **output** (stdout): JSON `{"output":"model reply","inputTokens":0,"outputTokens":0,"costUSD":0}`
490
+ - stdout only needs to return the fields you care about; others default to 0. Plain-text output (no tokens/cost parsing) is also fine.
491
+ - non-zero exit code counts as failure
431
492
 
432
- ### Artifact 目录结构
493
+ ### Artifact directory layout
433
494
 
434
- 默认执行器(claude/openai/gemini)支持两种 artifact 布局,同一次评测中可混用:
495
+ The built-in executors (claude / openai / gemini) support two artifact layouts, mixable in the same run:
435
496
 
436
497
  ```
437
498
  skills/
438
- ├── v1.md # 方式一:直接放 .md 文件
439
- └── my-skill/ # 方式二:完整 artifact 目录
440
- ├── SKILL.md # 工具自动读取此文件作为 system prompt
441
- ├── config.json # 其他文件不参与评测,仅保留完整性
499
+ ├── v1.md # option 1: plain .md file
500
+ └── my-skill/ # option 2: full artifact dir
501
+ ├── SKILL.md # this file is auto-loaded as system prompt
502
+ ├── config.json # other files don't participate in eval, kept for completeness
442
503
  └── scripts/
443
504
  ```
444
505
 
445
- **Variant 解析规则:**
506
+ **Variant resolution rules:**
446
507
 
447
- `variant` 是实验分组表达式。解析之后,OMK 会得到一个 `artifact` 与可选的 `runtime context`(当前主要是 `cwd`)。
508
+ `variant` is the experiment-group expression. After resolution, OMK produces an `artifact` plus an optional `runtime context` (currently mainly `cwd`).
448
509
 
449
- | 格式 | 含义 |
450
- |------|------|
451
- | `name` | artifact 目录查找 `name.md` `name/SKILL.md`,解析为一个 artifact |
452
- | `baseline` | artifact,不使用 system prompt;可直接理解为“什么都没有” |
453
- | `project-env@/path/to/project` | artifact,但在指定项目目录运行,用于单独观察项目级 runtime context |
454
- | `git:name` | git HEAD 读取一个 artifact 的上次提交版本 |
455
- | `git:ref:name` | git 指定 commit 读取一个 artifact |
456
- | `./path/to/file.md` | `/` 的路径,直接读取文件作为 artifact |
457
- | `variant@/path/to/project` | 给任意变体附加运行目录,支持 `name@cwd`、`git:name@cwd`、`/file.md@cwd` |
510
+ | Format | Meaning |
511
+ |---|---|
512
+ | `name` | looks up `name.md` or `name/SKILL.md` in the artifact dir, resolves to one artifact |
513
+ | `baseline` | empty artifact, no system prompt — think "nothing at all" |
514
+ | `project-env@/path/to/project` | empty artifact, but run in the specified project dir — observe project-level runtime context alone |
515
+ | `git:name` | reads the last-committed version of an artifact from git HEAD |
516
+ | `git:ref:name` | reads an artifact from a specific commit |
517
+ | `./path/to/file.md` | path with `/`: read the file directly as an artifact |
518
+ | `variant@/path/to/project` | attach a run dir to any variant; supports `name@cwd`, `git:name@cwd`, `/file.md@cwd` |
458
519
 
459
- 不指定 `--variants` 时,自动扫描 artifact 目录下的所有 `.md` 文件和含 `SKILL.md` 的子目录。只有一个 artifact 时自动加 `baseline` 作为对照。
520
+ When both `--control` and `--treatment` are omitted, use `--config eval.yaml` or `--each`. With `--each`, `baseline` is auto-added as control and every discovered artifact becomes a treatment.
460
521
 
461
522
  ```bash
462
- # 自动发现 skills/ 下所有 artifact
463
- omk bench run
523
+ # explicit: one control, one or more treatments
524
+ omk bench run --control v1 --treatment v2
525
+ omk bench run --control baseline --treatment v1,v2,v3
464
526
 
465
- # 显式指定两个变体
466
- omk bench run --variants v1,v2
527
+ # compare empty artifact vs explicit artifact
528
+ omk bench run --control baseline --treatment my-skill
467
529
 
468
- # 对比空 artifact 和显式 artifact 的效果差异
469
- omk bench run --variants baseline,my-skill
530
+ # observe project-level runtime context in isolation (use a self-describing label)
531
+ omk bench run --control baseline --treatment project-env@/path/to/target-project
470
532
 
471
- # 推荐用自描述标签单独观察项目级 runtime context 的影响
472
- omk bench run --variants project-env@/path/to/target-project
533
+ # compare "project-level runtime context" vs "explicit artifact injection"
534
+ omk bench run \
535
+ --control project-env@/path/to/target-project \
536
+ --treatment /path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
473
537
 
474
- # 对比“项目级 runtime context”与“显式 artifact 注入”
475
- omk bench run --variants project-env@/path/to/target-project,/path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
538
+ # before vs after (old version read from git history)
539
+ omk bench run --control git:my-skill --treatment my-skill
476
540
 
477
- # 对比修改前后(旧版本从 git 历史读取)
478
- omk bench run --variants git:my-skill,my-skill
541
+ # direct file paths
542
+ omk bench run --control ./old-skill.md --treatment ./new-skill.md
479
543
 
480
- # 直接指定文件路径
481
- omk bench run --variants ./old-skill.md,./new-skill.md
544
+ # config-file driven (evaluation-as-code)
545
+ omk bench run --config eval.yaml
482
546
  ```
483
547
 
484
- **前置要求:**
548
+ **Prerequisites:**
485
549
 
486
- - **claude**:安装 [Claude Code](https://claude.ai/code) 并认证
487
- - **claude-sdk**:安装 [Claude Code](https://claude.ai/code) 并认证(使用 Agent SDK,无需 CLI stdout 解析)
488
- - **anthropic-api**:设置 `ANTHROPIC_API_KEY` 环境变量
489
- - **openai**:`pip install openai` 并设置 `OPENAI_API_KEY`
490
- - **openai-api**:设置 `OPENAI_API_KEY` 环境变量
491
- - **gemini**:`npm i -g @google/gemini-cli` 并认证
550
+ - **claude**: install [Claude Code](https://claude.ai/code) and authenticate
551
+ - **claude-sdk**: install [Claude Code](https://claude.ai/code) and authenticate (uses Agent SDK, no CLI stdout parsing)
552
+ - **anthropic-api**: set the `ANTHROPIC_API_KEY` env var
553
+ - **openai**: `pip install openai` and set `OPENAI_API_KEY`
554
+ - **openai-api**: set the `OPENAI_API_KEY` env var
555
+ - **gemini**: `npm i -g @google/gemini-cli` and authenticate
492
556
 
493
- ### Agent 评测与项目级 Runtime Context
557
+ ### Agent evaluation and project-level runtime context
494
558
 
495
- 当执行器使用 `claude-sdk` 时,OMK 现在已经支持第一版 agent-aware evaluation
559
+ When the executor is `claude-sdk`, OMK supports a first pass of agent-aware evaluation.
496
560
 
497
- 这里建议把几个概念分开理解:
561
+ A few concepts worth keeping separate:
498
562
 
499
- - `artifact`:被评测对象,例如 baselineskillpromptagent
500
- - `variant`:CLI 里的实验分组表达式
501
- - `runtime context`:运行时上下文,当前主要是 `cwd`;在项目型 agent 场景下,它就包含项目目录、`CLAUDE.md`、本地 skills 等会影响行为的环境因素
563
+ - `artifact`: the thing being evaluated — baseline, skill, prompt, agent
564
+ - `variant`: the CLI expression for an experiment group
565
+ - `runtime context`: the runtime environment; currently mainly `cwd`. In project-type agent scenarios it includes the project dir, its `CLAUDE.md`, local skills, and any other environmental factors that affect behavior
502
566
 
503
- OMK 里,`agent` 不是所有对象的总称,`skill` 也不是所有对象的总称。更稳妥的说法是:你在比较不同 artifact 在不同 runtime context 下的表现。
567
+ In OMK, `agent` is not a catch-all term and neither is `skill`. A cleaner phrasing: **you are comparing how different artifacts behave under different runtime contexts.**
504
568
 
505
- - 自动抽取 turns / toolCalls trace
506
- - 支持基于工具调用行为的断言
507
- - 支持在指定 `cwd` 下运行,让 Claude Code 自动加载项目内的 `CLAUDE.md`、skills 和本地 runtime context
569
+ - auto-extracts turns / toolCalls traces
570
+ - supports assertions on tool-call behavior
571
+ - supports running under a specified `cwd`, so Claude Code auto-loads the project's `CLAUDE.md`, skills, and local runtime context
508
572
 
509
- #### 推荐执行器
573
+ #### Recommended executor
510
574
 
511
575
  ```bash
512
576
  omk bench run --executor claude-sdk
513
577
  ```
514
578
 
515
- #### 支持的 agent 相关断言
579
+ #### Agent-related assertions
516
580
 
517
- | 断言 | 含义 |
518
- |------|------|
519
- | `tools_called` | 必须调用指定工具 |
520
- | `tools_not_called` | 禁止调用指定工具 |
521
- | `tools_count_min` / `tools_count_max` | 工具调用次数上下界 |
522
- | `tool_output_contains` | 指定工具输出必须包含关键内容 |
523
- | `turns_min` / `turns_max` | 交互轮次上下界 |
581
+ | Assertion | Meaning |
582
+ |---|---|
583
+ | `tools_called` | must call the specified tool(s) |
584
+ | `tools_not_called` | must not call the specified tool(s) |
585
+ | `tools_count_min` / `tools_count_max` | tool-call-count bounds |
586
+ | `tool_output_contains` | output of a specific tool must contain given content |
587
+ | `turns_min` / `turns_max` | turn-count bounds |
524
588
 
525
- #### 三种常见对照组
589
+ #### Three common control setups
526
590
 
527
- **1. 裸模型 baseline**
591
+ **1. Bare-model baseline**
528
592
 
529
- 不注入 system prompt,也不进入带知识的项目目录。
593
+ No system prompt and no knowledge-carrying project dir. Requires at least one treatment to compare against:
530
594
 
531
595
  ```bash
532
596
  omk bench run \
533
597
  --executor claude-sdk \
534
- --variants baseline
598
+ --control baseline \
599
+ --treatment my-skill
535
600
  ```
536
601
 
537
- **2. artifact + 项目级 runtime context**
602
+ **2. Empty artifact + project-level runtime context**
538
603
 
539
- 不注入 system prompt,但在项目目录运行。它不是严格意义上的“裸 baseline”,而是“空 artifact + 项目级 runtime context”。
604
+ No system prompt, but runs inside a project dir. This is **not** a strict "bare baseline" — it is "empty artifact + project-level runtime context".
540
605
 
541
606
  ```bash
542
607
  omk bench run \
543
608
  --executor claude-sdk \
544
- --variants project-env@/path/to/target-project
609
+ --control baseline \
610
+ --treatment project-env@/path/to/target-project
545
611
  ```
546
612
 
547
- **3. 显式 artifact 注入**
613
+ **3. Explicit artifact injection**
548
614
 
549
- 直接把某个外部 `SKILL.md` 作为 artifact 注入,同时保留项目目录上下文。适合对比“项目级 runtime context”与“显式单 artifact 注入”之间的差异。
615
+ Inject an external `SKILL.md` as the artifact while also keeping the project dir. Good for contrasting "project-level runtime context" vs "explicit single-artifact injection".
550
616
 
551
617
  ```bash
552
618
  omk bench run \
553
619
  --executor claude-sdk \
554
- --variants /path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
620
+ --control project-env@/path/to/target-project \
621
+ --treatment /path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
555
622
  ```
556
623
 
557
- #### 推荐的第一轮对照设计
624
+ #### Recommended first-round design
558
625
 
559
- 对于 PRD / 复杂业务知识场景,建议先从下面两组开始:
626
+ For PRD / complex business-knowledge scenarios, start with:
560
627
 
561
628
  ```bash
562
629
  omk bench run \
563
630
  --executor claude-sdk \
564
631
  --samples skills/evaluate-review/eval-samples.yaml \
565
- --variants baseline,/path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
632
+ --control baseline \
633
+ --treatment /path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
566
634
  ```
567
635
 
568
- 如果你想证明“项目目录中的知识沉淀本身”是否有效,再加第三组:
636
+ If you want to prove whether "the knowledge sitting inside the project directory" is effective on its own, add a second treatment:
569
637
 
570
638
  ```bash
571
639
  omk bench run \
572
640
  --executor claude-sdk \
573
641
  --samples skills/evaluate-review/eval-samples.yaml \
574
- --variants baseline,project-env@/path/to/target-project,/path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
642
+ --control baseline \
643
+ --treatment project-env@/path/to/target-project,/path/to/target-project/.claude/skills/prd/SKILL.md@/path/to/target-project
575
644
  ```
576
645
 
577
- #### 设计建议
646
+ #### Design tips
578
647
 
579
- - **先用 `--dry-run`**:确认样本、variant `cwd` 被正确解析
580
- - **项目级对照必须区分 `cwd`**:相同 prompt 在不同项目目录下会走不同 runtime context
581
- - **优先先跑 PRD 场景**:相比 Coding,更容易验证知识完整性、影响面识别和业务正确性
648
+ - **Always start with `--dry-run`** to confirm samples, variants, and `cwd` are parsed correctly
649
+ - **Project-level controls must differ in `cwd`**: the same prompt under different project dirs hits different runtime contexts
650
+ - **Try PRD scenarios first**: compared to pure coding, they make it easier to validate knowledge completeness, impact-area detection, and business correctness
582
651
 
583
- ### 常见模型配置示例
652
+ ### Common model configurations
584
653
 
585
- **没有 Claude?** 大多数国产模型(GLM、通义千问、MoonshotDeepSeek 等)都兼容 OpenAI API 格式,可以直接使用 `openai-api` 执行器:
654
+ **Don't have Claude?** Most Chinese LLMs (GLM, Qwen, Moonshot, DeepSeek, etc.) are OpenAI-API compatible — use the `openai-api` executor directly:
586
655
 
587
656
  ```bash
588
- # GLM(智谱)
589
- export OPENAI_API_KEY="你的智谱 API Key"
657
+ # GLM (Zhipu)
658
+ export OPENAI_API_KEY="your Zhipu API key"
590
659
  export OPENAI_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
591
660
  omk bench run --executor openai-api --model glm-4-plus \
592
661
  --judge-model glm-4-plus --no-cache
593
662
 
594
- # 通义千问
595
- export OPENAI_API_KEY="你的通义 API Key"
663
+ # Qwen (Alibaba)
664
+ export OPENAI_API_KEY="your Qwen API key"
596
665
  export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
597
666
  omk bench run --executor openai-api --model qwen-plus \
598
667
  --judge-model qwen-plus
599
668
 
600
669
  # DeepSeek
601
- export OPENAI_API_KEY="你的 DeepSeek API Key"
670
+ export OPENAI_API_KEY="your DeepSeek API key"
602
671
  export OPENAI_BASE_URL="https://api.deepseek.com"
603
672
  omk bench run --executor openai-api --model deepseek-chat \
604
673
  --judge-model deepseek-chat
605
674
 
606
- # MoonshotKimi
607
- export OPENAI_API_KEY="你的 Moonshot API Key"
675
+ # Moonshot (Kimi)
676
+ export OPENAI_API_KEY="your Moonshot API key"
608
677
  export OPENAI_BASE_URL="https://api.moonshot.cn/v1"
609
678
  omk bench run --executor openai-api --model moonshot-v1-8k \
610
679
  --judge-model moonshot-v1-8k
611
680
  ```
612
681
 
613
- **Ollama 本地模型:**
682
+ **Ollama local model:**
614
683
 
615
684
  ```bash
616
685
  omk bench run --executor "python examples/custom-executor/ollama-executor.py" \
617
686
  --model llama3 --no-judge
618
687
  ```
619
688
 
620
- **关于评委模型:**
689
+ **About the judge model:**
621
690
 
622
- - `--judge-model` 指定 LLM 评委使用的模型,默认 `haiku`
623
- - `--judge-executor` 指定评委使用的执行器(默认与 `--executor` 相同)
624
- - 如果你没有 Claude,用 `--judge-executor` `--judge-model` 指向你可用的模型
625
- - `--no-judge` 可跳过 LLM 评委,仅使用断言评分
691
+ - `--judge-model` picks the model used by the LLM judge (default `haiku`)
692
+ - `--judge-executor` picks the executor the judge uses (defaults to `--executor`)
693
+ - If you don't have Claude, point `--judge-executor` and `--judge-model` at whatever model you have
694
+ - Add `--no-judge` to skip the LLM judge and rely on assertions alone
626
695
 
627
- ## 环境变量
696
+ ## Environment variables
628
697
 
629
- | 变量 | 说明 |
630
- |------|------|
631
- | `CCV_PROXY_URL` | 将请求代理到 cc-viewer,实时可视化评测流量 |
632
- | `OMK_BENCH_PORT` | 报告服务端口(默认:7799 |
698
+ | Variable | Description |
699
+ |---|---|
700
+ | `CCV_PROXY_URL` | proxy requests through cc-viewer for live eval-traffic visualization |
701
+ | `OMK_BENCH_PORT` | report server port (default: 7799) |
633
702
 
634
- ## 系统要求
703
+ ## Requirements
635
704
 
636
705
  - Node.js >= 20
637
- - `claude` CLI(用于默认执行器和 LLM 评委,安装方式见 [Claude Code](https://claude.ai/code)
638
- - 使用其他执行器(openai/gemini)且加 `--no-judge` 时可不装
706
+ - `claude` CLI (for the default executor and LLM judge; see [Claude Code](https://claude.ai/code))
707
+ - not needed if you use other executors (openai / gemini) with `--no-judge`
708
+
709
+ ## Security notice
710
+
711
+ This tool is designed for **local trusted environments** (dev machines, CI pipelines). The following features execute local code — make sure inputs come from a trusted source:
639
712
 
640
- ## 安全说明
713
+ | Feature | Risk | Scope |
714
+ |---|---|---|
715
+ | **Custom assertions** (`custom`) | dynamically loads and executes user-specified `.mjs` files | only use assertion files you authored or reviewed |
716
+ | **eval-samples.json** | assertion configs can reference external file paths | don't use sample files from untrusted sources |
641
717
 
642
- 本工具设计用于**本地可信环境**(开发机、CI 流水线)。以下功能会执行本地代码,请确保输入来源可信:
718
+ **Recommendations:**
643
719
 
644
- | 功能 | 风险说明 | 适用范围 |
645
- |------|----------|----------|
646
- | **自定义断言** (`custom`) | 动态加载并执行用户指定的 `.mjs` 文件 | 仅使用自己编写或审查过的断言文件 |
647
- | **eval-samples.json** | 断言配置中可引用外部文件路径 | 不要使用不可信来源的样本文件 |
720
+ - Do not expose `omk bench report` on the public internet (no auth)
721
+ - Don't use third-party eval-samples you haven't vetted
722
+ - Custom assertions have a 30-second timeout but no sandbox isolation
648
723
 
649
- **建议:**
724
+ ---
650
725
 
651
- - 不要在公网服务中暴露 `omk bench report` 服务(无认证)
652
- - 不要用不可信的第三方 eval-samples 文件
653
- - 自定义断言有 30 秒执行超时,但无沙箱隔离
726
+ See [CHANGELOG](./CHANGELOG.md) for release notes. Contributions welcome — see [CONTRIBUTING](./CONTRIBUTING.md).