@mudssky/trellis 0.6.16-mudssky.5

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