@iloom/cli 0.10.1 → 0.11.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 (262) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -2
  3. package/dist/{BranchNamingService-25KSZAEM.js → BranchNamingService-XBCO747L.js} +4 -4
  4. package/dist/ClaudeContextManager-SXDCWDJA.js +14 -0
  5. package/dist/ClaudeService-6E6MCGJE.js +13 -0
  6. package/dist/GitHubService-2R5GQG4K.js +12 -0
  7. package/dist/IssueTrackerFactory-XN6MQ4UN.js +14 -0
  8. package/dist/{LoomLauncher-TDLZSYG2.js → LoomLauncher-5AZU2F5I.js} +15 -12
  9. package/dist/LoomLauncher-5AZU2F5I.js.map +1 -0
  10. package/dist/MetadataManager-CMQQTFLQ.js +10 -0
  11. package/dist/ProjectCapabilityDetector-IC6NAFGY.js +11 -0
  12. package/dist/{PromptTemplateManager-YOE2SIPG.js → PromptTemplateManager-T5VTLJP3.js} +3 -3
  13. package/dist/README.md +4 -2
  14. package/dist/{SettingsManager-FNKCOZMQ.js → SettingsManager-WQ5NSGAH.js} +3 -3
  15. package/dist/SettingsMigrationManager-S6J7OHUH.js +10 -0
  16. package/dist/agents/iloom-code-reviewer.md +50 -8
  17. package/dist/agents/iloom-issue-analyze-and-plan.md +10 -0
  18. package/dist/agents/iloom-issue-analyzer.md +13 -0
  19. package/dist/agents/iloom-issue-complexity-evaluator.md +8 -1
  20. package/dist/agents/iloom-issue-enhancer.md +8 -1
  21. package/dist/agents/iloom-issue-planner.md +5 -0
  22. package/dist/build-OLS6J5KZ.js +27 -0
  23. package/dist/{chunk-WWKOVDWC.js → chunk-3GTUXW26.js} +3 -3
  24. package/dist/{chunk-4FGEGQW4.js → chunk-3RXYOBME.js} +5 -5
  25. package/dist/{chunk-HEXKPKCK.js → chunk-5LTID2AF.js} +6 -6
  26. package/dist/{chunk-G5V75JD5.js → chunk-5PNZBH6V.js} +2 -2
  27. package/dist/{chunk-SKSYYBCU.js → chunk-5UFGO4ZT.js} +24 -3
  28. package/dist/{chunk-SKSYYBCU.js.map → chunk-5UFGO4ZT.js.map} +1 -1
  29. package/dist/{chunk-E6KOWMKA.js → chunk-6YVJVUR4.js} +3 -3
  30. package/dist/{chunk-RJ3VBUFK.js → chunk-7FIXNAUO.js} +36 -7
  31. package/dist/chunk-7FIXNAUO.js.map +1 -0
  32. package/dist/{chunk-QVLPWNE3.js → chunk-7NFCGKZT.js} +3 -3
  33. package/dist/{chunk-433MOLAU.js → chunk-7OCGBJLR.js} +2 -2
  34. package/dist/{chunk-KVHIAWVT.js → chunk-ABVMUNCD.js} +8 -8
  35. package/dist/{chunk-7JDMYTFZ.js → chunk-CV47VCMQ.js} +2 -2
  36. package/dist/{chunk-7VHJNVLF.js → chunk-ET6A2JR4.js} +8 -6
  37. package/dist/chunk-ET6A2JR4.js.map +1 -0
  38. package/dist/{chunk-MORRVYPT.js → chunk-G2MNSPA4.js} +2 -2
  39. package/dist/{chunk-RSYT7MVI.js → chunk-GMDSYLI6.js} +36 -3
  40. package/dist/chunk-GMDSYLI6.js.map +1 -0
  41. package/dist/{chunk-VT4PDUYT.js → chunk-H2SSF24U.js} +284 -209
  42. package/dist/chunk-H2SSF24U.js.map +1 -0
  43. package/dist/{chunk-LLHXQS3C.js → chunk-HLDY5S4C.js} +3 -3
  44. package/dist/{chunk-BYUMEDDD.js → chunk-IDCE26KD.js} +3 -3
  45. package/dist/{chunk-OTGH2HRS.js → chunk-IR74O2F6.js} +221 -88
  46. package/dist/chunk-IR74O2F6.js.map +1 -0
  47. package/dist/{chunk-O7VL5N6S.js → chunk-K7R5QY6C.js} +2 -2
  48. package/dist/{chunk-S7PZA6IV.js → chunk-KQFIGI37.js} +5 -5
  49. package/dist/{chunk-I5T677EA.js → chunk-LE2NOUTN.js} +3 -3
  50. package/dist/{chunk-KXDRI47U.js → chunk-LHDD4JHC.js} +6 -6
  51. package/dist/{chunk-5FJWO4IT.js → chunk-LL6TOX3G.js} +9 -9
  52. package/dist/{chunk-YQ57ORTV.js → chunk-NCPZYQ4B.js} +2 -2
  53. package/dist/{chunk-EWJFUFPT.js → chunk-NDSGJZI2.js} +2 -2
  54. package/dist/{chunk-VG45TUYK.js → chunk-NH3QZYE5.js} +2 -2
  55. package/dist/{chunk-KKV5WH5M.js → chunk-NN5RYWXA.js} +7 -7
  56. package/dist/chunk-NOMQ5RFG.js +118 -0
  57. package/dist/chunk-NOMQ5RFG.js.map +1 -0
  58. package/dist/{chunk-KIK2ZFAL.js → chunk-QNHZM5ZV.js} +3 -3
  59. package/dist/{chunk-EVPZFV3K.js → chunk-QR4FU53I.js} +8 -8
  60. package/dist/{chunk-FXDYIV3K.js → chunk-QVAA5KHK.js} +2 -2
  61. package/dist/{chunk-NGJZ4TOU.js → chunk-RBYTXYGD.js} +2 -2
  62. package/dist/{chunk-SWSJWA2S.js → chunk-RMLADZRY.js} +12 -9
  63. package/dist/chunk-RMLADZRY.js.map +1 -0
  64. package/dist/{chunk-CVCTIDDK.js → chunk-RVI6C2H5.js} +5 -5
  65. package/dist/{chunk-Q7POFB5Q.js → chunk-SQYHPBFP.js} +2 -2
  66. package/dist/{chunk-GRISNU6G.js → chunk-TEJAGQX2.js} +64 -40
  67. package/dist/chunk-TEJAGQX2.js.map +1 -0
  68. package/dist/{chunk-QZWEJVWV.js → chunk-TZNNJLGT.js} +6 -6
  69. package/dist/{chunk-63QWFWH3.js → chunk-UDCI3QTS.js} +2 -2
  70. package/dist/{chunk-UKBAJ2QQ.js → chunk-UHIBKD73.js} +7 -7
  71. package/dist/{chunk-WXIM2WS7.js → chunk-V4STTBQD.js} +10 -10
  72. package/dist/{chunk-P4O6EH46.js → chunk-VMZG66UV.js} +5 -5
  73. package/dist/{chunk-C6HNNJIV.js → chunk-VNYWBHKR.js} +34 -4
  74. package/dist/chunk-VNYWBHKR.js.map +1 -0
  75. package/dist/{chunk-5RPBYK5Q.js → chunk-VUUN3KE4.js} +10 -10
  76. package/dist/chunk-VUUN3KE4.js.map +1 -0
  77. package/dist/{chunk-UUEW5KWB.js → chunk-WG4MLJ6J.js} +15 -10
  78. package/dist/chunk-WG4MLJ6J.js.map +1 -0
  79. package/dist/{chunk-ZNMPGMHY.js → chunk-XFQGI2E3.js} +66 -43
  80. package/dist/chunk-XFQGI2E3.js.map +1 -0
  81. package/dist/{chunk-LUKXJSRI.js → chunk-XXFSOVL3.js} +4 -4
  82. package/dist/{chunk-UR5DGNUO.js → chunk-Y3RX7LZT.js} +11 -8
  83. package/dist/chunk-Y3RX7LZT.js.map +1 -0
  84. package/dist/{chunk-KB64WNBZ.js → chunk-YRCEOQPX.js} +4 -2
  85. package/dist/chunk-YRCEOQPX.js.map +1 -0
  86. package/dist/{chunk-6MLEBAYZ.js → chunk-ZAXRQLK3.js} +2 -2
  87. package/dist/{claude-7GGEWVEM.js → claude-ONQTDWV3.js} +4 -4
  88. package/dist/{cleanup-6PVAC4NI.js → cleanup-YOM6PQCN.js} +35 -34
  89. package/dist/{cleanup-6PVAC4NI.js.map → cleanup-YOM6PQCN.js.map} +1 -1
  90. package/dist/cli.js +235 -147
  91. package/dist/cli.js.map +1 -1
  92. package/dist/{color-4TJ4P5EY.js → color-VQD52LOI.js} +3 -3
  93. package/dist/{commit-FZR5XDQG.js → commit-DC2Q5CDY.js} +15 -15
  94. package/dist/{compile-7ALJHZ4N.js → compile-4NCQECKE.js} +11 -11
  95. package/dist/{contribute-5GKLK3BQ.js → contribute-M5UWXCAV.js} +12 -12
  96. package/dist/darwin-5BHWRJ7D.js +10 -0
  97. package/dist/{dev-server-7SMIB7OF.js → dev-server-CYRP6M73.js} +19 -19
  98. package/dist/{feedback-G2GJFN2F.js → feedback-BMAZGKRW.js} +16 -16
  99. package/dist/{git-GTLKAZRJ.js → git-BXUD6CL5.js} +6 -6
  100. package/dist/ignite-IO4LXVXJ.js +35 -0
  101. package/dist/index.d.ts +39 -65
  102. package/dist/index.js +637 -110
  103. package/dist/index.js.map +1 -1
  104. package/dist/{init-32YOKXRL.js → init-CI43GJHV.js} +17 -17
  105. package/dist/{init-32YOKXRL.js.map → init-CI43GJHV.js.map} +1 -1
  106. package/dist/install-deps-SRTM5U7D.js +43 -0
  107. package/dist/install-deps-SRTM5U7D.js.map +1 -0
  108. package/dist/{installation-detector-MMFWLJYN.js → installation-detector-HF6QN7KP.js} +3 -3
  109. package/dist/{issues-4UUAQ5K6.js → issues-DMRQJH7E.js} +15 -15
  110. package/dist/lint-BSWRMGPZ.js +27 -0
  111. package/dist/linux-RYLOP2LY.js +103 -0
  112. package/dist/linux-RYLOP2LY.js.map +1 -0
  113. package/dist/mcp/chunk-PIIRD4LO.js +373 -0
  114. package/dist/mcp/chunk-PIIRD4LO.js.map +1 -0
  115. package/dist/mcp/darwin-3JFFE3W2.js +10 -0
  116. package/dist/mcp/issue-management-server.js +23 -127
  117. package/dist/mcp/issue-management-server.js.map +1 -1
  118. package/dist/mcp/linux-JBVS4R3A.js +103 -0
  119. package/dist/mcp/linux-JBVS4R3A.js.map +1 -0
  120. package/dist/mcp/tmux-RYBLEHUZ.js +156 -0
  121. package/dist/mcp/tmux-RYBLEHUZ.js.map +1 -0
  122. package/dist/mcp/wsl-4QZIQLLE.js +78 -0
  123. package/dist/mcp/wsl-4QZIQLLE.js.map +1 -0
  124. package/dist/neon-helpers-HWIYRKOW.js +11 -0
  125. package/dist/{open-FXWW3VI4.js → open-2Y7GSUTJ.js} +19 -19
  126. package/dist/{plan-RQ5FPIGF.js → plan-SWFPLNJE.js} +47 -46
  127. package/dist/{plan-RQ5FPIGF.js.map → plan-SWFPLNJE.js.map} +1 -1
  128. package/dist/{projects-2UOXFLNZ.js → projects-IUSUXD5D.js} +6 -6
  129. package/dist/{prompt-ONNPSNKM.js → prompt-7LZB4PAT.js} +3 -3
  130. package/dist/prompts/init-prompt.txt +56 -107
  131. package/dist/prompts/issue-prompt.txt +57 -11
  132. package/dist/prompts/pr-prompt.txt +154 -4
  133. package/dist/prompts/regular-prompt.txt +20 -3
  134. package/dist/prompts/swarm-orchestrator-prompt.txt +134 -14
  135. package/dist/{rebase-6NVLX5V7.js → rebase-S6OHAOOF.js} +12 -12
  136. package/dist/{recap-OMBOKJST.js → recap-GGVCG5VH.js} +9 -9
  137. package/dist/{remote-IJAMOEAP.js → remote-MZTFHHTU.js} +3 -3
  138. package/dist/remote-MZTFHHTU.js.map +1 -0
  139. package/dist/{run-BBXLRIZB.js → run-ST3FR75O.js} +19 -19
  140. package/dist/schema/settings.schema.json +8 -49
  141. package/dist/{shell-RF7LTND5.js → shell-W4SBQPTE.js} +8 -8
  142. package/dist/{summary-WTQZ7XG2.js → summary-P2JCIIJO.js} +17 -17
  143. package/dist/test-6JH4FE2X.js +27 -0
  144. package/dist/{test-git-XM4TM65W.js → test-git-2KFFAQ6B.js} +6 -6
  145. package/dist/{test-jira-LDTOYFSD.js → test-jira-FKDKG6CD.js} +8 -8
  146. package/dist/{test-prefix-GBO37XCN.js → test-prefix-GP2DAX37.js} +11 -11
  147. package/dist/test-prefix-GP2DAX37.js.map +1 -0
  148. package/dist/{test-tabs-D3POYOJ5.js → test-tabs-YDWMWTVA.js} +3 -3
  149. package/dist/{test-webserver-NZ3JTVLL.js → test-webserver-QI3QQFZ3.js} +8 -8
  150. package/dist/tmux-7ZTA3BDI.js +156 -0
  151. package/dist/tmux-7ZTA3BDI.js.map +1 -0
  152. package/dist/{update-HJKDYA3F.js → update-XLW7R7FL.js} +4 -4
  153. package/dist/{update-notifier-LBAUOOLM.js → update-notifier-EYLAXZAA.js} +3 -3
  154. package/dist/update-notifier-EYLAXZAA.js.map +1 -0
  155. package/dist/{vscode-6XUGHJKL.js → vscode-TOGE5N67.js} +13 -13
  156. package/dist/{vscode-announcement-EQ2SKK3T.js → vscode-announcement-NIX7O2MG.js} +3 -3
  157. package/dist/wsl-Y4GUTOQ7.js +78 -0
  158. package/dist/wsl-Y4GUTOQ7.js.map +1 -0
  159. package/package.json +4 -2
  160. package/dist/ClaudeContextManager-66GR4BGM.js +0 -14
  161. package/dist/ClaudeService-7KM5NA5Z.js +0 -13
  162. package/dist/GitHubService-MEHKHUQP.js +0 -12
  163. package/dist/IssueTrackerFactory-NG53YX5S.js +0 -14
  164. package/dist/LoomLauncher-TDLZSYG2.js.map +0 -1
  165. package/dist/MetadataManager-5QZSTKNN.js +0 -10
  166. package/dist/ProjectCapabilityDetector-5KSYUTBJ.js +0 -11
  167. package/dist/SettingsMigrationManager-LEBMJP3B.js +0 -10
  168. package/dist/build-VHGEMXBA.js +0 -27
  169. package/dist/chunk-5RPBYK5Q.js.map +0 -1
  170. package/dist/chunk-7VHJNVLF.js.map +0 -1
  171. package/dist/chunk-C6HNNJIV.js.map +0 -1
  172. package/dist/chunk-GRISNU6G.js.map +0 -1
  173. package/dist/chunk-KB64WNBZ.js.map +0 -1
  174. package/dist/chunk-OTGH2HRS.js.map +0 -1
  175. package/dist/chunk-RJ3VBUFK.js.map +0 -1
  176. package/dist/chunk-RSYT7MVI.js.map +0 -1
  177. package/dist/chunk-SWSJWA2S.js.map +0 -1
  178. package/dist/chunk-UR5DGNUO.js.map +0 -1
  179. package/dist/chunk-UUEW5KWB.js.map +0 -1
  180. package/dist/chunk-VT4PDUYT.js.map +0 -1
  181. package/dist/chunk-ZNMPGMHY.js.map +0 -1
  182. package/dist/ignite-H2O5Y5A2.js +0 -34
  183. package/dist/lint-AAN2NZWG.js +0 -27
  184. package/dist/neon-helpers-CQN2PB4S.js +0 -11
  185. package/dist/test-SGO6I5Z7.js +0 -27
  186. package/dist/test-prefix-GBO37XCN.js.map +0 -1
  187. /package/dist/{BranchNamingService-25KSZAEM.js.map → BranchNamingService-XBCO747L.js.map} +0 -0
  188. /package/dist/{ClaudeContextManager-66GR4BGM.js.map → ClaudeContextManager-SXDCWDJA.js.map} +0 -0
  189. /package/dist/{ClaudeService-7KM5NA5Z.js.map → ClaudeService-6E6MCGJE.js.map} +0 -0
  190. /package/dist/{GitHubService-MEHKHUQP.js.map → GitHubService-2R5GQG4K.js.map} +0 -0
  191. /package/dist/{IssueTrackerFactory-NG53YX5S.js.map → IssueTrackerFactory-XN6MQ4UN.js.map} +0 -0
  192. /package/dist/{MetadataManager-5QZSTKNN.js.map → MetadataManager-CMQQTFLQ.js.map} +0 -0
  193. /package/dist/{ProjectCapabilityDetector-5KSYUTBJ.js.map → ProjectCapabilityDetector-IC6NAFGY.js.map} +0 -0
  194. /package/dist/{PromptTemplateManager-YOE2SIPG.js.map → PromptTemplateManager-T5VTLJP3.js.map} +0 -0
  195. /package/dist/{SettingsManager-FNKCOZMQ.js.map → SettingsManager-WQ5NSGAH.js.map} +0 -0
  196. /package/dist/{SettingsMigrationManager-LEBMJP3B.js.map → SettingsMigrationManager-S6J7OHUH.js.map} +0 -0
  197. /package/dist/{build-VHGEMXBA.js.map → build-OLS6J5KZ.js.map} +0 -0
  198. /package/dist/{chunk-WWKOVDWC.js.map → chunk-3GTUXW26.js.map} +0 -0
  199. /package/dist/{chunk-4FGEGQW4.js.map → chunk-3RXYOBME.js.map} +0 -0
  200. /package/dist/{chunk-HEXKPKCK.js.map → chunk-5LTID2AF.js.map} +0 -0
  201. /package/dist/{chunk-G5V75JD5.js.map → chunk-5PNZBH6V.js.map} +0 -0
  202. /package/dist/{chunk-E6KOWMKA.js.map → chunk-6YVJVUR4.js.map} +0 -0
  203. /package/dist/{chunk-QVLPWNE3.js.map → chunk-7NFCGKZT.js.map} +0 -0
  204. /package/dist/{chunk-433MOLAU.js.map → chunk-7OCGBJLR.js.map} +0 -0
  205. /package/dist/{chunk-KVHIAWVT.js.map → chunk-ABVMUNCD.js.map} +0 -0
  206. /package/dist/{chunk-7JDMYTFZ.js.map → chunk-CV47VCMQ.js.map} +0 -0
  207. /package/dist/{chunk-MORRVYPT.js.map → chunk-G2MNSPA4.js.map} +0 -0
  208. /package/dist/{chunk-LLHXQS3C.js.map → chunk-HLDY5S4C.js.map} +0 -0
  209. /package/dist/{chunk-BYUMEDDD.js.map → chunk-IDCE26KD.js.map} +0 -0
  210. /package/dist/{chunk-O7VL5N6S.js.map → chunk-K7R5QY6C.js.map} +0 -0
  211. /package/dist/{chunk-S7PZA6IV.js.map → chunk-KQFIGI37.js.map} +0 -0
  212. /package/dist/{chunk-I5T677EA.js.map → chunk-LE2NOUTN.js.map} +0 -0
  213. /package/dist/{chunk-KXDRI47U.js.map → chunk-LHDD4JHC.js.map} +0 -0
  214. /package/dist/{chunk-5FJWO4IT.js.map → chunk-LL6TOX3G.js.map} +0 -0
  215. /package/dist/{chunk-YQ57ORTV.js.map → chunk-NCPZYQ4B.js.map} +0 -0
  216. /package/dist/{chunk-EWJFUFPT.js.map → chunk-NDSGJZI2.js.map} +0 -0
  217. /package/dist/{chunk-VG45TUYK.js.map → chunk-NH3QZYE5.js.map} +0 -0
  218. /package/dist/{chunk-KKV5WH5M.js.map → chunk-NN5RYWXA.js.map} +0 -0
  219. /package/dist/{chunk-KIK2ZFAL.js.map → chunk-QNHZM5ZV.js.map} +0 -0
  220. /package/dist/{chunk-EVPZFV3K.js.map → chunk-QR4FU53I.js.map} +0 -0
  221. /package/dist/{chunk-FXDYIV3K.js.map → chunk-QVAA5KHK.js.map} +0 -0
  222. /package/dist/{chunk-NGJZ4TOU.js.map → chunk-RBYTXYGD.js.map} +0 -0
  223. /package/dist/{chunk-CVCTIDDK.js.map → chunk-RVI6C2H5.js.map} +0 -0
  224. /package/dist/{chunk-Q7POFB5Q.js.map → chunk-SQYHPBFP.js.map} +0 -0
  225. /package/dist/{chunk-QZWEJVWV.js.map → chunk-TZNNJLGT.js.map} +0 -0
  226. /package/dist/{chunk-63QWFWH3.js.map → chunk-UDCI3QTS.js.map} +0 -0
  227. /package/dist/{chunk-UKBAJ2QQ.js.map → chunk-UHIBKD73.js.map} +0 -0
  228. /package/dist/{chunk-WXIM2WS7.js.map → chunk-V4STTBQD.js.map} +0 -0
  229. /package/dist/{chunk-P4O6EH46.js.map → chunk-VMZG66UV.js.map} +0 -0
  230. /package/dist/{chunk-LUKXJSRI.js.map → chunk-XXFSOVL3.js.map} +0 -0
  231. /package/dist/{chunk-6MLEBAYZ.js.map → chunk-ZAXRQLK3.js.map} +0 -0
  232. /package/dist/{claude-7GGEWVEM.js.map → claude-ONQTDWV3.js.map} +0 -0
  233. /package/dist/{color-4TJ4P5EY.js.map → color-VQD52LOI.js.map} +0 -0
  234. /package/dist/{commit-FZR5XDQG.js.map → commit-DC2Q5CDY.js.map} +0 -0
  235. /package/dist/{compile-7ALJHZ4N.js.map → compile-4NCQECKE.js.map} +0 -0
  236. /package/dist/{contribute-5GKLK3BQ.js.map → contribute-M5UWXCAV.js.map} +0 -0
  237. /package/dist/{git-GTLKAZRJ.js.map → darwin-5BHWRJ7D.js.map} +0 -0
  238. /package/dist/{dev-server-7SMIB7OF.js.map → dev-server-CYRP6M73.js.map} +0 -0
  239. /package/dist/{feedback-G2GJFN2F.js.map → feedback-BMAZGKRW.js.map} +0 -0
  240. /package/dist/{ignite-H2O5Y5A2.js.map → git-BXUD6CL5.js.map} +0 -0
  241. /package/dist/{installation-detector-MMFWLJYN.js.map → ignite-IO4LXVXJ.js.map} +0 -0
  242. /package/dist/{neon-helpers-CQN2PB4S.js.map → installation-detector-HF6QN7KP.js.map} +0 -0
  243. /package/dist/{issues-4UUAQ5K6.js.map → issues-DMRQJH7E.js.map} +0 -0
  244. /package/dist/{lint-AAN2NZWG.js.map → lint-BSWRMGPZ.js.map} +0 -0
  245. /package/dist/{prompt-ONNPSNKM.js.map → mcp/darwin-3JFFE3W2.js.map} +0 -0
  246. /package/dist/{remote-IJAMOEAP.js.map → neon-helpers-HWIYRKOW.js.map} +0 -0
  247. /package/dist/{open-FXWW3VI4.js.map → open-2Y7GSUTJ.js.map} +0 -0
  248. /package/dist/{projects-2UOXFLNZ.js.map → projects-IUSUXD5D.js.map} +0 -0
  249. /package/dist/{update-notifier-LBAUOOLM.js.map → prompt-7LZB4PAT.js.map} +0 -0
  250. /package/dist/{rebase-6NVLX5V7.js.map → rebase-S6OHAOOF.js.map} +0 -0
  251. /package/dist/{recap-OMBOKJST.js.map → recap-GGVCG5VH.js.map} +0 -0
  252. /package/dist/{run-BBXLRIZB.js.map → run-ST3FR75O.js.map} +0 -0
  253. /package/dist/{shell-RF7LTND5.js.map → shell-W4SBQPTE.js.map} +0 -0
  254. /package/dist/{summary-WTQZ7XG2.js.map → summary-P2JCIIJO.js.map} +0 -0
  255. /package/dist/{test-SGO6I5Z7.js.map → test-6JH4FE2X.js.map} +0 -0
  256. /package/dist/{test-git-XM4TM65W.js.map → test-git-2KFFAQ6B.js.map} +0 -0
  257. /package/dist/{test-jira-LDTOYFSD.js.map → test-jira-FKDKG6CD.js.map} +0 -0
  258. /package/dist/{test-tabs-D3POYOJ5.js.map → test-tabs-YDWMWTVA.js.map} +0 -0
  259. /package/dist/{test-webserver-NZ3JTVLL.js.map → test-webserver-QI3QQFZ3.js.map} +0 -0
  260. /package/dist/{update-HJKDYA3F.js.map → update-XLW7R7FL.js.map} +0 -0
  261. /package/dist/{vscode-6XUGHJKL.js.map → vscode-TOGE5N67.js.map} +0 -0
  262. /package/dist/{vscode-announcement-EQ2SKK3T.js.map → vscode-announcement-NIX7O2MG.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/MetadataManager.ts"],"sourcesContent":["import path from 'path'\nimport os from 'os'\nimport fs from 'fs-extra'\nimport { getLogger } from '../utils/logger-context.js'\nimport type { ProjectCapability } from '../types/loom.js'\nimport type { OneShotMode } from '../types/index.js'\n\nexport type SwarmState = 'pending' | 'in_progress' | 'code_review' | 'done' | 'failed'\n\n/**\n * Schema for metadata JSON file\n * Stored in ~/.config/iloom-ai/looms/\n */\nexport interface MetadataFile {\n description: string\n created_at?: string\n version: number\n // Additional metadata fields (v2)\n branchName?: string\n worktreePath?: string\n issueType?: 'branch' | 'issue' | 'pr' | 'epic'\n issueKey?: string // Canonical, properly-cased issue key (e.g., \"PROJ-123\")\n issue_numbers?: string[]\n pr_numbers?: string[]\n issueTracker?: string\n colorHex?: string // Stored hex color (e.g., \"#dcebff\") - robust against palette changes\n sessionId?: string // Claude Code session ID for resume support\n projectPath?: string // Main worktree path (project root) - enables project identification\n issueUrls?: Record<string, string> // Map of issue ID to URL in the issue tracker\n prUrls?: Record<string, string> // Map of PR number to URL in the issue tracker\n draftPrNumber?: number // Draft PR number if github-draft-pr mode was used\n oneShot?: OneShotMode // One-shot automation mode stored during loom creation\n capabilities?: ProjectCapability[] // Detected project capabilities\n state?: SwarmState // Swarm mode lifecycle state\n childIssueNumbers?: string[] // Child issue numbers for epic looms\n parentLoom?: {\n type: 'issue' | 'pr' | 'branch' | 'epic'\n identifier: string | number\n branchName: string\n worktreePath: string\n databaseBranch?: string\n }\n // Epic/swarm child issue data (populated during spin setup)\n childIssues?: Array<{\n number: string // Prefixed: \"#123\" for GitHub, \"ENG-123\" for Linear\n title: string\n body: string\n url: string\n }>\n dependencyMap?: Record<string, string[]> // issueNumber -> array of blocking issueNumbers\n mcpConfigPath?: string // Path to per-loom MCP config file (for swarm claude -p commands)\n}\n\n/**\n * Input for writing metadata (all fields except version and created_at)\n * Note: issueTracker is required because every loom should have an associated\n * issue tracker provider (defaults to 'github' via IssueTrackerFactory)\n */\nexport interface WriteMetadataInput {\n description: string\n branchName: string\n worktreePath: string\n issueType: 'branch' | 'issue' | 'pr' | 'epic'\n issueKey?: string // Canonical, properly-cased issue key (e.g., \"PROJ-123\")\n issue_numbers: string[]\n pr_numbers: string[]\n issueTracker: string\n colorHex: string // Hex color (e.g., \"#dcebff\") - robust against palette changes\n sessionId: string // Claude Code session ID for resume support (required for new looms)\n projectPath: string // Main worktree path (project root) - required for new looms\n issueUrls: Record<string, string> // Map of issue ID to URL in the issue tracker\n prUrls: Record<string, string> // Map of PR number to URL in the issue tracker\n draftPrNumber?: number // Draft PR number for github-draft-pr mode\n oneShot?: OneShotMode // One-shot automation mode to persist\n capabilities: ProjectCapability[] // Detected project capabilities (required for new looms)\n state?: SwarmState // Swarm mode lifecycle state\n childIssueNumbers?: string[] // Child issue numbers for epic looms\n parentLoom?: {\n type: 'issue' | 'pr' | 'branch' | 'epic'\n identifier: string | number\n branchName: string\n worktreePath: string\n databaseBranch?: string\n }\n // Epic/swarm child issue data (populated during spin setup)\n childIssues?: Array<{\n number: string // Prefixed: \"#123\" for GitHub, \"ENG-123\" for Linear\n title: string\n body: string\n url: string\n }>\n dependencyMap?: Record<string, string[]> // issueNumber -> array of blocking issueNumbers\n mcpConfigPath?: string // Path to per-loom MCP config file (for swarm claude -p commands)\n}\n\n/**\n * Result of reading metadata for a worktree\n */\nexport interface LoomMetadata {\n status?: 'active' | 'finished'\n finishedAt?: string | null\n description: string\n created_at: string | null\n branchName: string | null\n worktreePath: string | null\n issueType: 'branch' | 'issue' | 'pr' | 'epic' | null\n issueKey: string | null // Canonical, properly-cased issue key (e.g., \"PROJ-123\")\n issue_numbers: string[]\n pr_numbers: string[]\n issueTracker: string | null\n colorHex: string | null // Hex color (e.g., \"#dcebff\") - robust against palette changes\n sessionId: string | null // Claude Code session ID (null for legacy looms)\n projectPath: string | null // Main worktree path (null for legacy looms)\n issueUrls: Record<string, string> // Map of issue ID to URL ({} for legacy looms)\n prUrls: Record<string, string> // Map of PR number to URL ({} for legacy looms)\n draftPrNumber: number | null // Draft PR number (null if not draft mode)\n oneShot: OneShotMode | null // One-shot mode (null for legacy looms)\n capabilities: ProjectCapability[] // Detected project capabilities (empty for legacy looms)\n state: SwarmState | null // Swarm mode lifecycle state (null for non-swarm looms)\n childIssueNumbers: string[] // Child issue numbers for epic looms (empty for non-epic looms)\n parentLoom: {\n type: 'issue' | 'pr' | 'branch' | 'epic'\n identifier: string | number\n branchName: string\n worktreePath: string\n databaseBranch?: string\n } | null\n // Epic/swarm child issue data (empty arrays/objects for non-epic looms)\n childIssues: Array<{\n number: string\n title: string\n body: string\n url: string\n }>\n dependencyMap: Record<string, string[]>\n mcpConfigPath: string | null // Path to per-loom MCP config file (null for non-swarm looms)\n}\n\n/**\n * MetadataManager: Manage loom metadata persistence\n *\n * Stores loom metadata in ~/.config/iloom-ai/looms/ directory.\n * Each worktree gets a JSON file named by slugifying its absolute path.\n *\n * Per spec section 2.2:\n * - Filename derived from worktree absolute path\n * - Path separators replaced with double underscores\n * - Non-alphanumeric chars (except _ and -) replaced with hyphens\n */\nexport class MetadataManager {\n private readonly loomsDir: string\n private readonly finishedDir: string\n\n constructor() {\n this.loomsDir = path.join(os.homedir(), '.config', 'iloom-ai', 'looms')\n this.finishedDir = path.join(this.loomsDir, 'finished')\n }\n\n /**\n * Convert MetadataFile to LoomMetadata with default values for optional fields\n */\n private toMetadata(data: MetadataFile): LoomMetadata {\n return {\n description: data.description,\n created_at: data.created_at ?? null,\n branchName: data.branchName ?? null,\n worktreePath: data.worktreePath ?? null,\n issueType: data.issueType ?? null,\n issueKey: data.issueKey ?? null,\n issue_numbers: data.issue_numbers ?? [],\n pr_numbers: data.pr_numbers ?? [],\n issueTracker: data.issueTracker ?? null,\n colorHex: data.colorHex ?? null,\n sessionId: data.sessionId ?? null,\n projectPath: data.projectPath ?? null,\n issueUrls: data.issueUrls ?? {},\n prUrls: data.prUrls ?? {},\n draftPrNumber: data.draftPrNumber ?? null,\n oneShot: data.oneShot ?? null,\n capabilities: data.capabilities ?? [],\n state: data.state ?? null,\n childIssueNumbers: data.childIssueNumbers ?? [],\n parentLoom: data.parentLoom ?? null,\n childIssues: data.childIssues ?? [],\n dependencyMap: data.dependencyMap ?? {},\n mcpConfigPath: data.mcpConfigPath ?? null,\n }\n }\n\n /**\n * Convert worktree path to filename slug per spec section 2.2\n *\n * Algorithm:\n * 1. Trim trailing slashes\n * 2. Replace all path separators (/ or \\) with __ (double underscore)\n * 3. Replace any other non-alphanumeric characters (except _ and -) with -\n * 4. Append .json\n *\n * Example:\n * - Worktree: /Users/jane/dev/repo\n * - Filename: _Users__jane__dev__repo.json\n */\n slugifyPath(worktreePath: string): string {\n // 1. Trim trailing slashes\n let slug = worktreePath.replace(/[/\\\\]+$/, '')\n\n // 2. Replace path separators with triple underscores\n slug = slug.replace(/[/\\\\]/g, '___')\n\n // 3. Replace non-alphanumeric chars (except _ and -) with hyphens\n slug = slug.replace(/[^a-zA-Z0-9_-]/g, '-')\n\n // 4. Append .json\n return `${slug}.json`\n }\n\n /**\n * Get the full path to the metadata file for a worktree\n */\n private getFilePath(worktreePath: string): string {\n const filename = this.slugifyPath(worktreePath)\n return path.join(this.loomsDir, filename)\n }\n\n /**\n * Get the full path to the metadata file for a worktree (public API)\n * Used by other services that need to reference the metadata file location\n * (e.g., MCP servers that need to read loom context)\n */\n getMetadataFilePath(worktreePath: string): string {\n return this.getFilePath(worktreePath)\n }\n\n /**\n * Write metadata for a worktree (spec section 3.1)\n *\n * @param worktreePath - Absolute path to the worktree (used for file naming)\n * @param input - Metadata to write (description plus additional fields)\n */\n async writeMetadata(worktreePath: string, input: WriteMetadataInput): Promise<void> {\n try {\n // 1. Ensure looms directory exists\n await fs.ensureDir(this.loomsDir, { mode: 0o755 })\n\n // 2. Create JSON content\n const content: MetadataFile = {\n description: input.description,\n created_at: new Date().toISOString(),\n version: 1,\n branchName: input.branchName,\n worktreePath: input.worktreePath,\n issueType: input.issueType,\n ...(input.issueKey && { issueKey: input.issueKey }),\n issue_numbers: input.issue_numbers,\n pr_numbers: input.pr_numbers,\n issueTracker: input.issueTracker,\n colorHex: input.colorHex,\n sessionId: input.sessionId,\n projectPath: input.projectPath,\n issueUrls: input.issueUrls,\n prUrls: input.prUrls,\n capabilities: input.capabilities,\n ...(input.draftPrNumber && { draftPrNumber: input.draftPrNumber }),\n ...(input.oneShot && { oneShot: input.oneShot }),\n ...(input.state && { state: input.state }),\n ...(input.childIssueNumbers && input.childIssueNumbers.length > 0 && { childIssueNumbers: input.childIssueNumbers }),\n ...(input.parentLoom && { parentLoom: input.parentLoom }),\n ...(input.childIssues && input.childIssues.length > 0 && { childIssues: input.childIssues }),\n ...(input.dependencyMap && Object.keys(input.dependencyMap).length > 0 && { dependencyMap: input.dependencyMap }),\n ...(input.mcpConfigPath && { mcpConfigPath: input.mcpConfigPath }),\n }\n\n // 3. Write to slugified filename\n const filePath = this.getFilePath(worktreePath)\n await fs.writeFile(filePath, JSON.stringify(content, null, 2), { mode: 0o644 })\n\n getLogger().debug(`Metadata written for worktree: ${worktreePath}`)\n } catch (error) {\n // Log warning but don't throw - metadata is supplementary\n getLogger().warn(\n `Failed to write metadata for worktree: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n }\n\n /**\n * Read metadata for a worktree (spec section 3.2)\n *\n * @param worktreePath - Absolute path to the worktree\n * @returns The metadata object with all fields, or null if not found/invalid\n */\n async readMetadata(worktreePath: string): Promise<LoomMetadata | null> {\n try {\n const filePath = this.getFilePath(worktreePath)\n\n // Check if file exists\n if (!(await fs.pathExists(filePath))) {\n return null\n }\n\n // Read and parse JSON\n const content = await fs.readFile(filePath, 'utf8')\n const data: MetadataFile = JSON.parse(content)\n\n if (!data.description) {\n return null\n }\n\n return this.toMetadata(data)\n } catch (error) {\n // Return null on any error (graceful degradation per spec)\n getLogger().debug(\n `Could not read metadata for worktree ${worktreePath}: ${error instanceof Error ? error.message : String(error)}`\n )\n return null\n }\n }\n\n /**\n * List all stored loom metadata files\n *\n * Returns an array of LoomMetadata objects for all valid metadata files\n * in the looms directory. Invalid or unreadable files are skipped.\n *\n * @returns Array of LoomMetadata objects from all stored files\n */\n async listAllMetadata(): Promise<LoomMetadata[]> {\n const results: LoomMetadata[] = []\n\n try {\n // Check if looms directory exists\n if (!(await fs.pathExists(this.loomsDir))) {\n return results\n }\n\n // Read all files in looms directory\n const files = await fs.readdir(this.loomsDir)\n\n // Filter to only .json files and read each\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n\n try {\n const filePath = path.join(this.loomsDir, file)\n const content = await fs.readFile(filePath, 'utf8')\n const data: MetadataFile = JSON.parse(content)\n\n // Skip files without required description field\n if (!data.description) {\n continue\n }\n\n results.push(this.toMetadata(data))\n } catch (error) {\n // Skip individual files that fail to parse (graceful degradation)\n getLogger().debug(\n `Skipping metadata file ${file}: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n }\n } catch (error) {\n // Log error but return empty array (graceful degradation)\n getLogger().debug(\n `Could not list metadata files: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n\n return results\n }\n\n /**\n * Update existing metadata for a worktree by merging new fields\n *\n * Reads the existing metadata file, merges the provided updates,\n * and writes back. Only provided fields are overwritten.\n *\n * @param worktreePath - Absolute path to the worktree\n * @param updates - Partial metadata fields to merge\n */\n async updateMetadata(worktreePath: string, updates: Partial<MetadataFile>): Promise<void> {\n try {\n const filePath = this.getFilePath(worktreePath)\n\n // Check if file exists\n if (!(await fs.pathExists(filePath))) {\n getLogger().warn(`No metadata file to update for worktree: ${worktreePath}`)\n return\n }\n\n // Read existing data\n const content = await fs.readFile(filePath, 'utf8')\n const data: MetadataFile = JSON.parse(content)\n\n // Merge updates\n const merged = { ...data, ...updates }\n\n // Write back\n await fs.writeFile(filePath, JSON.stringify(merged, null, 2), { mode: 0o644 })\n\n getLogger().debug(`Metadata updated for worktree: ${worktreePath}`)\n } catch (error) {\n getLogger().warn(\n `Failed to update metadata for worktree: ${error instanceof Error ? error.message : String(error)}`\n )\n throw error\n }\n }\n\n /**\n * Delete metadata for a worktree (spec section 3.3)\n *\n * Idempotent: silently succeeds if file doesn't exist\n * Non-fatal: logs warning on permission errors but doesn't throw\n *\n * @param worktreePath - Absolute path to the worktree\n */\n async deleteMetadata(worktreePath: string): Promise<void> {\n try {\n const filePath = this.getFilePath(worktreePath)\n\n // Check if file exists - silently return if not\n if (!(await fs.pathExists(filePath))) {\n getLogger().debug(`No metadata file to delete for worktree: ${worktreePath}`)\n return\n }\n\n // Delete the file\n await fs.unlink(filePath)\n getLogger().debug(`Metadata deleted for worktree: ${worktreePath}`)\n } catch (error) {\n // Log warning on permission error but don't throw (per spec section 3.3)\n getLogger().warn(\n `Failed to delete metadata for worktree: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n }\n\n /**\n * Archive metadata for a finished worktree\n *\n * Moves the metadata file to the finished/ subdirectory and adds\n * status: 'finished' and finishedAt timestamp fields.\n *\n * Idempotent: silently succeeds if source file doesn't exist\n * Non-fatal: logs warning on errors but doesn't throw\n *\n * @param worktreePath - Absolute path to the worktree\n */\n async archiveMetadata(worktreePath: string): Promise<void> {\n try {\n const filename = this.slugifyPath(worktreePath)\n const sourcePath = path.join(this.loomsDir, filename)\n\n // Check if source file exists - silently return if not (idempotent)\n if (!(await fs.pathExists(sourcePath))) {\n getLogger().debug(`No metadata file to archive for worktree: ${worktreePath}`)\n return\n }\n\n // Read existing metadata\n const content = await fs.readFile(sourcePath, 'utf8')\n const data: MetadataFile = JSON.parse(content)\n\n // Add finished status and timestamp\n const finishedData = {\n ...data,\n status: 'finished' as const,\n finishedAt: new Date().toISOString(),\n }\n\n // Ensure finished directory exists\n await fs.ensureDir(this.finishedDir, { mode: 0o755 })\n\n // Write to finished subdirectory\n const destPath = path.join(this.finishedDir, filename)\n await fs.writeFile(destPath, JSON.stringify(finishedData, null, 2), { mode: 0o644 })\n\n // Delete original file\n await fs.unlink(sourcePath)\n\n getLogger().debug(`Metadata archived for worktree: ${worktreePath}`)\n } catch (error) {\n // Log warning but don't throw - archiving is supplementary\n getLogger().warn(\n `Failed to archive metadata for worktree: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n }\n\n /**\n * List all finished loom metadata files\n *\n * Returns an array of LoomMetadata objects for all finished looms\n * in the finished/ subdirectory, sorted by finishedAt in descending order\n * (most recently finished first).\n *\n * @returns Array of LoomMetadata objects from finished files, sorted by finishedAt desc\n */\n async listFinishedMetadata(): Promise<LoomMetadata[]> {\n const results: LoomMetadata[] = []\n\n try {\n // Check if finished directory exists\n if (!(await fs.pathExists(this.finishedDir))) {\n return results\n }\n\n // Read all files in finished directory\n const files = await fs.readdir(this.finishedDir)\n\n // Filter to only .json files and read each\n for (const file of files) {\n if (!file.endsWith('.json')) {\n continue\n }\n\n try {\n const filePath = path.join(this.finishedDir, file)\n const content = await fs.readFile(filePath, 'utf8')\n const data = JSON.parse(content) as MetadataFile & { status?: string; finishedAt?: string }\n\n // Skip files without required description field\n if (!data.description) {\n continue\n }\n\n const metadata = this.toMetadata(data)\n // Add finished-specific fields\n metadata.status = (data.status as 'active' | 'finished') ?? 'finished'\n metadata.finishedAt = data.finishedAt ?? null\n\n results.push(metadata)\n } catch (error) {\n // Skip individual files that fail to parse (graceful degradation)\n getLogger().warn(\n `Skipping finished metadata file ${file}: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n }\n\n // Sort by finishedAt descending (most recently finished first)\n results.sort((a, b) => {\n const aTime = a.finishedAt ? new Date(a.finishedAt).getTime() : 0\n const bTime = b.finishedAt ? new Date(b.finishedAt).getTime() : 0\n return bTime - aTime\n })\n } catch (error) {\n // Log error but return empty array (graceful degradation)\n getLogger().warn(\n `Could not list finished metadata files: ${error instanceof Error ? error.message : String(error)}`\n )\n }\n\n return results\n }\n}\n"],"mappings":";;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,QAAQ;AAmJR,IAAM,kBAAN,MAAsB;AAAA,EAI3B,cAAc;AACZ,SAAK,WAAW,KAAK,KAAK,GAAG,QAAQ,GAAG,WAAW,YAAY,OAAO;AACtE,SAAK,cAAc,KAAK,KAAK,KAAK,UAAU,UAAU;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA,EAKQ,WAAW,MAAkC;AACnD,WAAO;AAAA,MACL,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK,cAAc;AAAA,MAC/B,YAAY,KAAK,cAAc;AAAA,MAC/B,cAAc,KAAK,gBAAgB;AAAA,MACnC,WAAW,KAAK,aAAa;AAAA,MAC7B,UAAU,KAAK,YAAY;AAAA,MAC3B,eAAe,KAAK,iBAAiB,CAAC;AAAA,MACtC,YAAY,KAAK,cAAc,CAAC;AAAA,MAChC,cAAc,KAAK,gBAAgB;AAAA,MACnC,UAAU,KAAK,YAAY;AAAA,MAC3B,WAAW,K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AQ,OAAO;AACxB,YAAI,CAAC,KAAK,SAAS,OAAO,GAAG;AAC3B;AAAA,QACF;AAEA,YAAI;AACF,gBAAM,WAAW,KAAK,KAAK,KAAK,aAAa,IAAI;AACjD,gBAAM,UAAU,MAAM,GAAG,SAAS,UAAU,MAAM;AAClD,gBAAM,OAAO,KAAK,MAAM,OAAO;AAG/B,cAAI,CAAC,KAAK,aAAa;AACrB;AAAA,UACF;AAEA,gBAAM,WAAW,KAAK,WAAW,IAAI;AAErC,mBAAS,SAAU,KAAK,UAAoC;AAC5D,mBAAS,aAAa,KAAK,cAAc;AAEzC,kBAAQ,KAAK,QAAQ;AAAA,QACvB,SAAS,OAAO;AAEd,oBAAU,EAAE;AAAA,YACV,mCAAmC,IAAI,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,UACpG;AAAA,QACF;AAAA,MACF;AAGA,cAAQ,KAAK,CAAC,GAAG,MAAM;AACrB,cAAM,QAAQ,EAAE,aAAa,IAAI,KAAK,EAAE,UAAU,EAAE,QAAQ,IAAI;AAChE,cAAM,QAAQ,EAAE,aAAa,IAAI,KAAK,EAAE,UAAU,EAAE,QAAQ,IAAI;AAChE,eAAO,QAAQ;AAAA,MACjB,CAAC;AAAA,IACH,SAAS,OAAO;AAEd,gBAAU,EAAE;AAAA,QACV,2CAA2C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACnG;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/ignite.ts","../src/lib/ClaudeHookManager.ts","../src/lib/SwarmSetupService.ts","../src/utils/language-detector.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\nimport { logger, createStderrLogger } from '../utils/logger.js'\nimport { withLogger } from '../utils/logger-context.js'\nimport { ClaudeWorkflowOptions } from '../lib/ClaudeService.js'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { launchClaude, ClaudeCliOptions } from '../utils/claude.js'\nimport { PromptTemplateManager, TemplateVariables, buildReviewTemplateVariables } from '../lib/PromptTemplateManager.js'\nimport { generateIssueManagementMcpConfig, generateRecapMcpConfig, generateAndWriteMcpConfigFile } from '../utils/mcp.js'\nimport { AgentManager } from '../lib/AgentManager.js'\nimport { IssueTrackerFactory } from '../lib/IssueTrackerFactory.js'\nimport { SettingsManager, type IloomSettings } from '../lib/SettingsManager.js'\nimport { MetadataManager } from '../lib/MetadataManager.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport { FirstRunManager } from '../utils/FirstRunManager.js'\nimport { extractIssueNumber, isValidGitRepo, getWorktreeRoot, findMainWorktreePathWithSettings } from '../utils/git.js'\nimport { getWorkspacePort } from '../utils/port.js'\nimport { readFile } from 'fs/promises'\nimport { ClaudeHookManager } from '../lib/ClaudeHookManager.js'\nimport type { OneShotMode } from '../types/index.js'\nimport { fetchChildIssueDetails } from '../utils/list-children.js'\nimport { buildDependencyMap } from '../utils/dependency-map.js'\nimport { SwarmSetupService } from '../lib/SwarmSetupService.js'\nimport type { LoomMetadata } from '../lib/MetadataManager.js'\nimport { TelemetryService } from '../lib/TelemetryService.js'\nimport { detectProjectLanguage } from '../utils/language-detector.js'\n\n/**\n * Error thrown when the spin command is run from an invalid location\n */\nexport class WorktreeValidationError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly suggestion: string\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'WorktreeValidationError'\n\t}\n}\n\n/**\n * IgniteCommand: Auto-detect workspace context and launch Claude\n *\n * This command:\n * 1. Auto-detects context from current directory and git branch\n * 2. Loads appropriate prompt template with variable substitution\n * 3. Launches Claude with existing agent system (NO changes to agent loading)\n * 4. Executes in current terminal (not opening a new window)\n *\n * CRITICAL: This command works with agents exactly as they currently function.\n * NO modifications to agent loading mechanisms.\n */\nexport class IgniteCommand {\n\tprivate templateManager: PromptTemplateManager\n\tprivate gitWorktreeManager: GitWorktreeManager\n\tprivate agentManager: AgentManager\n\tprivate settingsManager: SettingsManager\n\tprivate firstRunManager: FirstRunManager\n\tprivate hookManager: ClaudeHookManager\n\tprivate settings?: IloomSettings\n\n\tconstructor(\n\t\ttemplateManager?: PromptTemplateManager,\n\t\tgitWorktreeManager?: GitWorktreeManager,\n\t\tagentManager?: AgentManager,\n\t\tsettingsManager?: SettingsManager,\n\t\tfirstRunManager?: FirstRunManager,\n\t\thookManager?: ClaudeHookManager\n\t) {\n\t\tthis.templateManager = templateManager ?? new PromptTemplateManager()\n\t\tthis.gitWorktreeManager = gitWorktreeManager ?? new GitWorktreeManager()\n\t\tthis.agentManager = agentManager ?? new AgentManager()\n\t\tthis.settingsManager = settingsManager ?? new SettingsManager()\n\t\tthis.firstRunManager = firstRunManager ?? new FirstRunManager('spin')\n\t\tthis.hookManager = hookManager ?? new ClaudeHookManager()\n\t}\n\n\t/**\n\t * Validate that we're not running from the main worktree\n\t * @param workspacePath - Optional explicit workspace path; defaults to process.cwd()\n\t * @throws WorktreeValidationError if running from main worktree\n\t */\n\tprivate async validateNotMainWorktree(workspacePath?: string): Promise<void> {\n\t\tconst currentDir = workspacePath ?? process.cwd()\n\n\t\t// Step 1: Check if we're in a git repository at all\n\t\tconst isGitRepo = await isValidGitRepo(currentDir)\n\t\tif (!isGitRepo) {\n\t\t\t// Not a git repo - let detectWorkspaceContext handle this gracefully\n\t\t\treturn\n\t\t}\n\n\t\t// Step 2: Get the worktree root (handles subdirectories)\n\t\tconst worktreeRoot = await getWorktreeRoot(currentDir)\n\t\tif (!worktreeRoot) {\n\t\t\t// Could not determine root - let detectWorkspaceContext handle this\n\t\t\treturn\n\t\t}\n\n\t\t// Step 3: Check if this path is a registered git worktree\n\t\tconst worktrees = await this.gitWorktreeManager.listWorktrees()\n\t\tconst currentWorktree = worktrees.find(wt => wt.path === worktreeRoot)\n\n\t\tif (!currentWorktree) {\n\t\t\t// Not a registered worktree - let detectWorkspaceContext handle this\n\t\t\treturn\n\t\t}\n\n\t\t// Step 4: Check if this is the main worktree\n\t\tconst isMain = await this.gitWorktreeManager.isMainWorktree(currentWorktree, this.settingsManager)\n\t\tif (isMain) {\n\t\t\tthrow new WorktreeValidationError(\n\t\t\t\t'You cannot run the command from the main worktree.',\n\t\t\t\t\"Navigate to a feature worktree created by 'il start <issue>' and run 'il spin' from there.\"\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Print mode options for headless/CI execution\n\t */\n\tpublic printOptions: {\n\t\tprint?: boolean\n\t\toutputFormat?: 'json' | 'stream-json' | 'text'\n\t\tverbose?: boolean\n\t\tjson?: boolean // --json flag: output final JSON object\n\t\tjsonStream?: boolean // --json-stream flag: stream JSONL to stdout\n\t} | undefined\n\n\t/**\n\t * Main entry point for spin command\n\t * @param oneShot - One-shot automation mode\n\t * @param printOptions - Print mode options for headless/CI execution\n\t * @param skipCleanup - Skip cleanup after execution\n\t * @param workspacePath - Optional explicit workspace path for programmatic invocation (avoids process.chdir())\n\t */\n\tasync execute(oneShot?: OneShotMode, printOptions?: {\n\t\tprint?: boolean\n\t\toutputFormat?: 'json' | 'stream-json' | 'text'\n\t\tverbose?: boolean\n\t\tjson?: boolean\n\t\tjsonStream?: boolean\n\t}, skipCleanup?: boolean, workspacePath?: string): Promise<void> {\n\t\tthis.printOptions = printOptions\n\n\t\t// Wrap execution in stderr logger for JSON modes to keep stdout clean\n\t\tconst isJsonMode = (this.printOptions?.json ?? false) || (this.printOptions?.jsonStream ?? false)\n\t\tif (isJsonMode) {\n\t\t\tconst jsonLogger = createStderrLogger()\n\t\t\treturn withLogger(jsonLogger, () => this.executeInternal(oneShot, skipCleanup, workspacePath))\n\t\t}\n\n\t\treturn this.executeInternal(oneShot, skipCleanup, workspacePath)\n\t}\n\n\t/**\n\t * Internal execution method (separated for withLogger wrapping)\n\t */\n\tprivate async executeInternal(oneShot?: OneShotMode, skipCleanup?: boolean, workspacePath?: string): Promise<void> {\n\t\t// Set ILOOM=1 so hooks know this is an iloom session\n\t\t// This is inherited by the Claude child process\n\t\tprocess.env.ILOOM = '1'\n\n\t\t// Validate we're not in the main worktree first\n\t\ttry {\n\t\t\tawait this.validateNotMainWorktree(workspacePath)\n\t\t} catch (error) {\n\t\t\tif (error instanceof WorktreeValidationError) {\n\t\t\t\tlogger.error(error.message)\n\t\t\t\tlogger.info(error.suggestion)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\n\t\ttry {\n\t\t\tlogger.info('🚀 Your loom is spinning up, please wait...')\n\n\t\t\t// Step 0.5: Check if this is first-time user\n\t\t\tconst isFirstRun = await this.firstRunManager.isFirstRun()\n\t\t\tif (isFirstRun) {\n\t\t\t\tlogger.success('Welcome to iloom! Preparing first-time experience...')\n\t\t\t}\n\n\t\t\t// Step 0.6: Install Claude hooks for VSCode integration (idempotent, quick)\n\t\t\tawait this.hookManager.installHooks()\n\n\t\t\t// Step 1: Auto-detect workspace context\n\t\t\tconst context = await this.detectWorkspaceContext(workspacePath)\n\n\t\t\tlogger.debug('Auto-detected workspace context', { context })\n\n\t\t\t// Inform user what context was detected\n\t\t\tthis.logDetectedContext(context)\n\n\t\t\tlogger.info('📝 Loading prompt template and preparing Claude...')\n\n\t\t\t// Step 2: Read metadata early to get draftPrNumber and draftPrUrl for templates and MCP config\n\t\t\tconst metadataManager = new MetadataManager()\n\t\t\tconst metadata = await metadataManager.readMetadata(context.workspacePath)\n\t\t\tconst draftPrNumber = metadata?.draftPrNumber ?? undefined\n\t\t\t// Extract draft PR URL from prUrls map if available\n\t\t\tconst draftPrUrl = draftPrNumber && metadata?.prUrls?.[String(draftPrNumber)]\n\t\t\t\t? metadata.prUrls[String(draftPrNumber)]\n\t\t\t\t: undefined\n\n\t\t\t// Step 2.0.3: Prevent il spin in child worktrees of epic looms\n\t\t\t// Child issues managed by a swarm orchestrator must not launch independent agents.\n\t\t\t// Exception: child epics (issueType === 'epic') need il spin for their own swarm.\n\t\t\tif (metadata?.parentLoom?.type === 'epic' && metadata.issueType !== 'epic') {\n\t\t\t\tthrow new WorktreeValidationError(\n\t\t\t\t\t'Cannot run il spin in a child worktree of an epic loom. The swarm orchestrator manages agent execution for these issues.',\n\t\t\t\t\t'Run il spin from the parent epic worktree instead to launch the swarm orchestrator.'\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Step 2.0.4: Determine effective oneShot mode\n\t\t\t// If print mode is enabled, force noReview to skip interactive reviews\n\t\t\t// If oneShot is provided (any value including 'default'), use it\n\t\t\t// If oneShot is undefined (not passed), use metadata or fallback to 'default'\n\t\t\t// Note: metadata?.oneShot can be null (for legacy looms), so we need double nullish coalescing\n\t\t\tconst storedOneShot = metadata?.oneShot ?? 'default'\n\t\t\tconst isHeadlessForOneShot = this.printOptions?.print ?? false\n\t\t\tconst effectiveOneShot: OneShotMode = isHeadlessForOneShot ? 'noReview' : (oneShot ?? storedOneShot)\n\n\t\t\t// Step 2.0.5: Load settings early if not cached (needed for port calculation)\n\t\t\tif (!this.settings) {\n\t\t\t\tconst cliOverrides = extractSettingsOverrides()\n\t\t\t\tthis.settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\t\t}\n\n\t\t\t// Step 2.0.5.1: Track session.started telemetry\n\t\t\ttry {\n\t\t\t\tconst hasNeon = !!this.settings?.databaseProviders?.neon\n\t\t\t\tconst language = await detectProjectLanguage(context.workspacePath)\n\t\t\t\tTelemetryService.getInstance().track('session.started', {\n\t\t\t\t\thas_neon: hasNeon,\n\t\t\t\t\tlanguage,\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tlogger.debug(`Telemetry session.started tracking failed: ${error instanceof Error ? error.message : error}`)\n\t\t\t}\n\n\t\t\t// Step 2.0.6: Calculate port for web-capable looms\n\t\t\tif (metadata?.capabilities?.includes('web') && context.branchName) {\n\t\t\t\tconst basePort = this.settings?.capabilities?.web?.basePort ?? 3000\n\t\t\t\tcontext.port = await getWorkspacePort({\n\t\t\t\t\tbasePort,\n\t\t\t\t\tworktreePath: context.workspacePath,\n\t\t\t\t\tworktreeBranch: context.branchName,\n\t\t\t\t})\n\t\t\t\tlogger.info(`🌐 Development server port: ${context.port}`)\n\t\t\t}\n\n\t\t\t// Step 2.1: Fetch and persist epic child data if this is an epic loom\n\t\t\t// Detection: check for childIssues already stored (re-spin of an epic)\n\t\t\t// or check for 'epic' issueType once issue #624 adds it\n\t\t\tconst isEpicLoom = metadata && metadata.issue_numbers.length > 0\n\t\t\t\t&& ((metadata.childIssues?.length ?? 0) > 0 || metadata.issueType === 'epic')\n\t\t\tif (isEpicLoom && this.settings) {\n\t\t\t\tawait this.fetchAndStoreEpicChildData(metadataManager, metadata, context.workspacePath, this.settings)\n\t\t\t}\n\n\t\t\t// Step 2.1.1: If this is an epic loom, enter swarm mode\n\t\t\tif (isEpicLoom && this.settings) {\n\t\t\t\t// Re-read metadata to get freshly persisted child data\n\t\t\t\tconst freshMetadata = await metadataManager.readMetadata(context.workspacePath)\n\t\t\t\tif (freshMetadata && freshMetadata.childIssues.length > 0) {\n\t\t\t\t\tawait this.executeSwarmMode(\n\t\t\t\t\t\tfreshMetadata,\n\t\t\t\t\t\tcontext.workspacePath,\n\t\t\t\t\t\tcontext.branchName ?? '',\n\t\t\t\t\t\tmetadataManager,\n\t\t\t\t\t\tskipCleanup,\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step 2.2: Get prompt template with variable substitution\n\t\t\tconst variables = this.buildTemplateVariables(context, effectiveOneShot, draftPrNumber, draftPrUrl)\n\n\t\t\t// Step 2.5: Add first-time user context if needed\n\t\t\tif (isFirstRun) {\n\t\t\t\tvariables.FIRST_TIME_USER = true\n\t\t\t\tvariables.README_CONTENT = await this.loadReadmeContent()\n\t\t\t\tvariables.SETTINGS_SCHEMA_CONTENT = await this.loadSettingsSchemaContent()\n\t\t\t}\n\n\t\t\tconst systemInstructions = await this.templateManager.getPrompt(context.type, variables)\n\n\t\t\t// User prompt to trigger the workflow (includes one-shot bypass instructions if needed)\n\t\t\tconst userPrompt = this.buildUserPrompt(effectiveOneShot)\n\n\t\t\t// Step 3: Determine model and permission mode based on workflow type\n\t\t\tconst model = this.settingsManager.getSpinModel(this.settings)\n\t\t\tlet permissionMode = this.getPermissionModeForWorkflow(context.type)\n\n\t\t\t// Override permission mode if bypassPermissions oneShot mode\n\t\t\tif (effectiveOneShot === 'bypassPermissions') {\n\t\t\t\tpermissionMode = 'bypassPermissions'\n\t\t\t}\n\n\t\t\t// Display warning if bypassPermissions is used\n\t\t\tif (permissionMode === 'bypassPermissions') {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t'⚠️ WARNING: Using bypassPermissions mode - Claude will execute all tool calls without confirmation. ' +\n\t\t\t\t\t\t'This can be dangerous. Use with caution.'\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Step 4: Build Claude CLI options\n\t\t\t// Session ID must come from loom metadata - no fallback generation\n\t\t\tconst sessionId = metadata?.sessionId\n\t\t\tif (!sessionId) {\n\t\t\t\tthrow new Error('No session ID found in loom metadata. This loom may need to be recreated with `il start`.')\n\t\t\t}\n\t\t\tlogger.debug('Using session ID from metadata', { sessionId })\n\n\t\t\t// Determine if we're in print/headless mode\n\t\t\tconst isHeadless = this.printOptions?.print ?? false\n\n\t\t\tconst claudeOptions: ClaudeCliOptions = {\n\t\t\t\theadless: isHeadless,\n\t\t\t\taddDir: context.workspacePath,\n\t\t\t\tsessionId, // Enable Claude Code session resume\n\t\t\t}\n\n\t\t\t// Add optional model if present\n\t\t\tif (model !== undefined) {\n\t\t\t\tclaudeOptions.model = model\n\t\t\t}\n\n\t\t\t// Add permission mode if not default\n\t\t\t// When print mode is enabled, force bypassPermissions for autonomous execution\n\t\t\tif (isHeadless) {\n\t\t\t\tpermissionMode = 'bypassPermissions'\n\t\t\t}\n\t\t\tif (permissionMode !== undefined && permissionMode !== 'default') {\n\t\t\t\tclaudeOptions.permissionMode = permissionMode\n\t\t\t}\n\n\t\t\t// Add output format and verbose options if provided (print mode only)\n\t\t\tif (this.printOptions?.outputFormat !== undefined) {\n\t\t\t\tclaudeOptions.outputFormat = this.printOptions.outputFormat\n\t\t\t}\n\t\t\tif (this.printOptions?.verbose !== undefined) {\n\t\t\t\tclaudeOptions.verbose = this.printOptions.verbose\n\t\t\t}\n\n\t\t\t// Add JSON mode if specified (requires print mode)\n\t\t\tif (this.printOptions?.json) {\n\t\t\t\tclaudeOptions.jsonMode = 'json'\n\t\t\t\tclaudeOptions.outputFormat = 'stream-json' // Force stream-json for parsing\n\t\t\t} else if (this.printOptions?.jsonStream) {\n\t\t\t\tclaudeOptions.jsonMode = 'stream'\n\t\t\t\tclaudeOptions.outputFormat = 'stream-json' // Force stream-json for streaming\n\t\t\t}\n\n\t\t\t// Add optional branch name for context\n\t\t\tif (context.branchName !== undefined) {\n\t\t\t\tclaudeOptions.branchName = context.branchName\n\t\t\t}\n\n\t\t\t// Step 4.5: Generate MCP config and tool filtering for issue/PR workflows\n\t\t\tlet mcpConfig: Record<string, unknown>[] | undefined\n\t\t\tlet allowedTools: string[] | undefined\n\t\t\tlet disallowedTools: string[] | undefined\n\n\t\t\tif (context.type === 'issue' || context.type === 'pr') {\n\t\t\t\ttry {\n\t\t\t\t\tconst provider = this.settings ? IssueTrackerFactory.getProviderName(this.settings) : 'github'\n\t\t\t\t\t// Pass draftPrNumber to route comments to PR when in github-draft-pr mode\n\t\t\t\t\tmcpConfig = await generateIssueManagementMcpConfig(context.type, undefined, provider, this.settings, draftPrNumber)\n\t\t\t\t\tlogger.debug('Generated MCP configuration for issue management', { provider, draftPrNumber })\n\n\t\t\t\t\t// Configure tool filtering for issue/PR workflows\n\t\t\t\t\t// Note: set_goal is only allowed for PR workflow (user's purpose unclear)\n\t\t\t\t\t// For issue workflow, the issue title provides context so set_goal is not needed\n\t\t\t\t\tconst baseTools = [\n\t\t\t\t\t\t'mcp__issue_management__get_issue',\n\t\t\t\t\t\t'mcp__issue_management__get_comment',\n\t\t\t\t\t\t'mcp__issue_management__create_comment',\n\t\t\t\t\t\t'mcp__issue_management__update_comment',\n\t\t\t\t\t\t'mcp__issue_management__create_issue',\n\t\t\t\t\t\t'mcp__issue_management__close_issue',\n\t\t\t\t\t\t'mcp__issue_management__reopen_issue',\n\t\t\t\t\t\t'mcp__issue_management__edit_issue',\n\t\t\t\t\t\t'mcp__recap__add_entry',\n\t\t\t\t\t\t'mcp__recap__get_recap',\n\t\t\t\t\t\t'mcp__recap__add_artifact',\n\t\t\t\t\t\t'mcp__recap__set_complexity',\n\t\t\t\t\t\t'mcp__recap__set_loom_state',\n\t\t\t\t\t\t'mcp__recap__get_loom_state'\n\t\t\t\t\t]\n\t\t\t\t\tallowedTools = context.type === 'pr'\n\t\t\t\t\t\t? [...baseTools, 'mcp__issue_management__get_pr', 'mcp__issue_management__get_review_comments', 'mcp__recap__set_goal']\n\t\t\t\t\t\t: baseTools\n\t\t\t\t\tdisallowedTools = ['Bash(gh api:*), Bash(gh issue comment:*)']\n\n\t\t\t\t\tlogger.debug('Configured tool filtering for issue/PR workflow', { allowedTools, disallowedTools })\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Log warning but continue without MCP\n\t\t\t\t\tlogger.warn(`Failed to generate MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Regular/branch workflow - allow recap tools (including set_goal since no issue/PR context)\n\t\t\t\tallowedTools = [\n\t\t\t\t\t'mcp__recap__set_goal',\n\t\t\t\t\t'mcp__recap__add_entry',\n\t\t\t\t\t'mcp__recap__get_recap',\n\t\t\t\t\t'mcp__recap__set_complexity',\n\t\t\t\t\t'mcp__recap__set_loom_state',\n\t\t\t\t\t'mcp__recap__get_loom_state',\n\t\t\t\t]\n\t\t\t\tlogger.debug('Configured tool filtering for regular workflow', { allowedTools })\n\t\t\t}\n\n\t\t\t// Step 4.5.1: Generate recap MCP config (always added for all workflow types)\n\t\t\t// Reuses metadata already read in Step 2\n\t\t\ttry {\n\t\t\t\tif (!metadata) {\n\t\t\t\t\tthrow new Error('No loom metadata found for this workspace')\n\t\t\t\t}\n\t\t\t\tconst recapMcpConfig = generateRecapMcpConfig(context.workspacePath, metadata)\n\t\t\t\tif (mcpConfig) {\n\t\t\t\t\tmcpConfig.push(...recapMcpConfig)\n\t\t\t\t} else {\n\t\t\t\t\tmcpConfig = recapMcpConfig\n\t\t\t\t}\n\t\t\t\tlogger.debug('Generated MCP configuration for recap server')\n\t\t\t} catch (error) {\n\t\t\t\t// Log warning but continue without recap MCP\n\t\t\t\tlogger.warn(`Failed to generate recap MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t}\n\n\t\t\t// Step 4.6: Load agent configurations using cached settings\n\t\t\tlet agents: Record<string, unknown> | undefined\n\t\t\ttry {\n\t\t\t\t// Use cached settings from Step 2.5\n\t\t\t\tif (this.settings?.agents && Object.keys(this.settings.agents).length > 0) {\n\t\t\t\t\tlogger.debug('Loaded project settings', {\n\t\t\t\t\t\tagentOverrides: Object.keys(this.settings.agents),\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\t// Load agents with settings overrides and template variables for substitution\n\t\t\t\t// Exclude init-only agents (e.g., framework-detector which is only for il init)\n\t\t\t\tconst loadedAgents = await this.agentManager.loadAgents(\n\t\t\t\t\tthis.settings,\n\t\t\t\t\tvariables,\n\t\t\t\t\t['*.md', '!iloom-framework-detector.md']\n\t\t\t\t)\n\t\t\t\tagents = this.agentManager.formatForCli(loadedAgents)\n\t\t\t\tlogger.debug('Loaded agent configurations', {\n\t\t\t\t\tagentCount: Object.keys(agents).length,\n\t\t\t\t\tagentNames: Object.keys(agents),\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\t// Log warning but continue without agents\n\t\t\t\tlogger.warn(`Failed to load agents: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t}\n\n\t\t\tlogger.debug('Launching Claude in current terminal', {\n\t\t\t\ttype: context.type,\n\t\t\t\tmodel,\n\t\t\t\tpermissionMode,\n\t\t\t\tworkspacePath: context.workspacePath,\n\t\t\t\thasMcpConfig: !!mcpConfig,\n\t\t\t})\n\n\t\t\tlogger.info(isHeadless ? '✨ Launching Claude in headless mode...' : '✨ Launching Claude in current terminal...')\n\n\t\t\t// Step 5: Launch Claude with system instructions appended and user prompt\n\t\t\tconst claudeResult = await launchClaude(userPrompt, {\n\t\t\t\t...claudeOptions,\n\t\t\t\tappendSystemPrompt: systemInstructions,\n\t\t\t\t...(mcpConfig && { mcpConfig }),\n\t\t\t\t...(allowedTools && { allowedTools }),\n\t\t\t\t...(disallowedTools && { disallowedTools }),\n\t\t\t\t...(agents && { agents }),\n\t\t\t})\n\n\t\t\t// Output final JSON for --json mode (--json-stream already streamed to stdout)\n\t\t\tif (this.printOptions?.json) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(JSON.stringify({\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\toutput: claudeResult ?? ''\n\t\t\t\t}))\n\t\t\t}\n\n\t\t\t// Step 6: Mark as run after successful launch\n\t\t\tif (isFirstRun) {\n\t\t\t\tawait this.firstRunManager.markAsRun()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\t\t\t// Output error as JSON for --json mode\n\t\t\tif (this.printOptions?.json) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(JSON.stringify({\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: errorMessage\n\t\t\t\t}))\n\t\t\t} else {\n\t\t\t\tlogger.error(`Failed to launch Claude: ${errorMessage}`)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Log user-friendly information about detected context\n\t */\n\tprivate logDetectedContext(context: ClaudeWorkflowOptions): void {\n\t\tif (context.type === 'issue') {\n\t\t\tlogger.info(`🎯 Detected issue workflow: Issue #${context.issueNumber}`)\n\t\t} else if (context.type === 'pr') {\n\t\t\tlogger.info(`🔄 Detected PR workflow: PR #${context.prNumber}`)\n\t\t} else {\n\t\t\tlogger.info('🌟 Detected regular workflow')\n\t\t}\n\n\t\tif (context.branchName) {\n\t\t\tlogger.info(`🌿 Working on branch: ${context.branchName}`)\n\t\t}\n\n\t\tif (context.port) {\n\t\t\tlogger.info(`🌐 Development server port: ${context.port}`)\n\t\t}\n\t}\n\n\t/**\n\t * Build template variables from context\n\t */\n\tprivate buildTemplateVariables(\n\t\tcontext: ClaudeWorkflowOptions,\n\t\toneShot: OneShotMode,\n\t\tdraftPrNumber?: number,\n\t\tdraftPrUrl?: string\n\t): TemplateVariables {\n\t\tconst variables: TemplateVariables = {\n\t\t\tWORKSPACE_PATH: context.workspacePath,\n\t\t}\n\n\t\tif (context.issueNumber !== undefined) {\n\t\t\tvariables.ISSUE_NUMBER = context.issueNumber\n\t\t}\n\n\t\tif (context.prNumber !== undefined) {\n\t\t\tvariables.PR_NUMBER = context.prNumber\n\t\t}\n\n\t\tif (context.title !== undefined) {\n\t\t\tif (context.type === 'issue') {\n\t\t\t\tvariables.ISSUE_TITLE = context.title\n\t\t\t} else if (context.type === 'pr') {\n\t\t\t\tvariables.PR_TITLE = context.title\n\t\t\t}\n\t\t}\n\n\t\tif (context.port !== undefined) {\n\t\t\tvariables.PORT = context.port\n\t\t}\n\n\t\t// Set ONE_SHOT_MODE or INTERACTIVE_MODE flag for template conditional sections\n\t\tif (oneShot === 'noReview' || oneShot === 'bypassPermissions') {\n\t\t\tvariables.ONE_SHOT_MODE = true\n\t\t} else {\n\t\t\tvariables.INTERACTIVE_MODE = true\n\t\t}\n\n\t\t// Set review configuration variables (code reviewer + artifact reviewer + per-agent flags)\n\t\tObject.assign(variables, buildReviewTemplateVariables(this.settings?.agents))\n\n\t\t// Set draft PR mode flags (mutually exclusive)\n\t\t// When draftPrNumber is set, we're in github-draft-pr mode\n\t\tif (draftPrNumber !== undefined) {\n\t\t\tvariables.DRAFT_PR_MODE = true\n\t\t\tvariables.DRAFT_PR_NUMBER = draftPrNumber\n\t\t\tif (draftPrUrl) {\n\t\t\t\tvariables.DRAFT_PR_URL = draftPrUrl\n\t\t\t}\n\t\t\t// Set AUTO_COMMIT_PUSH when in draft PR mode and not explicitly disabled\n\t\t\t// Default is true (enabled) for draft PR mode\n\t\t\tconst autoCommitPushEnabled = this.settings?.mergeBehavior?.autoCommitPush !== false\n\t\t\tvariables.AUTO_COMMIT_PUSH = autoCommitPushEnabled\n\t\t\t// Set GIT_REMOTE from settings or default to 'origin'\n\t\t\tconst remote = this.settings?.mergeBehavior?.remote ?? 'origin'\n\t\t\tif (!/^[a-zA-Z0-9_-]+$/.test(remote)) {\n\t\t\t\tthrow new Error(`Invalid git remote name: \"${remote}\". Remote names can only contain alphanumeric characters, underscores, and hyphens.`)\n\t\t\t}\n\t\t\tvariables.GIT_REMOTE = remote\n\t\t} else if (context.type === 'regular') {\n\t\t\t// Branch mode without draft PR\n\t\t\tvariables.STANDARD_BRANCH_MODE = true\n\t\t} else {\n\t\t\t// Issue/PR mode without draft PR\n\t\t\tvariables.STANDARD_ISSUE_MODE = true\n\t\t}\n\n\t\t// Detect VS Code mode\n\t\tconst isVscodeMode = process.env.ILOOM_VSCODE === '1'\n\t\tvariables.IS_VSCODE_MODE = isVscodeMode\n\n\t\treturn variables\n\t}\n\n\t/**\n\t * Get the appropriate permission mode for a workflow type\n\t * Same logic as ClaudeService.getPermissionModeForWorkflow()\n\t */\n\tprivate getPermissionModeForWorkflow(\n\t\ttype: 'issue' | 'pr' | 'regular'\n\t): ClaudeCliOptions['permissionMode'] {\n\t\t// Check settings for configured permission mode\n\t\tif (this.settings?.workflows) {\n\t\t\tconst workflowConfig =\n\t\t\t\ttype === 'issue'\n\t\t\t\t\t? this.settings.workflows.issue\n\t\t\t\t\t: type === 'pr'\n\t\t\t\t\t\t? this.settings.workflows.pr\n\t\t\t\t\t\t: this.settings.workflows.regular\n\n\t\t\tif (workflowConfig?.permissionMode) {\n\t\t\t\treturn workflowConfig.permissionMode\n\t\t\t}\n\t\t}\n\n\t\t// Fall back to current defaults\n\t\tif (type === 'issue') {\n\t\t\treturn 'acceptEdits'\n\t\t}\n\t\t// For PR and regular workflows, use default permissions\n\t\treturn 'default'\n\t}\n\n\t/**\n\t * Auto-detect workspace context from current directory and git branch\n\t *\n\t * Detection priority:\n\t * 1. Directory name patterns (_pr_N, issue-N)\n\t * 2. Git branch name patterns\n\t * 3. Fallback to 'regular' workflow\n\t *\n\t * This leverages the same logic as FinishCommand.autoDetectFromCurrentDirectory()\n\t */\n\tprivate async detectWorkspaceContext(workspacePath?: string): Promise<ClaudeWorkflowOptions> {\n\t\tconst workspacePath_ = workspacePath ?? process.cwd()\n\t\tconst currentDir = path.basename(workspacePath_)\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\t// Pattern: /.*_pr_(\\d+)$/\n\t\tconst prPattern = /_pr_(\\d+)$/\n\t\tconst prMatch = currentDir.match(prPattern)\n\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tlogger.debug(`Auto-detected PR #${prNumber} from directory: ${currentDir}`)\n\n\t\t\treturn this.buildContextForPR(prNumber, workspacePath_)\n\t\t}\n\n\t\t// Check for issue pattern in directory name\n\t\tconst issueNumber = extractIssueNumber(currentDir)\n\n\t\tif (issueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${issueNumber} from directory: ${currentDir}`)\n\n\t\t\treturn this.buildContextForIssue(issueNumber, workspacePath_)\n\t\t}\n\n\t\t// Fallback: Try to extract from git branch name\n\t\ttry {\n\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\t\tif (currentBranch) {\n\t\t\t\t// Try to extract issue from branch name\n\t\t\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\t\t\tif (branchIssueNumber !== null) {\n\t\t\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\n\t\t\t\t\treturn this.buildContextForIssue(branchIssueNumber, workspacePath_, currentBranch)\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Git command failed - not a git repo or other git error\n\t\t\tlogger.debug('Could not detect from git branch', { error })\n\t\t}\n\n\t\t// Last resort: use regular workflow\n\t\tlogger.debug('No specific context detected, using regular workflow')\n\t\treturn this.buildContextForRegular(workspacePath_)\n\t}\n\n\t/**\n\t * Build context for issue workflow\n\t */\n\tprivate async buildContextForIssue(\n\t\tissueNumber: string | number,\n\t\tworkspacePath: string,\n\t\tbranchName?: string\n\t): Promise<ClaudeWorkflowOptions> {\n\t\t// Get branch name if not provided\n\t\tif (!branchName) {\n\t\t\ttry {\n\t\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\t\tbranchName = repoInfo.currentBranch ?? undefined\n\t\t\t} catch {\n\t\t\t\t// Ignore git errors\n\t\t\t}\n\t\t}\n\n\t\tconst context: ClaudeWorkflowOptions = {\n\t\t\ttype: 'issue',\n\t\t\tissueNumber,\n\t\t\tworkspacePath,\n\t\t\theadless: false, // Interactive mode\n\t\t}\n\n\t\tif (branchName !== undefined) {\n\t\t\tcontext.branchName = branchName\n\t\t}\n\n\t\treturn context\n\t}\n\n\t/**\n\t * Build context for PR workflow\n\t */\n\tprivate async buildContextForPR(\n\t\tprNumber: number,\n\t\tworkspacePath: string\n\t): Promise<ClaudeWorkflowOptions> {\n\t\t// Get branch name\n\t\tlet branchName: string | undefined\n\t\ttry {\n\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\tbranchName = repoInfo.currentBranch ?? undefined\n\t\t} catch {\n\t\t\t// Ignore git errors\n\t\t}\n\n\t\tconst context: ClaudeWorkflowOptions = {\n\t\t\ttype: 'pr',\n\t\t\tprNumber,\n\t\t\tworkspacePath,\n\t\t\theadless: false, // Interactive mode\n\t\t}\n\n\t\tif (branchName !== undefined) {\n\t\t\tcontext.branchName = branchName\n\t\t}\n\n\t\treturn context\n\t}\n\n\t/**\n\t * Build context for regular workflow\n\t */\n\tprivate async buildContextForRegular(workspacePath: string): Promise<ClaudeWorkflowOptions> {\n\t\t// Get branch name\n\t\tlet branchName: string | undefined\n\t\ttry {\n\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\tbranchName = repoInfo.currentBranch ?? undefined\n\t\t} catch {\n\t\t\t// Ignore git errors\n\t\t}\n\n\t\tconst context: ClaudeWorkflowOptions = {\n\t\t\ttype: 'regular',\n\t\t\tworkspacePath,\n\t\t\theadless: false, // Interactive mode\n\t\t}\n\n\t\tif (branchName !== undefined) {\n\t\t\tcontext.branchName = branchName\n\t\t}\n\n\t\treturn context\n\t}\n\n\n\t/**\n\t * Fetch and store epic child issue data and dependency map in metadata\n\t *\n\t * Called during spin setup for epic looms. Fetches child issue details\n\t * and dependency relationships from the issue tracker, then persists\n\t * them in the loom metadata for use by the orchestrator.\n\t */\n\tprivate async fetchAndStoreEpicChildData(\n\t\tmetadataManager: MetadataManager,\n\t\tmetadata: import('../lib/MetadataManager.js').LoomMetadata,\n\t\tworktreePath: string,\n\t\tsettings: import('../lib/SettingsManager.js').IloomSettings,\n\t): Promise<void> {\n\t\tconst parentIssueNumber = metadata.issue_numbers[0]\n\t\tif (!parentIssueNumber) return\n\n\t\tlogger.info('Fetching child issue data for epic...')\n\n\t\ttry {\n\t\t\tconst issueTracker = IssueTrackerFactory.create(settings)\n\n\t\t\t// Fetch child issue details and build dependency map in parallel\n\t\t\tconst childIssueDetails = await fetchChildIssueDetails(\n\t\t\t\tparentIssueNumber, issueTracker\n\t\t\t)\n\n\t\t\tif (childIssueDetails.length === 0) {\n\t\t\t\tlogger.debug('No child issues found for epic')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Extract raw IDs for dependency map building (strip prefixes)\n\t\t\tconst childIds = childIssueDetails.map((child) => child.number.replace(/^#/, ''))\n\n\t\t\tconst dependencyMap = await buildDependencyMap(childIds, settings)\n\n\t\t\t// Persist to metadata\n\t\t\tawait metadataManager.updateMetadata(worktreePath, {\n\t\t\t\tchildIssues: childIssueDetails,\n\t\t\t\tdependencyMap,\n\t\t\t})\n\n\t\t\tlogger.info(`Stored ${childIssueDetails.length} child issues and dependency map in metadata`)\n\t\t} catch (error) {\n\t\t\t// Non-fatal: epic can still spin without child data\n\t\t\tlogger.warn(`Failed to fetch epic child data: ${error instanceof Error ? error.message : String(error)}`)\n\t\t}\n\t}\n\n\t/**\n\t * Execute swarm mode for an epic loom.\n\t *\n\t * Creates child worktrees, renders swarm agents/skill, builds the\n\t * orchestrator prompt, and launches Claude with agent teams enabled.\n\t */\n\tprivate async executeSwarmMode(\n\t\tmetadata: LoomMetadata,\n\t\tepicWorktreePath: string,\n\t\tepicBranch: string,\n\t\tmetadataManager: MetadataManager,\n\t\tskipCleanup?: boolean,\n\t): Promise<void> {\n\t\tif (!this.settings) {\n\t\t\tthrow new Error('Settings not loaded. Cannot enter swarm mode.')\n\t\t}\n\t\tconst settings = this.settings\n\t\tconst epicIssueNumber = metadata.issue_numbers[0]\n\t\tif (!epicIssueNumber) {\n\t\t\tthrow new Error('Epic loom has no issue number in metadata')\n\t\t}\n\n\t\tlogger.info('Epic loom detected - entering swarm mode...')\n\n\t\t// Determine main worktree path and issue tracker provider\n\t\tconst mainWorktreePath = await findMainWorktreePathWithSettings()\n\t\tconst providerName = IssueTrackerFactory.getProviderName(settings)\n\n\t\t// Create SwarmSetupService\n\t\tconst swarmSetup = new SwarmSetupService(\n\t\t\tthis.gitWorktreeManager,\n\t\t\tmetadataManager,\n\t\t\tthis.agentManager,\n\t\t\tthis.settingsManager,\n\t\t\tthis.templateManager,\n\t\t)\n\n\t\t// Generate and write per-loom MCP config file for the epic worktree\n\t\ttry {\n\t\t\tconst epicMcpConfigPath = await generateAndWriteMcpConfigFile(\n\t\t\t\tepicWorktreePath,\n\t\t\t\tmetadata,\n\t\t\t\tproviderName as 'github' | 'linear' | 'jira',\n\t\t\t\tsettings,\n\t\t\t)\n\t\t\tawait metadataManager.updateMetadata(epicWorktreePath, { mcpConfigPath: epicMcpConfigPath })\n\n\t\t\t// Write MCP config path to .claude/iloom-swarm-mcp-config-path for worker discovery\n\t\t\tconst epicClaudeDir = path.join(epicWorktreePath, '.claude')\n\t\t\tawait fs.ensureDir(epicClaudeDir)\n\t\t\tawait fs.writeFile(\n\t\t\t\tpath.join(epicClaudeDir, 'iloom-swarm-mcp-config-path'),\n\t\t\t\tepicMcpConfigPath,\n\t\t\t\t'utf-8',\n\t\t\t)\n\n\t\t\tlogger.debug('Wrote MCP config for epic loom', { epicMcpConfigPath })\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to write MCP config for epic loom: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Build MCP configs for the orchestrator's own launchClaude call\n\t\tconst mcpConfigs: Record<string, unknown>[] = []\n\n\t\t// Issue management MCP\n\t\ttry {\n\t\t\tconst issueMcpConfigs = await generateIssueManagementMcpConfig(\n\t\t\t\t'issue',\n\t\t\t\tundefined,\n\t\t\t\tproviderName as 'github' | 'linear' | 'jira',\n\t\t\t\tsettings,\n\t\t\t)\n\t\t\tmcpConfigs.push(...issueMcpConfigs)\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to generate issue management MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Recap MCP for the epic loom\n\t\ttry {\n\t\t\tconst recapMcpConfigs = generateRecapMcpConfig(epicWorktreePath, metadata)\n\t\t\tmcpConfigs.push(...recapMcpConfigs)\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to generate recap MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Run swarm setup: child worktrees, agents, worker agent\n\t\tconst swarmResult = await swarmSetup.setupSwarm(\n\t\t\tepicIssueNumber,\n\t\t\tepicBranch,\n\t\t\tepicWorktreePath,\n\t\t\tmetadata.childIssues,\n\t\t\tmainWorktreePath,\n\t\t\tproviderName,\n\t\t\tsettings,\n\t\t)\n\n\t\t// Build template variables for orchestrator prompt\n\t\tconst successfulWorktrees = swarmResult.childWorktrees.filter((c) => c.success)\n\t\tconst worktreeMap = new Map(successfulWorktrees.map((cw) => [cw.issueId, cw]))\n\n\t\tconst childIssuesData = metadata.childIssues\n\t\t\t.filter((ci) => worktreeMap.has(ci.number.replace(/^#/, '')))\n\t\t\t.map((ci) => {\n\t\t\t\tconst rawId = ci.number.replace(/^#/, '')\n\t\t\t\tconst wt = worktreeMap.get(rawId)\n\t\t\t\treturn {\n\t\t\t\t\tnumber: rawId,\n\t\t\t\t\ttitle: ci.title,\n\t\t\t\t\tbody: ci.body,\n\t\t\t\t\tworktreePath: wt?.worktreePath ?? '',\n\t\t\t\t\tbranchName: wt?.branch ?? '',\n\t\t\t\t}\n\t\t\t})\n\n\t\t// Get metadata file path for the orchestrator prompt template\n\t\tconst epicMetadataPath = metadataManager.getMetadataFilePath(epicWorktreePath)\n\n\t\t// Determine issue prefix for commit message trailers\n\t\tconst issuePrefix = providerName === 'github' ? '#' : ''\n\n\t\tconst variables: TemplateVariables = {\n\t\t\tEPIC_ISSUE_NUMBER: epicIssueNumber,\n\t\t\tEPIC_WORKTREE_PATH: epicWorktreePath,\n\t\t\tEPIC_METADATA_PATH: epicMetadataPath,\n\t\t\tCHILD_ISSUES: JSON.stringify(childIssuesData, null, 2),\n\t\t\tDEPENDENCY_MAP: JSON.stringify(metadata.dependencyMap, null, 2),\n\t\t\tISSUE_PREFIX: issuePrefix,\n\t\t\t...(skipCleanup && { NO_CLEANUP: true }),\n\t\t}\n\n\t\t// Set draft PR mode flags for swarm orchestrator (same logic as buildTemplateVariables)\n\t\tconst draftPrNumber = metadata.draftPrNumber ?? undefined\n\t\tif (draftPrNumber !== undefined) {\n\t\t\tvariables.DRAFT_PR_MODE = true\n\t\t\tvariables.DRAFT_PR_NUMBER = draftPrNumber\n\t\t\tconst draftPrUrl = metadata.prUrls?.[String(draftPrNumber)]\n\t\t\tif (draftPrUrl) {\n\t\t\t\tvariables.DRAFT_PR_URL = draftPrUrl\n\t\t\t}\n\t\t\tconst autoCommitPushEnabled = settings.mergeBehavior?.autoCommitPush !== false\n\t\t\tvariables.AUTO_COMMIT_PUSH = autoCommitPushEnabled\n\t\t\tconst remote = settings.mergeBehavior?.remote ?? 'origin'\n\t\t\tif (!/^[a-zA-Z0-9_-]+$/.test(remote)) {\n\t\t\t\tthrow new Error(`Invalid git remote name: \"${remote}\". Remote names can only contain alphanumeric characters, underscores, and hyphens.`)\n\t\t\t}\n\t\t\tvariables.GIT_REMOTE = remote\n\t\t}\n\n\t\tconst orchestratorPrompt = await this.templateManager.getPrompt('swarm-orchestrator', variables)\n\n\t\t// Build allowed tools\n\t\tconst allowedTools = [\n\t\t\t'mcp__issue_management__get_issue',\n\t\t\t'mcp__issue_management__get_comment',\n\t\t\t'mcp__issue_management__create_comment',\n\t\t\t'mcp__issue_management__update_comment',\n\t\t\t'mcp__issue_management__create_issue',\n\t\t\t'mcp__issue_management__close_issue',\n\t\t\t'mcp__issue_management__reopen_issue',\n\t\t\t'mcp__issue_management__edit_issue',\n\t\t\t'mcp__recap__add_entry',\n\t\t\t'mcp__recap__get_recap',\n\t\t\t'mcp__recap__add_artifact',\n\t\t\t'mcp__recap__set_complexity',\n\t\t\t'mcp__recap__set_loom_state',\n\t\t\t'mcp__recap__get_loom_state',\n\t\t]\n\n\t\t// Launch Claude with agent teams enabled\n\t\tconst model = this.settingsManager.getSpinModel(settings, 'swarm')\n\n\t\tlogger.info('Launching swarm orchestrator...')\n\t\tlogger.info(` Model: ${model ?? 'default'}`)\n\t\tlogger.info(` Permission mode: bypassPermissions`)\n\t\tlogger.info(` Agent teams: enabled`)\n\t\tlogger.info(` Child worktrees: ${successfulWorktrees.length}`)\n\n\t\t// Load agents for the orchestrator\n\t\tlet agents: Record<string, unknown> | undefined\n\t\ttry {\n\t\t\tconst loadedAgents = await this.agentManager.loadAgents(\n\t\t\t\tsettings,\n\t\t\t\tvariables,\n\t\t\t\t['*.md', '!iloom-framework-detector.md']\n\t\t\t)\n\t\t\tagents = this.agentManager.formatForCli(loadedAgents)\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to load agents: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Track swarm.started before launching orchestrator\n\t\tconst swarmStartTime = Date.now()\n\t\ttry {\n\t\t\tTelemetryService.getInstance().track('swarm.started', {\n\t\t\t\tchild_count: successfulWorktrees.length,\n\t\t\t\ttracker: providerName,\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tlogger.debug(`Telemetry swarm.started tracking failed: ${error instanceof Error ? error.message : error}`)\n\t\t}\n\n\t\tawait launchClaude(\n\t\t\t`You are the swarm orchestrator for epic #${epicIssueNumber}. Begin by reading your system prompt instructions and executing the workflow.`,\n\t\t\t{\n\t\t\t\tmodel,\n\t\t\t\tpermissionMode: 'bypassPermissions',\n\t\t\t\taddDir: epicWorktreePath,\n\t\t\t\theadless: false,\n\t\t\t\t...(metadata.sessionId && { sessionId: metadata.sessionId }),\n\t\t\t\tappendSystemPrompt: orchestratorPrompt,\n\t\t\t\tmcpConfig: mcpConfigs,\n\t\t\t\tallowedTools,\n\t\t\t\t...(agents && { agents }),\n\t\t\t\tenv: {\n\t\t\t\t\tCLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1',\n\t\t\t\t\tILOOM_SWARM: '1',\n\t\t\t\t\tENABLE_TOOL_SEARCH: 'auto:30',\n\t\t\t\t},\n\t\t\t},\n\t\t)\n\n\t\t// Track swarm child completions and overall completion\n\t\ttry {\n\t\t\tconst swarmEndTime = Date.now()\n\t\t\tlet succeeded = 0\n\t\t\tlet failed = 0\n\n\t\t\tfor (const child of successfulWorktrees) {\n\t\t\t\tconst childMeta = await metadataManager.readMetadata(child.worktreePath)\n\t\t\t\tconst isSuccess = childMeta?.state === 'done'\n\t\t\t\tif (isSuccess) {\n\t\t\t\t\tsucceeded++\n\t\t\t\t} else {\n\t\t\t\t\tfailed++\n\t\t\t\t}\n\n\t\t\t\tconst parsed = childMeta?.created_at ? Date.parse(childMeta.created_at) : NaN\n\t\t\t\tconst childCreatedAt = Number.isNaN(parsed) ? swarmStartTime : parsed\n\t\t\t\tconst childDuration = Math.max(0, Math.round((swarmEndTime - childCreatedAt) / 60000))\n\n\t\t\t\tTelemetryService.getInstance().track('swarm.child_completed', {\n\t\t\t\t\tsuccess: isSuccess,\n\t\t\t\t\tduration_minutes: childDuration,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tTelemetryService.getInstance().track('swarm.completed', {\n\t\t\t\ttotal_children: successfulWorktrees.length,\n\t\t\t\tsucceeded,\n\t\t\t\tfailed,\n\t\t\t\tduration_minutes: Math.round((swarmEndTime - swarmStartTime) / 60000),\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tlogger.debug(`Telemetry swarm completion tracking failed: ${error instanceof Error ? error.message : error}`)\n\t\t}\n\t}\n\n\t/**\n\t * Build user prompt based on one-shot mode\n\t */\n\tprivate buildUserPrompt(oneShot: OneShotMode = 'default'): string {\n\t\t// For one-shot modes, add bypass instructions to override template approval requirements\n\t\tif (oneShot === 'noReview' || oneShot === 'bypassPermissions') {\n\t\t\treturn 'Guide the user through the iloom workflow! The user has requested you move through the workflow without awaiting confirmation. This supersedes any other guidance.'\n\t\t}\n\n\t\t// Default mode: simple \"Go!\" prompt\n\t\treturn 'Guide the user through the iloom workflow!'\n\t}\n\n\t/**\n\t * Load README.md content for first-time users\n\t * Walks up from dist directory to find README.md in project root\n\t */\n\tprivate async loadReadmeContent(): Promise<string> {\n\t\ttry {\n\t\t\t// Walk up from current file location to find README.md\n\t\t\t// Use same pattern as PromptTemplateManager for finding files\n\t\t\tlet currentDir = path.dirname(new URL(import.meta.url).pathname)\n\n\t\t\t// Walk up to find README.md\n\t\t\twhile (currentDir !== path.dirname(currentDir)) {\n\t\t\t\tconst readmePath = path.join(currentDir, 'README.md')\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await readFile(readmePath, 'utf-8')\n\t\t\t\t\tlogger.debug('Loaded README.md for first-time user', { readmePath })\n\t\t\t\t\treturn content\n\t\t\t\t} catch {\n\t\t\t\t\tcurrentDir = path.dirname(currentDir)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug('README.md not found, returning empty string')\n\t\t\treturn ''\n\t\t} catch (error) {\n\t\t\t// Graceful degradation - return empty string on error\n\t\t\tlogger.debug(`Failed to load README.md: ${error}`)\n\t\t\treturn ''\n\t\t}\n\t}\n\n\t/**\n\t * Load settings schema content for first-time users\n\t * Walks up from dist directory to find .iloom/README.md\n\t */\n\tprivate async loadSettingsSchemaContent(): Promise<string> {\n\t\ttry {\n\t\t\t// Walk up from current file location to find .iloom/README.md\n\t\t\tlet currentDir = path.dirname(new URL(import.meta.url).pathname)\n\n\t\t\t// Walk up to find .iloom/README.md\n\t\t\twhile (currentDir !== path.dirname(currentDir)) {\n\t\t\t\tconst schemaPath = path.join(currentDir, '.iloom', 'README.md')\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await readFile(schemaPath, 'utf-8')\n\t\t\t\t\tlogger.debug('Loaded .iloom/README.md for first-time user', { schemaPath })\n\t\t\t\t\treturn content\n\t\t\t\t} catch {\n\t\t\t\t\tcurrentDir = path.dirname(currentDir)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug('.iloom/README.md not found, returning empty string')\n\t\t\treturn ''\n\t\t} catch (error) {\n\t\t\t// Graceful degradation - return empty string on error\n\t\t\tlogger.debug(`Failed to load .iloom/README.md: ${error}`)\n\t\t\treturn ''\n\t\t}\n\t}\n}\n","import os from 'os'\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { parse, modify, applyEdits, ParseError } from 'jsonc-parser'\nimport { fileURLToPath } from 'url'\nimport { accessSync } from 'fs'\nimport { logger } from '../utils/logger.js'\n\n/**\n * Hook configuration for a single event\n */\ninterface HookEntry {\n\ttype: 'command'\n\tcommand: string\n\ttimeout?: number\n}\n\n/**\n * Hook event configuration\n */\ninterface HookEventConfig {\n\tmatcher?: string\n\thooks: HookEntry[]\n}\n\n/**\n * Claude settings.json structure (partial)\n */\ninterface ClaudeSettings {\n\thooks?: Record<string, HookEventConfig[]>\n\t[key: string]: unknown\n}\n\n/**\n * Manages installation of Claude Code hooks to ~/.claude/\n *\n * Hooks enable real-time monitoring of Claude session state\n * via Unix socket communication with the iloom-vscode extension.\n */\nexport class ClaudeHookManager {\n\tprivate claudeDir: string\n\tprivate hooksDir: string\n\tprivate settingsPath: string\n\tprivate templateDir: string\n\n\tconstructor() {\n\t\t// Initialize paths using os.homedir()\n\t\tthis.claudeDir = path.join(os.homedir(), '.claude')\n\t\tthis.hooksDir = path.join(this.claudeDir, 'hooks')\n\t\tthis.settingsPath = path.join(this.claudeDir, 'settings.json')\n\n\t\t// Find templates relative to the package installation\n\t\t// Same pattern as PromptTemplateManager\n\t\tconst currentFileUrl = import.meta.url\n\t\tconst currentFilePath = fileURLToPath(currentFileUrl)\n\t\tconst distDir = path.dirname(currentFilePath)\n\n\t\t// Walk up to find the hooks template directory\n\t\tlet templateDir = path.join(distDir, 'hooks')\n\t\tlet currentDir = distDir\n\n\t\twhile (currentDir !== path.dirname(currentDir)) {\n\t\t\tconst candidatePath = path.join(currentDir, 'hooks')\n\t\t\ttry {\n\t\t\t\taccessSync(candidatePath)\n\t\t\t\ttemplateDir = candidatePath\n\t\t\t\tbreak\n\t\t\t} catch {\n\t\t\t\tcurrentDir = path.dirname(currentDir)\n\t\t\t}\n\t\t}\n\n\t\tthis.templateDir = templateDir\n\t\tlogger.debug('ClaudeHookManager initialized', {\n\t\t\tclaudeDir: this.claudeDir,\n\t\t\thooksDir: this.hooksDir,\n\t\t\tsettingsPath: this.settingsPath,\n\t\t\ttemplateDir: this.templateDir\n\t\t})\n\t}\n\n\t/**\n\t * Install Claude hooks for VSCode integration\n\t *\n\t * This is idempotent - safe to call on every spin.\n\t * Installs hook script to ~/.claude/hooks/ and merges\n\t * hook configuration into ~/.claude/settings.json\n\t */\n\tasync installHooks(): Promise<void> {\n\t\ttry {\n\t\t\t// 1. Create ~/.claude/hooks if missing\n\t\t\tawait fs.ensureDir(this.hooksDir)\n\n\t\t\t// 2. Install hook script from bundled templates\n\t\t\tawait this.installHookScript()\n\n\t\t\t// 3. Merge hook config into settings.json\n\t\t\tawait this.mergeHookConfig()\n\n\t\t\tlogger.debug('Claude hooks installed successfully')\n\t\t} catch (error) {\n\t\t\t// Log warning but don't fail - hooks are optional enhancement\n\t\t\tlogger.warn(\n\t\t\t\t`Failed to install Claude hooks: ${error instanceof Error ? error.message : 'Unknown error'}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Check if hooks are already installed\n\t */\n\tasync isHooksInstalled(): Promise<boolean> {\n\t\ttry {\n\t\t\t// Check if hook script exists\n\t\t\tconst hookScriptPath = path.join(this.hooksDir, 'iloom-hook.js')\n\t\t\tif (!(await fs.pathExists(hookScriptPath))) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Check if settings.json has our hooks\n\t\t\tif (!(await fs.pathExists(this.settingsPath))) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tconst content = await fs.readFile(this.settingsPath, 'utf8')\n\t\t\tconst errors: ParseError[] = []\n\t\t\tconst settings = parse(content, errors, { allowTrailingComma: true }) as ClaudeSettings\n\n\t\t\tif (errors.length > 0 || !settings?.hooks) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Check if our hooks are registered (check for SessionStart as indicator)\n\t\t\treturn Array.isArray(settings.hooks.SessionStart)\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Install the hook script from bundled templates\n\t * Skips write if destination already has identical content\n\t */\n\tprivate async installHookScript(): Promise<void> {\n\t\tconst sourcePath = path.join(this.templateDir, 'iloom-hook.js')\n\t\tconst destPath = path.join(this.hooksDir, 'iloom-hook.js')\n\n\t\t// Check if source template exists\n\t\tif (!(await fs.pathExists(sourcePath))) {\n\t\t\tthrow new Error(`Hook template not found at ${sourcePath}`)\n\t\t}\n\n\t\t// Skip if destination exists and content matches\n\t\tif (await fs.pathExists(destPath)) {\n\t\t\tconst [sourceContent, destContent] = await Promise.all([\n\t\t\t\tfs.readFile(sourcePath, 'utf8'),\n\t\t\t\tfs.readFile(destPath, 'utf8')\n\t\t\t])\n\t\t\tif (sourceContent === destContent) {\n\t\t\t\tlogger.debug('Hook script already up to date, skipping')\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Copy hook script (only when content differs or doesn't exist)\n\t\tawait fs.copyFile(sourcePath, destPath)\n\t\tlogger.debug('Hook script installed', { sourcePath, destPath })\n\t}\n\n\t/**\n\t * Merge hook configuration into settings.json\n\t * Preserves existing user hooks and comments\n\t */\n\tprivate async mergeHookConfig(): Promise<void> {\n\t\t// Ensure ~/.claude directory exists\n\t\tawait fs.ensureDir(this.claudeDir)\n\n\t\t// Read existing settings (or create empty)\n\t\tlet existingContent = '{}'\n\t\tlet existingSettings: ClaudeSettings = {}\n\n\t\tif (await fs.pathExists(this.settingsPath)) {\n\t\t\texistingContent = await fs.readFile(this.settingsPath, 'utf8')\n\t\t\tconst errors: ParseError[] = []\n\t\t\texistingSettings = parse(existingContent, errors, { allowTrailingComma: true }) as ClaudeSettings\n\n\t\t\tif (errors.length > 0) {\n\t\t\t\tlogger.warn('Existing settings.json has parse errors, will attempt to merge anyway')\n\t\t\t}\n\t\t}\n\n\t\t// Get our hook configuration\n\t\tconst ourHooks = this.getHookConfig()\n\n\t\t// Merge hooks - preserve user's existing hooks on same events\n\t\tconst mergedHooks: Record<string, HookEventConfig[]> = { ...(existingSettings.hooks ?? {}) }\n\t\tlet hooksAdded = false\n\n\t\tfor (const [eventName, eventConfigs] of Object.entries(ourHooks)) {\n\t\t\tconst existing = mergedHooks[eventName] ?? []\n\n\t\t\t// Check if our hook is already registered\n\t\t\tconst ourConfig = eventConfigs[0]\n\t\t\tconst ourCommand = ourConfig?.hooks?.[0]?.command\n\t\t\tconst existingConfigIndex = existing.findIndex(\n\t\t\t\t(config) => config.hooks?.some((h) => h.command === ourCommand)\n\t\t\t)\n\n\t\t\tif (existingConfigIndex === -1) {\n\t\t\t\t// Add our hook config to the event\n\t\t\t\tmergedHooks[eventName] = [...existing, ...eventConfigs]\n\t\t\t\thooksAdded = true\n\t\t\t} else {\n\t\t\t\t// Hook is already registered - check if we need to update the matcher\n\t\t\t\tconst existingConfig = existing[existingConfigIndex]\n\t\t\t\tconst ourMatcher = ourConfig?.matcher\n\n\t\t\t\t// Update matcher if our config has one and existing doesn't match\n\t\t\t\tif (existingConfig && ourMatcher !== undefined && existingConfig.matcher !== ourMatcher) {\n\t\t\t\t\texisting[existingConfigIndex] = {\n\t\t\t\t\t\t...existingConfig,\n\t\t\t\t\t\tmatcher: ourMatcher\n\t\t\t\t\t}\n\t\t\t\t\thooksAdded = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Skip write if no new hooks were added\n\t\tif (!hooksAdded) {\n\t\t\tlogger.debug('All hooks already registered, skipping settings.json update')\n\t\t\treturn\n\t\t}\n\n\t\t// Write updated settings\n\t\tlet content: string\n\n\t\t// Check if existing content has comments\n\t\tif (existingContent.includes('//') || existingContent.includes('/*')) {\n\t\t\t// Use jsonc-parser to preserve comments\n\t\t\tlet modifiedContent = existingContent\n\t\t\tconst edits = modify(modifiedContent, ['hooks'], mergedHooks, {})\n\t\t\tcontent = applyEdits(modifiedContent, edits)\n\t\t} else {\n\t\t\t// No comments - use JSON.stringify\n\t\t\tconst updatedSettings: ClaudeSettings = {\n\t\t\t\t...existingSettings,\n\t\t\t\thooks: mergedHooks\n\t\t\t}\n\t\t\tcontent = JSON.stringify(updatedSettings, null, 2) + '\\n'\n\t\t}\n\n\t\t// Write atomically using temp file + rename\n\t\tconst tempPath = `${this.settingsPath}.tmp`\n\t\tawait fs.writeFile(tempPath, content, 'utf8')\n\t\tawait fs.rename(tempPath, this.settingsPath)\n\n\t\tlogger.debug('Hook configuration merged into settings.json')\n\t}\n\n\t/**\n\t * Get the hook configuration to register\n\t *\n\t * Each event maps to a hook that runs iloom-hook.js\n\t */\n\tprivate getHookConfig(): Record<string, HookEventConfig[]> {\n\t\tconst hookCommand = `node ${path.join(this.hooksDir, 'iloom-hook.js')}`\n\n\t\treturn {\n\t\t\tNotification: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tStop: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tSubagentStop: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tPermissionRequest: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand, timeout: 86400 }] }\n\t\t\t],\n\t\t\tPreToolUse: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tPostToolUse: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tSessionStart: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tSessionEnd: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tUserPromptSubmit: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t]\n\t\t}\n\t}\n}\n","import path from 'path'\nimport fs from 'fs-extra'\nimport { GitWorktreeManager } from './GitWorktreeManager.js'\nimport { MetadataManager, type WriteMetadataInput, type SwarmState } from './MetadataManager.js'\nimport { AgentManager } from './AgentManager.js'\nimport { SettingsManager, type IloomSettings } from './SettingsManager.js'\nimport { PromptTemplateManager, buildReviewTemplateVariables, type TemplateVariables } from './PromptTemplateManager.js'\nimport { IssueTrackerFactory } from './IssueTrackerFactory.js'\nimport { IssueManagementProviderFactory } from '../mcp/IssueManagementProviderFactory.js'\nimport { getLogger } from '../utils/logger-context.js'\nimport { installDependencies } from '../utils/package-manager.js'\nimport { generateWorktreePath } from '../utils/git.js'\nimport { generateAndWriteMcpConfigFile } from '../utils/mcp.js'\n\n/**\n * Result of the swarm setup process\n */\nexport interface SwarmSetupResult {\n\tepicWorktreePath: string\n\tepicBranch: string\n\tchildWorktrees: Array<{\n\t\tissueId: string\n\t\tworktreePath: string\n\t\tbranch: string\n\t\tsuccess: boolean\n\t\terror?: string\n\t}>\n\tagentsRendered: string[]\n\tworkerAgentRendered: boolean\n}\n\n/**\n * Metadata extracted from agent YAML frontmatter for use in claude -p commands.\n * Maps agent file name (without .md) to model and tools info.\n */\nexport interface SwarmAgentMetadata {\n\t[agentFileName: string]: {\n\t\tmodel: string\n\t\ttools?: string[]\n\t}\n}\n\n/**\n * Child issue data as stored in epic metadata\n */\nexport interface SwarmChildIssue {\n\tnumber: string // Prefixed: \"#123\" for GitHub, \"ENG-123\" for Linear\n\ttitle: string\n\tbody: string\n\turl: string\n}\n\n/**\n * SwarmSetupService handles the creation of child worktrees\n * for swarm mode, plus rendering swarm-mode agents and skill files.\n *\n * Called from the spin command (ignite.ts) when an epic loom is detected.\n * The epic worktree already exists (created by `il start`).\n */\nexport class SwarmSetupService {\n\tconstructor(\n\t\tprivate gitWorktree: GitWorktreeManager,\n\t\tprivate metadataManager: MetadataManager,\n\t\tprivate agentManager: AgentManager,\n\t\tprivate settingsManager: SettingsManager,\n\t\tprivate templateManager: PromptTemplateManager,\n\t) {}\n\n\t/**\n\t * Create child worktrees for each child issue, branched off the epic branch.\n\t * Writes iloom-metadata.json for each child with state: 'pending' and parentLoom.\n\t * Generates and writes per-loom MCP config file for each child.\n\t *\n\t * Uses standard iloom naming conventions via generateWorktreePath().\n\t *\n\t * @param childIssues - Array of child issues from epic metadata\n\t * @param epicBranch - The epic branch name (base branch for children)\n\t * @param epicWorktreePath - Path to the epic worktree\n\t * @param mainWorktreePath - Path to the main worktree (project root)\n\t * @param epicIssueNumber - The parent epic issue number\n\t * @param issueTrackerName - The issue tracker provider name (e.g., 'github')\n\t * @param settings - Optional settings for MCP config generation\n\t * @returns Array of results for each child worktree creation\n\t */\n\tasync createChildWorktrees(\n\t\tchildIssues: SwarmChildIssue[],\n\t\tepicBranch: string,\n\t\tepicWorktreePath: string,\n\t\tmainWorktreePath: string,\n\t\tepicIssueNumber: string | number,\n\t\tissueTrackerName: string,\n\t\tsettings?: IloomSettings,\n\t): Promise<SwarmSetupResult['childWorktrees']> {\n\t\treturn Promise.all(childIssues.map(async (child) => {\n\t\t\ttry {\n\t\t\t\t// Strip prefix from child number (e.g., \"#123\" -> \"123\", \"ENG-123\" stays as-is for branch naming)\n\t\t\t\tconst rawId = child.number.replace(/^#/, '')\n\n\t\t\t\t// Sanitize ID for safe git branch naming (replace non-alphanumeric except - and _ with -)\n\t\t\t\tconst safeId = rawId.replace(/[^a-zA-Z0-9-_]/g, '-')\n\n\t\t\t\t// Use standard iloom branch naming: issue/<id> pattern\n\t\t\t\tconst childBranch = `issue/${safeId}`\n\n\t\t\t\t// Use standard iloom worktree path generation\n\t\t\t\tconst childWorktreePath = generateWorktreePath(\n\t\t\t\t\tchildBranch,\n\t\t\t\t\tmainWorktreePath,\n\t\t\t\t)\n\n\t\t\t\tgetLogger().info(`Creating child worktree for ${child.number}: ${childWorktreePath}...`)\n\n\t\t\t\tawait this.gitWorktree.createWorktree({\n\t\t\t\t\tpath: childWorktreePath,\n\t\t\t\t\tbranch: childBranch,\n\t\t\t\t\tcreateBranch: true,\n\t\t\t\t\tbaseBranch: epicBranch,\n\t\t\t\t})\n\n\t\t\t\t// Write metadata with state: 'pending' and parentLoom\n\t\t\t\tconst metadataInput: WriteMetadataInput = {\n\t\t\t\t\tdescription: child.title,\n\t\t\t\t\tbranchName: childBranch,\n\t\t\t\t\tworktreePath: childWorktreePath,\n\t\t\t\t\tissueType: 'issue',\n\t\t\t\t\tissue_numbers: [rawId],\n\t\t\t\t\tpr_numbers: [],\n\t\t\t\t\tissueTracker: issueTrackerName,\n\t\t\t\t\tcolorHex: '#808080',\n\t\t\t\t\tsessionId: '', // No session - not launching Claude directly\n\t\t\t\t\tprojectPath: mainWorktreePath,\n\t\t\t\t\tissueUrls: { [rawId]: child.url },\n\t\t\t\t\tprUrls: {},\n\t\t\t\t\tcapabilities: [],\n\t\t\t\t\tstate: 'pending' as SwarmState,\n\t\t\t\t\tparentLoom: {\n\t\t\t\t\t\ttype: 'epic',\n\t\t\t\t\t\tidentifier: epicIssueNumber,\n\t\t\t\t\t\tbranchName: epicBranch,\n\t\t\t\t\t\tworktreePath: epicWorktreePath,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait this.metadataManager.writeMetadata(childWorktreePath, metadataInput)\n\t\t\t\t} catch (metaError) {\n\t\t\t\t\t// Clean up the worktree to avoid zombie worktrees without metadata\n\t\t\t\t\tgetLogger().warn(`Metadata write failed for ${child.number}, cleaning up worktree...`)\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.gitWorktree.removeWorktree(childWorktreePath, { force: true })\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tgetLogger().debug(`Could not clean up worktree at ${childWorktreePath}`)\n\t\t\t\t\t}\n\t\t\t\t\tthrow metaError\n\t\t\t\t}\n\n\t\t\t\t// Generate and write per-loom MCP config file\n\t\t\t\ttry {\n\t\t\t\t\tconst childMetadata = await this.metadataManager.readMetadata(childWorktreePath)\n\t\t\t\t\tif (childMetadata) {\n\t\t\t\t\t\tconst providerName = IssueTrackerFactory.getProviderName(\n\t\t\t\t\t\t\tsettings ?? await this.settingsManager.loadSettings(),\n\t\t\t\t\t\t) as 'github' | 'linear' | 'jira'\n\t\t\t\t\t\tconst mcpConfigPath = await generateAndWriteMcpConfigFile(\n\t\t\t\t\t\t\tchildWorktreePath,\n\t\t\t\t\t\t\tchildMetadata,\n\t\t\t\t\t\t\tproviderName,\n\t\t\t\t\t\t\tsettings,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tawait this.metadataManager.updateMetadata(childWorktreePath, { mcpConfigPath })\n\n\t\t\t\t\t\t// Write MCP config path to .claude/iloom-swarm-mcp-config-path for worker discovery\n\t\t\t\t\t\tconst claudeDir = path.join(childWorktreePath, '.claude')\n\t\t\t\t\t\tawait fs.ensureDir(claudeDir)\n\t\t\t\t\t\tawait fs.writeFile(\n\t\t\t\t\t\t\tpath.join(claudeDir, 'iloom-swarm-mcp-config-path'),\n\t\t\t\t\t\t\tmcpConfigPath,\n\t\t\t\t\t\t\t'utf-8',\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tgetLogger().debug(`Wrote MCP config for ${child.number}: ${mcpConfigPath}`)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Non-fatal: child can still work without MCP config\n\t\t\t\t\tgetLogger().warn(\n\t\t\t\t\t\t`Failed to write MCP config for child ${child.number}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\t// Install dependencies in the child worktree\n\t\t\t\ttry {\n\t\t\t\t\tawait installDependencies(childWorktreePath, true, true)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tgetLogger().warn(\n\t\t\t\t\t\t`Failed to install dependencies in child worktree ${child.number}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tgetLogger().success(`Created child worktree for ${child.number}`)\n\t\t\t\treturn {\n\t\t\t\t\tissueId: rawId,\n\t\t\t\t\tworktreePath: childWorktreePath,\n\t\t\t\t\tbranch: childBranch,\n\t\t\t\t\tsuccess: true,\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst rawId = child.number.replace(/^#/, '')\n\t\t\t\tconst errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\t\t\t\tgetLogger().warn(`Failed to create child worktree for ${child.number}: ${errorMessage}`)\n\t\t\t\treturn {\n\t\t\t\t\tissueId: rawId,\n\t\t\t\t\tworktreePath: '',\n\t\t\t\t\tbranch: '',\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: errorMessage,\n\t\t\t\t}\n\t\t\t}\n\t\t}))\n\t}\n\n\t/**\n\t * Render swarm-mode agent templates to the epic worktree's .claude/agents/ directory.\n\t *\n\t * Phase agent files are written WITHOUT frontmatter (prompt body only) because they are\n\t * loaded via `--append-system-prompt-file` which does not parse YAML frontmatter.\n\t * Model and tools metadata is extracted from the agent config and returned separately\n\t * for use as CLI flags in `claude -p` commands.\n\t */\n\tasync renderSwarmAgents(epicWorktreePath: string): Promise<{\n\t\trenderedFiles: string[]\n\t\tmetadata: SwarmAgentMetadata\n\t}> {\n\t\tconst claudeAgentsDir = path.join(epicWorktreePath, '.claude', 'agents')\n\t\tawait fs.ensureDir(claudeAgentsDir)\n\n\t\tconst settings = await this.settingsManager.loadSettings()\n\n\t\tconst templateVariables: TemplateVariables = {\n\t\t\tSWARM_MODE: true,\n\t\t}\n\n\t\tconst agents = await this.agentManager.loadAgents(settings, templateVariables)\n\n\t\t// Default swarmModel map for \"Balanced\" mode. All swarm phase agents are\n\t\t// listed explicitly so that swarm mode never accidentally inherits a\n\t\t// non-swarm model override. User-configured swarmModel values always\n\t\t// take precedence.\n\t\tconst defaultSwarmModels: Record<string, 'sonnet' | 'opus' | 'haiku'> = {\n\t\t\t'iloom-issue-analyzer': 'opus',\n\t\t\t'iloom-issue-analyze-and-plan': 'opus',\n\t\t\t'iloom-issue-planner': 'sonnet',\n\t\t\t'iloom-issue-implementer': 'sonnet',\n\t\t\t'iloom-issue-enhancer': 'sonnet',\n\t\t\t'iloom-code-reviewer': 'sonnet',\n\t\t\t'iloom-issue-complexity-evaluator': 'haiku',\n\t\t}\n\n\t\t// Apply per-agent swarmModel overrides (user-configured takes precedence over defaults)\n\t\tfor (const [agentName, agentConfig] of Object.entries(agents)) {\n\t\t\tconst userSwarmModel = settings?.agents?.[agentName]?.swarmModel\n\t\t\tif (userSwarmModel) {\n\t\t\t\tagents[agentName] = { ...agentConfig, model: userSwarmModel }\n\t\t\t} else if (defaultSwarmModels[agentName]) {\n\t\t\t\tagents[agentName] = { ...agentConfig, model: defaultSwarmModels[agentName] }\n\t\t\t}\n\t\t}\n\n\t\tconst renderedFiles: string[] = []\n\t\tconst metadata: SwarmAgentMetadata = {}\n\n\t\tfor (const [agentName, agentConfig] of Object.entries(agents)) {\n\t\t\tconst swarmFileName = agentName.startsWith('iloom-')\n\t\t\t\t? `iloom-swarm-${agentName.slice('iloom-'.length)}.md`\n\t\t\t\t: `iloom-swarm-${agentName}.md`\n\n\t\t\tconst agentKey = swarmFileName.replace('.md', '')\n\n\t\t\t// Extract metadata from agent config for use in claude -p CLI flags\n\t\t\tmetadata[agentKey] = {\n\t\t\t\tmodel: agentConfig.model,\n\t\t\t\t...(agentConfig.tools && { tools: agentConfig.tools }),\n\t\t\t}\n\n\t\t\t// Write file WITHOUT frontmatter - prompt body only\n\t\t\t// Phase agents are loaded via --append-system-prompt-file which does not parse YAML frontmatter\n\t\t\tconst outputPath = path.join(claudeAgentsDir, swarmFileName)\n\t\t\tawait fs.writeFile(outputPath, agentConfig.prompt + '\\n', 'utf-8')\n\t\t\trenderedFiles.push(swarmFileName)\n\t\t\tgetLogger().debug(`Rendered swarm agent: ${swarmFileName}`)\n\t\t}\n\n\t\tgetLogger().success(`Rendered ${renderedFiles.length} swarm agents to ${claudeAgentsDir}`)\n\t\treturn { renderedFiles, metadata }\n\t}\n\n\t/**\n\t * Render the swarm worker agent file to the epic worktree's .claude/agents/ directory.\n\t *\n\t * This creates an agent file at `.claude/agents/iloom-swarm-worker.md` containing\n\t * the full iloom workflow instructions (rendered from issue-prompt.txt with SWARM_MODE=true).\n\t * The orchestrator spawns children with `subagent_type: \"iloom-swarm-worker\"` so these\n\t * instructions become the agent's system prompt (high authority), rather than arriving\n\t * as a skill invocation (low authority user message).\n\t *\n\t * The agent file is shared across all children. Issue-specific context (number, title,\n\t * worktree path, body) is provided per-child via the Task prompt from the orchestrator.\n\t */\n\tasync renderSwarmWorkerAgent(\n\t\tepicWorktreePath: string,\n\t\tagentMetadata?: SwarmAgentMetadata,\n\t): Promise<boolean> {\n\t\tconst agentsDir = path.join(epicWorktreePath, '.claude', 'agents')\n\t\tconst agentOutputPath = path.join(agentsDir, 'iloom-swarm-worker.md')\n\n\t\tawait fs.ensureDir(agentsDir)\n\n\t\ttry {\n\t\t\t// Load settings for review configuration and issue prefix\n\t\t\tconst settings = await this.settingsManager.loadSettings()\n\t\t\tconst providerType = settings?.issueManagement?.provider ?? 'github'\n\t\t\tconst issuePrefix = IssueManagementProviderFactory.create(providerType, settings ?? undefined).issuePrefix\n\n\t\t\t// Compute sub-agent timeout in milliseconds (default: 10 minutes)\n\t\t\tconst subAgentTimeoutMinutes = settings?.agents?.['iloom-swarm-worker']?.subAgentTimeout ?? 10\n\t\t\tconst subAgentTimeoutMs = subAgentTimeoutMinutes * 60 * 1000\n\n\t\t\t// Build template variables for swarm worker agent rendering\n\t\t\tconst variables: TemplateVariables = {\n\t\t\t\tSWARM_MODE: true,\n\t\t\t\tONE_SHOT_MODE: true,\n\t\t\t\tEPIC_WORKTREE_PATH: epicWorktreePath,\n\t\t\t\tISSUE_PREFIX: issuePrefix,\n\t\t\t\tSWARM_SUB_AGENT_TIMEOUT_MS: subAgentTimeoutMs,\n\t\t\t\t...(agentMetadata && { SWARM_AGENT_METADATA: JSON.stringify(agentMetadata) }),\n\t\t\t\t...buildReviewTemplateVariables(settings?.agents),\n\t\t\t}\n\n\t\t\t// Render issue prompt template with swarm variables\n\t\t\tconst agentBody = await this.templateManager.getPrompt('issue', variables)\n\n\t\t\t// Build the agent file with frontmatter\n\t\t\tconst workerModel = settings?.agents?.['iloom-swarm-worker']?.model ?? 'opus'\n\n\t\t\tconst frontmatter = [\n\t\t\t\t'---',\n\t\t\t\t'name: iloom-swarm-worker',\n\t\t\t\t'description: Swarm worker agent that implements a child issue following the full iloom workflow.',\n\t\t\t\t`model: ${workerModel}`,\n\t\t\t\t'---',\n\t\t\t].join('\\n')\n\n\t\t\tconst content = `${frontmatter}\\n\\n${agentBody}\\n`\n\n\t\t\tawait fs.writeFile(agentOutputPath, content, 'utf-8')\n\t\t\tgetLogger().success(`Rendered swarm worker agent to ${agentOutputPath}`)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\t// Intentional graceful degradation: setupSwarm reports workerAgentRendered=false\n\t\t\t// in its result rather than aborting the entire swarm setup.\n\t\t\tgetLogger().warn(\n\t\t\t\t`Failed to render swarm worker agent: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Copy .claude/agents/ from the epic worktree to each child worktree.\n\t *\n\t * Child workers need local access to agent files (used via --append-system-prompt-file).\n\t * Without this copy, child worktrees lack the rendered agent files since they only\n\t * exist in the epic worktree after renderSwarmAgents/renderSwarmWorkerAgent.\n\t */\n\tasync copyAgentsToChildWorktrees(\n\t\tepicWorktreePath: string,\n\t\tchildWorktrees: SwarmSetupResult['childWorktrees'],\n\t): Promise<void> {\n\t\tconst sourceDir = path.join(epicWorktreePath, '.claude', 'agents')\n\n\t\tif (!await fs.pathExists(sourceDir)) {\n\t\t\tgetLogger().warn('No .claude/agents/ directory in epic worktree to copy')\n\t\t\treturn\n\t\t}\n\n\t\tconst successfulChildren = childWorktrees.filter((c) => c.success)\n\n\t\tawait Promise.all(successfulChildren.map(async (child) => {\n\t\t\ttry {\n\t\t\t\tconst targetDir = path.join(child.worktreePath, '.claude', 'agents')\n\t\t\t\tawait fs.copy(sourceDir, targetDir, { overwrite: true })\n\t\t\t\tgetLogger().debug(`Copied .claude/agents/ to ${child.worktreePath}`)\n\t\t\t} catch (error) {\n\t\t\t\t// Non-fatal: worker can fall back to epic worktree path\n\t\t\t\tgetLogger().warn(\n\t\t\t\t\t`Failed to copy agents to child worktree ${child.issueId}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}))\n\n\t\tgetLogger().success(`Copied agents to ${successfulChildren.length} child worktrees`)\n\t}\n\n\t/**\n\t * Run the full swarm setup: child worktrees, agents, and worker agent.\n\t *\n\t * The epic worktree already exists (created by `il start`).\n\t */\n\tasync setupSwarm(\n\t\tepicIssueNumber: string | number,\n\t\tepicBranch: string,\n\t\tepicWorktreePath: string,\n\t\tchildIssues: SwarmChildIssue[],\n\t\tmainWorktreePath: string,\n\t\tissueTrackerName: string,\n\t\tsettings?: IloomSettings,\n\t): Promise<SwarmSetupResult> {\n\t\t// 1. Create child worktrees (with per-loom MCP config generation)\n\t\tconst childWorktrees = await this.createChildWorktrees(\n\t\t\tchildIssues,\n\t\t\tepicBranch,\n\t\t\tepicWorktreePath,\n\t\t\tmainWorktreePath,\n\t\t\tepicIssueNumber,\n\t\t\tissueTrackerName,\n\t\t\tsettings,\n\t\t)\n\n\t\t// 2. Render swarm agents to epic worktree's .claude/ directory (returns metadata)\n\t\tconst { renderedFiles: agentsRendered, metadata: agentMetadata } =\n\t\t\tawait this.renderSwarmAgents(epicWorktreePath)\n\n\t\t// 3. Render the swarm worker agent file with agent metadata\n\t\tconst workerAgentRendered = await this.renderSwarmWorkerAgent(\n\t\t\tepicWorktreePath,\n\t\t\tagentMetadata,\n\t\t)\n\n\t\t// 4. Copy .claude/agents/ from epic worktree to each child worktree\n\t\tawait this.copyAgentsToChildWorktrees(epicWorktreePath, childWorktrees)\n\n\t\tconst successCount = childWorktrees.filter((c) => c.success).length\n\t\tconst failCount = childWorktrees.filter((c) => !c.success).length\n\n\t\tgetLogger().success(\n\t\t\t`Swarm setup complete: ${successCount} child worktrees` +\n\t\t\t\t(failCount > 0 ? ` (${failCount} failed)` : ''),\n\t\t)\n\n\t\treturn {\n\t\t\tepicWorktreePath,\n\t\t\tepicBranch,\n\t\t\tchildWorktrees,\n\t\t\tagentsRendered,\n\t\t\tworkerAgentRendered,\n\t\t}\n\t}\n}\n","import fs from 'fs-extra'\nimport path from 'path'\nimport fg from 'fast-glob'\n\n/**\n * Detect the primary programming language of a project by checking for common project files.\n * Checks are performed in priority order; the first match wins.\n * All errors are caught and return 'unknown' — this function is non-blocking.\n */\nexport async function detectProjectLanguage(projectPath: string): Promise<string> {\n try {\n // 1. package.json → check for 'typescript' in deps/devDeps → 'typescript' or 'javascript'\n const packageJsonPath = path.join(projectPath, 'package.json')\n if (await fs.pathExists(packageJsonPath)) {\n try {\n const pkg = await fs.readJson(packageJsonPath) as {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n }\n const allDeps = { ...pkg.dependencies, ...pkg.devDependencies }\n return 'typescript' in allDeps ? 'typescript' : 'javascript'\n } catch {\n return 'javascript'\n }\n }\n\n // 2. Cargo.toml → 'rust'\n if (await fs.pathExists(path.join(projectPath, 'Cargo.toml'))) {\n return 'rust'\n }\n\n // 3. go.mod → 'go'\n if (await fs.pathExists(path.join(projectPath, 'go.mod'))) {\n return 'go'\n }\n\n // 4. pyproject.toml | setup.py | requirements.txt → 'python'\n for (const file of ['pyproject.toml', 'setup.py', 'requirements.txt']) {\n if (await fs.pathExists(path.join(projectPath, file))) {\n return 'python'\n }\n }\n\n // 5. Gemfile → 'ruby'\n if (await fs.pathExists(path.join(projectPath, 'Gemfile'))) {\n return 'ruby'\n }\n\n // 6. pom.xml | build.gradle | build.gradle.kts → 'java'\n for (const file of ['pom.xml', 'build.gradle', 'build.gradle.kts']) {\n if (await fs.pathExists(path.join(projectPath, file))) {\n return 'java'\n }\n }\n\n // 7. *.csproj via glob → 'csharp'\n const csprojFiles = await fg('*.csproj', { cwd: projectPath, dot: false })\n if (csprojFiles.length > 0) {\n return 'csharp'\n }\n\n // 8. Default\n return 'unknown'\n } catch {\n return 'unknown'\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,WAAU;AACjB,OAAOC,SAAQ;AAgBf,S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AM,UAAU,MAAM,SAAS,YAAY,OAAO;AAClD,iBAAO,MAAM,wCAAwC,EAAE,WAAW,CAAC;AACnE,iBAAO;AAAA,QACR,QAAQ;AACP,uBAAaA,MAAK,QAAQ,UAAU;AAAA,QACrC;AAAA,MACD;AAEA,aAAO,MAAM,6CAA6C;AAC1D,aAAO;AAAA,IACR,SAAS,OAAO;AAEf,aAAO,MAAM,6BAA6B,KAAK,EAAE;AACjD,aAAO;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,4BAA6C;AAC1D,QAAI;AAEH,UAAI,aAAaA,MAAK,QAAQ,IAAI,IAAI,YAAY,GAAG,EAAE,QAAQ;AAG/D,aAAO,eAAeA,MAAK,QAAQ,UAAU,GAAG;AAC/C,cAAM,aAAaA,MAAK,KAAK,YAAY,UAAU,WAAW;AAC9D,YAAI;AACH,gBAAM,UAAU,MAAM,SAAS,YAAY,OAAO;AAClD,iBAAO,MAAM,+CAA+C,EAAE,WAAW,CAAC;AAC1E,iBAAO;AAAA,QACR,QAAQ;AACP,uBAAaA,MAAK,QAAQ,UAAU;AAAA,QACrC;AAAA,MACD;AAEA,aAAO,MAAM,oDAAoD;AACjE,aAAO;AAAA,IACR,SAAS,OAAO;AAEf,aAAO,MAAM,oCAAoC,KAAK,EAAE;AACxD,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["path","fs","_a","path","fs","path","fs","fs","path","path","fs"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/ResourceCleanup.ts"],"sourcesContent":["import path from 'path'\nimport { GitWorktreeManager } from './GitWorktreeManager.js'\nimport { DatabaseManager } from './DatabaseManager.js'\nimport { ProcessManager } from './process/ProcessManager.js'\nimport { CLIIsolationManager } from './CLIIsolationManager.js'\nimport { SettingsManager } from './SettingsManager.js'\nimport { MetadataManager } from './MetadataManager.js'\nimport { getLogger } from '../utils/logger-context.js'\nimport { hasUncommittedChanges, executeGitCommand, findMainWorktreePathWithSettings, extractIssueNumber, isBranchMergedIntoMain, checkRemoteBranchStatus, getMergeTargetBranch, findWorktreeForBranch, type RemoteBranchStatus } from '../utils/git.js'\nimport { calculatePortFromIdentifier } from '../utils/port.js'\nimport { archiveRecap } from '../utils/recap-archiver.js'\n\nimport type {\n\tResourceCleanupOptions,\n\tCleanupResult,\n\tOperationResult,\n\tSafetyCheck,\n\tBranchDeleteOptions,\n} from '../types/cleanup.js'\nimport type { GitWorktree } from '../types/worktree.js'\nimport type { ParsedInput } from '../commands/start.js'\n\n/**\n * Manages resource cleanup for worktrees\n * Provides shared cleanup functionality for finish and cleanup commands\n */\nexport class ResourceCleanup {\n\tprivate settingsManager: SettingsManager\n\tprivate metadataManager: MetadataManager\n\n\tconstructor(\n\t\tprivate gitWorktree: GitWorktreeManager,\n\t\tprivate processManager: ProcessManager,\n\t\tprivate database?: DatabaseManager,\n\t\tprivate cliIsolation?: CLIIsolationManager,\n\t\tsettingsManager?: SettingsManager\n\t) {\n\t\tthis.settingsManager = settingsManager ?? new SettingsManager()\n\t\tthis.metadataManager = new MetadataManager()\n\t}\n\n\t/**\n\t * Cleanup a worktree and associated resources\n\t * Main orchestration method\n\t *\n\t * @param parsed - ParsedInput from IdentifierParser with type information\n\t * @param options - Cleanup options\n\t */\n\tasync cleanupWorktree(\n\t\tparsed: ParsedInput,\n\t\toptions: ResourceCleanupOptions = {}\n\t): Promise<CleanupResult> {\n\t\tconst operations: OperationResult[] = []\n\t\tconst errors: Error[] = []\n\n\t\tconst displayIdentifier = parsed.branchName ?? parsed.number?.toString() ?? parsed.originalInput\n\t\tgetLogger().info(`Starting cleanup for: ${displayIdentifier}`)\n\n\t\t// Extract number from ParsedInput for port calculation\n\t\tconst number = parsed.number\n\n\t\t// Step 1: Terminate dev server if applicable\n\t\tif (number !== undefined) {\n\t\t\t// Load settings to get basePort\n\t\t\tconst settings = await this.settingsManager.loadSettings()\n\t\t\tconst basePort = settings?.capabilities?.web?.basePort ?? 3000\n\t\t\tconst port = calculatePortFromIdentifier(number, basePort)\n\n\t\t\tif (options.dryRun) {\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'dev-server',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `[DRY RUN] Would check for dev server on port ${port}`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst terminated = await this.terminateDevServer(port)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'dev-server',\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tmessage: terminated\n\t\t\t\t\t\t\t? `Dev server on port ${port} terminated`\n\t\t\t\t\t\t\t: `No dev server running on port ${port}`,\n\t\t\t\t\t})\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\t\t\terrors.push(err)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'dev-server',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: `Failed to terminate dev server`,\n\t\t\t\t\t\terror: err.message,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 2: Find worktree using specific methods based on type\n\t\tlet worktree: GitWorktree | null = null\n\t\ttry {\n\t\t\t// Use pre-resolved worktree if provided (skips the search step)\n\t\t\tif (options.worktree) {\n\t\t\t\tworktree = {\n\t\t\t\t\tpath: options.worktree.path,\n\t\t\t\t\tbranch: options.worktree.branch,\n\t\t\t\t\tcommit: '',\n\t\t\t\t\tbare: false,\n\t\t\t\t\tdetached: false,\n\t\t\t\t\tlocked: false,\n\t\t\t\t}\n\t\t\t\tgetLogger().debug(`Using pre-resolved worktree: path=\"${worktree.path}\", branch=\"${worktree.branch}\"`)\n\t\t\t} else {\n\t\t\t\t// Use specific finding methods based on parsed type for precision\n\t\t\t\tif (parsed.type === 'pr' && parsed.number !== undefined) {\n\t\t\t\t\t// For PRs, ensure the number is numeric (PRs are always numeric per GitHub)\n\t\t\t\t\tconst prNumber = typeof parsed.number === 'number' ? parsed.number : Number(parsed.number)\n\t\t\t\t\tif (isNaN(prNumber) || !isFinite(prNumber)) {\n\t\t\t\t\t\tthrow new Error(`Invalid PR number: ${parsed.number}. PR numbers must be numeric.`)\n\t\t\t\t\t}\n\t\t\t\t\t// For PRs, pass empty string for branchName since we're detecting from path pattern\n\t\t\t\t\tworktree = await this.gitWorktree.findWorktreeForPR(prNumber, '')\n\t\t\t\t} else if (parsed.type === 'issue' && parsed.number !== undefined) {\n\t\t\t\t\tworktree = await this.gitWorktree.findWorktreeForIssue(parsed.number)\n\t\t\t\t} else if (parsed.type === 'branch' && parsed.branchName) {\n\t\t\t\t\tworktree = await this.gitWorktree.findWorktreeForBranch(parsed.branchName)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!worktree) {\n\t\t\t\tthrow new Error(`No worktree found for identifier: ${displayIdentifier}`)\n\t\t\t}\n\n\t\t\tgetLogger().debug(`Found worktree: path=\"${worktree.path}\", branch=\"${worktree.branch}\"`)\n\t\t} catch (error) {\n\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\terrors.push(err)\n\n\t\t\treturn {\n\t\t\t\tidentifier: displayIdentifier,\n\t\t\t\tsuccess: false,\n\t\t\t\toperations,\n\t\t\t\terrors,\n\t\t\t\trollbackRequired: false,\n\t\t\t}\n\t\t}\n\n\t\t// Step 2.5: Validate safety before proceeding with cleanup (unless force flag is set)\n\t\t// Check merge safety if: deleteBranch is true AND checkMergeSafety is not explicitly false\n\t\t// This prevents the scenario where worktree is deleted but branch deletion fails\n\t\tlet safetyCheckPassed = false\n\t\tif (!options.force) {\n\t\t\tconst shouldCheckMergeSafety = options.checkMergeSafety ?? (options.deleteBranch === true)\n\t\t\tconst shouldCheckRemoteBranch = options.checkRemoteBranch ?? false\n\t\t\tconst safety = await this.validateWorktreeSafety(worktree, parsed.originalInput, shouldCheckMergeSafety, shouldCheckRemoteBranch)\n\n\t\t\tif (!safety.isSafe) {\n\t\t\t\t// Format blocker messages for error output\n\t\t\t\tconst blockerMessage = safety.blockers.join('\\n\\n')\n\t\t\t\tthrow new Error(`Cannot cleanup:\\n\\n${blockerMessage}`)\n\t\t\t}\n\n\t\t\tsafetyCheckPassed = true\n\n\t\t\t// Log warnings if any\n\t\t\tif (safety.warnings.length > 0) {\n\t\t\t\tsafety.warnings.forEach(warning => {\n\t\t\t\t\tgetLogger().warn(warning)\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Step 3: Pre-fetch database configuration before worktree removal\n\t\t// This config is used AFTER worktree deletion when env file no longer exists\n\t\tlet databaseConfig: { shouldCleanup: boolean; envFilePath: string } | null = null\n\t\tif (!options.keepDatabase && worktree) {\n\t\t\tconst envFilePath = path.join(worktree.path, '.env')\n\t\t\ttry {\n\t\t\t\t// Pre-check if database cleanup should happen by reading .env file now\n\t\t\t\tconst shouldCleanup = this.database\n\t\t\t\t\t? await this.database.shouldUseDatabaseBranching(envFilePath)\n\t\t\t\t\t: false\n\t\t\t\tdatabaseConfig = { shouldCleanup, envFilePath }\n\t\t\t} catch (error) {\n\t\t\t\t// If we can't read the config, we'll skip database cleanup\n\t\t\tgetLogger().warn(\n\t\t\t\t\t`Failed to read database config from ${envFilePath}, skipping database cleanup: ${\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t\t}`\n\t\t\t\t)\n\t\t\t\tdatabaseConfig = { shouldCleanup: false, envFilePath }\n\t\t\t}\n\t\t}\n\n\t\t// Step 3.5: Find main worktree path before deletion (needed for branch and database operations)\n\t\tlet mainWorktreePath: string | null = null\n\t\tif (!options.dryRun) {\n\t\t\ttry {\n\t\t\t\tmainWorktreePath = await findMainWorktreePathWithSettings(worktree.path, this.settingsManager)\n\t\t\t} catch (error) {\n\t\t\tgetLogger().warn(\n\t\t\t\t\t`Failed to find main worktree path: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// Step 3.6: Pre-fetch merge target branch before worktree deletion\n\t\t// This is needed because deleteBranch() needs to know the merge target (parent branch for child looms)\n\t\t// but the worktree metadata won't be readable after deletion in Step 4\n\t\tlet mergeTargetBranch: string | null = null\n\t\tif (options.deleteBranch && worktree && !options.dryRun) {\n\t\t\ttry {\n\t\t\t\tmergeTargetBranch = await getMergeTargetBranch(worktree.path, {\n\t\t\t\t\tsettingsManager: this.settingsManager,\n\t\t\t\t\tmetadataManager: this.metadataManager,\n\t\t\t\t})\n\t\t\t\tgetLogger().debug(`Pre-fetched merge target branch: ${mergeTargetBranch}`)\n\t\t\t} catch (error) {\n\t\t\t\tgetLogger().warn(\n\t\t\t\t\t`Failed to pre-fetch merge target branch: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// Step 4: Remove worktree\n\t\tif (options.dryRun) {\n\t\t\toperations.push({\n\t\t\t\ttype: 'worktree',\n\t\t\t\tsuccess: true,\n\t\t\t\tmessage: `[DRY RUN] Would remove worktree: ${worktree.path}`,\n\t\t\t})\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tconst worktreeOptions: { force?: boolean; removeDirectory: true; removeBranch: false } =\n\t\t\t\t\t{\n\t\t\t\t\t\tremoveDirectory: true,\n\t\t\t\t\t\tremoveBranch: false, // Handle branch separately\n\t\t\t\t\t}\n\t\t\t\tif (options.force !== undefined) {\n\t\t\t\t\tworktreeOptions.force = options.force\n\t\t\t\t}\n\t\t\t\tawait this.gitWorktree.removeWorktree(worktree.path, worktreeOptions)\n\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'worktree',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `Worktree removed: ${worktree.path}`,\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\t\terrors.push(err)\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'worktree',\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tmessage: `Failed to remove worktree`,\n\t\t\t\t\terror: err.message,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Step 4.5: Archive recap file\n\t\tif (worktree) {\n\t\t\tif (options.dryRun) {\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'recap',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `[DRY RUN] Would archive recap file for: ${worktree.path}`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tawait archiveRecap(worktree.path)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'recap',\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tmessage: `Recap file archived`,\n\t\t\t\t\t})\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Non-fatal: log warning but don't add to errors\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\t\t\tgetLogger().warn(`Recap archival failed: ${err.message}`)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'recap',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: 'Recap archival failed (non-fatal)',\n\t\t\t\t\t\terror: err.message,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 5: Delete branch if requested\n\t\tif (options.deleteBranch && worktree) {\n\t\t\tif (options.dryRun) {\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'branch',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `[DRY RUN] Would delete branch: ${worktree.branch}`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst branchOptions: BranchDeleteOptions = {\n\t\t\t\t\t\tdryRun: false,\n\t\t\t\t\t\tsafetyVerified: safetyCheckPassed,\n\t\t\t\t\t}\n\t\t\t\t\t// Pass pre-fetched merge target (fetched in Step 3.6 before worktree deletion)\n\t\t\t\t\tif (mergeTargetBranch !== null) {\n\t\t\t\t\t\tbranchOptions.mergeTargetBranch = mergeTargetBranch\n\t\t\t\t\t}\n\t\t\t\t\tif (options.force !== undefined) {\n\t\t\t\t\t\tbranchOptions.force = options.force\n\t\t\t\t\t}\n\t\t\t\t\t// Pass main worktree path to ensure we can execute git commands\n\t\t\t\t\tawait this.deleteBranch(worktree.branch, branchOptions, mainWorktreePath ?? undefined)\n\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'branch',\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tmessage: `Branch deleted: ${worktree.branch}`,\n\t\t\t\t\t})\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\t\t\terrors.push(err)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'branch',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: `Failed to delete branch`,\n\t\t\t\t\t\terror: err.message,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 5.5: Cleanup CLI symlinks if CLI isolation is available\n\t\t// Derive identifier from parsed input (number for issue/PR, branchName for branch)\n\t\tconst cliIdentifier = parsed.number ?? parsed.branchName\n\t\tif (this.cliIsolation && cliIdentifier !== undefined) {\n\t\t\tif (options.dryRun) {\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'cli-symlinks',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `[DRY RUN] Would cleanup CLI symlinks for: ${cliIdentifier}`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tconst removed = await this.cliIsolation.cleanupVersionedExecutables(cliIdentifier)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'cli-symlinks',\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tmessage: removed.length > 0\n\t\t\t\t\t\t\t? `CLI symlinks removed: ${removed.length}`\n\t\t\t\t\t\t\t: 'No CLI symlinks to cleanup',\n\t\t\t\t\t})\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Log warning but don't fail\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\t\t\terrors.push(err)\n\t\t\t\tgetLogger().warn(\n\t\t\t\t\t\t`CLI symlink cleanup failed: ${err.message}`\n\t\t\t\t\t)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'cli-symlinks',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: 'CLI symlink cleanup failed (non-fatal)',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 6: Cleanup database after worktree and branch removal (using pre-read config)\n\t\tif (databaseConfig && worktree) {\n\t\t\tif (options.dryRun) {\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'database',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `[DRY RUN] Would cleanup database branch for: ${worktree.branch}`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tif (databaseConfig.shouldCleanup && this.database) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t// Call database deletion with pre-fetched shouldCleanup value and main worktree path\n\t\t\t\t\t\t\t// This avoids reading the already-deleted env file and running commands from deleted directories\n\t\t\t\t\t\t\tconst deletionResult = await this.database.deleteBranchIfConfigured(\n\t\t\t\t\t\t\t\tworktree.branch,\n\t\t\t\t\t\t\t\tdatabaseConfig.shouldCleanup,\n\t\t\t\t\t\t\t\tfalse, // isPreview\n\t\t\t\t\t\t\t\tmainWorktreePath ?? undefined\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t// Create operation result based on what actually happened\n\t\t\t\t\t\t\tif (deletionResult.deleted) {\n\t\t\t\t\t\t\t\t// Branch was actually deleted\n\t\t\t\t\t\t\tgetLogger().info(`Database branch deleted: ${worktree.branch}`)\n\t\t\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\tmessage: `Database branch deleted`,\n\t\t\t\t\t\t\t\t\tdeleted: true,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else if (deletionResult.notFound) {\n\t\t\t\t\t\t\t\t// Branch didn't exist - not an error, just nothing to delete\n\t\t\t\t\t\t\tgetLogger().debug(`No database branch found for: ${worktree.branch}`)\n\t\t\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\tmessage: `No database branch found (skipped)`,\n\t\t\t\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else if (deletionResult.userDeclined) {\n\t\t\t\t\t\t\t\t// User declined preview database deletion\n\t\t\t\t\t\t\tgetLogger().info('Preview database deletion declined by user')\n\t\t\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\tmessage: `Database cleanup skipped (user declined)`,\n\t\t\t\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else if (!deletionResult.success) {\n\t\t\t\t\t\t\t\t// Deletion failed with error\n\t\t\t\t\t\t\t\tconst errorMsg = deletionResult.error ?? 'Unknown error'\n\t\t\t\t\t\t\t\terrors.push(new Error(errorMsg))\n\t\t\t\t\t\t\tgetLogger().warn(`Database cleanup failed: ${errorMsg}`)\n\t\t\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\t\t\tsuccess: false, // Non-fatal, but report error\n\t\t\t\t\t\t\t\t\tmessage: `Database cleanup failed`,\n\t\t\t\t\t\t\t\t\terror: errorMsg,\n\t\t\t\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Unexpected state - log for debugging\n\t\t\t\t\t\t\t\terrors.push(new Error('Database cleanup in an unknown state'))\n\t\t\t\t\t\t\tgetLogger().warn('Database deletion returned unexpected result state')\n\t\t\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\t\tmessage: `Database cleanup in an unknown state`,\n\t\t\t\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Unexpected exception (shouldn't happen with result object pattern)\n\t\t\t\t\t\t\terrors.push(error instanceof Error ? error : new Error(String(error)))\n\t\t\t\t\t\tgetLogger().warn(\n\t\t\t\t\t\t\t\t`Unexpected database cleanup exception: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\t\tmessage: `Database cleanup failed`,\n\t\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Database manager not available or not configured\n\t\t\t\t\t\toperations.push({\n\t\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\tmessage: `Database cleanup skipped (not available)`,\n\t\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// This catch block is for any unexpected errors in the outer logic\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error('Unknown error')\n\t\t\t\t\terrors.push(err)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'database',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: `Database cleanup failed`,\n\t\t\t\t\t\terror: err.message,\n\t\t\t\t\t\tdeleted: false,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Step 7: Delete or archive metadata file\n\t\tif (worktree) {\n\t\t\tif (options.dryRun) {\n\t\t\t\tconst action = options.archive ? 'archive' : 'delete'\n\t\t\t\toperations.push({\n\t\t\t\t\ttype: 'metadata',\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: `[DRY RUN] Would ${action} metadata for worktree: ${worktree.path}`,\n\t\t\t\t})\n\t\t\t} else if (options.archive) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.metadataManager.archiveMetadata(worktree.path)\n\t\t\t\t\tgetLogger().info(`Metadata archived for worktree: ${worktree.path}`)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'metadata',\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tmessage: 'Metadata archived',\n\t\t\t\t\t})\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error))\n\t\t\t\t\terrors.push(err)\n\t\t\t\t\tgetLogger().warn(`Metadata archival failed: ${err.message}`)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'metadata',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: 'Metadata archival failed (non-fatal)',\n\t\t\t\t\t\terror: err.message,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.metadataManager.deleteMetadata(worktree.path)\n\t\t\t\t\tgetLogger().info(`Metadata deleted for worktree: ${worktree.path}`)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'metadata',\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\tmessage: 'Metadata deleted',\n\t\t\t\t\t})\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error))\n\t\t\t\t\terrors.push(err)\n\t\t\t\t\tgetLogger().warn(`Metadata deletion failed: ${err.message}`)\n\t\t\t\t\toperations.push({\n\t\t\t\t\t\ttype: 'metadata',\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tmessage: 'Metadata deletion failed (non-fatal)',\n\t\t\t\t\t\terror: err.message,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Calculate overall success\n\t\tconst success = errors.length === 0\n\n\t\treturn {\n\t\t\tidentifier: displayIdentifier,\n\t\t\tbranchName: worktree?.branch,\n\t\t\tsuccess,\n\t\t\toperations,\n\t\t\terrors,\n\t\t\trollbackRequired: false, // Cleanup operations are generally not reversible\n\t\t}\n\t}\n\n\t/**\n\t * Terminate dev server on specified port\n\t */\n\tasync terminateDevServer(port: number): Promise<boolean> {\n\tgetLogger().debug(`Checking for dev server on port ${port}`)\n\n\t\tconst processInfo = await this.processManager.detectDevServer(port)\n\n\t\tif (!processInfo) {\n\t\tgetLogger().debug(`No process found on port ${port}`)\n\t\t\treturn false\n\t\t}\n\n\t\tif (!processInfo.isDevServer) {\n\t\tgetLogger().warn(\n\t\t\t\t`Process on port ${port} (${processInfo.name}) doesn't appear to be a dev server, skipping`\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\n\tgetLogger().info(`Terminating dev server: ${processInfo.name} (PID: ${processInfo.pid})`)\n\n\t\tawait this.processManager.terminateProcess(processInfo.pid)\n\n\t\t// Verify termination\n\t\tconst isFree = await this.processManager.verifyPortFree(port)\n\t\tif (!isFree) {\n\t\t\tthrow new Error(`Dev server may still be running on port ${port}`)\n\t\t}\n\n\t\treturn true\n\t}\n\n\t/**\n\t * Delete a Git branch with safety checks\n\t *\n\t * @param branchName - Name of the branch to delete\n\t * @param options - Delete options (force, dryRun)\n\t * @param cwd - Working directory to execute git command from (defaults to finding main worktree)\n\t */\n\tasync deleteBranch(\n\t\tbranchName: string,\n\t\toptions: BranchDeleteOptions = {},\n\t\tcwd?: string\n\t): Promise<boolean> {\n\t\t// Get protected branches list from centralized method\n\t\tconst protectedBranches = await this.settingsManager.getProtectedBranches(cwd)\n\n\t\t// Check for protected branches\n\t\tif (protectedBranches.includes(branchName)) {\n\t\t\tthrow new Error(`Cannot delete protected branch: ${branchName}`)\n\t\t}\n\n\t\t// Use provided cwd, or find main worktree path as fallback\n\t\t// This ensures we're not running git commands from a deleted directory\n\t\tconst workingDir = cwd ?? await findMainWorktreePathWithSettings(undefined, this.settingsManager)\n\n\t\t// Check if branch exists before attempting deletion (idempotent behavior)\n\t\ttry {\n\t\t\tawait executeGitCommand(['rev-parse', '--verify', `refs/heads/${branchName}`], {\n\t\t\t\tcwd: workingDir\n\t\t\t})\n\t\t} catch {\n\t\t\t// Branch doesn't exist - already deleted, return success\n\t\tgetLogger().debug(`Branch ${branchName} does not exist, skipping deletion`)\n\t\t\treturn true\n\t\t}\n\n\t\tif (options.dryRun) {\n\t\tgetLogger().info(`[DRY RUN] Would delete branch: ${branchName}`)\n\t\t\treturn true\n\t\t}\n\n\t\t// Execute git branch deletion\n\t\t// deleteCwd is declared outside try so it's accessible in the catch block for safetyVerified retry\n\t\tlet deleteCwd = workingDir // Default: main worktree\n\t\ttry {\n\t\t\t// Determine the correct delete flag and working directory\n\t\t\tlet deleteFlag = '-d' // Default: safe delete\n\n\t\t\tif (options.force) {\n\t\t\t\t// User explicitly requested force delete\n\t\t\t\tdeleteFlag = '-D'\n\t\t\t} else if (options.mergeTargetBranch) {\n\t\t\t\t// Use pre-fetched merge target (from Step 3.6, fetched before worktree deletion)\n\t\t\t\t// For child looms, git branch -d checks against HEAD, which may not be the correct target\n\t\t\t\t// Instead of using -D (force), we run git branch -d from the worktree where the\n\t\t\t\t// parent branch is checked out. This lets git do its own safety verification.\n\t\t\t\tconst mergeTarget = options.mergeTargetBranch\n\n\t\t\t\t// Find the worktree where the merge target (parent branch) is checked out\n\t\t\t\ttry {\n\t\t\t\t\tconst targetWorktreePath = await findWorktreeForBranch(mergeTarget, workingDir)\n\t\t\t\t\t// Run git branch -d from that worktree - HEAD will be the correct branch\n\t\t\t\t\t// and git will correctly verify the merge itself\n\t\t\t\t\tgetLogger().debug(`Running branch delete from worktree where '${mergeTarget}' is checked out: ${targetWorktreePath}`)\n\t\t\t\t\tdeleteCwd = targetWorktreePath\n\t\t\t\t} catch {\n\t\t\t\t\t// If we can't find the worktree for the target branch, fall back to checking merge status\n\t\t\t\t\t// and using -D if merged (the previous behavior)\n\t\t\t\t\tgetLogger().debug(`Could not find worktree for branch '${mergeTarget}', falling back to merge check`)\n\t\t\t\t\tconst isMerged = await isBranchMergedIntoMain(branchName, mergeTarget, workingDir)\n\n\t\t\t\t\tif (isMerged) {\n\t\t\t\t\t\tgetLogger().debug(`Branch '${branchName}' verified merged into '${mergeTarget}', using force delete`)\n\t\t\t\t\t\tdeleteFlag = '-D'\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (options.worktreePath) {\n\t\t\t\t// DEPRECATED: Fall back to reading from worktree path if mergeTargetBranch not provided\n\t\t\t\t// This path should not be used when called from cleanupWorktree() since the worktree\n\t\t\t\t// has already been deleted by the time deleteBranch() is called\n\t\t\t\tgetLogger().warn('deleteBranch called with worktreePath but no mergeTargetBranch - this may fail if worktree was deleted')\n\t\t\t\ttry {\n\t\t\t\t\tconst mergeTarget = await getMergeTargetBranch(options.worktreePath, {\n\t\t\t\t\t\tsettingsManager: this.settingsManager,\n\t\t\t\t\t\tmetadataManager: this.metadataManager,\n\t\t\t\t\t})\n\n\t\t\t\t\t// Find the worktree where the merge target (parent branch) is checked out\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst targetWorktreePath = await findWorktreeForBranch(mergeTarget, workingDir)\n\t\t\t\t\t\tgetLogger().debug(`Running branch delete from worktree where '${mergeTarget}' is checked out: ${targetWorktreePath}`)\n\t\t\t\t\t\tdeleteCwd = targetWorktreePath\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tgetLogger().debug(`Could not find worktree for branch '${mergeTarget}', falling back to merge check`)\n\t\t\t\t\t\tconst isMerged = await isBranchMergedIntoMain(branchName, mergeTarget, workingDir)\n\n\t\t\t\t\t\tif (isMerged) {\n\t\t\t\t\t\t\tgetLogger().debug(`Branch '${branchName}' verified merged into '${mergeTarget}', using force delete`)\n\t\t\t\t\t\t\tdeleteFlag = '-D'\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// If we can't read the merge target (e.g., worktree deleted), just use safe delete\n\t\t\t\t\tgetLogger().debug(`Could not read merge target from worktreePath: ${error instanceof Error ? error.message : String(error)}`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait executeGitCommand(['branch', deleteFlag, branchName], {\n\t\t\t\tcwd: deleteCwd\n\t\t\t})\n\n\t\tgetLogger().info(`Branch deleted: ${branchName}`)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\n\t\t\t// Handle \"branch not found\" - may occur in race conditions\n\t\t\tif (errorMessage.includes('not found') || errorMessage.includes('does not exist')) {\n\t\t\tgetLogger().debug(`Branch ${branchName} already deleted`)\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tif (options.force) {\n\t\t\t\tthrow error\n\t\t\t}\n\n\t\t\t// Git error for unmerged branch typically contains \"not fully merged\"\n\t\t\tif (errorMessage.includes('not fully merged')) {\n\t\t\t\tif (options.safetyVerified) {\n\t\t\t\t\t// Safety check already confirmed no data loss - retry with force delete\n\t\t\t\t\tgetLogger().info(`Branch '${branchName}' not merged into HEAD but safety verified - using force delete`)\n\t\t\t\t\tawait executeGitCommand(['branch', '-D', branchName], { cwd: deleteCwd })\n\t\t\t\t\tgetLogger().info(`Branch deleted: ${branchName}`)\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot delete unmerged branch '${branchName}'. Use --force to delete anyway.`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// For other errors, show the actual git error\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Cleanup database branch\n\t * Gracefully handles missing DatabaseManager\n\t *\n\t * @deprecated This method is deprecated and should not be used for post-deletion cleanup.\n\t * Use the pre-fetch mechanism in cleanupWorktree() instead.\n\t * This method will fail if called after worktree deletion because\n\t * it attempts to read the .env file which has been deleted.\n\t *\n\t * @param branchName - Name of the branch to delete\n\t * @param worktreePath - Path to worktree (must still exist with .env file)\n\t */\n\tasync cleanupDatabase(branchName: string, worktreePath: string): Promise<boolean> {\n\t\tif (!this.database) {\n\t\tgetLogger().debug('Database manager not available, skipping database cleanup')\n\t\t\treturn false\n\t\t}\n\n\t\ttry {\n\t\t\t// Pre-fetch configuration before deletion\n\t\t\tconst envFilePath = path.join(worktreePath, '.env')\n\t\t\tconst shouldCleanup = await this.database.shouldUseDatabaseBranching(envFilePath)\n\n\t\t\t// Find main worktree path to avoid running commands from potentially deleted directories\n\t\t\tlet cwd: string | undefined\n\t\t\ttry {\n\t\t\t\tcwd = await findMainWorktreePathWithSettings(worktreePath, this.settingsManager)\n\t\t\t} catch (error) {\n\t\t\t\t// If we can't find main worktree, commands will run from current directory\n\t\t\tgetLogger().debug(\n\t\t\t\t\t`Could not find main worktree path, using current directory: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst result = await this.database.deleteBranchIfConfigured(\n\t\t\t\tbranchName,\n\t\t\t\tshouldCleanup,\n\t\t\t\tfalse, // isPreview\n\t\t\t\tcwd\n\t\t\t)\n\n\t\t\t// Only return true if deletion actually occurred\n\t\t\tif (result.deleted) {\n\t\t\tgetLogger().info(`Database branch deleted: ${branchName}`)\n\t\t\t\treturn true\n\t\t\t} else if (result.notFound) {\n\t\t\tgetLogger().debug(`No database branch found for: ${branchName}`)\n\t\t\t\treturn false\n\t\t\t} else if (result.userDeclined) {\n\t\t\tgetLogger().info('Preview database deletion declined by user')\n\t\t\t\treturn false\n\t\t\t} else if (!result.success) {\n\t\t\tgetLogger().warn(`Database cleanup failed: ${result.error ?? 'Unknown error'}`)\n\t\t\t\treturn false\n\t\t\t} else {\n\t\t\t\t// Unexpected state\n\t\t\tgetLogger().debug('Database deletion returned unexpected result')\n\t\t\t\treturn false\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Unexpected exception\n\t\tgetLogger().warn(\n\t\t\t\t`Unexpected database cleanup error: ${error instanceof Error ? error.message : String(error)}`\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Cleanup multiple worktrees\n\t */\n\tasync cleanupMultipleWorktrees(\n\t\tidentifiers: string[],\n\t\toptions: ResourceCleanupOptions = {}\n\t): Promise<CleanupResult[]> {\n\t\tconst results: CleanupResult[] = []\n\n\t\tfor (const identifier of identifiers) {\n\t\t\t// Parse the identifier to get ParsedInput format\n\t\t\tconst parsed = this.parseIdentifier(identifier)\n\t\t\tconst result = await this.cleanupWorktree(parsed, options)\n\t\t\tresults.push(result)\n\t\t}\n\n\t\treturn results\n\t}\n\n\t/**\n\t * Validate worktree safety given a worktree object\n\t * Private method used internally when worktree is already known\n\t *\n\t * @param worktree - The worktree to validate\n\t * @param identifier - The original identifier used (for error messages)\n\t * @param checkBranchMerge - Whether to check if branch is merged into main (for branch deletion)\n\t * @param checkRemoteBranch - Whether to check if branch exists on remote (for GitHub-PR mode)\n\t */\n\tprivate async validateWorktreeSafety(\n\t\tworktree: GitWorktree,\n\t\tidentifier: string,\n\t\tcheckBranchMerge: boolean = false,\n\t\tcheckRemoteBranch: boolean = false\n\t): Promise<SafetyCheck> {\n\t\tconst warnings: string[] = []\n\t\tconst blockers: string[] = []\n\n\t\t// Check if main worktree\n\t\tconst isMain = await this.gitWorktree.isMainWorktree(worktree, this.settingsManager)\n\t\tif (isMain) {\n\t\t\tblockers.push(`Cannot cleanup main worktree: \"${worktree.branch}\" @ \"${worktree.path}\"`)\n\t\t}\n\n\t\t// Check for uncommitted changes\n\t\tconst hasChanges = await hasUncommittedChanges(worktree.path)\n\t\tif (hasChanges) {\n\t\t\t// Create simple blocker message with actionable guidance\n\t\t\tconst blockerMessage =\n\t\t\t\t`Worktree has uncommitted changes.\\n\\n` +\n\t\t\t\t`Please resolve before cleanup - you have some options:\\n` +\n\t\t\t\t` • Commit changes: cd ${worktree.path} && git commit -am \"message\"\\n` +\n\t\t\t\t` • Stash changes: cd ${worktree.path} && git stash\\n` +\n\t\t\t\t` • Force cleanup: il cleanup ${identifier} --force (WARNING: will discard changes)`\n\n\t\t\tblockers.push(blockerMessage)\n\t\t}\n\n\t\t// 5-point safety check for branch deletion\n\t\t// The key insight: we care about DATA LOSS, not about remote state\n\t\t// - Remote ahead of local is SAFE (commits exist on remote, no data loss)\n\t\t// - Local ahead of remote is DANGEROUS (unpushed commits would be lost)\n\t\t//\n\t\t// 1. Network error -> BLOCK (can't verify safety)\n\t\t// 2. Remote ahead of local -> OK (no data loss - commits exist on remote)\n\t\t// 3. Local ahead of remote (unpushed commits) -> BLOCK (data loss risk)\n\t\t// 4. No remote, merged to main -> OK (work is in main)\n\t\t// 5. No remote, NOT merged to main -> BLOCK (unmerged work would be lost)\n\t\tif ((checkBranchMerge || checkRemoteBranch) && worktree.branch) {\n\t\t\t// Use shared utility to get merge target (parent branch for child looms, main for others)\n\t\t\tconst mainBranch = await getMergeTargetBranch(worktree.path, {\n\t\t\t\tsettingsManager: this.settingsManager,\n\t\t\t\tmetadataManager: this.metadataManager,\n\t\t\t})\n\n\t\t\t// Check remote branch status\n\t\t\tconst remoteStatus: RemoteBranchStatus = await checkRemoteBranchStatus(worktree.branch, worktree.path)\n\n\t\t\t// Scenario 1: Network error checking remote -> Block\n\t\t\tif (remoteStatus.networkError) {\n\t\t\t\tconst blockerMessage =\n\t\t\t\t\t`Cannot verify remote branch status due to network error.\\n\\n` +\n\t\t\t\t\t`Error: ${remoteStatus.errorMessage ?? 'Unknown network error'}\\n\\n` +\n\t\t\t\t\t`Unable to determine if branch '${worktree.branch}' is safely backed up.\\n` +\n\t\t\t\t\t`Use --force to proceed without verification.`\n\n\t\t\t\tblockers.push(blockerMessage)\n\t\t\t}\n\t\t\t// Scenario 3: Local ahead of remote (unpushed commits) -> Block (data loss risk)\n\t\t\telse if (remoteStatus.exists && remoteStatus.localAhead) {\n\t\t\t\tconst blockerMessage =\n\t\t\t\t\t`Branch '${worktree.branch}' has unpushed commits that would be lost.\\n` +\n\t\t\t\t\t`The remote branch exists but your local branch is ahead.\\n\\n` +\n\t\t\t\t\t`Please resolve before cleanup:\\n` +\n\t\t\t\t\t` • Push your commits: git push origin ${worktree.branch}\\n` +\n\t\t\t\t\t` • Force cleanup: il cleanup ${identifier} --force (WARNING: will lose commits)`\n\n\t\t\t\tblockers.push(blockerMessage)\n\t\t\t}\n\t\t\t// Scenario 2: Remote ahead of local OR same commits -> Safe (work is on remote)\n\t\t\telse if (remoteStatus.exists && !remoteStatus.localAhead) {\n\t\t\t\t// Work is safely on remote (either remote is ahead or same commits)\n\t\t\t\t// No blocker needed\n\t\t\t}\n\t\t\t// Remote doesn't exist - need to check merge status\n\t\t\telse if (!remoteStatus.exists) {\n\t\t\t\tconst isMerged = await isBranchMergedIntoMain(worktree.branch, mainBranch, worktree.path)\n\n\t\t\t\tif (isMerged) {\n\t\t\t\t\t// Scenario 4: Remote doesn't exist, but merged to main -> Safe\n\t\t\t\t\t// No blocker needed\n\t\t\t\t} else {\n\t\t\t\t\t// Scenario 5: Remote doesn't exist AND not merged to main -> Block\n\t\t\t\t\tconst blockerMessage =\n\t\t\t\t\t\t`Branch '${worktree.branch}' has not been pushed to remote and is not merged into '${mainBranch}'.\\n` +\n\t\t\t\t\t\t`Deleting this branch would result in data loss.\\n\\n` +\n\t\t\t\t\t\t`Please resolve before cleanup - you have some options:\\n` +\n\t\t\t\t\t\t` • Push to remote: git push -u origin ${worktree.branch}\\n` +\n\t\t\t\t\t\t` • Merge to ${mainBranch}: git checkout ${mainBranch} && git merge ${worktree.branch}\\n` +\n\t\t\t\t\t\t` • Force cleanup: il cleanup ${identifier} --force (WARNING: will lose commits)`\n\n\t\t\t\t\tblockers.push(blockerMessage)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tisSafe: blockers.length === 0,\n\t\t\twarnings,\n\t\t\tblockers,\n\t\t}\n\t}\n\n\t/**\n\t * Validate cleanup safety\n\t */\n\tasync validateCleanupSafety(identifier: string): Promise<SafetyCheck> {\n\t\tconst warnings: string[] = []\n\t\tconst blockers: string[] = []\n\n\t\t// Find worktree\n\t\tconst worktrees = await this.gitWorktree.findWorktreesByIdentifier(identifier)\n\n\t\tif (worktrees.length === 0) {\n\t\t\tblockers.push(`No worktree found for: ${identifier}`)\n\t\t\treturn { isSafe: false, warnings, blockers }\n\t\t}\n\n\t\tconst worktree = worktrees[0]\n\t\tif (!worktree) {\n\t\t\tblockers.push(`No worktree found for: ${identifier}`)\n\t\t\treturn { isSafe: false, warnings, blockers }\n\t\t}\n\n\t\t// Delegate to private method that validates the worktree\n\t\treturn await this.validateWorktreeSafety(worktree, identifier)\n\t}\n\n\t/**\n\t * Parse identifier to determine type and extract number\n\t * Helper method for port calculation\n\t */\n\tprivate parseIdentifier(identifier: string): ParsedInput {\n\t\t// Check for issue pattern\n\t\tconst issueId = extractIssueNumber(identifier)\n\t\tif (issueId !== null) {\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: issueId,\n\t\t\t\toriginalInput: identifier\n\t\t\t}\n\t\t}\n\n\t\t// Check for PR pattern\n\t\tconst prMatch = identifier.match(/(?:pr|PR)[/-](\\d+)/)\n\t\tif (prMatch?.[1]) {\n\t\t\treturn {\n\t\t\t\ttype: 'pr',\n\t\t\t\tnumber: parseInt(prMatch[1], 10),\n\t\t\t\toriginalInput: identifier\n\t\t\t}\n\t\t}\n\n\t\t// Check for numeric identifier\n\t\tconst numericMatch = identifier.match(/^#?(\\d+)$/)\n\t\tif (numericMatch?.[1]) {\n\t\t\t// Assume issue for numeric identifiers\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: parseInt(numericMatch[1], 10),\n\t\t\t\toriginalInput: identifier\n\t\t\t}\n\t\t}\n\n\t\t// Treat as branch name\n\t\treturn {\n\t\t\ttype: 'branch',\n\t\t\tbranchName: identifier,\n\t\t\toriginalInput: identifier\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AA0BV,IAAM,kBAAN,MAAsB;AAAA,EAI5B,YACS,aACA,gBACA,UACA,cACR,iBACC;AALO;AACA;AACA;AACA;AAGR,SAAK,kBAAkB,mBAAmB,IAAI,gBAAgB;AAC9D,SAAK,kBAAkB,IAAI,gBAAgB;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,gBACL,QACA,UAAkC,CAAC,GACV;AAnD3B;AAoDE,UAAM,aAAgC,CAAC;AACvC,UAAM,SAAkB,CAAC;AAEzB,UAAM,oBAAoB,OAAO,gBAAc,YAAO,WAAP,mBAAe,eAAc,OAAO;AACnF,cAAU,EAAE,KAAK,yBAAyB,iBAAiB,EAAE;AAG7D,UAAM,SAAS,OAAO;AAGtB,QAAI,WAAW,QAAW;AAEzB,YAAM,WAAW,MAAM,KAAK,gBAAgB,aAAa;AACzD,YAAM,aAAW,gDAAU,iBAAV,mBAAwB,QAAxB,mBAA6B,aAAY;AAC1D,YAAM,OAAO,4BAA4B,QAAQ,QAAQ;AAEzD,UAAI,QAAQ,QAAQ;AACnB,mBAAW,KAAK;AAAA,UACf,MAAM;AAAA,UACN,SAAS;AAAA,UACT,SAAS,gDAAgD,IAAI;AAAA,QAC9D,CAAC;AAAA,MACF,OAAO;AACN,YAAI;AACH,gBAAM,aAAa,MAAM,KAAK,mBAAmB,IAAI;AACrD,qBAAW,KAAK;AAAA,YACf,MAAM;AAAA,YACN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QAAQ,OAAO,UAAU,SAAS;AAAA,IAC5C;AAEA,UAAM,WAAW,UAAU,CAAC;AAC5B,QAAI,CAAC,UAAU;AACd,eAAS,KAAK,0BAA0B,UAAU,EAAE;AACpD,aAAO,EAAE,QAAQ,OAAO,UAAU,SAAS;AAAA,IAC5C;AAGA,WAAO,MAAM,KAAK,uBAAuB,UAAU,UAAU;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,gBAAgB,YAAiC;AAExD,UAAM,UAAU,mBAAmB,UAAU;AAC7C,QAAI,YAAY,MAAM;AACrB,aAAO;AAAA,QACN,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,eAAe;AAAA,MAChB;AAAA,IACD;AAGA,UAAM,UAAU,WAAW,MAAM,oBAAoB;AACrD,QAAI,mCAAU,IAAI;AACjB,aAAO;AAAA,QACN,MAAM;AAAA,QACN,QAAQ,SAAS,QAAQ,CAAC,GAAG,EAAE;AAAA,QAC/B,eAAe;AAAA,MAChB;AAAA,IACD;AAGA,UAAM,eAAe,WAAW,MAAM,WAAW;AACjD,QAAI,6CAAe,IAAI;AAEtB,aAAO;AAAA,QACN,MAAM;AAAA,QACN,QAAQ,SAAS,aAAa,CAAC,GAAG,EAAE;AAAA,QACpC,eAAe;AAAA,MAChB;AAAA,IACD;AAGA,WAAO;AAAA,MACN,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,eAAe;AAAA,IAChB;AAAA,EACD;AACD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/TelemetryManager.ts","../src/lib/TelemetryService.ts"],"sourcesContent":["import os from 'os'\nimport path from 'path'\nimport nodeFs from 'node:fs'\nimport fs from 'fs-extra'\nimport { v4 as uuidv4 } from 'uuid'\nimport { logger } from '../utils/logger.js'\nimport type { TelemetryConfig } from '../types/telemetry.js'\n\nconst DEFAULT_CONFIG: TelemetryConfig = { enabled: true }\nconst CONFIG_FILE = 'telemetry.json'\nconst ID_FILE = 'telemetry-id'\n\nexport class TelemetryManager {\n\tprivate configFilePath: string\n\tprivate idFilePath: string\n\tprivate distinctId: string\n\tprivate config: TelemetryConfig\n\n\tconstructor(configDir?: string) {\n\t\tconst dir = configDir ?? path.join(os.homedir(), '.config', 'iloom-ai')\n\t\tthis.configFilePath = path.join(dir, CONFIG_FILE)\n\t\tthis.idFilePath = path.join(dir, ID_FILE)\n\t\tthis.distinctId = this.readOrCreateDistinctId()\n\t\tthis.config = this.readConfig()\n\t}\n\n\tprivate readOrCreateDistinctId(): string {\n\t\t// 1. Try to read existing telemetry-id file\n\t\ttry {\n\t\t\tconst id = nodeFs.readFileSync(this.idFilePath, 'utf8').trim()\n\t\t\tif (id) return id\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code\n\t\t\tif (code !== 'ENOENT') {\n\t\t\t\tif (code === 'EACCES' || code === 'EPERM') {\n\t\t\t\t\tlogger.warn(`TelemetryManager: Permission denied reading ID file: ${code}`)\n\t\t\t\t} else {\n\t\t\t\t\tlogger.debug(`TelemetryManager: Failed to read ID file: ${error}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 2. Generate new ID and write it\n\t\tconst newId = uuidv4()\n\t\tthis.writeDistinctId(newId)\n\t\treturn newId\n\t}\n\n\tprivate writeDistinctId(id: string): void {\n\t\ttry {\n\t\t\tfs.ensureDirSync(path.dirname(this.idFilePath))\n\t\t\tnodeFs.writeFileSync(this.idFilePath, id, 'utf8')\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code\n\t\t\tif (code === 'EACCES' || code === 'EPERM') {\n\t\t\t\tlogger.warn(`TelemetryManager: Permission denied writing ID file: ${code}`)\n\t\t\t} else {\n\t\t\t\tlogger.debug(`TelemetryManager: Failed to write ID file: ${error}`)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readConfig(): TelemetryConfig {\n\t\ttry {\n\t\t\tconst data = fs.readJsonSync(this.configFilePath)\n\t\t\tif (!data || typeof data !== 'object' || Array.isArray(data)) {\n\t\t\t\tthrow new Error('Invalid config format: expected a JSON object')\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tenabled: typeof data.enabled === 'boolean' ? data.enabled : true,\n\t\t\t\t...(typeof data.disclosed_at === 'string' ? { disclosed_at: data.disclosed_at } : {}),\n\t\t\t\t...(typeof data.last_version === 'string' ? { last_version: data.last_version } : {}),\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code\n\t\t\tif (code === 'ENOENT') {\n\t\t\t\tlogger.debug('TelemetryManager: Config file not found, using defaults')\n\t\t\t\treturn { ...DEFAULT_CONFIG }\n\t\t\t}\n\t\t\t// Corrupted/unreadable file: disable telemetry to respect user opt-out\n\t\t\tlogger.warn(`TelemetryManager: Unexpected error reading config (${code ?? error}), disabling telemetry`)\n\t\t\treturn { ...DEFAULT_CONFIG, enabled: false }\n\t\t}\n\t}\n\n\tprivate writeConfig(): void {\n\t\ttry {\n\t\t\tconst dir = path.dirname(this.configFilePath)\n\t\t\tfs.ensureDirSync(dir)\n\t\t\t// Atomic write: write to a temp file in the same directory, then rename.\n\t\t\t// renameSync is atomic on the same filesystem, so concurrent readers will\n\t\t\t// either see the old file or the new file, never a partially-written one.\n\t\t\tconst tmpPath = `${this.configFilePath}.${process.pid}.tmp`\n\t\t\tconst data = JSON.stringify(this.config, null, 2)\n\t\t\tnodeFs.writeFileSync(tmpPath, data, 'utf8')\n\t\t\tnodeFs.renameSync(tmpPath, this.configFilePath)\n\t\t} catch (error: unknown) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code\n\t\t\tif (code === 'EACCES' || code === 'EPERM') {\n\t\t\t\tlogger.warn(`TelemetryManager: Permission denied writing config: ${code}`)\n\t\t\t} else {\n\t\t\t\tlogger.debug(`TelemetryManager: Failed to write config: ${error}`)\n\t\t\t}\n\t\t\t// Clean up temp file if it exists\n\t\t\ttry {\n\t\t\t\tconst tmpPath = `${this.configFilePath}.${process.pid}.tmp`\n\t\t\t\tnodeFs.unlinkSync(tmpPath)\n\t\t\t} catch (cleanupError: unknown) {\n\t\t\t\tconst cleanupCode = (cleanupError as NodeJS.ErrnoException).code\n\t\t\t\tif (cleanupCode !== 'ENOENT') {\n\t\t\t\t\tlogger.debug(`TelemetryManager: Failed to clean up temp file: ${cleanupError}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tgetDistinctId(): string {\n\t\treturn this.distinctId\n\t}\n\n\tisEnabled(): boolean {\n\t\treturn this.config.enabled\n\t}\n\n\tenable(): void {\n\t\tthis.config.enabled = true\n\t\tthis.writeConfig()\n\t}\n\n\tdisable(): void {\n\t\tthis.config.enabled = false\n\t\tthis.writeConfig()\n\t}\n\n\tgetStatus(): { enabled: boolean; distinctId: string } {\n\t\treturn { enabled: this.isEnabled(), distinctId: this.getDistinctId() }\n\t}\n\n\thasBeenDisclosed(): boolean {\n\t\treturn this.config.disclosed_at !== undefined && this.config.disclosed_at !== ''\n\t}\n\n\tmarkDisclosed(): void {\n\t\tthis.config.disclosed_at = new Date().toISOString()\n\t\tthis.writeConfig()\n\t}\n\n\tgetLastVersion(): string | null {\n\t\treturn this.config.last_version ?? null\n\t}\n\n\tsetLastVersion(version: string): void {\n\t\tif (this.config.last_version === version) return\n\t\tthis.config.last_version = version\n\t\tthis.writeConfig()\n\t}\n}\n","import { PostHog } from 'posthog-node'\nimport { TelemetryManager } from './TelemetryManager.js'\nimport { logger } from '../utils/logger.js'\nimport type { TelemetryEventMap, TelemetryEventName } from '../types/telemetry.js'\n\nconst POSTHOG_API_KEY = 'phc_H9IRi41nQuIXs6fthwCZJ4wi6jIs2LWQkUanMSdqmj'\nconst POSTHOG_HOST = 'https://us.i.posthog.com'\nconst SHUTDOWN_TIMEOUT_MS = 1000\n\nexport class TelemetryService {\n\tprivate static instance: TelemetryService | null = null\n\tprivate client: PostHog | null = null\n\tprivate manager: TelemetryManager\n\n\tconstructor(manager?: TelemetryManager) {\n\t\tthis.manager = manager ?? new TelemetryManager()\n\t\tif (this.manager.isEnabled()) {\n\t\t\ttry {\n\t\t\t\tthis.client = new PostHog(POSTHOG_API_KEY, { host: POSTHOG_HOST, flushAt: 1, flushInterval: 0 })\n\t\t\t} catch (error) {\n\t\t\t\tlogger.debug(`TelemetryService: Failed to initialize PostHog: ${error}`)\n\t\t\t\tthis.client = null\n\t\t\t}\n\t\t}\n\t}\n\n\tgetManager(): TelemetryManager {\n\t\treturn this.manager\n\t}\n\n\tstatic getInstance(): TelemetryService {\n\t\tTelemetryService.instance ??= new TelemetryService()\n\t\treturn TelemetryService.instance\n\t}\n\n\t/**\n\t * Reset singleton instance. For testing only — does not flush pending events.\n\t */\n\tstatic resetInstance(): void {\n\t\tTelemetryService.instance = null\n\t}\n\n\ttrack<K extends TelemetryEventName>(event: K, properties: TelemetryEventMap[K]): void\n\ttrack(event: string, properties?: Record<string, unknown>): void\n\ttrack(event: string, properties?: Record<string, unknown>): void {\n\t\tif (!this.client) return\n\t\ttry {\n\t\t\tthis.client.capture({\n\t\t\t\tdistinctId: this.manager.getDistinctId(),\n\t\t\t\tevent,\n\t\t\t\tproperties: { ...properties, source: 'cli' },\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tlogger.debug(`TelemetryService: track error: ${error}`)\n\t\t}\n\t}\n\n\tasync shutdown(): Promise<void> {\n\t\tif (!this.client) return\n\t\tlet timeoutId: NodeJS.Timeout | undefined\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tthis.client.shutdown(),\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\ttimeoutId = globalThis.setTimeout(resolve, SHUTDOWN_TIMEOUT_MS)\n\t\t\t\t}),\n\t\t\t])\n\t\t} catch (error) {\n\t\t\tlogger.debug(`TelemetryService: Shutdown error: ${error}`)\n\t\t} finally {\n\t\t\tif (timeoutId) globalThis.clearTimeout(timeoutId)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAA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