agent-tune-kit 2.1.0__tar.gz → 2.2.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 (123) hide show
  1. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/.codex-plugin/plugin.json +1 -1
  2. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/.gitignore +2 -1
  3. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/PKG-INFO +51 -8
  4. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/README.en.md +50 -7
  5. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/README.md +50 -7
  6. {agent_tune_kit-2.1.0/src → agent_tune_kit-2.2.0}/agent_tune_kit/__init__.py +1 -1
  7. agent_tune_kit-2.2.0/agent_tune_kit/cli/__init__.py +3 -0
  8. agent_tune_kit-2.2.0/agent_tune_kit/cli/__main__.py +3 -0
  9. agent_tune_kit-2.2.0/agent_tune_kit/cli/dataset.py +81 -0
  10. agent_tune_kit-2.2.0/agent_tune_kit/cli/evaluation.py +22 -0
  11. agent_tune_kit-2.2.0/agent_tune_kit/cli/main.py +55 -0
  12. agent_tune_kit-2.2.0/agent_tune_kit/cli/output.py +11 -0
  13. agent_tune_kit-2.2.0/agent_tune_kit/cli/results.py +99 -0
  14. agent_tune_kit-2.2.0/agent_tune_kit/cli/visualize.py +55 -0
  15. agent_tune_kit-2.2.0/agent_tune_kit/datasets/__init__.py +4 -0
  16. agent_tune_kit-2.2.0/agent_tune_kit/datasets/prepare.py +39 -0
  17. agent_tune_kit-2.2.0/agent_tune_kit/datasets/truth.py +179 -0
  18. agent_tune_kit-2.2.0/agent_tune_kit/datasets/updates.py +226 -0
  19. agent_tune_kit-2.2.0/agent_tune_kit/datasets/validation.py +39 -0
  20. agent_tune_kit-2.2.0/agent_tune_kit/errors.py +9 -0
  21. agent_tune_kit-2.2.0/agent_tune_kit/execution/__init__.py +13 -0
  22. agent_tune_kit-2.2.0/agent_tune_kit/execution/calibration.py +135 -0
  23. agent_tune_kit-2.2.0/agent_tune_kit/execution/logs.py +147 -0
  24. agent_tune_kit-2.2.0/agent_tune_kit/execution/rules.py +78 -0
  25. agent_tune_kit-2.2.0/agent_tune_kit/execution/runner.py +696 -0
  26. agent_tune_kit-2.2.0/agent_tune_kit/execution/runtime.py +130 -0
  27. agent_tune_kit-2.2.0/agent_tune_kit/execution/tracing.py +216 -0
  28. {agent_tune_kit-2.1.0/src → agent_tune_kit-2.2.0}/agent_tune_kit/installer.py +1 -1
  29. agent_tune_kit-2.2.0/agent_tune_kit/results/__init__.py +4 -0
  30. agent_tune_kit-2.2.0/agent_tune_kit/results/assessment.py +162 -0
  31. agent_tune_kit-2.2.0/agent_tune_kit/results/evidence.py +815 -0
  32. agent_tune_kit-2.2.0/agent_tune_kit/results/judgments.py +142 -0
  33. agent_tune_kit-2.2.0/agent_tune_kit/results/summary.py +102 -0
  34. agent_tune_kit-2.2.0/agent_tune_kit/results/versions.py +140 -0
  35. agent_tune_kit-2.2.0/agent_tune_kit/utils/csv_io.py +36 -0
  36. agent_tune_kit-2.2.0/agent_tune_kit/utils/files.py +30 -0
  37. agent_tune_kit-2.2.0/agent_tune_kit/visualize/__init__.py +4 -0
  38. {agent_tune_kit-2.1.0/skills/atk-visualize-dataset/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/dataset}/app.js +77 -28
  39. {agent_tune_kit-2.1.0/skills/atk-visualize-dataset/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/dataset}/page.html +9 -0
  40. {agent_tune_kit-2.1.0/skills/atk-visualize-dataset/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/dataset}/styles.css +4 -0
  41. agent_tune_kit-2.1.0/skills/atk-visualize-dataset/scripts/generate_dataset_browser.py → agent_tune_kit-2.2.0/agent_tune_kit/visualize/dataset.py +52 -174
  42. agent_tune_kit-2.2.0/agent_tune_kit/visualize/failures.py +512 -0
  43. agent_tune_kit-2.2.0/agent_tune_kit/visualize/fields.py +45 -0
  44. agent_tune_kit-2.2.0/agent_tune_kit/visualize/history.py +585 -0
  45. agent_tune_kit-2.2.0/agent_tune_kit/visualize/render.py +35 -0
  46. agent_tune_kit-2.2.0/agent_tune_kit/workspace.py +7 -0
  47. agent_tune_kit-2.2.0/docs/cli-skill-modularization-plan.md +599 -0
  48. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/codex_agent_tuning_prd.md +2 -2
  49. agent_tune_kit-2.2.0/docs/execution-evidence-and-tracing-plan.md +902 -0
  50. agent_tune_kit-2.2.0/docs/ground-truth-and-grading-assessment-2026-10-25.md +405 -0
  51. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/shared-versioning-and-confirmation.md +70 -70
  52. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/skill-template-pack-usage.md +50 -9
  53. agent_tune_kit-2.2.0/docs/truth-and-assessment.md +106 -0
  54. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/pyproject.toml +9 -5
  55. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/check-release.py +104 -5
  56. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/install_plugin.py +2 -3
  57. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/release-version.py +2 -2
  58. agent_tune_kit-2.2.0/scripts/validate_skill_pack.py +417 -0
  59. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/skills/atk-dataset/SKILL.md +24 -8
  60. agent_tune_kit-2.2.0/skills/atk-dataset/scripts/update_dataset.py +18 -0
  61. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/skills/atk-diagnose/SKILL.md +32 -6
  62. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/skills/atk-eval/SKILL.md +24 -10
  63. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/skills/atk-init/SKILL.md +21 -10
  64. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/skills/atk-optimize/SKILL.md +18 -3
  65. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/skills/atk-report/SKILL.md +25 -3
  66. agent_tune_kit-2.2.0/skills/atk-visualize-dataset/SKILL.md +57 -0
  67. agent_tune_kit-2.2.0/skills/atk-visualize-dataset/scripts/generate_dataset_browser.py +18 -0
  68. agent_tune_kit-2.2.0/skills/atk-visualize-failures/SKILL.md +55 -0
  69. agent_tune_kit-2.2.0/skills/atk-visualize-failures/scripts/generate_failure_browser.py +18 -0
  70. agent_tune_kit-2.2.0/templates/.atk/runner/eval_runner.py.md +89 -0
  71. agent_tune_kit-2.2.0/templates/.atk/runner/failure_rule.py.md +31 -0
  72. agent_tune_kit-2.2.0/templates/.atk/runner/import_evidence.py.md +42 -0
  73. agent_tune_kit-2.2.0/tests/__init__.py +0 -0
  74. agent_tune_kit-2.1.0/templates/.atk/runner/eval_runner.py.md → agent_tune_kit-2.2.0/tests/fixtures/legacy_eval_runner.py.txt +1 -7
  75. agent_tune_kit-2.2.0/tests/fixtures/managed_v1.py.md +51 -0
  76. agent_tune_kit-2.2.0/tests/test_assessment_contract.py +183 -0
  77. agent_tune_kit-2.2.0/tests/test_cli_workflow.py +199 -0
  78. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_dataset_updates.py +3 -6
  79. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_diagnosis.py +4 -4
  80. agent_tune_kit-2.2.0/tests/test_evidence_import.py +160 -0
  81. agent_tune_kit-2.2.0/tests/test_evidence_judgments.py +63 -0
  82. agent_tune_kit-2.2.0/tests/test_evidence_packaging.py +11 -0
  83. agent_tune_kit-2.2.0/tests/test_evidence_versions.py +79 -0
  84. agent_tune_kit-2.2.0/tests/test_execution_evidence.py +196 -0
  85. agent_tune_kit-2.2.0/tests/test_execution_tracing.py +403 -0
  86. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_generate_dataset_browser.py +7 -10
  87. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_generate_failure_browser.py +17 -21
  88. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_install_plugin.py +3 -4
  89. agent_tune_kit-2.2.0/tests/test_judge_calibration.py +81 -0
  90. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_release_scripts.py +5 -5
  91. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_runner_template_row_logging.py +6 -10
  92. agent_tune_kit-2.2.0/tests/test_runtime_contracts.py +194 -0
  93. agent_tune_kit-2.2.0/tests/test_truth_browser.py +63 -0
  94. agent_tune_kit-2.2.0/tests/test_truth_cli.py +65 -0
  95. agent_tune_kit-2.2.0/tests/test_truth_contract.py +151 -0
  96. agent_tune_kit-2.2.0/tests/test_truth_runner.py +21 -0
  97. agent_tune_kit-2.1.0/docs/ground-truth-and-grading-assessment-2026-10-25.md +0 -158
  98. agent_tune_kit-2.1.0/scripts/validate_skill_pack.py +0 -913
  99. agent_tune_kit-2.1.0/skills/atk-dataset/scripts/update_dataset.py +0 -305
  100. agent_tune_kit-2.1.0/skills/atk-visualize-dataset/SKILL.md +0 -146
  101. agent_tune_kit-2.1.0/skills/atk-visualize-failures/SKILL.md +0 -100
  102. agent_tune_kit-2.1.0/skills/atk-visualize-failures/scripts/generate_failure_browser.py +0 -1176
  103. agent_tune_kit-2.1.0/src/agent_tune_kit/cli.py +0 -15
  104. agent_tune_kit-2.1.0/templates/.atk/runner/failure_rule.py.md +0 -126
  105. {agent_tune_kit-2.1.0/tests → agent_tune_kit-2.2.0/agent_tune_kit/utils}/__init__.py +0 -0
  106. {agent_tune_kit-2.1.0/skills/atk-visualize-dataset/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/dataset}/vendor/echarts.min.js +0 -0
  107. {agent_tune_kit-2.1.0/skills/atk-visualize-failures/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/failures}/app.js +0 -0
  108. {agent_tune_kit-2.1.0/skills/atk-visualize-failures/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/failures}/page.html +0 -0
  109. {agent_tune_kit-2.1.0/skills/atk-visualize-failures/assets → agent_tune_kit-2.2.0/agent_tune_kit/visualize/assets/failures}/styles.css +0 -0
  110. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/assets/arch-en.png +0 -0
  111. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/assets/arch.png +0 -0
  112. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/assets/architecture.en.svg +0 -0
  113. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/assets/architecture.svg +0 -0
  114. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/docs/local-context.md +0 -0
  115. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/dev-refresh-install.sh +0 -0
  116. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/publish-pypi.sh +0 -0
  117. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/publish-release.py +0 -0
  118. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/scripts/release-version.sh +0 -0
  119. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/templates/.gitkeep +0 -0
  120. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/conftest.py +0 -0
  121. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_atk_init_contract.py +0 -0
  122. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_local_context.py +0 -0
  123. {agent_tune_kit-2.1.0 → agent_tune_kit-2.2.0}/tests/test_plugin_cache.py +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-tune-kit",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Local Codex plugin for iterative Agent tuning with guided Skills, reusable runner templates, versioned results, and static validation.",
