python-yama 0.1.0__tar.gz → 0.3.0__tar.gz

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 (48) hide show
  1. {python_yama-0.1.0 → python_yama-0.3.0}/CLAUDE.md +7 -0
  2. python_yama-0.3.0/PKG-INFO +105 -0
  3. python_yama-0.3.0/README.md +80 -0
  4. python_yama-0.1.0/PKG-INFO → python_yama-0.3.0/README.zh-CN.md +8 -26
  5. {python_yama-0.1.0 → python_yama-0.3.0}/docs/agent-skill-test-framework-design.md +152 -24
  6. {python_yama-0.1.0 → python_yama-0.3.0}/skills/eval-plugin-with-yama/SKILL.md +31 -7
  7. {python_yama-0.1.0 → python_yama-0.3.0}/skills/eval-plugin-with-yama/references/case-schema.md +4 -1
  8. {python_yama-0.1.0 → python_yama-0.3.0}/skills/eval-plugin-with-yama/references/debugging.md +13 -6
  9. python_yama-0.3.0/tests/test_cli.py +728 -0
  10. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_framework.py +281 -2
  11. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_mocks.py +52 -0
  12. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_report.py +48 -0
  13. python_yama-0.3.0/yama/cli.py +626 -0
  14. {python_yama-0.1.0 → python_yama-0.3.0}/yama/llm.py +4 -1
  15. {python_yama-0.1.0 → python_yama-0.3.0}/yama/loaders/case.py +7 -0
  16. {python_yama-0.1.0 → python_yama-0.3.0}/yama/mocks.py +22 -1
  17. {python_yama-0.1.0 → python_yama-0.3.0}/yama/models.py +1 -0
  18. {python_yama-0.1.0 → python_yama-0.3.0}/yama/report.py +8 -1
  19. {python_yama-0.1.0 → python_yama-0.3.0}/yama/runner.py +88 -9
  20. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/bash/fs.py +16 -5
  21. python_yama-0.1.0/README.md +0 -73
  22. python_yama-0.1.0/tests/test_cli.py +0 -300
  23. python_yama-0.1.0/yama/cli.py +0 -318
  24. {python_yama-0.1.0 → python_yama-0.3.0}/.github/workflows/publish.yml +0 -0
  25. {python_yama-0.1.0 → python_yama-0.3.0}/.gitignore +0 -0
  26. {python_yama-0.1.0 → python_yama-0.3.0}/LICENSE +0 -0
  27. {python_yama-0.1.0 → python_yama-0.3.0}/pyproject.toml +0 -0
  28. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_assertions.py +0 -0
  29. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_cli_shim.py +0 -0
  30. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_main_entrypoint.py +0 -0
  31. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_public_api.py +0 -0
  32. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_skill_tool.py +0 -0
  33. {python_yama-0.1.0 → python_yama-0.3.0}/tests/test_workspace.py +0 -0
  34. {python_yama-0.1.0 → python_yama-0.3.0}/uv.lock +0 -0
  35. {python_yama-0.1.0 → python_yama-0.3.0}/yama/__init__.py +0 -0
  36. {python_yama-0.1.0 → python_yama-0.3.0}/yama/__main__.py +0 -0
  37. {python_yama-0.1.0 → python_yama-0.3.0}/yama/assertions.py +0 -0
  38. {python_yama-0.1.0 → python_yama-0.3.0}/yama/loaders/__init__.py +0 -0
  39. {python_yama-0.1.0 → python_yama-0.3.0}/yama/loaders/common.py +0 -0
  40. {python_yama-0.1.0 → python_yama-0.3.0}/yama/loaders/tool_loader.py +0 -0
  41. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/__init__.py +0 -0
  42. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/base.py +0 -0
  43. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/bash/__init__.py +0 -0
  44. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/bash/_cli_shim.py +0 -0
  45. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/bash/bash.py +0 -0
  46. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/skill/__init__.py +0 -0
  47. {python_yama-0.1.0 → python_yama-0.3.0}/yama/tools/skill/skill.py +0 -0
  48. {python_yama-0.1.0 → python_yama-0.3.0}/yama/workspace.py +0 -0
@@ -37,6 +37,11 @@ Reproducible evaluation runner for tool-using Agent skills (see `README.md` and
37
37
  default `.yama/runs` / `.yama/reports/latest.html` locations) changes.
38
38
  Everything beyond that basic subset only needs to stay in
39
39
  `docs/agent-skill-test-framework-design.md`.
40
+ - `README.zh-CN.md` is the Chinese mirror of `README.md` (English, also the
41
+ PyPI page). Whenever `README.md` changes, apply the same change to
42
+ `README.zh-CN.md` so the two never drift. Links inside `README.md` use
43
+ absolute GitHub URLs (relative links break on PyPI); `README.zh-CN.md` may
44
+ use relative links.
40
45
  - When changing the Case syntax (schema fields, mock/assertion/judge
41
46
  configuration, path conventions) or the Case execution logic (tool loop,
42
47
  step advancement, failure semantics, artifact layout, CLI behavior), update
