@mengde1231/rudder 0.5.13

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