@mindfoldhq/trellis 0.4.0-beta.1 → 0.4.0-beta.10

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 (200) hide show
  1. package/README.md +19 -5
  2. package/dist/cli/index.js +3 -0
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/init.d.ts +3 -0
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +48 -23
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/update.d.ts.map +1 -1
  9. package/dist/commands/update.js +52 -41
  10. package/dist/commands/update.js.map +1 -1
  11. package/dist/configurators/codebuddy.d.ts +11 -0
  12. package/dist/configurators/codebuddy.d.ts.map +1 -0
  13. package/dist/configurators/codebuddy.js +58 -0
  14. package/dist/configurators/codebuddy.js.map +1 -0
  15. package/dist/configurators/codex.d.ts +7 -4
  16. package/dist/configurators/codex.d.ts.map +1 -1
  17. package/dist/configurators/codex.js +40 -10
  18. package/dist/configurators/codex.js.map +1 -1
  19. package/dist/configurators/copilot.d.ts +9 -0
  20. package/dist/configurators/copilot.d.ts.map +1 -0
  21. package/dist/configurators/copilot.js +34 -0
  22. package/dist/configurators/copilot.js.map +1 -0
  23. package/dist/configurators/index.d.ts +11 -1
  24. package/dist/configurators/index.d.ts.map +1 -1
  25. package/dist/configurators/index.js +72 -4
  26. package/dist/configurators/index.js.map +1 -1
  27. package/dist/configurators/opencode.d.ts +1 -1
  28. package/dist/configurators/opencode.js +1 -1
  29. package/dist/configurators/windsurf.d.ts +8 -0
  30. package/dist/configurators/windsurf.d.ts.map +1 -0
  31. package/dist/configurators/windsurf.js +18 -0
  32. package/dist/configurators/windsurf.js.map +1 -0
  33. package/dist/configurators/workflow.d.ts +1 -1
  34. package/dist/configurators/workflow.d.ts.map +1 -1
  35. package/dist/configurators/workflow.js +4 -2
  36. package/dist/configurators/workflow.js.map +1 -1
  37. package/dist/migrations/manifests/0.3.10.json +9 -0
  38. package/dist/migrations/manifests/0.4.0-beta.10.json +9 -0
  39. package/dist/migrations/manifests/0.4.0-beta.2.json +9 -0
  40. package/dist/migrations/manifests/0.4.0-beta.3.json +9 -0
  41. package/dist/migrations/manifests/0.4.0-beta.4.json +9 -0
  42. package/dist/migrations/manifests/0.4.0-beta.5.json +9 -0
  43. package/dist/migrations/manifests/0.4.0-beta.6.json +9 -0
  44. package/dist/migrations/manifests/0.4.0-beta.7.json +9 -0
  45. package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
  46. package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
  47. package/dist/templates/claude/commands/trellis/record-session.md +3 -2
  48. package/dist/templates/claude/hooks/inject-subagent-context.py +8 -1
  49. package/dist/templates/claude/hooks/ralph-loop.py +18 -10
  50. package/dist/templates/claude/hooks/session-start.py +33 -9
  51. package/dist/templates/claude/hooks/statusline.py +211 -0
  52. package/dist/templates/claude/settings.json +4 -0
  53. package/dist/templates/codebuddy/commands/trellis/before-dev.md +29 -0
  54. package/dist/templates/codebuddy/commands/trellis/brainstorm.md +487 -0
  55. package/dist/templates/codebuddy/commands/trellis/break-loop.md +107 -0
  56. package/dist/templates/codebuddy/commands/trellis/check-cross-layer.md +153 -0
  57. package/dist/templates/codebuddy/commands/trellis/check.md +25 -0
  58. package/dist/templates/codebuddy/commands/trellis/create-command.md +154 -0
  59. package/dist/templates/codebuddy/commands/trellis/finish-work.md +143 -0
  60. package/dist/templates/codebuddy/commands/trellis/integrate-skill.md +219 -0
  61. package/dist/templates/codebuddy/commands/trellis/onboard.md +358 -0
  62. package/dist/templates/codebuddy/commands/trellis/record-session.md +61 -0
  63. package/dist/templates/codebuddy/commands/trellis/start.md +373 -0
  64. package/dist/templates/codebuddy/commands/trellis/update-spec.md +354 -0
  65. package/dist/templates/codebuddy/index.d.ts +25 -0
  66. package/dist/templates/codebuddy/index.d.ts.map +1 -0
  67. package/dist/templates/codebuddy/index.js +45 -0
  68. package/dist/templates/codebuddy/index.js.map +1 -0
  69. package/dist/templates/codex/agents/check.toml +23 -0
  70. package/dist/templates/codex/agents/implement.toml +19 -0
  71. package/dist/templates/codex/agents/research.toml +26 -0
  72. package/dist/templates/codex/codex-skills/parallel/SKILL.md +194 -0
  73. package/dist/templates/codex/config.toml +5 -0
  74. package/dist/templates/codex/hooks/session-start.py +228 -0
  75. package/dist/templates/codex/hooks.json +16 -0
  76. package/dist/templates/codex/index.d.ts +27 -5
  77. package/dist/templates/codex/index.d.ts.map +1 -1
  78. package/dist/templates/codex/index.js +60 -8
  79. package/dist/templates/codex/index.js.map +1 -1
  80. package/dist/templates/codex/skills/before-dev/SKILL.md +1 -1
  81. package/dist/templates/codex/skills/brainstorm/SKILL.md +1 -1
  82. package/dist/templates/codex/skills/break-loop/SKILL.md +1 -1
  83. package/dist/templates/codex/skills/check/SKILL.md +1 -1
  84. package/dist/templates/codex/skills/check-cross-layer/SKILL.md +1 -1
  85. package/dist/templates/codex/skills/create-command/SKILL.md +1 -1
  86. package/dist/templates/codex/skills/finish-work/SKILL.md +1 -1
  87. package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
  88. package/dist/templates/codex/skills/integrate-skill/SKILL.md +1 -1
  89. package/dist/templates/codex/skills/onboard/SKILL.md +1 -1
  90. package/dist/templates/codex/skills/record-session/SKILL.md +4 -3
  91. package/dist/templates/codex/skills/start/SKILL.md +1 -1
  92. package/dist/templates/codex/skills/update-spec/SKILL.md +1 -1
  93. package/dist/templates/copilot/hooks/session-start.py +218 -0
  94. package/dist/templates/copilot/hooks.json +11 -0
  95. package/dist/templates/copilot/index.d.ts +23 -0
  96. package/dist/templates/copilot/index.d.ts.map +1 -0
  97. package/dist/templates/copilot/index.js +54 -0
  98. package/dist/templates/copilot/index.js.map +1 -0
  99. package/dist/templates/copilot/prompts/before-dev.prompt.md +33 -0
  100. package/dist/templates/copilot/prompts/brainstorm.prompt.md +491 -0
  101. package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
  102. package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
  103. package/dist/templates/copilot/prompts/check.prompt.md +29 -0
  104. package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
  105. package/dist/templates/copilot/prompts/finish-work.prompt.md +157 -0
  106. package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
  107. package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
  108. package/dist/templates/copilot/prompts/parallel.prompt.md +196 -0
  109. package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
  110. package/dist/templates/copilot/prompts/start.prompt.md +397 -0
  111. package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
  112. package/dist/templates/cursor/commands/trellis-record-session.md +3 -2
  113. package/dist/templates/extract.d.ts +36 -0
  114. package/dist/templates/extract.d.ts.map +1 -1
  115. package/dist/templates/extract.js +64 -0
  116. package/dist/templates/extract.js.map +1 -1
  117. package/dist/templates/gemini/commands/trellis/record-session.toml +3 -2
  118. package/dist/templates/iflow/commands/trellis/record-session.md +3 -2
  119. package/dist/templates/iflow/hooks/inject-subagent-context.py +8 -1
  120. package/dist/templates/iflow/hooks/ralph-loop.py +8 -1
  121. package/dist/templates/iflow/hooks/session-start.py +33 -9
  122. package/dist/templates/kilo/workflows/record-session.md +3 -2
  123. package/dist/templates/kiro/skills/before-dev/SKILL.md +1 -1
  124. package/dist/templates/kiro/skills/brainstorm/SKILL.md +1 -1
  125. package/dist/templates/kiro/skills/break-loop/SKILL.md +1 -1
  126. package/dist/templates/kiro/skills/check/SKILL.md +1 -1
  127. package/dist/templates/kiro/skills/check-cross-layer/SKILL.md +1 -1
  128. package/dist/templates/kiro/skills/create-command/SKILL.md +1 -1
  129. package/dist/templates/kiro/skills/finish-work/SKILL.md +1 -1
  130. package/dist/templates/kiro/skills/integrate-skill/SKILL.md +1 -1
  131. package/dist/templates/kiro/skills/onboard/SKILL.md +1 -1
  132. package/dist/templates/kiro/skills/record-session/SKILL.md +4 -3
  133. package/dist/templates/kiro/skills/start/SKILL.md +1 -1
  134. package/dist/templates/kiro/skills/update-spec/SKILL.md +1 -1
  135. package/dist/templates/markdown/agents.md +4 -0
  136. package/dist/templates/markdown/spec/backend/directory-structure.md +1 -1
  137. package/dist/templates/markdown/workspace-index.md +2 -0
  138. package/dist/templates/opencode/agents/dispatch.md +20 -19
  139. package/dist/templates/opencode/commands/trellis/record-session.md +3 -2
  140. package/dist/templates/opencode/lib/trellis-context.js +42 -2
  141. package/dist/templates/opencode/{plugin → plugins}/session-start.js +7 -27
  142. package/dist/templates/qoder/skills/before-dev/SKILL.md +1 -1
  143. package/dist/templates/qoder/skills/brainstorm/SKILL.md +1 -1
  144. package/dist/templates/qoder/skills/break-loop/SKILL.md +1 -1
  145. package/dist/templates/qoder/skills/check/SKILL.md +1 -1
  146. package/dist/templates/qoder/skills/check-cross-layer/SKILL.md +1 -1
  147. package/dist/templates/qoder/skills/create-command/SKILL.md +1 -1
  148. package/dist/templates/qoder/skills/finish-work/SKILL.md +1 -1
  149. package/dist/templates/qoder/skills/integrate-skill/SKILL.md +1 -1
  150. package/dist/templates/qoder/skills/onboard/SKILL.md +1 -1
  151. package/dist/templates/qoder/skills/record-session/SKILL.md +4 -3
  152. package/dist/templates/qoder/skills/start/SKILL.md +1 -1
  153. package/dist/templates/qoder/skills/update-spec/SKILL.md +1 -1
  154. package/dist/templates/trellis/scripts/add_session.py +69 -16
  155. package/dist/templates/trellis/scripts/common/__init__.py +2 -0
  156. package/dist/templates/trellis/scripts/common/cli_adapter.py +133 -21
  157. package/dist/templates/trellis/scripts/common/config.py +40 -0
  158. package/dist/templates/trellis/scripts/common/developer.py +2 -2
  159. package/dist/templates/trellis/scripts/common/packages_context.py +9 -4
  160. package/dist/templates/trellis/scripts/common/paths.py +57 -6
  161. package/dist/templates/trellis/scripts/common/session_context.py +98 -2
  162. package/dist/templates/trellis/scripts/common/task_context.py +27 -1
  163. package/dist/templates/trellis/scripts/common/task_store.py +6 -4
  164. package/dist/templates/trellis/scripts/common/task_utils.py +14 -8
  165. package/dist/templates/trellis/scripts/create_bootstrap.py +1 -1
  166. package/dist/templates/trellis/scripts/multi_agent/plan.py +7 -6
  167. package/dist/templates/trellis/scripts/multi_agent/start.py +16 -11
  168. package/dist/templates/trellis/scripts/task.py +1 -1
  169. package/dist/templates/trellis/scripts-shell-archive/create-bootstrap.sh +1 -1
  170. package/dist/templates/trellis/workflow.md +17 -4
  171. package/dist/templates/windsurf/index.d.ts +21 -0
  172. package/dist/templates/windsurf/index.d.ts.map +1 -0
  173. package/dist/templates/windsurf/index.js +44 -0
  174. package/dist/templates/windsurf/index.js.map +1 -0
  175. package/dist/templates/windsurf/workflows/trellis-before-dev.md +31 -0
  176. package/dist/templates/windsurf/workflows/trellis-brainstorm.md +491 -0
  177. package/dist/templates/windsurf/workflows/trellis-break-loop.md +111 -0
  178. package/dist/templates/windsurf/workflows/trellis-check-cross-layer.md +157 -0
  179. package/dist/templates/windsurf/workflows/trellis-check.md +27 -0
  180. package/dist/templates/windsurf/workflows/trellis-create-command.md +154 -0
  181. package/dist/templates/windsurf/workflows/trellis-finish-work.md +147 -0
  182. package/dist/templates/windsurf/workflows/trellis-integrate-skill.md +220 -0
  183. package/dist/templates/windsurf/workflows/trellis-onboard.md +362 -0
  184. package/dist/templates/windsurf/workflows/trellis-record-session.md +66 -0
  185. package/dist/templates/windsurf/workflows/trellis-start.md +373 -0
  186. package/dist/templates/windsurf/workflows/trellis-update-spec.md +358 -0
  187. package/dist/types/ai-tools.d.ts +15 -3
  188. package/dist/types/ai-tools.d.ts.map +1 -1
  189. package/dist/types/ai-tools.js +42 -2
  190. package/dist/types/ai-tools.js.map +1 -1
  191. package/dist/utils/project-detector.d.ts +5 -0
  192. package/dist/utils/project-detector.d.ts.map +1 -1
  193. package/dist/utils/project-detector.js +7 -0
  194. package/dist/utils/project-detector.js.map +1 -1
  195. package/dist/utils/template-fetcher.d.ts +24 -3
  196. package/dist/utils/template-fetcher.d.ts.map +1 -1
  197. package/dist/utils/template-fetcher.js +129 -16
  198. package/dist/utils/template-fetcher.js.map +1 -1
  199. package/package.json +1 -1
  200. /package/dist/templates/opencode/{plugin → plugins}/inject-subagent-context.js +0 -0