5
5
  "author": {
6
6
  "name": "hustyichi",
@@ -36,4 +36,5 @@ node_modules/
36
36
  .pnpm-store/
37
37
 
38
38
  # Agent tune kit generated outputs
39
- .atk/
39
+ .atk/
40
+ !templates/.atk/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agent-tune-kit
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Local Codex plugin for iterative Agent tuning with guided Skills, reusable runner templates, versioned results, and static validation.
5
5
  Project-URL: Homepage, https://github.com/hustyichi/agent-tune-kit
6
6
  Project-URL: Repository, https://github.com/hustyichi/agent-tune-kit
@@ -14,6 +14,12 @@ Description-Content-Type: text/markdown
14
14
 
15
15
  # Agent Tune Kit
16
16
 
17
+ Ground-truth reviews, judge calibration and assessment provenance are documented in
18
+ [the trust contract](docs/truth-and-assessment.md). Existing datasets remain readable, not automatically certified.
19
+ `atk dataset inspect/update` supports content-bound confirmations; `atk results calibrate` checks reviewed outputs
20
+ without executing the Agent or allocating an evaluation version. Rejudgments preserve history and comparisons expose
21
+ changes to their criteria and judge.
22
+
17
23
  English | [简体中文](README.md)
18
24
 
19
25
  [![PyPI](https://img.shields.io/pypi/v/agent-tune-kit.svg)](https://pypi.org/project/agent-tune-kit/)
@@ -46,13 +52,7 @@ This turns Agent tuning from one-off subjective trial and error into an engineer
46
52
 
47
53
  ## Install
48
54
 
49
- One-command install:
50
-
51
- ```sh
52
- uvx --from agent-tune-kit atk install
53
- ```
54
-
55
- To keep the `atk` command available:
55
+ Install the ATK CLI, then install its bundled Skills:
56
56
 
57
57
  ```sh
58
58
  uv tool install agent-tune-kit
@@ -192,3 +192,46 @@ Common output files:
192
192
  - `$atk-report`: generate analysis and cross-loop validation.
193
193
  - `$atk-visualize-failures`: generate the failure review HTML page.
194
194
  - `$atk-optimize`: tune the Agent based on the report.
195
+
196
+ Legacy one-shot installation remains available: `uvx --from agent-tune-kit atk install`. Skills now require the persistent `atk` command on PATH.
197
+
198
+ ## Shared CLI capabilities
199
+
200
+ Install the ATK CLI first, then run `atk install` to install its bundled Skills. Fixed operations are maintained in the Python package; Skills retain semantic diagnosis, reporting and Agent optimization.
201
+
202
+ ```sh
203
+ atk dataset prepare --source data/eval.csv
204
+ atk dataset inspect --direct --json
205
+ atk dataset update --direct --field expected --updates-path updates.csv
206
+ atk eval --check --json
207
+ atk eval --limit 5 --concurrency 2
208
+ atk results inspect --json
209
+ atk results run-rule
210
+ atk results apply-judgments --judgments-path judgments.csv --source-results .atk/results/v1/eval_results.csv
211
+ atk results compare --ids 1 2 --json
212
+ atk visualize dataset --no-open
213
+ atk visualize failures --no-open
214
+ ```
215
+
216
+ These commands run from the Agent project. New project adapters delegate to the shared engine; legacy full runners require migration before writing alongside new evidence Runs. Dataset fields, IDs, result paths, unknown verdicts, logs and offline review pages retain their contracts. Use `--help` on each command for its options.
217
+
218
+
219
+ ## 本地执行证据 / Local execution evidence
220
+
221
+ V2 adapters declare `ATK_ADAPTER_VERSION = 2` and `EVIDENCE.retain(role, value)`.
222
+ Each execution saves independent input/output, context, structured events and artifacts beneath
223
+ `.atk/results/vN/executions/<id>/`; shared Cases map multiple selected samples to one directory.
224
+ Retention runs before persistence. Existing V1 adapters remain explicit; no historical migration is automatic.
225
+
226
+ ```sh
227
+ atk results inspect --json
228
+ atk results evidence --version v1 --atk-id 1 --json
229
+ atk results evidence --execution-dir ./copied-execution --json
230
+ atk results import-evidence --source ./native-run --adapter ./importer.py --json
231
+ ```
232
+
233
+ `inspect` separates latest Run from the evaluation target. Evidence-only imports do not displace the latter.
234
+ Diagnosis and reports bind `--version`; changed evidence invalidates dependent judgments. Import adapters are
235
+ trusted Python code, not a sandbox. No Agent call, remote fetch, automatic cleanup or post-seal supplementation
236
+ is performed. Declared capture coverage is distinct from successful persistence and business verdicts.
237
+ See [execution evidence plan](docs/execution-evidence-and-tracing-plan.md) for interfaces, source limitations, recovery and validation.
@@ -1,5 +1,11 @@
1
1
  # Agent Tune Kit
2
2
 
3
+ Ground-truth reviews, judge calibration and assessment provenance are documented in
4
+ [the trust contract](docs/truth-and-assessment.md). Existing datasets remain readable, not automatically certified.
5
+ `atk dataset inspect/update` supports content-bound confirmations; `atk results calibrate` checks reviewed outputs
6
+ without executing the Agent or allocating an evaluation version. Rejudgments preserve history and comparisons expose
7
+ changes to their criteria and judge.
8
+
3
9
  English | [简体中文](README.md)
4
10
 
5
11
  [![PyPI](https://img.shields.io/pypi/v/agent-tune-kit.svg)](https://pypi.org/project/agent-tune-kit/)
@@ -32,13 +38,7 @@ This turns Agent tuning from one-off subjective trial and error into an engineer
32
38
 
33
39
  ## Install
34
40
 
35
- One-command install:
36
-
37
- ```sh
38
- uvx --from agent-tune-kit atk install
39
- ```
40
-
41
- To keep the `atk` command available:
41
+ Install the ATK CLI, then install its bundled Skills:
42
42
 
43
43
  ```sh
44
44
  uv tool install agent-tune-kit
@@ -178,3 +178,46 @@ Common output files:
178
178
  - `$atk-report`: generate analysis and cross-loop validation.
179
179
  - `$atk-visualize-failures`: generate the failure review HTML page.
180
180
  - `$atk-optimize`: tune the Agent based on the report.
181
+
182
+ Legacy one-shot installation remains available: `uvx --from agent-tune-kit atk install`. Skills now require the persistent `atk` command on PATH.
183
+
184
+ ## Shared CLI capabilities
185
+
186
+ Install the ATK CLI first, then run `atk install` to install its bundled Skills. Fixed operations are maintained in the Python package; Skills retain semantic diagnosis, reporting and Agent optimization.
187
+
188
+ ```sh
189
+ atk dataset prepare --source data/eval.csv
190
+ atk dataset inspect --direct --json
191
+ atk dataset update --direct --field expected --updates-path updates.csv
192
+ atk eval --check --json
193
+ atk eval --limit 5 --concurrency 2
194
+ atk results inspect --json
195
+ atk results run-rule
196
+ atk results apply-judgments --judgments-path judgments.csv --source-results .atk/results/v1/eval_results.csv
197
+ atk results compare --ids 1 2 --json
198
+ atk visualize dataset --no-open
199
+ atk visualize failures --no-open
200
+ ```
201
+
202
+ These commands run from the Agent project. New project adapters delegate to the shared engine; legacy full runners require migration before writing alongside new evidence Runs. Dataset fields, IDs, result paths, unknown verdicts, logs and offline review pages retain their contracts. Use `--help` on each command for its options.
203
+
204
+
205
+ ## 本地执行证据 / Local execution evidence
206
+
207
+ V2 adapters declare `ATK_ADAPTER_VERSION = 2` and `EVIDENCE.retain(role, value)`.
208
+ Each execution saves independent input/output, context, structured events and artifacts beneath
209
+ `.atk/results/vN/executions/<id>/`; shared Cases map multiple selected samples to one directory.
210
+ Retention runs before persistence. Existing V1 adapters remain explicit; no historical migration is automatic.
211
+
212
+ ```sh
213
+ atk results inspect --json
214
+ atk results evidence --version v1 --atk-id 1 --json
215
+ atk results evidence --execution-dir ./copied-execution --json
216
+ atk results import-evidence --source ./native-run --adapter ./importer.py --json
217
+ ```
218
+
219
+ `inspect` separates latest Run from the evaluation target. Evidence-only imports do not displace the latter.
220
+ Diagnosis and reports bind `--version`; changed evidence invalidates dependent judgments. Import adapters are
221
+ trusted Python code, not a sandbox. No Agent call, remote fetch, automatic cleanup or post-seal supplementation
222
+ is performed. Declared capture coverage is distinct from successful persistence and business verdicts.
223
+ See [execution evidence plan](docs/execution-evidence-and-tracing-plan.md) for interfaces, source limitations, recovery and validation.
@@ -1,5 +1,10 @@
1
1
  # Agent Tune Kit
2
2
 
3
+ 真值复核、裁判校准和判定追溯见[可信度契约](docs/truth-and-assessment.md):数据集可按答案字段记录来源和
4
+ 有效确认,输入/答案/标准变化会使确认过期;`atk dataset update --review-path dataset_review.csv` 可只导入
5
+ 确认而不改答案。`atk results calibrate` 用已复核输出检查裁判,不调用 Agent 或创建评测轮次。
6
+ 判定可绑定标准与裁判快照,重判保存历史,比较显式列出可比性差异。旧数据可读,但不自动标为已确认。
7
+
3
8
  简体中文 | [English](README.en.md)
4
9
 
5
10
  [![PyPI](https://img.shields.io/pypi/v/agent-tune-kit.svg)](https://pypi.org/project/agent-tune-kit/)
@@ -32,13 +37,7 @@ Agent Tune Kit 的价值不只是“跑一次测试”,而是把 Agent 调优
32
37
 
33
38
  ## 安装
34
39
 
35
- 一键运行:
36
-
37
- ```sh
38
- uvx --from agent-tune-kit atk install
39
- ```
40
-
41
- 如果希望长期保留 `atk` 命令,可以改用:
40
+ 先安装 ATK CLI,再安装配套 Skills:
42
41
 
43
42
  ```sh
44
43
  uv tool install agent-tune-kit
@@ -182,3 +181,47 @@ ATK 可选读取本地私有的 `.atk/context.md`,用于保存用户沟通后
182
181
  ## 能力评估
183
182
 
184
183
  - [Ground truth 与评分方案支持评估(2026-10-25)](docs/ground-truth-and-grading-assessment-2026-10-25.md):基于当前源码与 44 项相关测试,梳理数据准备、人工校准和判定支持,区分小规模调优可用性与可信评分体系的缺口;未重新验收业务调优效果。
184
+ - [执行项现场与调用轨迹改造实现方案(2026-10-26)](docs/execution-evidence-and-tracing-plan.md):明确每项独立现场、V2 托管采集及外部 runner 本地证据导入,结合 Magic 双 Case 实践补齐来源身份、文件变更与验收;首版不做封存后补采,按 P0–P5 实施,详见方案中的验收状态。
185
+
186
+ 兼容一次性安装命令 `uvx --from agent-tune-kit atk install`;日常使用 Skill 需要 PATH 中持续可用的 `atk` 命令。
187
+
188
+ ## 统一 CLI 能力
189
+
190
+ 固定操作由 Python 包维护,Skill 继续负责语义诊断、报告分析和 Agent 优化。可在目标 Agent 项目中使用以下命令:
191
+
192
+ ```sh
193
+ atk dataset prepare --source data/eval.csv
194
+ atk dataset inspect --direct --json
195
+ atk dataset update --direct --field expected --updates-path updates.csv
196
+ atk eval --check --json
197
+ atk eval --limit 5 --concurrency 2
198
+ atk results inspect --json
199
+ atk results run-rule
200
+ atk results apply-judgments --judgments-path judgments.csv --source-results .atk/results/v1/eval_results.csv
201
+ atk results compare --ids 1 2 --json
202
+ atk visualize dataset --no-open
203
+ atk visualize failures --no-open
204
+ ```
205
+
206
+ 新生成的项目适配文件使用统一执行引擎,旧完整 runner 与新证据现场共存时需先满足写入保护,否则启动前提示迁移。数据字段、ID、结果目录、未判定状态、日志和离线浏览页遵循原有约定。各命令参数见对应 `--help`。
207
+
208
+
209
+ ## 本地执行证据 / Local execution evidence
210
+
211
+ V2 adapters declare `ATK_ADAPTER_VERSION = 2` and `EVIDENCE.retain(role, value)`.
212
+ Each execution saves independent input/output, context, structured events and artifacts beneath
213
+ `.atk/results/vN/executions/<id>/`; shared Cases map multiple selected samples to one directory.
214
+ Retention runs before persistence. Existing V1 adapters remain explicit; no historical migration is automatic.
215
+
216
+ ```sh
217
+ atk results inspect --json
218
+ atk results evidence --version v1 --atk-id 1 --json
219
+ atk results evidence --execution-dir ./copied-execution --json
220
+ atk results import-evidence --source ./native-run --adapter ./importer.py --json
221
+ ```
222
+
223
+ `inspect` separates latest Run from the evaluation target. Evidence-only imports do not displace the latter.
224
+ Diagnosis and reports bind `--version`; changed evidence invalidates dependent judgments. Import adapters are
225
+ trusted Python code, not a sandbox. No Agent call, remote fetch, automatic cleanup or post-seal supplementation
226
+ is performed. Declared capture coverage is distinct from successful persistence and business verdicts.
227
+ See [execution evidence plan](docs/execution-evidence-and-tracing-plan.md) for interfaces, source limitations, recovery and validation.
@@ -1,3 +1,3 @@
1
1
  """Agent Tune Kit package."""
2
2
 
3
- __version__ = "2.1.0"
3
+ __version__ = "2.2.0"
@@ -0,0 +1,3 @@
1
+ from .main import main
2
+
3
+ __all__ = ["main"]
@@ -0,0 +1,3 @@
1
+ from .main import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,81 @@
1
+ from agent_tune_kit import datasets
2
+ from agent_tune_kit.datasets import updates
3
+ from agent_tune_kit.workspace import DATASET_PATH
4
+
5
+
6
+ def add_options(parser):
7
+ parser.add_argument("--dataset-path", default=str(DATASET_PATH))
8
+ parser.add_argument("--field", default="ground_truth")
9
+ parser.add_argument("--input-fields", nargs="+")
10
+ parser.add_argument("--home-dir")
11
+ mode = parser.add_mutually_exclusive_group()
12
+ mode.add_argument("--review-path")
13
+ mode.add_argument("--direct", action="store_true")
14
+ parser.add_argument("--json", action="store_true")
15
+
16
+
17
+ def register(subparsers):
18
+ commands = subparsers.add_parser("dataset", help="prepare, inspect and update evaluation data").add_subparsers(
19
+ dest="action", required=True
20
+ )
21
+ prepare = commands.add_parser("prepare")
22
+ prepare.add_argument("--source", required=True)
23
+ prepare.add_argument("--dataset-path", default=str(DATASET_PATH))
24
+ mode = prepare.add_mutually_exclusive_group()
25
+ mode.add_argument("--append", action="store_true")
26
+ mode.add_argument("--overwrite", action="store_true")
27
+ prepare.add_argument("--json", action="store_true")
28
+ add_options(commands.add_parser("inspect"))
29
+ update = commands.add_parser("update")
30
+ add_options(update)
31
+ update.add_argument("--updates-path")
32
+
33
+
34
+ def execute(args):
35
+ if args.action == "prepare":
36
+ return datasets.prepare_dataset(args.source, args.dataset_path, append=args.append, overwrite=args.overwrite)
37
+ options = dict(
38
+ dataset_path=args.dataset_path,
39
+ direct=args.direct,
40
+ review_path=args.review_path,
41
+ field=args.field,
42
+ home_dir=args.home_dir,
43
+ input_fields=args.input_fields,
44
+ )
45
+ if args.action == "inspect":
46
+ return datasets.inspect_dataset(**options)
47
+ return datasets.update_dataset(args.updates_path, **options)
48
+
49
+
50
+ def legacy_main(argv=None):
51
+ import argparse
52
+ import json
53
+ import sys
54
+
55
+ parser = argparse.ArgumentParser()
56
+ add_options(parser)
57
+ parser.add_argument("--updates-path")
58
+ parser.add_argument("--dump-context", action="store_true")
59
+ args = parser.parse_args(argv)
60
+ options = dict(
61
+ dataset_path=args.dataset_path,
62
+ direct=args.direct,
63
+ review_path=args.review_path,
64
+ field=args.field,
65
+ home_dir=args.home_dir,
66
+ input_fields=args.input_fields,
67
+ )
68
+ try:
69
+ if args.dump_context or not args.updates_path:
70
+ print(json.dumps(datasets.inspect_dataset(**options), ensure_ascii=False, indent=2))
71
+ if args.updates_path:
72
+ from .output import emit
73
+
74
+ emit(datasets.update_dataset(args.updates_path, **options))
75
+ return 0
76
+ except updates.UserActionRequired as exc:
77
+ print(str(exc), file=sys.stderr)
78
+ return 2
79
+ except Exception as exc:
80
+ print(f"Unexpected error: {exc}", file=sys.stderr)
81
+ return 1
@@ -0,0 +1,22 @@
1
+ from agent_tune_kit.execution import run_evaluation
2
+
3
+
4
+ def register(subparsers):
5
+ parser = subparsers.add_parser("eval", help="run the project Agent with the shared engine")
6
+ parser.add_argument("--check", action="store_true")
7
+ parser.add_argument("--limit", type=int)
8
+ parser.add_argument("--offset", type=int, default=0)
9
+ parser.add_argument("--concurrency", type=int, default=1)
10
+ parser.add_argument("--only-failures", action="store_true")
11
+ parser.add_argument("--no-progress", action="store_true")
12
+ parser.add_argument("--python")
13
+ parser.add_argument("--json", action="store_true")
14
+
15
+
16
+ def execute(args):
17
+ return run_evaluation(
18
+ **{
19
+ key: getattr(args, key)
20
+ for key in ["check", "limit", "offset", "concurrency", "only_failures", "no_progress", "python"]
21
+ }
22
+ )
@@ -0,0 +1,55 @@
1
+ """Public command dispatch; business behavior lives in domain packages."""
2
+
3
+ import argparse
4
+ import sys
5
+
6
+ from agent_tune_kit import installer
7
+ from agent_tune_kit.errors import UserActionRequired
8
+ from agent_tune_kit.execution.runtime import ExecutionFailed
9
+
10
+ from . import dataset, evaluation, results, visualize
11
+ from .output import emit
12
+
13
+ HANDLERS = {"dataset": dataset, "eval": evaluation, "results": results, "visualize": visualize}
14
+
15
+
16
+ def main(argv=None):
17
+ argv = list(sys.argv[1:] if argv is None else argv)
18
+ if argv and argv[0] == "_legacy":
19
+ if argv[1] == "atk-dataset":
20
+ return dataset.legacy_main(argv[2:])
21
+ return visualize.legacy_main("dataset" if argv[1] == "atk-visualize-dataset" else "failures", argv[2:])
22
+ if not argv or argv[0] not in HANDLERS:
23
+ if argv and argv[0] in ["-h", "--help"]:
24
+ parser = argparse.ArgumentParser(description="Register Agent Tune Kit and run shared project capabilities")
25
+ subparsers = parser.add_subparsers(dest="command")
26
+ for module in HANDLERS.values():
27
+ module.register(subparsers)
28
+ for command in ["install", "preview", "status", "version"]:
29
+ subparsers.add_parser(command)
30
+ parser.print_help()
31
+ return 0
32
+ return installer.main(argv)
33
+ parser = argparse.ArgumentParser(prog="atk")
34
+ subparsers = parser.add_subparsers(dest="command", required=True)
35
+ for module in HANDLERS.values():
36
+ module.register(subparsers)
37
+ args = parser.parse_args(argv)
38
+ try:
39
+ emit(HANDLERS[args.command].execute(args), args.json)
40
+ return 0
41
+ except UserActionRequired as exc:
42
+ print(f"atk: {exc}", file=sys.stderr)
43
+ return 2
44
+ except ExecutionFailed as exc:
45
+ print(f"atk: {exc}", file=sys.stderr)
46
+ return exc.returncode if exc.returncode > 0 else 1
47
+ except KeyboardInterrupt:
48
+ print("Evaluation interrupted; partial results were preserved.", file=sys.stderr)
49
+ return 130
50
+ except (OSError, ValueError) as exc:
51
+ print(f"atk: {exc}", file=sys.stderr)
52
+ return 2
53
+ except Exception as exc:
54
+ print(f"atk: unexpected error: {exc}", file=sys.stderr)
55
+ return 1
@@ -0,0 +1,11 @@
1
+ import json
2
+
3
+
4
+ def emit(result, json_output=False):
5
+ if json_output:
6
+ print(json.dumps(result, ensure_ascii=False))
7
+ else:
8
+ for key, value in result.items():
9
+ if key == "browser_open":
10
+ value = "ok" if value else "skipped"
11
+ print(f"{key}={value}")
@@ -0,0 +1,99 @@
1
+ from agent_tune_kit import results
2
+ from agent_tune_kit.execution import run_rule
3
+
4
+
5
+ def register(subparsers):
6
+ commands = subparsers.add_parser("results", help="inspect and judge versioned results").add_subparsers(
7
+ dest="action", required=True
8
+ )
9
+ calibration = commands.add_parser(
10
+ "calibrate", help="check a judge against reviewed outputs without running the Agent"
11
+ )
12
+ calibration.add_argument("--samples-path", required=True)
13
+ calibration.add_argument("--output-path", required=True)
14
+ mode = calibration.add_mutually_exclusive_group(required=True)
15
+ mode.add_argument("--rule-path")
16
+ mode.add_argument("--judgments-path")
17
+ calibration.add_argument("--judge-id")
18
+ calibration.add_argument("--instructions")
19
+ calibration.add_argument("--python")
20
+ calibration.add_argument("--json", action="store_true")
21
+ for name in ["inspect", "run-rule", "apply-judgments", "compare", "evidence", "import-evidence"]:
22
+ parser = commands.add_parser(name)
23
+ parser.add_argument("--results-dir", default=".atk/results")
24
+ parser.add_argument("--json", action="store_true")
25
+ if name != "import-evidence":
26
+ parser.add_argument("--version")
27
+ if name == "run-rule":
28
+ parser.add_argument("--rule-path", default=".atk/runner/failure_rule.py")
29
+ parser.add_argument("--python")
30
+ elif name == "apply-judgments":
31
+ parser.add_argument("--judgments-path", required=True)
32
+ parser.add_argument("--source-results")
33
+ elif name == "compare":
34
+ parser.add_argument("--ids", nargs="+", required=True)
35
+ elif name == "import-evidence":
36
+ parser.add_argument("--source", required=True)
37
+ parser.add_argument("--adapter", required=True, help="explicit trusted Python adapter (not sandboxed)")
38
+ elif name == "evidence":
39
+ parser.add_argument("--execution-dir")
40
+ parser.add_argument("--atk-id")
41
+ parser.add_argument("--execution-id")
42
+ parser.add_argument("--event-id")
43
+ parser.add_argument("--artifact-id")
44
+ parser.add_argument("--after-seq", type=int)
45
+ parser.add_argument("--offset", type=int, default=0)
46
+ parser.add_argument("--limit", type=int)
47
+
48
+
49
+ def execute(args):
50
+ if args.action == "calibrate":
51
+ from agent_tune_kit.execution.calibration import launch_calibration
52
+
53
+ return launch_calibration(
54
+ **{
55
+ key: getattr(args, key)
56
+ for key in (
57
+ "samples_path",
58
+ "output_path",
59
+ "rule_path",
60
+ "judgments_path",
61
+ "judge_id",
62
+ "instructions",
63
+ "python",
64
+ )
65
+ }
66
+ )
67
+ if args.action == "import-evidence":
68
+ from agent_tune_kit.results.evidence import import_evidence
69
+
70
+ return import_evidence(args.source, args.adapter, args.results_dir)
71
+ if args.action == "evidence":
72
+ from agent_tune_kit.results.evidence import query_evidence
73
+
74
+ return query_evidence(
75
+ **{
76
+ key: getattr(args, key)
77
+ for key in [
78
+ "results_dir",
79
+ "version",
80
+ "execution_dir",
81
+ "atk_id",
82
+ "execution_id",
83
+ "event_id",
84
+ "artifact_id",
85
+ "after_seq",
86
+ "offset",
87
+ "limit",
88
+ ]
89
+ }
90
+ )
91
+ if args.action == "inspect":
92
+ return results.inspect_results(args.results_dir, version=args.version)
93
+ if args.action == "compare":
94
+ return results.compare_targets(args.ids, args.results_dir, version=args.version)
95
+ if args.action == "apply-judgments":
96
+ return results.apply_judgments(
97
+ args.judgments_path, source_results=args.source_results, results_dir=args.results_dir, version=args.version
98
+ )
99
+ return run_rule(rule_path=args.rule_path, results_dir=args.results_dir, python=args.python, version=args.version)
@@ -0,0 +1,55 @@
1
+ import argparse
2
+ import sys
3
+
4
+ from agent_tune_kit.errors import UserActionRequired
5
+ from agent_tune_kit.visualize import generate_dataset, generate_failures
6
+
7
+ from .output import emit
8
+
9
+
10
+ def add_options(parser, kind):
11
+ parser.add_argument("--overwrite", action="store_true")
12
+ parser.add_argument("--open", dest="open_browser", action="store_true", default=True)
13
+ parser.add_argument("--no-open", dest="open_browser", action="store_false")
14
+ parser.add_argument("--json", action="store_true")
15
+ if kind == "dataset":
16
+ parser.add_argument("--dataset-path", default=".atk/datasets/dataset.csv")
17
+ else:
18
+ parser.add_argument("--results-dir", default=".atk/results")
19
+ parser.add_argument("--version")
20
+ parser.add_argument("--no-report", action="store_true")
21
+ parser.add_argument("--no-history", action="store_true")
22
+
23
+
24
+ def register(subparsers):
25
+ commands = subparsers.add_parser("visualize", help="generate offline review pages").add_subparsers(
26
+ dest="action", required=True
27
+ )
28
+ for kind in ["dataset", "failures"]:
29
+ add_options(commands.add_parser(kind), kind)
30
+
31
+
32
+ def execute(args):
33
+ options = dict(overwrite=args.overwrite, open_browser=args.open_browser)
34
+ if args.action == "dataset":
35
+ return generate_dataset(args.dataset_path, **options)
36
+ return generate_failures(
37
+ args.results_dir, no_report=args.no_report, no_history=args.no_history, version=args.version, **options
38
+ )
39
+
40
+
41
+ def legacy_main(kind, argv=None):
42
+ parser = argparse.ArgumentParser()
43
+ add_options(parser, kind)
44
+ args = parser.parse_args(argv)
45
+ args.action = kind
46
+ try:
47
+ result = execute(args)
48
+ emit(result)
49
+ return 0
50
+ except UserActionRequired as exc:
51
+ print(str(exc), file=sys.stderr)
52
+ return 2
53
+ except Exception as exc:
54
+ print(f"Unexpected HTML generation error: {exc}", file=sys.stderr)
55
+ return 1
@@ -0,0 +1,4 @@
1
+ from .prepare import prepare_dataset
2
+ from .updates import inspect_dataset, update_dataset
3
+
4
+ __all__ = ["prepare_dataset", "inspect_dataset", "update_dataset"]
@@ -0,0 +1,39 @@
1
+ from pathlib import Path
2
+
3
+ from agent_tune_kit.errors import UserActionRequired
4
+ from agent_tune_kit.utils.csv_io import parse_csv, write_csv_atomic
5
+ from agent_tune_kit.workspace import DATASET_PATH
6
+
7
+ from .truth import TRUTH_FIELD
8
+ from .validation import validate_dataset_rows
9
+
10
+
11
+ def prepare_dataset(source, dataset_path=DATASET_PATH, *, append=False, overwrite=False):
12
+ source, target = Path(source), Path(dataset_path)
13
+ fields, rows = parse_csv(source)
14
+ old_fields, old_rows = parse_csv(target) if target.exists() else ([], [])
15
+ if append and not target.exists():
16
+ raise UserActionRequired("Append requires an existing canonical dataset.")
17
+ if append:
18
+ validate_dataset_rows(old_fields, old_rows)
19
+ if set(fields) - {"atk_id", TRUTH_FIELD} != set(old_fields) - {"atk_id", TRUTH_FIELD}:
20
+ raise UserActionRequired("Append fields differ; confirm the field mapping before appending.")
21
+ if TRUTH_FIELD in fields and TRUTH_FIELD not in old_fields:
22
+ old_fields = old_fields + [TRUTH_FIELD]
23
+ if "atk_id" not in fields:
24
+ fields = fields + ["atk_id"]
25
+ start = max((int(row["atk_id"]) for row in old_rows), default=0) + 1 if append else 1
26
+ for index, row in enumerate(rows, start):
27
+ row["atk_id"] = str(index)
28
+ validate_dataset_rows(fields, rows)
29
+ if append:
30
+ fields, rows = old_fields, old_rows + rows
31
+ validate_dataset_rows(fields, rows)
32
+ if old_fields == fields and old_rows == rows:
33
+ return {"dataset": str(target), "rows": len(rows), "reused": True}
34
+ if target.exists() and not (append or overwrite):
35
+ raise UserActionRequired(
36
+ f"Refusing to overwrite different canonical content: {target}; confirm and use --overwrite."
37
+ )
38
+ write_csv_atomic(target, fields, rows)
39
+ return {"dataset": str(target), "rows": len(rows), "reused": False}