@jahanxu/trellis 0.4.2 → 0.5.0
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.
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +58 -1
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/constants/paths.d.ts +17 -0
- package/dist/constants/paths.d.ts.map +1 -1
- package/dist/constants/paths.js +19 -0
- package/dist/constants/paths.js.map +1 -1
- package/dist/templates/claude/commands/trellis/handoff.md +90 -387
- package/dist/templates/claude/commands/trellis/pick-task.md +74 -444
- package/dist/templates/claude/hooks/inject-subagent-context.py +17 -101
- package/dist/templates/claude/hooks/ralph-loop.py +1 -0
- package/dist/templates/claude/hooks/session-start.py +170 -54
- package/dist/templates/iflow/commands/trellis/handoff.md +148 -0
- package/dist/templates/iflow/commands/trellis/pick-task.md +145 -0
- package/dist/templates/iflow/hooks/inject-subagent-context.py +1 -0
- package/dist/templates/iflow/hooks/ralph-loop.py +1 -0
- package/dist/templates/iflow/hooks/session-start.py +171 -0
- package/dist/templates/markdown/index.d.ts +9 -0
- package/dist/templates/markdown/index.d.ts.map +1 -1
- package/dist/templates/markdown/index.js +10 -0
- package/dist/templates/markdown/index.js.map +1 -1
- package/dist/templates/markdown/spec/roles/designer/index.md.txt +57 -0
- package/dist/templates/markdown/spec/roles/designer/mock-data-standards.md.txt +63 -0
- package/dist/templates/markdown/spec/roles/designer/prototype-guidelines.md.txt +49 -0
- package/dist/templates/markdown/spec/roles/frontend-impl/api-integration.md.txt +63 -0
- package/dist/templates/markdown/spec/roles/frontend-impl/index.md.txt +57 -0
- package/dist/templates/markdown/spec/roles/frontend-impl/prototype-to-production.md.txt +57 -0
- package/dist/templates/markdown/spec/roles/pm/index.md.txt +45 -0
- package/dist/templates/markdown/spec/roles/pm/prd-template.md.txt +64 -0
- package/dist/templates/markdown/spec/roles/pm/requirement-checklist.md.txt +43 -0
- package/dist/templates/trellis/index.d.ts +1 -0
- package/dist/templates/trellis/index.d.ts.map +1 -1
- package/dist/templates/trellis/index.js +2 -0
- package/dist/templates/trellis/index.js.map +1 -1
- package/dist/templates/trellis/scripts/add_session.py +3 -2
- package/dist/templates/trellis/scripts/common/cli_adapter.py +4 -4
- package/dist/templates/trellis/scripts/common/developer.py +4 -4
- package/dist/templates/trellis/scripts/common/git_context.py +7 -7
- package/dist/templates/trellis/scripts/common/paths.py +64 -14
- package/dist/templates/trellis/scripts/common/phase.py +2 -2
- package/dist/templates/trellis/scripts/common/registry.py +16 -16
- package/dist/templates/trellis/scripts/common/task_queue.py +10 -10
- package/dist/templates/trellis/scripts/common/task_utils.py +5 -5
- package/dist/templates/trellis/scripts/common/worktree.py +8 -8
- package/dist/templates/trellis/scripts/pool.py +214 -265
- package/dist/templates/trellis/scripts/task.py +3 -116
- package/package.json +3 -3
- package/dist/templates/claude/commands/trellis/before-role-work.md +0 -364
- package/dist/templates/trellis/VERSION +0 -1
- package/dist/templates/trellis/deliverables/README.md +0 -51
- package/dist/templates/trellis/paths.README.md +0 -277
- package/dist/templates/trellis/paths.yaml +0 -41
- package/dist/templates/trellis/pool/implementations.json +0 -5
- package/dist/templates/trellis/pool/prototypes.json +0 -5
- package/dist/templates/trellis/pool/requirements.json +0 -5
- package/dist/templates/trellis/scripts/common/project_paths.py +0 -189
- package/dist/templates/trellis/scripts/handoff_generator.py +0 -380
- package/dist/templates/trellis/spec/roles/designer/index.md +0 -243
- package/dist/templates/trellis/spec/roles/designer/mock-data-standards.md +0 -481
- package/dist/templates/trellis/spec/roles/designer/prototype-guidelines.md +0 -429
- package/dist/templates/trellis/spec/roles/frontend-impl/api-integration.md +0 -565
- package/dist/templates/trellis/spec/roles/frontend-impl/index.md +0 -321
- package/dist/templates/trellis/spec/roles/frontend-impl/state-management.md +0 -599
- package/dist/templates/trellis/spec/roles/pm/index.md +0 -112
- package/dist/templates/trellis/spec/roles/pm/prd-template.md +0 -124
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
HANDOFF Document Generator
|
|
5
|
-
|
|
6
|
-
Generates role-specific handoff documents for three-role collaboration.
|
|
7
|
-
|
|
8
|
-
Templates:
|
|
9
|
-
- PM: Summarize PRD core requirements
|
|
10
|
-
- Designer: Design rationale + Mock data locations
|
|
11
|
-
- Frontend: Implementation details + API integration points
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
import sys
|
|
15
|
-
from datetime import datetime
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
from typing import Optional
|
|
18
|
-
|
|
19
|
-
# Add parent directory to path for imports
|
|
20
|
-
sys.path.insert(0, str(Path(__file__).parent))
|
|
21
|
-
|
|
22
|
-
from common.paths import get_developer, get_repo_root
|
|
23
|
-
|
|
24
|
-
# =============================================================================
|
|
25
|
-
# Template Functions
|
|
26
|
-
# =============================================================================
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def generate_handoff_pm(task_dir: Path, task_data: dict) -> str:
|
|
30
|
-
"""Generate HANDOFF.md for PM role."""
|
|
31
|
-
task_id = task_data.get("id", "unknown")
|
|
32
|
-
title = task_data.get("title", "未命名任务")
|
|
33
|
-
developer = get_developer(get_repo_root()) or "unknown"
|
|
34
|
-
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
35
|
-
|
|
36
|
-
# Read PRD content
|
|
37
|
-
prd_file = task_dir / "prd.md"
|
|
38
|
-
prd_content = ""
|
|
39
|
-
if prd_file.exists():
|
|
40
|
-
prd_content = prd_file.read_text(encoding="utf-8")
|
|
41
|
-
|
|
42
|
-
template = f"""# {title} - 需求交接文档
|
|
43
|
-
|
|
44
|
-
## 📋 任务信息
|
|
45
|
-
- **功能ID**: {task_id}
|
|
46
|
-
- **功能名称**: {title}
|
|
47
|
-
- **完成人**: {developer}
|
|
48
|
-
- **完成时间**: {now}
|
|
49
|
-
|
|
50
|
-
## 🎯 核心需求
|
|
51
|
-
|
|
52
|
-
**请AI根据PRD总结核心要点(2-3段)**
|
|
53
|
-
|
|
54
|
-
PRD位置:`{task_dir.name}/prd.md`
|
|
55
|
-
|
|
56
|
-
## 📄 产出文件
|
|
57
|
-
|
|
58
|
-
- `prd.md` - 产品需求文档
|
|
59
|
-
- `user-stories.md` - 用户故事(如有)
|
|
60
|
-
- 其他补充文档(如有)
|
|
61
|
-
|
|
62
|
-
## 🔑 关键设计要点
|
|
63
|
-
|
|
64
|
-
**请Designer重点关注**:
|
|
65
|
-
|
|
66
|
-
1. [TODO: AI填写关键功能点1]
|
|
67
|
-
2. [TODO: AI填写关键功能点2]
|
|
68
|
-
3. [TODO: AI填写关键功能点3]
|
|
69
|
-
|
|
70
|
-
## ⚠️ 特别注意事项
|
|
71
|
-
|
|
72
|
-
**设计实现时需要注意**:
|
|
73
|
-
|
|
74
|
-
- [TODO: AI填写注意事项1 - 如UI布局要求]
|
|
75
|
-
- [TODO: AI填写注意事项2 - 如交互特殊要求]
|
|
76
|
-
- [TODO: AI填写注意事项3 - 如性能要求]
|
|
77
|
-
|
|
78
|
-
## 🔗 相关资源
|
|
79
|
-
|
|
80
|
-
- 设计稿: [TODO: 填写Figma链接]
|
|
81
|
-
- API文档: [TODO: 填写API文档链接]
|
|
82
|
-
- 参考资料: [TODO: 填写其他资源]
|
|
83
|
-
|
|
84
|
-
## 📞 联系方式
|
|
85
|
-
|
|
86
|
-
如有疑问,请联系 {developer}
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## 附录:PRD内容摘要
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
{prd_content[:500]}...
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
> 完整PRD请查看 `{task_dir.name}/prd.md`
|
|
97
|
-
"""
|
|
98
|
-
|
|
99
|
-
return template
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def generate_handoff_designer(task_dir: Path, task_data: dict, source_data: Optional[dict] = None) -> str:
|
|
103
|
-
"""Generate HANDOFF.md for Designer role."""
|
|
104
|
-
task_id = task_data.get("id", "unknown")
|
|
105
|
-
title = task_data.get("title", "未命名任务")
|
|
106
|
-
developer = get_developer(get_repo_root()) or "unknown"
|
|
107
|
-
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
108
|
-
|
|
109
|
-
# Get upstream info
|
|
110
|
-
based_on = "N/A"
|
|
111
|
-
if source_data and "based_on" in source_data:
|
|
112
|
-
based_on = f"{source_data['based_on']['type']}/{source_data['based_on']['id']}"
|
|
113
|
-
|
|
114
|
-
template = f"""# {title} - 原型交接文档
|
|
115
|
-
|
|
116
|
-
## 📋 任务信息
|
|
117
|
-
- **功能ID**: {task_id}
|
|
118
|
-
- **基于需求**: {based_on}
|
|
119
|
-
- **完成人**: {developer}
|
|
120
|
-
- **完成时间**: {now}
|
|
121
|
-
|
|
122
|
-
## 🎨 设计说明
|
|
123
|
-
|
|
124
|
-
**请AI总结设计思路(2-3段)**:
|
|
125
|
-
|
|
126
|
-
- 整体布局思路
|
|
127
|
-
- 主要组件设计
|
|
128
|
-
- 交互流程设计
|
|
129
|
-
|
|
130
|
-
## 📄 产出文件
|
|
131
|
-
|
|
132
|
-
**请列出所有组件文件**:
|
|
133
|
-
|
|
134
|
-
- `[ComponentName].tsx` - 组件说明
|
|
135
|
-
- `[ComponentName].tsx` - 组件说明
|
|
136
|
-
- ...
|
|
137
|
-
|
|
138
|
-
## 🧩 组件结构
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
[TODO: AI绘制组件树]
|
|
142
|
-
App
|
|
143
|
-
├── LoginPage
|
|
144
|
-
│ ├── LoginForm
|
|
145
|
-
│ │ ├── EmailInput
|
|
146
|
-
│ │ └── PasswordInput
|
|
147
|
-
│ └── SocialLoginButtons
|
|
148
|
-
└── ...
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## 💾 Mock数据说明
|
|
152
|
-
|
|
153
|
-
**当前使用的Mock数据**:
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
// [TODO: AI填写Mock数据示例]
|
|
157
|
-
const mockUser = {{
|
|
158
|
-
id: "1",
|
|
159
|
-
email: "test@example.com",
|
|
160
|
-
name: "Test User"
|
|
161
|
-
}};
|
|
162
|
-
|
|
163
|
-
// Mock登录逻辑位置:[TODO: 文件名:行号]
|
|
164
|
-
const handleLogin = async () => {{
|
|
165
|
-
// TODO: 替换为真实API调用
|
|
166
|
-
setTimeout(() => setUser(mockUser), 1000);
|
|
167
|
-
}};
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## 🔄 需要Frontend补充的逻辑
|
|
171
|
-
|
|
172
|
-
**请Frontend开发重点处理**:
|
|
173
|
-
|
|
174
|
-
1. **API集成** - 替换Mock为真实API调用
|
|
175
|
-
- 位置: [TODO: 文件名:行号]
|
|
176
|
-
- 需要调用: [TODO: API端点]
|
|
177
|
-
|
|
178
|
-
2. **错误处理** - 添加网络错误和业务错误处理
|
|
179
|
-
- 网络超时
|
|
180
|
-
- 登录失败提示
|
|
181
|
-
- 表单验证错误
|
|
182
|
-
|
|
183
|
-
3. **状态管理** - 添加全局状态管理(如需要)
|
|
184
|
-
- 用户登录状态
|
|
185
|
-
- Token存储
|
|
186
|
-
|
|
187
|
-
4. **持久化** - 实现"记住我"功能
|
|
188
|
-
- localStorage/Cookie
|
|
189
|
-
- Token刷新逻辑
|
|
190
|
-
|
|
191
|
-
## ⚠️ 特别注意事项
|
|
192
|
-
|
|
193
|
-
**保留以下设计**:
|
|
194
|
-
|
|
195
|
-
- [TODO: 需要保留的交互细节]
|
|
196
|
-
- [TODO: 需要保留的UI元素]
|
|
197
|
-
- [TODO: 需要保留的样式]
|
|
198
|
-
|
|
199
|
-
**可以优化的部分**:
|
|
200
|
-
|
|
201
|
-
- [TODO: 可以优化的性能点]
|
|
202
|
-
- [TODO: 可以调整的代码结构]
|
|
203
|
-
|
|
204
|
-
## 📞 联系方式
|
|
205
|
-
|
|
206
|
-
如有疑问,请联系 {developer}
|
|
207
|
-
"""
|
|
208
|
-
|
|
209
|
-
return template
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
def generate_handoff_frontend(task_dir: Path, task_data: dict, source_data: Optional[dict] = None) -> str:
|
|
213
|
-
"""Generate HANDOFF.md for Frontend role."""
|
|
214
|
-
task_id = task_data.get("id", "unknown")
|
|
215
|
-
title = task_data.get("title", "未命名任务")
|
|
216
|
-
developer = get_developer(get_repo_root()) or "unknown"
|
|
217
|
-
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
218
|
-
|
|
219
|
-
# Get upstream info
|
|
220
|
-
based_on = "N/A"
|
|
221
|
-
if source_data and "based_on" in source_data:
|
|
222
|
-
based_on = f"{source_data['based_on']['type']}/{source_data['based_on']['id']}"
|
|
223
|
-
|
|
224
|
-
template = f"""# {title} - 生产代码交接文档
|
|
225
|
-
|
|
226
|
-
## 📋 任务信息
|
|
227
|
-
- **功能ID**: {task_id}
|
|
228
|
-
- **基于原型**: {based_on}
|
|
229
|
-
- **完成人**: {developer}
|
|
230
|
-
- **完成时间**: {now}
|
|
231
|
-
|
|
232
|
-
## 🎯 实现总结
|
|
233
|
-
|
|
234
|
-
**请AI总结实现要点(2-3段)**:
|
|
235
|
-
|
|
236
|
-
- 主要功能实现
|
|
237
|
-
- API集成情况
|
|
238
|
-
- 状态管理方案
|
|
239
|
-
|
|
240
|
-
## 📄 产出文件
|
|
241
|
-
|
|
242
|
-
**请列出修改的文件**:
|
|
243
|
-
|
|
244
|
-
- `[FileName].tsx` - 修改说明
|
|
245
|
-
- `[FileName].ts` - 修改说明
|
|
246
|
-
- ...
|
|
247
|
-
|
|
248
|
-
## 🔌 API集成
|
|
249
|
-
|
|
250
|
-
**已集成的API**:
|
|
251
|
-
|
|
252
|
-
| 端点 | 方法 | 用途 | 位置 |
|
|
253
|
-
|------|------|------|------|
|
|
254
|
-
| [TODO] | POST | [TODO] | [TODO:文件:行号] |
|
|
255
|
-
|
|
256
|
-
## 🧪 测试说明
|
|
257
|
-
|
|
258
|
-
**已添加的测试**:
|
|
259
|
-
|
|
260
|
-
- [ ] 单元测试: [TODO: 测试文件]
|
|
261
|
-
- [ ] 集成测试: [TODO: 测试文件]
|
|
262
|
-
- [ ] E2E测试: [TODO: 测试文件]
|
|
263
|
-
|
|
264
|
-
**测试覆盖率**: [TODO: X%]
|
|
265
|
-
|
|
266
|
-
## 🐛 已知问题
|
|
267
|
-
|
|
268
|
-
**遗留问题**(如有):
|
|
269
|
-
|
|
270
|
-
1. [TODO: 问题描述]
|
|
271
|
-
- 影响: [TODO]
|
|
272
|
-
- 计划修复时间: [TODO]
|
|
273
|
-
|
|
274
|
-
## ⚠️ 部署注意事项
|
|
275
|
-
|
|
276
|
-
**环境变量**:
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
# [TODO: 列出需要的环境变量]
|
|
280
|
-
VITE_API_BASE_URL=https://api.example.com
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
**依赖项**:
|
|
284
|
-
|
|
285
|
-
- [TODO: 新增的npm包]
|
|
286
|
-
|
|
287
|
-
**数据库迁移**(如需要):
|
|
288
|
-
|
|
289
|
-
- [TODO: 迁移脚本]
|
|
290
|
-
|
|
291
|
-
## 📞 联系方式
|
|
292
|
-
|
|
293
|
-
如有疑问,请联系 {developer}
|
|
294
|
-
"""
|
|
295
|
-
|
|
296
|
-
return template
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
# =============================================================================
|
|
300
|
-
# Main Function
|
|
301
|
-
# =============================================================================
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
def generate_handoff(task_dir: Path, role: str, task_data: dict, source_data: Optional[dict] = None) -> str:
|
|
305
|
-
"""Generate HANDOFF.md based on role.
|
|
306
|
-
|
|
307
|
-
Args:
|
|
308
|
-
task_dir: Task directory path
|
|
309
|
-
role: Role type (pm, designer, frontend)
|
|
310
|
-
task_data: Task metadata from task.json
|
|
311
|
-
source_data: Source reference from source.json (optional)
|
|
312
|
-
|
|
313
|
-
Returns:
|
|
314
|
-
HANDOFF.md content
|
|
315
|
-
"""
|
|
316
|
-
generators = {
|
|
317
|
-
"pm": generate_handoff_pm,
|
|
318
|
-
"designer": generate_handoff_designer,
|
|
319
|
-
"frontend": generate_handoff_frontend,
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if role not in generators:
|
|
323
|
-
raise ValueError(f"Invalid role: {role}. Must be one of {list(generators.keys())}")
|
|
324
|
-
|
|
325
|
-
# Designer and Frontend can use source_data
|
|
326
|
-
if role in ("designer", "frontend"):
|
|
327
|
-
return generators[role](task_dir, task_data, source_data)
|
|
328
|
-
else:
|
|
329
|
-
return generators[role](task_dir, task_data)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
# =============================================================================
|
|
333
|
-
# CLI Entry Point
|
|
334
|
-
# =============================================================================
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
def main() -> int:
|
|
338
|
-
"""CLI entry point for testing."""
|
|
339
|
-
import argparse
|
|
340
|
-
import json
|
|
341
|
-
|
|
342
|
-
parser = argparse.ArgumentParser(description="HANDOFF Document Generator")
|
|
343
|
-
parser.add_argument("task_dir", help="Task directory path")
|
|
344
|
-
parser.add_argument("role", choices=["pm", "designer", "frontend"], help="Role type")
|
|
345
|
-
parser.add_argument("--output", "-o", help="Output file path (default: HANDOFF.md in task dir)")
|
|
346
|
-
|
|
347
|
-
args = parser.parse_args()
|
|
348
|
-
|
|
349
|
-
task_dir = Path(args.task_dir)
|
|
350
|
-
if not task_dir.exists():
|
|
351
|
-
print(f"Error: Task directory not found: {task_dir}", file=sys.stderr)
|
|
352
|
-
return 1
|
|
353
|
-
|
|
354
|
-
# Read task.json
|
|
355
|
-
task_json = task_dir / "task.json"
|
|
356
|
-
if not task_json.exists():
|
|
357
|
-
print(f"Error: task.json not found in {task_dir}", file=sys.stderr)
|
|
358
|
-
return 1
|
|
359
|
-
|
|
360
|
-
task_data = json.loads(task_json.read_text(encoding="utf-8"))
|
|
361
|
-
|
|
362
|
-
# Read source.json (optional)
|
|
363
|
-
source_json = task_dir / "source.json"
|
|
364
|
-
source_data = None
|
|
365
|
-
if source_json.exists():
|
|
366
|
-
source_data = json.loads(source_json.read_text(encoding="utf-8"))
|
|
367
|
-
|
|
368
|
-
# Generate HANDOFF
|
|
369
|
-
handoff_content = generate_handoff(task_dir, args.role, task_data, source_data)
|
|
370
|
-
|
|
371
|
-
# Output
|
|
372
|
-
output_file = Path(args.output) if args.output else task_dir / "HANDOFF.md"
|
|
373
|
-
output_file.write_text(handoff_content, encoding="utf-8")
|
|
374
|
-
|
|
375
|
-
print(f"✓ Generated HANDOFF.md: {output_file}")
|
|
376
|
-
return 0
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
if __name__ == "__main__":
|
|
380
|
-
sys.exit(main())
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
# Designer (交互设计师) 工作规范
|
|
2
|
-
|
|
3
|
-
> 交互设计师在三角色协作中的职责、标准和工作流程
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 角色定位
|
|
8
|
-
|
|
9
|
-
**交互设计师(Designer)** 是三角色协作流水线的**第二环**:
|
|
10
|
-
- 从 `requirements` 池选择需求
|
|
11
|
-
- 基于PRD创建可运行的前端原型(带Mock数据)
|
|
12
|
-
- 产出物进入 `prototypes` 池,供 Frontend 消费
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## 工作流程
|
|
17
|
-
|
|
18
|
-
### 1. 选择需求
|
|
19
|
-
```bash
|
|
20
|
-
# 查看可用需求
|
|
21
|
-
python3 .trellis/scripts/pool.py list requirements
|
|
22
|
-
|
|
23
|
-
# 选择需求并创建任务
|
|
24
|
-
/trellis:pick-task requirements <task-id>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
系统会自动:
|
|
28
|
-
- 创建任务目录
|
|
29
|
-
- 设置 `source.json` 引用上游产出
|
|
30
|
-
- 注入上游PRD和HANDOFF文档
|
|
31
|
-
|
|
32
|
-
### 2. 创建原型
|
|
33
|
-
|
|
34
|
-
参考上游的 `HANDOFF.md`,创建:
|
|
35
|
-
- React/Vue组件(推荐使用项目技术栈)
|
|
36
|
-
- Mock数据和Mock API
|
|
37
|
-
- 基本交互逻辑
|
|
38
|
-
|
|
39
|
-
### 3. 完成并交接
|
|
40
|
-
```bash
|
|
41
|
-
/trellis:handoff
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
产出自动进入 `deliverables/prototypes/{task-id}/`
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## 原型代码标准
|
|
49
|
-
|
|
50
|
-
### 必需要素
|
|
51
|
-
|
|
52
|
-
#### 1. 可运行性
|
|
53
|
-
- ✅ 原型可以直接 `npm run dev` 运行
|
|
54
|
-
- ✅ 所有交互可以点击/操作
|
|
55
|
-
- ✅ 使用Mock数据模拟真实数据流
|
|
56
|
-
|
|
57
|
-
#### 2. Mock数据规范
|
|
58
|
-
```typescript
|
|
59
|
-
// Mock数据应该结构清晰,易于替换
|
|
60
|
-
// ✅ 推荐:集中管理Mock
|
|
61
|
-
// src/mocks/user.mock.ts
|
|
62
|
-
export const mockUser = {
|
|
63
|
-
id: "mock-user-1",
|
|
64
|
-
name: "张三",
|
|
65
|
-
email: "zhangsan@example.com"
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// ❌ 避免:硬编码分散各处
|
|
69
|
-
const user = { name: "张三" }; // 不易查找和替换
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
#### 3. Mock API位置标注
|
|
73
|
-
```typescript
|
|
74
|
-
// ✅ 使用清晰的TODO注释
|
|
75
|
-
const handleLogin = async (email: string, password: string) => {
|
|
76
|
-
// TODO: [Frontend] 替换为真实API调用 /api/auth/login
|
|
77
|
-
return new Promise(resolve => {
|
|
78
|
-
setTimeout(() => resolve(mockUser), 1000);
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### 组件结构规范
|
|
84
|
-
|
|
85
|
-
**推荐分层**:
|
|
86
|
-
```
|
|
87
|
-
src/
|
|
88
|
-
├── pages/ # 页面级组件
|
|
89
|
-
│ └── LoginPage.tsx
|
|
90
|
-
├── components/ # 复用组件
|
|
91
|
-
│ ├── LoginForm.tsx
|
|
92
|
-
│ └── SocialLoginButtons.tsx
|
|
93
|
-
├── mocks/ # Mock数据
|
|
94
|
-
│ └── auth.mock.ts
|
|
95
|
-
└── types/ # TypeScript类型定义
|
|
96
|
-
└── user.ts
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### 样式规范
|
|
100
|
-
|
|
101
|
-
根据项目技术栈选择:
|
|
102
|
-
- **Tailwind CSS** - 推荐用于快速原型
|
|
103
|
-
- **CSS Modules** - 适合组件隔离
|
|
104
|
-
- **Styled Components** - 适合复杂主题
|
|
105
|
-
|
|
106
|
-
**原则**:样式应该**接近最终效果**,但不必完美实现所有细节。
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## HANDOFF文档要点
|
|
111
|
-
|
|
112
|
-
AI生成的 `HANDOFF.md` 应包含:
|
|
113
|
-
|
|
114
|
-
### 设计说明
|
|
115
|
-
- 整体布局思路
|
|
116
|
-
- 主要组件设计理由
|
|
117
|
-
- 交互流程说明
|
|
118
|
-
|
|
119
|
-
### 组件结构
|
|
120
|
-
```
|
|
121
|
-
App
|
|
122
|
-
├── LoginPage
|
|
123
|
-
│ ├── LoginForm (核心表单)
|
|
124
|
-
│ │ ├── EmailInput
|
|
125
|
-
│ │ └── PasswordInput
|
|
126
|
-
│ └── SocialLoginButtons (第三方登录)
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Mock数据说明
|
|
130
|
-
```typescript
|
|
131
|
-
// 清楚标注每个Mock数据的位置和用途
|
|
132
|
-
const mockUser = { ... }; // 位置:src/mocks/auth.mock.ts:10
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### 需要Frontend补充的逻辑
|
|
136
|
-
|
|
137
|
-
**明确列出**:
|
|
138
|
-
1. **API集成点** - 哪些函数需要替换为真实API
|
|
139
|
-
- 文件:`LoginPage.tsx:45`
|
|
140
|
-
- Mock: `mockLogin()`
|
|
141
|
-
- 真实API: `POST /api/auth/login`
|
|
142
|
-
|
|
143
|
-
2. **状态管理** - 需要接入全局状态的部分
|
|
144
|
-
- 用户登录状态
|
|
145
|
-
- Token存储和刷新
|
|
146
|
-
|
|
147
|
-
3. **错误处理** - 需要完善的错误场景
|
|
148
|
-
- 网络超时
|
|
149
|
-
- 登录失败(密码错误、账号不存在)
|
|
150
|
-
- 表单验证错误
|
|
151
|
-
|
|
152
|
-
### 特别注意事项
|
|
153
|
-
|
|
154
|
-
**需要保留的设计**:
|
|
155
|
-
- 特定的交互动画
|
|
156
|
-
- 品牌色使用
|
|
157
|
-
- 布局细节
|
|
158
|
-
|
|
159
|
-
**可以优化的部分**:
|
|
160
|
-
- 性能优化(lazy loading等)
|
|
161
|
-
- 代码结构调整
|
|
162
|
-
- 组件拆分
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## 质量检查清单
|
|
167
|
-
|
|
168
|
-
在执行 `/trellis:handoff` 前,确保:
|
|
169
|
-
|
|
170
|
-
- [ ] 原型可运行(npm run dev 无报错)
|
|
171
|
-
- [ ] 所有交互可操作(按钮、表单、链接)
|
|
172
|
-
- [ ] Mock数据结构合理(接近真实API)
|
|
173
|
-
- [ ] TODO注释清晰(标注需要替换的Mock)
|
|
174
|
-
- [ ] 组件命名语义化
|
|
175
|
-
- [ ] 已测试关键交互流程
|
|
176
|
-
- [ ] HANDOFF文档包含所有关键信息
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## Mock数据最佳实践
|
|
181
|
-
|
|
182
|
-
### 1. 集中管理
|
|
183
|
-
```typescript
|
|
184
|
-
// src/mocks/index.ts
|
|
185
|
-
export { mockUser, mockUserList } from './user.mock';
|
|
186
|
-
export { mockProduct, mockProductList } from './product.mock';
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### 2. 类型安全
|
|
190
|
-
```typescript
|
|
191
|
-
// src/types/user.ts
|
|
192
|
-
export interface User {
|
|
193
|
-
id: string;
|
|
194
|
-
name: string;
|
|
195
|
-
email: string;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// src/mocks/user.mock.ts
|
|
199
|
-
import type { User } from '../types/user';
|
|
200
|
-
|
|
201
|
-
export const mockUser: User = {
|
|
202
|
-
id: "1",
|
|
203
|
-
name: "张三",
|
|
204
|
-
email: "zhangsan@example.com"
|
|
205
|
-
};
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
### 3. 真实性
|
|
209
|
-
```typescript
|
|
210
|
-
// ✅ Mock数据应该接近真实场景
|
|
211
|
-
export const mockUserList: User[] = [
|
|
212
|
-
{ id: "1", name: "张三", email: "zhangsan@example.com" },
|
|
213
|
-
{ id: "2", name: "李四", email: "lisi@example.com" },
|
|
214
|
-
// ... 10-20条数据,测试分页、滚动等
|
|
215
|
-
];
|
|
216
|
-
|
|
217
|
-
// ❌ 避免过于简化
|
|
218
|
-
export const mockUserList = [{ id: "1", name: "test" }];
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## 常见问题
|
|
224
|
-
|
|
225
|
-
### Q: 原型需要实现所有PRD功能吗?
|
|
226
|
-
A: 实现核心流程即可。边缘场景可以用TODO注释标注,交给Frontend补充。
|
|
227
|
-
|
|
228
|
-
### Q: Mock数据应该多详细?
|
|
229
|
-
A: 结构完整、字段真实。数量上:列表型数据10-20条,单条数据包含所有字段。
|
|
230
|
-
|
|
231
|
-
### Q: 需要实现响应式设计吗?
|
|
232
|
-
A: 根据PRD要求。如果PRD要求多端适配,原型应体现主要断点。
|
|
233
|
-
|
|
234
|
-
### Q: 如何处理复杂交互?
|
|
235
|
-
A: 核心交互必须可操作,动画和过渡效果可简化。在HANDOFF中说明预期效果。
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## 参考资料
|
|
240
|
-
|
|
241
|
-
- [原型代码指南](./prototype-guidelines.md)
|
|
242
|
-
- [Mock数据标准](./mock-data-standards.md)
|
|
243
|
-
- [组件设计模式](./component-patterns.md)
|