python-yama 0.3.0__tar.gz → 0.5.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 (57) hide show
  1. {python_yama-0.3.0 → python_yama-0.5.0}/PKG-INFO +18 -3
  2. {python_yama-0.3.0 → python_yama-0.5.0}/README.md +16 -2
  3. {python_yama-0.3.0 → python_yama-0.5.0}/README.zh-CN.md +16 -2
  4. {python_yama-0.3.0 → python_yama-0.5.0}/docs/agent-skill-test-framework-design.md +379 -65
  5. python_yama-0.5.0/docs/yama-intro.html +815 -0
  6. {python_yama-0.3.0 → python_yama-0.5.0}/pyproject.toml +1 -0
  7. {python_yama-0.3.0 → python_yama-0.5.0}/skills/eval-plugin-with-yama/SKILL.md +25 -6
  8. {python_yama-0.3.0 → python_yama-0.5.0}/skills/eval-plugin-with-yama/references/case-schema.md +62 -6
  9. {python_yama-0.3.0 → python_yama-0.5.0}/skills/eval-plugin-with-yama/references/debugging.md +19 -5
  10. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_assertions.py +23 -2
  11. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_cli.py +353 -16
  12. python_yama-0.5.0/tests/test_dashboard.py +263 -0
  13. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_framework.py +345 -0
  14. python_yama-0.5.0/tests/test_llm.py +183 -0
  15. python_yama-0.5.0/tests/test_preview.py +337 -0
  16. python_yama-0.5.0/tests/test_report.py +563 -0
  17. python_yama-0.5.0/tests/test_run_plan.py +150 -0
  18. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_skill_tool.py +18 -2
  19. python_yama-0.5.0/tests/test_tool_loader.py +343 -0
  20. python_yama-0.5.0/tests/test_usage.py +224 -0
  21. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_workspace.py +102 -0
  22. {python_yama-0.3.0 → python_yama-0.5.0}/uv.lock +2 -0
  23. {python_yama-0.3.0 → python_yama-0.5.0}/yama/assertions.py +4 -0
  24. {python_yama-0.3.0 → python_yama-0.5.0}/yama/cli.py +244 -48
  25. python_yama-0.5.0/yama/dashboard.py +320 -0
  26. {python_yama-0.3.0 → python_yama-0.5.0}/yama/llm.py +83 -19
  27. {python_yama-0.3.0 → python_yama-0.5.0}/yama/loaders/case.py +12 -33
  28. python_yama-0.5.0/yama/loaders/tool_loader.py +324 -0
  29. {python_yama-0.3.0 → python_yama-0.5.0}/yama/models.py +1 -0
  30. python_yama-0.5.0/yama/preview.py +384 -0
  31. python_yama-0.5.0/yama/report.py +1354 -0
  32. {python_yama-0.3.0 → python_yama-0.5.0}/yama/runner.py +151 -14
  33. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/bash/fs.py +13 -2
  34. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/skill/skill.py +8 -2
  35. {python_yama-0.3.0 → python_yama-0.5.0}/yama/workspace.py +29 -0
  36. python_yama-0.3.0/tests/test_report.py +0 -149
  37. python_yama-0.3.0/yama/loaders/tool_loader.py +0 -173
  38. python_yama-0.3.0/yama/report.py +0 -861
  39. {python_yama-0.3.0 → python_yama-0.5.0}/.github/workflows/publish.yml +0 -0
  40. {python_yama-0.3.0 → python_yama-0.5.0}/.gitignore +0 -0
  41. {python_yama-0.3.0 → python_yama-0.5.0}/CLAUDE.md +0 -0
  42. {python_yama-0.3.0 → python_yama-0.5.0}/LICENSE +0 -0
  43. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_cli_shim.py +0 -0
  44. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_main_entrypoint.py +0 -0
  45. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_mocks.py +0 -0
  46. {python_yama-0.3.0 → python_yama-0.5.0}/tests/test_public_api.py +0 -0
  47. {python_yama-0.3.0 → python_yama-0.5.0}/yama/__init__.py +0 -0
  48. {python_yama-0.3.0 → python_yama-0.5.0}/yama/__main__.py +0 -0
  49. {python_yama-0.3.0 → python_yama-0.5.0}/yama/loaders/__init__.py +0 -0
  50. {python_yama-0.3.0 → python_yama-0.5.0}/yama/loaders/common.py +0 -0
  51. {python_yama-0.3.0 → python_yama-0.5.0}/yama/mocks.py +0 -0
  52. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/__init__.py +0 -0
  53. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/base.py +0 -0
  54. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/bash/__init__.py +0 -0
  55. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/bash/_cli_shim.py +0 -0
  56. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/bash/bash.py +0 -0
  57. {python_yama-0.3.0 → python_yama-0.5.0}/yama/tools/skill/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-yama
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: A reproducible evaluation runner for tool-using Agent skills
5
5
  Project-URL: Repository, https://github.com/world-sim-dev/yama
