@pennixrv/trellis 0.7.0-beta.46 → 0.7.0-beta.48

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 (45) hide show
  1. package/dist/cli/index.d.ts.map +1 -1
  2. package/dist/cli/index.js +35 -0
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/backup.d.ts +20 -0
  5. package/dist/commands/backup.d.ts.map +1 -0
  6. package/dist/commands/backup.js +122 -0
  7. package/dist/commands/backup.js.map +1 -0
  8. package/dist/commands/channel/rm.d.ts.map +1 -1
  9. package/dist/commands/channel/rm.js +203 -91
  10. package/dist/commands/channel/rm.js.map +1 -1
  11. package/dist/commands/update.d.ts.map +1 -1
  12. package/dist/commands/update.js +10 -4
  13. package/dist/commands/update.js.map +1 -1
  14. package/dist/commands/workflow.js +1 -1
  15. package/dist/commands/workflow.js.map +1 -1
  16. package/dist/migrations/manifests/0.7.0-beta.47.json +9 -0
  17. package/dist/migrations/manifests/0.7.0-beta.48.json +9 -0
  18. package/dist/templates/codex/hooks/session-start.py +6 -6
  19. package/dist/templates/copilot/hooks/session-start.py +6 -6
  20. package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +22 -22
  21. package/dist/templates/markdown/spec/backend/directory-structure.md.txt +20 -20
  22. package/dist/templates/markdown/spec/backend/error-handling.md.txt +22 -22
  23. package/dist/templates/markdown/spec/backend/index.md.txt +19 -19
  24. package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +22 -22
  25. package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +22 -22
  26. package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +25 -25
  27. package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +20 -20
  28. package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +22 -22
  29. package/dist/templates/markdown/spec/frontend/index.md.txt +20 -20
  30. package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +22 -22
  31. package/dist/templates/markdown/spec/frontend/state-management.md.txt +22 -22
  32. package/dist/templates/markdown/spec/frontend/type-safety.md.txt +22 -22
  33. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +80 -85
  34. package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +164 -209
  35. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +161 -185
  36. package/dist/templates/markdown/spec/guides/index.md.txt +51 -51
  37. package/dist/templates/markdown/workspace-index.md +44 -44
  38. package/dist/templates/opencode/lib/session-utils.js +2 -2
  39. package/dist/templates/shared-hooks/session-start.py +7 -7
  40. package/dist/templates/trellis/scripts/add_session.py +35 -32
  41. package/dist/templates/trellis/scripts/common/developer.py +18 -18
  42. package/dist/templates/trellis/scripts/common/task_store.py +11 -11
  43. package/dist/templates/trellis/scripts/common/workflow_phase.py +4 -3
  44. package/dist/templates/trellis/workflow.md +403 -458
  45. package/package.json +2 -2
@@ -1,39 +1,39 @@
1
- # Frontend Development Guidelines
1
+ # 前端开发指南(Frontend Development Guidelines)
2
2
 
3
- > Best practices for frontend development in this project.
3
+ > 本项目的前端开发最佳实践。
4
4
 
5
5
  ---
6
6
 
7
- ## Overview
7
+ ## 概览(Overview)
8
8
 
9
- This directory contains guidelines for frontend development. Fill in each file with your project's specific conventions.
9
+ 本目录包含前端开发指南。请在各文件中填写项目的具体约定。
10
10
 
11
11
  ---
12
12
 
13
- ## Guidelines Index
13
+ ## 指南索引(Guidelines Index)
14
14
 
15
- | Guide | Description | Status |
15
+ | 指南(Guide) | 说明(Description) | 状态(Status) |
16
16
  |-------|-------------|--------|