@@ -59,6 +64,8 @@ Reproducible evaluation runner for tool-using Agent skills (see `README.md` and
59
64
 
60
65
  ## Releasing
61
66
 
67
+ - The PyPI distribution is named `python-yama` (PyPI rejects `yama` as too
68
+ similar to `yaml`); the import package and CLI command are still `yama`.
62
69
  - The package version is derived from git tags by `hatch-vcs`; there is no
63
70
  `version` field in `pyproject.toml` to edit. Untagged commits build as
64
71
  `+g<hash>` dev versions, which PyPI rejects, so only tagged commits can be
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-yama
3
+ Version: 0.3.0
4
+ Summary: A reproducible evaluation runner for tool-using Agent skills
5
+ Project-URL: Repository, https://github.com/world-sim-dev/yama
6
+ Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
7
+ Author-email: Farmer Sun <podpodiumapp@gmail.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agent,evaluation,llm,skill,testing
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Requires-Python: >=3.12
18
+ Requires-Dist: fastapi>=0.139.0
19
+ Requires-Dist: jinja2>=3.1
20
+ Requires-Dist: litellm<2.0,>=1.80
21
+ Requires-Dist: orjson>=3.11.9
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: rich<15.0,>=14.1
24
+ Description-Content-Type: text/markdown
25
+
26
+ # yama
27
+
28
+ English | [简体中文](https://github.com/world-sim-dev/yama/blob/main/README.zh-CN.md)
29
+
30
+ `yama` is a reproducible evaluation framework for tool-using Agent Skills: a declarative YAML Case describes what the model sees — the system prompt, Skill metadata, tool schemas, and multi-turn user messages — then yama calls the LLM through LiteLLM, drives the tool loop, and scores the transcript with deterministic hard checks or an LLM judge. See the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese) for the full Case schema and execution contract.
31
+
32
+ ## Quick start
33
+
34
+ ```bash
35
+ # Run from a plugin root; collects __evals__/cases/**/*.yaml by default
36
+ cd dingding-simple
37
+ OPENAI_API_KEY=... uv run --project yama yama
38
+
39
+ # Or, from a workspace root (a directory with yama.toml), pick a plugin by name
40
+ OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
41
+ ```
42
+
43
+ ## Writing a Case
44
+
45
+ A Case is a YAML file organized as `context` (what the model sees) → `mocks` (how tool calls get executed) → `steps` (user turns sent in order, each with assertions) → `outcome` (the pass bar for the whole Case):
46
+
47
+ ```yaml
48
+ description: The model reads the DSL before proposing creative directions
49
+
50
+ context:
51
+ system_prompt: { default: true } # use SYSTEM.md from the plugin root
52
+
53
+ tools:
54
+ - file: tools/read-dsl.yaml # tool schema, resolved relative to __evals__
55
+
56
+ mocks:
57
+ tools:
58
+ read_dsl:
59
+ respond:
60
+ result:
61
+ visualStyle: { name: Vintage Film }
62
+
63
+ steps:
64
+ - id: request-directions
65
+ user: Give me a few creative directions
66
+ assert:
67
+ hard:
68
+ - tool_called: { name: read_dsl }
69
+ - assistant_contains: creative direction
70
+
71
+ outcome:
72
+ require:
73
+ hard_checks: all_pass
74
+ ```
75
+
76
+ - `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
77
+ - `context.tools` is the tool schema sent to the model; `mocks.tools` is how the runner responds when a tool call arrives. The two sets of tool names must match exactly.
78
+ - To use a Skill, declare it by name under `context.skills` and also declare `{builtin: skill}` under `context.tools`; the model reads the Skill body via `skill(name, file?)`.
79
+ - To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
80
+ - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); add `assert.judge` for LLM scoring.
81
+
82
+ For the full schema (every Skill/tool/mock form, the `bash` sandbox, message injection, judge configuration, and more), see the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese).
83
+
84
+ ## CLI usage
85
+
86
+ ```bash
87
+ uv run --project yama yama --plugin dingding-simple --report
88
+ ```
89
+
90
+ | Flag | Meaning |
91
+ | --- | --- |
92
+ | `paths` (positional, repeatable) | Explicit Case YAML paths to run |
93
+ | `--plugin-root PATH` | Use the given path as the single plugin root |
94
+ | `--plugin NAME` (repeatable) | Select plugins by name from `yama.toml` |
95
+ | `--all-plugins` | Run every plugin configured in `yama.toml` |
96
+ | `--result-dir PATH` | Override the artifact root (default `<plugin_root>/.yama/runs`) |
97
+ | `--concurrency N` | Maximum number of cases running in parallel (default 10; `1` runs cases one at a time) |
98
+ | `--report [PATH]` | Also generate a single-file HTML report (default `.yama/reports/latest.html`) |
99
+ | `--list` | Only print the collected Cases, without running them |
100
+ | `--no-artifacts` | Write no artifact files at all |
101
+ | `--json` | Emit machine-readable JSON instead of Rich tables |
102
+
103
+ `--plugin`, `--all-plugins`, and `--plugin-root` are mutually exclusive. When none of them is given, yama walks up from the current directory to the nearest directory containing `yama.toml` and uses it as the workspace root (falling back to the cwd), running it as a single plugin root.
104
+
105
+ Cases run in parallel, up to 10 at a time by default (`--concurrency` changes the cap); runs within one case stay sequential, and results keep collection order regardless of completion order. While several cases run concurrently, a transient dashboard at the bottom of the terminal shows one row per case, updated in place — waiting, then a spinner with the run/step currently executing, then its ✓/✗ verdict — and each case's full run/step detail is printed above the dashboard as one block the moment it finishes, so blocks of different cases never interleave. With `--concurrency 1` (or a single collected case) it streams instead — a spinner marks the step currently executing (on a terminal), and each case, run, and assertion result is printed the moment it completes. Either way a per-case summary table closes the output, and with `--json` the progress stream goes to stderr so stdout stays valid JSON.
@@ -0,0 +1,80 @@
1
+ # yama
2
+
3
+ English | [简体中文](https://github.com/world-sim-dev/yama/blob/main/README.zh-CN.md)
4
+
5
+ `yama` is a reproducible evaluation framework for tool-using Agent Skills: a declarative YAML Case describes what the model sees — the system prompt, Skill metadata, tool schemas, and multi-turn user messages — then yama calls the LLM through LiteLLM, drives the tool loop, and scores the transcript with deterministic hard checks or an LLM judge. See the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese) for the full Case schema and execution contract.
6
+
7
+ ## Quick start
8
+
9
+ ```bash
10
+ # Run from a plugin root; collects __evals__/cases/**/*.yaml by default
11
+ cd dingding-simple
12
+ OPENAI_API_KEY=... uv run --project yama yama
13
+
14
+ # Or, from a workspace root (a directory with yama.toml), pick a plugin by name
15
+ OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
16
+ ```
17
+
18
+ ## Writing a Case
19
+
20
+ A Case is a YAML file organized as `context` (what the model sees) → `mocks` (how tool calls get executed) → `steps` (user turns sent in order, each with assertions) → `outcome` (the pass bar for the whole Case):
21
+
22
+ ```yaml
23
+ description: The model reads the DSL before proposing creative directions
24
+
25
+ context:
26
+ system_prompt: { default: true } # use SYSTEM.md from the plugin root
27
+
28
+ tools:
29
+ - file: tools/read-dsl.yaml # tool schema, resolved relative to __evals__
30
+
31
+ mocks:
32
+ tools:
33
+ read_dsl:
34
+ respond:
35
+ result:
36
+ visualStyle: { name: Vintage Film }
37
+
38
+ steps:
39
+ - id: request-directions
40
+ user: Give me a few creative directions
41
+ assert:
42
+ hard:
43
+ - tool_called: { name: read_dsl }
44
+ - assistant_contains: creative direction
45
+
46
+ outcome:
47
+ require:
48
+ hard_checks: all_pass
49
+ ```
50
+
51
+ - `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
52
+ - `context.tools` is the tool schema sent to the model; `mocks.tools` is how the runner responds when a tool call arrives. The two sets of tool names must match exactly.
53
+ - To use a Skill, declare it by name under `context.skills` and also declare `{builtin: skill}` under `context.tools`; the model reads the Skill body via `skill(name, file?)`.
54
+ - To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
55
+ - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); add `assert.judge` for LLM scoring.
56
+
57
+ For the full schema (every Skill/tool/mock form, the `bash` sandbox, message injection, judge configuration, and more), see the [design doc](https://github.com/world-sim-dev/yama/blob/main/docs/agent-skill-test-framework-design.md) (Chinese).
58
+
59
+ ## CLI usage
60
+
61
+ ```bash
62
+ uv run --project yama yama --plugin dingding-simple --report
63
+ ```
64
+
65
+ | Flag | Meaning |
66
+ | --- | --- |
67
+ | `paths` (positional, repeatable) | Explicit Case YAML paths to run |
68
+ | `--plugin-root PATH` | Use the given path as the single plugin root |
69
+ | `--plugin NAME` (repeatable) | Select plugins by name from `yama.toml` |
70
+ | `--all-plugins` | Run every plugin configured in `yama.toml` |
71
+ | `--result-dir PATH` | Override the artifact root (default `<plugin_root>/.yama/runs`) |
72
+ | `--concurrency N` | Maximum number of cases running in parallel (default 10; `1` runs cases one at a time) |
73
+ | `--report [PATH]` | Also generate a single-file HTML report (default `.yama/reports/latest.html`) |
74
+ | `--list` | Only print the collected Cases, without running them |
75
+ | `--no-artifacts` | Write no artifact files at all |
76
+ | `--json` | Emit machine-readable JSON instead of Rich tables |
77
+
78
+ `--plugin`, `--all-plugins`, and `--plugin-root` are mutually exclusive. When none of them is given, yama walks up from the current directory to the nearest directory containing `yama.toml` and uses it as the workspace root (falling back to the cwd), running it as a single plugin root.
79
+
80
+ Cases run in parallel, up to 10 at a time by default (`--concurrency` changes the cap); runs within one case stay sequential, and results keep collection order regardless of completion order. While several cases run concurrently, a transient dashboard at the bottom of the terminal shows one row per case, updated in place — waiting, then a spinner with the run/step currently executing, then its ✓/✗ verdict — and each case's full run/step detail is printed above the dashboard as one block the moment it finishes, so blocks of different cases never interleave. With `--concurrency 1` (or a single collected case) it streams instead — a spinner marks the step currently executing (on a terminal), and each case, run, and assertion result is printed the moment it completes. Either way a per-case summary table closes the output, and with `--json` the progress stream goes to stderr so stdout stays valid JSON.
@@ -1,30 +1,7 @@
1
- Metadata-Version: 2.4
2
- Name: python-yama
3
- Version: 0.1.0
4
- Summary: A reproducible evaluation runner for tool-using Agent skills
5
- Project-URL: Repository, https://github.com/world-sim-dev/yama
6
- Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
7
- Author-email: Farmer Sun <podpodiumapp@gmail.com>
8
- License-Expression: MIT
9
- License-File: LICENSE
10
- Keywords: agent,evaluation,llm,skill,testing
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Classifier: Topic :: Software Development :: Testing
17
- Requires-Python: >=3.12
18
- Requires-Dist: fastapi>=0.139.0
19
- Requires-Dist: jinja2>=3.1
20
- Requires-Dist: litellm<2.0,>=1.80
21
- Requires-Dist: orjson>=3.11.9
22
- Requires-Dist: pyyaml>=6.0
23
- Requires-Dist: rich<15.0,>=14.1
24
- Description-Content-Type: text/markdown
25
-
26
1
  # yama
27
2
 
3
+ [English](README.md) | 简体中文
4
+
28
5
  `yama` 是一个可复现的 Agent Skill 评测框架:用声明式 YAML Case 描述模型看到的 System Prompt、Skill metadata、Tool Schema 与多轮 User Message,通过 LiteLLM 统一调用 LLM 并驱动 Tool Loop,再对 Transcript 做确定性 Hard Check 或 LLM Judge 评分。完整 Case Schema 与执行契约见[设计文档](docs/agent-skill-test-framework-design.md)。
29
6
 
30
7
  ## 快速开始
@@ -43,6 +20,8 @@ OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
43
20
  一个 Case 是一份 YAML 文件,按 `context`(模型看到什么)→ `mocks`(Tool 怎么被执行)→ `steps`(依次发送的用户回合与断言)→ `outcome`(整个 Case 的通过门槛)的结构组织:
44
21
 
45
22
  ```yaml
23
+ description: 模型应先读取 DSL 再给出创意方向
24
+
46
25
  context:
47
26
  system_prompt: { default: true } # 使用 Plugin 根目录下的 SYSTEM.md
48
27
 
@@ -69,6 +48,7 @@ outcome:
69
48
  hard_checks: all_pass
70
49
  ```
71
50
 
51
+ - `description`(可选)是一句话说明当前 Case 测试什么;会展示在 CLI 输出和 HTML 报告中。
72
52
  - `context.tools` 是发给模型的 Tool Schema,`mocks.tools` 是 Runner 收到 Tool Call 后如何返回结果;两者的 Tool 名字集合必须完全一致。
73
53
  - 需要 Skill 时在 `context.skills` 中按名字声明,并在 `context.tools` 中同时声明 `{builtin: skill}`;模型通过 `skill(name, file?)` 读取正文。
74
54
  - 需要模拟命令行工具时声明 `{builtin: bash}`,在 `mocks.cli` 中按命令配置输出。
@@ -88,11 +68,13 @@ uv run --project yama yama --plugin dingding-simple --report
88
68
  | `--plugin-root PATH` | 以指定路径作为单一 Plugin Root |
89
69
  | `--plugin NAME`(可重复) | 按 `yama.toml` 中的 Plugin 名字选择 |
90
70
  | `--all-plugins` | 运行 `yama.toml` 中配置的全部 Plugin |
91
- | `--response-script PATH` | 用脚本化 LLM 响应回放,不调用真实模型 |
92
71
  | `--result-dir PATH` | 覆盖产物根目录(默认 `<plugin_root>/.yama/runs`) |
72
+ | `--concurrency N` | 同时运行的 Case 数上限(默认 10;`1` 表示逐个顺序执行) |
93
73
  | `--report [PATH]` | 额外生成单文件 HTML 报告(默认 `.yama/reports/latest.html`) |
94
74
  | `--list` | 只打印匹配到的 Case,不运行 |
95
75
  | `--no-artifacts` | 不写任何产物文件 |
96
76
  | `--json` | 输出机器可读 JSON 而不是 Rich 表格 |
97
77
 
98
78
  `--plugin`/`--all-plugins`/`--plugin-root` 三者互斥;都不提供时默认用当前目录向上搜索到的 `yama.toml` 所在目录作为 Workspace Root(找不到则用 cwd),把该目录当作单一 Plugin Root 运行。
79
+
80
+ Case 之间并行执行,默认最多同时 10 个(用 `--concurrency` 调整上限);同一 Case 内的多个 run 仍顺序执行,结果始终保持收集顺序,与完成先后无关。多个 Case 并发运行时,终端底部会有一张原地刷新的状态面板,每个 Case 固定占一行——排队等待、转圈显示当前执行到的 Run/Step、完成后原地翻成 ✓/✗——任何一个 Case 一完成,它的完整 Run/Step 明细就作为一个整块打印到面板上方,不同 Case 的块不会交错。使用 `--concurrency 1`(或只收集到一个 Case)时则实时流式输出——正在执行的 Step 会显示转圈的 loading 状态(终端下),每个 Case、Run、断言一完成就立即打印结果。两种模式最后都以逐 Case 的汇总表格收尾;使用 `--json` 时进度流打印到 stderr,stdout 保持为纯 JSON。
@@ -82,10 +82,10 @@ SYSTEM.md Skill Catalog Extra Messages
82
82
  | `tools/bash/_cli_shim.py` | 独立子进程入口,被编译出的 `.mockbin/<cmd>` 脚本调用,复用 `mocks.py` 的 `_matches` 语义在规则树里做匹配 | `main`、`_resolve` |
83
83
  | `tools/skill/skill.py` | `{builtin: skill}` 默认 Handler:按 Skill 目录 + 文件名读取 Skill 正文/子文件 | `SkillTool`、`read_skill`(`= SkillTool().run`) |
84
84
  | `llm.py` | LLM Provider 适配层,把统一消息格式转换成 LiteLLM 调用参数;提供可脚本化的确定性 Client 供测试/回放用 | `LLMClient`(抽象)、`LiteLLMClient`、`ScriptedLLMClient` |
85
- | `runner.py` | 核心编排:按 run/step/request 三层驱动一次 Case 执行 | `YamaRunner`、`RunResult`、`CaseResult`、`MaxToolRoundsExceeded` |
85
+ | `runner.py` | 核心编排:按 run/step/request 三层驱动一次 Case 执行,并通过 `on_event` 回调对外发布进度事件(见第 13 节) | `YamaRunner`、`RunResult`、`CaseResult`、`RunnerEventCallback`、`MaxToolRoundsExceeded` |
86
86
  | `assertions.py` | 硬断言(tool_called / assistant_matches / jsonpath 等)与 LLM-as-Judge 的实现 | `run_hard_assertions`、`run_judge` |
87
87
  | `report.py` | 把执行结果渲染成单个自包含 HTML 报告 | `write_html_report` |
88
- | `cli.py` | 命令行入口:串联 config → loaders → runner → report,Rich 表格/树状终端输出 | `main`、`build_results_renderable` |
88
+ | `cli.py` | 命令行入口:串联 config → loaders → runner → report;按 `--concurrency` 并行调度多个 Case(asyncio),执行中流式打印进度,收尾打印汇总表格 | `main`、`ProgressPrinter`、`ParallelProgressPrinter`、`build_case_tree`、`build_summary_table`、`build_results_renderable` |
89
89
 
90
90
  ### 3.2 一次 Case 执行的数据流
91
91
 
@@ -141,6 +141,9 @@ cli.main
141
141
  `id(context.state)` 做 `ShellSession` 的 key)。