6
6
  Project-URL: Issues, https://github.com/world-sim-dev/yama/issues
@@ -19,6 +19,7 @@ Requires-Dist: fastapi>=0.139.0
19
19
  Requires-Dist: jinja2>=3.1
20
20
  Requires-Dist: litellm<2.0,>=1.80
21
21
  Requires-Dist: orjson>=3.11.9
22
+ Requires-Dist: python-dotenv>=1.0
22
23
  Requires-Dist: pyyaml>=6.0
23
24
  Requires-Dist: rich<15.0,>=14.1
24
25
  Description-Content-Type: text/markdown
@@ -40,6 +41,8 @@ OPENAI_API_KEY=... uv run --project yama yama
40
41
  OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
41
42
  ```
42
43
 
44
+ Instead of prefixing every command, you can put credentials in a `.env` file: on startup the CLI loads the nearest `.env` found from the working directory upward (variables already set in the environment are not overridden).
45
+
43
46
  ## Writing a Case
44
47
 
45
48
  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):
@@ -75,7 +78,7 @@ outcome:
75
78
 
76
79
  - `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
77
80
  - `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?)`.
81
+ - 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?, call_reason?)`.
79
82
  - To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
80
83
  - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); add `assert.judge` for LLM scoring.
81
84
 
@@ -93,13 +96,25 @@ uv run --project yama yama --plugin dingding-simple --report
93
96
  | `--plugin-root PATH` | Use the given path as the single plugin root |
94
97
  | `--plugin NAME` (repeatable) | Select plugins by name from `yama.toml` |
95
98
  | `--all-plugins` | Run every plugin configured in `yama.toml` |
99
+ | `-k, --filter PATTERN` (repeatable) | Only run cases whose case key (path relative to the plugin root) matches — a substring, or an fnmatch glob when the pattern contains `*` `?` `[`; with several patterns a case runs if any matches |
96
100
  | `--result-dir PATH` | Override the artifact root (default `<plugin_root>/.yama/runs`) |
97
101
  | `--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`) |
102
+ | `--report [PATH]` | Also generate a single-file HTML report. Without PATH it writes a timestamped `.yama/reports/report-<ts>.html` (history accumulates) and keeps `.yama/reports/latest.html` as a symlink to the newest one; an explicit PATH writes exactly that file |
103
+ | `--preview` | Don't run anything (no LLM calls): resolve the collected Cases and write an HTML case preview (default `.yama/reports/preview.html`; `--report PATH` overrides), or print a JSON preview to stdout when combined with `--json` |
99
104
  | `--list` | Only print the collected Cases, without running them |
100
105
  | `--no-artifacts` | Write no artifact files at all |
101
106
  | `--json` | Emit machine-readable JSON instead of Rich tables |
102
107
 
103
108
  `--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
109
 
110
+ ### Dashboard
111
+
112
+ ```bash
113
+ uv run --project yama yama dashboard --plugin dingding-simple
114
+ ```
115
+
116
+ `yama dashboard` starts a local HTTP server (default `http://127.0.0.1:8765/`, change with `--host`/`--port`; it also accepts the same plugin selection flags as the main command plus `-k/--filter` and `--result-dir`). The index page lists the historical HTML reports accumulated under `.yama/reports/` (newest first, with the `latest` one flagged), `/reports/<name>` serves each report, and `/preview` renders the same case preview as `--preview` — re-collecting and re-resolving the case files on every refresh (collection errors render as an error page), so you can edit a Case YAML and just reload the browser. No LLM calls are ever made by the dashboard.
117
+
118
+ ### Output
119
+
105
120
  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.
@@ -15,6 +15,8 @@ OPENAI_API_KEY=... uv run --project yama yama
15
15
  OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
16
16
  ```
17
17
 
18
+ Instead of prefixing every command, you can put credentials in a `.env` file: on startup the CLI loads the nearest `.env` found from the working directory upward (variables already set in the environment are not overridden).
19
+
18
20
  ## Writing a Case
19
21
 
20
22
  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):
@@ -50,7 +52,7 @@ outcome:
50
52
 
51
53
  - `description` (optional) is a one-line summary of what the Case tests; it is shown in the CLI output and the HTML report.
52
54
  - `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?)`.
55
+ - 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?, call_reason?)`.
54
56
  - To simulate command-line tools, declare `{builtin: bash}` and configure per-command output under `mocks.cli`.