17
- | [Directory Structure](./directory-structure.md) | Module organization and file layout | To fill |
18
- | [Component Guidelines](./component-guidelines.md) | Component patterns, props, composition | To fill |
19
- | [Hook Guidelines](./hook-guidelines.md) | Custom hooks, data fetching patterns | To fill |
20
- | [State Management](./state-management.md) | Local state, global state, server state | To fill |
21
- | [Quality Guidelines](./quality-guidelines.md) | Code standards, forbidden patterns | To fill |
22
- | [Type Safety](./type-safety.md) | Type patterns, validation | To fill |
17
+ | [目录结构(Directory Structure)](./directory-structure.md) | 模块组织和文件布局 | 待填写 |
18
+ | [组件指南(Component Guidelines)](./component-guidelines.md) | 组件模式、props 和组合 | 待填写 |
19
+ | [Hook 指南(Hook Guidelines)](./hook-guidelines.md) | 自定义 Hook 和数据获取模式 | 待填写 |
20
+ | [状态管理(State Management)](./state-management.md) | 本地状态、全局状态和服务端状态 | 待填写 |
21
+ | [质量指南(Quality Guidelines)](./quality-guidelines.md) | 代码标准和禁止模式 | 待填写 |
22
+ | [类型安全(Type Safety)](./type-safety.md) | 类型模式和校验 | 待填写 |
23
23
 
24
24
  ---
25
25
 
26
- ## How to Fill These Guidelines
26
+ ## 如何填写这些指南(How to Fill These Guidelines)
27
27
 
28
- For each guideline file:
28
+ 对于每个指南文件:
29
29
 
30
- 1. Document your project's **actual conventions** (not ideals)
31
- 2. Include **code examples** from your codebase
32
- 3. List **forbidden patterns** and why
33
- 4. Add **common mistakes** your team has made
30
+ 1. 记录项目的**实际约定**,而不是理想状态
31
+ 2. 包含代码库中的**代码示例**
32
+ 3. 列出**禁止模式**及其原因
33
+ 4. 补充团队曾经出现过的**常见错误**
34
34
 
35
- The goal is to help AI assistants and new team members understand how YOUR project works.
35
+ 目标是帮助 AI 助手和新团队成员理解项目的实际工作方式。
36
36
 
37
37
  ---
38
38
 
39
- **Language**: All documentation should be written in **English**.
39
+ **语言(Language)**:所有文档默认使用**简体中文**。
@@ -1,51 +1,51 @@
1
- # Quality Guidelines
1
+ # 质量指南(Quality Guidelines)
2
2
 
3
- > Code quality standards for frontend development.
3
+ > 前端开发的代码质量标准。
4
4
 
5
5
  ---
6
6
 
7
- ## Overview
7
+ ## 概览(Overview)
8
8
 
9
9
  <!--
10
- Document your project's quality standards here.
10
+ 在此记录项目的质量标准。
11
11
 
12
- Questions to answer:
13
- - What patterns are forbidden?
14
- - What linting rules do you enforce?
15
- - What are your testing requirements?
16
- - What code review standards apply?
12
+ 需要回答的问题:
13
+ - 禁止哪些模式?
14
+ - 执行哪些 lint 规则?
15
+ - 有哪些测试要求?
16
+ - 适用哪些代码审查标准?
17
17
  -->
18
18
 
19
- (To be filled by the team)
19
+ (待团队填写)
20
20
 
21
21
  ---
22
22
 
23
- ## Forbidden Patterns
23
+ ## 禁止模式(Forbidden Patterns)
24
24
 
25
- <!-- Patterns that should never be used and why -->
25
+ <!-- 永远不应使用的模式及其原因 -->
26
26
 
27
- (To be filled by the team)
27
+ (待团队填写)
28
28
 
29
29
  ---
30
30
 
31
- ## Required Patterns
31
+ ## 必须遵守的模式(Required Patterns)
32
32
 
33
- <!-- Patterns that must always be used -->
33
+ <!-- 必须始终使用的模式 -->
34
34
 
35
- (To be filled by the team)
35
+ (待团队填写)
36
36
 
37
37
  ---
38
38
 
39
- ## Testing Requirements
39
+ ## 测试要求(Testing Requirements)
40
40
 
41
- <!-- What level of testing is expected -->
41
+ <!-- 期望达到的测试层级 -->
42
42
 
43
- (To be filled by the team)
43
+ (待团队填写)
44
44
 
45
45
  ---
46
46
 
47
- ## Code Review Checklist
47
+ ## 代码审查清单(Code Review Checklist)
48
48
 
49
- <!-- What reviewers should check -->
49
+ <!-- 审查者应检查的内容 -->
50
50
 