142
142
  - **`LLMClient`**:`LiteLLMClient` 走真实 Provider,`ScriptedLLMClient` 用于
143
143
  确定性测试/回放,两者共用同一套消息/工具转换逻辑 (`_litellm_call_arguments`)。
144
+ 脚本响应可带 `expect`(`tools`/`last_role`/`last_user_contains`)对当次请求做
145
+ 断言;请求没有工具时 litellm 参数会整体省略 `tools` 键,`expect: {tools: []}`
146
+ 按空列表匹配(Judge 请求正是这种无工具请求)。
144
147
 
145
148
  ## 4. Workspace 与 Plugin
146
149
 
@@ -214,17 +217,38 @@ yama --plugin-root ./dingding-simple
214
217
  | `--plugin-root PATH` | 以指定路径作为单一 Plugin Root |
215
218
  | `--plugin NAME`(可重复) | 按 `yama.toml` 中的 Plugin 名字选择,一次可传多次 |
216
219
  | `--all-plugins` | 运行 `yama.toml` 中配置的全部 Plugin |
217
- | `--response-script PATH` | 用 `ScriptedLLMClient` 回放一份确定性响应脚本,不调用真实模型 |
218
220
  | `--result-dir PATH` | 覆盖产物根目录(默认每个 Case 写到其所属 `plugin_root/.yama/runs`) |
