@blulotus/trellis 0.7.0

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 (821) hide show
  1. package/LICENSE +235 -0
  2. package/README.md +149 -0
  3. package/bin/trellis.js +3 -0
  4. package/dist/cli/index.d.ts +3 -0
  5. package/dist/cli/index.d.ts.map +1 -0
  6. package/dist/cli/index.js +276 -0
  7. package/dist/cli/index.js.map +1 -0
  8. package/dist/commands/channel/adapters/claude.d.ts +29 -0
  9. package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
  10. package/dist/commands/channel/adapters/claude.js +203 -0
  11. package/dist/commands/channel/adapters/claude.js.map +1 -0
  12. package/dist/commands/channel/adapters/codex.d.ts +93 -0
  13. package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
  14. package/dist/commands/channel/adapters/codex.js +573 -0
  15. package/dist/commands/channel/adapters/codex.js.map +1 -0
  16. package/dist/commands/channel/adapters/index.d.ts +86 -0
  17. package/dist/commands/channel/adapters/index.d.ts.map +1 -0
  18. package/dist/commands/channel/adapters/index.js +115 -0
  19. package/dist/commands/channel/adapters/index.js.map +1 -0
  20. package/dist/commands/channel/adapters/types.d.ts +33 -0
  21. package/dist/commands/channel/adapters/types.d.ts.map +1 -0
  22. package/dist/commands/channel/adapters/types.js +2 -0
  23. package/dist/commands/channel/adapters/types.js.map +1 -0
  24. package/dist/commands/channel/agent-loader.d.ts +32 -0
  25. package/dist/commands/channel/agent-loader.d.ts.map +1 -0
  26. package/dist/commands/channel/agent-loader.js +158 -0
  27. package/dist/commands/channel/agent-loader.js.map +1 -0
  28. package/dist/commands/channel/context-loader.d.ts +26 -0
  29. package/dist/commands/channel/context-loader.d.ts.map +1 -0
  30. package/dist/commands/channel/context-loader.js +311 -0
  31. package/dist/commands/channel/context-loader.js.map +1 -0
  32. package/dist/commands/channel/context-trust.d.ts +31 -0
  33. package/dist/commands/channel/context-trust.d.ts.map +1 -0
  34. package/dist/commands/channel/context-trust.js +139 -0
  35. package/dist/commands/channel/context-trust.js.map +1 -0
  36. package/dist/commands/channel/context.d.ts +16 -0
  37. package/dist/commands/channel/context.d.ts.map +1 -0
  38. package/dist/commands/channel/context.js +83 -0
  39. package/dist/commands/channel/context.js.map +1 -0
  40. package/dist/commands/channel/create.d.ts +27 -0
  41. package/dist/commands/channel/create.d.ts.map +1 -0
  42. package/dist/commands/channel/create.js +39 -0
  43. package/dist/commands/channel/create.js.map +1 -0
  44. package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
  45. package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
  46. package/dist/commands/channel/dev-parse-trace.js +70 -0
  47. package/dist/commands/channel/dev-parse-trace.js.map +1 -0
  48. package/dist/commands/channel/guard.d.ts +150 -0
  49. package/dist/commands/channel/guard.d.ts.map +1 -0
  50. package/dist/commands/channel/guard.js +479 -0
  51. package/dist/commands/channel/guard.js.map +1 -0
  52. package/dist/commands/channel/index.d.ts +3 -0
  53. package/dist/commands/channel/index.d.ts.map +1 -0
  54. package/dist/commands/channel/index.js +535 -0
  55. package/dist/commands/channel/index.js.map +1 -0
  56. package/dist/commands/channel/interrupt.d.ts +10 -0
  57. package/dist/commands/channel/interrupt.d.ts.map +1 -0
  58. package/dist/commands/channel/interrupt.js +22 -0
  59. package/dist/commands/channel/interrupt.js.map +1 -0
  60. package/dist/commands/channel/kill.d.ts +7 -0
  61. package/dist/commands/channel/kill.d.ts.map +1 -0
  62. package/dist/commands/channel/kill.js +121 -0
  63. package/dist/commands/channel/kill.js.map +1 -0
  64. package/dist/commands/channel/list.d.ts +17 -0
  65. package/dist/commands/channel/list.d.ts.map +1 -0
  66. package/dist/commands/channel/list.js +233 -0
  67. package/dist/commands/channel/list.js.map +1 -0
  68. package/dist/commands/channel/messages.d.ts +15 -0
  69. package/dist/commands/channel/messages.d.ts.map +1 -0
  70. package/dist/commands/channel/messages.js +245 -0
  71. package/dist/commands/channel/messages.js.map +1 -0
  72. package/dist/commands/channel/rm.d.ts +27 -0
  73. package/dist/commands/channel/rm.d.ts.map +1 -0
  74. package/dist/commands/channel/rm.js +216 -0
  75. package/dist/commands/channel/rm.js.map +1 -0
  76. package/dist/commands/channel/run.d.ts +30 -0
  77. package/dist/commands/channel/run.d.ts.map +1 -0
  78. package/dist/commands/channel/run.js +130 -0
  79. package/dist/commands/channel/run.js.map +1 -0
  80. package/dist/commands/channel/send.d.ts +11 -0
  81. package/dist/commands/channel/send.d.ts.map +1 -0
  82. package/dist/commands/channel/send.js +24 -0
  83. package/dist/commands/channel/send.js.map +1 -0
  84. package/dist/commands/channel/spawn.d.ts +43 -0
  85. package/dist/commands/channel/spawn.d.ts.map +1 -0
  86. package/dist/commands/channel/spawn.js +247 -0
  87. package/dist/commands/channel/spawn.js.map +1 -0
  88. package/dist/commands/channel/store/events.d.ts +39 -0
  89. package/dist/commands/channel/store/events.d.ts.map +1 -0
  90. package/dist/commands/channel/store/events.js +87 -0
  91. package/dist/commands/channel/store/events.js.map +1 -0
  92. package/dist/commands/channel/store/filter.d.ts +3 -0
  93. package/dist/commands/channel/store/filter.d.ts.map +1 -0
  94. package/dist/commands/channel/store/filter.js +2 -0
  95. package/dist/commands/channel/store/filter.js.map +1 -0
  96. package/dist/commands/channel/store/lock.d.ts +23 -0
  97. package/dist/commands/channel/store/lock.d.ts.map +1 -0
  98. package/dist/commands/channel/store/lock.js +99 -0
  99. package/dist/commands/channel/store/lock.js.map +1 -0
  100. package/dist/commands/channel/store/paths.d.ts +77 -0
  101. package/dist/commands/channel/store/paths.d.ts.map +1 -0
  102. package/dist/commands/channel/store/paths.js +272 -0
  103. package/dist/commands/channel/store/paths.js.map +1 -0
  104. package/dist/commands/channel/store/schema.d.ts +27 -0
  105. package/dist/commands/channel/store/schema.d.ts.map +1 -0
  106. package/dist/commands/channel/store/schema.js +34 -0
  107. package/dist/commands/channel/store/schema.js.map +1 -0
  108. package/dist/commands/channel/store/thread-state.d.ts +5 -0
  109. package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
  110. package/dist/commands/channel/store/thread-state.js +16 -0
  111. package/dist/commands/channel/store/thread-state.js.map +1 -0
  112. package/dist/commands/channel/store/watch.d.ts +19 -0
  113. package/dist/commands/channel/store/watch.d.ts.map +1 -0
  114. package/dist/commands/channel/store/watch.js +146 -0
  115. package/dist/commands/channel/store/watch.js.map +1 -0
  116. package/dist/commands/channel/supervisor/idle.d.ts +45 -0
  117. package/dist/commands/channel/supervisor/idle.d.ts.map +1 -0
  118. package/dist/commands/channel/supervisor/idle.js +70 -0
  119. package/dist/commands/channel/supervisor/idle.js.map +1 -0
  120. package/dist/commands/channel/supervisor/inbox.d.ts +30 -0
  121. package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
  122. package/dist/commands/channel/supervisor/inbox.js +160 -0
  123. package/dist/commands/channel/supervisor/inbox.js.map +1 -0
  124. package/dist/commands/channel/supervisor/shutdown.d.ts +68 -0
  125. package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
  126. package/dist/commands/channel/supervisor/shutdown.js +146 -0
  127. package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
  128. package/dist/commands/channel/supervisor/stdout.d.ts +53 -0
  129. package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
  130. package/dist/commands/channel/supervisor/stdout.js +168 -0
  131. package/dist/commands/channel/supervisor/stdout.js.map +1 -0
  132. package/dist/commands/channel/supervisor/turns.d.ts +31 -0
  133. package/dist/commands/channel/supervisor/turns.d.ts.map +1 -0
  134. package/dist/commands/channel/supervisor/turns.js +45 -0
  135. package/dist/commands/channel/supervisor/turns.js.map +1 -0
  136. package/dist/commands/channel/supervisor/warning.d.ts +48 -0
  137. package/dist/commands/channel/supervisor/warning.d.ts.map +1 -0
  138. package/dist/commands/channel/supervisor/warning.js +77 -0
  139. package/dist/commands/channel/supervisor/warning.js.map +1 -0
  140. package/dist/commands/channel/supervisor.d.ts +75 -0
  141. package/dist/commands/channel/supervisor.d.ts.map +1 -0
  142. package/dist/commands/channel/supervisor.js +397 -0
  143. package/dist/commands/channel/supervisor.js.map +1 -0
  144. package/dist/commands/channel/text-body.d.ts +13 -0
  145. package/dist/commands/channel/text-body.d.ts.map +1 -0
  146. package/dist/commands/channel/text-body.js +47 -0
  147. package/dist/commands/channel/text-body.js.map +1 -0
  148. package/dist/commands/channel/threads.d.ts +39 -0
  149. package/dist/commands/channel/threads.d.ts.map +1 -0
  150. package/dist/commands/channel/threads.js +106 -0
  151. package/dist/commands/channel/threads.js.map +1 -0
  152. package/dist/commands/channel/title.d.ts +12 -0
  153. package/dist/commands/channel/title.d.ts.map +1 -0
  154. package/dist/commands/channel/title.js +24 -0
  155. package/dist/commands/channel/title.js.map +1 -0
  156. package/dist/commands/channel/wait.d.ts +17 -0
  157. package/dist/commands/channel/wait.d.ts.map +1 -0
  158. package/dist/commands/channel/wait.js +75 -0
  159. package/dist/commands/channel/wait.js.map +1 -0
  160. package/dist/commands/init.d.ts +71 -0
  161. package/dist/commands/init.d.ts.map +1 -0
  162. package/dist/commands/init.js +1603 -0
  163. package/dist/commands/init.js.map +1 -0
  164. package/dist/commands/mem.d.ts +30 -0
  165. package/dist/commands/mem.d.ts.map +1 -0
  166. package/dist/commands/mem.js +447 -0
  167. package/dist/commands/mem.js.map +1 -0
  168. package/dist/commands/uninstall.d.ts +36 -0
  169. package/dist/commands/uninstall.d.ts.map +1 -0
  170. package/dist/commands/uninstall.js +410 -0
  171. package/dist/commands/uninstall.js.map +1 -0
  172. package/dist/commands/update.d.ts +111 -0
  173. package/dist/commands/update.d.ts.map +1 -0
  174. package/dist/commands/update.js +2152 -0
  175. package/dist/commands/update.js.map +1 -0
  176. package/dist/commands/upgrade.d.ts +28 -0
  177. package/dist/commands/upgrade.d.ts.map +1 -0
  178. package/dist/commands/upgrade.js +84 -0
  179. package/dist/commands/upgrade.js.map +1 -0
  180. package/dist/commands/workflow.d.ts +52 -0
  181. package/dist/commands/workflow.d.ts.map +1 -0
  182. package/dist/commands/workflow.js +454 -0
  183. package/dist/commands/workflow.js.map +1 -0
  184. package/dist/configurators/antigravity.d.ts +7 -0
  185. package/dist/configurators/antigravity.d.ts.map +1 -0
  186. package/dist/configurators/antigravity.js +11 -0
  187. package/dist/configurators/antigravity.js.map +1 -0
  188. package/dist/configurators/claude.d.ts +23 -0
  189. package/dist/configurators/claude.d.ts.map +1 -0
  190. package/dist/configurators/claude.js +123 -0
  191. package/dist/configurators/claude.js.map +1 -0
  192. package/dist/configurators/codebuddy.d.ts +10 -0
  193. package/dist/configurators/codebuddy.d.ts.map +1 -0
  194. package/dist/configurators/codebuddy.js +24 -0
  195. package/dist/configurators/codebuddy.js.map +1 -0
  196. package/dist/configurators/codex.d.ts +57 -0
  197. package/dist/configurators/codex.d.ts.map +1 -0
  198. package/dist/configurators/codex.js +170 -0
  199. package/dist/configurators/codex.js.map +1 -0
  200. package/dist/configurators/copilot.d.ts +14 -0
  201. package/dist/configurators/copilot.d.ts.map +1 -0
  202. package/dist/configurators/copilot.js +46 -0
  203. package/dist/configurators/copilot.js.map +1 -0
  204. package/dist/configurators/cursor.d.ts +10 -0
  205. package/dist/configurators/cursor.d.ts.map +1 -0
  206. package/dist/configurators/cursor.js +23 -0
  207. package/dist/configurators/cursor.js.map +1 -0
  208. package/dist/configurators/devin.d.ts +8 -0
  209. package/dist/configurators/devin.d.ts.map +1 -0
  210. package/dist/configurators/devin.js +12 -0
  211. package/dist/configurators/devin.js.map +1 -0
  212. package/dist/configurators/droid.d.ts +10 -0
  213. package/dist/configurators/droid.d.ts.map +1 -0
  214. package/dist/configurators/droid.js +24 -0
  215. package/dist/configurators/droid.js.map +1 -0
  216. package/dist/configurators/dsh.d.ts +26 -0
  217. package/dist/configurators/dsh.d.ts.map +1 -0
  218. package/dist/configurators/dsh.js +76 -0
  219. package/dist/configurators/dsh.js.map +1 -0
  220. package/dist/configurators/gemini.d.ts +18 -0
  221. package/dist/configurators/gemini.d.ts.map +1 -0
  222. package/dist/configurators/gemini.js +39 -0
  223. package/dist/configurators/gemini.js.map +1 -0
  224. package/dist/configurators/grok.d.ts +17 -0
  225. package/dist/configurators/grok.d.ts.map +1 -0
  226. package/dist/configurators/grok.js +38 -0
  227. package/dist/configurators/grok.js.map +1 -0
  228. package/dist/configurators/index.d.ts +68 -0
  229. package/dist/configurators/index.d.ts.map +1 -0
  230. package/dist/configurators/index.js +191 -0
  231. package/dist/configurators/index.js.map +1 -0
  232. package/dist/configurators/kilo.d.ts +7 -0
  233. package/dist/configurators/kilo.d.ts.map +1 -0
  234. package/dist/configurators/kilo.js +11 -0
  235. package/dist/configurators/kilo.js.map +1 -0
  236. package/dist/configurators/kimi.d.ts +26 -0
  237. package/dist/configurators/kimi.d.ts.map +1 -0
  238. package/dist/configurators/kimi.js +74 -0
  239. package/dist/configurators/kimi.js.map +1 -0
  240. package/dist/configurators/kiro.d.ts +11 -0
  241. package/dist/configurators/kiro.d.ts.map +1 -0
  242. package/dist/configurators/kiro.js +30 -0
  243. package/dist/configurators/kiro.js.map +1 -0
  244. package/dist/configurators/omp.d.ts +6 -0
  245. package/dist/configurators/omp.d.ts.map +1 -0
  246. package/dist/configurators/omp.js +28 -0
  247. package/dist/configurators/omp.js.map +1 -0
  248. package/dist/configurators/opencode.d.ts +5 -0
  249. package/dist/configurators/opencode.d.ts.map +1 -0
  250. package/dist/configurators/opencode.js +84 -0
  251. package/dist/configurators/opencode.js.map +1 -0
  252. package/dist/configurators/pi.d.ts +5 -0
  253. package/dist/configurators/pi.d.ts.map +1 -0
  254. package/dist/configurators/pi.js +39 -0
  255. package/dist/configurators/pi.js.map +1 -0
  256. package/dist/configurators/qoder.d.ts +12 -0
  257. package/dist/configurators/qoder.d.ts.map +1 -0
  258. package/dist/configurators/qoder.js +30 -0
  259. package/dist/configurators/qoder.js.map +1 -0
  260. package/dist/configurators/reasonix.d.ts +17 -0
  261. package/dist/configurators/reasonix.d.ts.map +1 -0
  262. package/dist/configurators/reasonix.js +37 -0
  263. package/dist/configurators/reasonix.js.map +1 -0
  264. package/dist/configurators/shared.d.ts +187 -0
  265. package/dist/configurators/shared.d.ts.map +1 -0
  266. package/dist/configurators/shared.js +590 -0
  267. package/dist/configurators/shared.js.map +1 -0
  268. package/dist/configurators/snow.d.ts +25 -0
  269. package/dist/configurators/snow.d.ts.map +1 -0
  270. package/dist/configurators/snow.js +69 -0
  271. package/dist/configurators/snow.js.map +1 -0
  272. package/dist/configurators/trae.d.ts +16 -0
  273. package/dist/configurators/trae.d.ts.map +1 -0
  274. package/dist/configurators/trae.js +34 -0
  275. package/dist/configurators/trae.js.map +1 -0
  276. package/dist/configurators/workflow.d.ts +51 -0
  277. package/dist/configurators/workflow.d.ts.map +1 -0
  278. package/dist/configurators/workflow.js +210 -0
  279. package/dist/configurators/workflow.js.map +1 -0
  280. package/dist/configurators/zcode.d.ts +23 -0
  281. package/dist/configurators/zcode.d.ts.map +1 -0
  282. package/dist/configurators/zcode.js +63 -0
  283. package/dist/configurators/zcode.js.map +1 -0
  284. package/dist/constants/paths.d.ts +74 -0
  285. package/dist/constants/paths.d.ts.map +1 -0
  286. package/dist/constants/paths.js +83 -0
  287. package/dist/constants/paths.js.map +1 -0
  288. package/dist/constants/version.d.ts +9 -0
  289. package/dist/constants/version.d.ts.map +1 -0
  290. package/dist/constants/version.js +15 -0
  291. package/dist/constants/version.js.map +1 -0
  292. package/dist/index.d.ts +9 -0
  293. package/dist/index.d.ts.map +1 -0
  294. package/dist/index.js +9 -0
  295. package/dist/index.js.map +1 -0
  296. package/dist/migrations/index.d.ts +62 -0
  297. package/dist/migrations/index.d.ts.map +1 -0
  298. package/dist/migrations/index.js +187 -0
  299. package/dist/migrations/index.js.map +1 -0
  300. package/dist/migrations/manifests/0.1.9.json +30 -0
  301. package/dist/migrations/manifests/0.2.0.json +49 -0
  302. package/dist/migrations/manifests/0.2.12.json +9 -0
  303. package/dist/migrations/manifests/0.2.13.json +9 -0
  304. package/dist/migrations/manifests/0.2.14.json +175 -0
  305. package/dist/migrations/manifests/0.2.15.json +33 -0
  306. package/dist/migrations/manifests/0.3.0-beta.0.json +297 -0
  307. package/dist/migrations/manifests/0.3.0-beta.1.json +9 -0
  308. package/dist/migrations/manifests/0.3.0-beta.10.json +9 -0
  309. package/dist/migrations/manifests/0.3.0-beta.11.json +9 -0
  310. package/dist/migrations/manifests/0.3.0-beta.12.json +9 -0
  311. package/dist/migrations/manifests/0.3.0-beta.13.json +9 -0
  312. package/dist/migrations/manifests/0.3.0-beta.14.json +9 -0
  313. package/dist/migrations/manifests/0.3.0-beta.15.json +9 -0
  314. package/dist/migrations/manifests/0.3.0-beta.16.json +9 -0
  315. package/dist/migrations/manifests/0.3.0-beta.2.json +9 -0
  316. package/dist/migrations/manifests/0.3.0-beta.3.json +9 -0
  317. package/dist/migrations/manifests/0.3.0-beta.4.json +9 -0
  318. package/dist/migrations/manifests/0.3.0-beta.5.json +9 -0
  319. package/dist/migrations/manifests/0.3.0-beta.6.json +9 -0
  320. package/dist/migrations/manifests/0.3.0-beta.7.json +11 -0
  321. package/dist/migrations/manifests/0.3.0-beta.8.json +9 -0
  322. package/dist/migrations/manifests/0.3.0-beta.9.json +9 -0
  323. package/dist/migrations/manifests/0.3.0-rc.0.json +9 -0
  324. package/dist/migrations/manifests/0.3.0-rc.1.json +9 -0
  325. package/dist/migrations/manifests/0.3.0-rc.2.json +9 -0
  326. package/dist/migrations/manifests/0.3.0-rc.3.json +9 -0
  327. package/dist/migrations/manifests/0.3.0-rc.4.json +9 -0
  328. package/dist/migrations/manifests/0.3.0-rc.5.json +9 -0
  329. package/dist/migrations/manifests/0.3.0-rc.6.json +9 -0
  330. package/dist/migrations/manifests/0.3.0.json +11 -0
  331. package/dist/migrations/manifests/0.3.1.json +9 -0
  332. package/dist/migrations/manifests/0.3.10.json +9 -0
  333. package/dist/migrations/manifests/0.3.2.json +9 -0
  334. package/dist/migrations/manifests/0.3.3.json +9 -0
  335. package/dist/migrations/manifests/0.3.4.json +21 -0
  336. package/dist/migrations/manifests/0.3.5.json +9 -0
  337. package/dist/migrations/manifests/0.3.6.json +9 -0
  338. package/dist/migrations/manifests/0.3.7.json +9 -0
  339. package/dist/migrations/manifests/0.3.8.json +9 -0
  340. package/dist/migrations/manifests/0.3.9.json +9 -0
  341. package/dist/migrations/manifests/0.4.0-beta.1.json +228 -0
  342. package/dist/migrations/manifests/0.4.0-beta.10.json +9 -0
  343. package/dist/migrations/manifests/0.4.0-beta.2.json +9 -0
  344. package/dist/migrations/manifests/0.4.0-beta.3.json +9 -0
  345. package/dist/migrations/manifests/0.4.0-beta.4.json +9 -0
  346. package/dist/migrations/manifests/0.4.0-beta.5.json +9 -0
  347. package/dist/migrations/manifests/0.4.0-beta.6.json +9 -0
  348. package/dist/migrations/manifests/0.4.0-beta.7.json +9 -0
  349. package/dist/migrations/manifests/0.4.0-beta.8.json +34 -0
  350. package/dist/migrations/manifests/0.4.0-beta.9.json +9 -0
  351. package/dist/migrations/manifests/0.4.0-rc.0.json +9 -0
  352. package/dist/migrations/manifests/0.4.0-rc.1.json +9 -0
  353. package/dist/migrations/manifests/0.4.0.json +9 -0
  354. package/dist/migrations/manifests/0.5.0-beta.0.json +1646 -0
  355. package/dist/migrations/manifests/0.5.0-beta.1.json +9 -0
  356. package/dist/migrations/manifests/0.5.0-beta.10.json +9 -0
  357. package/dist/migrations/manifests/0.5.0-beta.11.json +9 -0
  358. package/dist/migrations/manifests/0.5.0-beta.12.json +9 -0
  359. package/dist/migrations/manifests/0.5.0-beta.13.json +9 -0
  360. package/dist/migrations/manifests/0.5.0-beta.14.json +9 -0
  361. package/dist/migrations/manifests/0.5.0-beta.15.json +116 -0
  362. package/dist/migrations/manifests/0.5.0-beta.16.json +9 -0
  363. package/dist/migrations/manifests/0.5.0-beta.17.json +9 -0
  364. package/dist/migrations/manifests/0.5.0-beta.18.json +9 -0
  365. package/dist/migrations/manifests/0.5.0-beta.19.json +9 -0
  366. package/dist/migrations/manifests/0.5.0-beta.2.json +9 -0
  367. package/dist/migrations/manifests/0.5.0-beta.3.json +9 -0
  368. package/dist/migrations/manifests/0.5.0-beta.4.json +9 -0
  369. package/dist/migrations/manifests/0.5.0-beta.5.json +222 -0
  370. package/dist/migrations/manifests/0.5.0-beta.6.json +9 -0
  371. package/dist/migrations/manifests/0.5.0-beta.7.json +9 -0
  372. package/dist/migrations/manifests/0.5.0-beta.8.json +9 -0
  373. package/dist/migrations/manifests/0.5.0-beta.9.json +48 -0
  374. package/dist/migrations/manifests/0.5.0-rc.0.json +9 -0
  375. package/dist/migrations/manifests/0.5.0-rc.1.json +9 -0
  376. package/dist/migrations/manifests/0.5.0-rc.2.json +9 -0
  377. package/dist/migrations/manifests/0.5.0-rc.3.json +9 -0
  378. package/dist/migrations/manifests/0.5.0-rc.4.json +9 -0
  379. package/dist/migrations/manifests/0.5.0-rc.5.json +9 -0
  380. package/dist/migrations/manifests/0.5.0-rc.6.json +9 -0
  381. package/dist/migrations/manifests/0.5.0-rc.7.json +9 -0
  382. package/dist/migrations/manifests/0.5.0.json +9 -0
  383. package/dist/migrations/manifests/0.5.1.json +9 -0
  384. package/dist/migrations/manifests/0.5.10.json +9 -0
  385. package/dist/migrations/manifests/0.5.11.json +16 -0
  386. package/dist/migrations/manifests/0.5.12.json +9 -0
  387. package/dist/migrations/manifests/0.5.13.json +9 -0
  388. package/dist/migrations/manifests/0.5.14.json +9 -0
  389. package/dist/migrations/manifests/0.5.15.json +9 -0
  390. package/dist/migrations/manifests/0.5.16.json +9 -0
  391. package/dist/migrations/manifests/0.5.17.json +9 -0
  392. package/dist/migrations/manifests/0.5.18.json +9 -0
  393. package/dist/migrations/manifests/0.5.19.json +9 -0
  394. package/dist/migrations/manifests/0.5.2.json +9 -0
  395. package/dist/migrations/manifests/0.5.3.json +9 -0
  396. package/dist/migrations/manifests/0.5.4.json +9 -0
  397. package/dist/migrations/manifests/0.5.5.json +9 -0
  398. package/dist/migrations/manifests/0.5.6.json +9 -0
  399. package/dist/migrations/manifests/0.5.7.json +16 -0
  400. package/dist/migrations/manifests/0.5.8.json +9 -0
  401. package/dist/migrations/manifests/0.5.9.json +9 -0
  402. package/dist/migrations/manifests/0.6.0-beta.0.json +16 -0
  403. package/dist/migrations/manifests/0.6.0-beta.1.json +9 -0
  404. package/dist/migrations/manifests/0.6.0-beta.10.json +9 -0
  405. package/dist/migrations/manifests/0.6.0-beta.11.json +9 -0
  406. package/dist/migrations/manifests/0.6.0-beta.12.json +9 -0
  407. package/dist/migrations/manifests/0.6.0-beta.13.json +9 -0
  408. package/dist/migrations/manifests/0.6.0-beta.14.json +9 -0
  409. package/dist/migrations/manifests/0.6.0-beta.15.json +9 -0
  410. package/dist/migrations/manifests/0.6.0-beta.16.json +9 -0
  411. package/dist/migrations/manifests/0.6.0-beta.17.json +9 -0
  412. package/dist/migrations/manifests/0.6.0-beta.18.json +16 -0
  413. package/dist/migrations/manifests/0.6.0-beta.19.json +9 -0
  414. package/dist/migrations/manifests/0.6.0-beta.2.json +9 -0
  415. package/dist/migrations/manifests/0.6.0-beta.20.json +9 -0
  416. package/dist/migrations/manifests/0.6.0-beta.21.json +9 -0
  417. package/dist/migrations/manifests/0.6.0-beta.22.json +9 -0
  418. package/dist/migrations/manifests/0.6.0-beta.23.json +88 -0
  419. package/dist/migrations/manifests/0.6.0-beta.3.json +9 -0
  420. package/dist/migrations/manifests/0.6.0-beta.4.json +9 -0
  421. package/dist/migrations/manifests/0.6.0-beta.5.json +9 -0
  422. package/dist/migrations/manifests/0.6.0-beta.6.json +16 -0
  423. package/dist/migrations/manifests/0.6.0-beta.7.json +9 -0
  424. package/dist/migrations/manifests/0.6.0-beta.8.json +9 -0
  425. package/dist/migrations/manifests/0.6.0-beta.9.json +9 -0
  426. package/dist/migrations/manifests/0.6.0-rc.0.json +9 -0
  427. package/dist/migrations/manifests/0.6.0.json +1 -0
  428. package/dist/migrations/manifests/0.6.1.json +9 -0
  429. package/dist/migrations/manifests/0.6.10.json +9 -0
  430. package/dist/migrations/manifests/0.6.11.json +9 -0
  431. package/dist/migrations/manifests/0.6.12.json +9 -0
  432. package/dist/migrations/manifests/0.6.13.json +9 -0
  433. package/dist/migrations/manifests/0.6.14.json +9 -0
  434. package/dist/migrations/manifests/0.6.2.json +9 -0
  435. package/dist/migrations/manifests/0.6.3.json +24 -0
  436. package/dist/migrations/manifests/0.6.4.json +9 -0
  437. package/dist/migrations/manifests/0.6.5.json +9 -0
  438. package/dist/migrations/manifests/0.6.6.json +17 -0
  439. package/dist/migrations/manifests/0.6.7.json +9 -0
  440. package/dist/migrations/manifests/0.6.8.json +17 -0
  441. package/dist/migrations/manifests/0.6.9.json +9 -0
  442. package/dist/migrations/manifests/0.7.0-beta.0.json +9 -0
  443. package/dist/migrations/manifests/0.7.0-beta.1.json +9 -0
  444. package/dist/migrations/manifests/0.7.0-beta.2.json +9 -0
  445. package/dist/migrations/manifests/0.7.0-beta.3.json +9 -0
  446. package/dist/templates/claude/agents/trellis-check.md +115 -0
  447. package/dist/templates/claude/agents/trellis-implement.md +115 -0
  448. package/dist/templates/claude/agents/trellis-research.md +137 -0
  449. package/dist/templates/claude/hooks/statusline.py +332 -0
  450. package/dist/templates/claude/index.d.ts +31 -0
  451. package/dist/templates/claude/index.d.ts.map +1 -0
  452. package/dist/templates/claude/index.js +57 -0
  453. package/dist/templates/claude/index.js.map +1 -0
  454. package/dist/templates/claude/settings.json +95 -0
  455. package/dist/templates/codebuddy/agents/trellis-check.md +115 -0
  456. package/dist/templates/codebuddy/agents/trellis-implement.md +115 -0
  457. package/dist/templates/codebuddy/agents/trellis-research.md +137 -0
  458. package/dist/templates/codebuddy/index.d.ts +15 -0
  459. package/dist/templates/codebuddy/index.d.ts.map +1 -0
  460. package/dist/templates/codebuddy/index.js +15 -0
  461. package/dist/templates/codebuddy/index.js.map +1 -0
  462. package/dist/templates/codebuddy/settings.json +69 -0
  463. package/dist/templates/codex/agents/trellis-check.toml +56 -0
  464. package/dist/templates/codex/agents/trellis-implement.toml +37 -0
  465. package/dist/templates/codex/agents/trellis-research.toml +78 -0
  466. package/dist/templates/codex/config.toml +39 -0
  467. package/dist/templates/codex/hooks/session-start.py +568 -0
  468. package/dist/templates/codex/hooks.json +52 -0
  469. package/dist/templates/codex/index.d.ts +35 -0
  470. package/dist/templates/codex/index.d.ts.map +1 -0
  471. package/dist/templates/codex/index.js +67 -0
  472. package/dist/templates/codex/index.js.map +1 -0
  473. package/dist/templates/common/bundled-skills/trellis-channel/SKILL.md +67 -0
  474. package/dist/templates/common/bundled-skills/trellis-channel/references/command-reference.md +480 -0
  475. package/dist/templates/common/bundled-skills/trellis-channel/references/forum.md +233 -0
  476. package/dist/templates/common/bundled-skills/trellis-channel/references/progress-debugging.md +226 -0
  477. package/dist/templates/common/bundled-skills/trellis-channel/references/workers.md +276 -0
  478. package/dist/templates/common/bundled-skills/trellis-channel/references/workflows.md +128 -0
  479. package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +85 -0
  480. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
  481. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +56 -0
  482. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +84 -0
  483. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
  484. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +123 -0
  485. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
  486. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-task-lifecycle.md +90 -0
  487. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +65 -0
  488. package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +55 -0
  489. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/bundled-skills.md +159 -0
  490. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
  491. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
  492. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/multi-agent-channel.md +69 -0
  493. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +51 -0
  494. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
  495. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +130 -0
  496. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workflow.md +75 -0
  497. package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
  498. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +84 -0
  499. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +73 -0
  500. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +59 -0
  501. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +113 -0
  502. package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +87 -0
  503. package/dist/templates/common/bundled-skills/trellis-session-insight/SKILL.md +81 -0
  504. package/dist/templates/common/bundled-skills/trellis-session-insight/references/cli-quick-reference.md +65 -0
  505. package/dist/templates/common/bundled-skills/trellis-session-insight/references/triggering-patterns.md +93 -0
  506. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/SKILL.md +41 -0
  507. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/mcp-setup.md +90 -0
  508. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/repository-analysis.md +59 -0
  509. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-task-planning.md +61 -0
  510. package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +70 -0
  511. package/dist/templates/common/commands/continue.md +56 -0
  512. package/dist/templates/common/commands/finish-work.md +66 -0
  513. package/dist/templates/common/commands/start.md +59 -0
  514. package/dist/templates/common/index.d.ts +48 -0
  515. package/dist/templates/common/index.d.ts.map +1 -0
  516. package/dist/templates/common/index.js +104 -0
  517. package/dist/templates/common/index.js.map +1 -0
  518. package/dist/templates/common/skills/before-dev.md +46 -0
  519. package/dist/templates/common/skills/brainstorm.md +212 -0
  520. package/dist/templates/common/skills/break-loop.md +184 -0
  521. package/dist/templates/common/skills/check.md +106 -0
  522. package/dist/templates/common/skills/tdd.md +142 -0
  523. package/dist/templates/common/skills/update-spec.md +351 -0
  524. package/dist/templates/copilot/copilot-instructions.md +11 -0
  525. package/dist/templates/copilot/hooks/session-start.py +564 -0
  526. package/dist/templates/copilot/hooks.json +19 -0
  527. package/dist/templates/copilot/index.d.ts +28 -0
  528. package/dist/templates/copilot/index.d.ts.map +1 -0
  529. package/dist/templates/copilot/index.js +61 -0
  530. package/dist/templates/copilot/index.js.map +1 -0
  531. package/dist/templates/copilot/prompts/before-dev.prompt.md +39 -0
  532. package/dist/templates/copilot/prompts/brainstorm.prompt.md +173 -0
  533. package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
  534. package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +170 -0
  535. package/dist/templates/copilot/prompts/check.prompt.md +110 -0
  536. package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
  537. package/dist/templates/copilot/prompts/finish-work.prompt.md +99 -0
  538. package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
  539. package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
  540. package/dist/templates/copilot/prompts/parallel.prompt.md +204 -0
  541. package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
  542. package/dist/templates/copilot/prompts/start.prompt.md +63 -0
  543. package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
  544. package/dist/templates/cursor/agents/trellis-check.md +114 -0
  545. package/dist/templates/cursor/agents/trellis-implement.md +114 -0
  546. package/dist/templates/cursor/agents/trellis-research.md +136 -0
  547. package/dist/templates/cursor/hooks.json +24 -0
  548. package/dist/templates/cursor/index.d.ts +13 -0
  549. package/dist/templates/cursor/index.d.ts.map +1 -0
  550. package/dist/templates/cursor/index.js +13 -0
  551. package/dist/templates/cursor/index.js.map +1 -0
  552. package/dist/templates/droid/droids/trellis-check.md +107 -0
  553. package/dist/templates/droid/droids/trellis-implement.md +107 -0
  554. package/dist/templates/droid/droids/trellis-research.md +137 -0
  555. package/dist/templates/droid/index.d.ts +15 -0
  556. package/dist/templates/droid/index.d.ts.map +1 -0
  557. package/dist/templates/droid/index.js +15 -0
  558. package/dist/templates/droid/index.js.map +1 -0
  559. package/dist/templates/droid/settings.json +69 -0
  560. package/dist/templates/dsh/DSH.md +80 -0
  561. package/dist/templates/dsh/agents/trellis-check.md +99 -0
  562. package/dist/templates/dsh/agents/trellis-implement.md +106 -0
  563. package/dist/templates/dsh/agents/trellis-research.md +134 -0
  564. package/dist/templates/dsh/index.d.ts +22 -0
  565. package/dist/templates/dsh/index.d.ts.map +1 -0
  566. package/dist/templates/dsh/index.js +27 -0
  567. package/dist/templates/dsh/index.js.map +1 -0
  568. package/dist/templates/extract.d.ts +40 -0
  569. package/dist/templates/extract.d.ts.map +1 -0
  570. package/dist/templates/extract.js +106 -0
  571. package/dist/templates/extract.js.map +1 -0
  572. package/dist/templates/gemini/agents/trellis-check.md +107 -0
  573. package/dist/templates/gemini/agents/trellis-implement.md +107 -0
  574. package/dist/templates/gemini/agents/trellis-research.md +136 -0
  575. package/dist/templates/gemini/index.d.ts +13 -0
  576. package/dist/templates/gemini/index.d.ts.map +1 -0
  577. package/dist/templates/gemini/index.js +13 -0
  578. package/dist/templates/gemini/index.js.map +1 -0
  579. package/dist/templates/gemini/settings.json +40 -0
  580. package/dist/templates/grok/agents/trellis-check.md +106 -0
  581. package/dist/templates/grok/agents/trellis-implement.md +121 -0
  582. package/dist/templates/grok/agents/trellis-research.md +146 -0
  583. package/dist/templates/grok/index.d.ts +16 -0
  584. package/dist/templates/grok/index.d.ts.map +1 -0
  585. package/dist/templates/grok/index.js +19 -0
  586. package/dist/templates/grok/index.js.map +1 -0
  587. package/dist/templates/kimi/agents/trellis-check.md +104 -0
  588. package/dist/templates/kimi/agents/trellis-implement.md +120 -0
  589. package/dist/templates/kimi/agents/trellis-research.md +144 -0
  590. package/dist/templates/kimi/index.d.ts +20 -0
  591. package/dist/templates/kimi/index.d.ts.map +1 -0
  592. package/dist/templates/kimi/index.js +23 -0
  593. package/dist/templates/kimi/index.js.map +1 -0
  594. package/dist/templates/kiro/agents/trellis-check.json +26 -0
  595. package/dist/templates/kiro/agents/trellis-implement.json +26 -0
  596. package/dist/templates/kiro/agents/trellis-research.json +30 -0
  597. package/dist/templates/kiro/agents/trellis.json +34 -0
  598. package/dist/templates/kiro/hooks/trellis-workflow-state.kiro.hook +14 -0
  599. package/dist/templates/kiro/index.d.ts +32 -0
  600. package/dist/templates/kiro/index.d.ts.map +1 -0
  601. package/dist/templates/kiro/index.js +28 -0
  602. package/dist/templates/kiro/index.js.map +1 -0
  603. package/dist/templates/markdown/agents.md +21 -0
  604. package/dist/templates/markdown/gitignore.txt +15 -0
  605. package/dist/templates/markdown/index.d.ts +27 -0
  606. package/dist/templates/markdown/index.d.ts.map +1 -0
  607. package/dist/templates/markdown/index.js +52 -0
  608. package/dist/templates/markdown/index.js.map +1 -0
  609. package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
  610. package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
  611. package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
  612. package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
  613. package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
  614. package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
  615. package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
  616. package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
  617. package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
  618. package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
  619. package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
  620. package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
  621. package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
  622. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +223 -0
  623. package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +327 -0
  624. package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +633 -0
  625. package/dist/templates/markdown/spec/guides/index.md.txt +97 -0
  626. package/dist/templates/markdown/workspace-index.md +125 -0
  627. package/dist/templates/markdown/worktree.yaml.txt +58 -0
  628. package/dist/templates/omp/agents/trellis-check.md +41 -0
  629. package/dist/templates/omp/agents/trellis-implement.md +55 -0
  630. package/dist/templates/omp/agents/trellis-research.md +30 -0
  631. package/dist/templates/omp/extensions/trellis/index.ts.txt +592 -0
  632. package/dist/templates/omp/index.d.ts +4 -0
  633. package/dist/templates/omp/index.d.ts.map +1 -0
  634. package/dist/templates/omp/index.js +9 -0
  635. package/dist/templates/omp/index.js.map +1 -0
  636. package/dist/templates/opencode/agents/trellis-check.md +122 -0
  637. package/dist/templates/opencode/agents/trellis-implement.md +123 -0
  638. package/dist/templates/opencode/agents/trellis-research.md +145 -0
  639. package/dist/templates/opencode/lib/context-visibility.js +86 -0
  640. package/dist/templates/opencode/lib/session-utils.js +526 -0
  641. package/dist/templates/opencode/lib/trellis-context.js +627 -0
  642. package/dist/templates/opencode/package.json +5 -0
  643. package/dist/templates/opencode/plugins/inject-spec-context.js +121 -0
  644. package/dist/templates/opencode/plugins/inject-subagent-context.js +569 -0
  645. package/dist/templates/opencode/plugins/inject-workflow-state.js +340 -0
  646. package/dist/templates/opencode/plugins/session-start.js +74 -0
  647. package/dist/templates/pi/agents/trellis-check.md +37 -0
  648. package/dist/templates/pi/agents/trellis-implement.md +52 -0
  649. package/dist/templates/pi/agents/trellis-research.md +25 -0
  650. package/dist/templates/pi/extensions/trellis/index.ts.txt +2033 -0
  651. package/dist/templates/pi/index.d.ts +5 -0
  652. package/dist/templates/pi/index.d.ts.map +1 -0
  653. package/dist/templates/pi/index.js +12 -0
  654. package/dist/templates/pi/index.js.map +1 -0
  655. package/dist/templates/pi/settings.json +9 -0
  656. package/dist/templates/qoder/agents/trellis-check.md +108 -0
  657. package/dist/templates/qoder/agents/trellis-implement.md +108 -0
  658. package/dist/templates/qoder/agents/trellis-research.md +137 -0
  659. package/dist/templates/qoder/index.d.ts +15 -0
  660. package/dist/templates/qoder/index.d.ts.map +1 -0
  661. package/dist/templates/qoder/index.js +15 -0
  662. package/dist/templates/qoder/index.js.map +1 -0
  663. package/dist/templates/qoder/settings.json +59 -0
  664. package/dist/templates/reasonix/agents/trellis-check.md +36 -0
  665. package/dist/templates/reasonix/agents/trellis-implement.md +51 -0
  666. package/dist/templates/reasonix/index.d.ts +13 -0
  667. package/dist/templates/reasonix/index.d.ts.map +1 -0
  668. package/dist/templates/reasonix/index.js +16 -0
  669. package/dist/templates/reasonix/index.js.map +1 -0
  670. package/dist/templates/shared-hooks/index.d.ts +83 -0
  671. package/dist/templates/shared-hooks/index.d.ts.map +1 -0
  672. package/dist/templates/shared-hooks/index.js +152 -0
  673. package/dist/templates/shared-hooks/index.js.map +1 -0
  674. package/dist/templates/shared-hooks/inject-shell-session-context.py +292 -0
  675. package/dist/templates/shared-hooks/inject-spec-context.py +844 -0
  676. package/dist/templates/shared-hooks/inject-subagent-context.py +1175 -0
  677. package/dist/templates/shared-hooks/inject-workflow-state.py +501 -0
  678. package/dist/templates/shared-hooks/session-start.py +969 -0
  679. package/dist/templates/snow/SNOW.md +86 -0
  680. package/dist/templates/snow/agents/trellis-check.md +136 -0
  681. package/dist/templates/snow/agents/trellis-implement.md +158 -0
  682. package/dist/templates/snow/agents/trellis-research.md +114 -0
  683. package/dist/templates/snow/hooks/beforeSubAgentStart.json +15 -0
  684. package/dist/templates/snow/hooks/onSessionStart.json +15 -0
  685. package/dist/templates/snow/hooks/onUserMessage.json +15 -0
  686. package/dist/templates/snow/hooks/write-trellis-context.py +644 -0
  687. package/dist/templates/snow/index.d.ts +26 -0
  688. package/dist/templates/snow/index.d.ts.map +1 -0
  689. package/dist/templates/snow/index.js +36 -0
  690. package/dist/templates/snow/index.js.map +1 -0
  691. package/dist/templates/template-utils.d.ts +26 -0
  692. package/dist/templates/template-utils.d.ts.map +1 -0
  693. package/dist/templates/template-utils.js +64 -0
  694. package/dist/templates/template-utils.js.map +1 -0
  695. package/dist/templates/trae/agents/trellis-check.md +108 -0
  696. package/dist/templates/trae/agents/trellis-implement.md +108 -0
  697. package/dist/templates/trae/agents/trellis-research.md +137 -0
  698. package/dist/templates/trae/hooks.json +39 -0
  699. package/dist/templates/trae/index.d.ts +15 -0
  700. package/dist/templates/trae/index.d.ts.map +1 -0
  701. package/dist/templates/trae/index.js +15 -0
  702. package/dist/templates/trae/index.js.map +1 -0
  703. package/dist/templates/trellis/agents/check.md +70 -0
  704. package/dist/templates/trellis/agents/implement.md +81 -0
  705. package/dist/templates/trellis/config.yaml +205 -0
  706. package/dist/templates/trellis/gitattributes.txt +9 -0
  707. package/dist/templates/trellis/gitignore.txt +32 -0
  708. package/dist/templates/trellis/index.d.ts +70 -0
  709. package/dist/templates/trellis/index.d.ts.map +1 -0
  710. package/dist/templates/trellis/index.js +127 -0
  711. package/dist/templates/trellis/index.js.map +1 -0
  712. package/dist/templates/trellis/scripts/__init__.py +5 -0
  713. package/dist/templates/trellis/scripts/add_session.py +681 -0
  714. package/dist/templates/trellis/scripts/common/__init__.py +92 -0
  715. package/dist/templates/trellis/scripts/common/active_task.py +787 -0
  716. package/dist/templates/trellis/scripts/common/cli_adapter.py +982 -0
  717. package/dist/templates/trellis/scripts/common/config.py +587 -0
  718. package/dist/templates/trellis/scripts/common/developer.py +190 -0
  719. package/dist/templates/trellis/scripts/common/git.py +74 -0
  720. package/dist/templates/trellis/scripts/common/git_context.py +138 -0
  721. package/dist/templates/trellis/scripts/common/io.py +61 -0
  722. package/dist/templates/trellis/scripts/common/log.py +45 -0
  723. package/dist/templates/trellis/scripts/common/packages_context.py +238 -0
  724. package/dist/templates/trellis/scripts/common/paths.py +508 -0
  725. package/dist/templates/trellis/scripts/common/safe_commit.py +315 -0
  726. package/dist/templates/trellis/scripts/common/session_context.py +892 -0
  727. package/dist/templates/trellis/scripts/common/spec_inject.py +439 -0
  728. package/dist/templates/trellis/scripts/common/spec_match.py +395 -0
  729. package/dist/templates/trellis/scripts/common/task_context.py +372 -0
  730. package/dist/templates/trellis/scripts/common/task_queue.py +188 -0
  731. package/dist/templates/trellis/scripts/common/task_store.py +1016 -0
  732. package/dist/templates/trellis/scripts/common/task_utils.py +309 -0
  733. package/dist/templates/trellis/scripts/common/tasks.py +112 -0
  734. package/dist/templates/trellis/scripts/common/trellis_config.py +132 -0
  735. package/dist/templates/trellis/scripts/common/types.py +110 -0
  736. package/dist/templates/trellis/scripts/common/workflow_phase.py +243 -0
  737. package/dist/templates/trellis/scripts/common/workflow_selection.py +177 -0
  738. package/dist/templates/trellis/scripts/get_context.py +16 -0
  739. package/dist/templates/trellis/scripts/get_developer.py +26 -0
  740. package/dist/templates/trellis/scripts/hooks/linear_sync.py +243 -0
  741. package/dist/templates/trellis/scripts/init_developer.py +51 -0
  742. package/dist/templates/trellis/scripts/task.py +694 -0
  743. package/dist/templates/trellis/tasks/.gitkeep +0 -0
  744. package/dist/templates/trellis/workflow.md +777 -0
  745. package/dist/templates/zcode/agents/trellis-check.md +110 -0
  746. package/dist/templates/zcode/agents/trellis-implement.md +116 -0
  747. package/dist/templates/zcode/agents/trellis-research.md +133 -0
  748. package/dist/templates/zcode/config.json +52 -0
  749. package/dist/templates/zcode/index.d.ts +25 -0
  750. package/dist/templates/zcode/index.d.ts.map +1 -0
  751. package/dist/templates/zcode/index.js +29 -0
  752. package/dist/templates/zcode/index.js.map +1 -0
  753. package/dist/types/ai-tools.d.ts +95 -0
  754. package/dist/types/ai-tools.d.ts.map +1 -0
  755. package/dist/types/ai-tools.js +509 -0
  756. package/dist/types/ai-tools.js.map +1 -0
  757. package/dist/types/migration.d.ts +125 -0
  758. package/dist/types/migration.d.ts.map +1 -0
  759. package/dist/types/migration.js +8 -0
  760. package/dist/types/migration.js.map +1 -0
  761. package/dist/utils/agent-refs.d.ts +31 -0
  762. package/dist/utils/agent-refs.d.ts.map +1 -0
  763. package/dist/utils/agent-refs.js +63 -0
  764. package/dist/utils/agent-refs.js.map +1 -0
  765. package/dist/utils/atomic-write.d.ts +12 -0
  766. package/dist/utils/atomic-write.d.ts.map +1 -0
  767. package/dist/utils/atomic-write.js +30 -0
  768. package/dist/utils/atomic-write.js.map +1 -0
  769. package/dist/utils/compare-versions.d.ts +12 -0
  770. package/dist/utils/compare-versions.d.ts.map +1 -0
  771. package/dist/utils/compare-versions.js +86 -0
  772. package/dist/utils/compare-versions.js.map +1 -0
  773. package/dist/utils/cwd-guard.d.ts +38 -0
  774. package/dist/utils/cwd-guard.d.ts.map +1 -0
  775. package/dist/utils/cwd-guard.js +62 -0
  776. package/dist/utils/cwd-guard.js.map +1 -0
  777. package/dist/utils/file-writer.d.ts +36 -0
  778. package/dist/utils/file-writer.d.ts.map +1 -0
  779. package/dist/utils/file-writer.js +204 -0
  780. package/dist/utils/file-writer.js.map +1 -0
  781. package/dist/utils/manifest-prune.d.ts +61 -0
  782. package/dist/utils/manifest-prune.d.ts.map +1 -0
  783. package/dist/utils/manifest-prune.js +136 -0
  784. package/dist/utils/manifest-prune.js.map +1 -0
  785. package/dist/utils/posix.d.ts +13 -0
  786. package/dist/utils/posix.d.ts.map +1 -0
  787. package/dist/utils/posix.js +15 -0
  788. package/dist/utils/posix.js.map +1 -0
  789. package/dist/utils/project-detector.d.ts +46 -0
  790. package/dist/utils/project-detector.d.ts.map +1 -0
  791. package/dist/utils/project-detector.js +666 -0
  792. package/dist/utils/project-detector.js.map +1 -0
  793. package/dist/utils/proxy.d.ts +25 -0
  794. package/dist/utils/proxy.d.ts.map +1 -0
  795. package/dist/utils/proxy.js +60 -0
  796. package/dist/utils/proxy.js.map +1 -0
  797. package/dist/utils/registry-config.d.ts +7 -0
  798. package/dist/utils/registry-config.d.ts.map +1 -0
  799. package/dist/utils/registry-config.js +172 -0
  800. package/dist/utils/registry-config.js.map +1 -0
  801. package/dist/utils/task-json.d.ts +13 -0
  802. package/dist/utils/task-json.d.ts.map +1 -0
  803. package/dist/utils/task-json.js +12 -0
  804. package/dist/utils/task-json.js.map +1 -0
  805. package/dist/utils/template-fetcher.d.ts +161 -0
  806. package/dist/utils/template-fetcher.d.ts.map +1 -0
  807. package/dist/utils/template-fetcher.js +994 -0
  808. package/dist/utils/template-fetcher.js.map +1 -0
  809. package/dist/utils/template-hash.d.ts +123 -0
  810. package/dist/utils/template-hash.d.ts.map +1 -0
  811. package/dist/utils/template-hash.js +335 -0
  812. package/dist/utils/template-hash.js.map +1 -0
  813. package/dist/utils/uninstall-scrubbers.d.ts +67 -0
  814. package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
  815. package/dist/utils/uninstall-scrubbers.js +361 -0
  816. package/dist/utils/uninstall-scrubbers.js.map +1 -0
  817. package/dist/utils/workflow-resolver.d.ts +86 -0
  818. package/dist/utils/workflow-resolver.d.ts.map +1 -0
  819. package/dist/utils/workflow-resolver.js +265 -0
  820. package/dist/utils/workflow-resolver.js.map +1 -0
  821. package/package.json +89 -0