51
- (To be filled by the team)
51
+ (待团队填写)
@@ -1,51 +1,51 @@
1
- # State Management
1
+ # 状态管理(State Management)
2
2
 
3
- > How state is managed in this project.
3
+ > 本项目如何管理状态。
4
4
 
5
5
  ---
6
6
 
7
- ## Overview
7
+ ## 概览(Overview)
8
8
 
9
9
  <!--
10
- Document your project's state management conventions here.
10
+ 在此记录项目的状态管理约定。
11
11
 
12
- Questions to answer:
13
- - What state management solution do you use?
14
- - How is local vs global state decided?
15
- - How do you handle server state?
16
- - What are the patterns for derived state?
12
+ 需要回答的问题:
13
+ - 使用什么状态管理方案?
14
+ - 如何决定使用本地状态还是全局状态?
15
+ - 如何处理服务端状态?
16
+ - 派生状态遵循哪些模式?
17
17
  -->
18
18
 
19
- (To be filled by the team)
19
+ (待团队填写)
20
20
 
21
21
  ---
22
22
 
23
- ## State Categories
23
+ ## 状态分类(State Categories)
24
24
 
25
- <!-- Local state, global state, server state, URL state -->
25
+ <!-- 本地状态、全局状态、服务端状态、URL 状态 -->
26
26
 
27
- (To be filled by the team)
27
+ (待团队填写)
28
28
 
29
29
  ---
30
30
 
31
- ## When to Use Global State
31
+ ## 何时使用全局状态(When to Use Global State)
32
32
 
33
- <!-- Criteria for promoting state to global -->
33
+ <!-- 将状态提升为全局状态的条件 -->
34
34
 
35
- (To be filled by the team)
35
+ (待团队填写)
36
36
 
37
37
  ---
38
38
 
39
- ## Server State
39
+ ## 服务端状态(Server State)
40
40
 
41
- <!-- How server data is cached and synchronized -->
41
+ <!-- 如何缓存和同步服务端数据 -->
42
42
 
43
- (To be filled by the team)
43
+ (待团队填写)
44
44
 
45
45
  ---
46
46
 
47
- ## Common Mistakes
47
+ ## 常见错误(Common Mistakes)
48
48
 
49
- <!-- State management mistakes your team has made -->
49
+ <!-- 团队曾经出现过的状态管理错误 -->
50
50
 
51
- (To be filled by the team)
51
+ (待团队填写)
@@ -1,51 +1,51 @@
1
- # Type Safety
1
+ # 类型安全(Type Safety)
2
2
 
3
- > Type safety patterns in this project.
3
+ > 本项目的类型安全模式。
4
4
 
5
5
  ---
6
6
 
7
- ## Overview
7
+ ## 概览(Overview)
8
8
 
9
9
  <!--
10
- Document your project's type safety conventions here.
10
+ 在此记录项目的类型安全约定。
11
11
 
12
- Questions to answer:
13
- - What type system do you use?
14
- - How are types organized?
15
- - What validation library do you use?
16
- - How do you handle type inference?
12
+ 需要回答的问题:
13
+ - 使用什么类型系统?
14
+ - 如何组织类型?
15
+ - 使用什么校验库?
16
+ - 如何处理类型推断?
17
17
  -->
18
18
 
19
- (To be filled by the team)
19
+ (待团队填写)
20
20
 
21
21
  ---
22
22
 
23
- ## Type Organization
23
+ ## 类型组织(Type Organization)
24
24
 
25
- <!-- Where types are defined, shared types vs local types -->
25
+ <!-- 类型定义位置,共享类型与局部类型的区别 -->
26
26
 
27
- (To be filled by the team)
27
+ (待团队填写)
28
28
 
29
29
  ---
30
30
 
31
- ## Validation
31
+ ## 校验(Validation)
32
32
 
33
- <!-- Runtime validation patterns (Zod, Yup, io-ts, etc.) -->
33
+ <!-- 运行时校验模式(Zod、Yup、io-ts 等) -->
34
34
 
35
- (To be filled by the team)
35
+ (待团队填写)
36
36
 
37
37
  ---
38
38
 
39
- ## Common Patterns
39
+ ## 常见模式(Common Patterns)
40
40
 
