@jahanxu/trellis 0.4.2 → 0.5.1

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 (67) hide show
  1. package/dist/configurators/workflow.d.ts.map +1 -1
  2. package/dist/configurators/workflow.js +58 -1
  3. package/dist/configurators/workflow.js.map +1 -1
  4. package/dist/constants/paths.d.ts +17 -0
  5. package/dist/constants/paths.d.ts.map +1 -1
  6. package/dist/constants/paths.js +19 -0
  7. package/dist/constants/paths.js.map +1 -1
  8. package/dist/templates/claude/commands/trellis/handoff.md +90 -387
  9. package/dist/templates/claude/commands/trellis/pick-task.md +74 -444
  10. package/dist/templates/claude/commands/trellis/update-spec.md +19 -3
  11. package/dist/templates/claude/hooks/inject-subagent-context.py +17 -101
  12. package/dist/templates/claude/hooks/ralph-loop.py +1 -0
  13. package/dist/templates/claude/hooks/session-start.py +170 -54
  14. package/dist/templates/iflow/commands/trellis/handoff.md +148 -0
  15. package/dist/templates/iflow/commands/trellis/pick-task.md +145 -0
  16. package/dist/templates/iflow/commands/trellis/update-spec.md +19 -3
  17. package/dist/templates/iflow/hooks/inject-subagent-context.py +1 -0
  18. package/dist/templates/iflow/hooks/ralph-loop.py +1 -0
  19. package/dist/templates/iflow/hooks/session-start.py +171 -0
  20. package/dist/templates/markdown/index.d.ts +9 -0
  21. package/dist/templates/markdown/index.d.ts.map +1 -1
  22. package/dist/templates/markdown/index.js +10 -0
  23. package/dist/templates/markdown/index.js.map +1 -1
  24. package/dist/templates/markdown/spec/roles/designer/index.md.txt +57 -0
  25. package/dist/templates/markdown/spec/roles/designer/mock-data-standards.md.txt +63 -0
  26. package/dist/templates/markdown/spec/roles/designer/prototype-guidelines.md.txt +49 -0
  27. package/dist/templates/markdown/spec/roles/frontend-impl/api-integration.md.txt +63 -0
  28. package/dist/templates/markdown/spec/roles/frontend-impl/index.md.txt +57 -0
  29. package/dist/templates/markdown/spec/roles/frontend-impl/prototype-to-production.md.txt +57 -0
  30. package/dist/templates/markdown/spec/roles/pm/index.md.txt +45 -0
  31. package/dist/templates/markdown/spec/roles/pm/prd-template.md.txt +64 -0
  32. package/dist/templates/markdown/spec/roles/pm/requirement-checklist.md.txt +43 -0
  33. package/dist/templates/trellis/index.d.ts +1 -0
  34. package/dist/templates/trellis/index.d.ts.map +1 -1
  35. package/dist/templates/trellis/index.js +2 -0
  36. package/dist/templates/trellis/index.js.map +1 -1
  37. package/dist/templates/trellis/scripts/add_session.py +3 -2
  38. package/dist/templates/trellis/scripts/common/cli_adapter.py +4 -4
  39. package/dist/templates/trellis/scripts/common/developer.py +4 -4
  40. package/dist/templates/trellis/scripts/common/git_context.py +7 -7
  41. package/dist/templates/trellis/scripts/common/paths.py +64 -14
  42. package/dist/templates/trellis/scripts/common/phase.py +2 -2
  43. package/dist/templates/trellis/scripts/common/registry.py +16 -16
  44. package/dist/templates/trellis/scripts/common/task_queue.py +10 -10
  45. package/dist/templates/trellis/scripts/common/task_utils.py +5 -5
  46. package/dist/templates/trellis/scripts/common/worktree.py +8 -8
  47. package/dist/templates/trellis/scripts/pool.py +214 -266
  48. package/dist/templates/trellis/scripts/task.py +3 -116
  49. package/package.json +3 -3
  50. package/dist/templates/claude/commands/trellis/before-role-work.md +0 -364
  51. package/dist/templates/trellis/VERSION +0 -1
  52. package/dist/templates/trellis/deliverables/README.md +0 -51
  53. package/dist/templates/trellis/paths.README.md +0 -277
  54. package/dist/templates/trellis/paths.yaml +0 -41
  55. package/dist/templates/trellis/pool/implementations.json +0 -5
  56. package/dist/templates/trellis/pool/prototypes.json +0 -5
  57. package/dist/templates/trellis/pool/requirements.json +0 -5
  58. package/dist/templates/trellis/scripts/common/project_paths.py +0 -189
  59. package/dist/templates/trellis/scripts/handoff_generator.py +0 -380
  60. package/dist/templates/trellis/spec/roles/designer/index.md +0 -243
  61. package/dist/templates/trellis/spec/roles/designer/mock-data-standards.md +0 -481
  62. package/dist/templates/trellis/spec/roles/designer/prototype-guidelines.md +0 -429
  63. package/dist/templates/trellis/spec/roles/frontend-impl/api-integration.md +0 -565
  64. package/dist/templates/trellis/spec/roles/frontend-impl/index.md +0 -321
  65. package/dist/templates/trellis/spec/roles/frontend-impl/state-management.md +0 -599
  66. package/dist/templates/trellis/spec/roles/pm/index.md +0 -112
  67. package/dist/templates/trellis/spec/roles/pm/prd-template.md +0 -124