@@ -0,0 +1,1603 @@
1
+ import { execSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import readline from "node:readline";
5
+ import chalk from "chalk";
6
+ import figlet from "figlet";
7
+ import inquirer from "inquirer";
8
+ import { createWorkflowStructure } from "../configurators/workflow.js";
9
+ import { getInitToolChoices, resolveCliFlag, configurePlatform, getConfiguredPlatforms, getPlatformsWithPythonHooks, } from "../configurators/index.js";
10
+ import { getPythonCommandForPlatform, setResolvedPythonCommand, } from "../configurators/shared.js";
11
+ import { AI_TOOLS } from "../types/ai-tools.js";
12
+ import { DIR_NAMES, FILE_NAMES, PATHS } from "../constants/paths.js";
13
+ import { VERSION } from "../constants/version.js";
14
+ import { agentsMdContent } from "../templates/markdown/index.js";
15
+ import { setWriteMode, startRecordingWrites, stopRecordingWrites, writeFile, } from "../utils/file-writer.js";
16
+ import { emptyTaskJson } from "../utils/task-json.js";
17
+ import { detectProjectType, detectMonorepo, sanitizePkgName, } from "../utils/project-detector.js";
18
+ import { initializeHashes, removeHash } from "../utils/template-hash.js";
19
+ import { NATIVE_WORKFLOW_ID, resolveWorkflowTemplate, } from "../utils/workflow-resolver.js";
20
+ import { isCwdHomedir, homedirGuardMessage, homedirBypassEnabled, } from "../utils/cwd-guard.js";
21
+ import { writeSpecRegistryConfig, } from "../utils/registry-config.js";
22
+ import { fetchTemplateIndex, probeRegistryIndex, downloadTemplateById, downloadRegistryDirect, parseRegistrySource, TIMEOUTS, TEMPLATE_INDEX_URL, } from "../utils/template-fetcher.js";
23
+ import { setupProxy, maskProxyUrl } from "../utils/proxy.js";
24
+ import { toPosix } from "../utils/posix.js";
25
+ import { updateHashes } from "../utils/template-hash.js";
26
+ const MIN_PYTHON_MAJOR = 3;
27
+ const MIN_PYTHON_MINOR = 9;
28
+ const PYTHON_VERSION_RE = /Python (\d+)\.(\d+)/;
29
+ function collectSpecPaths(cwd) {
30
+ const specRoot = path.join(cwd, PATHS.SPEC);
31
+ const paths = new Set();
32
+ if (!fs.existsSync(specRoot))
33
+ return paths;
34
+ const walk = (dir) => {
35
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
36
+ const fullPath = path.join(dir, entry.name);
37
+ if (entry.isDirectory()) {
38
+ walk(fullPath);
39
+ }
40
+ else if (entry.isFile()) {
41
+ paths.add(toPosix(path.relative(cwd, fullPath)));
42
+ }
43
+ }
44
+ };
45
+ walk(specRoot);
46
+ return paths;
47
+ }
48
+ export function isSupportedPythonVersion(versionOutput) {
49
+ const match = versionOutput.match(PYTHON_VERSION_RE);
50
+ if (!match)
51
+ return false;
52
+ const major = Number(match[1]);
53
+ const minor = Number(match[2]);
54
+ return (major > MIN_PYTHON_MAJOR ||
55
+ (major === MIN_PYTHON_MAJOR && minor >= MIN_PYTHON_MINOR));
56
+ }
57
+ function detectPythonVersion(command) {
58
+ try {
59
+ return execSync(`${command} --version`, {
60
+ encoding: "utf-8",
61
+ stdio: "pipe",
62
+ }).trim();
63
+ }
64
+ catch (err) {
65
+ const code = err?.code;
66
+ if (code === "EPERM" || code === "EACCES") {
67
+ return "sandbox-restricted";
68
+ }
69
+ return null;
70
+ }
71
+ }
72
+ export function requireSupportedPython(command) {
73
+ // Final escape hatch — set when the user knows python3 is on PATH but
74
+ // the probe keeps failing for environment-specific reasons.
75
+ if (process.env.TRELLIS_SKIP_PYTHON_CHECK === "1") {
76
+ return `version check skipped (TRELLIS_SKIP_PYTHON_CHECK=1)`;
77
+ }
78
+ const versionOutput = detectPythonVersion(command);
79
+ if (versionOutput === "sandbox-restricted") {
80
+ console.warn(chalk.yellow(`⚠ Python version check skipped — sandboxed environment blocked ` +
81
+ `child_process spawn (EPERM/EACCES). Assuming "${command}" is on ` +
82
+ `PATH. If init fails later, re-run on the host or set ` +
83
+ `TRELLIS_SKIP_PYTHON_CHECK=1.`));
84
+ return `version unknown (sandbox-restricted)`;
85
+ }
86
+ if (!versionOutput) {
87
+ throw new Error(`Python command "${command}" not found. Trellis init requires Python ≥ 3.9.`);
88
+ }
89
+ if (!isSupportedPythonVersion(versionOutput)) {
90
+ throw new Error(`${versionOutput} detected via "${command}", but Trellis init requires Python ≥ 3.9.`);
91
+ }
92
+ return versionOutput;
93
+ }
94
+ /**
95
+ * Candidate Python command list per platform.
96
+ *
97
+ * Windows: `python` is the usual python.org installer choice, but Microsoft
98
+ * Store ships `python3`, and the `py` launcher is `py -3`. We try all three
99
+ * before giving up — fixes #236 where users with only `python3` (not
100
+ * `python`) had `trellis init` fail outright.
101
+ *
102
+ * Non-Windows: `python3` is canonical; `python` is a fallback for systems
103
+ * where Python 3 is the only Python and is named `python` (some Arch
104
+ * configs, conda envs).
105
+ */
106
+ const PYTHON_CANDIDATES = {
107
+ win32: ["python", "python3", "py -3"],
108
+ other: ["python3", "python"],
109
+ };
110
+ /**
111
+ * Detect a working Python ≥ 3.9 command on the host platform.
112
+ *
113
+ * Honors `TRELLIS_PYTHON_CMD` (explicit override, no probe) and
114
+ * `TRELLIS_SKIP_PYTHON_CHECK=1` (skip probe, trust platform default).
115
+ *
116
+ * Otherwise tries each candidate in `PYTHON_CANDIDATES` in order and returns
117
+ * the first whose `--version` matches `Python ≥ 3.9`. Caches the result via
118
+ * `setResolvedPythonCommand` so all downstream template / configurator
119
+ * writes pick up the resolved value.
120
+ *
121
+ * Throws a helpful, Windows-aware error if no candidate works.
122
+ */
123
+ export function resolveSupportedPython() {
124
+ // Explicit override — user knows their environment.
125
+ const override = process.env.TRELLIS_PYTHON_CMD?.trim();
126
+ if (override) {
127
+ setResolvedPythonCommand(override);
128
+ return { command: override, version: "set via TRELLIS_PYTHON_CMD" };
129
+ }
130
+ // Skip probe entirely.
131
+ if (process.env.TRELLIS_SKIP_PYTHON_CHECK === "1") {
132
+ const fallback = getPythonCommandForPlatform();
133
+ setResolvedPythonCommand(fallback);
134
+ return {
135
+ command: fallback,
136
+ version: "version check skipped (TRELLIS_SKIP_PYTHON_CHECK=1)",
137
+ };
138
+ }
139
+ const candidates = process.platform === "win32"
140
+ ? PYTHON_CANDIDATES.win32
141
+ : PYTHON_CANDIDATES.other;
142
+ const probeFailures = [];
143
+ for (const candidate of candidates) {
144
+ const probe = detectPythonVersion(candidate);
145
+ if (probe === "sandbox-restricted") {
146
+ console.warn(chalk.yellow(`⚠ Python version check skipped — sandboxed environment blocked ` +
147
+ `child_process spawn (EPERM/EACCES). Assuming "${candidate}" is ` +
148
+ `on PATH. If init fails later, re-run on the host or set ` +
149
+ `TRELLIS_SKIP_PYTHON_CHECK=1.`));
150
+ setResolvedPythonCommand(candidate);
151
+ return {
152
+ command: candidate,
153
+ version: "version unknown (sandbox-restricted)",
154
+ };
155
+ }
156
+ if (!probe) {
157
+ probeFailures.push(`${candidate}: not found`);
158
+ continue;
159
+ }
160
+ if (!isSupportedPythonVersion(probe)) {
161
+ probeFailures.push(`${candidate}: ${probe} (< 3.9)`);
162
+ continue;
163
+ }
164
+ setResolvedPythonCommand(candidate);
165
+ return { command: candidate, version: probe };
166
+ }
167
+ const isWindows = process.platform === "win32";
168
+ const installHint = isWindows
169
+ ? `Install Python ≥ 3.9 from https://www.python.org/downloads/windows/ — make sure ` +
170
+ `"Add Python to PATH" is checked in the installer. Or, if Python is ` +
171
+ `installed under a different name, set TRELLIS_PYTHON_CMD=<your-cmd> ` +
172
+ `before re-running init (e.g. \`set TRELLIS_PYTHON_CMD=py -3\`).`
173
+ : `Install Python ≥ 3.9 from https://www.python.org/downloads/ or via your ` +
174
+ `package manager. Or set TRELLIS_PYTHON_CMD=<your-cmd> before re-running.`;
175
+ throw new Error(`No supported Python command found. Tried: ${candidates.join(", ")}.\n` +
176
+ `Probe results:\n ${probeFailures.join("\n ")}\n\n` +
177
+ `Trellis init requires Python ≥ 3.9. ${installHint}\n` +
178
+ `Last-resort escape hatch: set TRELLIS_SKIP_PYTHON_CHECK=1 to skip the probe entirely.`);
179
+ }
180
+ function getOsDisplayName(platform = process.platform) {
181
+ switch (platform) {
182
+ case "win32":
183
+ return "Windows";
184
+ case "darwin":
185
+ return "macOS";
186
+ case "linux":
187
+ return "Linux";
188
+ default:
189
+ return platform;
190
+ }
191
+ }
192
+ function logPythonAdaptationNotice(command) {
193
+ const osName = getOsDisplayName();
194
+ console.log(chalk.blue(`📌 ${osName} detected: Trellis rendered Python commands as "${command}" in generated hooks, settings, and help text`));
195
+ }
196
+ // =============================================================================
197
+ // Bootstrap Task Creation
198
+ // =============================================================================
199
+ const BOOTSTRAP_TASK_NAME = "00-bootstrap-guidelines";
200
+ /**
201
+ * Slugify a developer name for safe use in task directory names.
202
+ *
203
+ * Unlike `sanitizePkgName` (which only strips npm @scope/ prefixes), this
204
+ * handles arbitrary developer input: spaces, Unicode letters, punctuation,
205
+ * path separators. Returns "user" fallback when input slugifies to empty.
206
+ *
207
+ * Exported for unit testing; not part of the public API.
208
+ */
209
+ export function slugifyDeveloperName(name) {
210
+ const slug = name
211
+ .toLowerCase()
212
+ .normalize("NFKD")
213
+ .replace(/[^\p{Letter}\p{Number}]+/gu, "-")
214
+ .replace(/^-+|-+$/g, "");
215
+ return slug || "user";
216
+ }
217
+ /**
218
+ * Write a task skeleton (task.json + prd.md).
219
+ *
220
+ * Idempotent: if the task dir already exists, returns true without touching
221
+ * anything. Shared by both creator bootstrap and joiner onboarding flows.
222
+ */
223
+ function writeTaskSkeleton(cwd, taskName, taskJson, prdContent) {
224
+ const taskDir = path.join(cwd, PATHS.TASKS, taskName);
225
+ if (fs.existsSync(taskDir))
226
+ return true; // idempotent
227
+ try {
228
+ fs.mkdirSync(taskDir, { recursive: true });
229
+ fs.writeFileSync(path.join(taskDir, FILE_NAMES.TASK_JSON), JSON.stringify(taskJson, null, 2), "utf-8");
230
+ fs.writeFileSync(path.join(taskDir, FILE_NAMES.PRD), prdContent, "utf-8");
231
+ return true;
232
+ }
233
+ catch {
234
+ return false;
235
+ }
236
+ }
237
+ /**
238
+ * Compute the bootstrap checklist items (previously stored as structured
239
+ * `subtasks: [{name, status}]` in task.json). Per task 04-21-task-schema-unify
240
+ * (D1), these live as markdown `- [ ]` items in prd.md instead, so task.json
241
+ * stays canonical with `subtasks: string[]` (child task dir names, same as
242
+ * task_store.py).
243
+ */
244
+ function getBootstrapChecklistItems(projectType, packages) {
245
+ if (packages && packages.length > 0) {
246
+ const items = packages.map((pkg) => `Fill guidelines for ${pkg.name}`);
247
+ items.push("Add code examples");
248
+ return items;
249
+ }
250
+ if (projectType === "frontend") {
251
+ return ["Fill frontend guidelines", "Add code examples"];
252
+ }
253
+ if (projectType === "backend") {
254
+ return ["Fill backend guidelines", "Add code examples"];
255
+ }
256
+ return [
257
+ "Fill backend guidelines",
258
+ "Fill frontend guidelines",
259
+ "Add code examples",
260
+ ];
261
+ }
262
+ function getBootstrapRelatedFiles(projectType, packages) {
263
+ if (packages && packages.length > 0) {
264
+ return packages.map((pkg) => `.trellis/spec/${sanitizePkgName(pkg.name)}/`);
265
+ }
266
+ if (projectType === "frontend") {
267
+ return [".trellis/spec/frontend/"];
268
+ }
269
+ if (projectType === "backend") {
270
+ return [".trellis/spec/backend/"];
271
+ }
272
+ return [".trellis/spec/backend/", ".trellis/spec/frontend/"];
273
+ }
274
+ function getBootstrapPrdContent(projectType, pythonCmd, packages) {
275
+ const checklistItems = getBootstrapChecklistItems(projectType, packages);
276
+ const checklistMarkdown = checklistItems
277
+ .map((item) => `- [ ] ${item}`)
278
+ .join("\n");
279
+ const header = `# Bootstrap Task: Fill Project Development Guidelines
280
+
281
+ **You (the AI) are running this task. The developer does not read this file.**
282
+
283
+ The developer just ran \`trellis init\` on this project for the first time.
284
+ \`.trellis/\` now exists with empty spec scaffolding, and this bootstrap task
285
+ exists under \`.trellis/tasks/\`. When they want to work on it, they should start
286
+ this task from a session that provides Trellis session identity.
287
+
288
+ **Your job**: help them populate \`.trellis/spec/\` with the team's real
289
+ coding conventions. Every future AI session — this project's
290
+ \`trellis-implement\` and \`trellis-check\` sub-agents — auto-loads spec files
291
+ listed in per-task jsonl manifests. Empty spec = sub-agents write generic
292
+ code. Real spec = sub-agents match the team's actual patterns.
293
+
294
+ Don't dump instructions. Open with a short greeting, figure out if the repo
295
+ has any existing convention docs (CLAUDE.md, .cursorrules, etc.), and drive
296
+ the rest conversationally.
297
+
298
+ ---
299
+
300
+ ## Status (update the checkboxes as you complete each item)
301
+
302
+ ${checklistMarkdown}
303
+
304
+ ---
305
+
306
+ ## Spec files to populate
307
+ `;
308
+ const backendSection = `
309
+
310
+ ### Backend guidelines
311
+
312
+ | File | What to document |
313
+ |------|------------------|
314
+ | \`.trellis/spec/backend/directory-structure.md\` | Where different file types go (routes, services, utils) |
315
+ | \`.trellis/spec/backend/database-guidelines.md\` | ORM, migrations, query patterns, naming conventions |
316
+ | \`.trellis/spec/backend/error-handling.md\` | How errors are caught, logged, and returned |
317
+ | \`.trellis/spec/backend/logging-guidelines.md\` | Log levels, format, what to log |
318
+ | \`.trellis/spec/backend/quality-guidelines.md\` | Code review standards, testing requirements |
319
+ `;
320
+ const frontendSection = `
321
+
322
+ ### Frontend guidelines
323
+
324
+ | File | What to document |
325
+ |------|------------------|
326
+ | \`.trellis/spec/frontend/directory-structure.md\` | Component/page/hook organization |
327
+ | \`.trellis/spec/frontend/component-guidelines.md\` | Component patterns, props conventions |
328
+ | \`.trellis/spec/frontend/hook-guidelines.md\` | Custom hook naming, patterns |
329
+ | \`.trellis/spec/frontend/state-management.md\` | State library, patterns, what goes where |
330
+ | \`.trellis/spec/frontend/type-safety.md\` | TypeScript conventions, type organization |
331
+ | \`.trellis/spec/frontend/quality-guidelines.md\` | Linting, testing, accessibility |
332
+ `;
333
+ const footer = `
334
+
335
+ ### Thinking guides (already populated)
336
+
337
+ \`.trellis/spec/guides/\` contains general thinking guides pre-filled with
338
+ best practices. Customize only if something clearly doesn't fit this project.
339
+
340
+ ---
341
+
342
+ ## How to fill the spec
343
+
344
+ ### Step 1: Import from existing convention files first (preferred)
345
+
346
+ Search the repo for existing convention docs. If any exist, read them and
347
+ extract the relevant rules into the matching \`.trellis/spec/\` files —
348
+ usually much faster than documenting from scratch.
349
+
350
+ | File / Directory | Tool |
351
+ |------|------|
352
+ | \`CLAUDE.md\` / \`CLAUDE.local.md\` | Claude Code |
353
+ | \`AGENTS.md\` | Codex / Claude Code / agent-compatible tools |
354
+ | \`.cursorrules\` | Cursor |
355
+ | \`.cursor/rules/*.mdc\` | Cursor (rules directory) |
356
+ | \`.windsurfrules\` | Windsurf |
357
+ | \`.clinerules\` | Cline |
358
+ | \`.roomodes\` | Roo Code |
359
+ | \`.github/copilot-instructions.md\` | GitHub Copilot |
360
+ | \`.vscode/settings.json\` → \`github.copilot.chat.codeGeneration.instructions\` | VS Code Copilot |
361
+ | \`CONVENTIONS.md\` / \`.aider.conf.yml\` | aider |
362
+ | \`CONTRIBUTING.md\` | General project conventions |
363
+ | \`.editorconfig\` | Editor formatting rules |
364
+
365
+ ### Step 2: Analyze the codebase for anything not covered by existing docs
366
+
367
+ Scan real code to discover patterns. Before writing each spec file:
368
+ - Find 2-3 real examples of each pattern in the codebase.
369
+ - Reference real file paths (not hypothetical ones).
370
+ - Document anti-patterns the team clearly avoids.
371
+
372
+ ### Step 3: Document reality, not ideals
373
+
374
+ **Critical**: write what the code *actually does*, not what it should do.
375
+ Sub-agents match the spec, so aspirational patterns that don't exist in the
376
+ codebase will cause sub-agents to write code that looks out of place.
377
+
378
+ If the team has known tech debt, document the current state — improvement
379
+ is a separate conversation, not a bootstrap concern.
380
+
381
+ ---
382
+
383
+ ## Quick explainer of the runtime (share when they ask "why do we need spec at all")
384
+
385
+ - Every AI coding task spawns two sub-agents: \`trellis-implement\` (writes
386
+ code) and \`trellis-check\` (verifies quality).
387
+ - Each task has \`implement.jsonl\` / \`check.jsonl\` manifests listing which
388
+ spec files to load.
389
+ - The platform hook auto-injects those spec files + the task's \`prd.md\`
390
+ into every sub-agent prompt, so the sub-agent codes/reviews per team
391
+ conventions without anyone pasting them manually.
392
+ - Source of truth: \`.trellis/spec/\`. That's why filling it well now pays
393
+ off forever.
394
+
395
+ ---
396
+
397
+ ## Completion
398
+
399
+ When the developer confirms the checklist items above are done with real
400
+ examples (not placeholders), guide them to run:
401
+
402
+ \`\`\`bash
403
+ ${pythonCmd} ./.trellis/scripts/task.py finish
404
+ ${pythonCmd} ./.trellis/scripts/task.py archive 00-bootstrap-guidelines
405
+ \`\`\`
406
+
407
+ After archive, every new developer who joins this project will get a
408
+ \`00-join-<slug>\` onboarding task instead of this bootstrap task.
409
+
410
+ ---
411
+
412
+ ## Suggested opening line
413
+
414
+ "Welcome to Trellis! Your init just set me up to help you fill the project
415
+ spec — a one-time setup so every future AI session follows the team's
416
+ conventions instead of writing generic code. Before we start, do you have
417
+ any existing convention docs (CLAUDE.md, .cursorrules, CONTRIBUTING.md,
418
+ etc.) I can pull from, or should I scan the codebase from scratch?"
419
+ `;
420
+ let content = header;
421
+ if (packages && packages.length > 0) {
422
+ // Monorepo: generate per-package sections
423
+ for (const pkg of packages) {
424
+ const pkgType = pkg.type === "unknown" ? "fullstack" : pkg.type;
425
+ const specName = sanitizePkgName(pkg.name);
426
+ content += `\n### Package: ${pkg.name} (\`spec/${specName}/\`)\n`;
427
+ if (pkgType !== "frontend") {
428
+ content += `\n- Backend guidelines: \`.trellis/spec/${specName}/backend/\`\n`;
429
+ }
430
+ if (pkgType !== "backend") {
431
+ content += `\n- Frontend guidelines: \`.trellis/spec/${specName}/frontend/\`\n`;
432
+ }
433
+ }
434
+ }
435
+ else if (projectType === "frontend") {
436
+ content += frontendSection;
437
+ }
438
+ else if (projectType === "backend") {
439
+ content += backendSection;
440
+ }
441
+ else {
442
+ // fullstack
443
+ content += backendSection;
444
+ content += frontendSection;
445
+ }
446
+ content += footer;
447
+ return content;
448
+ }
449
+ function getBootstrapTaskJson(developer, projectType, packages) {
450
+ const today = new Date().toISOString().split("T")[0];
451
+ const relatedFiles = getBootstrapRelatedFiles(projectType, packages);
452
+ // Canonical 24-field shape via emptyTaskJson factory.
453
+ // Checklist items (previously stored as structured `subtasks`) are now
454
+ // rendered as `- [ ]` items in prd.md; task.json.subtasks is always
455
+ // string[] (child task dir names) per the canonical schema.
456
+ return emptyTaskJson({
457
+ id: BOOTSTRAP_TASK_NAME,
458
+ name: BOOTSTRAP_TASK_NAME,
459
+ title: "Bootstrap Guidelines",
460
+ description: "Fill in project development guidelines for AI agents",
461
+ status: "in_progress",
462
+ dev_type: "docs",
463
+ priority: "P1",
464
+ creator: developer,
465
+ assignee: developer,
466
+ createdAt: today,
467
+ relatedFiles,
468
+ notes: `First-time setup task created by trellis init (${projectType} project)`,
469
+ });
470
+ }
471
+ /**
472
+ * Create bootstrap task for first-time setup
473
+ */
474
+ function createBootstrapTask(cwd, developer, pythonCmd, projectType, packages) {
475
+ const taskJson = getBootstrapTaskJson(developer, projectType, packages);
476
+ const prdContent = getBootstrapPrdContent(projectType, pythonCmd, packages);
477
+ return writeTaskSkeleton(cwd, BOOTSTRAP_TASK_NAME, taskJson, prdContent);
478
+ }
479
+ // =============================================================================
480
+ // Joiner Onboarding Task Creation
481
+ // =============================================================================
482
+ /**
483
+ * task.json factory for joiner onboarding. Mirrors the bootstrap factory but
484
+ * uses dev_type "docs", higher priority "P1", and the developer-specific task
485
+ * name (so multiple joiners in the same checkout don't collide).
486
+ */
487
+ function getJoinerTaskJson(developer, taskName) {
488
+ const today = new Date().toISOString().split("T")[0];
489
+ return emptyTaskJson({
490
+ id: taskName,
491
+ name: taskName,
492
+ title: `Joining: Onboard to this Trellis project (${developer})`,
493
+ description: "Onboard a new developer to an existing Trellis project: learn the workflow, conventions, and find assigned work",
494
+ status: "in_progress",
495
+ dev_type: "docs",
496
+ priority: "P1",
497
+ creator: developer,
498
+ assignee: developer,
499
+ createdAt: today,
500
+ notes: "Generated by trellis init for a new developer joining an existing Trellis project",
501
+ });
502
+ }
503
+ /**
504
+ * PRD content for joiner onboarding. Kept concise (~80 lines) — deeper
505
+ * guidance lives in skills and docs.
506
+ */
507
+ function getJoinerPrdContent(developer, pythonCmd) {
508
+ const slug = slugifyDeveloperName(developer);
509
+ return `# Joiner Onboarding Task
510
+
511
+ **You (the AI) are running this task. The developer does not read this file.**
512
+
513
+ \`${developer}\` just ran \`trellis init\` on a fresh clone, saw "Developer
514
+ initialized", and will now start asking you questions in chat. This joiner task
515
+ exists under \`.trellis/tasks/\`; when they want to work on it, they should
516
+ start it from a session that provides Trellis session identity.
517
+
518
+ Your job is to orient them to Trellis. Don't dump all of this at them — open
519
+ with a short greeting, ask where they want to start, and fill in the rest as
520
+ they engage.
521
+
522
+ ---
523
+
524
+ ## Topics to cover (adapt order to their questions)
525
+
526
+ ### 1. What Trellis is + the workflow
527
+
528
+ Trellis is a workflow layer over Claude Code / Cursor / etc. that keeps AI
529
+ agents consistent with project-specific conventions instead of writing generic
530
+ code every session.
531
+
532
+ - **Three phases**: Plan (brainstorm → \`prd.md\`) → Execute (code + check) →
533
+ Finish (capture + wrap). Full reference: \`.trellis/workflow.md\`.
534
+ - **Task lifecycle**: planning → in_progress → done → archive, under
535
+ \`.trellis/tasks/\`.
536
+ - **Core slash commands**:
537
+ - \`/trellis:continue\` — resume the current session's active task
538
+ - \`/trellis:finish-work\` — wrap up a finished task
539
+ - \`/trellis:start\` — session boot from scratch (not needed here; the
540
+ SessionStart hook does its job automatically)
541
+
542
+ ### 2. Runtime mechanics (explain when they ask "how does it know what to do")
543
+
544
+ - **SessionStart hook** runs \`get_context.py\` and injects identity, git
545
+ status, session active task, active tasks, and workflow phase into the AI
546
+ conversation at every session start.
547
+ - **\`<workflow-state>\` tag** is auto-injected with every user message,
548
+ carrying the current task + phase hint.
549
+ - **\`/trellis:continue\`** loads the Phase Index, reads \`prd.md\` + recent
550
+ activity, and routes to the right skill (\`trellis-brainstorm\` for planning,
551
+ \`trellis-implement\` for coding, \`trellis-check\` for verification).
552
+ - **\`trellis-implement\` sub-agent** is spawned when code needs to be written.
553
+ The platform hook reads \`{TASK_DIR}/implement.jsonl\` and auto-injects those
554
+ spec files + \`prd.md\` into the sub-agent's prompt so it codes per project
555
+ conventions.
556
+ - **\`trellis-check\` sub-agent** follows the same pattern with \`check.jsonl\`
557
+ — reviews changes against specs, auto-fixes issues, runs lint/typecheck.
558
+
559
+ File layout (mention when they ask "where does what live"):
560
+ - \`.trellis/.runtime/sessions/<session>.json\` — session active-task state, gitignored
561
+ - \`.trellis/tasks/<task>/{implement,check}.jsonl\` — per-task context manifests
562
+ - \`.trellis/spec/\` — project-wide conventions (source of truth)
563
+ - \`.trellis/workspace/${developer}/journal-*.md\` — their session log,
564
+ rotated at ~2000 lines
565
+
566
+ ### 3. This project's actual conventions
567
+
568
+ - Summarize \`.trellis/spec/\` for them — what coding conventions this
569
+ specific team enforces.
570
+ - Point at the last 5 entries in \`.trellis/tasks/archive/\` as a rhythm
571
+ example of how people actually work here. **If archive is empty** (the
572
+ project just started), skip this — don't invent examples.
573
+ - Not your job in this onboarding to teach them the business code itself —
574
+ the README and their teammates handle that.
575
+
576
+ ### 4. Their assigned work
577
+
578
+ - Check if \`.trellis/workspace/${developer}/\` already exists — if yes, it's
579
+ their journal from another machine and worth mentioning.
580
+ - Run \`${pythonCmd} ./.trellis/scripts/task.py list --assignee ${developer}\` to
581
+ show tasks assigned to them. (Quote the name if it contains spaces.)
582
+ - Remind them that the "My Tasks" section appears in the SessionStart context
583
+ on every new session.
584
+
585
+ ---
586
+
587
+ ## Optional: walk through a small task end-to-end
588
+
589
+ If they want to practice before touching real work, offer to pick a tiny
590
+ P3 task or a typo fix and run the full cycle together: \`/trellis:continue\`
591
+ → you implement via sub-agents → \`/trellis:finish-work\`.
592
+
593
+ ---
594
+
595
+ ## Completion
596
+
597
+ When they feel oriented (or after you've covered the four topics with
598
+ reasonable back-and-forth), guide them to run:
599
+
600
+ \`\`\`bash
601
+ ${pythonCmd} ./.trellis/scripts/task.py finish
602
+ ${pythonCmd} ./.trellis/scripts/task.py archive 00-join-${slug}
603
+ \`\`\`
604
+
605
+ ---
606
+
607
+ ## Suggested opening line
608
+
609
+ "Welcome! Your \`trellis init\` set me up to onboard you to this project. I
610
+ can walk you through the workflow, show you the runtime mechanics under the
611
+ hood, summarize the team's spec, or jump to what you're already curious about
612
+ — which would you prefer?"
613
+ `;
614
+ }
615
+ /**
616
+ * Create joiner onboarding task for a new developer on an existing Trellis
617
+ * project. Task name is slugified to be filesystem-safe for arbitrary
618
+ * developer names (spaces, Unicode, punctuation).
619
+ */
620
+ function createJoinerOnboardingTask(cwd, developer, pythonCmd) {
621
+ const slug = slugifyDeveloperName(developer);
622
+ const taskName = `00-join-${slug}`;
623
+ const taskJson = getJoinerTaskJson(developer, taskName);
624
+ const prdContent = getJoinerPrdContent(developer, pythonCmd);
625
+ return writeTaskSkeleton(cwd, taskName, taskJson, prdContent);
626
+ }
627
+ /**
628
+ * Handle re-init when .trellis/ already exists.
629
+ * Returns true if handled (caller should return), false if user chose full re-init.
630
+ */
631
+ async function handleReinit(cwd, options, developerName, pythonCmd) {
632
+ const TOOLS = getInitToolChoices();
633
+ const configuredPlatforms = getConfiguredPlatforms(cwd);
634
+ const configuredNames = [...configuredPlatforms]
635
+ .map((id) => AI_TOOLS[id].name)
636
+ .join(", ");
637
+ // Determine explicit platform flags
638
+ const explicitTools = TOOLS.filter((t) => options[t.key]).map((t) => t.key);
639
+ let doAddPlatforms = explicitTools.length > 0;
640
+ let doAddDeveloper = !!options.user;
641
+ let platformsToAdd = explicitTools;
642
+ // No explicit flags → show menu
643
+ if (!doAddPlatforms && !doAddDeveloper) {
644
+ if (options.yes) {
645
+ console.log(chalk.gray(`Already initialized with: ${configuredNames}`));
646
+ console.log(chalk.gray("Use platform flags (e.g., --codex) or -u <name> to add platforms/developer."));
647
+ return true;
648
+ }
649
+ console.log(chalk.gray(`\n Already initialized with: ${configuredNames}\n`));
650
+ const { action } = await inquirer.prompt([
651
+ {
652
+ type: "list",
653
+ name: "action",
654
+ message: "Trellis is already initialized. What would you like to do?",
655
+ choices: [
656
+ { name: "Add AI platform(s)", value: "add-platform" },
657
+ {
658
+ name: "Set up developer identity on this device",
659
+ value: "add-developer",
660
+ },
661
+ { name: "Full re-initialize", value: "full" },
662
+ ],
663
+ },
664
+ ]);
665
+ if (action === "full") {
666
+ return false; // Fall through to full init
667
+ }
668
+ if (action === "add-platform")
669
+ doAddPlatforms = true;
670
+ if (action === "add-developer")
671
+ doAddDeveloper = true;
672
+ }
673
+ // --- Add platforms ---
674
+ if (doAddPlatforms) {
675
+ if (platformsToAdd.length === 0) {
676
+ // Interactive: show only unconfigured platforms
677
+ const unconfigured = TOOLS.filter((t) => {
678
+ const pid = resolveCliFlag(t.key);
679
+ return pid && !configuredPlatforms.has(pid);
680
+ });
681
+ if (unconfigured.length === 0) {
682
+ console.log(chalk.green("✓ All available platforms are already configured."));
683
+ }
684
+ else {
685
+ const answers = await inquirer.prompt([
686
+ {
687
+ type: "checkbox",
688
+ name: "tools",
689
+ message: "Select platforms to add:",
690
+ choices: unconfigured.map((t) => ({
691
+ name: t.name,
692
+ value: t.key,
693
+ })),
694
+ },
695
+ ]);
696
+ platformsToAdd = answers.tools;
697
+ }
698
+ }
699
+ // Opt-in Claude Code statusLine: only for platforms actually being added
700
+ // (already-configured ones are skipped in the loop below)
701
+ await maybePromptStatuslineOptIn(options, platformsToAdd.filter((tool) => {
702
+ const pid = resolveCliFlag(tool);
703
+ return !!pid && !configuredPlatforms.has(pid);
704
+ }));
705
+ const reinitWritten = startRecordingWrites(cwd);
706
+ try {
707
+ for (const tool of platformsToAdd) {
708
+ const platformId = resolveCliFlag(tool);
709
+ if (platformId) {
710
+ if (configuredPlatforms.has(platformId)) {
711
+ console.log(chalk.gray(` ○ ${AI_TOOLS[platformId].name} already configured, skipping`));
712
+ }
713
+ else {
714
+ console.log(chalk.blue(`📝 Configuring ${AI_TOOLS[platformId].name}...`));
715
+ await configurePlatform(platformId, cwd, {
716
+ withStatusline: options.withStatusline,
717
+ });
718
+ if (platformId === "claude-code" && options.withStatusline) {
719
+ console.log(chalk.gray(" ↳ Trellis statusLine installed (--with-statusline)"));
720
+ }
721
+ }
722
+ }
723
+ }
724
+ }
725
+ finally {
726
+ stopRecordingWrites();
727
+ }
728
+ // Update template hashes. Merge mode: preserve previously-tracked
729
+ // platforms' hashes, layer in the newly-added platform's writes.
730
+ const hashedCount = initializeHashes(cwd, {
731
+ trackedPaths: reinitWritten,
732
+ merge: true,
733
+ });
734
+ if (hashedCount > 0) {
735
+ console.log(chalk.gray(`📋 Tracking ${hashedCount} template files for updates`));
736
+ }
737
+ }
738
+ // --- Add developer ---
739
+ if (doAddDeveloper) {
740
+ let devName = developerName;
741
+ if (!devName) {
742
+ devName = await askInput("Your name: ");
743
+ while (!devName) {
744
+ console.log(chalk.yellow("Name is required"));
745
+ devName = await askInput("Your name: ");
746
+ }
747
+ }
748
+ // Capture pre-init state: if .developer did not exist before we ran
749
+ // init_developer.py, this checkout had no identity → treat as a new
750
+ // joiner onboarding onto an existing Trellis project.
751
+ const hadDeveloperFileBefore = fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW, FILE_NAMES.DEVELOPER));
752
+ try {
753
+ const scriptPath = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
754
+ execSync(`${pythonCmd} "${scriptPath}" "${devName}"`, {
755
+ cwd,
756
+ stdio: "pipe",
757
+ });
758
+ console.log(chalk.green(`✓ Developer "${devName}" initialized`));
759
+ }
760
+ catch {
761
+ console.log(chalk.yellow("⚠ Could not initialize developer. Run manually:"));
762
+ console.log(chalk.gray(` ${pythonCmd} .trellis/scripts/init_developer.py ${devName}`));
763
+ }
764
+ // Create joiner onboarding task for fresh checkouts (no prior .developer).
765
+ // Runs outside the init_developer try/catch so failures surface as warnings.
766
+ if (!hadDeveloperFileBefore) {
767
+ try {
768
+ if (!createJoinerOnboardingTask(cwd, devName, pythonCmd)) {
769
+ console.warn(chalk.yellow("⚠ Failed to create joiner onboarding task"));
770
+ }
771
+ }
772
+ catch (err) {
773
+ console.warn(chalk.yellow(`⚠ Joiner onboarding setup failed: ${err instanceof Error ? err.message : String(err)}`));
774
+ }
775
+ }
776
+ }
777
+ return true;
778
+ }
779
+ /**
780
+ * Interactive opt-in for the Claude Code statusLine when `--with-statusline`
781
+ * was not passed. Fires only when Claude Code is among the platforms about to
782
+ * be configured and never in -y mode. Mutates `options.withStatusline` so the
783
+ * configurePlatform call sites and the install hint read the same answer; the
784
+ * `!== undefined` gate doubles as the asked-once-per-run guard.
785
+ */
786
+ async function maybePromptStatuslineOptIn(options, toolKeys) {
787
+ if (options.yes || options.withStatusline !== undefined)
788
+ return;
789
+ if (!toolKeys.includes(AI_TOOLS["claude-code"].cliFlag))
790
+ return;
791
+ const answer = await inquirer.prompt([
792
+ {
793
+ type: "confirm",
794
+ name: "withStatusline",
795
+ message: "Install Trellis statusLine for Claude Code? (status bar: model, context, branch, rate limits)",
796
+ default: false,
797
+ },
798
+ ]);
799
+ options.withStatusline = answer.withStatusline;
800
+ }
801
+ const _cliFlagCheck = true;
802
+ /**
803
+ * Write monorepo package configuration to config.yaml (non-destructive patch).
804
+ * Appends packages: and default_package: without disturbing existing config.
805
+ */
806
+ function writeMonorepoConfig(cwd, packages) {
807
+ const configPath = path.join(cwd, DIR_NAMES.WORKFLOW, "config.yaml");
808
+ let content = "";
809
+ try {
810
+ content = fs.readFileSync(configPath, "utf-8");
811
+ }
812
+ catch {
813
+ // Config not created yet; will be created by createWorkflowStructure
814
+ return;
815
+ }
816
+ // Don't overwrite if packages: already exists (re-init case)
817
+ if (/^packages\s*:/m.test(content)) {
818
+ return;
819
+ }
820
+ const lines = ["\n# Auto-detected monorepo packages", "packages:"];
821
+ for (const pkg of packages) {
822
+ lines.push(` ${sanitizePkgName(pkg.name)}:`);
823
+ lines.push(` path: ${pkg.path}`);
824
+ if (pkg.isSubmodule) {
825
+ lines.push(" type: submodule");
826
+ }
827
+ else if (pkg.isGitRepo) {
828
+ lines.push(" git: true");
829
+ }
830
+ }
831
+ // Use first non-submodule package as default, fallback to first package
832
+ const defaultPkg = packages.find((p) => !p.isSubmodule)?.name ?? packages[0]?.name;
833
+ if (defaultPkg) {
834
+ lines.push(`default_package: ${defaultPkg}`);
835
+ }
836
+ fs.writeFileSync(configPath, content.trimEnd() + "\n" + lines.join("\n") + "\n", "utf-8");
837
+ }
838
+ export async function init(options) {
839
+ // Refuse to run in $HOME — running here would scoop platform runtime data
840
+ // (Claude/Codex/OpenCode session histories etc.) into the trellis hash
841
+ // manifest, and a subsequent `trellis uninstall` would wipe it.
842
+ if (isCwdHomedir() && !homedirBypassEnabled()) {
843
+ console.error(chalk.red(homedirGuardMessage("init")));
844
+ process.exit(1);
845
+ }
846
+ // Deprecated alias: --windsurf → --devin (Windsurf was renamed to Devin).
847
+ // Normalize here too so programmatic callers (not just the CLI action) map
848
+ // correctly. The CLI action prints the deprecation notice.
849
+ if (options.windsurf) {
850
+ options.devin = true;
851
+ delete options.windsurf;
852
+ }
853
+ const cwd = process.cwd();
854
+ const isFirstInit = !fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW));
855
+ // Captured here (before createWorkflowStructure + init_developer run) so
856
+ // the three-branch dispatch at the bottom can tell "fresh clone joiner"
857
+ // (.trellis/ exists, .developer missing) apart from "creator first init".
858
+ const hadDeveloperFileAtStart = fs.existsSync(path.join(cwd, DIR_NAMES.WORKFLOW, FILE_NAMES.DEVELOPER));
859
+ // Generate ASCII art banner dynamically using FIGlet "Rebel" font
860
+ const banner = figlet.textSync("Trellis", { font: "Rebel" });
861
+ console.log(chalk.cyan(`\n${banner.trimEnd()}`));
862
+ console.log(chalk.gray("\n All-in-one AI framework & toolkit for Claude Code & Cursor\n"));
863
+ // Set up proxy before any network calls
864
+ const proxyUrl = setupProxy();
865
+ if (proxyUrl) {
866
+ console.log(chalk.gray(` Using proxy: ${maskProxyUrl(proxyUrl)}\n`));
867
+ }
868
+ // Set write mode based on options
869
+ let writeMode = "ask";
870
+ if (options.force) {
871
+ writeMode = "force";
872
+ console.log(chalk.gray("Mode: Force overwrite existing files\n"));
873
+ }
874
+ else if (options.skipExisting) {
875
+ writeMode = "skip";
876
+ console.log(chalk.gray("Mode: Skip existing files\n"));
877
+ }
878
+ else if (options.yes) {
879
+ // -y implies non-interactive: never prompt on conflicts. Default to skip
880
+ // (preserve user files) — explicit --force is required to overwrite.
881
+ writeMode = "skip";
882
+ console.log(chalk.gray("Mode: Non-interactive (skip existing files)\n"));
883
+ }
884
+ setWriteMode(writeMode);
885
+ // Detect developer name from git config or options
886
+ let developerName = options.user;
887
+ if (!developerName) {
888
+ // Only detect from git if current directory is a git repo
889
+ const isGitRepo = fs.existsSync(path.join(cwd, ".git"));
890
+ if (isGitRepo) {
891
+ try {
892
+ developerName = execSync("git config user.name", {
893
+ cwd,
894
+ encoding: "utf-8",
895
+ }).trim();
896
+ }
897
+ catch {
898
+ // Git not available or no user.name configured
899
+ }
900
+ }
901
+ }
902
+ if (developerName) {
903
+ console.log(chalk.blue("👤 Developer:"), chalk.gray(developerName));
904
+ }
905
+ const { command: pythonCmd } = resolveSupportedPython();
906
+ // ==========================================================================
907
+ // Re-init fast path: skip full flow when .trellis/ already exists
908
+ // ==========================================================================
909
+ // Aborted-init recovery (issue #204): if .trellis/ exists but tasks/ is
910
+ // empty, the previous init never reached bootstrap creation. Fall through
911
+ // to the full flow so the main-dispatch tasksEmpty fallback fires —
912
+ // handleReinit's joiner branch would otherwise mis-route the recovery.
913
+ const tasksDirEarly = path.join(cwd, PATHS.TASKS);
914
+ const tasksEmptyEarly = !fs.existsSync(tasksDirEarly) || fs.readdirSync(tasksDirEarly).length === 0;
915
+ const hasTemplateRequest = !!options.template || !!options.registry;
916
+ if (!isFirstInit &&
917
+ !options.force &&
918
+ !options.skipExisting &&
919
+ !tasksEmptyEarly &&
920
+ !hasTemplateRequest) {
921
+ const reinitDone = await handleReinit(cwd, options, developerName, pythonCmd);
922
+ if (reinitDone)
923
+ return;
924
+ // reinitDone === false means user chose "full re-initialize" → fall through
925
+ }
926
+ if (!developerName && !options.yes) {
927
+ // Ask for developer name if not detected and not in yes mode
928
+ console.log(chalk.gray("\nTrellis supports team collaboration - each developer has their own\n" +
929
+ `workspace directory (${PATHS.WORKSPACE}/{name}/) to track AI sessions.\n` +
930
+ "Tip: Usually this is your git username (git config user.name).\n"));
931
+ developerName = await askInput("Your name: ");
932
+ while (!developerName) {
933
+ console.log(chalk.yellow("Name is required"));
934
+ developerName = await askInput("Your name: ");
935
+ }
936
+ console.log(chalk.blue("👤 Developer:"), chalk.gray(developerName));
937
+ }
938
+ // Detect project type (silent - no output)
939
+ const detectedType = detectProjectType(cwd);
940
+ // Parse custom registry source early (needed by both monorepo + single-repo flows)
941
+ let registry;
942
+ let registrySourceForConfig;
943
+ if (options.registry) {
944
+ try {
945
+ registry = parseRegistrySource(options.registry);
946
+ registrySourceForConfig = options.registry;
947
+ }
948
+ catch (error) {
949
+ console.log(chalk.red(error instanceof Error ? error.message : "Invalid registry source"));
950
+ return;
951
+ }
952
+ }
953
+ // Determine template strategy from flags (needed before monorepo template downloads)
954
+ let templateStrategy = "skip";
955
+ if (options.overwrite) {
956
+ templateStrategy = "overwrite";
957
+ }
958
+ else if (options.append) {
959
+ templateStrategy = "append";
960
+ }
961
+ // ==========================================================================
962
+ // Monorepo Detection
963
+ // ==========================================================================
964
+ let monorepoPackages;
965
+ let remoteSpecPackages;
966
+ if (options.monorepo !== false) {
967
+ // options.monorepo: true = --monorepo, false = --no-monorepo, undefined = auto
968
+ const detected = detectMonorepo(cwd);
969
+ if (options.monorepo === true && !detected) {
970
+ console.log(chalk.red("Error: --monorepo specified but no multi-package layout detected."));
971
+ console.log("");
972
+ console.log(chalk.gray("Checked:"));
973
+ console.log(chalk.gray(" ✗ pnpm-workspace.yaml"));
974
+ console.log(chalk.gray(" ✗ package.json workspaces"));
975
+ console.log(chalk.gray(" ✗ Cargo.toml [workspace]"));
976
+ console.log(chalk.gray(" ✗ go.work"));
977
+ console.log(chalk.gray(" ✗ pyproject.toml [tool.uv.workspace]"));
978
+ console.log(chalk.gray(" ✗ .gitmodules"));
979
+ console.log(chalk.gray(" ✗ sibling .git directories (need ≥ 2)"));
980
+ console.log("");
981
+ console.log("To configure manually, add to .trellis/config.yaml:");
982
+ console.log("");
983
+ console.log(chalk.cyan(" packages:"));
984
+ console.log(chalk.cyan(" frontend:"));
985
+ console.log(chalk.cyan(" path: ./frontend"));
986
+ console.log(chalk.cyan(" git: true # if it has its own .git"));
987
+ console.log(chalk.cyan(" backend:"));
988
+ console.log(chalk.cyan(" path: ./backend"));
989
+ console.log(chalk.cyan(" git: true"));
990
+ return;
991
+ }
992
+ if (detected && detected.length > 0) {
993
+ let enableMonorepo = false;
994
+ if (options.monorepo === true || options.yes) {
995
+ enableMonorepo = true;
996
+ }
997
+ else {
998
+ // Show detected packages and ask
999
+ console.log(chalk.blue("\n🔍 Detected monorepo packages:"));
1000
+ for (const pkg of detected) {
1001
+ const tag = pkg.isSubmodule
1002
+ ? chalk.gray(" (submodule)")
1003
+ : pkg.isGitRepo
1004
+ ? chalk.gray(" (git repo)")
1005
+ : "";
1006
+ console.log(chalk.gray(` - ${pkg.name}`) +
1007
+ chalk.gray(` (${pkg.path})`) +
1008
+ chalk.gray(` [${pkg.type}]`) +
1009
+ tag);
1010
+ }
1011
+ console.log("");
1012
+ const { useMonorepo } = await inquirer.prompt([
1013
+ {
1014
+ type: "confirm",
1015
+ name: "useMonorepo",
1016
+ message: "Enable monorepo mode?",
1017
+ default: true,
1018
+ },
1019
+ ]);
1020
+ enableMonorepo = useMonorepo;
1021
+ }
1022
+ if (enableMonorepo) {
1023
+ monorepoPackages = detected;
1024
+ remoteSpecPackages = new Set();
1025
+ // Per-package template selection (unless -y mode: all use blank spec)
1026
+ if (!options.yes && !options.template) {
1027
+ for (const pkg of detected) {
1028
+ const { specSource } = await inquirer.prompt([
1029
+ {
1030
+ type: "list",
1031
+ name: "specSource",
1032
+ message: `Spec source for ${pkg.name} (${pkg.path}):`,
1033
+ choices: [
1034
+ { name: "From scratch (Trellis default)", value: "blank" },
1035
+ { name: "Download remote template", value: "remote" },
1036
+ ],
1037
+ default: "blank",
1038
+ },
1039
+ ]);
1040
+ if (specSource === "remote") {
1041
+ // Use existing template download flow, targeting spec/<name>/
1042
+ const destDir = path.join(cwd, PATHS.SPEC, sanitizePkgName(pkg.name));
1043
+ console.log(chalk.blue(`📦 Select template for ${pkg.name}...`));
1044
+ // Fetch templates if not already done
1045
+ const templates = await fetchTemplateIndex();
1046
+ const specTemplates = templates
1047
+ .filter((t) => t.type === "spec")
1048
+ .map((t) => ({
1049
+ name: `${t.id} (${t.name})`,
1050
+ value: t.id,
1051
+ }));
1052
+ if (specTemplates.length > 0) {
1053
+ const { templateId } = await inquirer.prompt([
1054
+ {
1055
+ type: "list",
1056
+ name: "templateId",
1057
+ message: `Select template for ${pkg.name}:`,
1058
+ choices: specTemplates,
1059
+ },
1060
+ ]);
1061
+ const result = await downloadTemplateById(cwd, templateId, templateStrategy, templates.find((t) => t.id === templateId), undefined, destDir);
1062
+ if (result.success) {
1063
+ console.log(chalk.green(` ${result.message}`));
1064
+ remoteSpecPackages.add(sanitizePkgName(pkg.name));
1065
+ }
1066
+ else {
1067
+ console.log(chalk.yellow(` ${result.message}`));
1068
+ console.log(chalk.gray(" Falling back to blank spec..."));
1069
+ }
1070
+ }
1071
+ else {
1072
+ console.log(chalk.gray(" No templates available. Using blank spec."));
1073
+ }
1074
+ }
1075
+ }
1076
+ }
1077
+ else if (options.template) {
1078
+ // --template as default for all packages
1079
+ for (const pkg of detected) {
1080
+ const destDir = path.join(cwd, PATHS.SPEC, sanitizePkgName(pkg.name));
1081
+ const result = await downloadTemplateById(cwd, options.template, templateStrategy, undefined, registry, destDir);
1082
+ if (result.success && !result.skipped) {
1083
+ remoteSpecPackages.add(sanitizePkgName(pkg.name));
1084
+ }
1085
+ }
1086
+ }
1087
+ }
1088
+ }
1089
+ }
1090
+ // Tool definitions derived from platform registry
1091
+ const TOOLS = getInitToolChoices();
1092
+ // Build tools from explicit flags
1093
+ const explicitTools = TOOLS.filter((t) => options[t.key]).map((t) => t.key);
1094
+ let tools;
1095
+ if (explicitTools.length > 0) {
1096
+ // Explicit flags take precedence (works with or without -y)
1097
+ tools = explicitTools;
1098
+ }
1099
+ else if (options.yes) {
1100
+ // No explicit tools + -y: default to Cursor and Claude
1101
+ tools = TOOLS.filter((t) => t.defaultChecked).map((t) => t.key);
1102
+ }
1103
+ else {
1104
+ // Interactive mode
1105
+ const answers = await inquirer.prompt([
1106
+ {
1107
+ type: "checkbox",
1108
+ name: "tools",
1109
+ message: "Select AI tools to configure:",
1110
+ choices: TOOLS.map((t) => ({
1111
+ name: t.name,
1112
+ value: t.key,
1113
+ checked: t.defaultChecked,
1114
+ })),
1115
+ },
1116
+ ]);
1117
+ tools = answers.tools;
1118
+ }
1119
+ // Treat unknown project type as fullstack
1120
+ const projectType = detectedType === "unknown" ? "fullstack" : detectedType;
1121
+ if (tools.length === 0) {
1122
+ console.log(chalk.yellow("No tools selected. At least one tool is required."));
1123
+ return;
1124
+ }
1125
+ // Opt-in Claude Code statusLine: confirm interactively when the flag wasn't passed
1126
+ await maybePromptStatuslineOptIn(options, tools);
1127
+ // ==========================================================================
1128
+ // Template Selection (single-repo only; monorepo handles templates above)
1129
+ // ==========================================================================
1130
+ let selectedTemplate = null;
1131
+ // Pre-fetched templates list (used to pass selected SpecTemplate to downloadTemplateById)
1132
+ let fetchedTemplates = [];
1133
+ let registryBackend;
1134
+ // Determine the index URL based on registry
1135
+ const indexUrl = registry
1136
+ ? `${registry.rawBaseUrl}/index.json`
1137
+ : TEMPLATE_INDEX_URL;
1138
+ if (monorepoPackages) {
1139
+ // Monorepo: template selection already handled above
1140
+ }
1141
+ else if (options.template) {
1142
+ // Template specified via --template flag
1143
+ selectedTemplate = options.template;
1144
+ if (registry) {
1145
+ const probeResult = await probeRegistryIndex(indexUrl, registry);
1146
+ registryBackend = probeResult.backend;
1147
+ if (probeResult.error) {
1148
+ console.log(chalk.red(`Error: ${probeResult.error.message}`));
1149
+ return;
1150
+ }
1151
+ if (probeResult.isNotFound) {
1152
+ console.log(chalk.red("Error: Registry has no index.json. Remove --template to use direct download mode."));
1153
+ return;
1154
+ }
1155
+ fetchedTemplates = probeResult.templates;
1156
+ }
1157
+ }
1158
+ else if (!options.yes) {
1159
+ // Interactive mode: show template selection
1160
+ const timeoutSec = TIMEOUTS.INDEX_FETCH_MS / 1000;
1161
+ const sourceLabel = registry ? registry.gigetSource : TEMPLATE_INDEX_URL;
1162
+ console.log(chalk.gray(` Fetching available templates from ${sourceLabel}`));
1163
+ let elapsed = 0;
1164
+ const ticker = setInterval(() => {
1165
+ elapsed++;
1166
+ process.stdout.write(`\r${chalk.gray(` Loading... ${elapsed}s/${timeoutSec}s`)}`);
1167
+ }, 1000);
1168
+ process.stdout.write(chalk.gray(` Loading... 0s/${timeoutSec}s`));
1169
+ let templates;
1170
+ let registryProbeNotFound = false;
1171
+ let registryProbeError;
1172
+ if (registry) {
1173
+ const probeResult = await probeRegistryIndex(indexUrl, registry);
1174
+ templates = probeResult.templates;
1175
+ registryProbeNotFound = probeResult.isNotFound;
1176
+ registryProbeError = probeResult.error;
1177
+ registryBackend = probeResult.backend;
1178
+ }
1179
+ else {
1180
+ templates = await fetchTemplateIndex(indexUrl);
1181
+ }
1182
+ clearInterval(ticker);
1183
+ // Clear the loading line
1184
+ process.stdout.write("\r\x1b[2K");
1185
+ fetchedTemplates = templates;
1186
+ if (templates.length === 0 && registry && registryProbeNotFound) {
1187
+ // Custom registry: confirmed no index.json — will try direct download later
1188
+ console.log(chalk.gray(" No index.json found at registry. Will download as direct spec template."));
1189
+ }
1190
+ else if (templates.length === 0 && registry) {
1191
+ // Custom registry: transient error (not a 404) — abort, don't misclassify
1192
+ console.log(chalk.red(` ${registryProbeError?.message ?? "Could not reach registry. Check your connection and try again."}`));
1193
+ return;
1194
+ }
1195
+ else if (templates.length === 0) {
1196
+ console.log(chalk.gray(" Could not fetch templates (offline or server unavailable)."));
1197
+ console.log(chalk.gray(" Using blank templates.\n"));
1198
+ }
1199
+ if (templates.length > 0) {
1200
+ // Build template choices
1201
+ const specTemplates = templates
1202
+ .filter((t) => t.type === "spec")
1203
+ .map((t) => ({
1204
+ name: `${t.id} (${t.name})`,
1205
+ value: t.id,
1206
+ }));
1207
+ const templateChoices = registry
1208
+ ? specTemplates
1209
+ : [
1210
+ {
1211
+ name: "from scratch (default)",
1212
+ value: "blank",
1213
+ },
1214
+ ...specTemplates,
1215
+ {
1216
+ name: "custom (enter a registry source)",
1217
+ value: "__custom__",
1218
+ },
1219
+ ];
1220
+ // Loop to allow returning from custom source input back to the picker
1221
+ let templatePicked = false;
1222
+ while (templateChoices.length > 0 && !templatePicked) {
1223
+ const templateAnswer = await inquirer.prompt([
1224
+ {
1225
+ type: "list",
1226
+ name: "template",
1227
+ message: "Select a spec template:",
1228
+ choices: templateChoices,
1229
+ default: registry ? undefined : "blank",
1230
+ },
1231
+ ]);
1232
+ if (templateAnswer.template === "__custom__") {
1233
+ // Prompt for custom registry source (empty → back to picker)
1234
+ const customSource = await askInput("Enter registry source (e.g., gh:myorg/myrepo/specs), or press Enter to go back: ");
1235
+ if (!customSource) {
1236
+ continue; // Back to picker
1237
+ }
1238
+ try {
1239
+ registry = parseRegistrySource(customSource);
1240
+ registrySourceForConfig = customSource;
1241
+ fetchedTemplates = []; // Reset so direct-download guard works correctly
1242
+ // Probe index.json to detect marketplace vs direct download
1243
+ const customIndexUrl = `${registry.rawBaseUrl}/index.json`;
1244
+ console.log(chalk.gray(` Checking for templates at ${registry.gigetSource}...`));
1245
+ const customProbe = await probeRegistryIndex(customIndexUrl, registry);
1246
+ const customTemplates = customProbe.templates;
1247
+ registryBackend = customProbe.backend;
1248
+ if (customTemplates.length > 0) {
1249
+ // Marketplace mode: show picker with custom templates
1250
+ fetchedTemplates = customTemplates;
1251
+ const customChoices = customTemplates
1252
+ .filter((t) => t.type === "spec")
1253
+ .map((t) => ({
1254
+ name: `${t.id} (${t.name})`,
1255
+ value: t.id,
1256
+ }));
1257
+ if (customChoices.length > 0) {
1258
+ const customAnswer = await inquirer.prompt([
1259
+ {
1260
+ type: "list",
1261
+ name: "template",
1262
+ message: "Select a spec template:",
1263
+ choices: customChoices,
1264
+ },
1265
+ ]);
1266
+ selectedTemplate = customAnswer.template;
1267
+ // Check if spec directory already exists and ask what to do
1268
+ const specDir = path.join(cwd, PATHS.SPEC);
1269
+ if (fs.existsSync(specDir) &&
1270
+ !options.overwrite &&
1271
+ !options.append) {
1272
+ const actionAnswer = await inquirer.prompt([
1273
+ {
1274
+ type: "list",
1275
+ name: "action",
1276
+ message: `Directory ${PATHS.SPEC} already exists. What do you want to do?`,
1277
+ choices: [
1278
+ { name: "Skip (keep existing)", value: "skip" },
1279
+ {
1280
+ name: "Overwrite (replace all)",
1281
+ value: "overwrite",
1282
+ },
1283
+ {
1284
+ name: "Append (add missing files only)",
1285
+ value: "append",
1286
+ },
1287
+ ],
1288
+ default: "skip",
1289
+ },
1290
+ ]);
1291
+ templateStrategy = actionAnswer.action;
1292
+ }
1293
+ }
1294
+ templatePicked = true;
1295
+ }
1296
+ else if (customProbe.isNotFound) {
1297
+ // No index.json → direct download mode
1298
+ templatePicked = true;
1299
+ }
1300
+ else {
1301
+ // Transient error (not 404) — loop back, don't misclassify
1302
+ console.log(chalk.yellow(` ${customProbe.error?.message ?? "Could not reach registry. Try again or enter a different source."}`));
1303
+ registry = undefined; // Reset so we don't fall through to direct download
1304
+ registrySourceForConfig = undefined;
1305
+ }
1306
+ }
1307
+ catch (error) {
1308
+ console.log(chalk.red(error instanceof Error
1309
+ ? error.message
1310
+ : "Invalid registry source"));
1311
+ // Loop back to picker
1312
+ }
1313
+ }
1314
+ else {
1315
+ templatePicked = true;
1316
+ if (templateAnswer.template !== "blank") {
1317
+ selectedTemplate = templateAnswer.template;
1318
+ // Check if spec directory already exists and ask what to do
1319
+ const specDir = path.join(cwd, PATHS.SPEC);
1320
+ if (fs.existsSync(specDir) &&
1321
+ !options.overwrite &&
1322
+ !options.append) {
1323
+ const actionAnswer = await inquirer.prompt([
1324
+ {
1325
+ type: "list",
1326
+ name: "action",
1327
+ message: `Directory ${PATHS.SPEC} already exists. What do you want to do?`,
1328
+ choices: [
1329
+ { name: "Skip (keep existing)", value: "skip" },
1330
+ { name: "Overwrite (replace all)", value: "overwrite" },
1331
+ {
1332
+ name: "Append (add missing files only)",
1333
+ value: "append",
1334
+ },
1335
+ ],
1336
+ default: "skip",
1337
+ },
1338
+ ]);
1339
+ templateStrategy = actionAnswer.action;
1340
+ }
1341
+ }
1342
+ }
1343
+ }
1344
+ }
1345
+ }
1346
+ // -y mode with --registry (no --template): probe index.json to detect mode
1347
+ // Skip when monorepo mode already handled templates above
1348
+ if (options.yes && registry && !selectedTemplate && !monorepoPackages) {
1349
+ const probeResult = await probeRegistryIndex(`${registry.rawBaseUrl}/index.json`, registry);
1350
+ registryBackend = probeResult.backend;
1351
+ if (probeResult.templates.length > 0) {
1352
+ // Marketplace mode requires interactive selection — can't auto-select
1353
+ console.log(chalk.red("Error: Registry is a marketplace with multiple templates. " +
1354
+ "Use --template <id> to specify which one, or remove -y for interactive selection."));
1355
+ return;
1356
+ }
1357
+ if (!probeResult.isNotFound) {
1358
+ // Transient error (not 404) — abort, don't misclassify as direct-download
1359
+ console.log(chalk.red(`Error: ${probeResult.error?.message ?? "Could not reach registry. Check your connection and try again."}`));
1360
+ return;
1361
+ }
1362
+ // isNotFound=true → no index.json, proceed with direct download (fetchedTemplates stays empty)
1363
+ }
1364
+ // ==========================================================================
1365
+ // Download Remote Template (if selected or direct registry download)
1366
+ // ==========================================================================
1367
+ let useRemoteTemplate = false;
1368
+ let registrySpecConfigToPersist = null;
1369
+ if (selectedTemplate) {
1370
+ // Marketplace mode: download specific template by ID
1371
+ console.log(chalk.blue(`📦 Downloading template "${selectedTemplate}"...`));
1372
+ console.log(chalk.gray(" This may take a moment on slow connections."));
1373
+ // Find pre-fetched SpecTemplate to avoid double-fetch
1374
+ const prefetched = fetchedTemplates.find((t) => t.id === selectedTemplate);
1375
+ const result = await downloadTemplateById(cwd, selectedTemplate, templateStrategy, prefetched, registry, undefined, registryBackend);
1376
+ if (result.success) {
1377
+ if (result.skipped) {
1378
+ console.log(chalk.gray(` ${result.message}`));
1379
+ }
1380
+ else {
1381
+ console.log(chalk.green(` ${result.message}`));
1382
+ useRemoteTemplate = true;
1383
+ if (registry) {
1384
+ registrySpecConfigToPersist = {
1385
+ source: registrySourceForConfig ?? registry.gigetSource,
1386
+ template: selectedTemplate,
1387
+ };
1388
+ }
1389
+ }
1390
+ }
1391
+ else {
1392
+ console.log(chalk.yellow(` ${result.message}`));
1393
+ console.log(chalk.gray(" Falling back to blank templates..."));
1394
+ const retryCmd = registry
1395
+ ? `trellis init --registry ${registry.gigetSource} --template ${selectedTemplate}`
1396
+ : `trellis init --template ${selectedTemplate}`;
1397
+ console.log(chalk.gray(` You can retry later: ${retryCmd}`));
1398
+ }
1399
+ }
1400
+ else if (registry && fetchedTemplates.length === 0) {
1401
+ // Direct download mode: registry has no index.json, download directory directly
1402
+ console.log(chalk.blue(`📦 Downloading spec from ${registry.gigetSource}...`));
1403
+ console.log(chalk.gray(" This may take a moment on slow connections."));
1404
+ // Ask about existing spec dir in interactive mode
1405
+ if (!options.yes && !options.overwrite && !options.append) {
1406
+ const specDir = path.join(cwd, PATHS.SPEC);
1407
+ if (fs.existsSync(specDir)) {
1408
+ const actionAnswer = await inquirer.prompt([
1409
+ {
1410
+ type: "list",
1411
+ name: "action",
1412
+ message: `Directory ${PATHS.SPEC} already exists. What do you want to do?`,
1413
+ choices: [
1414
+ { name: "Skip (keep existing)", value: "skip" },
1415
+ { name: "Overwrite (replace all)", value: "overwrite" },
1416
+ { name: "Append (add missing files only)", value: "append" },
1417
+ ],
1418
+ default: "skip",
1419
+ },
1420
+ ]);
1421
+ templateStrategy = actionAnswer.action;
1422
+ }
1423
+ }
1424
+ const result = await downloadRegistryDirect(cwd, registry, templateStrategy, undefined, registryBackend);
1425
+ if (result.success) {
1426
+ if (result.skipped) {
1427
+ console.log(chalk.gray(` ${result.message}`));
1428
+ }
1429
+ else {
1430
+ console.log(chalk.green(` ${result.message}`));
1431
+ useRemoteTemplate = true;
1432
+ registrySpecConfigToPersist = {
1433
+ source: registrySourceForConfig ?? registry.gigetSource,
1434
+ };
1435
+ }
1436
+ }
1437
+ else {
1438
+ console.log(chalk.yellow(` ${result.message}`));
1439
+ console.log(chalk.gray(" Falling back to blank templates..."));
1440
+ console.log(chalk.gray(` You can retry later: trellis init --registry ${registry.gigetSource}`));
1441
+ }
1442
+ }
1443
+ // ==========================================================================
1444
+ // Resolve workflow template (default: native bundled)
1445
+ // ==========================================================================
1446
+ const workflowIdInput = options.workflow?.trim();
1447
+ const workflowId = workflowIdInput && workflowIdInput.length > 0
1448
+ ? workflowIdInput
1449
+ : NATIVE_WORKFLOW_ID;
1450
+ let workflowMdOverride;
1451
+ if (workflowId !== NATIVE_WORKFLOW_ID || options.workflowSource) {
1452
+ const resolved = await resolveWorkflowTemplate(workflowId, {
1453
+ source: options.workflowSource,
1454
+ });
1455
+ if (resolved.id !== NATIVE_WORKFLOW_ID) {
1456
+ workflowMdOverride = resolved.content;
1457
+ console.log(chalk.blue(`🧭 Using workflow template: ${chalk.cyan(resolved.id)}`));
1458
+ }
1459
+ }
1460
+ // ==========================================================================
1461
+ // Create Workflow Structure
1462
+ // ==========================================================================
1463
+ // Record every successful write from here through createRootFiles. The
1464
+ // captured set is the source of truth for `.template-hashes.json`'s
1465
+ // platform/root entries — replacing the previous "walk every managed dir"
1466
+ // approach that swept user-owned runtime files into the manifest
1467
+ // (.codex/sessions/, .claude/projects/, pre-existing AGENTS.md).
1468
+ const writtenPaths = startRecordingWrites(cwd);
1469
+ try {
1470
+ // Create workflow structure with project type
1471
+ console.log(chalk.blue("📁 Creating workflow structure..."));
1472
+ await createWorkflowStructure(cwd, {
1473
+ projectType,
1474
+ skipSpecTemplates: useRemoteTemplate,
1475
+ packages: monorepoPackages,
1476
+ remoteSpecPackages,
1477
+ workflowMdOverride,
1478
+ });
1479
+ // Write monorepo packages to config.yaml (non-destructive patch)
1480
+ if (monorepoPackages) {
1481
+ writeMonorepoConfig(cwd, monorepoPackages);
1482
+ console.log(chalk.blue("📦 Monorepo packages written to config.yaml"));
1483
+ }
1484
+ // Write version file for update tracking
1485
+ const versionPath = path.join(cwd, DIR_NAMES.WORKFLOW, ".version");
1486
+ fs.writeFileSync(versionPath, VERSION);
1487
+ // Configure selected tools by copying entire directories (dogfooding)
1488
+ for (const tool of tools) {
1489
+ const platformId = resolveCliFlag(tool);
1490
+ if (platformId) {
1491
+ console.log(chalk.blue(`📝 Configuring ${AI_TOOLS[platformId].name}...`));
1492
+ await configurePlatform(platformId, cwd, {
1493
+ withStatusline: options.withStatusline,
1494
+ });
1495
+ if (platformId === "claude-code" && options.withStatusline) {
1496
+ console.log(chalk.gray(" ↳ Trellis statusLine installed (--with-statusline)"));
1497
+ }
1498
+ }
1499
+ }
1500
+ const pythonPlatforms = getPlatformsWithPythonHooks();
1501
+ const hasSelectedPythonPlatform = pythonPlatforms.some((id) => tools.includes(AI_TOOLS[id].cliFlag));
1502
+ if (hasSelectedPythonPlatform) {
1503
+ logPythonAdaptationNotice(pythonCmd);
1504
+ }
1505
+ // Create root files (skip if exists)
1506
+ await createRootFiles(cwd);
1507
+ }
1508
+ finally {
1509
+ stopRecordingWrites();
1510
+ }
1511
+ if (registrySpecConfigToPersist) {
1512
+ writeSpecRegistryConfig(cwd, registrySpecConfigToPersist);
1513
+ }
1514
+ // Initialize template hashes for modification tracking
1515
+ const hashedCount = initializeHashes(cwd, { trackedPaths: writtenPaths });
1516
+ if (useRemoteTemplate) {
1517
+ const specFilesToHash = new Map();
1518
+ for (const relativePath of collectSpecPaths(cwd)) {
1519
+ const content = fs.readFileSync(path.join(cwd, relativePath), "utf-8");
1520
+ specFilesToHash.set(relativePath, content);
1521
+ }
1522
+ if (specFilesToHash.size > 0) {
1523
+ updateHashes(cwd, specFilesToHash);
1524
+ }
1525
+ }
1526
+ if (hashedCount > 0) {
1527
+ console.log(chalk.gray(`📋 Tracking ${hashedCount} template files for updates`));
1528
+ }
1529
+ // Non-native workflow is user-managed local content. Drop the
1530
+ // `.trellis/workflow.md` hash entry so `trellis update` classifies it as
1531
+ // modified and does not silently restore native bytes. See design.md
1532
+ // "Durable-state contract".
1533
+ if (workflowMdOverride !== undefined && workflowId !== NATIVE_WORKFLOW_ID) {
1534
+ removeHash(cwd, PATHS.WORKFLOW_GUIDE_FILE);
1535
+ }
1536
+ // Initialize developer identity (silent - no output)
1537
+ if (developerName) {
1538
+ try {
1539
+ const scriptPath = path.join(cwd, PATHS.SCRIPTS, "init_developer.py");
1540
+ execSync(`${pythonCmd} "${scriptPath}" "${developerName}"`, {
1541
+ cwd,
1542
+ stdio: "pipe", // Silent
1543
+ });
1544
+ }
1545
+ catch {
1546
+ // Silent failure - user can run init_developer.py manually
1547
+ }
1548
+ // Three-branch dispatch using flags captured at init() start (before
1549
+ // createWorkflowStructure/init_developer ran, so they reflect the disk
1550
+ // state of the user's checkout, not the state this init just produced):
1551
+ // isFirstInit=true → creator bootstrap (new project)
1552
+ // isFirstInit=false + no .developer file → joiner onboarding (fresh clone)
1553
+ // isFirstInit=false + .developer exists → same-dev re-init, no task
1554
+ //
1555
+ // Tasks-empty fallback (issue #204): if .trellis/ exists but tasks dir is
1556
+ // empty, the previous init aborted before creating the bootstrap task. Run
1557
+ // bootstrap creation regardless of isFirstInit. writeTaskSkeleton is
1558
+ // idempotent so repeated triggers are safe.
1559
+ //
1560
+ // Runs OUTSIDE the init_developer try/catch (which uses stdio: "pipe")
1561
+ // so joiner failures surface as warnings instead of being silently
1562
+ // swallowed.
1563
+ const tasksDir = path.join(cwd, PATHS.TASKS);
1564
+ const tasksEmpty = !fs.existsSync(tasksDir) || fs.readdirSync(tasksDir).length === 0;
1565
+ if (isFirstInit || tasksEmpty) {
1566
+ createBootstrapTask(cwd, developerName, pythonCmd, projectType, monorepoPackages);
1567
+ }
1568
+ else if (!hadDeveloperFileAtStart) {
1569
+ try {
1570
+ if (!createJoinerOnboardingTask(cwd, developerName, pythonCmd)) {
1571
+ console.warn(chalk.yellow("⚠ Failed to create joiner onboarding task"));
1572
+ }
1573
+ }
1574
+ catch (err) {
1575
+ console.warn(chalk.yellow(`⚠ Joiner onboarding setup failed: ${err instanceof Error ? err.message : String(err)}`));
1576
+ }
1577
+ }
1578
+ }
1579
+ }
1580
+ /**
1581
+ * Simple readline-based input (no flickering like inquirer)
1582
+ */
1583
+ function askInput(prompt) {
1584
+ const rl = readline.createInterface({
1585
+ input: process.stdin,
1586
+ output: process.stdout,
1587
+ });
1588
+ return new Promise((resolve) => {
1589
+ rl.question(prompt, (answer) => {
1590
+ rl.close();
1591
+ resolve(answer.trim());
1592
+ });
1593
+ });
1594
+ }
1595
+ async function createRootFiles(cwd) {
1596
+ const agentsPath = path.join(cwd, FILE_NAMES.AGENTS);
1597
+ // Write AGENTS.md from template
1598
+ const agentsWritten = await writeFile(agentsPath, agentsMdContent);
1599
+ if (agentsWritten) {
1600
+ console.log(chalk.blue("📄 Created AGENTS.md"));
1601
+ }
1602
+ }
1603
+ //# sourceMappingURL=init.js.map