41
- <!-- Type utilities, generics, type guards -->
41
+ <!-- 类型工具、泛型和类型守卫 -->
42
42
 
43
- (To be filled by the team)
43
+ (待团队填写)
44
44
 
45
45
  ---
46
46
 
47
- ## Forbidden Patterns
47
+ ## 禁止模式(Forbidden Patterns)
48
48
 
49
- <!-- any, type assertions, etc. -->
49
+ <!-- any、类型断言等 -->
50
50
 
51
- (To be filled by the team)
51
+ (待团队填写)
@@ -1,23 +1,23 @@
1
- # Code Reuse Thinking Guide
1
+ # 代码复用思考指南(Code Reuse Thinking Guide)
2
2
 
3
- > **Purpose**: Stop and think before creating new code - does it already exist?
3
+ > **目的(Purpose)**:创建新代码前先停下来思考:它是否已经存在?
4
4
 
5
5
  ---
6
6
 
7
- ## The Problem
7
+ ## 问题(The Problem)
8
8
 
9
- **Duplicated code is the #1 source of inconsistency bugs.**
9
+ **重复代码是不一致错误的首要来源。**
10
10
 
11
- When you copy-paste or rewrite existing logic:
12
- - Bug fixes don't propagate
13
- - Behavior diverges over time
14
- - Codebase becomes harder to understand
11
+ 复制粘贴或重写已有逻辑会导致:
12
+ - 错误修复无法传播
13
+ - 行为随时间逐渐分化
14
+ - 代码库更难理解
15
15
 
16
16
  ---
17
17
 
18
- ## Before Writing New Code
18
+ ## 编写新代码前(Before Writing New Code)
19
19
 
20
- ### Step 1: Search First
20
+ ### 第一步:先搜索(Step 1: Search First)
21
21
 
22
22
  ```bash
23
23
  # Search for similar function names
@@ -27,50 +27,49 @@ grep -r "functionName" .
27
27
  grep -r "keyword" .
28
28
  ```
29
29
 
30
- ### Step 2: Ask These Questions
30
+ ### 第二步:回答这些问题(Step 2: Ask These Questions)
31
31
 
32
- | Question | If Yes... |
32
+ | 问题(Question) | 如果是……(If Yes...) |
33
33
  |----------|-----------|
34
- | Does a similar function exist? | Use or extend it |
35
- | Is this pattern used elsewhere? | Follow the existing pattern |
36
- | Could this be a shared utility? | Create it in the right place |
37
- | Am I copying code from another file? | **STOP** - extract to shared |
34
+ | 是否存在相似函数? | 使用或扩展它 |
35
+ | 其他地方是否使用了这种模式? | 遵循已有模式 |
36
+ | 它是否可以成为共享工具? | 在正确位置创建它 |
37
+ | 是否正在复制其他文件中的代码? | **停止**:提取为共享逻辑 |
38
38
 
39
39
  ---
40
40
 
41
- ## Common Duplication Patterns
41
+ ## 常见重复模式(Common Duplication Patterns)
42
42
 
43
- ### Pattern 1: Copy-Paste Functions
43
+ ### 模式一:复制粘贴函数(Pattern 1: Copy-Paste Functions)
44
44
 
45
- **Bad**: Copying a validation function to another file
45
+ **不佳**:将校验函数复制到另一个文件。
46
46
 
47
- **Good**: Extract to shared utilities, import where needed
47
+ **较好**:提取为共享工具,在需要的位置导入。
48
48
 
49
- ### Pattern 2: Similar Components
49
+ ### 模式二:相似组件(Pattern 2: Similar Components)
50
50
 
51
- **Bad**: Creating a new component that's 80% similar to existing
51
+ **不佳**:创建一个与现有组件有 80% 相似度的新组件。
52
52
 
53
- **Good**: Extend existing component with props/variants
53
+ **较好**:通过 props/变体扩展现有组件。
54
54
 
55
- ### Pattern 3: Repeated Constants
55
+ ### 模式三:重复常量(Pattern 3: Repeated Constants)
56
56
 
57
- **Bad**: Defining the same constant in multiple files
57
+ **不佳**:在多个文件中定义同一个常量。
58
58
 