221
+ | `--concurrency N` | 同时运行的 Case 数上限(必须 ≥ 1,默认 10);`1` 表示按收集顺序逐个执行 |
219
222
  | `--report [PATH]` | 额外写一份单文件 HTML 报告;省略路径时默认写到 `<第一个 result_root 的上级>/reports/latest.html` |
220
223
  | `--list` | 只收集并打印 `case_key` 列表,不运行 |
221
224
  | `--no-artifacts` | 不写任何产物文件 |
222
- | `--json` | 以机器可读 JSON 数组打印结果,而不是 Rich 表格 |
225
+ | `--json` | 以机器可读 JSON 数组打印结果(进度流转到 stderr,stdout 保持纯 JSON) |
223
226
 
224
227
  `--plugin`/`--all-plugins`/`--plugin-root` 三者互斥,都不提供时默认用 cwd 向上搜索到的
225
228
  Workspace Root(或 cwd 本身)作为单一 Plugin Root——这正是 `cd dingding-simple && yama`
226
229
  可行的原因。
227
230
 
231
+ **Case 级并发调度(`--concurrency`,`cli.py:_run`)。** 收集到的多个 Case 用
232
+ `asyncio.Semaphore(concurrency)` + `asyncio.gather` 在同一事件循环里并发执行
233
+ (执行链路本就是全异步:LiteLLM `acompletion`、bash 沙箱的 asyncio 子进程——
234
+ 不是 OS 线程,工作负载是 I/O 密集的 LLM 请求,事件循环并发即可拿到全部吞吐)。
235
+ 语义边界:
236
+
237
+ - 并发单位是 **Case**;同一 Case 内 `execution.repeat` 的多个 run 仍严格顺序执行。
238
+ - 每个 Case 用独立的 `YamaRunner` + 独立的 `LiteLLMClient`——runner 在每次
239
+ `complete()` 后回读 client 的 `last_request`/`last_provider` 写入请求记录,
240
+ 共享 client 会被并发 Case 互相覆盖。
241
+ - 结果数组保持**收集顺序**(`gather` 保序),与完成先后无关;汇总表格、`--json`
242
+ 输出、HTML 报告的 Case 顺序因此在任何并发度下都稳定。
243
+ - 某个 Case 抛出异常(罕见:run 内的错误都会被 `_run_once` 捕获进
244
+ `RunResult.error`)时,其余 Case 仍会跑完并写完产物(`gather`
245
+ `return_exceptions=True`),随后第一个异常按原有 `main()` 错误出口重新抛出。
246
+ - Case 间的隔离不依赖新机制:bash 沙箱工作目录/产物目录本就按 `case_key` 分目录,
247
+ 持久 shell 会话按每 run 的 `state` 身份键控(见 8.4.3 与第 12 节)。
248
+ - 进度输出按并发模式切换(见第 13 节):并发 >1 且收集到多个 Case 时使用
249
+ `ParallelProgressPrinter`(终端底部一张原地刷新的逐 Case 状态面板 + 完成时
250
+ 整 Case 成块打印),否则保持逐 Step 流式的 `ProgressPrinter`。
251
+
228
252
  ## 5. 全局配置