@@ -0,0 +1,354 @@
1
+ # Update Code-Spec - Capture Executable Contracts
2
+
3
+ When you learn something valuable (from debugging, implementing, or discussion), use this command to update the relevant code-spec documents.
4
+
5
+ **Timing**: After completing a task, fixing a bug, or discovering a new pattern
6
+
7
+ ---
8
+
9
+ ## Code-Spec First Rule (CRITICAL)
10
+
11
+ In this project, "spec" for implementation work means **code-spec**:
12
+ - Executable contracts (not principle-only text)
13
+ - Concrete signatures, payload fields, env keys, and boundary behavior
14
+ - Testable validation/error behavior
15
+
16
+ If the change touches infra or cross-layer contracts, code-spec depth is mandatory.
17
+
18
+ ### Mandatory Triggers
19
+
20
+ Apply code-spec depth when the change includes any of:
21
+ - New/changed command or API signature
22
+ - Cross-layer request/response contract change
23
+ - Database schema/migration change
24
+ - Infra integration (storage, queue, cache, secrets, env wiring)
25
+
26
+ ### Mandatory Output (7 Sections)
27
+
28
+ For triggered tasks, include all sections below:
29
+ 1. Scope / Trigger
30
+ 2. Signatures (command/API/DB)
31
+ 3. Contracts (request/response/env)
32
+ 4. Validation & Error Matrix
33
+ 5. Good/Base/Bad Cases
34
+ 6. Tests Required (with assertion points)
35
+ 7. Wrong vs Correct (at least one pair)
36
+
37
+ ---
38
+
39
+ ## When to Update Code-Specs
40
+
41
+ | Trigger | Example | Target Spec |
42
+ |---------|---------|-------------|
43
+ | **Implemented a feature** | Added template download with giget | Relevant `backend/` or `frontend/` file |
44
+ | **Made a design decision** | Used type field + mapping table for extensibility | Relevant code-spec + "Design Decisions" section |
45
+ | **Fixed a bug** | Found a subtle issue with error handling | `backend/error-handling.md` |
46
+ | **Discovered a pattern** | Found a better way to structure code | Relevant `backend/` or `frontend/` file |
47
+ | **Hit a gotcha** | Learned that X must be done before Y | Relevant code-spec + "Common Mistakes" section |
48
+ | **Established a convention** | Team agreed on naming pattern | `quality-guidelines.md` |
49
+ | **New thinking trigger** | "Don't forget to check X before doing Y" | `guides/*.md` (as a checklist item, not detailed rules) |
50
+
51
+ **Key Insight**: Code-spec updates are NOT just for problems. Every feature implementation contains design decisions and contracts that future AI/developers need to execute safely.
52
+
53
+ ---
54
+
55
+ ## Spec Structure Overview
56
+
57
+ ```
58
+ .trellis/spec/
59
+ ├── backend/ # Backend coding standards
60
+ │ ├── index.md # Overview and links
61
+ │ └── *.md # Topic-specific guidelines
62
+ ├── frontend/ # Frontend coding standards
63
+ │ ├── index.md # Overview and links
64
+ │ └── *.md # Topic-specific guidelines
65
+ └── guides/ # Thinking checklists (NOT coding specs!)
66
+ ├── index.md # Guide index
67
+ └── *.md # Topic-specific guides
68
+ ```
69
+
70
+ ### CRITICAL: Code-Spec vs Guide - Know the Difference
71
+
72
+ | Type | Location | Purpose | Content Style |
73
+ |------|----------|---------|---------------|
74
+ | **Code-Spec** | `backend/*.md`, `frontend/*.md` | Tell AI "how to implement safely" | Signatures, contracts, matrices, cases, test points |
75
+ | **Guide** | `guides/*.md` | Help AI "what to think about" | Checklists, questions, pointers to specs |
76
+
77
+ **Decision Rule**: Ask yourself:
78
+
79
+ - "This is **how to write** the code" → Put in `backend/` or `frontend/`
80
+ - "This is **what to consider** before writing" → Put in `guides/`
81
+
82
+ **Example**:
83
+
84
+ | Learning | Wrong Location | Correct Location |
85
+ |----------|----------------|------------------|
86
+ | "Use `reconfigure()` not `TextIOWrapper` for Windows stdout" | ❌ `guides/cross-platform-thinking-guide.md` | ✅ `backend/script-conventions.md` |
87
+ | "Remember to check encoding when writing cross-platform code" | ❌ `backend/script-conventions.md` | ✅ `guides/cross-platform-thinking-guide.md` |
88
+
89
+ **Guides should be short checklists that point to specs**, not duplicate the detailed rules.
90
+
91
+ ---
92
+
93
+ ## Update Process
94
+
95
+ ### Step 1: Identify What You Learned
96
+
97
+ Answer these questions:
98
+
99
+ 1. **What did you learn?** (Be specific)
100
+ 2. **Why is it important?** (What problem does it prevent?)
101
+ 3. **Where does it belong?** (Which spec file?)
102
+
103
+ ### Step 2: Classify the Update Type
104
+
105
+ | Type | Description | Action |
106
+ |------|-------------|--------|
107
+ | **Design Decision** | Why we chose approach X over Y | Add to "Design Decisions" section |
108
+ | **Project Convention** | How we do X in this project | Add to relevant section with examples |
109
+ | **New Pattern** | A reusable approach discovered | Add to "Patterns" section |
110
+ | **Forbidden Pattern** | Something that causes problems | Add to "Anti-patterns" or "Don't" section |
111
+ | **Common Mistake** | Easy-to-make error | Add to "Common Mistakes" section |
112
+ | **Convention** | Agreed-upon standard | Add to relevant section |
113
+ | **Gotcha** | Non-obvious behavior | Add warning callout |
114
+
115
+ ### Step 3: Read the Target Code-Spec
116
+
117
+ Before editing, read the current code-spec to:
118
+ - Understand existing structure
119
+ - Avoid duplicating content
120
+ - Find the right section for your update
121
+
122
+ ```bash
123
+ cat .trellis/spec/<category>/<file>.md
124
+ ```
125
+
126
+ ### Step 4: Make the Update
127
+
128
+ Follow these principles:
129
+
130
+ 1. **Be Specific**: Include concrete examples, not just abstract rules
131
+ 2. **Explain Why**: State the problem this prevents
132
+ 3. **Show Contracts**: Add signatures, payload fields, and error behavior
133
+ 4. **Show Code**: Add code snippets for key patterns
134
+ 5. **Keep it Short**: One concept per section
135
+
136
+ ### Step 5: Update the Index (if needed)
137
+
138
+ If you added a new section or the code-spec status changed, update the category's `index.md`.
139
+
140
+ ---
141
+
142
+ ## Update Templates
143
+
144
+ ### Mandatory Template for Infra/Cross-Layer Work
145
+
146
+ ```markdown
147
+ ## Scenario: <name>
148
+
149
+ ### 1. Scope / Trigger
150
+ - Trigger: <why this requires code-spec depth>
151
+
152
+ ### 2. Signatures
153
+ - Backend command/API/DB signature(s)
154
+
155
+ ### 3. Contracts
156
+ - Request fields (name, type, constraints)
157
+ - Response fields (name, type, constraints)
158
+ - Environment keys (required/optional)
159
+
160
+ ### 4. Validation & Error Matrix
161
+ - <condition> -> <error>
162
+
163
+ ### 5. Good/Base/Bad Cases
164
+ - Good: ...
165
+ - Base: ...
166
+ - Bad: ...
167
+
168
+ ### 6. Tests Required
169
+ - Unit/Integration/E2E with assertion points
170
+
171
+ ### 7. Wrong vs Correct
172
+ #### Wrong
173
+ ...
174
+ #### Correct
175
+ ...
176
+ ```
177
+
178
+ ### Adding a Design Decision
179
+
180
+ ```markdown
181
+ ### Design Decision: [Decision Name]
182
+
183
+ **Context**: What problem were we solving?
184
+
185
+ **Options Considered**:
186
+ 1. Option A - brief description
187
+ 2. Option B - brief description
188
+
189
+ **Decision**: We chose Option X because...
190
+
191
+ **Example**:
192
+ \`\`\`typescript
193
+ // How it's implemented
194
+ code example
195
+ \`\`\`
196
+
197
+ **Extensibility**: How to extend this in the future...
198
+ ```
199
+
200
+ ### Adding a Project Convention
201
+
202
+ ```markdown
203
+ ### Convention: [Convention Name]
204
+
205
+ **What**: Brief description of the convention.
206
+
207
+ **Why**: Why we do it this way in this project.
208
+
209
+ **Example**:
210
+ \`\`\`typescript
211
+ // How to follow this convention
212
+ code example
213
+ \`\`\`
214
+
215
+ **Related**: Links to related conventions or specs.
216
+ ```
217
+
218
+ ### Adding a New Pattern
219
+
220
+ ```markdown
221
+ ### Pattern Name
222
+
223
+ **Problem**: What problem does this solve?
224
+
225
+ **Solution**: Brief description of the approach.
226
+
227
+ **Example**:
228
+ \`\`\`
229
+ // Good
230
+ code example
231
+
232
+ // Bad
233
+ code example
234
+ \`\`\`
235
+
236
+ **Why**: Explanation of why this works better.
237
+ ```
238
+
239
+ ### Adding a Forbidden Pattern
240
+
241
+ ```markdown
242
+ ### Don't: Pattern Name
243
+
244
+ **Problem**:
245
+ \`\`\`
246
+ // Don't do this
247
+ bad code example
248
+ \`\`\`
249
+
250
+ **Why it's bad**: Explanation of the issue.
251
+
252
+ **Instead**:
253
+ \`\`\`
254
+ // Do this instead
255
+ good code example
256
+ \`\`\`
257
+ ```
258
+
259
+ ### Adding a Common Mistake
260
+
261
+ ```markdown
262
+ ### Common Mistake: Description
263
+
264
+ **Symptom**: What goes wrong
265
+
266
+ **Cause**: Why this happens
267
+
268
+ **Fix**: How to correct it
269
+
270
+ **Prevention**: How to avoid it in the future
271
+ ```
272
+
273
+ ### Adding a Gotcha
274
+
275
+ ```markdown
276
+ > **Warning**: Brief description of the non-obvious behavior.
277
+ >
278
+ > Details about when this happens and how to handle it.
279
+ ```
280
+
281
+ ---
282
+
283
+ ## Interactive Mode
284
+
285
+ If you're unsure what to update, answer these prompts:
286
+
287
+ 1. **What did you just finish?**
288
+ - [ ] Fixed a bug
289
+ - [ ] Implemented a feature
290
+ - [ ] Refactored code
291
+ - [ ] Had a discussion about approach
292
+
293
+ 2. **What did you learn or decide?**
294
+ - Design decision (why X over Y)
295
+ - Project convention (how we do X)
296
+ - Non-obvious behavior (gotcha)
297
+ - Better approach (pattern)
298
+
299
+ 3. **Would future AI/developers need to know this?**
300
+ - To understand how the code works → Yes, update spec
301
+ - To maintain or extend the feature → Yes, update spec
302
+ - To avoid repeating mistakes → Yes, update spec
303
+ - Purely one-off implementation detail → Maybe skip
304
+
305
+ 4. **Which area does it relate to?**
306
+ - [ ] Backend code
307
+ - [ ] Frontend code
308
+ - [ ] Cross-layer data flow
309
+ - [ ] Code organization/reuse
310
+ - [ ] Quality/testing
311
+
312
+ ---
313
+
314
+ ## Quality Checklist
315
+
316
+ Before finishing your code-spec update:
317
+
318
+ - [ ] Is the content specific and actionable?
319
+ - [ ] Did you include a code example?
320
+ - [ ] Did you explain WHY, not just WHAT?
321
+ - [ ] Did you include executable signatures/contracts?
322
+ - [ ] Did you include validation and error matrix?
323
+ - [ ] Did you include Good/Base/Bad cases?
324
+ - [ ] Did you include required tests with assertion points?
325
+ - [ ] Is it in the right code-spec file?
326
+ - [ ] Does it duplicate existing content?
327
+ - [ ] Would a new team member understand it?
328
+
329
+ ---
330
+
331
+ ## Relationship to Other Commands
332
+
333
+ ```
334
+ Development Flow:
335
+ Learn something → /trellis:update-spec → Knowledge captured
336
+ ↑ ↓
337
+ /trellis:break-loop ←──────────────────── Future sessions benefit
338
+ (deep bug analysis)
339
+ ```
340
+
341
+ - `/trellis:break-loop` - Analyzes bugs deeply, often reveals spec updates needed
342
+ - `/trellis:update-spec` - Actually makes the updates (this command)
343
+ - `/trellis:finish-work` - Reminds you to check if specs need updates
344
+
345
+ ---
346
+
347
+ ## Core Philosophy
348
+
349
+ > **Code-specs are living documents. Every debugging session, every "aha moment" is an opportunity to make the implementation contract clearer.**
350
+
351
+ The goal is **institutional memory**:
352
+ - What one person learns, everyone benefits from
353
+ - What AI learns in one session, persists to future sessions
354
+ - Mistakes become documented guardrails
@@ -0,0 +1,25 @@
1
+ /**
2
+ * CodeBuddy templates
3
+ *
4
+ * These are GENERIC templates for user projects.
5
+ * Do NOT use Trellis project's own .codebuddy/ directory (which may be customized).
6
+ *
7
+ * Directory structure:
8
+ * codebuddy/
9
+ * └── commands/
10
+ * └── trellis/ # Nested subdirectory for namespace
11
+ * └── *.md
12
+ */
13
+ /**
14
+ * Command template with name and content
15
+ */
16
+ export interface CommandTemplate {
17
+ name: string;
18
+ content: string;
19
+ }
20
+ /**
21
+ * Get all command templates
22
+ * CodeBuddy uses nested directories: commands/trellis/<name>.md → /trellis:<name>
23
+ */
24
+ export declare function getAllCommands(): CommandTemplate[];
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/codebuddy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqBH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,eAAe,EAAE,CAalD"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * CodeBuddy templates
3
+ *
4
+ * These are GENERIC templates for user projects.
5
+ * Do NOT use Trellis project's own .codebuddy/ directory (which may be customized).
6
+ *
7
+ * Directory structure:
8
+ * codebuddy/
9
+ * └── commands/
10
+ * └── trellis/ # Nested subdirectory for namespace
11
+ * └── *.md
12
+ */
13
+ import { readdirSync, readFileSync } from "node:fs";
14
+ import { dirname, join } from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = dirname(__filename);
18
+ function readTemplate(relativePath) {
19
+ return readFileSync(join(__dirname, relativePath), "utf-8");
20
+ }
21
+ function listFiles(dir) {
22
+ try {
23
+ return readdirSync(join(__dirname, dir));
24
+ }
25
+ catch {
26
+ return [];
27
+ }
28
+ }
29
+ /**
30
+ * Get all command templates
31
+ * CodeBuddy uses nested directories: commands/trellis/<name>.md → /trellis:<name>
32
+ */
33
+ export function getAllCommands() {
34
+ const commands = [];
35
+ const files = listFiles("commands/trellis");
36
+ for (const file of files) {
37
+ if (file.endsWith(".md")) {
38
+ const name = file.replace(".md", "");
39
+ const content = readTemplate(`commands/trellis/${file}`);
40
+ commands.push({ name, content });
41
+ }
42
+ }
43
+ return commands;
44
+ }
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/codebuddy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,SAAS,YAAY,CAAC,YAAoB;IACxC,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAUD;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACrC,MAAM,OAAO,GAAG,YAAY,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;YACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,23 @@
1
+ name = "check"
2
+ description = "Read-only Trellis reviewer focused on correctness, missing tests, and spec drift."
3
+ sandbox_mode = "read-only"
4
+
5
+ developer_instructions = """
6
+ You are the Trellis reviewer agent.
7
+
8
+ Review checklist:
9
+ - Verify behavior against the actual code paths, not assumptions.
10
+ - Look for missing template/update/detection touch points when platform config changes.
11
+ - Check whether tests should be added or updated.
12
+ - Check whether `.trellis/spec/` docs need sync after implementation.
13
+ - Prefer concrete findings over speculative warnings.
14
+
15
+ Output format:
16
+ ## Findings
17
+ - Severity: <high|medium|low>
18
+ - File: <path>
19
+ - Issue: <what is wrong>
20
+ - Recommendation: <specific fix>
21
+
22
+ If no issues are found, say so explicitly.
23
+ """
@@ -0,0 +1,19 @@
1
+ name = "implement"
2
+ description = "Workspace-write Trellis implementer that follows specs and keeps generated templates in sync."
3
+ sandbox_mode = "workspace-write"
4
+
5
+ developer_instructions = """
6
+ You are the Trellis implementer agent.
7
+
8
+ Rules:
9
+ - Read before write. Follow `.trellis/spec/` guidance relevant to the task.
10
+ - Keep changes focused on the requested scope.
11
+ - When touching platform registries or template lists, search first so you do not miss mirrored update paths.
12
+ - If you modify `.trellis/scripts/`, keep `packages/cli/src/templates/trellis/scripts/` in sync.
13
+ - Do not make destructive git changes unless explicitly asked.
14
+
15
+ Before finishing, summarize:
16
+ - Files changed
17
+ - Tests/checks run
18
+ - Remaining risks or follow-ups
19
+ """
@@ -0,0 +1,26 @@
1
+ name = "research"
2
+ description = "Read-only Trellis researcher for specs, code patterns, and affected files."
3
+ sandbox_mode = "read-only"
4
+
5
+ developer_instructions = """
6
+ You are the Trellis researcher agent.
7
+
8
+ Responsibilities:
9
+ - Read `.trellis/workflow.md`, relevant `.trellis/spec/` files, and target code before proposing changes.
10
+ - Identify the smallest set of relevant specs, code patterns, and files to modify.
11
+ - Call out cross-layer or cross-platform risks when they are real.
12
+ - Do not edit files.
13
+
14
+ Output format:
15
+ ## Relevant Specs
16
+ - <path>: <why>
17
+
18
+ ## Code Patterns Found
19
+ - <pattern>: <file>
20
+
21
+ ## Files to Modify
22
+ - <path>: <change>
23
+
24
+ ## Risks / Follow-ups
25
+ - <none or concrete note>
26
+ """
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: parallel
3
+ description: "Multi-agent pipeline orchestrator that plans and dispatches parallel development tasks to worktree agents. Reads project context, configures task directories with PRDs and jsonl context files, and launches isolated coding agents. Use when multiple independent features need parallel development, orchestrating worktree agents, or managing multi-agent coding pipelines."
4
+ ---
5
+
6
+ # Multi-Agent Pipeline Orchestrator
7
+
8
+ You are the Multi-Agent Pipeline Orchestrator Agent, running in the main repository, responsible for collaborating with users to manage parallel development tasks.
9
+
10
+ ## Role Definition
11
+
12
+ - **You are in the main repository**, not in a worktree
13
+ - **You don't write code directly** - code work is done by agents in worktrees
14
+ - **You are responsible for planning and dispatching**: discuss requirements, create plans, configure context, start worktree agents
15
+ - **Delegate complex analysis to research**: find specs, inspect code structure, and reduce ambiguity before dispatch
16
+
17
+ ---
18
+
19
+ ## Operation Types
20
+
21
+ Operations in this document are categorized as:
22
+
23
+ | Marker | Meaning | Executor |
24
+ |--------|---------|----------|
25
+ | `[AI]` | Bash scripts or tool calls executed by AI | You (AI) |
26
+ | `[USER]` | Skills executed by user | User |
27
+
28
+ ---
29
+
30
+ ## Startup Flow
31
+
32
+ ### Step 1: Understand Trellis Workflow `[AI]`
33
+
34
+ First, read the workflow guide to understand the development process:
35
+
36
+ ```bash
37
+ cat .trellis/workflow.md # Development process, conventions, and quick start guide
38
+ ```
39
+
40
+ ### Step 2: Get Current Status `[AI]`
41
+
42
+ ```bash
43
+ python3 ./.trellis/scripts/get_context.py
44
+ ```
45
+
46
+ ### Step 3: Read Project Guidelines `[AI]`
47
+
48
+ ```bash
49
+ python3 ./.trellis/scripts/get_context.py --mode packages # Discover available spec layers
50
+ cat .trellis/spec/guides/index.md # Thinking guides
51
+ ```
52
+
53
+ ### Step 4: Ask User for Requirements
54
+
55
+ Ask the user:
56
+
57
+ 1. What feature to develop?
58
+ 2. Which modules are involved?
59
+ 3. Development type? (backend / frontend / fullstack)
60
+
61
+ ---
62
+
63
+ ## Planning: Choose Your Approach
64
+
65
+ Based on requirement complexity, choose one of these approaches:
66
+
67
+ ### Option A: Plan Agent (Recommended for complex features) `[AI]`
68
+
69
+ Use when:
70
+ - Requirements need analysis and validation
71
+ - Multiple modules or cross-layer changes
72
+ - Unclear scope that needs research
73
+
74
+ ```bash
75
+ python3 ./.trellis/scripts/multi_agent/plan.py \
76
+ --name "<feature-name>" \
77
+ --type "<backend|frontend|fullstack>" \
78
+ --requirement "<user requirement description>" \
79
+ --platform codex
80
+ ```
81
+
82
+ Plan Agent will:
83
+ 1. Evaluate requirement validity (may reject if unclear/too large)
84
+ 2. Analyze the codebase and specs
85
+ 3. Create and configure task directory
86
+ 4. Write `prd.md` with acceptance criteria
87
+ 5. Output a ready-to-use task directory
88
+
89
+ After `plan.py` completes, start the worktree agent:
90
+
91
+ ```bash
92
+ python3 ./.trellis/scripts/multi_agent/start.py "$TASK_DIR" --platform codex
93
+ ```
94
+
95
+ ### Option B: Manual Configuration (For simple or already-clear features) `[AI]`
96
+
97
+ Use when:
98
+ - Requirements are already clear and specific
99
+ - You know exactly which files are involved
100
+ - Simple, well-scoped changes
101
+
102
+ #### Step 1: Create Task Directory
103
+
104
+ ```bash
105
+ TASK_DIR=$(python3 ./.trellis/scripts/task.py create "<title>" --slug <task-name>)
106
+ ```
107
+
108
+ #### Step 2: Configure Task
109
+
110
+ ```bash
111
+ python3 ./.trellis/scripts/task.py init-context "$TASK_DIR" <dev_type>
112
+ python3 ./.trellis/scripts/task.py set-branch "$TASK_DIR" feature/<name>
113
+ python3 ./.trellis/scripts/task.py set-scope "$TASK_DIR" <scope>
114
+ ```
115
+
116
+ #### Step 3: Add Context
117
+
118
+ ```bash
119
+ python3 ./.trellis/scripts/task.py add-context "$TASK_DIR" implement "<path>" "<reason>"
120
+ python3 ./.trellis/scripts/task.py add-context "$TASK_DIR" check "<path>" "<reason>"
121
+ ```
122
+
123
+ #### Step 4: Create `prd.md`
124
+
125
+ ```bash
126
+ cat > "$TASK_DIR/prd.md" << 'END_PRD'
127
+ # Feature: <name>
128
+
129
+ ## Requirements
130
+ - ...
131
+
132
+ ## Acceptance Criteria
133
+ - ...
134
+ END_PRD
135
+ ```
136
+
137
+ #### Step 5: Validate and Start
138
+
139
+ ```bash
140
+ python3 ./.trellis/scripts/task.py validate "$TASK_DIR"
141
+ python3 ./.trellis/scripts/multi_agent/start.py "$TASK_DIR" --platform codex
142
+ ```
143
+
144
+ ---
145
+
146
+ ## After Starting: Report Status
147
+
148
+ Tell the user the agent has started and provide monitoring commands.
149
+
150
+ ---
151
+
152
+ ## User Available Skills `[USER]`
153
+
154
+ The following skills are for users (not AI):
155
+
156
+ | Skill | Description |
157
+ |-------|-------------|
158
+ | `$parallel` | Start Multi-Agent Pipeline (this skill) |
159
+ | `$start` | Start normal development mode (single process) |
160
+ | `$record-session` | Record session progress |
161
+ | `$finish-work` | Pre-completion checklist |
162
+
163
+ ---
164
+
165
+ ## Monitoring Commands (for user reference)
166
+
167
+ Tell the user they can use these commands to monitor:
168
+
169
+ ```bash
170
+ python3 ./.trellis/scripts/multi_agent/status.py # Overview
171
+ python3 ./.trellis/scripts/multi_agent/status.py --log <name> # View log
172
+ python3 ./.trellis/scripts/multi_agent/status.py --watch <name> # Real-time monitoring
173
+ python3 ./.trellis/scripts/multi_agent/cleanup.py <branch> # Cleanup worktree
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Pipeline Phases
179
+
180
+ The dispatch agent in the worktree will automatically execute:
181
+
182
+ 1. implement → Implement feature
183
+ 2. check → Check code quality
184
+ 3. finish → Final verification
185
+ 4. create-pr → Create PR
186
+
187
+ ---
188
+
189
+ ## Core Rules
190
+
191
+ - **Don't write code directly** - delegate to agents in worktrees
192
+ - **Don't execute git commit** - the flow handles it in the worktree pipeline
193
+ - **Delegate complex analysis before dispatch** - find specs, inspect code structure, and reduce ambiguity
194
+ - **Prefer focused tasks** - parallelism works best when each worktree has a narrow scope
@@ -0,0 +1,5 @@
1
+ # Project-scoped Codex defaults for Trellis workflows.
2
+ # Codex loads this after ~/.codex/config.toml when you work in this project.
3
+
4
+ # Keep AGENTS.md as the primary project instruction file.
5
+ project_doc_fallback_filenames = ["AGENTS.md"]