59
- **Good**: Single source of truth, import everywhere
59
+ **较好**:保留唯一事实来源,在各处导入。
60
60
 
61
- ### Pattern 4: Repeated Payload Field Extraction
61
+ ### 模式四:重复提取载荷字段(Pattern 4: Repeated Payload Field Extraction)
62
62
 
63
- **Bad**: Multiple consumers cast the same JSON/event fields locally:
63
+ **错误示例(Bad)**:多个消费者各自在本地转换同一组 JSON/事件字段:
64
64
 
65
65
  ```typescript
66
66
  const description = (ev as { description?: string }).description;
67
67
  const context = (ev as { context?: ContextEntry[] }).context;
68
68
  ```
69
69
 
70
- This is duplicated contract logic even when the code is only two lines. Each
71
- consumer now has its own definition of what a valid payload means.
70
+ 即使只有两行代码,这也是重复的合同逻辑。此时每个消费者都有一份自己对“有效载荷”的定义。
72
71
 
73
- **Good**: Put the decoder, type guard, or projection next to the data owner:
72
+ **较好**:将解码器、类型守卫或投影放在数据 owner 旁边:
74
73
 
75
74
  ```typescript
76
75
  if (isThreadEvent(ev)) {
@@ -78,37 +77,35 @@ if (isThreadEvent(ev)) {
78
77
  }
79
78
  ```
80
79
 
81
- **Rule**: If the same untyped payload field is read in 2+ places, create a
82
- shared type guard / normalizer / projection before adding a third reader.
80
+ **规则**:如果同一个无类型载荷字段在两个或更多位置被读取,在增加第三个读取者前创建共享类型守卫、规范化器或投影。
83
81
 
84
82
  ---
85
83
 
86
- ## When to Abstract
84
+ ## 何时抽象(When to Abstract)
87
85
 
88
- **Abstract when**:
89
- - Same code appears 3+ times
90
- - Logic is complex enough to have bugs
91
- - Multiple people might need this
86
+ **在以下情况进行抽象**:
87
+ - 相同代码出现三次或更多
88
+ - 逻辑复杂到足以产生错误
89
+ - 多个人可能需要使用它
92
90
 
93
- **Don't abstract when**:
94
- - Only used once
95
- - Trivial one-liner
96
- - Abstraction would be more complex than duplication
91
+ **在以下情况不要抽象**:
92
+ - 只使用一次
93
+ - 只是简单的一行代码
94
+ - 抽象后的复杂度高于重复代码
97
95
 
98
96
  ---
99
97
 
100
- ## After Batch Modifications
98
+ ## 批量修改后(After Batch Modifications)
101
99
 
102
- When you've made similar changes to multiple files:
100
+ 对多个文件进行相似修改后:
103
101
 
104
- 1. **Review**: Did you catch all instances?
105
- 2. **Search**: Run grep to find any missed
106
- 3. **Consider**: Should this be abstracted?
102
+ 1. **复核**:是否覆盖了所有实例?
103
+ 2. **搜索**:运行 grep 查找遗漏
104
+ 3. **考虑**:是否应该进行抽象?
107
105
 
108
- ### Reducers Should Use Exhaustive Structure
106
+ ### Reducer 应使用穷举结构(Reducers Should Use Exhaustive Structure)
109
107
 
110
- When state is derived from action-like values (`action`, `kind`, `status`,
111
- `phase`), prefer a reducer with one `switch` over scattered `if/else` updates.
108
+ 当状态由类似 action 的值(`action`、`kind`、`status`、`phase`)派生时,优先使用一个 `switch` 的 reducer,而不是分散的 `if/else` 更新。
112
109
 
113
110
  ```typescript
114
111
  // BAD - action-specific state transitions are hard to audit
@@ -127,30 +124,28 @@ switch (event.action) {
127
124
  }
128
125
  ```
129
126
 
130
- This matters when the event log is the source of truth. A reducer is the
131
- documented replay model; display code and commands should not duplicate pieces
132
- of that replay model.
127
+ 当事件日志是事实来源时,这一点尤其重要。Reducer 是有文档记录的重放模型;展示代码和命令不应重复该重放模型的局部逻辑。
133
128
 
