@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,277 +0,0 @@
1
- # 三角色协作路径配置说明
2
-
3
- > 框架层与业务层分离,支持不同项目自定义目录结构
4
-
5
- ---
6
-
7
- ## 设计理念
8
-
9
- **问题**:`deliverables/` 及其子目录是业务层概念,不应该在框架层硬编码。
10
-
11
- **解决**:通过 `.trellis/paths.yaml` 配置文件,将路径定义从框架层抽离到项目配置层。
12
-
13
- **优点**:
14
- - ✅ 框架通用性更强,可适配不同项目
15
- - ✅ 一处配置,处处生效
16
- - ✅ 向后兼容(配置文件不存在时使用默认值)
17
-
18
- ---
19
-
20
- ## 配置文件
21
-
22
- ### 位置
23
-
24
- `.trellis/paths.yaml`
25
-
26
- ### 默认配置
27
-
28
- 如果此文件不存在,使用以下默认值:
29
-
30
- ```yaml
31
- deliverables_base: "deliverables"
32
-
33
- role_outputs:
34
- pm:
35
- dir: "requirements"
36
- designer:
37
- dir: "prototypes"
38
- frontend:
39
- dir: "production/features"
40
-
41
- pools:
42
- pm: "requirements"
43
- designer: "prototypes"
44
- frontend: "implementations"
45
- ```
46
-
47
- ### 自定义示例
48
-
49
- #### 示例1:修改基础目录名
50
-
51
- ```yaml
52
- # 将 deliverables/ 改为 outputs/
53
- deliverables_base: "outputs"
54
-
55
- role_outputs:
56
- pm:
57
- dir: "requirements"
58
- designer:
59
- dir: "prototypes"
60
- frontend:
61
- dir: "production/features"
62
- ```
63
-
64
- **结果**:
65
- - PM 产出 → `outputs/requirements/`
66
- - Designer 产出 → `outputs/prototypes/`
67
- - Frontend 产出 → `outputs/production/features/`
68
-
69
- #### 示例2:完全自定义
70
-
71
- ```yaml
72
- deliverables_base: "artifacts"
73
-
74
- role_outputs:
75
- pm:
76
- dir: "specs"
77
- designer:
78
- dir: "designs"
79
- frontend:
80
- dir: "code"
81
- ```
82
-
83
- **结果**:
84
- - PM 产出 → `artifacts/specs/`
85
- - Designer 产出 → `artifacts/designs/`
86
- - Frontend 产出 → `artifacts/code/`
87
-
88
- #### 示例3:多级目录
89
-
90
- ```yaml
91
- deliverables_base: "dist"
92
-
93
- role_outputs:
94
- pm:
95
- dir: "docs/requirements"
96
- designer:
97
- dir: "docs/designs"
98
- frontend:
99
- dir: "src/features"
100
- ```
101
-
102
- **结果**:
103
- - PM 产出 → `dist/docs/requirements/`
104
- - Designer 产出 → `dist/docs/designs/`
105
- - Frontend 产出 → `dist/src/features/`
106
-
107
- ---
108
-
109
- ## 使用方式
110
-
111
- ### 在 Python 脚本中使用
112
-
113
- ```python
114
- from common.project_paths import get_output_dir_for_task, get_repo_root
115
-
116
- repo_root = get_repo_root()
117
- role = "pm"
118
- task_id = "user-login"
119
-
120
- # 获取产出目录
121
- output_dir = get_output_dir_for_task(repo_root, role, task_id)
122
- # 结果:deliverables/requirements/user-login(默认配置)
123
- # 或:outputs/specs/user-login(自定义配置)
124
- ```
125
-
126
- ### 在命令行中使用
127
-
128
- ```bash
129
- # 查看当前配置
130
- python3 .trellis/scripts/common/project_paths.py
131
-
132
- # 输出:
133
- # === Loaded Configuration ===
134
- # Deliverables base: deliverables
135
- #
136
- # Role output directories:
137
- # pm: deliverables/requirements
138
- # designer: deliverables/prototypes
139
- # frontend: deliverables/production/features
140
- ```
141
-
142
- ### 在 AI 命令中使用
143
-
144
- AI 读取配置并自动使用正确的路径:
145
-
146
- ```bash
147
- # AI 执行 /trellis:handoff 时会:
148
- 1. 读取 .trellis/paths.yaml(如果存在)
149
- 2. 获取当前角色的产出目录配置
150
- 3. 创建产出目录并复制文件
151
- ```
152
-
153
- ---
154
-
155
- ## API 参考
156
-
157
- ### `load_paths_config(repo_root: Path) -> Dict`
158
-
159
- 加载路径配置,如果配置文件不存在则返回默认配置。
160
-
161
- ### `get_deliverables_base(repo_root: Path) -> str`
162
-
163
- 获取产出物基础目录名(如 `deliverables`)。
164
-
165
- ### `get_role_output_dir(repo_root: Path, role: str) -> str`
166
-
167
- 获取指定角色的产出目录路径。
168
-
169
- **参数**:
170
- - `role`: `pm`、`designer` 或 `frontend`
171
-
172
- **返回**:
173
- - 完整路径,如 `deliverables/requirements`
174
-
175
- ### `get_output_dir_for_task(repo_root: Path, role: str, task_id: str) -> str`
176
-
177
- 获取指定任务的完整产出目录路径。
178
-
179
- **返回**:
180
- - 完整路径,如 `deliverables/requirements/user-login`
181
-
182
- ### `get_pool_name(role: str) -> str`
183
-
184
- 获取指定角色的任务池名称。
185
-
186
- **返回**:
187
- - 池名称,如 `requirements`、`prototypes`、`implementations`
188
-
189
- ---
190
-
191
- ## 依赖
192
-
193
- ### 可选依赖:PyYAML
194
-
195
- ```bash
196
- pip install pyyaml
197
- ```
198
-
199
- 如果未安装 PyYAML:
200
- - ⚠️ 会打印警告信息
201
- - ✅ 仍然可以正常工作(使用默认配置)
202
-
203
- ---
204
-
205
- ## 迁移指南
206
-
207
- ### 从硬编码路径迁移
208
-
209
- **之前**:路径硬编码在文档中
210
-
211
- ```markdown
212
- | `pm` | `deliverables/requirements/{task-id}/` |
213
- ```
214
-
215
- **现在**:使用配置化路径
216
-
217
- ```python
218
- from project_paths import get_output_dir_for_task
219
- output_dir = get_output_dir_for_task(repo_root, "pm", task_id)
220
- ```
221
-
222
- ### 为现有项目添加自定义配置
223
-
224
- 1. 创建 `.trellis/paths.yaml`
225
- 2. 定义你的目录结构
226
- 3. 无需修改任何代码,AI 会自动读取新配置
227
-
228
- ---
229
-
230
- ## 注意事项
231
-
232
- 1. **池子状态文件名不建议修改**
233
- - `.trellis/pool/requirements.json`
234
- - `.trellis/pool/prototypes.json`
235
- - `.trellis/pool/implementations.json`
236
- - 这些是框架层的内部文件
237
-
238
- 2. **产出目录可以任意定制**
239
- - `deliverables/` 及其子目录
240
- - 这些是业务层的目录
241
-
242
- 3. **配置文件是可选的**
243
- - 不存在时使用默认值
244
- - 向后兼容
245
-
246
- ---
247
-
248
- ## 常见问题
249
-
250
- ### Q: 修改配置后需要重启吗?
251
- A: 不需要。每次执行命令时都会重新读取配置。
252
-
253
- ### Q: 可以为不同角色使用完全不同的基础目录吗?
254
- A: 可以,通过多级路径实现:
255
- ```yaml
256
- role_outputs:
257
- pm:
258
- dir: "../docs/specs" # 相对路径
259
- designer:
260
- dir: "ui/designs"
261
- frontend:
262
- dir: "src/features"
263
- ```
264
-
265
- ### Q: 其他项目如何快速采用?
266
- A:
267
- 1. 复制 `.trellis/` 整个目录到新项目
268
- 2. 修改 `.trellis/paths.yaml` 适配新项目的目录结构
269
- 3. 立即可用,无需修改任何代码
270
-
271
- ---
272
-
273
- ## 相关文档
274
-
275
- - [三角色协作工作流](../workflow.md)
276
- - [Handoff 命令说明](../../.claude/commands/trellis/handoff.md)
277
- - [项目路径工具源码](../scripts/common/project_paths.py)
@@ -1,41 +0,0 @@
1
- # Trellis 三角色协作路径配置
2
- #
3
- # 此文件定义项目特定的目录结构,不同项目可以自定义。
4
- # 如果此文件不存在,将使用默认值。
5
-
6
- # 产出物基础目录
7
- deliverables_base: "deliverables"
8
-
9
- # 角色产出目录映射
10
- role_outputs:
11
- pm:
12
- # PM 角色的产出目录(相对于 deliverables_base)
13
- dir: "requirements"
14
- # 完整路径(自动计算:deliverables_base + dir)
15
- # full_path: "deliverables/requirements"
16
-
17
- designer:
18
- # Designer 角色的产出目录
19
- dir: "prototypes"
20
- # full_path: "deliverables/prototypes"
21
-
22
- frontend:
23
- # Frontend 角色的产出目录
24
- dir: "production/features"
25
- # full_path: "deliverables/production/features"
26
-
27
- # 任务池配置(池子状态文件名,通常不需要修改)
28
- pools:
29
- pm: "requirements"
30
- designer: "prototypes"
31
- frontend: "implementations"
32
-
33
- # 示例:其他项目可能的配置
34
- # deliverables_base: "outputs"
35
- # role_outputs:
36
- # pm:
37
- # dir: "specs"
38
- # designer:
39
- # dir: "designs"
40
- # frontend:
41
- # dir: "code"
@@ -1,5 +0,0 @@
1
- {
2
- "available": [],
3
- "consumed": [],
4
- "last_updated": null
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "available": [],
3
- "consumed": [],
4
- "last_updated": null
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "available": [],
3
- "consumed": [],
4
- "last_updated": null
5
- }
@@ -1,189 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Project-specific path configuration loader.
4
-
5
- Reads .trellis/paths.yaml to get project-specific directory structure.
6
- Falls back to defaults if config file doesn't exist.
7
-
8
- This separates framework layer from business layer, allowing different
9
- projects to use different directory structures.
10
- """
11
-
12
- import sys
13
- from pathlib import Path
14
- from typing import Optional, Dict
15
-
16
- try:
17
- import yaml
18
- HAS_YAML = True
19
- except ImportError:
20
- HAS_YAML = False
21
-
22
- # =============================================================================
23
- # Default Configuration (Framework Layer)
24
- # =============================================================================
25
-
26
- DEFAULT_CONFIG = {
27
- "deliverables_base": "deliverables",
28
- "role_outputs": {
29
- "pm": {"dir": "requirements"},
30
- "designer": {"dir": "prototypes"},
31
- "frontend": {"dir": "production/features"},
32
- },
33
- "pools": {
34
- "pm": "requirements",
35
- "designer": "prototypes",
36
- "frontend": "implementations",
37
- },
38
- }
39
-
40
- # =============================================================================
41
- # Configuration Loader
42
- # =============================================================================
43
-
44
-
45
- def load_paths_config(repo_root: Path) -> Dict:
46
- """Load paths configuration from .trellis/paths.yaml.
47
-
48
- Args:
49
- repo_root: Repository root path
50
-
51
- Returns:
52
- Configuration dict with paths
53
- """
54
- config_file = repo_root / ".trellis" / "paths.yaml"
55
-
56
- # If config file doesn't exist, use defaults
57
- if not config_file.exists():
58
- return DEFAULT_CONFIG.copy()
59
-
60
- # If yaml not available, use defaults
61
- if not HAS_YAML:
62
- print(
63
- "Warning: PyYAML not installed, using default paths. "
64
- "Install with: pip install pyyaml",
65
- file=sys.stderr,
66
- )
67
- return DEFAULT_CONFIG.copy()
68
-
69
- # Load config from yaml
70
- try:
71
- with open(config_file, "r", encoding="utf-8") as f:
72
- config = yaml.safe_load(f) or {}
73
-
74
- # Merge with defaults (in case some keys are missing)
75
- merged = DEFAULT_CONFIG.copy()
76
- merged.update(config)
77
-
78
- # Ensure role_outputs has all roles
79
- for role in ["pm", "designer", "frontend"]:
80
- if role not in merged["role_outputs"]:
81
- merged["role_outputs"][role] = DEFAULT_CONFIG["role_outputs"][role]
82
-
83
- return merged
84
- except Exception as e:
85
- print(
86
- f"Warning: Failed to load {config_file}: {e}. Using defaults.",
87
- file=sys.stderr,
88
- )
89
- return DEFAULT_CONFIG.copy()
90
-
91
-
92
- def get_deliverables_base(repo_root: Path) -> str:
93
- """Get deliverables base directory.
94
-
95
- Args:
96
- repo_root: Repository root path
97
-
98
- Returns:
99
- Deliverables base directory name
100
- """
101
- config = load_paths_config(repo_root)
102
- return config.get("deliverables_base", "deliverables")
103
-
104
-
105
- def get_role_output_dir(repo_root: Path, role: str) -> str:
106
- """Get output directory for a specific role.
107
-
108
- Args:
109
- repo_root: Repository root path
110
- role: Role name (pm, designer, frontend)
111
-
112
- Returns:
113
- Full output directory path (relative to repo_root)
114
- """
115
- config = load_paths_config(repo_root)
116
- base = config.get("deliverables_base", "deliverables")
117
- role_config = config.get("role_outputs", {}).get(role, {})
118
- role_dir = role_config.get("dir", "")
119
-
120
- if not role_dir:
121
- # Fallback to default
122
- role_dir = DEFAULT_CONFIG["role_outputs"].get(role, {}).get("dir", "")
123
-
124
- return f"{base}/{role_dir}"
125
-
126
-
127
- def get_pool_name(role: str) -> str:
128
- """Get pool name for a specific role.
129
-
130
- Args:
131
- role: Role name (pm, designer, frontend)
132
-
133
- Returns:
134
- Pool name (e.g., 'requirements', 'prototypes', 'implementations')
135
- """
136
- # Pool names are usually fixed in framework layer
137
- # But can be overridden in config if needed
138
- return DEFAULT_CONFIG["pools"].get(role, role)
139
-
140
-
141
- def get_output_dir_for_task(repo_root: Path, role: str, task_id: str) -> str:
142
- """Get complete output directory for a specific task.
143
-
144
- Args:
145
- repo_root: Repository root path
146
- role: Role name (pm, designer, frontend)
147
- task_id: Task ID
148
-
149
- Returns:
150
- Full output directory path (e.g., "deliverables/requirements/user-login")
151
- """
152
- role_dir = get_role_output_dir(repo_root, role)
153
- return f"{role_dir}/{task_id}"
154
-
155
-
156
- # =============================================================================
157
- # CLI for testing
158
- # =============================================================================
159
-
160
-
161
- def main():
162
- """Test configuration loading."""
163
- # Add parent directory to path for imports
164
- sys.path.insert(0, str(Path(__file__).parent))
165
- from paths import get_repo_root
166
-
167
- repo_root = get_repo_root()
168
- config = load_paths_config(repo_root)
169
-
170
- print("=== Loaded Configuration ===")
171
- print(f"Deliverables base: {config['deliverables_base']}")
172
- print("\nRole output directories:")
173
- for role in ["pm", "designer", "frontend"]:
174
- full_path = get_role_output_dir(repo_root, role)
175
- print(f" {role}: {full_path}")
176
-
177
- print("\nPool names:")
178
- for role in ["pm", "designer", "frontend"]:
179
- pool = get_pool_name(role)
180
- print(f" {role}: {pool}")
181
-
182
- print("\nExample output paths:")
183
- for role in ["pm", "designer", "frontend"]:
184
- path = get_output_dir_for_task(repo_root, role, "user-login")
185
- print(f" {role}/user-login: {path}")
186
-
187
-
188
- if __name__ == "__main__":
189
- main()