@blxzer/cursor-trellis 0.1.0

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