134
129
  ---
135
130
 
136
- ## Checklist Before Commit
131
+ ## 提交前清单(Checklist Before Commit)
137
132
 
138
- - [ ] Searched for existing similar code
139
- - [ ] No copy-pasted logic that should be shared
140
- - [ ] No repeated untyped payload field extraction outside a shared decoder
141
- - [ ] Constants defined in one place
142
- - [ ] Similar patterns follow same structure
143
- - [ ] Reducer/action transitions live in one reducer or command dispatcher
133
+ - [ ] 已搜索现有相似代码
134
+ - [ ] 没有应当共享却被复制粘贴的逻辑
135
+ - [ ] 共享解码器之外没有重复提取无类型载荷字段
136
+ - [ ] 常量只在一个位置定义
137
+ - [ ] 相似模式遵循相同结构
138
+ - [ ] Reducer/action 转换集中在一个 reducer 或命令分发器中
144
139
 
145
140
  ---
146
141
 
147
- ## Gotcha: Python if/elif/else Exhaustive Check
142
+ ## 注意:Python 的 if/elif/else 穷举检查(Gotcha: Python if/elif/else Exhaustive Check)
148
143
 
149
- **Problem**: Python's if/elif/else chains have no compile-time exhaustive check. When you add a new value to a `Literal` type (e.g., `Platform`), existing if/elif/else chains silently fall through to `else` with wrong defaults.
144
+ **问题**:Python 的 if/elif/else 链没有编译期穷举检查。向 `Literal` 类型(例如 `Platform`)增加新值时,已有 if/elif/else 链可能静默落入 `else`,使用错误的默认值。
150
145
 
151
- **Symptom**: New platform works partially — some methods return Claude defaults instead of platform-specific values. No error is raised.
146
+ **表现**:新平台只能部分工作,一些方法返回 Claude 默认值而不是平台专属值,并且不会抛出错误。
152
147
 
153
- **Example** (`cli_adapter.py`):
148
+ **示例**(`cli_adapter.py`):
154
149
  ```python
155
150
  # BAD: "gemini" falls through to else, returns "claude"
156
151
  @property
@@ -171,53 +166,53 @@ def cli_name(self) -> str:
171
166
  return "claude"
172
167
  ```
173
168
 
174
- **Prevention**: When adding a new value to a Python `Literal` type, search for ALL if/elif/else chains that switch on that type and add explicit branches. Don't rely on `else` being correct for new values.
169
+ **预防**:向 Python `Literal` 类型增加新值时,搜索所有基于该类型分支的 if/elif/else 链,并增加显式分支。不要假定 `else` 对新值仍然正确。
175
170
 
176
171
  ---
177
172
 
178
- ## Gotcha: Asymmetric Mechanisms Producing Same Output
173
+ ## 注意:产生相同输出的非对称机制(Gotcha: Asymmetric Mechanisms Producing Same Output)
179
174
 
180
- **Problem**: When two different mechanisms must produce the same file set (e.g., recursive directory copy for init vs. manual `files.set()` for update), structural changes (renaming, moving, adding subdirectories) only propagate through the automatic mechanism. The manual one silently drifts.
175
+ **问题**:当两个不同机制必须产生相同文件集合时(例如 init 的递归目录复制与 update 的手动 `files.set()`),结构变化(重命名、移动、增加子目录)只会通过自动机制传播,手动机制会静默漂移。
181
176
 
182
- **Symptom**: Init works perfectly, but update creates files at wrong paths or misses files entirely.
177
+ **表现**:init 完全正常,但 update 将文件创建到错误路径,或完全遗漏文件。
183
178
 
184
- **Prevention**:
185
- - **Best**: Eliminate the asymmetry — have the manual path call the automatic one (e.g., `collectTemplateFiles()` calls `getAllScripts()` instead of maintaining its own list)
186
- - **If asymmetry is unavoidable**: Add a regression test that compares outputs from both mechanisms
187
- - When migrating directory structures, search for ALL code paths that reference the old structure
179
+ **预防**:
180
+ - **最佳做法**:消除非对称性,让手动路径调用自动路径(例如让 `collectTemplateFiles()` 调用 `getAllScripts()`,而不是维护自己的列表)。
181
+ - **如果无法避免非对称性**:增加回归测试,比较两种机制的输出。
182
+ - 迁移目录结构时,搜索所有引用旧结构的代码路径。
188
183
 
