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