55
57
  - `steps[].assert.hard` are deterministic checks (nine types, including `tool_called`, `tool_arguments`, and `assistant_contains`); add `assert.judge` for LLM scoring.
56
58
 
@@ -68,13 +70,25 @@ uv run --project yama yama --plugin dingding-simple --report
68
70
  | `--plugin-root PATH` | Use the given path as the single plugin root |
69
71
  | `--plugin NAME` (repeatable) | Select plugins by name from `yama.toml` |
70
72
  | `--all-plugins` | Run every plugin configured in `yama.toml` |
73
+ | `-k, --filter PATTERN` (repeatable) | Only run cases whose case key (path relative to the plugin root) matches — a substring, or an fnmatch glob when the pattern contains `*` `?` `[`; with several patterns a case runs if any matches |
71
74
  | `--result-dir PATH` | Override the artifact root (default `<plugin_root>/.yama/runs`) |
72
75
  | `--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`) |
76
+ | `--report [PATH]` | Also generate a single-file HTML report. Without PATH it writes a timestamped `.yama/reports/report-<ts>.html` (history accumulates) and keeps `.yama/reports/latest.html` as a symlink to the newest one; an explicit PATH writes exactly that file |
77
+ | `--preview` | Don't run anything (no LLM calls): resolve the collected Cases and write an HTML case preview (default `.yama/reports/preview.html`; `--report PATH` overrides), or print a JSON preview to stdout when combined with `--json` |
74
78
  | `--list` | Only print the collected Cases, without running them |
75
79
  | `--no-artifacts` | Write no artifact files at all |
76
80
  | `--json` | Emit machine-readable JSON instead of Rich tables |
77
81
 
78
82
  `--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
83
 
84
+ ### Dashboard
85
+
86
+ ```bash
87
+ uv run --project yama yama dashboard --plugin dingding-simple
88
+ ```
89
+
90
+ `yama dashboard` starts a local HTTP server (default `http://127.0.0.1:8765/`, change with `--host`/`--port`; it also accepts the same plugin selection flags as the main command plus `-k/--filter` and `--result-dir`). The index page lists the historical HTML reports accumulated under `.yama/reports/` (newest first, with the `latest` one flagged), `/reports/<name>` serves each report, and `/preview` renders the same case preview as `--preview` — re-collecting and re-resolving the case files on every refresh (collection errors render as an error page), so you can edit a Case YAML and just reload the browser. No LLM calls are ever made by the dashboard.
91
+
92
+ ### Output
93
+
80
94
  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.
@@ -15,6 +15,8 @@ OPENAI_API_KEY=... uv run --project yama yama
15
15
  OPENAI_API_KEY=... uv run --project yama yama --plugin dingding-simple
