@mindfoldhq/trellis 0.6.0-beta.2 → 0.6.0-beta.21

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 (331) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/index.d.ts +1 -1
  3. package/dist/cli/index.d.ts.map +1 -1
  4. package/dist/cli/index.js +58 -2
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/commands/channel/adapters/claude.d.ts +29 -0
  7. package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
  8. package/dist/commands/channel/adapters/claude.js +203 -0
  9. package/dist/commands/channel/adapters/claude.js.map +1 -0
  10. package/dist/commands/channel/adapters/codex.d.ts +85 -0
  11. package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
  12. package/dist/commands/channel/adapters/codex.js +505 -0
  13. package/dist/commands/channel/adapters/codex.js.map +1 -0
  14. package/dist/commands/channel/adapters/index.d.ts +84 -0
  15. package/dist/commands/channel/adapters/index.d.ts.map +1 -0
  16. package/dist/commands/channel/adapters/index.js +115 -0
  17. package/dist/commands/channel/adapters/index.js.map +1 -0
  18. package/dist/commands/channel/adapters/types.d.ts +33 -0
  19. package/dist/commands/channel/adapters/types.d.ts.map +1 -0
  20. package/dist/commands/channel/adapters/types.js +2 -0
  21. package/dist/commands/channel/adapters/types.js.map +1 -0
  22. package/dist/commands/channel/agent-loader.d.ts +32 -0
  23. package/dist/commands/channel/agent-loader.d.ts.map +1 -0
  24. package/dist/commands/channel/agent-loader.js +154 -0
  25. package/dist/commands/channel/agent-loader.js.map +1 -0
  26. package/dist/commands/channel/context-loader.d.ts +26 -0
  27. package/dist/commands/channel/context-loader.d.ts.map +1 -0
  28. package/dist/commands/channel/context-loader.js +290 -0
  29. package/dist/commands/channel/context-loader.js.map +1 -0
  30. package/dist/commands/channel/context.d.ts +16 -0
  31. package/dist/commands/channel/context.d.ts.map +1 -0
  32. package/dist/commands/channel/context.js +83 -0
  33. package/dist/commands/channel/context.js.map +1 -0
  34. package/dist/commands/channel/create.d.ts +27 -0
  35. package/dist/commands/channel/create.d.ts.map +1 -0
  36. package/dist/commands/channel/create.js +39 -0
  37. package/dist/commands/channel/create.js.map +1 -0
  38. package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
  39. package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
  40. package/dist/commands/channel/dev-parse-trace.js +70 -0
  41. package/dist/commands/channel/dev-parse-trace.js.map +1 -0
  42. package/dist/commands/channel/guard.d.ts +150 -0
  43. package/dist/commands/channel/guard.d.ts.map +1 -0
  44. package/dist/commands/channel/guard.js +474 -0
  45. package/dist/commands/channel/guard.js.map +1 -0
  46. package/dist/commands/channel/index.d.ts +3 -0
  47. package/dist/commands/channel/index.d.ts.map +1 -0
  48. package/dist/commands/channel/index.js +531 -0
  49. package/dist/commands/channel/index.js.map +1 -0
  50. package/dist/commands/channel/interrupt.d.ts +10 -0
  51. package/dist/commands/channel/interrupt.d.ts.map +1 -0
  52. package/dist/commands/channel/interrupt.js +22 -0
  53. package/dist/commands/channel/interrupt.js.map +1 -0
  54. package/dist/commands/channel/kill.d.ts +7 -0
  55. package/dist/commands/channel/kill.d.ts.map +1 -0
  56. package/dist/commands/channel/kill.js +121 -0
  57. package/dist/commands/channel/kill.js.map +1 -0
  58. package/dist/commands/channel/list.d.ts +17 -0
  59. package/dist/commands/channel/list.d.ts.map +1 -0
  60. package/dist/commands/channel/list.js +233 -0
  61. package/dist/commands/channel/list.js.map +1 -0
  62. package/dist/commands/channel/messages.d.ts +15 -0
  63. package/dist/commands/channel/messages.d.ts.map +1 -0
  64. package/dist/commands/channel/messages.js +245 -0
  65. package/dist/commands/channel/messages.js.map +1 -0
  66. package/dist/commands/channel/rm.d.ts +27 -0
  67. package/dist/commands/channel/rm.d.ts.map +1 -0
  68. package/dist/commands/channel/rm.js +216 -0
  69. package/dist/commands/channel/rm.js.map +1 -0
  70. package/dist/commands/channel/run.d.ts +30 -0
  71. package/dist/commands/channel/run.d.ts.map +1 -0
  72. package/dist/commands/channel/run.js +130 -0
  73. package/dist/commands/channel/run.js.map +1 -0
  74. package/dist/commands/channel/send.d.ts +11 -0
  75. package/dist/commands/channel/send.d.ts.map +1 -0
  76. package/dist/commands/channel/send.js +24 -0
  77. package/dist/commands/channel/send.js.map +1 -0
  78. package/dist/commands/channel/spawn.d.ts +40 -0
  79. package/dist/commands/channel/spawn.d.ts.map +1 -0
  80. package/dist/commands/channel/spawn.js +244 -0
  81. package/dist/commands/channel/spawn.js.map +1 -0
  82. package/dist/commands/channel/store/events.d.ts +39 -0
  83. package/dist/commands/channel/store/events.d.ts.map +1 -0
  84. package/dist/commands/channel/store/events.js +87 -0
  85. package/dist/commands/channel/store/events.js.map +1 -0
  86. package/dist/commands/channel/store/filter.d.ts +3 -0
  87. package/dist/commands/channel/store/filter.d.ts.map +1 -0
  88. package/dist/commands/channel/store/filter.js +2 -0
  89. package/dist/commands/channel/store/filter.js.map +1 -0
  90. package/dist/commands/channel/store/lock.d.ts +23 -0
  91. package/dist/commands/channel/store/lock.d.ts.map +1 -0
  92. package/dist/commands/channel/store/lock.js +99 -0
  93. package/dist/commands/channel/store/lock.js.map +1 -0
  94. package/dist/commands/channel/store/paths.d.ts +63 -0
  95. package/dist/commands/channel/store/paths.d.ts.map +1 -0
  96. package/dist/commands/channel/store/paths.js +246 -0
  97. package/dist/commands/channel/store/paths.js.map +1 -0
  98. package/dist/commands/channel/store/schema.d.ts +27 -0
  99. package/dist/commands/channel/store/schema.d.ts.map +1 -0
  100. package/dist/commands/channel/store/schema.js +34 -0
  101. package/dist/commands/channel/store/schema.js.map +1 -0
  102. package/dist/commands/channel/store/thread-state.d.ts +5 -0
  103. package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
  104. package/dist/commands/channel/store/thread-state.js +16 -0
  105. package/dist/commands/channel/store/thread-state.js.map +1 -0
  106. package/dist/commands/channel/store/watch.d.ts +19 -0
  107. package/dist/commands/channel/store/watch.d.ts.map +1 -0
  108. package/dist/commands/channel/store/watch.js +146 -0
  109. package/dist/commands/channel/store/watch.js.map +1 -0
  110. package/dist/commands/channel/supervisor/idle.d.ts +46 -0
  111. package/dist/commands/channel/supervisor/idle.d.ts.map +1 -0
  112. package/dist/commands/channel/supervisor/idle.js +72 -0
  113. package/dist/commands/channel/supervisor/idle.js.map +1 -0
  114. package/dist/commands/channel/supervisor/inbox.d.ts +30 -0
  115. package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
  116. package/dist/commands/channel/supervisor/inbox.js +160 -0
  117. package/dist/commands/channel/supervisor/inbox.js.map +1 -0
  118. package/dist/commands/channel/supervisor/shutdown.d.ts +68 -0
  119. package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
  120. package/dist/commands/channel/supervisor/shutdown.js +146 -0
  121. package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
  122. package/dist/commands/channel/supervisor/stdout.d.ts +51 -0
  123. package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
  124. package/dist/commands/channel/supervisor/stdout.js +121 -0
  125. package/dist/commands/channel/supervisor/stdout.js.map +1 -0
  126. package/dist/commands/channel/supervisor/turns.d.ts +31 -0
  127. package/dist/commands/channel/supervisor/turns.d.ts.map +1 -0
  128. package/dist/commands/channel/supervisor/turns.js +45 -0
  129. package/dist/commands/channel/supervisor/turns.js.map +1 -0
  130. package/dist/commands/channel/supervisor/warning.d.ts +48 -0
  131. package/dist/commands/channel/supervisor/warning.d.ts.map +1 -0
  132. package/dist/commands/channel/supervisor/warning.js +77 -0
  133. package/dist/commands/channel/supervisor/warning.js.map +1 -0
  134. package/dist/commands/channel/supervisor.d.ts +59 -0
  135. package/dist/commands/channel/supervisor.d.ts.map +1 -0
  136. package/dist/commands/channel/supervisor.js +344 -0
  137. package/dist/commands/channel/supervisor.js.map +1 -0
  138. package/dist/commands/channel/text-body.d.ts +13 -0
  139. package/dist/commands/channel/text-body.d.ts.map +1 -0
  140. package/dist/commands/channel/text-body.js +47 -0
  141. package/dist/commands/channel/text-body.js.map +1 -0
  142. package/dist/commands/channel/threads.d.ts +39 -0
  143. package/dist/commands/channel/threads.d.ts.map +1 -0
  144. package/dist/commands/channel/threads.js +106 -0
  145. package/dist/commands/channel/threads.js.map +1 -0
  146. package/dist/commands/channel/title.d.ts +12 -0
  147. package/dist/commands/channel/title.d.ts.map +1 -0
  148. package/dist/commands/channel/title.js +24 -0
  149. package/dist/commands/channel/title.js.map +1 -0
  150. package/dist/commands/channel/wait.d.ts +17 -0
  151. package/dist/commands/channel/wait.d.ts.map +1 -0
  152. package/dist/commands/channel/wait.js +75 -0
  153. package/dist/commands/channel/wait.js.map +1 -0
  154. package/dist/commands/init.d.ts +2 -0
  155. package/dist/commands/init.d.ts.map +1 -1
  156. package/dist/commands/init.js +97 -42
  157. package/dist/commands/init.js.map +1 -1
  158. package/dist/commands/mem.d.ts +13 -117
  159. package/dist/commands/mem.d.ts.map +1 -1
  160. package/dist/commands/mem.js +168 -1074
  161. package/dist/commands/mem.js.map +1 -1
  162. package/dist/commands/uninstall.d.ts.map +1 -1
  163. package/dist/commands/uninstall.js +28 -2
  164. package/dist/commands/uninstall.js.map +1 -1
  165. package/dist/commands/update.d.ts.map +1 -1
  166. package/dist/commands/update.js +31 -111
  167. package/dist/commands/update.js.map +1 -1
  168. package/dist/commands/upgrade.d.ts +28 -0
  169. package/dist/commands/upgrade.d.ts.map +1 -0
  170. package/dist/commands/upgrade.js +84 -0
  171. package/dist/commands/upgrade.js.map +1 -0
  172. package/dist/commands/workflow.d.ts +35 -0
  173. package/dist/commands/workflow.d.ts.map +1 -0
  174. package/dist/commands/workflow.js +219 -0
  175. package/dist/commands/workflow.js.map +1 -0
  176. package/dist/configurators/claude.d.ts.map +1 -1
  177. package/dist/configurators/claude.js +1 -0
  178. package/dist/configurators/claude.js.map +1 -1
  179. package/dist/configurators/codex.d.ts.map +1 -1
  180. package/dist/configurators/codex.js +5 -3
  181. package/dist/configurators/codex.js.map +1 -1
  182. package/dist/configurators/shared.js +4 -4
  183. package/dist/configurators/shared.js.map +1 -1
  184. package/dist/configurators/workflow.d.ts +8 -0
  185. package/dist/configurators/workflow.d.ts.map +1 -1
  186. package/dist/configurators/workflow.js +3 -2
  187. package/dist/configurators/workflow.js.map +1 -1
  188. package/dist/migrations/manifests/0.5.10.json +9 -0
  189. package/dist/migrations/manifests/0.5.11.json +16 -0
  190. package/dist/migrations/manifests/0.5.12.json +9 -0
  191. package/dist/migrations/manifests/0.5.13.json +9 -0
  192. package/dist/migrations/manifests/0.5.14.json +9 -0
  193. package/dist/migrations/manifests/0.5.15.json +9 -0
  194. package/dist/migrations/manifests/0.5.16.json +9 -0
  195. package/dist/migrations/manifests/0.5.17.json +9 -0
  196. package/dist/migrations/manifests/0.5.18.json +9 -0
  197. package/dist/migrations/manifests/0.6.0-beta.10.json +9 -0
  198. package/dist/migrations/manifests/0.6.0-beta.11.json +9 -0
  199. package/dist/migrations/manifests/0.6.0-beta.12.json +9 -0
  200. package/dist/migrations/manifests/0.6.0-beta.13.json +9 -0
  201. package/dist/migrations/manifests/0.6.0-beta.14.json +9 -0
  202. package/dist/migrations/manifests/0.6.0-beta.15.json +9 -0
  203. package/dist/migrations/manifests/0.6.0-beta.16.json +9 -0
  204. package/dist/migrations/manifests/0.6.0-beta.17.json +9 -0
  205. package/dist/migrations/manifests/0.6.0-beta.18.json +16 -0
  206. package/dist/migrations/manifests/0.6.0-beta.19.json +9 -0
  207. package/dist/migrations/manifests/0.6.0-beta.20.json +9 -0
  208. package/dist/migrations/manifests/0.6.0-beta.21.json +9 -0
  209. package/dist/migrations/manifests/0.6.0-beta.3.json +9 -0
  210. package/dist/migrations/manifests/0.6.0-beta.4.json +9 -0
  211. package/dist/migrations/manifests/0.6.0-beta.5.json +9 -0
  212. package/dist/migrations/manifests/0.6.0-beta.6.json +16 -0
  213. package/dist/migrations/manifests/0.6.0-beta.7.json +9 -0
  214. package/dist/migrations/manifests/0.6.0-beta.8.json +9 -0
  215. package/dist/migrations/manifests/0.6.0-beta.9.json +9 -0
  216. package/dist/templates/claude/agents/trellis-check.md +13 -7
  217. package/dist/templates/claude/agents/trellis-implement.md +8 -7
  218. package/dist/templates/claude/settings.json +4 -4
  219. package/dist/templates/codebuddy/agents/trellis-check.md +13 -7
  220. package/dist/templates/codebuddy/agents/trellis-implement.md +8 -7
  221. package/dist/templates/codebuddy/settings.json +4 -4
  222. package/dist/templates/codex/agents/trellis-check.toml +4 -4
  223. package/dist/templates/codex/agents/trellis-implement.toml +4 -4
  224. package/dist/templates/codex/config.toml +9 -16
  225. package/dist/templates/codex/hooks/session-start.py +205 -119
  226. package/dist/templates/codex/hooks.json +2 -2
  227. package/dist/templates/codex/skills/before-dev/SKILL.md +12 -6
  228. package/dist/templates/codex/skills/brainstorm/SKILL.md +69 -457
  229. package/dist/templates/codex/skills/check/SKILL.md +86 -18
  230. package/dist/templates/codex/skills/start/SKILL.md +33 -323
  231. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +7 -4
  232. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +1 -1
  233. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +3 -2
  234. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +5 -5
  235. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +1 -1
  236. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +35 -6
  237. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +5 -4
  238. package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/SKILL.md +41 -0
  239. package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/mcp-setup.md +90 -0
  240. package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/repository-analysis.md +59 -0
  241. package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/spec-task-planning.md +61 -0
  242. package/dist/templates/common/bundled-skills/trellis-spec-bootstarp/references/spec-writing.md +70 -0
  243. package/dist/templates/common/commands/continue.md +6 -5
  244. package/dist/templates/common/commands/start.md +9 -6
  245. package/dist/templates/common/skills/before-dev.md +12 -6
  246. package/dist/templates/common/skills/brainstorm.md +68 -504
  247. package/dist/templates/common/skills/check.md +7 -1
  248. package/dist/templates/copilot/hooks/session-start.py +219 -101
  249. package/dist/templates/copilot/hooks.json +2 -2
  250. package/dist/templates/copilot/prompts/before-dev.prompt.md +12 -6
  251. package/dist/templates/copilot/prompts/brainstorm.prompt.md +69 -457
  252. package/dist/templates/copilot/prompts/check.prompt.md +86 -18
  253. package/dist/templates/copilot/prompts/parallel.prompt.md +16 -8
  254. package/dist/templates/copilot/prompts/start.prompt.md +33 -367
  255. package/dist/templates/cursor/agents/trellis-check.md +13 -7
  256. package/dist/templates/cursor/agents/trellis-implement.md +8 -7
  257. package/dist/templates/cursor/hooks.json +1 -7
  258. package/dist/templates/droid/droids/trellis-check.md +13 -7
  259. package/dist/templates/droid/droids/trellis-implement.md +8 -7
  260. package/dist/templates/droid/settings.json +4 -4
  261. package/dist/templates/gemini/agents/trellis-check.md +11 -5
  262. package/dist/templates/gemini/agents/trellis-implement.md +7 -6
  263. package/dist/templates/gemini/settings.json +2 -2
  264. package/dist/templates/kiro/agents/trellis-check.json +1 -1
  265. package/dist/templates/kiro/agents/trellis-implement.json +1 -1
  266. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +127 -9
  267. package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +171 -6
  268. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +333 -43
  269. package/dist/templates/markdown/spec/guides/index.md.txt +18 -0
  270. package/dist/templates/opencode/agents/trellis-check.md +13 -7
  271. package/dist/templates/opencode/agents/trellis-implement.md +9 -8
  272. package/dist/templates/opencode/lib/session-utils.js +212 -123
  273. package/dist/templates/opencode/lib/trellis-context.js +73 -11
  274. package/dist/templates/opencode/plugins/inject-subagent-context.js +131 -29
  275. package/dist/templates/opencode/plugins/inject-workflow-state.js +9 -5
  276. package/dist/templates/opencode/plugins/session-start.js +9 -1
  277. package/dist/templates/pi/agents/trellis-check.md +5 -4
  278. package/dist/templates/pi/agents/trellis-implement.md +5 -4
  279. package/dist/templates/pi/extensions/trellis/index.ts.txt +1357 -754
  280. package/dist/templates/qoder/agents/trellis-check.md +11 -5
  281. package/dist/templates/qoder/agents/trellis-implement.md +7 -6
  282. package/dist/templates/qoder/settings.json +4 -4
  283. package/dist/templates/shared-hooks/index.d.ts.map +1 -1
  284. package/dist/templates/shared-hooks/index.js +0 -1
  285. package/dist/templates/shared-hooks/index.js.map +1 -1
  286. package/dist/templates/shared-hooks/inject-subagent-context.py +36 -14
  287. package/dist/templates/shared-hooks/inject-workflow-state.py +40 -42
  288. package/dist/templates/shared-hooks/session-start.py +222 -171
  289. package/dist/templates/trellis/config.yaml +38 -0
  290. package/dist/templates/trellis/index.d.ts +1 -0
  291. package/dist/templates/trellis/index.d.ts.map +1 -1
  292. package/dist/templates/trellis/index.js +2 -0
  293. package/dist/templates/trellis/index.js.map +1 -1
  294. package/dist/templates/trellis/scripts/add_session.py +50 -24
  295. package/dist/templates/trellis/scripts/common/config.py +57 -1
  296. package/dist/templates/trellis/scripts/common/safe_commit.py +285 -0
  297. package/dist/templates/trellis/scripts/common/session_context.py +384 -137
  298. package/dist/templates/trellis/scripts/common/task_context.py +3 -3
  299. package/dist/templates/trellis/scripts/common/task_store.py +161 -15
  300. package/dist/templates/trellis/scripts/common/workflow_phase.py +7 -10
  301. package/dist/templates/trellis/scripts/task.py +3 -3
  302. package/dist/templates/trellis/workflow.md +119 -98
  303. package/dist/utils/cwd-guard.d.ts +38 -0
  304. package/dist/utils/cwd-guard.d.ts.map +1 -0
  305. package/dist/utils/cwd-guard.js +62 -0
  306. package/dist/utils/cwd-guard.js.map +1 -0
  307. package/dist/utils/file-writer.d.ts +13 -0
  308. package/dist/utils/file-writer.d.ts.map +1 -1
  309. package/dist/utils/file-writer.js +59 -1
  310. package/dist/utils/file-writer.js.map +1 -1
  311. package/dist/utils/manifest-prune.d.ts +61 -0
  312. package/dist/utils/manifest-prune.d.ts.map +1 -0
  313. package/dist/utils/manifest-prune.js +136 -0
  314. package/dist/utils/manifest-prune.js.map +1 -0
  315. package/dist/utils/task-json.d.ts +9 -42
  316. package/dist/utils/task-json.d.ts.map +1 -1
  317. package/dist/utils/task-json.js +8 -45
  318. package/dist/utils/task-json.js.map +1 -1
  319. package/dist/utils/template-hash.d.ts +32 -6
  320. package/dist/utils/template-hash.d.ts.map +1 -1
  321. package/dist/utils/template-hash.js +53 -31
  322. package/dist/utils/template-hash.js.map +1 -1
  323. package/dist/utils/uninstall-scrubbers.d.ts +1 -0
  324. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -1
  325. package/dist/utils/uninstall-scrubbers.js +21 -0
  326. package/dist/utils/uninstall-scrubbers.js.map +1 -1
  327. package/dist/utils/workflow-resolver.d.ts +86 -0
  328. package/dist/utils/workflow-resolver.d.ts.map +1 -0
  329. package/dist/utils/workflow-resolver.js +265 -0
  330. package/dist/utils/workflow-resolver.js.map +1 -0
  331. package/package.json +9 -8
