Files
16gagent/docs/reports/real-requirement-benchmark-report.md
T
2026-06-06 10:40:48 +08:00

115 lines
3.8 KiB
Markdown

# Real Requirement Benchmark Report
> 2026-06-05T10:25:00Z
## Before
| Test | Result |
|------|--------|
| 10/10 benchmark | PASS |
| 3/3 real requirement | **FAIL** |
**Root Cause:** `project-intake-agent``matchDomain()` 优先级高于用户输入。用户输入的详细需求被忽略,直接使用域模板。
**表现:**
- BookShelf → NoteApp (note domain)
- TeamFlow → NoteApp (note domain)
- MealPrep → ShopApp (ecommerce domain)
- Features/Pages/APIs 全部来自模板,非用户输入
## Fixes
### Fix 1: 用户输入优先于域匹配
**文件:** `scripts/project-intake-agent.mjs`
**修改:** `generatePRD()` 函数重写
```
Before: matchDomain() → 直接使用模板 → 忽略用户输入
After: extractFromInput() → matchDomain() → 合并(用户优先) → 域补充
```
新增 4 个提取函数:
- `extractProjectName(input)` — 从"叫 XXX"提取项目名
- `extractFeaturesFromInput(input)` — 从编号列表提取功能
- `extractPagesFromInput(input, features)` — 从功能派生页面
- `extractAPIsFromInput(input, features)` — 从功能派生 CRUD API
### Fix 2: 防止空生成
**修改:** `generatePRD()` 增加检查
```javascript
if (features.length === 0 || pages.length === 0 || apiRequirements.length === 0) {
return { error: "EXTRACTION_FAILED", message: "..." };
}
```
CLI 模式下 `process.exit(1)`,不输出空壳 JSON。
### Fix 3: DEFAULT_DOMAIN 清空模板
**修改:** `DEFAULT_DOMAIN` 的 features/pages/apiRequirements 改为空数组
```javascript
// Before: 3 generic features, 3 generic pages, 3 generic APIs
// After: empty arrays — forces extraction from user input
```
## After
| Test | Result |
|------|--------|
| 10/10 benchmark | PASS (170/170 regression) |
| 3/3 real requirement | **PASS** |
### 真实需求验证
| 需求 | 项目名 | Features | Pages | APIs | Frontend Pages | Backend Routes |
|------|--------|----------|-------|------|----------------|----------------|
| BookShelf | BookShelf | 7 | 8 | 10 | 书籍库/阅读状态/阅读进度/笔记和标注/书评/统计仪表盘/搜索和筛选 | auth/notes/tags/note_tags/users |
| TeamFlow | TeamFlow | 6 | 7 | 10 | 看板视图/任务管理/团队成员/筛选和搜索/活动日志/数据统计 | auth/notes/tags/note_tags/users |
| MealPrep | MealPrep | 6 | 7 | 10 | 食物库/客户管理/餐计划/营养计算/购物清单/模板功能 | auth/orders/products/order_items/logistics/users |
### 10 领域回归
| Domain | Features | Pages | APIs | E2E |
|--------|----------|-------|------|-----|
| petcare | 7 | 8 | 9 | ✅ |
| crm | 4 | 5 | 10 | ✅ |
| inventory | 4 | 5 | 10 | ✅ |
| ticket | 5 | 6 | 10 | ✅ |
| blog-cms | 4 | 5 | 10 | ✅ |
| project-mgmt | 4 | 5 | 10 | ✅ |
| hr | 4 | 5 | 10 | ✅ |
| asset | 4 | 5 | 10 | ✅ |
| course | 4 | 5 | 10 | ✅ |
| appointment | 4 | 5 | 10 | ✅ |
## Remaining Risks
### 1. 后端 routes 仍是域模板
backend-builder-agent 有自己的 `matchDomain()` 逻辑,生成的 routes 不从 PRD features 派生。
**影响:** BookShelf 生成的是 notes.ts 而不是 books.ts。前端 pages 正确,后端 routes 不匹配。
**修复方向:** 需要修改 backend-builder-agent(当前禁止修改)。
### 2. 复杂需求解析能力有限
当前提取基于正则匹配编号列表。以下格式可能无法正确解析:
- 无编号的自然语言描述
- 嵌套功能(功能下有子功能)
- 非中文/英文混合输入
- 隐含功能(用户说"和其他系统一样")
### 3. 域匹配置信度可能误判
当用户输入恰好包含域关键词时(如"管理"命中多个域),可能匹配到错误的域。当前用户输入优先机制可缓解,但域模板的 personas/summary 仍来自错误的域。
### 4. Pages 中文路由
生成的页面路由使用中文名(如 `/书籍库`),在实际 Next.js 中可能有编码问题。