@@ -1,429 +0,0 @@
1
- # 原型代码开发指南
2
-
3
- > Designer 角色创建可运行原型的详细指南
4
-
5
- ---
6
-
7
- ## 核心原则
8
-
9
- 原型代码的目标是:
10
- 1. **可运行** - Frontend 可以直接启动并看到效果
11
- 2. **易替换** - Mock 数据和 API 位置清晰,Frontend 可以快速替换
12
- 3. **接近真实** - 布局、交互、数据结构接近最终产品
13
-
14
- ---
15
-
16
- ## 原型结构规范
17
-
18
- ### 推荐目录结构
19
-
20
- ```
21
- task-dir/
22
- ├── src/
23
- │ ├── pages/ # 页面组件
24
- │ │ └── LoginPage.tsx
25
- │ ├── components/ # 复用组件
26
- │ │ ├── LoginForm.tsx
27
- │ │ └── SocialLoginButtons.tsx
28
- │ ├── mocks/ # Mock数据(集中管理)
29
- │ │ └── auth.mock.ts
30
- │ └── types/ # TypeScript类型定义
31
- │ └── user.ts
32
- ├── package.json
33
- ├── tsconfig.json
34
- └── README.md # 原型说明文档
35
- ```
36
-
37
- ### 文件命名规范
38
-
39
- - **组件文件**:大驼峰命名 `LoginForm.tsx`
40
- - **Mock 文件**:`*.mock.ts` 或 `*.mock.tsx`
41
- - **类型文件**:小驼峰或大驼峰 `user.ts` 或 `User.ts`
42
-
43
- ---
44
-
45
- ## Mock 数据规范
46
-
47
- ### 1. 集中管理
48
-
49
- **✅ 推荐**:所有 Mock 数据放在 `src/mocks/` 目录
50
-
51
- ```typescript
52
- // src/mocks/auth.mock.ts
53
- import type { User } from '../types/user';
54
-
55
- export const mockUser: User = {
56
- id: "mock-user-1",
57
- name: "张三",
58
- email: "zhangsan@example.com",
59
- avatar: "https://via.placeholder.com/150",
60
- createdAt: "2026-01-01T00:00:00Z"
61
- };
62
-
63
- export const mockUserList: User[] = [
64
- mockUser,
65
- {
66
- id: "mock-user-2",
67
- name: "李四",
68
- email: "lisi@example.com",
69
- avatar: "https://via.placeholder.com/150",
70
- createdAt: "2026-01-02T00:00:00Z"
71
- },
72
- // ... 10-20 条数据,模拟真实场景
73
- ];
74
- ```
75
-
76
- **❌ 避免**:在组件中硬编码 Mock 数据
77
-
78
- ```typescript
79
- // ❌ 不推荐
80
- const LoginPage = () => {
81
- const [user, setUser] = useState({ name: "测试用户" });
82
- // ...
83
- };
84
- ```
85
-
86
- ### 2. 类型安全
87
-
88
- 所有 Mock 数据必须符合类型定义:
89
-
90
- ```typescript
91
- // src/types/user.ts
92
- export interface User {
93
- id: string;
94
- name: string;
95
- email: string;
96
- avatar?: string;
97
- createdAt: string;
98
- }
99
-
100
- // src/mocks/auth.mock.ts
101
- import type { User } from '../types/user';
102
-
103
- // ✅ TypeScript 会检查类型
104
- export const mockUser: User = {
105
- id: "1",
106
- name: "张三",
107
- email: "zhangsan@example.com",
108
- createdAt: "2026-01-01T00:00:00Z"
109
- };
110
- ```
111
-
112
- ### 3. 真实性原则
113
-
114
- Mock 数据应该接近真实场景:
115
-
116
- **✅ 推荐**:
117
- ```typescript
118
- export const mockProductList = [
119
- {
120
- id: "prod-001",
121
- name: "iPhone 15 Pro",
122
- price: 7999,
123
- stock: 50,
124
- category: "电子产品",
125
- tags: ["手机", "苹果", "5G"],
126
- createdAt: "2026-01-15T10:30:00Z"
127
- },
128
- // ... 10-20 条,覆盖各种场景
129
- ];
130
- ```
131
-
132
- **❌ 避免**:
133
- ```typescript
134
- export const mockProductList = [
135
- { id: "1", name: "test", price: 100 }
136
- ];
137
- ```
138
-
139
- ---
140
-
141
- ## Mock API 规范
142
-
143
- ### 1. API 位置标注
144
-
145
- 使用清晰的 TODO 注释标注需要替换的位置:
146
-
147
- ```typescript
148
- // ✅ 推荐格式
149
- const handleLogin = async (email: string, password: string) => {
150
- // TODO: [Frontend] 替换为真实API调用 POST /api/auth/login
151
- return new Promise<User>((resolve) => {
152
- setTimeout(() => resolve(mockUser), 1000);
153
- });
154
- };
155
- ```
156
-
157
- **TODO 注释格式**:
158
- - `[Frontend]` - 标明需要 Frontend 角色处理
159
- - API 方法和路径 - `POST /api/auth/login`
160
- - 文件位置 - 自动通过 grep 查找
161
-
162
- ### 2. API 响应模拟
163
-
164
- Mock API 应该模拟真实 API 的行为:
165
-
166
- ```typescript
167
- // ✅ 推荐:模拟延迟、成功/失败场景
168
- const mockLoginAPI = async (email: string, password: string): Promise<User> => {
169
- // TODO: [Frontend] 替换为真实API调用 POST /api/auth/login
170
- return new Promise((resolve, reject) => {
171
- setTimeout(() => {
172
- // 模拟登录失败
173
- if (email === "fail@example.com") {
174
- reject(new Error("邮箱或密码错误"));
175
- } else {
176
- resolve(mockUser);
177
- }
178
- }, 1000); // 模拟网络延迟
179
- });
180
- };
181
- ```
182
-
183
- ### 3. 状态管理
184
-
185
- 简单的原型可以使用 React 内置状态:
186
-
187
- ```typescript
188
- // ✅ 推荐:简单原型使用 useState
189
- const LoginPage = () => {
190
- const [user, setUser] = useState<User | null>(null);
191
- const [loading, setLoading] = useState(false);
192
- const [error, setError] = useState<string | null>(null);
193
-
194
- const handleLogin = async (email: string, password: string) => {
195
- setLoading(true);
196
- setError(null);
197
- try {
198
- const user = await mockLoginAPI(email, password);
199
- setUser(user);
200
- } catch (err) {
201
- setError(err.message);
202
- } finally {
203
- setLoading(false);
204
- }
205
- };
206
-
207
- return (
208
- // ... JSX
209
- );
210
- };
211
- ```
212
-
213
- **注意**:复杂状态(全局用户状态、购物车等)在原型阶段可以简化,Frontend 会补充完整的状态管理方案。
214
-
215
- ---
216
-
217
- ## 组件设计规范
218
-
219
- ### 1. 组件拆分原则
220
-
221
- **按功能拆分**:
222
- ```
223
- LoginPage (页面组件)
224
- ├── LoginForm (表单逻辑)
225
- │ ├── EmailInput (输入组件)
226
- │ └── PasswordInput (输入组件)
227
- └── SocialLoginButtons (第三方登录)
228
- ```
229
-
230
- **拆分标准**:
231
- - 单一职责:每个组件只负责一个功能
232
- - 可复用性:通用组件(如 Button、Input)可以被多个页面使用
233
- - 复杂度控制:组件文件不超过 200 行
234
-
235
- ### 2. Props 接口定义
236
-
237
- 使用 TypeScript 定义清晰的 Props 接口:
238
-
239
- ```typescript
240
- interface LoginFormProps {
241
- onSubmit: (email: string, password: string) => void;
242
- loading?: boolean;
243
- error?: string;
244
- }
245
-
246
- const LoginForm: React.FC<LoginFormProps> = ({ onSubmit, loading, error }) => {
247
- // ...
248
- };
249
- ```
250
-
251
- ### 3. 组件命名规范
252
-
253
- - 页面组件:`XxxPage.tsx` (如 `LoginPage.tsx`)
254
- - 功能组件:`XxxForm.tsx`、`XxxList.tsx`
255
- - UI 组件:`Button.tsx`、`Input.tsx`
256
-
257
- ---
258
-
259
- ## 样式规范
260
-
261
- ### 推荐技术栈
262
-
263
- 根据项目选择:
264
-
265
- | 技术栈 | 适用场景 | 优点 |
266
- |--------|---------|------|
267
- | **Tailwind CSS** | 快速原型 | 无需写 CSS 文件,开发快 |
268
- | **CSS Modules** | 组件隔离 | 样式作用域明确 |
269
- | **Styled Components** | 复杂主题 | 动态样式、主题切换 |
270
-
271
- ### Tailwind CSS 示例
272
-
273
- ```tsx
274
- // ✅ 推荐:使用 Tailwind
275
- const LoginButton = () => (
276
- <button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
277
- 登录
278
- </button>
279
- );
280
- ```
281
-
282
- ### 样式原则
283
-
284
- 1. **接近最终效果**:布局、颜色、字体应该接近 PRD 要求
285
- 2. **响应式可选**:根据 PRD 要求决定是否实现响应式
286
- 3. **细节可简化**:动画、过渡效果可以简化,在 HANDOFF 中说明预期效果
287
-
288
- ---
289
-
290
- ## 交互实现规范
291
-
292
- ### 必须实现的交互
293
-
294
- - [ ] **表单输入**:所有输入框可以输入
295
- - [ ] **按钮点击**:所有按钮有点击事件
296
- - [ ] **链接跳转**:所有链接可以跳转(或模拟跳转)
297
- - [ ] **加载状态**:提交表单时显示加载状态
298
- - [ ] **错误提示**:模拟错误场景并显示错误信息
299
-
300
- ### 可以简化的交互
301
-
302
- - **复杂动画**:可以用简单过渡替代
303
- - **拖拽排序**:可以用点击上下移动替代
304
- - **实时搜索**:可以用按钮触发搜索替代
305
-
306
- ### 交互示例
307
-
308
- ```tsx
309
- const LoginPage = () => {
310
- const [email, setEmail] = useState('');
311
- const [password, setPassword] = useState('');
312
- const [loading, setLoading] = useState(false);
313
- const [error, setError] = useState<string | null>(null);
314
-
315
- const handleSubmit = async (e: React.FormEvent) => {
316
- e.preventDefault();
317
- setLoading(true);
318
- setError(null);
319
-
320
- try {
321
- await mockLoginAPI(email, password);
322
- // 跳转到首页(原型阶段可以 alert 或 console.log)
323
- alert('登录成功!');
324
- } catch (err) {
325
- setError('登录失败,请检查邮箱和密码');
326
- } finally {
327
- setLoading(false);
328
- }
329
- };
330
-
331
- return (
332
- <form onSubmit={handleSubmit}>
333
- <input
334
- type="email"
335
- value={email}
336
- onChange={(e) => setEmail(e.target.value)}
337
- placeholder="邮箱"
338
- disabled={loading}
339
- />
340
- <input
341
- type="password"
342
- value={password}
343
- onChange={(e) => setPassword(e.target.value)}
344
- placeholder="密码"
345
- disabled={loading}
346
- />
347
- {error && <p className="text-red-500">{error}</p>}
348
- <button type="submit" disabled={loading}>
349
- {loading ? '登录中...' : '登录'}
350
- </button>
351
- </form>
352
- );
353
- };
354
- ```
355
-
356
- ---
357
-
358
- ## 原型文档要求
359
-
360
- ### README.md 必须包含
361
-
362
- ```markdown
363
- # [功能名称] 原型
364
-
365
- ## 功能说明
366
- 简要描述此原型实现的功能
367
-
368
- ## 启动方式
369
- \`\`\`bash
370
- npm install
371
- npm run dev
372
- \`\`\`
373
-
374
- ## Mock 数据位置
375
- - 用户数据:src/mocks/user.mock.ts
376
- - 产品数据:src/mocks/product.mock.ts
377
-
378
- ## 需要 Frontend 补充的功能
379
- 1. 替换 Mock API 为真实 API(位置:src/pages/LoginPage.tsx:45)
380
- 2. 接入全局用户状态管理
381
- 3. 完善错误处理(网络超时、权限验证)
382
-
383
- ## 技术栈
384
- - React 18
385
- - TypeScript 5
386
- - Tailwind CSS 3
387
- - Vite 5
388
- ```
389
-
390
- ---
391
-
392
- ## 检查清单
393
-
394
- 在完成原型前,确保:
395
-
396
- - [ ] 项目可以正常启动(`npm run dev` 无报错)
397
- - [ ] 所有交互可以操作(按钮、输入框、链接)
398
- - [ ] Mock 数据结构合理(符合类型定义)
399
- - [ ] Mock API 位置已用 TODO 注释标注
400
- - [ ] 组件命名语义化
401
- - [ ] README.md 包含必要信息
402
- - [ ] 已测试关键交互流程(登录、提交、错误处理)
403
-
404
- ---
405
-
406
- ## 常见问题
407
-
408
- ### Q: 原型需要实现所有 PRD 功能吗?
409
- A: 实现**核心流程**即可。边缘场景可以用 TODO 注释标注,交给 Frontend 补充。
410
-
411
- ### Q: 原型需要完美像素级还原设计稿吗?
412
- A: 不需要。布局结构正确、颜色接近即可。细节由 Frontend 优化。
413
-
414
- ### Q: 如何处理复杂状态管理(Redux/Zustand)?
415
- A: 原型阶段可以简化为 `useState` 或 `useContext`。在 HANDOFF 中说明需要 Frontend 接入全局状态。
416
-
417
- ### Q: 原型需要写单元测试吗?
418
- A: 不需要。测试由 Frontend 补充。
419
-
420
- ### Q: 原型需要处理所有错误场景吗?
421
- A: 只需要处理**主要错误场景**(如登录失败、网络错误)。边缘场景交给 Frontend。
422
-
423
- ---
424
-
425
- ## 相关文档
426
-
427
- - [Designer 工作规范](./index.md)
428
- - [Mock 数据标准](./mock-data-standards.md)
429
- - [前端组件规范](../frontend/component-guidelines.md)