@@ -7,7 +7,7 @@
7
7
  {
8
8
  "type": "command",
9
9
  "command": "{{PYTHON_CMD}} .factory/hooks/session-start.py",
10
- "timeout": 10
10
+ "timeout": 30
11
11
  }
12
12
  ]
13
13
  },
@@ -17,7 +17,7 @@
17
17
  {
18
18
  "type": "command",
19
19
  "command": "{{PYTHON_CMD}} .factory/hooks/session-start.py",
20
- "timeout": 10
20
+ "timeout": 30
21
21
  }
22
22
  ]
23
23
  },
@@ -27,7 +27,7 @@
27
27
  {
28
28
  "type": "command",
29
29
  "command": "{{PYTHON_CMD}} .factory/hooks/session-start.py",
30
- "timeout": 10
30
+ "timeout": 30
31
31
  }
32
32
  ]
33
33
  }
@@ -50,7 +50,7 @@
50
50
  {
51
51
  "type": "command",
52
52
  "command": "{{PYTHON_CMD}} .factory/hooks/inject-workflow-state.py",
53
- "timeout": 5
53
+ "timeout": 15
54
54
  }
55
55
  ]
56
56
  }
@@ -19,14 +19,18 @@ You are already the `trellis-check` sub-agent that the main session dispatched.
19
19
 
