@jahanxu/trellis 0.4.1 → 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 -3
- package/dist/templates/trellis/scripts/common/developer.py +4 -3
- 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 -15
- package/dist/templates/trellis/scripts/common/task_queue.py +10 -10
- package/dist/templates/trellis/scripts/common/task_utils.py +5 -4
- package/dist/templates/trellis/scripts/common/worktree.py +8 -7
- 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,321 +0,0 @@
|
|
|
1
|
-
# Frontend (前端开发工程师) 工作规范
|
|
2
|
-
|
|
3
|
-
> 前端开发工程师在三角色协作中的职责、标准和工作流程
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 角色定位
|
|
8
|
-
|
|
9
|
-
**前端开发工程师(Frontend)** 是三角色协作流水线的**第三环**:
|
|
10
|
-
- 从 `prototypes` 池选择原型
|
|
11
|
-
- 基于原型代码补充真实API调用和业务逻辑
|
|
12
|
-
- 产出物进入 `production` 池,准备上线
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## 工作流程
|
|
17
|
-
|
|
18
|
-
### 1. 选择原型
|
|
19
|
-
```bash
|
|
20
|
-
# 查看可用原型
|
|
21
|
-
python3 .trellis/scripts/pool.py list prototypes
|
|
22
|
-
|
|
23
|
-
# 选择原型并创建任务
|
|
24
|
-
/trellis:pick-task prototypes <task-id>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
系统会自动:
|
|
28
|
-
- 创建任务目录
|
|
29
|
-
- 设置 `source.json` 引用上游原型
|
|
30
|
-
- 注入原型代码和HANDOFF文档
|
|
31
|
-
|
|
32
|
-
### 2. 补充真实逻辑
|
|
33
|
-
|
|
34
|
-
参考 `HANDOFF.md` 中的"需要Frontend补充的逻辑"章节:
|
|
35
|
-
1. 替换Mock API为真实API调用
|
|
36
|
-
2. 添加错误处理
|
|
37
|
-
3. 接入全局状态管理
|
|
38
|
-
4. 补充边缘场景逻辑
|
|
39
|
-
|
|
40
|
-
### 3. 完成并交接
|
|
41
|
-
```bash
|
|
42
|
-
/trellis:handoff
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
产出自动进入 `deliverables/production/{task-id}/`
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## 开发标准
|
|
50
|
-
|
|
51
|
-
### API集成规范
|
|
52
|
-
|
|
53
|
-
#### 1. 识别Mock位置
|
|
54
|
-
```typescript
|
|
55
|
-
// Designer留下的TODO注释
|
|
56
|
-
const handleLogin = async (email: string, password: string) => {
|
|
57
|
-
// TODO: [Frontend] 替换为真实API调用 /api/auth/login
|
|
58
|
-
return new Promise(resolve => {
|
|
59
|
-
setTimeout(() => resolve(mockUser), 1000);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### 2. 替换为真实API
|
|
65
|
-
```typescript
|
|
66
|
-
// ✅ 使用项目API客户端
|
|
67
|
-
import { apiClient } from '@/lib/api';
|
|
68
|
-
|
|
69
|
-
const handleLogin = async (email: string, password: string) => {
|
|
70
|
-
try {
|
|
71
|
-
const response = await apiClient.post('/api/auth/login', {
|
|
72
|
-
email,
|
|
73
|
-
password
|
|
74
|
-
});
|
|
75
|
-
return response.data;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
throw new ApiError('登录失败', error);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### 3. 保留类型定义
|
|
83
|
-
```typescript
|
|
84
|
-
// 继续使用Designer定义的类型
|
|
85
|
-
import type { User } from '@/types/user';
|
|
86
|
-
|
|
87
|
-
// 确保API返回与类型匹配
|
|
88
|
-
const user: User = response.data.user;
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### 错误处理规范
|
|
92
|
-
|
|
93
|
-
**必须处理的错误场景**:
|
|
94
|
-
1. **网络错误** - 超时、断网
|
|
95
|
-
2. **业务错误** - 登录失败、权限不足
|
|
96
|
-
3. **表单验证错误** - 格式错误、必填项缺失
|
|
97
|
-
|
|
98
|
-
**示例**:
|
|
99
|
-
```typescript
|
|
100
|
-
const handleLogin = async (email: string, password: string) => {
|
|
101
|
-
try {
|
|
102
|
-
setLoading(true);
|
|
103
|
-
setError(null);
|
|
104
|
-
|
|
105
|
-
const response = await apiClient.post('/api/auth/login', { email, password });
|
|
106
|
-
|
|
107
|
-
// 成功处理
|
|
108
|
-
setUser(response.data.user);
|
|
109
|
-
navigate('/dashboard');
|
|
110
|
-
|
|
111
|
-
} catch (error) {
|
|
112
|
-
// 错误处理
|
|
113
|
-
if (error instanceof NetworkError) {
|
|
114
|
-
setError('网络连接失败,请检查网络设置');
|
|
115
|
-
} else if (error.response?.status === 401) {
|
|
116
|
-
setError('邮箱或密码错误');
|
|
117
|
-
} else {
|
|
118
|
-
setError('登录失败,请稍后重试');
|
|
119
|
-
}
|
|
120
|
-
} finally {
|
|
121
|
-
setLoading(false);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### 状态管理规范
|
|
127
|
-
|
|
128
|
-
**根据复杂度选择方案**:
|
|
129
|
-
|
|
130
|
-
| 场景 | 推荐方案 | 示例 |
|
|
131
|
-
|------|---------|------|
|
|
132
|
-
| 简单页面状态 | React useState | 表单输入、UI切换 |
|
|
133
|
-
| 跨组件状态 | React Context | 用户信息、主题 |
|
|
134
|
-
| 复杂全局状态 | Zustand/Redux | 购物车、消息通知 |
|
|
135
|
-
|
|
136
|
-
**示例**:
|
|
137
|
-
```typescript
|
|
138
|
-
// 接入全局用户状态
|
|
139
|
-
import { useAuthStore } from '@/stores/auth';
|
|
140
|
-
|
|
141
|
-
const LoginPage = () => {
|
|
142
|
-
const { login, user } = useAuthStore();
|
|
143
|
-
|
|
144
|
-
const handleLogin = async (email: string, password: string) => {
|
|
145
|
-
await login(email, password); // 调用全局store
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### 代码质量要求
|
|
151
|
-
|
|
152
|
-
**必须通过**:
|
|
153
|
-
- [ ] TypeScript类型检查无错误
|
|
154
|
-
- [ ] ESLint检查无错误
|
|
155
|
-
- [ ] 单元测试覆盖率 > 70%(核心逻辑)
|
|
156
|
-
- [ ] 手动测试通过所有验收标准
|
|
157
|
-
|
|
158
|
-
**推荐优化**:
|
|
159
|
-
- [ ] 性能优化(lazy loading、缓存)
|
|
160
|
-
- [ ] 无障碍支持(ARIA标签)
|
|
161
|
-
- [ ] 响应式优化(移动端适配)
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## HANDOFF文档要点
|
|
166
|
-
|
|
167
|
-
AI生成的 `HANDOFF.md` 应包含:
|
|
168
|
-
|
|
169
|
-
### 实现总结
|
|
170
|
-
- 主要功能实现说明
|
|
171
|
-
- API集成情况
|
|
172
|
-
- 状态管理方案
|
|
173
|
-
|
|
174
|
-
### 产出文件
|
|
175
|
-
```
|
|
176
|
-
修改的文件:
|
|
177
|
-
- LoginPage.tsx - 添加真实API调用
|
|
178
|
-
- useAuth.ts - 新增全局登录状态hook
|
|
179
|
-
- api/auth.ts - 新增登录API封装
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### API集成清单
|
|
183
|
-
|
|
184
|
-
| 端点 | 方法 | 用途 | 位置 |
|
|
185
|
-
|------|------|------|------|
|
|
186
|
-
| /api/auth/login | POST | 用户登录 | LoginPage.tsx:67 |
|
|
187
|
-
| /api/auth/logout | POST | 用户登出 | Header.tsx:34 |
|
|
188
|
-
|
|
189
|
-
### 测试说明
|
|
190
|
-
```
|
|
191
|
-
已添加的测试:
|
|
192
|
-
- LoginForm.test.tsx - 表单验证测试
|
|
193
|
-
- useAuth.test.ts - Hook逻辑测试
|
|
194
|
-
|
|
195
|
-
测试覆盖率:78%
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### 已知问题
|
|
199
|
-
如有遗留问题,明确说明:
|
|
200
|
-
1. 问题描述
|
|
201
|
-
2. 影响范围
|
|
202
|
-
3. 计划修复时间
|
|
203
|
-
|
|
204
|
-
### 部署注意事项
|
|
205
|
-
|
|
206
|
-
**环境变量**:
|
|
207
|
-
```bash
|
|
208
|
-
VITE_API_BASE_URL=https://api.example.com
|
|
209
|
-
VITE_AUTH_REDIRECT_URI=https://app.example.com/callback
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
**依赖项**:
|
|
213
|
-
- 新增:`axios@1.6.0`, `zustand@4.5.0`
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
## 质量检查清单
|
|
218
|
-
|
|
219
|
-
在执行 `/trellis:handoff` 前,确保:
|
|
220
|
-
|
|
221
|
-
### 功能性
|
|
222
|
-
- [ ] 所有PRD要求的功能已实现
|
|
223
|
-
- [ ] Mock API已全部替换为真实API
|
|
224
|
-
- [ ] 错误处理完善(网络错误、业务错误)
|
|
225
|
-
- [ ] 边缘场景已处理
|
|
226
|
-
|
|
227
|
-
### 代码质量
|
|
228
|
-
- [ ] TypeScript编译无错误
|
|
229
|
-
- [ ] ESLint检查通过
|
|
230
|
-
- [ ] 单元测试覆盖核心逻辑
|
|
231
|
-
- [ ] 代码已Code Review
|
|
232
|
-
|
|
233
|
-
### 用户体验
|
|
234
|
-
- [ ] 加载状态友好
|
|
235
|
-
- [ ] 错误提示清晰
|
|
236
|
-
- [ ] 交互流畅
|
|
237
|
-
- [ ] 响应式适配(如需要)
|
|
238
|
-
|
|
239
|
-
### 文档
|
|
240
|
-
- [ ] HANDOFF文档完整
|
|
241
|
-
- [ ] API集成清单准确
|
|
242
|
-
- [ ] 环境变量已文档化
|
|
243
|
-
- [ ] 已知问题已记录
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## 从原型到生产的改造要点
|
|
248
|
-
|
|
249
|
-
### 1. API集成
|
|
250
|
-
```typescript
|
|
251
|
-
// Before (Designer's mock)
|
|
252
|
-
const mockLogin = () => Promise.resolve(mockUser);
|
|
253
|
-
|
|
254
|
-
// After (Real API)
|
|
255
|
-
const login = (email, password) => apiClient.post('/api/auth/login', { email, password });
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### 2. 错误处理
|
|
259
|
-
```typescript
|
|
260
|
-
// Before (无错误处理)
|
|
261
|
-
const handleSubmit = async () => {
|
|
262
|
-
const user = await mockLogin();
|
|
263
|
-
setUser(user);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
// After (完善错误处理)
|
|
267
|
-
const handleSubmit = async () => {
|
|
268
|
-
try {
|
|
269
|
-
setLoading(true);
|
|
270
|
-
const user = await login(email, password);
|
|
271
|
-
setUser(user);
|
|
272
|
-
} catch (error) {
|
|
273
|
-
handleError(error);
|
|
274
|
-
} finally {
|
|
275
|
-
setLoading(false);
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### 3. 状态管理
|
|
281
|
-
```typescript
|
|
282
|
-
// Before (本地state)
|
|
283
|
-
const [user, setUser] = useState(null);
|
|
284
|
-
|
|
285
|
-
// After (全局store)
|
|
286
|
-
const { user, login, logout } = useAuthStore();
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### 4. 性能优化
|
|
290
|
-
```typescript
|
|
291
|
-
// Before (直接import)
|
|
292
|
-
import HeavyComponent from './HeavyComponent';
|
|
293
|
-
|
|
294
|
-
// After (lazy loading)
|
|
295
|
-
const HeavyComponent = lazy(() => import('./HeavyComponent'));
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
---
|
|
299
|
-
|
|
300
|
-
## 常见问题
|
|
301
|
-
|
|
302
|
-
### Q: 可以重构Designer的代码吗?
|
|
303
|
-
A: 可以,但需要在HANDOFF中说明重构理由。保持组件结构相似,便于Designer理解。
|
|
304
|
-
|
|
305
|
-
### Q: Mock数据可以删除吗?
|
|
306
|
-
A: 保留Mock数据用于测试。在 `__tests__/mocks/` 目录下集中管理。
|
|
307
|
-
|
|
308
|
-
### Q: 需要实现哪些测试?
|
|
309
|
-
A: 最低要求:核心业务逻辑的单元测试。推荐:集成测试、E2E测试。
|
|
310
|
-
|
|
311
|
-
### Q: 如何处理原型中没有的功能?
|
|
312
|
-
A: 参考PRD,如果是必需功能但原型缺失,补充实现并在HANDOFF中说明。
|
|
313
|
-
|
|
314
|
-
---
|
|
315
|
-
|
|
316
|
-
## 参考资料
|
|
317
|
-
|
|
318
|
-
- [API集成指南](./api-integration.md)
|
|
319
|
-
- [状态管理最佳实践](./state-management.md)
|
|
320
|
-
- [错误处理规范](./error-handling.md)
|
|
321
|
-
- [测试指南](./testing-guide.md)
|