16
16
  ```
17
17
 
18
+ 也可以把凭据写进 `.env` 文件,省去每次命令前缀:CLI 启动时会从当前目录向上查找并加载最近的 `.env`(已在环境中设置的变量不会被覆盖)。
19
+
18
20
  ## 编写一个 Case
19
21
 
20
22
  一个 Case 是一份 YAML 文件,按 `context`(模型看到什么)→ `mocks`(Tool 怎么被执行)→ `steps`(依次发送的用户回合与断言)→ `outcome`(整个 Case 的通过门槛)的结构组织:
@@ -50,7 +52,7 @@ outcome:
50
52
 
51
53
  - `description`(可选)是一句话说明当前 Case 测试什么;会展示在 CLI 输出和 HTML 报告中。
52
54
  - `context.tools` 是发给模型的 Tool Schema,`mocks.tools` 是 Runner 收到 Tool Call 后如何返回结果;两者的 Tool 名字集合必须完全一致。
53
- - 需要 Skill 时在 `context.skills` 中按名字声明,并在 `context.tools` 中同时声明 `{builtin: skill}`;模型通过 `skill(name, file?)` 读取正文。
55
+ - 需要 Skill 时在 `context.skills` 中按名字声明,并在 `context.tools` 中同时声明 `{builtin: skill}`;模型通过 `skill(name, file?, call_reason?)` 读取正文。
54
56
  - 需要模拟命令行工具时声明 `{builtin: bash}`,在 `mocks.cli` 中按命令配置输出。
55
57
  - `steps[].assert.hard` 是确定性检查(`tool_called`、`tool_arguments`、`assistant_contains` 等九种类型);还可以加 `assert.judge` 做 LLM 打分。
56
58
 
@@ -68,13 +70,25 @@ uv run --project yama yama --plugin dingding-simple --report
68
70
  | `--plugin-root PATH` | 以指定路径作为单一 Plugin Root |
69
71
  | `--plugin NAME`(可重复) | 按 `yama.toml` 中的 Plugin 名字选择 |
70
72
  | `--all-plugins` | 运行 `yama.toml` 中配置的全部 Plugin |
73
+ | `-k, --filter PATTERN`(可重复) | 只运行 case key(相对 Plugin Root 的路径)匹配 PATTERN 的 Case——默认子串匹配,PATTERN 含 `*` `?` `[` 时按 fnmatch 通配符匹配;传多个时命中任意一个即运行 |
71
74
  | `--result-dir PATH` | 覆盖产物根目录(默认 `<plugin_root>/.yama/runs`) |
72
75
  | `--concurrency N` | 同时运行的 Case 数上限(默认 10;`1` 表示逐个顺序执行) |
73
- | `--report [PATH]` | 额外生成单文件 HTML 报告(默认 `.yama/reports/latest.html`) |
76
+ | `--report [PATH]` | 额外生成单文件 HTML 报告。省略 PATH 时写带时间戳的 `.yama/reports/report-<ts>.html`(历史累积),并把 `.yama/reports/latest.html` 维护成指向最新报告的软链;显式给 PATH 时精确写到该文件 |
77
+ | `--preview` | 不运行、不发起任何 LLM 调用:解析收集到的 Case 后生成用例预览 HTML(默认 `.yama/reports/preview.html`,`--report PATH` 可覆盖);与 `--json` 组合时改为向 stdout 打印 JSON 预览 |
74
78
  | `--list` | 只打印匹配到的 Case,不运行 |
75
79
  | `--no-artifacts` | 不写任何产物文件 |
76
80
  | `--json` | 输出机器可读 JSON 而不是 Rich 表格 |
77
81
 
78
82
  `--plugin`/`--all-plugins`/`--plugin-root` 三者互斥;都不提供时默认用当前目录向上搜索到的 `yama.toml` 所在目录作为 Workspace Root(找不到则用 cwd),把该目录当作单一 Plugin Root 运行。
79
83
 
84
+ ### Dashboard
85
+
86
+ ```bash
87
+ uv run --project yama yama dashboard --plugin dingding-simple
88
+ ```
89
+
90
+ `yama dashboard` 启动一个本地 HTTP 服务(默认 `http://127.0.0.1:8765/`,可用 `--host`/`--port` 调整;同样接受主命令的 Plugin 选择参数以及 `-k/--filter`、`--result-dir`)。首页列出 `.yama/reports/` 下累积的历史 HTML 报告(时间倒序,标注 `latest` 指向的那份),`/reports/<name>` 提供各报告文件,`/preview` 渲染与 `--preview` 相同的用例预览页——每次刷新都重新收集、重新解析 Case 文件(收集失败会渲染成错误页),改完 Case YAML 刷新浏览器即可看到效果。dashboard 不会发起任何 LLM 调用。
91
+
92
+ ### 输出
93
+
80
94
  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。