20
20
  Before checking, read:
21
21
  - `.trellis/spec/` - Development guidelines
22
+ - Task `prd.md` - Requirements document
23
+ - Task `design.md` - Technical design (if exists)
24
+ - Task `implement.md` - Execution plan (if exists)
22
25
  - Pre-commit checklist for quality standards
23
26
 
24
27
  ## Core Responsibilities
25
28
 
26
29
  1. **Get code changes** - Use git diff to get uncommitted code
27
- 2. **Check against specs** - Verify code follows guidelines
28
- 3. **Self-fix** - Fix issues yourself, not just report them
29
- 4. **Run verification** - typecheck and lint
30
+ 2. **Review task artifacts** - Check changes against prd.md, design.md if present, and implement.md if present
31
+ 3. **Check against specs** - Verify code follows guidelines
32
+ 4. **Self-fix** - Fix issues yourself, not just report them
33
+ 5. **Run verification** - typecheck and lint
30
34
 
31
35
  ## Important
32
36
 
@@ -45,10 +49,12 @@ git diff --name-only # List changed files
45
49
  git diff # View specific changes
46
50
  ```
47
51
 
48
- ### Step 2: Check Against Specs
52
+ ### Step 2: Check Against Specs and Task Artifacts
49
53
 
50
- Read relevant specs in `.trellis/spec/` to check code:
54
+ Read the task's prd.md, design.md if present, and implement.md if present, then read relevant specs in `.trellis/spec/` to check code:
51
55
 
56
+ - Does it satisfy the task requirements
57
+ - Does it follow the technical design and implementation plan when present
52
58
  - Does it follow directory structure conventions
53
59
  - Does it follow naming conventions
54
60
  - Does it follow code patterns
@@ -21,13 +21,14 @@ Before implementing, read:
21
21
  - `.trellis/workflow.md` - Project workflow
22
22
  - `.trellis/spec/` - Development guidelines
23
23
  - Task `prd.md` - Requirements document
24
- - Task `info.md` - Technical design (if exists)
24
+ - Task `design.md` - Technical design (if exists)
25
+ - Task `implement.md` - Execution plan (if exists)
25
26
 
26
27
  ## Core Responsibilities
27
28
 
28
29
  1. **Understand specs** - Read relevant spec files in `.trellis/spec/`
29
- 2. **Understand requirements** - Read prd.md and info.md
30
- 3. **Implement features** - Write code following specs and design
30
+ 2. **Understand task artifacts** - Read prd.md, design.md if present, and implement.md if present
31
+ 3. **Implement features** - Write code following specs and task artifacts
31
32
  4. **Self-check** - Ensure code quality
32
33
  5. **Report results** - Report completion status
33
34
 
@@ -52,15 +53,15 @@ Read relevant specs based on task type:
52
53
 
53
54
  ### 2. Understand Requirements
54
55
 
55
- Read the task's prd.md and info.md:
56
+ Read the task's prd.md, design.md if present, and implement.md if present:
56
57
 
57
58
  - What are the core requirements
58
59
  - Key points of technical design
59
- - Which files to modify/create
60
+ - Implementation order, validation commands, and rollback points
60
61
 
61
62
  ### 3. Implement Features
62
63
 
63
- - Write code following specs and technical design
64
+ - Write code following specs and task artifacts
64
65
  - Follow existing code patterns
65
66
  - Only do what's required, no over-engineering
66
67
 
@@ -7,7 +7,7 @@
7
7
  {
8
8
  "type": "command",
9
9
  "command": "{{PYTHON_CMD}} .gemini/hooks/session-start.py",
10
- "timeout": 10000
10
+ "timeout": 30000
11
11
  }
12
12
  ]
13
13
  }
@@ -19,7 +19,7 @@
19
19
  {
20
20
  "type": "command",
21
21
  "command": "{{PYTHON_CMD}} .gemini/hooks/inject-workflow-state.py",
22
- "timeout": 5000
22
+ "timeout": 15000
23
23
  }
24
24
  ]
25
25
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trellis-check",
3
3
  "description": "Code quality check expert. Reviews code changes against specs and self-fixes issues.",
4
- "prompt": "# Check Agent\n\nYou are the Check Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.\n\n- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.\n- If SessionStart context, workflow-state breadcrumbs, or workflow.md say to dispatch `trellis-implement` / `trellis-check`, treat that as a main-session instruction that is already satisfied by your current role.\n- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.\n\n## Trellis Context Loading Protocol\n\nLook for the `<!-- trellis-hook-injected -->` marker in your input above.\n\n- **If the marker is present**: prd / spec / research files have already been auto-loaded for you above. Proceed with the check work directly.\n- **If the marker is absent**: hook injection didn't fire (Windows + Claude Code, `--continue` resume, fork distribution, hooks disabled, etc.). Find the active task path from your dispatch prompt's first line `Active task: <path>`, then Read `<task-path>/prd.md` and the spec files listed in `<task-path>/check.jsonl` yourself before doing the work.\n\n## Context\n\nBefore checking, read:\n- `.trellis/spec/` - Development guidelines\n- Pre-commit checklist for quality standards\n\n## Core Responsibilities\n\n1. **Get code changes** - Use git diff to get uncommitted code\n2. **Check against specs** - Verify code follows guidelines\n3. **Self-fix** - Fix issues yourself, not just report them\n4. **Run verification** - typecheck and lint\n\n## Important\n\n**Fix issues yourself**, don't just report them.\n\nYou have write and edit tools, you can modify code directly.\n\n---\n\n## Workflow\n\n### Step 1: Get Changes\n\n```bash\ngit diff --name-only # List changed files\ngit diff # View specific changes\n```\n\n### Step 2: Check Against Specs\n\nRead relevant specs in `.trellis/spec/` to check code:\n\n- Does it follow directory structure conventions\n- Does it follow naming conventions\n- Does it follow code patterns\n- Are there missing types\n- Are there potential bugs\n\n### Step 3: Self-Fix\n\nAfter finding issues:\n\n1. Fix the issue directly (use edit tool)\n2. Record what was fixed\n3. Continue checking other issues\n\n### Step 4: Run Verification\n\nRun project's lint and typecheck commands to verify changes.\n\nIf failed, fix issues and re-run.\n\n---\n\n## Report Format\n\n```markdown\n## Self-Check Complete\n\n### Files Checked\n\n- src/components/Feature.tsx\n- src/hooks/useFeature.ts\n\n### Issues Found and Fixed\n\n1. `<file>:<line>` - <what was fixed>\n2. `<file>:<line>` - <what was fixed>\n\n### Issues Not Fixed\n\n(If there are issues that cannot be self-fixed, list them here with reasons)\n\n### Verification Results\n\n- TypeCheck: Passed\n- Lint: Passed\n\n### Summary\n\nChecked X files, found Y issues, all fixed.\n```",
4
+ "prompt": "# Check Agent\n\nYou are the Check Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-check` sub-agent that the main session dispatched. Do the review and fixes directly.\n\n- Do NOT spawn another `trellis-check` or `trellis-implement` sub-agent.\n- If SessionStart context, workflow-state breadcrumbs, or workflow.md say to dispatch `trellis-implement` / `trellis-check`, treat that as a main-session instruction that is already satisfied by your current role.\n- Only the main session may dispatch Trellis implement/check agents. If more implementation work is needed, report that recommendation instead of spawning.\n\n## Trellis Context Loading Protocol\n\nLook for the `<!-- trellis-hook-injected -->` marker in your input above.\n\n- **If the marker is present**: task artifacts, spec, and research files have already been auto-loaded for you above. Proceed with the check work directly.\n- **If the marker is absent**: hook injection didn't fire (Windows + Claude Code, `--continue` resume, fork distribution, hooks disabled, etc.). Find the active task path from your dispatch prompt's first line `Active task: <path>`, then Read `<task-path>/check.jsonl`, each listed file, `<task-path>/prd.md`, `<task-path>/design.md` if present, and `<task-path>/implement.md` if present before doing the work.\n\n## Context\n\nBefore checking, read:\n- `.trellis/spec/` - Development guidelines\n- Task `prd.md` - Requirements document\n- Task `design.md` - Technical design (if exists)\n- Task `implement.md` - Execution plan (if exists)\n- Pre-commit checklist for quality standards\n\n## Core Responsibilities\n\n1. **Get code changes** - Use git diff to get uncommitted code\n2. **Review task artifacts** - Check changes against prd.md, design.md if present, and implement.md if present\n3. **Check against specs** - Verify code follows guidelines\n4. **Self-fix** - Fix issues yourself, not just report them\n5. **Run verification** - typecheck and lint\n\n## Important\n\n**Fix issues yourself**, don't just report them.\n\nYou have write and edit tools, you can modify code directly.\n\n---\n\n## Workflow\n\n### Step 1: Get Changes\n\n```bash\ngit diff --name-only # List changed files\ngit diff # View specific changes\n```\n\n### Step 2: Check Against Specs and Task Artifacts\n\nRead the task's prd.md, design.md if present, and implement.md if present, then read relevant specs in `.trellis/spec/` to check code:\n\n- Does it satisfy the task requirements\n- Does it follow the technical design and implementation plan when present\n- Does it follow directory structure conventions\n- Does it follow naming conventions\n- Does it follow code patterns\n- Are there missing types\n- Are there potential bugs\n\n### Step 3: Self-Fix\n\nAfter finding issues:\n\n1. Fix the issue directly (use edit tool)\n2. Record what was fixed\n3. Continue checking other issues\n\n### Step 4: Run Verification\n\nRun project's lint and typecheck commands to verify changes.\n\nIf failed, fix issues and re-run.\n\n---\n\n## Report Format\n\n```markdown\n## Self-Check Complete\n\n### Files Checked\n\n- src/components/Feature.tsx\n- src/hooks/useFeature.ts\n\n### Issues Found and Fixed\n\n1. `<file>:<line>` - <what was fixed>\n2. `<file>:<line>` - <what was fixed>\n\n### Issues Not Fixed\n\n(If there are issues that cannot be self-fixed, list them here with reasons)\n\n### Verification Results\n\n- TypeCheck: Passed\n- Lint: Passed\n\n### Summary\n\nChecked X files, found Y issues, all fixed.\n```",
5
5
  "tools": [
6
6
  "read",
7
7
  "write",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trellis-implement",
3
3
  "description": "Code implementation expert. Understands specs and requirements, then implements features. No git commit allowed.",
4
- "prompt": "# Implement Agent\n\nYou are the Implement Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.\n\n- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.\n- If SessionStart context, workflow-state breadcrumbs, or workflow.md say to dispatch `trellis-implement` / `trellis-check`, treat that as a main-session instruction that is already satisfied by your current role.\n- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.\n\n## Trellis Context Loading Protocol\n\nLook for the `<!-- trellis-hook-injected -->` marker in your input above.\n\n- **If the marker is present**: prd / spec / research files have already been auto-loaded for you above. Proceed with the implementation work directly.\n- **If the marker is absent**: hook injection didn't fire (Windows + Claude Code, `--continue` resume, fork distribution, hooks disabled, etc.). Find the active task path from your dispatch prompt's first line `Active task: <path>`, then Read `<task-path>/prd.md`, `<task-path>/info.md` (if it exists), and the spec files listed in `<task-path>/implement.jsonl` yourself before doing the work.\n\n## Context\n\nBefore implementing, read:\n- `.trellis/workflow.md` - Project workflow\n- `.trellis/spec/` - Development guidelines\n- Task `prd.md` - Requirements document\n- Task `info.md` - Technical design (if exists)\n\n## Core Responsibilities\n\n1. **Understand specs** - Read relevant spec files in `.trellis/spec/`\n2. **Understand requirements** - Read prd.md and info.md\n3. **Implement features** - Write code following specs and design\n4. **Self-check** - Ensure code quality\n5. **Report results** - Report completion status\n\n## Forbidden Operations\n\n**Do NOT execute these git commands:**\n\n- `git commit`\n- `git push`\n- `git merge`\n\n---\n\n## Workflow\n\n### 1. Understand Specs\n\nRead relevant specs based on task type:\n\n- Spec layers: `.trellis/spec/<package>/<layer>/`\n- Shared guides: `.trellis/spec/guides/`\n\n### 2. Understand Requirements\n\nRead the task's prd.md and info.md:\n\n- What are the core requirements\n- Key points of technical design\n- Which files to modify/create\n\n### 3. Implement Features\n\n- Write code following specs and technical design\n- Follow existing code patterns\n- Only do what's required, no over-engineering\n\n### 4. Verify\n\nRun project's lint and typecheck commands to verify changes.\n\n---\n\n## Report Format\n\n```markdown\n## Implementation Complete\n\n### Files Modified\n\n- `src/components/Feature.tsx` - New component\n- `src/hooks/useFeature.ts` - New hook\n\n### Implementation Summary\n\n1. Created Feature component...\n2. Added useFeature hook...\n\n### Verification Results\n\n- Lint: Passed\n- TypeCheck: Passed\n```\n\n---\n\n## Code Standards\n\n- Follow existing code patterns\n- Don't add unnecessary abstractions\n- Only do what's required, no over-engineering\n- Keep code readable",
4
+ "prompt": "# Implement Agent\n\nYou are the Implement Agent in the Trellis workflow.\n\n## Recursion Guard\n\nYou are already the `trellis-implement` sub-agent that the main session dispatched. Do the implementation work directly.\n\n- Do NOT spawn another `trellis-implement` or `trellis-check` sub-agent.\n- If SessionStart context, workflow-state breadcrumbs, or workflow.md say to dispatch `trellis-implement` / `trellis-check`, treat that as a main-session instruction that is already satisfied by your current role.\n- Only the main session may dispatch Trellis implement/check agents. If more parallel work is needed, report that recommendation instead of spawning.\n\n## Trellis Context Loading Protocol\n\nLook for the `<!-- trellis-hook-injected -->` marker in your input above.\n\n- **If the marker is present**: prd / spec / research files have already been auto-loaded for you above. Proceed with the implementation work directly.\n- **If the marker is absent**: hook injection didn't fire (Windows + Claude Code, `--continue` resume, fork distribution, hooks disabled, etc.). Find the active task path from your dispatch prompt's first line `Active task: <path>`, then Read `<task-path>/implement.jsonl`, each listed file, `<task-path>/prd.md`, `<task-path>/design.md` if present, and `<task-path>/implement.md` if present before doing the work.\n\n## Context\n\nBefore implementing, read:\n- `.trellis/workflow.md` - Project workflow\n- `.trellis/spec/` - Development guidelines\n- Task `prd.md` - Requirements document\n- Task `design.md` - Technical design (if exists)\n- Task `implement.md` - Execution plan (if exists)\n\n## Core Responsibilities\n\n1. **Understand specs** - Read relevant spec files in `.trellis/spec/`\n2. **Understand task artifacts** - Read prd.md, design.md if present, and implement.md if present\n3. **Implement features** - Write code following specs and task artifacts\n4. **Self-check** - Ensure code quality\n5. **Report results** - Report completion status\n\n## Forbidden Operations\n\n**Do NOT execute these git commands:**\n\n- `git commit`\n- `git push`\n- `git merge`\n\n---\n\n## Workflow\n\n### 1. Understand Specs\n\nRead relevant specs based on task type:\n\n- Spec layers: `.trellis/spec/<package>/<layer>/`\n- Shared guides: `.trellis/spec/guides/`\n\n### 2. Understand Requirements\n\nRead the task's prd.md, design.md if present, and implement.md if present:\n\n- What are the core requirements\n- Key points of technical design\n- Implementation order, validation commands, and rollback points\n\n### 3. Implement Features\n\n- Write code following specs and task artifacts\n- Follow existing code patterns\n- Only do what's required, no over-engineering\n\n### 4. Verify\n\nRun project's lint and typecheck commands to verify changes.\n\n---\n\n## Report Format\n\n```markdown\n## Implementation Complete\n\n### Files Modified\n\n- `src/components/Feature.tsx` - New component\n- `src/hooks/useFeature.ts` - New hook\n\n### Implementation Summary\n\n1. Created Feature component...\n2. Added useFeature hook...\n\n### Verification Results\n\n- Lint: Passed\n- TypeCheck: Passed\n```\n\n---\n\n## Code Standards\n\n- Follow existing code patterns\n- Don't add unnecessary abstractions\n- Only do what's required, no over-engineering\n- Keep code readable",
5
5
  "tools": [
6
6
  "read",
7
7
  "write",
@@ -58,6 +58,29 @@ grep -r "keyword" .
58
58
 
59
59
  **Good**: Single source of truth, import everywhere
60
60
 
61
+ ### Pattern 4: Repeated Payload Field Extraction
62
+
63
+ **Bad**: Multiple consumers cast the same JSON/event fields locally:
64
+
65
+ ```typescript
66
+ const description = (ev as { description?: string }).description;
67
+ const context = (ev as { context?: ContextEntry[] }).context;
68
+ ```
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.
72
+
73
+ **Good**: Put the decoder, type guard, or projection next to the data owner:
74
+
75
+ ```typescript
76
+ if (isThreadEvent(ev)) {
77
+ renderThreadEvent(ev);
78
+ }
79
+ ```
80
+
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.
83
+
61
84
  ---
62
85
 
63
86
  ## When to Abstract
@@ -82,6 +105,74 @@ When you've made similar changes to multiple files:
82
105
  2. **Search**: Run grep to find any missed
83
106
  3. **Consider**: Should this be abstracted?
84
107
 
108
+ ### Reducers Should Use Exhaustive Structure
109
+
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.
112
+
113
+ ```typescript
114
+ // BAD - action-specific state transitions are hard to audit
115
+ if (action === "opened") { ... }
116
+ else if (action === "comment") { ... }
117
+ else if (action === "status") { ... }
118
+
119
+ // GOOD - one reducer owns the transition table
120
+ switch (event.action) {
121
+ case "opened":
122
+ ...
123
+ return;
124
+ case "comment":
125
+ ...
126
+ return;
127
+ }
128
+ ```
129
+
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.
133
+
134
+ ---
135
+
136
+ ## Checklist Before Commit
137
+
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
144
+
145
+ ---
146
+
147
+ ## Gotcha: Python if/elif/else Exhaustive Check
148
+
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.
150
+
151
+ **Symptom**: New platform works partially — some methods return Claude defaults instead of platform-specific values. No error is raised.
152
+
153
+ **Example** (`cli_adapter.py`):
154
+ ```python
155
+ # BAD: "gemini" falls through to else, returns "claude"
156
+ @property
157
+ def cli_name(self) -> str:
158
+ if self.platform == "opencode":
159
+ return "opencode"
160
+ else:
161
+ return "claude" # gemini silently gets "claude"!
162
+
163
+ # GOOD: explicit branch for every platform
164
+ @property
165
+ def cli_name(self) -> str:
166
+ if self.platform == "opencode":
167
+ return "opencode"
168
+ elif self.platform == "gemini":
169
+ return "gemini"
170
+ else:
171
+ return "claude"
172
+ ```
173
+
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.
175
+
85
176
  ---
86
177
 
87
178
  ## Gotcha: Asymmetric Mechanisms Producing Same Output
@@ -90,16 +181,43 @@ When you've made similar changes to multiple files:
90
181
 
91
182
  **Symptom**: Init works perfectly, but update creates files at wrong paths or misses files entirely.
92
183
 
93
- **Prevention checklist**:
94
- - [ ] When migrating directory structures, search for ALL code paths that reference the old structure
95
- - [ ] If one path is auto-derived (glob/copy) and another is manually listed, the manual one needs updating
96
- - [ ] Add a regression test that compares outputs from both mechanisms
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
188
+
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.
97
190
 
98
191
  ---
99
192
 
100
- ## Checklist Before Commit
193
+ ## Template File Registration (Trellis-specific)
101
194
 
102
- - [ ] Searched for existing similar code
103
- - [ ] No copy-pasted logic that should be shared
104
- - [ ] Constants defined in one place
105
- - [ ] Similar patterns follow same structure
195
+ When adding new files to `src/templates/trellis/scripts/`:
196
+
197
+ **Single registration point**: `src/templates/trellis/index.ts`
198
+
199
+ 1. Add `export const xxxScript = readTemplate("scripts/path/file.py");`
200
+ 2. Add to `getAllScripts()` Map
201
+
202
+ That's it. `commands/update.ts` uses `getAllScripts()` directly — no manual sync needed.
203
+
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.
205
+
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.
207
+
208
+ ### Quick Checklist for New Scripts
209
+
210
+ ```bash
211
+ # After adding a new .py file, verify it's in getAllScripts():
212
+ grep -l "newFileName" src/templates/trellis/index.ts # Should match
213
+ ```
214
+
215
+ ### Template Sync Convention
216
+
217
+ `.trellis/scripts/` (dogfooded) and `packages/cli/src/templates/trellis/scripts/` (template) must stay identical. After editing `.trellis/scripts/`, always sync:
218
+
219
+ ```bash
220
+ rsync -av --delete --exclude='__pycache__' .trellis/scripts/ packages/cli/src/templates/trellis/scripts/
221
+ ```
222
+
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.
@@ -9,6 +9,7 @@
9
9
  **Most bugs happen at layer boundaries**, not within layers.
10
10
 
11
11
  Common cross-layer bugs:
12
+
12
13
  - API returns format A, frontend expects format B
13
14
  - Database stores X, service transforms to Y, but loses data
14
15
  - Multiple layers implement the same logic differently
@@ -26,22 +27,24 @@ Source → Transform → Store → Retrieve → Transform → Display
26
27
  ```
27
28
 
28
29
  For each arrow, ask:
30
+
29
31
  - What format is the data in?
30
32
  - What could go wrong?
31
33
  - Who is responsible for validation?
32
34
 
33
35
  ### Step 2: Identify Boundaries
34
36
 
35
- | Boundary | Common Issues |
36
- |----------|---------------|
37
- | API ↔ Service | Type mismatches, missing fields |
38
- | Service ↔ Database | Format conversions, null handling |
39
- | Backend ↔ Frontend | Serialization, date formats |
40
- | Component ↔ Component | Props shape changes |
37
+ | Boundary | Common Issues |
38
+ | --------------------- | --------------------------------- |
39
+ | API ↔ Service | Type mismatches, missing fields |
40
+ | Service ↔ Database | Format conversions, null handling |
41
+ | Backend ↔ Frontend | Serialization, date formats |
42
+ | Component ↔ Component | Props shape changes |
41
43
 
42
44
  ### Step 3: Define Contracts
43
45
 
44
46
  For each boundary:
47
+
45
48
  - What is the exact input format?
46
49
  - What is the exact output format?
47
50
  - What errors can occur?
@@ -68,27 +71,189 @@ For each boundary:
68
71
 
69
72
  **Good**: Each layer only knows its neighbors
70
73
 
74
+ ### Mistake 4: Every Consumer Parses The Same Payload
75
+
76
+ **Bad**: A command reads JSONL events and casts fields inline:
77
+
78
+ ```typescript
79
+ const thread = (ev as { thread?: string }).thread;
80
+ const labels = (ev as { labels?: string[] }).labels;
81
+ ```
82
+
83
+ This looks local, but it means every consumer owns a private version of the
84
+ event contract. The next field change will update one command and miss another.
85
+
86
+ **Good**: Decode once at the event boundary, then export typed projections:
87
+
88
+ ```typescript
89
+ if (!isThreadEvent(ev)) return false;
90
+ return ev.thread === filter.thread;
91
+ ```
92
+
93
+ **Rule**: For append-only logs, JSON streams, RPC payloads, or config files,
94
+ create one owner for:
95
+
96
+ - event / payload type definitions
97
+ - type guards and normalization from `unknown`
98
+ - metadata projections used by UI commands
99
+ - reducers that replay state from the source of truth
100
+
101
+ Rendering code may format fields, but it must not redefine the payload contract.
102
+
71
103
  ---
72
104
 
73
105
  ## Checklist for Cross-Layer Features
74
106
 
75
107
  Before implementation:
108
+
76
109
  - [ ] Mapped the complete data flow
77
110
  - [ ] Identified all layer boundaries
78
111
  - [ ] Defined format at each boundary
79
112
  - [ ] Decided where validation happens
80
113
 
81
114
  After implementation:
115
+
82
116
  - [ ] Tested with edge cases (null, empty, invalid)
83
117
  - [ ] Verified error handling at each boundary
84
118
  - [ ] Checked data survives round-trip
119
+ - [ ] Checked that consumers import shared decoders / projections instead of
120
+ casting payload fields locally
121
+ - [ ] Checked that derived state points back to the source event identifier
122
+ (`seq`, `id`, `version`) instead of inventing a second cursor
123
+
124
+ ---
125
+
126
+ ## Cross-Platform Template Consistency
127
+
128
+ In Trellis, command templates (e.g., `record-session.md`) exist in **multiple platforms** with identical or near-identical content. This is a cross-layer boundary.
129
+
130
+ ### Checklist: After Modifying Any Command Template
131
+
132
+ - [ ] Find all platforms with the same command: `find src/templates/*/commands/trellis/ -name "<command>.*"`
133
+ - [ ] Update all platform copies (Markdown `.md` and TOML `.toml`)
134
+ - [ ] For Gemini TOML: adapt line continuations (`\\` vs `\`) and triple-quoted strings
135
+ - [ ] Run `/trellis:check-cross-layer` to verify nothing was missed
136
+
137
+ **Real-world example**: Updated `record-session.md` in Claude to use `--mode record`, but forgot iFlow, Kilo, OpenCode, and Gemini — caught by cross-layer check.
138
+
139
+ ---
140
+
141
+ ## Generated Runtime Template Upgrade Consistency
142
+
143
+ Some generated files are both documentation and runtime input. In Trellis,
144
+ `.trellis/workflow.md` is parsed by `get_context.py`, `workflow_phase.py`,
145
+ SessionStart filters, and per-turn hooks. Template changes must be validated
146
+ against both fresh init and upgrade paths.
147
+
148
+ ### Checklist: After Modifying A Runtime-Parsed Template
149
+
150
+ - [ ] Identify every runtime parser that reads the template, not just the file
151
+ writer that installs it
152
+ - [ ] Check whether relevant syntax lives outside obvious managed regions
153
+ such as tag blocks
154
+ - [ ] Verify fresh `init` output and a versioned `update` scenario that writes
155
+ the older `.trellis/.version`
156
+ - [ ] Add an upgrade regression using an older pristine template fixture, then
157
+ assert the installed file reaches the current packaged shape
158
+ - [ ] Update the backend spec that owns the runtime contract
159
+
160
+ ---
161
+
162
+ ## Versioned Documentation Boundary
163
+
164
+ Versioned documentation is a cross-layer boundary: source paths, `docs.json`
165
+ version routing, and the rendered version selector must all describe the same
166
+ release line.
167
+
168
+ ### Checklist: Before Editing Versioned Docs
169
+
170
+ - [ ] Identify the target release line: stable, beta, or RC
171
+ - [ ] Verify the edited MDX path matches that line:
172
+ - stable: `docs-site/{start,advanced,...}` and `docs-site/zh/{start,advanced,...}`
173
+ - beta: `docs-site/beta/**` and `docs-site/zh/beta/**`
174
+ - RC: `docs-site/rc/**` and `docs-site/zh/rc/**`
175
+ - [ ] Verify `docs.json` navigation points the version label to the same paths
176
+ - [ ] Grep the opposite tree for release-line-specific terms before committing
177
+ - [ ] Treat beta content appearing under root release paths as a source-path bug,
178
+ not a rendering bug
179
+
180
+ **Real-world example**: A beta-only task workflow change documented
181
+ `prd.md` + `design.md` + `implement.md`, task-creation consent, and Codex
182
+ mode banners under root `start/` and `advanced/` paths. The docs site then
183
+ served 0.6 beta behavior under the Release selector. The fix was to restore root
184
+ release docs, move the 0.6 content to `beta/` and `zh/beta/`, and add a grep
185
+ audit for beta markers against the root release tree.
186
+
187
+ **Real-world example**: Codex inline mode changed workflow platform markers from
188
+ `[Codex]` / `[Kilo, Antigravity, Windsurf]` to `[codex-sub-agent]` /
189
+ `[codex-inline, Kilo, Antigravity, Windsurf]`. Fresh init was correct, but
190
+ `trellis update` only merged `[workflow-state:*]` blocks and preserved stale
191
+ markers outside those blocks. Result: upgraded projects got new hook scripts
192
+ but old workflow routing, so `get_context.py --mode phase --platform codex`
193
+ could return empty Phase 2.1 detail.
194
+
195
+ ---
196
+
197
+ ## Mode-Detection Probe Checklist
198
+
199
+ When a CLI auto-detects a mode by probing a remote resource (e.g., checking if `index.json` exists to decide marketplace vs direct download):
200
+
201
+ ### Before implementing:
202
+
203
+ - [ ] Probe runs in **ALL** code paths that use the result (interactive, `-y`, `--flag` combos)
204
+ - [ ] 404 vs transient error are distinguished — don't treat both as "not found"
205
+ - [ ] Transient errors **abort or retry**, never silently switch modes
206
+ - [ ] Shared state (caches, prefetched data) is **reset** when context changes (e.g., user switches source)
207
+ - [ ] **Shortcut paths** (e.g., `--template` skipping picker) must have the same error-handling quality as the probed path — check that downstream functions don't call catch-all wrappers
208
+
209
+ ### After implementing:
210
+
211
+ - [ ] Trace every path from probe result to the mode-decision branch — no fallthrough
212
+ - [ ] External format contracts (giget URI, raw URLs) are tested or at least documented as comments
213
+ - [ ] Metadata reads consume a complete response or use a streaming parser — never parse a fixed-size prefix as full JSON
214
+ - [ ] When reconstructing a composite identifier from parsed parts, verify **all** fields are included and in the **correct position** (e.g., `provider:repo/path#ref` not `provider:repo#ref/path`)
215
+ - [ ] Verify that **action functions** called after a shortcut don't internally use the old catch-all fetch — they must use the probe-quality variant when error distinction matters
216
+
217
+ **Real-world example**: Custom registry flow had 8 bugs across 3 review rounds: (1) probe only ran in interactive mode, (2) transient errors fell through to wrong mode, (3) giget URI had `#ref` in wrong position, (4) prefetched templates leaked across source switches, (5) `--template` shortcut bypassed probe but `downloadTemplateById` internally used catch-all `fetchTemplateIndex`, turning timeouts into "Template not found".
218
+
219
+ **Real-world example**: Agent-session update hints fetched npm `latest` metadata with `response.read(4096)` and then parsed it as complete JSON. The `@mindfoldhq/trellis` package metadata exceeded 4 KB, so the JSON was truncated, parse failed silently, and the first session injection showed no update hint. Fix: read the complete response before parsing, and add a regression where `version` is followed by an 8 KB metadata tail.
85
220
 
86
221
  ---
87
222
 
88
223
  ## When to Create Flow Documentation
89
224
 
90
225
  Create detailed flow docs when:
226
+
91
227
  - Feature spans 3+ layers
92
228
  - Multiple teams are involved
93
229
  - Data format is complex
94
230
  - Feature has caused bugs before
231
+
232
+ ---
233
+
234
+ ## Event Log / Projection Boundary
235
+
236
+ Append-only logs are cross-layer contracts. A single event travels through:
237
+
238
+ ```
239
+ CLI input → event writer → events.jsonl → reader → filter → reducer → display
240
+ ```
241
+
242
+ ### Checklist: After Adding A New Event Kind Or Field
243
+
244
+ - [ ] Add the event kind to the central event taxonomy
245
+ - [ ] Add a typed event variant or type guard at the event layer
246
+ - [ ] Add normalization helpers for array/object fields that come from
247
+ user input or JSON
248
+ - [ ] Keep `seq` / `id` assignment in the event writer only
249
+ - [ ] Make filters and reducers consume the typed event guard, not local casts
250
+ - [ ] Make display code consume reducer output or typed events, not raw JSON
251
+ - [ ] Add at least one regression that proves history replay and live filtering
252
+ use the same filter model
253
+
254
+ **Real-world example**: Thread channels added `kind: "thread"`, `description`,
255
+ `context`, labels, and `lastSeq`. The first implementation replayed thread
256
+ state correctly, but several commands still re-parsed event payload fields with
257
+ local casts. The fix was to make the core event layer own `ThreadChannelEvent`
258
+ and `isThreadEvent`, make `reduceChannelMetadata` the only channel metadata
259
+ projection, and make `reduceThreads` the only thread replay reducer.