189
- **Real example**: `trellis update` had a manual `files.set()` list for 11 scripts that `getAllScripts()` already tracked. Fix: replaced the manual list with a `for..of getAllScripts()` loop. See `update.ts` refactor in v0.4.0-beta.3.
184
+ **真实示例**:`trellis update` 曾为 11 个脚本维护手动 `files.set()` 列表,而 `getAllScripts()` 已经跟踪这些脚本。修复方式是用 `for..of getAllScripts()` 循环替换手动列表。参见 v0.4.0-beta.3 的 `update.ts` 重构。
190
185
 
191
186
  ---
192
187
 
193
- ## Template File Registration (Trellis-specific)
188
+ ## 模板文件登记(Trellis-specific)
194
189
 
195
- When adding new files to `src/templates/trellis/scripts/`:
190
+ 向 `src/templates/trellis/scripts/` 增加文件时:
196
191
 
197
- **Single registration point**: `src/templates/trellis/index.ts`
192
+ **唯一登记点**:`src/templates/trellis/index.ts`
198
193
 
199
- 1. Add `export const xxxScript = readTemplate("scripts/path/file.py");`
200
- 2. Add to `getAllScripts()` Map
194
+ 1. 增加 `export const xxxScript = readTemplate("scripts/path/file.py");`
195
+ 2. 加入 `getAllScripts()` Map。
201
196
 
202
- That's it. `commands/update.ts` uses `getAllScripts()` directly — no manual sync needed.
197
+ 完成这两步即可。`commands/update.ts` 直接使用 `getAllScripts()`,不需要手动同步列表。
203
198
 
204
- **Why this matters**: Without registration in `getAllScripts()`, `trellis update` won't sync the file to user projects. Bug fixes and features won't propagate.
199
+ **原因**:如果没有在 `getAllScripts()` 中登记,`trellis update` 就不会把文件同步到用户项目,错误修复和新功能也无法传播。
205
200
 
206
- **History**: Before v0.4.0-beta.3, `update.ts` had its own hand-maintained file list that frequently fell out of sync with `getAllScripts()`. This caused 11 Python files to be silently skipped during `trellis update`. The fix was to eliminate the duplicate list and use `getAllScripts()` as the single source of truth.
201
+ **历史**:在 v0.4.0-beta.3 之前,`update.ts` 有一份自己维护的文件列表,经常与 `getAllScripts()` 不同步,导致 `trellis update` 静默跳过 11 个 Python 文件。修复方式是删除重复列表,并将 `getAllScripts()` 作为唯一事实来源。
207
202
 
208
- ### Quick Checklist for New Scripts
203
+ ### 新增脚本快速清单(Quick Checklist for New Scripts)
209
204
 
210
205
  ```bash
211
206
  # After adding a new .py file, verify it's in getAllScripts():
212
207
  grep -l "newFileName" src/templates/trellis/index.ts # Should match
213
208
  ```
214
209
 
215
- ### Template Sync Convention
210
+ ### 模板同步约定(Template Sync Convention)
216
211
 
217
- `.trellis/scripts/` (dogfooded) and `packages/cli/src/templates/trellis/scripts/` (template) must stay identical. After editing `.trellis/scripts/`, always sync:
212
+ `.trellis/scripts/`(自用代码)与 `packages/cli/src/templates/trellis/scripts/`(模板)必须保持一致。编辑 `.trellis/scripts/` 后始终同步:
218
213
 
219
214
  ```bash
220
215
  rsync -av --delete --exclude='__pycache__' .trellis/scripts/ packages/cli/src/templates/trellis/scripts/
221
216
  ```
222
217
 
223
- **Gotcha**: Running rsync with wrong source/destination paths can create nested garbage directories (e.g., `.trellis/scripts/packages/cli/...`). Always double-check paths before running.
218
+ **注意**:使用错误的 rsync 源路径或目标路径可能创建嵌套的垃圾目录(例如 `.trellis/scripts/packages/cli/...`)。运行前始终复核路径。