229
253
 
230
254
  Workspace 根目录使用 `yama.toml`。**实际支持的字段只有以下这些**(`workspace.py:WorkspaceConfig`):
@@ -278,8 +302,9 @@ timeout_seconds_per_step = 60
278
302
  < Case 自己顶层的 model: / execution: 字段
279
303
  ```
280
304
 
281
- **不存在** CLI 对 `model`/`execution`/超时参数的覆盖层——CLI 唯一能覆盖的运行期配置是
282
- `--result-dir`(产物根目录)。也**不存在** `[conventions]`、`[templates]` 两个配置表,
305
+ **不存在** CLI 对 `model`/`execution`/超时参数的覆盖层——CLI 能覆盖的运行期配置只有
306
+ `--result-dir`(产物根目录)和 `--concurrency`(Case 级并发上限,纯调度参数,
307
+ 不影响任何 Case 语义)。也**不存在** `[conventions]`、`[templates]` 两个配置表,
283
308
  也没有 `baseline_dir` 字段:
284
309
 
285
310
  - `[conventions]`:System Prompt/Skill 目录/入口文件名等约定只能在 **Plugin 级别**
@@ -901,10 +926,11 @@ transcript,不提供"只影响这一次请求"的临时选项,也不支持 `
901
926
 
902
927
  ## 8. Case Schema
903
928
 
904
- Case Schema 按"模型与 Context → Tool 执行 → 对话 Step → Step 断言 → Case 结果门槛"的层级组织。Case 相对 Plugin Root 的文件路径就是唯一身份(`case_key`),不再重复声明 `id`、`description` 或 `tags`。
929
+ Case Schema 按"模型与 Context → Tool 执行 → 对话 Step → Step 断言 → Case 结果门槛"的层级组织。Case 相对 Plugin Root 的文件路径就是唯一身份(`case_key`),不再重复声明 `id` 或 `tags`;可选的顶层 `description` 只是给人看的一句话说明(这个 Case 测试什么),不参与身份判定,会展示在 CLI 进度/汇总输出与 HTML 报告的 Case 头部(`loaders/case.py` 解析时校验必须是字符串并 strip 首尾空白)。
905
930
 
906
931
  ```text
907
932
  Case
933
+ ├── description 可选:一句话描述本 Case 测试什么
908
934
  ├── model 本 Case 的模型覆盖
909
935
  ├── context 模型实际看见的输入
910
936
  │ ├── system_prompt
@@ -934,6 +960,7 @@ Case
934
960
 
935
961
  | 字段 | 必填 | 含义 |
936
962
  | --- | --- | --- |
963
+ | `description` | 否 | 一句话说明当前 Case 测试什么;展示在 CLI 与 HTML 报告中,并写入 `case.resolved.yaml` 与 `CaseResult`。 |
937
964
  | `model` | 否 | 覆盖 Workspace / Plugin 默认模型。 |
938
965
  | `context` | 是 | 当前 Case 发给模型的全部显式输入。 |
939
966
  | `mocks` | 按需 | Tool Handler、参数匹配、初始 state 和有状态 Python Tool Mock。 |
@@ -1295,10 +1322,21 @@ mocks:
1295
1322
  持久 bash 子进程绑定。这个路径是 `plugin_root/case_key/run_index` 的纯函数,Python
1296
1323
  Handler 可以在物化发生之前就用包根导出的 `workspace_dir(context)`(定义在
1297
1324
  `tools/bash/fs.py`)预先计算它;首次物化时同一路径也会写入共享 state 的
1298
- `__fs__.workspace_dir`,供没有 `ToolMockContext` 的 Python Checker 读取。run 结束(成功、断言失败或异常)时框架在 `runner.py` 的
1299
- `finally` 块里保证调用 `cleanup_session` 杀掉这个进程,工作目录本身不自动清理,
1300
- 方便事后排查。因为是同一个真实进程贯穿整个 run,`cd`、`export`、写文件等状态天然
1301
- 延续到下一次 Tool Call,不需要额外的状态字典维护 cwd/环境。
1325
+ `__fs__.workspace_dir`,供没有 `ToolMockContext` 的 Python Checker 读取。
1326
+
1327
+ 物化时机以每 run 共享 state 里的 `__fs__` 标记为准,而不是"目录是否已存在"
1328
+ (`fs.py:_get_session`):run 的第一次 `bash` 调用总会执行 `materialize_workspace`
1329
+ (即使 Python Handler 已提前创建了该目录),把当前 Case 配置声明的 `files`、
1330
+ `.mockbin/` 假命令和编译后的 `mocks.cli` 规则文件全部写到最新状态;run 中途因超时/
1331
+ 会话死亡而重建 shell 会话时则不再重复物化,模型已写入的文件得以保留。此外
1332
+ `YamaRunner.run_case` 在一个 Case 的第一轮 run 开始前会整体删除
1333
+ `.yama/fs-runs/<sanitized-case-key>/`(`runner.py:_clean_case_dirs`)——run 编号每次
1334
+ 执行都从 1 重新计数,不先清掉上一次执行遗留的同名工作目录,本次执行就会复用过期的
1335
+ mock 脚本与旧文件,结果不可复现。run 结束(成功、断言失败或异常)时框架在
1336
+ `runner.py` 的 `finally` 块里保证调用 `cleanup_session` 杀掉持久 shell 进程,
1337
+ 工作目录本身保留到下一次执行该 Case 前才被清掉,方便事后排查。因为是同一个真实
1338
+ 进程贯穿整个 run,`cd`、`export`、写文件等状态天然延续到下一次 Tool Call,不需要
1339
+ 额外的状态字典维护 cwd/环境。
1302
1340
 
1303
1341
  **命令执行:持久 shell + marker 协议。** 每次 Tool Call 把命令包装成如下 payload
1304
1342
  写入这个 shell 的 stdin:
@@ -1919,7 +1957,11 @@ Registry 的执行顺序固定为:
1919
1957
  `request_index`、`call_index`、`handler_kind`(`"python"` 或 `"declarative"`)、
1920
1958
  `callable`(Python Handler 的点分路径,声明式 Mock 为 `None`)、`match_failed`、
1921
1959
  `arguments`、`result`、`is_error`、`duration_ms`、`state_diff`(`{op: add|remove|replace,
1922
- path, value|old}` 形式的差异列表)。Run 结束额外保存 `mock-state.json`;Python
1960
+ path, value|old}` 形式的差异列表)。`is_error` 的判定是语义化的
1961
+ (`mocks.py:result_is_error`,Mock Event 与 `ToolCallRecord.is_error` 共用同一函数):
1962
+ 结果携带**非 null** 的 `error` 字段,或是 bash 形状的 `{stdout, stderr, exit_code}`
1963
+ 信封且 `exit_code != 0` 时才算错误;成功结果里字面的 `error: null` 不算错误,
1964
+ `ToolMockError`/`match_failed` 路径则始终算错误。Run 结束额外保存 `mock-state.json`;Python
1923
1965
  Checker 从同一个最终 state 读取业务结果。Handler 源码本身不复制到 Judge 输入,
