playbook/test/agent/README.md

301 lines
6.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TSL Agent 测试定义
这个目录包含 TSL 语法的 agent 测试用例定义,**支持测试任何 agent**。
---
## 🎯 多 Agent 支持
### 测试定义(通用)
- **`test_cases.md`** - 100+ 测试用例定义(英文完整版)
- 适用于所有 agentClaude, GPT-4, Gemini, 等)
- 包含提示词、评分标准、预期代码
- 与具体 agent 无关
- **`test_cases_zh.md`** - 100+ 测试用例定义(中文完整版)
- 完整翻译版本,包含所有测试用例
- 适合中文环境下的 agent 评估
### 测试结果(按 Agent 分类)
- **`result/results_<agent>_<date>.md`** - 特定 agent 的测试结果
- 存放目录:`test/agent/result/`(已加入 `.gitignore`
- 命名格式:`results_{agent}_{YYYYMMDD}.md`
- 示例:
- `result/results_claude_20260610.md` - Claude 的测试结果
- `result/results_gpt4_20240617.md` - GPT-4 的测试结果
- `result/results_gemini_20240617.md` - Gemini 的测试结果
---
## 📁 目录结构
### 当前文件
```text
test/agent/
├── README.md # 本文件
├── test_cases.md # 通用测试定义(英文完整版)⭐
├── test_cases_zh.md # 通用测试定义(中文完整版)⭐
└── result/ # 测试结果目录gitignore
├── results_claude_20260610.md
├── results_gpt4_20240617.md
└── results_gemini_20240617.md
```
### 添加新 Agent 的测试结果
```text
test/agent/
├── test_cases.md # 通用(不变)
├── test_cases_zh.md # 中文版(不变)
└── result/
├── results_claude_20260610.md # Claude
├── results_gpt4_20240617.md # GPT-4新增
└── results_gemini_20240617.md # Gemini新增
```
---
## 🎯 使用方式
### 测试不同的 Agent
1. **使用相同的测试定义**
```bash
# 所有 agent 都使用 test_cases.md 中的测试用例
cat test_cases.md
```
2. **为每个 Agent 记录结果**
```bash
# 创建结果目录
mkdir -p test/agent/result
# 测试 GPT-4
# 结果保存为test/agent/result/results_gpt4_20240617.md
# 测试 Gemini
# 结果保存为test/agent/result/results_gemini_20240617.md
# 测试 Claude
# 结果保存为test/agent/result/results_claude_20240617.md
```
3. **对比不同 Agent 的表现**
```bash
# 对比通过率、得分、常见错误等
diff test/agent/result/results_claude_20240617.md \
test/agent/result/results_gpt4_20240617.md
```
---
## 📊 测试流程
### 1. 准备测试
```bash
# 查看测试用例
cat test_cases.md
# 选择要测试的 agent
AGENT="gpt4" # 或 claude, gemini, 等
DATE=$(date +%Y%m%d)
```
### 2. 执行测试
对于每个测试用例:
1. 复制提示词Prompt
2. 发送给目标 agent
3. 记录生成的代码
4. 根据评分标准打分0/1/2
### 3. 保存结果
```bash
# 创建结果目录
mkdir -p test/agent/result
# 创建结果文件
# 格式result/results_{agent}_{YYYYMMDD}.md
test/agent/result/results_gpt4_20240617.md
test/agent/result/results_claude_20240617.md
test/agent/result/results_gemini_20240617.md
```
### 4. 对比分析
```markdown
# 示例对比报告
| Agent | 测试日期 | 通过率 | 平均分 | 常见错误 |
|-------|---------|-------|--------|---------|
| Claude | 2026-06-10 | 100% (10/10) | 2.0 | 无 |
| GPT-4 | 2024-06-17 | 90% (9/10) | 1.8 | 赋值语法 |
| Gemini | 2024-06-17 | 85% (8.5/10) | 1.7 | 类定义 |
```
---
## 📝 结果文件命名规范
### 格式
```text
test/agent/result/results_{agent}_{YYYYMMDD}.md
```
**说明**
- `result/`: 测试结果统一存放目录(已加入 `.gitignore`
- `{agent}`: agent 名称(小写,如 claude, gpt4, gemini
- `{YYYYMMDD}`: 测试日期(如 20240617
### 示例
```text
test/agent/result/results_claude_20260610.md # Claude 在 2026-06-10 的测试
test/agent/result/results_claude_20240617.md # Claude 在 2024-06-17 的测试
test/agent/result/results_gpt4_20240617.md # GPT-4 在 2024-06-17 的测试
test/agent/result/results_gpt4o_20240617.md # GPT-4o 在 2024-06-17 的测试
test/agent/result/results_gemini_20240617.md # Gemini 在 2024-06-17 的测试
test/agent/result/results_gemini15_20240617.md # Gemini 1.5 在 2024-06-17 的测试
```
---
## 🎯 .gitignore 配置
### 版本控制策略
**提交到 git**
```text
✅ test/agent/test_cases.md # 测试定义(英文完整版)
✅ test/agent/test_cases_zh.md # 测试定义(中文完整版)
✅ test/agent/README.md # 说明文档
```
**不提交**(已加入 `.gitignore`
```text
❌ test/agent/result/ # 测试结果目录
```
---
## 📊 测试用例覆盖
`test_cases.md` 包含 100+ 测试用例,覆盖:
| 语法点 | 测试用例数 |
| ---------- | ---------- |
| 函数定义 | 15+ |
| 类与对象 | 10+ |
| 控制流 | 10+ |
| 变量与赋值 | 8+ |
| Unit 模块 | 5+ |
| 参数传递 | 8+ |
| 类型系统 | 6+ |
| 错误边界 | 10+ |
| 其他 | 30+ |
**总计**100+ 测试用例
---
## 🔗 相关文档
### TSL 文档
- TSL 语法文档:`docs/tsl/syntax/`
- TSL 快速索引:`docs/tsl/syntax/00_agent_index.json`
- TSL 语法入口:`docs/tsl/syntax/index.md`
### Agent 优化
- Agent 快速索引:`docs/tsl/syntax/00_agent_index.json`
- 为 agent 优化,减少 75% token 消耗
- 包含精确行号和示例代码
---
## 💡 最佳实践
### 1. 保持测试定义的通用性
- ✅ 测试用例应该对所有 agent 都适用
- ✅ 不要添加特定 agent 的专属测试
- ✅ 关注 TSL 语法本身,而非 agent 特性
### 2. 结果命名规范
- ✅ 使用统一的命名格式
- ✅ 包含 agent 名称和日期
- ✅ 便于排序和查找
### 3. 定期对比
- 建议每季度测试一次所有 agent
- 追踪 agent 的改进趋势
- 发现不同 agent 的优势和劣势
### 4. 基线管理
- 保留第一次测试结果作为基线
- 新结果与基线对比
- 追踪质量变化
---
## 🎉 示例:测试新 Agent
### 步骤
```bash
# 1. 选择测试用例
cat test_cases.md | grep "### TSL-001"
# 2. 复制提示词发送给新 agent如 GPT-4
# 3. 记录结果
cat > results_gpt4_20240617.md << 'EOF'
# TSL Codegen Test Results - GPT-4
Date: 2024-06-17
Agent: GPT-4 (gpt-4-turbo)
## Summary
- Cases run: 10
- Cases passed: 9
- First-pass score: 18 / 20
- Pass rate: 90%
## Results
| Case | Score | Notes |
|------|-------|-------|
| TSL-001 | 2 | Correct |
| TSL-002 | 2 | Correct |
| TSL-003 | 1 | Minor issue |
...
EOF
# 4. 对比 Claude 和 GPT-4
diff results_claude_20260610.md results_gpt4_20240617.md
```
---
**维护者**TSL Team
**最后更新**2024-06-17
**支持的 Agent**:所有支持 TSL 的 agent