1924
1966
  也不发送给被测模型。
1925
1967
 
@@ -1981,7 +2023,7 @@ async def run_step(case, step, messages, registry, run_index, requests):
1981
2023
  context = ToolMockContext(..., call_index=registry.next_call_index(call.name))
1982
2024
  result = await registry.call(call.name, call.arguments, context)
1983
2025
  records.append(ToolCallRecord(..., call=call, result=result,
1984
- is_error=isinstance(result, dict) and "error" in result))
2026
+ is_error=result_is_error(result))) # 语义化判定,见第 9 章
1985
2027
  messages.append({
1986
2028
  "role": "tool",
1987
2029
  "tool_call_id": call.id,
@@ -2057,6 +2099,7 @@ class CaseResult:
2057
2099
  passed: bool
2058
2100
  runs: list[RunResult]
2059
2101
  pass_rate: float
2102
+ description: str = "" # Case 顶层 description 的透传,供 CLI/JSON 输出展示
2060
2103
  ```
2061
2104
 
2062
2105
  ```python
@@ -2106,6 +2149,13 @@ class ToolCallRecord:
2106
2149
  └── result.json # RunResult.to_dict() + generated_at + traceback?
2107
2150
  ```
2108
2151
 
2152
+ 写产物前,`YamaRunner.run_case` 会先整体删除该 Case 的产物目录
2153
+ `<result_root>/<sanitize(case_key)>/`(`runner.py:_clean_case_dirs`,与 8.4.3 节的
2154
+ `.yama/fs-runs/<case>` 清理同一处):run 编号每次执行都从 1 重新计数,若本次
2155
+ `execution.repeat` 比上次小,不清理就会留下过期的 `run-002` 等目录,人工或脚本
2156
+ 扫描 `.yama/runs` 时会把旧执行误当成本次结果。`--no-artifacts` 时不写也不删任何
2157
+ 产物目录(用户显式选择不落盘,不应顺带删掉历史产物),但 fs-runs 工作目录照常清理。
2158
+
2109
2159
  `--report` 触发的单文件 HTML 报告(`report.py:write_html_report`)是 CLI 层面单独
2110
2160
  生成的汇总产物,**不属于**上面这份逐 Case/逐 run 的产物列表,也不是按 Plugin 拆分的
2111
2161
  多个文件——一次 CLI 调用只写一个 HTML 文件,汇总本次涉及的所有 Case(见第 13 节)。
@@ -2367,21 +2417,98 @@ Step——不是按 Plugin 拆开的多个文件,也没有 JSON 版的 `summar
2367
2417
  <result_root 的上级>/reports/latest.html # --report 省略路径时的默认位置
2368
2418
  ```
2369
2419
 
2370
- 终端输出(不用 `--json` 时)是 Rich 表格 + 详情树:
2420
+ 终端输出(不用 `--json` 时)在执行过程中**实时流式打印进度**,形态取决于并发模式
2421
+ (见 4.3 节的 `--concurrency`);两种模式最后都以逐 Case 的汇总表格收尾。
2422
+
2423
+ **顺序模式**(`--concurrency 1`,或只收集到一个 Case):每个 Case、Run、Step
2424
+ 一完成就立即打印结果(含每条 hard check 的通过情况与失败详情、Judge 结论):
2371
2425
 
2372
2426
  ```text
2427
+ [1/2] <case_key>
2428
+ <description,若有>
2429
+ Run 1/2
2430
+ ✓ <step_id> hard checks 3/3 judge passed 92%
2431
+ ├── ✓ 01 <hard check label>
2432
+ └── ✗ 02 <hard check label>
2433
+ ├── Expected ...
2434
+ ├── Actual ...
2435
+ └── Reason ...
2436
+ ✓ <case_key> 2/2 runs passed 100%
2437
+
2373
2438
  Yama Eval Results
2374
- Result | Case | Runs | Pass rate
2439
+ Result | Case(含 description 副行) | Runs | Pass rate
2375
2440
  ...
2376
- Details
2377
- ✓ <case_key> 100%
2378
- ✓ Run 1
2379
- ✓ <step_id> hard checks 3/3 judge passed 92%
2380
- ✓ 01 <hard check label>
2381
2441
  ```
2382
2442
 
2383
- `--json` 输出机器可读的 `[CaseResult.to_dict(), ...]` 数组;`--list` 只打印
2384
- `case_key` 列表,不运行任何 Case。
2443
+ **并发模式**(并发 >1 且收集到多个 Case,默认即是):不同 Case 的 Step 结果会
2444
+ 乱序到达,逐 Step 流式打印会把不相关 Case 的行交错在错误的 Case 标题下,因此改为
2445
+ 在终端底部维护一张**原地刷新的逐 Case 状态面板**(transient `rich Live`):每个
2446
+ 收集到的 Case 固定占一行、按收集顺序排列,状态原地更新——`waiting`(排队等并发
2447
+ 槽位)→ spinner + 当前 `Run k/n · <step_id>` → `✓/✗` 加简要结果。任何一个 Case
2448
+ 一完成,它的完整 Run/Step/断言明细就作为**一个整块**打印到面板上方(块内结构与
2449
+ 顺序模式相同),块与块绝不交错;全部结束后面板消失,汇总表格收尾。面板只在 TTY
2450
+ 上渲染,管道/CI 输出只得到按完成顺序追加的 Case 块;结果数组与汇总表格仍按收集
2451
+ 顺序:
2452
+
2453
+ ```text
2454
+ (面板上方,按完成顺序逐块追加)
2455
+ ✓ <case_key B> 100%
2456
+ ├── ✓ Run 1
2457
+ │ └── ✓ <step_id> hard checks 3/3
2458
+ ...
2459
+
2460
+ (终端底部的临时面板,逐行原地刷新)
2461
+ ⠧ <case_key A> Run 1/2 · <step_id>
2462
+ ✓ <case_key B> 1/1 runs 100%
2463
+ · <case_key C> waiting
2464
+ ```
2465
+
2466
+ 流式进度由 `YamaRunner` 的进度回调驱动(`runner.py:RunnerEventCallback`,
2467
+ 构造参数 `on_event`)。每个 Case 的事件顺序固定为:`case_start`
2468
+ `{case_key, description, repeat}` → 每个 run:`run_start` `{case_key, run_index,
2469
+ repeat}` → 每个 Step:`step_start` `{case_key, run_index, step_id}`、`step_end`
2470
+ `{case_key, run_index, step: StepResult}` → `run_end` `{case_key, run:
2471
+ RunResult}` → `case_end` `{result: CaseResult}`。`step_end` 在该 Step 的 hard
2472
+ check 与 Judge 都结算完之后才触发(含 max-tool-rounds 失败的 Step),payload
2473
+ 携带的是最终判定;run 在 Step 中途死掉(超时、Handler 异常)时该 Step 没有
2474
+ `step_end`,但 `run_end` 仍会触发(在产物写盘之后)。并发执行时多个 Case 的事件
2475
+ 流会在时间上交错,但单个 Case 内部的事件顺序不变(每个事件 payload 都带
2476
+ `case_key` 可供归属)。
2477
+
2478
+ CLI 侧按并发模式挑选回调实现,两者的**已完成结果**都只做顺序追加打印(不回改
2479
+ 已输出内容),管道/CI 日志中同样可读;动态元素(spinner/面板)都是 transient
2480
+ 的、仅 TTY 可见:
2481
+
2482
+ - `cli.py:ProgressPrinter`(顺序模式):逐事件流式打印;唯一的动态元素是
2483
+ `step_start` 到下一个事件之间显示的临时 spinner(`rich Status`,标出正在执行的
2484
+ Step),任何后续事件到来都会先停掉它再打印。
2485
+ - `cli.py:ParallelProgressPrinter`(并发模式):构造时接收全部收集到的 Case,
2486
+ 为每个 Case 预建一行 `waiting` 状态;`case_start`/`run_start`/`step_start`
2487
+ 只原地更新对应行的状态(首个事件时惰性启动 transient `rich Live` 面板,
2488
+ `get_renderable` 每个刷新帧重建全部行——事件处理只整体替换行 dict、从不原地
2489
+ 改写,避免与 Live 的刷新线程读写竞争);`case_end` 用 `build_case_tree` 从最终
2490
+ `CaseResult` 渲染整 Case 块打印到面板上方,并把该行翻成 `✓/✗`;最后一个
2491
+ `case_end` 后自动停掉面板。某个 Case 在 `case_end` 之前异常退出时面板不会自行
2492
+ 停止,由 `cli.py:_run` 在 `gather` 结束后统一调用 `progress.close()` 兜底
2493
+ (两个 printer 都实现了 `close()`)。两个容易回归的实现约束:
2494
+ - 所有 running 行共用**构造期创建的单个 `rich Spinner` 实例**(行内容每帧
2495
+ 重建,但 spinner 不能跟着重建——`Spinner.start_time` 会被每帧重置,动画
2496
+ 永远冻结在第 0 帧)。
2497
+ - 面板在 TTY 上启动时用 termios 关闭 stdin 回显(`ECHO|ECHONL`),`close()`
2498
+ 恢复。否则用户随手按下的回车会被终端回显成换行、顶移光标,Live 依赖
2499
+ "自己画了几行"回退光标重绘,起点一失位就把面板首行残留进滚动区(表现为
2500
+ 某一行被不断重复)。stdin 不是 TTY 或 termios 失败时静默跳过。
2501
+
2502
+ `--json` 输出机器可读的 `[CaseResult.to_dict(), ...]` 数组(此时进度流打印到
2503
+ stderr,保证 stdout 是纯 JSON);`--list` 只打印 `case_key` 列表,不运行任何
2504
+ Case。
2505
+
2506
+ `cli.py:main` 的错误出口按层归类(退出码都是 2):`ConfigurationError`/
2507
+ `CollectionError`/`ValueError` 打印 `Collection error: ...`(Case 还没跑起来,
2508
+ 问题出在工作区配置或 Case 收集/解析);`LLMError` 单独打印 `LLM error: ...`——
2509
+ 此时 Case 往往已经收集甚至执行过(例如脚本回放响应未被消费、Provider 配置缺失),
2510
+ 把它标成 Collection error 会把排查引到错误的层级。run 内部的 LLM 异常仍由
2511
+ `YamaRunner._run_once` 捕获进 `RunResult.error`,不走这个出口。
2385
2512
 
2386
2513
  一个 Plugin 的 Skill、Tool、Case、产物目录不会泄漏到另一个 Plugin——这一点由
2387
2514
  "每个 Case 归属唯一 Plugin Root、产物写在该 Plugin 自己的 `.yama/` 下"这一实现
@@ -2464,9 +2591,10 @@ Details
2464
2591
  `ScriptedLLMClient` 能回放 **LLM 响应**,没有对应的 Tool Call 录制/回放机制。
2465
2592
  - **参数矩阵**:对同一 Case 用多组参数矩阵批量展开执行——当前 `execution.repeat`
2466
2593
  只是一个单纯的重复次数整数,不是参数矩阵。
2467
- - **HTML Transcript Viewer 的进一步能力**、**人工评分与 Judge 校准**、**并发/远程
2594
+ - **HTML Transcript Viewer 的进一步能力**、**人工评分与 Judge 校准**、**远程
2468
2595
  执行**:`report.py` 目前只产出一个静态汇总 HTML,没有专门的单 Case 交互式
2469
- Transcript Viewer;Case 之间目前是顺序执行,没有并发调度。
2596
+ Transcript Viewer;Case 级的本地并发调度已实现(CLI `--concurrency`,默认 10,
2597
+ 见 4.3 节),但仍没有把执行分发到远程机器的能力。
2470
2598
 
2471
2599
  已经完成、且与原设计基本对齐或已按上文修正描述的能力(供快速核对现状):
2472
2600
 
@@ -31,7 +31,8 @@ Context(System Prompt / Skill / Tool Schema / 历史消息)、Tool 如何被
31
31
 
32
32
  Case 内所有相对路径(`context.tools` 的 `file:`、`mocks.cli`/`mocks.fs` 的文件引用、
33
33
  Python Handler/Checker 路径、fixture 路径)一律相对 `__evals__` 目录解析。
34
- Case 文件相对 Plugin Root 的路径就是它的唯一身份 `case_key`,不需要在文件里声明 id。
34
+ Case 文件相对 Plugin Root 的路径就是它的唯一身份 `case_key`,不需要在文件里声明 id;
35
+ 可选的顶层 `description` 用一句话说明该 Case 测试什么,会展示在 CLI 输出和 HTML 报告中。
35
36
 
36
37
  ## 编写用例
37
38
 
@@ -39,6 +40,8 @@ Case 文件相对 Plugin Root 的路径就是它的唯一身份 `case_key`,不
39
40
  `steps`(依次发送的用户回合与断言)→ `outcome`(Case 级通过门槛):
40
41
 
41
42
  ```yaml
43
+ description: 模型应先读 DSL 再给出差异化的创意方向 # 可省略,展示在 CLI 与报告中
44
+
42
45
  model: { name: gpt-5, temperature: 0 } # 可省略,继承 yama.toml 默认
43
46
 
44
47
  context:
@@ -105,23 +108,43 @@ outcome:
105
108
  完整 Schema(多模态消息、`message_inject`、`mocks.cli` 命令树、`mocks.fs` 沙箱、
106
109
  Python Handler / Checker、Judge 配置)见 [references/case-schema.md](references/case-schema.md)。
107
110
 
111
+ ## 安装
112
+
113
+ yama 在 PyPI 上的发行名是 `python-yama`(安装后的命令行入口仍叫 `yama`),要求
114
+ Python ≥ 3.12。推荐装成全局命令行工具:
115
+
116
+ ```bash
117
+ uv tool install python-yama # 或 pipx install python-yama / pip install python-yama
118
+ yama --help # 验证安装成功
119
+ ```
120
+
121
+ 已安装过的话,用 `uv tool upgrade python-yama` 升级到最新版。
122
+
108
123
  ## 运行
109
124
 
125
+ 以下命令假定 `yama` 已按上一节安装、可直接调用:
126
+
110
127
  ```bash
111
128
  # 在 Plugin 根目录直接运行(默认收集 __evals__/cases/**/*.yaml)
112
129
  cd <plugin-root>
113
- OPENAI_API_KEY=... uv run --project yama yama
130
+ OPENAI_API_KEY=... yama
114
131
 
115
132
  # 在 Workspace 根目录(存在 yama.toml)按名字选 Plugin,并生成 HTML 报告
116
- uv run --project yama yama --plugin <name> --report
133
+ yama --plugin <name> --report
117
134
 
118
135
  # 只跑一个 Case;只列出会收集到哪些 Case
119
- uv run --project yama yama __evals__/cases/foo.yaml
120
- uv run --project yama yama --list
136
+ yama __evals__/cases/foo.yaml
137
+ yama --list
121
138
  ```
122
139
 
123
- 退出码:`0` 全部通过;`1` 有 Case 失败;`2` Collection error 或没收集到任何 Case;
124
- `130` 手动中断。
140
+ 多个 Case 默认并行执行(最多同时 10 个,`--concurrency N` 调整;Case 内的多个
141
+ run 仍顺序执行)。并行时终端底部有一张原地刷新的逐 Case 状态面板(等待/执行中的
142
+ Run·Step/✓✗),每个 Case 的 Run/Step 明细在该 Case 完成后整块打印到面板上方;
143
+ 需要逐 Step 实时流式输出来盯一个用例时,用 `--concurrency 1` 或只跑那一个 Case。
144
+
145
+ 退出码:`0` 全部通过;`1` 有 Case 失败;`2` Collection error、LLM error
146
+ (stderr 分别打印 `Collection error: ...` / `LLM error: ...`)或没收集到任何
147
+ Case;`130` 手动中断。
125
148
 
126
149
  ## 排查不通过的用例
127
150
 
@@ -132,6 +155,7 @@ uv run --project yama yama --list
132
155
  | 现象 | 层级 | 去哪看 |
133
156
  | --- | --- | --- |
134
157
  | stderr 打印 `Collection error: ...`,退出码 2 | 用例根本没跑:YAML/Schema/路径/配置错误 | 错误消息本身,对照上面「硬规则」 |
158
+ | stderr 打印 `LLM error: ...`,退出码 2 | LLM 层错误(Provider 配置缺失、脚本回放响应未消费),Case 可能已经收集甚至执行过 | 错误消息本身;已写出的产物目录 |
135
159
  | 退出码 1,某 Run 标红且带 error | run 级基础设施失败(未 Mock 的 Tool 被调用、sequence 用尽、Step 超时、Handler 抛异常、LLM 请求失败) | `result.json` 的 `runs[].error` / `traceback` |
136
160
  | 退出码 1,某 Step 的 hard check 失败 | 断言失败(模型行为不符合预期,或断言写错) | 终端展开的 `expected/actual/reason`;`hard-checks.json` |
137
161
  | hard check 全过但 Case 失败 | Judge 不达标 | `judge-result.json` 各维度 `score/reason/evidence` |