@poetic-ai/poetic 1.42.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 (782) hide show
  1. package/.github/SECURITY.md +47 -0
  2. package/.nvmrc +1 -0
  3. package/.poetic/README.md +37 -0
  4. package/.poetic/providers/catalog.json +12051 -0
  5. package/.poetic/providers/pricing.json +1272 -0
  6. package/.poetic/providers/registry.json +3369 -0
  7. package/CHANGELOG.md +552 -0
  8. package/CODE_OF_CONDUCT.md +40 -0
  9. package/CONTRIBUTING.md +23 -0
  10. package/INSTALL.md +454 -0
  11. package/LICENSE +21 -0
  12. package/README.md +474 -0
  13. package/dist/BasicOptimizationCompetitionRunner-5H5TBYO4.js +153 -0
  14. package/dist/ExecutionTracker-UVONC4C6.js +16 -0
  15. package/dist/OptimizationConfig-7DFY2TST.js +17 -0
  16. package/dist/OptimizationEngine-JIMGP3LY.js +1597 -0
  17. package/dist/PromptStore-U6ZD3ZMQ.js +18 -0
  18. package/dist/actions-LUJPINLJ.js +322 -0
  19. package/dist/agent-ingest-3DJUJ7FU.js +53 -0
  20. package/dist/aggregator-DNCBINFO.js +12 -0
  21. package/dist/ai-judge-5QT5QJVU.js +156 -0
  22. package/dist/allowlist-grounding-RO6HKUFI.js +16 -0
  23. package/dist/allowlist-utils-23V7TJ3G.js +28 -0
  24. package/dist/anchored-turn-service-JULUCUIK.js +489 -0
  25. package/dist/api-transport-4TYTNLTJ.js +1087 -0
  26. package/dist/apply-completion-mode-AW2MOS3R.js +89 -0
  27. package/dist/artifact-migrator-23L45ISD.js +267 -0
  28. package/dist/ask-HWVV6QFR.js +135 -0
  29. package/dist/auth-5KEDKAPP.js +67 -0
  30. package/dist/auth-7TT3JINV.js +78 -0
  31. package/dist/auth-E6XUNZ5M.js +68 -0
  32. package/dist/auth-H3XDZE22.js +134 -0
  33. package/dist/auth-OC4E6633.js +71 -0
  34. package/dist/auth-S4CTX4GQ.js +44 -0
  35. package/dist/auth-YLH3S7EY.js +69 -0
  36. package/dist/auth-liveness-TDDEZY3T.js +46 -0
  37. package/dist/auto-optimizer-VPRWOWGU.js +80 -0
  38. package/dist/autoloop-cleanup-JOGKTLWA.js +109 -0
  39. package/dist/autoloop-evidence-gates-PCDALGVJ.js +38 -0
  40. package/dist/autoloop-gate-policy-Z7FVJVXV.js +175 -0
  41. package/dist/autoloop-helpers-2KTK43GL.js +22 -0
  42. package/dist/autoloop-ledger-W7QO62PX.js +96 -0
  43. package/dist/autoloop-ledger-subscriber-Z5RW5EIE.js +162 -0
  44. package/dist/autoloop-run-defaults-FERGRZGP.js +19 -0
  45. package/dist/autoloop-run-lock-CT2NWSV3.js +197 -0
  46. package/dist/autoloop-success-J2VKKBXQ.js +85 -0
  47. package/dist/autoloop-termination-summary-RN75F422.js +58 -0
  48. package/dist/autoloop-trajectory-XFIEXP5Z.js +282 -0
  49. package/dist/autoloop-wall-clock-T7ZVIQOC.js +12 -0
  50. package/dist/autonomous-loop-controller-PW4XVFGQ.js +4120 -0
  51. package/dist/backend-P3DAYRP7.js +29 -0
  52. package/dist/background-executor-CBN552V4.js +257 -0
  53. package/dist/backlog-execution-intent-U4XYPTV6.js +15 -0
  54. package/dist/backup-active-store-5WXG6SXT.js +17 -0
  55. package/dist/backup-telemetry-db-XGLXAA3N.js +254 -0
  56. package/dist/basic-competition-master-VCSBJVRN.js +344 -0
  57. package/dist/branch-archive-manager-RP6FP3ZC.js +254 -0
  58. package/dist/branch-cleanup-manager-RSHAI7YR.js +20 -0
  59. package/dist/build-gate-YHGRB4QB.js +71 -0
  60. package/dist/change-summary-WY7J5TOX.js +33 -0
  61. package/dist/chunk-23A26CSN.js +123 -0
  62. package/dist/chunk-27UTJD3M.js +265 -0
  63. package/dist/chunk-2A5CILN3.js +310 -0
  64. package/dist/chunk-2AQUWJPW.js +225 -0
  65. package/dist/chunk-2BZ53J6J.js +2344 -0
  66. package/dist/chunk-2DY5KNVM.js +276 -0
  67. package/dist/chunk-2EIA4RBE.js +659 -0
  68. package/dist/chunk-2IUXIGQD.js +1064 -0
  69. package/dist/chunk-2N42MS2Z.js +2193 -0
  70. package/dist/chunk-2QJ3H3L7.js +42 -0
  71. package/dist/chunk-2QLYTVYX.js +791 -0
  72. package/dist/chunk-2VSQMRCB.js +18 -0
  73. package/dist/chunk-2XQXYBM2.js +130 -0
  74. package/dist/chunk-2YFUIER7.js +426 -0
  75. package/dist/chunk-34CNP2HB.js +148 -0
  76. package/dist/chunk-35P3W3JX.js +456 -0
  77. package/dist/chunk-36PEBZAF.js +18 -0
  78. package/dist/chunk-3AOKYKA7.js +22 -0
  79. package/dist/chunk-3BCUNHKF.js +475 -0
  80. package/dist/chunk-3FLXLLB7.js +26 -0
  81. package/dist/chunk-3FOZ2VHV.js +100 -0
  82. package/dist/chunk-3G6FZCRF.js +106 -0
  83. package/dist/chunk-3M57DADF.js +44 -0
  84. package/dist/chunk-3S62LLWJ.js +543 -0
  85. package/dist/chunk-3ZPQLGV7.js +2904 -0
  86. package/dist/chunk-44N5WZZH.js +45 -0
  87. package/dist/chunk-45FPSA3B.js +125 -0
  88. package/dist/chunk-4BJ3O4RQ.js +929 -0
  89. package/dist/chunk-4BOP7T6L.js +2321 -0
  90. package/dist/chunk-4BTDUT2S.js +42 -0
  91. package/dist/chunk-4CSS7WVI.js +143 -0
  92. package/dist/chunk-4CUY7AFY.js +247 -0
  93. package/dist/chunk-4GSN5O5J.js +62 -0
  94. package/dist/chunk-4HN6DF7V.js +1027 -0
  95. package/dist/chunk-4IAPOG5V.js +415 -0
  96. package/dist/chunk-4IYIZQWV.js +48 -0
  97. package/dist/chunk-4NXPXE62.js +84 -0
  98. package/dist/chunk-4RCCF5BR.js +712 -0
  99. package/dist/chunk-4V7NAQ4R.js +19527 -0
  100. package/dist/chunk-4VJITV4P.js +445 -0
  101. package/dist/chunk-4YX7J6QL.js +1859 -0
  102. package/dist/chunk-527OBWQB.js +338 -0
  103. package/dist/chunk-5D4A7E3D.js +448 -0
  104. package/dist/chunk-5DLKYTQX.js +4003 -0
  105. package/dist/chunk-5EERLVZB.js +139 -0
  106. package/dist/chunk-5H72XE4H.js +256 -0
  107. package/dist/chunk-5HDP7XZG.js +91 -0
  108. package/dist/chunk-5LAMRH4X.js +969 -0
  109. package/dist/chunk-5LTN43AS.js +1972 -0
  110. package/dist/chunk-5RBHQYDB.js +2206 -0
  111. package/dist/chunk-5WCQRDRB.js +588 -0
  112. package/dist/chunk-5WRLK5KW.js +700 -0
  113. package/dist/chunk-5ZCXC23G.js +595 -0
  114. package/dist/chunk-6BM72ZMG.js +31 -0
  115. package/dist/chunk-6EDAJH2I.js +68 -0
  116. package/dist/chunk-6EQKFDBH.js +457 -0
  117. package/dist/chunk-6MFRHTRI.js +115 -0
  118. package/dist/chunk-6TZJRKNW.js +321 -0
  119. package/dist/chunk-6V7HGQFZ.js +20 -0
  120. package/dist/chunk-6VWVO2TU.js +3746 -0
  121. package/dist/chunk-6Y5TWI7H.js +146 -0
  122. package/dist/chunk-6Y5U7UFY.js +91 -0
  123. package/dist/chunk-6ZLAK3XG.js +14 -0
  124. package/dist/chunk-72XCRQED.js +34 -0
  125. package/dist/chunk-72YTZMAM.js +589 -0
  126. package/dist/chunk-73BBJOKA.js +263 -0
  127. package/dist/chunk-73NCTWKL.js +188 -0
  128. package/dist/chunk-77I6G4CO.js +1 -0
  129. package/dist/chunk-7DHRDWFS.js +3104 -0
  130. package/dist/chunk-7DNSNKJV.js +78 -0
  131. package/dist/chunk-7FMJVYBS.js +307 -0
  132. package/dist/chunk-7GDRQBQC.js +419 -0
  133. package/dist/chunk-7GPCEFUV.js +270 -0
  134. package/dist/chunk-7IL4A2PP.js +948 -0
  135. package/dist/chunk-7MMLMXO6.js +3679 -0
  136. package/dist/chunk-7QCZSLBH.js +1 -0
  137. package/dist/chunk-7R2WLDOS.js +62 -0
  138. package/dist/chunk-7T7RUJI7.js +949 -0
  139. package/dist/chunk-A2WKSVX7.js +43 -0
  140. package/dist/chunk-A3YGID55.js +133 -0
  141. package/dist/chunk-A722DEVA.js +14 -0
  142. package/dist/chunk-ACDIT7OP.js +1376 -0
  143. package/dist/chunk-ACKIPAOJ.js +302 -0
  144. package/dist/chunk-APPNGGN7.js +365 -0
  145. package/dist/chunk-APV6MK5E.js +137 -0
  146. package/dist/chunk-ASEP3M2W.js +968 -0
  147. package/dist/chunk-AT4TNPWW.js +2931 -0
  148. package/dist/chunk-ATVKCSGT.js +250 -0
  149. package/dist/chunk-AURFMVCD.js +899 -0
  150. package/dist/chunk-AX6GWE7V.js +47 -0
  151. package/dist/chunk-AY5EWJPF.js +385 -0
  152. package/dist/chunk-BAV2HJXS.js +194 -0
  153. package/dist/chunk-BBHRN366.js +89 -0
  154. package/dist/chunk-BBPSTTPA.js +1004 -0
  155. package/dist/chunk-BDATUDDJ.js +992 -0
  156. package/dist/chunk-BKE5PG5L.js +20414 -0
  157. package/dist/chunk-BLPHWMDK.js +797 -0
  158. package/dist/chunk-BSE4R6XD.js +322 -0
  159. package/dist/chunk-BXGMAU4A.js +396 -0
  160. package/dist/chunk-BXI4NXL3.js +507 -0
  161. package/dist/chunk-BZU2O43F.js +1125 -0
  162. package/dist/chunk-C3L6YQ7P.js +147 -0
  163. package/dist/chunk-C57KJOUQ.js +121 -0
  164. package/dist/chunk-CCV7BPSY.js +118 -0
  165. package/dist/chunk-CD7ISXA4.js +826 -0
  166. package/dist/chunk-CE5OZBYY.js +21 -0
  167. package/dist/chunk-CFBIG37O.js +154 -0
  168. package/dist/chunk-CJC6GZ46.js +457 -0
  169. package/dist/chunk-CKCDGXIV.js +408 -0
  170. package/dist/chunk-CKNX3TTP.js +10338 -0
  171. package/dist/chunk-CLKSETWE.js +10 -0
  172. package/dist/chunk-CP7H3HSP.js +1552 -0
  173. package/dist/chunk-CPLEWXNZ.js +66 -0
  174. package/dist/chunk-CQM3A35X.js +844 -0
  175. package/dist/chunk-CS6P76D3.js +103 -0
  176. package/dist/chunk-CTLUBNCW.js +622 -0
  177. package/dist/chunk-CUSRN6RJ.js +632 -0
  178. package/dist/chunk-D5EP5D2W.js +26 -0
  179. package/dist/chunk-D5RYINO7.js +412 -0
  180. package/dist/chunk-DBFS4HMH.js +751 -0
  181. package/dist/chunk-DC4ZYMXJ.js +115 -0
  182. package/dist/chunk-DCBZP442.js +9243 -0
  183. package/dist/chunk-DCYF7EKG.js +26 -0
  184. package/dist/chunk-DDMAFNUK.js +5351 -0
  185. package/dist/chunk-DF5SLDE4.js +966 -0
  186. package/dist/chunk-DJFW7SMX.js +348 -0
  187. package/dist/chunk-DQFLLBJW.js +121 -0
  188. package/dist/chunk-DSFM56OA.js +1203 -0
  189. package/dist/chunk-DTY4APYV.js +218 -0
  190. package/dist/chunk-DXH5JBRS.js +437 -0
  191. package/dist/chunk-E3NTPHEO.js +194 -0
  192. package/dist/chunk-E74LUIID.js +302 -0
  193. package/dist/chunk-EI57M5BI.js +194 -0
  194. package/dist/chunk-EJ4ZAWLV.js +305 -0
  195. package/dist/chunk-EJGCZGUF.js +1483 -0
  196. package/dist/chunk-EK2U3YEG.js +486 -0
  197. package/dist/chunk-ELMFYNV7.js +109 -0
  198. package/dist/chunk-ENRGKNR5.js +25 -0
  199. package/dist/chunk-ETYDXCK7.js +679 -0
  200. package/dist/chunk-EYRH3W74.js +239 -0
  201. package/dist/chunk-F23DIWNN.js +1024 -0
  202. package/dist/chunk-F5JO7HAS.js +94 -0
  203. package/dist/chunk-F7ER6ANO.js +174 -0
  204. package/dist/chunk-FATUVIIN.js +374 -0
  205. package/dist/chunk-FC23CTXV.js +322 -0
  206. package/dist/chunk-FD4ERYEG.js +22 -0
  207. package/dist/chunk-FH7WOJAE.js +79 -0
  208. package/dist/chunk-FHOWVDF5.js +1342 -0
  209. package/dist/chunk-FKAUPHMR.js +96 -0
  210. package/dist/chunk-FONNFJXA.js +137 -0
  211. package/dist/chunk-FQ7FSZRW.js +75 -0
  212. package/dist/chunk-FRG57FPM.js +240 -0
  213. package/dist/chunk-FUVP64ER.js +31 -0
  214. package/dist/chunk-FYOILAN5.js +6818 -0
  215. package/dist/chunk-G35UYQ6Z.js +69 -0
  216. package/dist/chunk-G36W2T2S.js +1143 -0
  217. package/dist/chunk-G3L2L5XZ.js +49 -0
  218. package/dist/chunk-G4THLFV3.js +148 -0
  219. package/dist/chunk-GAFJEYLK.js +29 -0
  220. package/dist/chunk-GFGYB2ZU.js +1689 -0
  221. package/dist/chunk-GG6KJYW6.js +85 -0
  222. package/dist/chunk-GHHFDU2U.js +55 -0
  223. package/dist/chunk-GHTZSQB7.js +57 -0
  224. package/dist/chunk-GK37ILCX.js +1231 -0
  225. package/dist/chunk-GKN3HMN4.js +2809 -0
  226. package/dist/chunk-GNVDBVJP.js +156 -0
  227. package/dist/chunk-GPEL3FBM.js +924 -0
  228. package/dist/chunk-GPSNGPZS.js +1604 -0
  229. package/dist/chunk-GSGD5E4C.js +30 -0
  230. package/dist/chunk-GSUQJJXQ.js +331 -0
  231. package/dist/chunk-GSV226X6.js +110 -0
  232. package/dist/chunk-H2AYQIHW.js +224 -0
  233. package/dist/chunk-H66DXFS5.js +1374 -0
  234. package/dist/chunk-H6G7QRMQ.js +35 -0
  235. package/dist/chunk-H7JAGHZT.js +59 -0
  236. package/dist/chunk-H7ZEFECA.js +316 -0
  237. package/dist/chunk-HAC6EHZZ.js +79 -0
  238. package/dist/chunk-HIO33P3G.js +19 -0
  239. package/dist/chunk-HMVQIPH3.js +547 -0
  240. package/dist/chunk-HOYBYAOA.js +257 -0
  241. package/dist/chunk-HX5P3CSP.js +1784 -0
  242. package/dist/chunk-I46EG2XQ.js +65 -0
  243. package/dist/chunk-I4NPDSCB.js +279 -0
  244. package/dist/chunk-I5WRT7ZR.js +514 -0
  245. package/dist/chunk-IC7I6YIJ.js +301 -0
  246. package/dist/chunk-IDCSOZVN.js +78 -0
  247. package/dist/chunk-IFCBYECK.js +112 -0
  248. package/dist/chunk-IFZCPEY2.js +66 -0
  249. package/dist/chunk-IKFP2KUR.js +48 -0
  250. package/dist/chunk-IRFBN336.js +878 -0
  251. package/dist/chunk-IUXNGKA6.js +152 -0
  252. package/dist/chunk-IV2RVAN7.js +1356 -0
  253. package/dist/chunk-IZYIQQ7X.js +53 -0
  254. package/dist/chunk-J3UUR7DE.js +210 -0
  255. package/dist/chunk-J54VUAY2.js +566 -0
  256. package/dist/chunk-J62KPGII.js +464 -0
  257. package/dist/chunk-J6P3FWWW.js +130 -0
  258. package/dist/chunk-JKBHJQMT.js +434 -0
  259. package/dist/chunk-JLS65NUQ.js +14 -0
  260. package/dist/chunk-JOSYEJKY.js +141 -0
  261. package/dist/chunk-JPKSXKNB.js +94 -0
  262. package/dist/chunk-JQNJB2BB.js +2440 -0
  263. package/dist/chunk-JRVNSWSQ.js +2626 -0
  264. package/dist/chunk-JSWMRQYG.js +28 -0
  265. package/dist/chunk-JZKNBBIB.js +152 -0
  266. package/dist/chunk-K54Y7MLK.js +160 -0
  267. package/dist/chunk-K65546RE.js +183 -0
  268. package/dist/chunk-KM3F7SYE.js +702 -0
  269. package/dist/chunk-KNDYMVWN.js +102 -0
  270. package/dist/chunk-KNT72VR6.js +132 -0
  271. package/dist/chunk-KP6YILMU.js +482 -0
  272. package/dist/chunk-KQEBSK3T.js +274 -0
  273. package/dist/chunk-KT6VHSPF.js +84 -0
  274. package/dist/chunk-KTMW65UX.js +14 -0
  275. package/dist/chunk-KZ5CJVBP.js +1813 -0
  276. package/dist/chunk-L4427KOE.js +26 -0
  277. package/dist/chunk-L6OM4A22.js +189 -0
  278. package/dist/chunk-L7E6XCRA.js +1042 -0
  279. package/dist/chunk-L7JZLXQL.js +173 -0
  280. package/dist/chunk-LAMKBTXX.js +40 -0
  281. package/dist/chunk-LDCF2MKN.js +132 -0
  282. package/dist/chunk-LEIIWPWQ.js +78 -0
  283. package/dist/chunk-LFTQVYBB.js +31 -0
  284. package/dist/chunk-LG3PDRTR.js +2872 -0
  285. package/dist/chunk-LGHII5ET.js +23 -0
  286. package/dist/chunk-LH5QY22X.js +1205 -0
  287. package/dist/chunk-LIVJ6266.js +438 -0
  288. package/dist/chunk-LKRAR3IH.js +276 -0
  289. package/dist/chunk-LO23NABI.js +3063 -0
  290. package/dist/chunk-LO3X5NLS.js +326 -0
  291. package/dist/chunk-LPITVM7M.js +339 -0
  292. package/dist/chunk-LR5IJIGV.js +810 -0
  293. package/dist/chunk-LRGMHROI.js +79 -0
  294. package/dist/chunk-LUVKFFWR.js +315 -0
  295. package/dist/chunk-LWCBNGH6.js +35 -0
  296. package/dist/chunk-LWTN3WRV.js +260 -0
  297. package/dist/chunk-M3HQYKQX.js +308 -0
  298. package/dist/chunk-M6GVSPEH.js +1016 -0
  299. package/dist/chunk-MF5HP6XV.js +221 -0
  300. package/dist/chunk-MHLCBZJB.js +328 -0
  301. package/dist/chunk-MN6PL4AN.js +120 -0
  302. package/dist/chunk-MOEY65Z6.js +5678 -0
  303. package/dist/chunk-MQ4WA34C.js +206 -0
  304. package/dist/chunk-MWHF5V7U.js +223 -0
  305. package/dist/chunk-MWHLBPNU.js +211 -0
  306. package/dist/chunk-MWK5UZQ3.js +1068 -0
  307. package/dist/chunk-MYLH2S4G.js +64 -0
  308. package/dist/chunk-MZ5WYKNA.js +28 -0
  309. package/dist/chunk-N4VTRA7K.js +131 -0
  310. package/dist/chunk-N5DX4JAK.js +12 -0
  311. package/dist/chunk-N65O4XTH.js +5011 -0
  312. package/dist/chunk-NEQUQHOX.js +223 -0
  313. package/dist/chunk-NGK6PEOG.js +25 -0
  314. package/dist/chunk-NJVD4PWE.js +1033 -0
  315. package/dist/chunk-NM6PMYY4.js +768 -0
  316. package/dist/chunk-NN4PJDHP.js +708 -0
  317. package/dist/chunk-NP2V3L7K.js +226 -0
  318. package/dist/chunk-NRLY536M.js +260 -0
  319. package/dist/chunk-NRNE225N.js +1270 -0
  320. package/dist/chunk-NS2K2GTP.js +605 -0
  321. package/dist/chunk-NS33V3IM.js +51 -0
  322. package/dist/chunk-NSHASMZZ.js +71 -0
  323. package/dist/chunk-NWOYOA6H.js +378 -0
  324. package/dist/chunk-NWRUSEXG.js +322 -0
  325. package/dist/chunk-NZGDAWIP.js +1905 -0
  326. package/dist/chunk-O47UOKU3.js +395 -0
  327. package/dist/chunk-O4G2W3ST.js +9831 -0
  328. package/dist/chunk-O6V4PNLO.js +63 -0
  329. package/dist/chunk-OA4GPILI.js +624 -0
  330. package/dist/chunk-OGMSYL6J.js +227 -0
  331. package/dist/chunk-OIS7J26S.js +319 -0
  332. package/dist/chunk-OMX5VL43.js +79 -0
  333. package/dist/chunk-ON3G73BU.js +264 -0
  334. package/dist/chunk-OPYFYTWQ.js +220 -0
  335. package/dist/chunk-OQ6K46CK.js +1734 -0
  336. package/dist/chunk-OYZYO7TV.js +47 -0
  337. package/dist/chunk-OZ4REHIN.js +4386 -0
  338. package/dist/chunk-P47VN5F4.js +282 -0
  339. package/dist/chunk-P5I4X7A7.js +353 -0
  340. package/dist/chunk-P6VQROCO.js +594 -0
  341. package/dist/chunk-P7CQGPLS.js +30 -0
  342. package/dist/chunk-PCAGC5MR.js +1763 -0
  343. package/dist/chunk-PFTQBXS6.js +5181 -0
  344. package/dist/chunk-PGSPX4SU.js +15 -0
  345. package/dist/chunk-PIKLF7BM.js +432 -0
  346. package/dist/chunk-PJWJ3SAV.js +22 -0
  347. package/dist/chunk-PKIFMV72.js +100 -0
  348. package/dist/chunk-PL37JDNA.js +189 -0
  349. package/dist/chunk-PTH5E5XO.js +195 -0
  350. package/dist/chunk-PW6AXLQC.js +4128 -0
  351. package/dist/chunk-PYITM4N2.js +79 -0
  352. package/dist/chunk-PZ5AY32C.js +10 -0
  353. package/dist/chunk-Q3RO7N35.js +45 -0
  354. package/dist/chunk-Q3WIC6GQ.js +2670 -0
  355. package/dist/chunk-Q5XIXSHX.js +271 -0
  356. package/dist/chunk-QGJDMEOV.js +34 -0
  357. package/dist/chunk-QNOB37UH.js +58 -0
  358. package/dist/chunk-QOCOVLUH.js +462 -0
  359. package/dist/chunk-QTCJ5CC5.js +172 -0
  360. package/dist/chunk-QVFV5IP2.js +232 -0
  361. package/dist/chunk-QVZMFDYG.js +29 -0
  362. package/dist/chunk-R35PEUKH.js +511 -0
  363. package/dist/chunk-R4UWBC35.js +200 -0
  364. package/dist/chunk-R6MLCREW.js +44 -0
  365. package/dist/chunk-R6W23LKN.js +254 -0
  366. package/dist/chunk-R7XDDX2A.js +4007 -0
  367. package/dist/chunk-RDFRCT64.js +168 -0
  368. package/dist/chunk-RE5VZDFQ.js +58 -0
  369. package/dist/chunk-RGROYC2G.js +638 -0
  370. package/dist/chunk-RGWHUI5E.js +68 -0
  371. package/dist/chunk-RHVG6UNL.js +205 -0
  372. package/dist/chunk-RI4EX2QE.js +18 -0
  373. package/dist/chunk-RJAAKDRX.js +17 -0
  374. package/dist/chunk-ROMHOSMQ.js +185 -0
  375. package/dist/chunk-RWREC3KJ.js +517 -0
  376. package/dist/chunk-RYNETRDJ.js +118 -0
  377. package/dist/chunk-RZY7RKM5.js +500 -0
  378. package/dist/chunk-S2MNWFAG.js +52 -0
  379. package/dist/chunk-S2VQCZO4.js +22 -0
  380. package/dist/chunk-S54MKU6V.js +117 -0
  381. package/dist/chunk-S5OIDFRM.js +302 -0
  382. package/dist/chunk-SCW4ZF6R.js +150 -0
  383. package/dist/chunk-SLS2N4PH.js +2213 -0
  384. package/dist/chunk-SNLBO4BF.js +247 -0
  385. package/dist/chunk-SP3LFU6B.js +60 -0
  386. package/dist/chunk-SQQTDDQA.js +537 -0
  387. package/dist/chunk-STV6LYYE.js +45 -0
  388. package/dist/chunk-SURZ2WFE.js +326 -0
  389. package/dist/chunk-SZ7DL357.js +1047 -0
  390. package/dist/chunk-T5E4NQCM.js +5742 -0
  391. package/dist/chunk-TAJPCXSB.js +13 -0
  392. package/dist/chunk-TAOOYK3P.js +358 -0
  393. package/dist/chunk-TDSEX5CF.js +24 -0
  394. package/dist/chunk-TFTGP7Z7.js +174 -0
  395. package/dist/chunk-TGON4N4O.js +197 -0
  396. package/dist/chunk-TGQZHDY2.js +2373 -0
  397. package/dist/chunk-TJJZ2OKV.js +6783 -0
  398. package/dist/chunk-TRSVUPCX.js +25 -0
  399. package/dist/chunk-TSXGRLPR.js +107 -0
  400. package/dist/chunk-U2S3YEX3.js +224 -0
  401. package/dist/chunk-U45RTRGY.js +818 -0
  402. package/dist/chunk-U6C3VVWS.js +13 -0
  403. package/dist/chunk-UDMS5AD3.js +307 -0
  404. package/dist/chunk-UGX7GI37.js +94 -0
  405. package/dist/chunk-UH3JJSHK.js +1 -0
  406. package/dist/chunk-UHRBTZYY.js +208 -0
  407. package/dist/chunk-UHT2KRG5.js +193 -0
  408. package/dist/chunk-UI2F6DJ5.js +118 -0
  409. package/dist/chunk-UMAKSB4Z.js +284 -0
  410. package/dist/chunk-UR2IBGIM.js +521 -0
  411. package/dist/chunk-UUH2RVKS.js +585 -0
  412. package/dist/chunk-UVJ4PJDK.js +4533 -0
  413. package/dist/chunk-V53UG2OT.js +9924 -0
  414. package/dist/chunk-V72RMBM4.js +48 -0
  415. package/dist/chunk-VBNCKCCI.js +16 -0
  416. package/dist/chunk-VNSYKC25.js +24 -0
  417. package/dist/chunk-VPHVFK4A.js +1984 -0
  418. package/dist/chunk-VTLNJQ44.js +133 -0
  419. package/dist/chunk-VTW7HP3R.js +100 -0
  420. package/dist/chunk-VVGEPBPS.js +218 -0
  421. package/dist/chunk-VVLLL7I4.js +166 -0
  422. package/dist/chunk-VX3UMWB7.js +483 -0
  423. package/dist/chunk-VXF4Q3FW.js +20 -0
  424. package/dist/chunk-W3JMT2YY.js +712 -0
  425. package/dist/chunk-WDUORIHF.js +877 -0
  426. package/dist/chunk-WDVTY4U6.js +148 -0
  427. package/dist/chunk-WIFZCHEG.js +12566 -0
  428. package/dist/chunk-WIRN3F75.js +736 -0
  429. package/dist/chunk-WMPU2UOV.js +82 -0
  430. package/dist/chunk-WTOKKE2V.js +784 -0
  431. package/dist/chunk-WX5IRLF6.js +740 -0
  432. package/dist/chunk-WZ6U3O7I.js +1581 -0
  433. package/dist/chunk-XAONGNST.js +57 -0
  434. package/dist/chunk-XB5YLCLB.js +13 -0
  435. package/dist/chunk-XEP5NQ5Y.js +688 -0
  436. package/dist/chunk-XGYF2QMZ.js +351 -0
  437. package/dist/chunk-XHEKQENB.js +255 -0
  438. package/dist/chunk-XNO4FM6X.js +1124 -0
  439. package/dist/chunk-XPHKYHO4.js +878 -0
  440. package/dist/chunk-XPK2I4NC.js +405 -0
  441. package/dist/chunk-XPU2XADL.js +2175 -0
  442. package/dist/chunk-XQD2B6BB.js +507 -0
  443. package/dist/chunk-XT2ZQVTC.js +558 -0
  444. package/dist/chunk-XTXJGGUV.js +351 -0
  445. package/dist/chunk-XUXVDPSZ.js +50 -0
  446. package/dist/chunk-XV7NZL4B.js +57 -0
  447. package/dist/chunk-XZE4XARH.js +563 -0
  448. package/dist/chunk-XZYR5EDO.js +152 -0
  449. package/dist/chunk-Y3J4JMTU.js +61 -0
  450. package/dist/chunk-Y55LZN5U.js +52 -0
  451. package/dist/chunk-Y5VN7DMP.js +112 -0
  452. package/dist/chunk-Y67VAHN4.js +459 -0
  453. package/dist/chunk-YAXSKEUH.js +3544 -0
  454. package/dist/chunk-YB3JD4E6.js +975 -0
  455. package/dist/chunk-YESZJFK6.js +220 -0
  456. package/dist/chunk-YGXKOBQQ.js +292 -0
  457. package/dist/chunk-YMX76IOS.js +31 -0
  458. package/dist/chunk-YOTXESEH.js +257 -0
  459. package/dist/chunk-YTYIEZQY.js +119 -0
  460. package/dist/chunk-YVORHQ2S.js +579 -0
  461. package/dist/chunk-Z2CUQDAR.js +3429 -0
  462. package/dist/chunk-Z2KYOFHS.js +7000 -0
  463. package/dist/chunk-Z6PC7QX6.js +161 -0
  464. package/dist/chunk-ZDTGECTN.js +235 -0
  465. package/dist/chunk-ZIPWI2LY.js +151 -0
  466. package/dist/chunk-ZSKKMTQJ.js +554 -0
  467. package/dist/chunk-ZTT5IVPY.js +1160 -0
  468. package/dist/chunk-ZX65UI5W.js +78 -0
  469. package/dist/chunk-ZYG7GGKO.js +218 -0
  470. package/dist/chunk-ZZZUL4OF.js +38 -0
  471. package/dist/cli-utils-IXL26KJT.js +40 -0
  472. package/dist/cli-validation-WLXWLUJL.js +111 -0
  473. package/dist/commit-utils-P7CRJF5N.js +202 -0
  474. package/dist/compete-config-resolver-R5ULXMYH.js +76 -0
  475. package/dist/compete-request-62JESVET.js +364 -0
  476. package/dist/compete-results-QEPG6FZX.js +208 -0
  477. package/dist/competition-outcome-tracker-R32OOZ43.js +38 -0
  478. package/dist/config-JCOKXOQT.js +166 -0
  479. package/dist/config-audit-EL3GHXS7.js +360 -0
  480. package/dist/config-explain-TNILDEVJ.js +12 -0
  481. package/dist/config-loader-VPFPFO4B.js +38 -0
  482. package/dist/config-manager-7T4E2BQO.js +67 -0
  483. package/dist/config-validator-KKOHOW7O.js +72 -0
  484. package/dist/cost-YC42XUF3.js +53 -0
  485. package/dist/coverage-orchestrator-CISNKJC2.js +772 -0
  486. package/dist/coverage-scanner-YVD62MLH.js +12 -0
  487. package/dist/createCompetitionRunner-LJG6ZQSO.js +46 -0
  488. package/dist/data-migration-state-VJK64DLT.js +31 -0
  489. package/dist/db-migrator-XSEIOGWY.js +34 -0
  490. package/dist/discovery-JGYGDD25.js +25 -0
  491. package/dist/doctor-GJOYE7AE.js +186 -0
  492. package/dist/domain-analyzer-AWF3RP6E.js +29 -0
  493. package/dist/ensure-initialized-744DIZEZ.js +52 -0
  494. package/dist/entry.js +940 -0
  495. package/dist/environment-YS45U5ZI.js +81 -0
  496. package/dist/error-parser-core-PPZ36A4S.js +50 -0
  497. package/dist/escalation-ladder-MKTCEGSA.js +130 -0
  498. package/dist/evaluation-context-KV4GZNN7.js +35 -0
  499. package/dist/evidence-plan-resolver-GBSYSAPX.js +85 -0
  500. package/dist/execution-data-writer-3ODTBDLH.js +53 -0
  501. package/dist/execution-policy-applier-ZHD3DCF3.js +31 -0
  502. package/dist/execution-preflight-Z4Y64V3I.js +209 -0
  503. package/dist/execution-roles-R3DPPMD3.js +66 -0
  504. package/dist/exit-code-error-Z4SW2DVK.js +14 -0
  505. package/dist/external-temp-cleanup-N2RZH4QP.js +311 -0
  506. package/dist/factory-XBN7DFIM.js +149 -0
  507. package/dist/file-utils-XIVR2ZMA.js +47 -0
  508. package/dist/flywheel-autoloop-executor-UILGOFFK.js +249 -0
  509. package/dist/flywheel-competition-executor-JOBEXTRB.js +259 -0
  510. package/dist/flywheel-executor-6JFLA6J5.js +369 -0
  511. package/dist/flywheel-git-isolation-UC5NIEVU.js +48 -0
  512. package/dist/flywheel-manifest-5UC4VBMA.js +108 -0
  513. package/dist/flywheel-model-defaults-7CVKP53V.js +27 -0
  514. package/dist/flywheel-preflight-XEY5SHM6.js +104 -0
  515. package/dist/flywheel-resume-7HELH7QS.js +23 -0
  516. package/dist/flywheel-safety-7U7DPOAP.js +28 -0
  517. package/dist/flywheel-scope-decision-ZHKF6ZIN.js +11 -0
  518. package/dist/get-telemetry-logger-DPVWWIYY.js +73 -0
  519. package/dist/git-worktree-IY6V6DUO.js +18 -0
  520. package/dist/github-pr-manager-4LXEKJTA.js +211 -0
  521. package/dist/guidance-profile-config-E7XJL2VP.js +117 -0
  522. package/dist/guidance-profile-renderer-QK2YMAAP.js +21 -0
  523. package/dist/index-query-4JEUKA44.js +31 -0
  524. package/dist/index.js +108661 -0
  525. package/dist/instructions-6BURLQJC.js +64 -0
  526. package/dist/invoke-provider-auth-GRUYP44M.js +223 -0
  527. package/dist/judge-scoring.json +80 -0
  528. package/dist/judge-test.js +555 -0
  529. package/dist/lab-mode-OTWVHN63.js +39 -0
  530. package/dist/lab-utils-BJRFLGK4.js +23 -0
  531. package/dist/linux-host-class-UY4KVLFD.js +29 -0
  532. package/dist/llm-judge-executor-F7Z3HO77.js +133 -0
  533. package/dist/local-executor-CEHWE2PL.js +223 -0
  534. package/dist/logger-33TR6EE5.js +72 -0
  535. package/dist/loop-spec-XTLQAVZ7.js +191 -0
  536. package/dist/manager-2HJG5CLT.js +25 -0
  537. package/dist/matrix-prompt-builder-6UDN5X3F.js +497 -0
  538. package/dist/matrix-result-parser-7W35EUOV.js +15 -0
  539. package/dist/metadata-HQ43NDEK.js +22 -0
  540. package/dist/model-invocations-db-QBO4Y7WZ.js +38 -0
  541. package/dist/monitor-XGYBG2DW.js +72 -0
  542. package/dist/next-PB5ZXZKB.js +90 -0
  543. package/dist/next-ZBDK725T.js +69 -0
  544. package/dist/optimization-config-resolver-O6WKR47U.js +75 -0
  545. package/dist/package-3YCWIQQ5.js +10 -0
  546. package/dist/parallel-orchestrator-NL7YJJU2.js +297 -0
  547. package/dist/parallel-worker.js +279 -0
  548. package/dist/parse-git-status-PIAF3OTP.js +10 -0
  549. package/dist/path-security-ETTH6TZL.js +39 -0
  550. package/dist/pattern-bank-UNJR5ADV.js +15 -0
  551. package/dist/plan-backlog-list-fast-VAGYBV3J.js +270 -0
  552. package/dist/plan-backlog-show-fast-SG2CZPW3.js +406 -0
  553. package/dist/plan-sprint-list-fast-LURAX47V.js +162 -0
  554. package/dist/plan-sprint-status-fast-FJAODCHD.js +208 -0
  555. package/dist/plan-task-status-fast-HNYBMQI4.js +349 -0
  556. package/dist/plan-to-flywheel-Z4U3GWPN.js +456 -0
  557. package/dist/planning-backlog-3CQ5QQBQ.js +319 -0
  558. package/dist/poetic-root-V5DNXEAE.js +17 -0
  559. package/dist/preflight-OPANWMME.js +12 -0
  560. package/dist/process-registry-PDZJPTAS.js +27 -0
  561. package/dist/process-scanner-C22SYXYD.js +22 -0
  562. package/dist/processes-KMQUD7HY.js +29 -0
  563. package/dist/processes-json-fast-IBDXZ6WW.js +135 -0
  564. package/dist/profile-SE5EVXAP.js +149 -0
  565. package/dist/prompts-WZZPGWBX.js +168 -0
  566. package/dist/protected-branches-RNTEX7ET.js +57 -0
  567. package/dist/provider-aware-resource-manager-QBTZJMNP.js +18 -0
  568. package/dist/provider-matrix-N5X57V3Y.js +154 -0
  569. package/dist/provider-matrix-renderer-MZDWKKID.js +139 -0
  570. package/dist/provider-output-forwarding-DERID3TP.js +30 -0
  571. package/dist/provider-registry-J5NRBJKI.js +128 -0
  572. package/dist/provider-temp-cleanup-KYGLF6YU.js +14 -0
  573. package/dist/prune-engine-Q6E2DXBN.js +451 -0
  574. package/dist/quality-gate-YRHMQAEI.js +70 -0
  575. package/dist/quickstart-FIRLKGJI.js +62 -0
  576. package/dist/readiness-VZTMSG6J.js +96 -0
  577. package/dist/registry-YODFY77A.js +153 -0
  578. package/dist/repair-helpers-TTV5FEF4.js +117 -0
  579. package/dist/repo-root-2IGD4H7X.js +22 -0
  580. package/dist/resolution-engine-D6TX6FRG.js +127 -0
  581. package/dist/resolve-provider-cli-O2P6XZBZ.js +35 -0
  582. package/dist/restore-telemetry-db-BQL6DTQF.js +360 -0
  583. package/dist/result-streamer-WEHW476R.js +19 -0
  584. package/dist/routing-events-DHPUZDDF.js +27 -0
  585. package/dist/routing-history-store-UWCEXAP3.js +46 -0
  586. package/dist/routing-planner-F5WQEUOM.js +160 -0
  587. package/dist/run-poetic-tui-J6LWRJUP.js +13517 -0
  588. package/dist/run-simulation.js +376 -0
  589. package/dist/runner-CS2TNGHA.js +1092 -0
  590. package/dist/runner-HHH7ZN2Z.js +1571 -0
  591. package/dist/safety-OCC4KJJR.js +64 -0
  592. package/dist/safety-stanza-7SV3HGG3.js +60 -0
  593. package/dist/sandbox-32QXJEMV.js +81 -0
  594. package/dist/sandbox-RSO7VP6V.js +94 -0
  595. package/dist/schema-extensions.sql +234 -0
  596. package/dist/security-2KI5XNDG.js +17 -0
  597. package/dist/setup-bb-plugin-QAQWZCV5.js +738 -0
  598. package/dist/setup-claude-code-P7BTTSPO.js +317 -0
  599. package/dist/setup-temp-cleanup-GASCWZ2I.js +20 -0
  600. package/dist/shared-utils-D6U6UREP.js +37 -0
  601. package/dist/simple-artifact-goal-OTXNGZY6.js +25 -0
  602. package/dist/sprint-UIXPYOXQ.js +338 -0
  603. package/dist/sprint-bridge-4BHMSC3M.js +68 -0
  604. package/dist/sprint-execution-service-2B7WHL5L.js +311 -0
  605. package/dist/sprint-manager-IDQUDNQI.js +91 -0
  606. package/dist/sqlite-wrapper-UDWCTNLJ.js +17 -0
  607. package/dist/stale-cleanup-orchestrator-XWXV7KCZ.js +62 -0
  608. package/dist/storage-access-F6ALDN4S.js +22 -0
  609. package/dist/synthesis-XD6EDVHF.js +185 -0
  610. package/dist/task-classifier-LNLXSHOM.js +494 -0
  611. package/dist/task-list-fast-PTMA4LUC.js +147 -0
  612. package/dist/task-manager-XAT7GOWB.js +93 -0
  613. package/dist/task-splitter-U7DJ7W6A.js +79 -0
  614. package/dist/task-type-detector-OLVOMXZO.js +21 -0
  615. package/dist/task-type-resolver-KKNQYSB4.js +42 -0
  616. package/dist/telemetry-5HWBBXLX.js +131 -0
  617. package/dist/telemetry-health-tracker-DMSSGBZ2.js +11 -0
  618. package/dist/telemetry-path-resolver-7ICSG276.js +28 -0
  619. package/dist/telemetry-reliability-XUOZNZZ6.js +125 -0
  620. package/dist/token-estimator-MEQUL3EJ.js +37 -0
  621. package/dist/transports-KNSSV2V4.js +255 -0
  622. package/dist/unified-cost-tracker-4TFRBVPR.js +35 -0
  623. package/dist/unified-state-cleanup-LJPF2BOW.js +276 -0
  624. package/dist/universal-cost-calculator-BAJV35GA.js +42 -0
  625. package/dist/user-agents-GHUGCSKN.js +22 -0
  626. package/dist/variant-delivery-state-KLRNG6XA.js +33 -0
  627. package/dist/variant-state-cleanup-MZGGLQAJ.js +280 -0
  628. package/dist/variant-success-PJXWE3ZV.js +12 -0
  629. package/dist/variant-worker-KUWKBLAH.js +4196 -0
  630. package/dist/variant-worker.js +24 -0
  631. package/dist/variants-JE2FSAQS.js +233 -0
  632. package/dist/verification-toolchains-V24UHW6Q.js +28 -0
  633. package/dist/verify-commands-H3DTCSGI.js +37 -0
  634. package/dist/warning-EGQGUUIO.js +12 -0
  635. package/dist/work-edge-RWEDWJZF.js +49 -0
  636. package/dist/work-item-writer-WHAVZXAY.js +19 -0
  637. package/dist/worker-7SA2VS2Y.js +1435 -0
  638. package/dist/worker.js +19 -0
  639. package/dist/worktree-metrics-3DFUYVYE.js +26 -0
  640. package/dist/writeback-VZKHYHSN.js +44 -0
  641. package/docs/CLI_REFERENCE.md +7042 -0
  642. package/docs/PROVIDER_SETUP.md +1570 -0
  643. package/docs/README.md +96 -0
  644. package/docs/TROUBLESHOOTING.md +2232 -0
  645. package/docs/getting-started/QUICK_START.md +294 -0
  646. package/docs/getting-started/README.md +188 -0
  647. package/docs/getting-started/SETUP.md +52 -0
  648. package/docs/reference/AGENT_CONTEXT.md +38 -0
  649. package/docs/reference/PROVIDER_RELEASE_TIERS.md +34 -0
  650. package/docs/reference/README.md +381 -0
  651. package/docs/reference/SECURITY.md +262 -0
  652. package/integrations/bb-plugin-poetic/README.md +362 -0
  653. package/integrations/bb-plugin-poetic/app.css +341 -0
  654. package/integrations/bb-plugin-poetic/app.tsx +5059 -0
  655. package/integrations/bb-plugin-poetic/package.json +45 -0
  656. package/integrations/bb-plugin-poetic/server.ts +444 -0
  657. package/integrations/bb-plugin-poetic/src/adapter.ts +3312 -0
  658. package/integrations/bb-plugin-poetic/src/backlog-authoring-model.ts +150 -0
  659. package/integrations/bb-plugin-poetic/src/backlog-authoring-schema.ts +355 -0
  660. package/integrations/bb-plugin-poetic/src/backlog-authoring-service.ts +419 -0
  661. package/integrations/bb-plugin-poetic/src/backlog-authoring-view.ts +1026 -0
  662. package/integrations/bb-plugin-poetic/src/competition-defaults-schema.ts +122 -0
  663. package/integrations/bb-plugin-poetic/src/competition-defaults-service.ts +105 -0
  664. package/integrations/bb-plugin-poetic/src/competition-defaults-view.ts +138 -0
  665. package/integrations/bb-plugin-poetic/src/contract.ts +615 -0
  666. package/integrations/bb-plugin-poetic/src/finalize-model.ts +205 -0
  667. package/integrations/bb-plugin-poetic/src/finalize-schema.ts +158 -0
  668. package/integrations/bb-plugin-poetic/src/finalize-service.ts +382 -0
  669. package/integrations/bb-plugin-poetic/src/finalize-view.ts +159 -0
  670. package/integrations/bb-plugin-poetic/src/judge-operations-readback.ts +303 -0
  671. package/integrations/bb-plugin-poetic/src/judge-operations-schema.ts +33 -0
  672. package/integrations/bb-plugin-poetic/src/judge-operations-view.ts +459 -0
  673. package/integrations/bb-plugin-poetic/src/model.ts +1302 -0
  674. package/integrations/bb-plugin-poetic/src/monitor-service.ts +233 -0
  675. package/integrations/bb-plugin-poetic/src/panel-read-ux.ts +97 -0
  676. package/integrations/bb-plugin-poetic/src/patch-preview-schema.ts +166 -0
  677. package/integrations/bb-plugin-poetic/src/patch-preview-service.ts +480 -0
  678. package/integrations/bb-plugin-poetic/src/patch-preview-view.ts +109 -0
  679. package/integrations/bb-plugin-poetic/src/planning-readback.ts +204 -0
  680. package/integrations/bb-plugin-poetic/src/planning-service.ts +594 -0
  681. package/integrations/bb-plugin-poetic/src/planning-workspace-schema.ts +95 -0
  682. package/integrations/bb-plugin-poetic/src/planning-workspace.ts +323 -0
  683. package/integrations/bb-plugin-poetic/src/poll-handoff.ts +136 -0
  684. package/integrations/bb-plugin-poetic/src/project-target-server.ts +21 -0
  685. package/integrations/bb-plugin-poetic/src/project-target.ts +45 -0
  686. package/integrations/bb-plugin-poetic/src/reference-index.ts +192 -0
  687. package/integrations/bb-plugin-poetic/src/repository-schema.ts +30 -0
  688. package/integrations/bb-plugin-poetic/src/result-explorer-view.ts +597 -0
  689. package/integrations/bb-plugin-poetic/src/result-readback-model.ts +163 -0
  690. package/integrations/bb-plugin-poetic/src/result-readback-schema.ts +319 -0
  691. package/integrations/bb-plugin-poetic/src/result-readback-service.ts +333 -0
  692. package/integrations/bb-plugin-poetic/src/run-page-view.ts +177 -0
  693. package/integrations/bb-plugin-poetic/src/setup-config-schema.ts +291 -0
  694. package/integrations/bb-plugin-poetic/src/setup-config-service.ts +590 -0
  695. package/integrations/bb-plugin-poetic/src/setup-config-view.ts +413 -0
  696. package/integrations/bb-plugin-poetic/src/sprint-close-model.ts +150 -0
  697. package/integrations/bb-plugin-poetic/src/sprint-close-schema.ts +136 -0
  698. package/integrations/bb-plugin-poetic/src/sprint-close-service.ts +341 -0
  699. package/integrations/bb-plugin-poetic/src/sprint-close-view.ts +116 -0
  700. package/integrations/bb-plugin-poetic/src/sprint-composition-model.ts +714 -0
  701. package/integrations/bb-plugin-poetic/src/sprint-composition-readback.ts +231 -0
  702. package/integrations/bb-plugin-poetic/src/sprint-composition-schema.ts +601 -0
  703. package/integrations/bb-plugin-poetic/src/sprint-composition-service.ts +775 -0
  704. package/integrations/bb-plugin-poetic/src/sprint-composition-view.ts +1221 -0
  705. package/integrations/bb-plugin-poetic/src/task-authoring-model.ts +567 -0
  706. package/integrations/bb-plugin-poetic/src/task-authoring-schema.ts +635 -0
  707. package/integrations/bb-plugin-poetic/src/task-authoring-service.ts +842 -0
  708. package/integrations/bb-plugin-poetic/src/task-authoring-view.ts +1227 -0
  709. package/integrations/bb-plugin-poetic/src/task-detail-readback.ts +56 -0
  710. package/integrations/bb-plugin-poetic/src/task-detail-schema.ts +144 -0
  711. package/integrations/bb-plugin-poetic/src/task-navigation.ts +446 -0
  712. package/integrations/bb-plugin-poetic/src/workbench-route.ts +74 -0
  713. package/integrations/bb-plugin-poetic/tests/host-contract.test.ts +773 -0
  714. package/integrations/bb-plugin-poetic/tsconfig.json +18 -0
  715. package/integrations/bb-plugin-poetic/types/PROVENANCE.json +52 -0
  716. package/integrations/bb-plugin-poetic/types/bb-plugin-sdk-app.d.ts +1444 -0
  717. package/integrations/bb-plugin-poetic/types/bb-plugin-sdk.d.ts +13030 -0
  718. package/integrations/bb-plugin-poetic/vitest.host.config.ts +71 -0
  719. package/npm-shrinkwrap.json +4950 -0
  720. package/package.json +331 -0
  721. package/schemas/README.md +80 -0
  722. package/schemas/config-v1.schema.json +136 -0
  723. package/schemas/execution-config.schema.json +47 -0
  724. package/schemas/judge-scoring.schema.json +370 -0
  725. package/schemas/poetic.config.schema.json +2214 -0
  726. package/schemas/provider-config.schema.json +203 -0
  727. package/schemas/telemetry-config.schema.json +79 -0
  728. package/schemas/user-preferences.schema.json +141 -0
  729. package/scripts/assert-node-runtime.mjs +140 -0
  730. package/scripts/preflight-native.mjs +49 -0
  731. package/scripts/preinstall-node-check.mjs +78 -0
  732. package/scripts/setup-git-hooks.mjs +24 -0
  733. package/scripts/sync.sh +2722 -0
  734. package/scripts/write-node-launcher.sh +108 -0
  735. package/src/resources/gemini/slash-packs/default/plan.toml +15 -0
  736. package/src/resources/gemini/slash-packs/default/summary.toml +16 -0
  737. package/src/resources/gemini/slash-packs/default/tests.toml +16 -0
  738. package/templates/.poetic/README.md +37 -0
  739. package/templates/.poetic/agents/README.md +296 -0
  740. package/templates/.poetic/agents/api-documenter.md +147 -0
  741. package/templates/.poetic/agents/backend-architect.md +31 -0
  742. package/templates/.poetic/agents/code-reviewer.md +157 -0
  743. package/templates/.poetic/agents/data-scientist.md +179 -0
  744. package/templates/.poetic/agents/database-optimizer.md +145 -0
  745. package/templates/.poetic/agents/debugger.md +31 -0
  746. package/templates/.poetic/agents/deployment-engineer.md +164 -0
  747. package/templates/.poetic/agents/devops-troubleshooter.md +139 -0
  748. package/templates/.poetic/agents/frontend-developer.md +150 -0
  749. package/templates/.poetic/agents/javascript-pro.md +36 -0
  750. package/templates/.poetic/agents/performance-engineer.md +151 -0
  751. package/templates/.poetic/agents/python-pro.md +137 -0
  752. package/templates/.poetic/agents/test-automator.md +147 -0
  753. package/templates/.poetic/agents/typescript-pro.md +34 -0
  754. package/templates/.poetic/config/poetic.config.jsonc +69 -0
  755. package/templates/.poetic/config/project-context.template.json +6 -0
  756. package/templates/.poetic/config/task-type-aliases.presets/kanban.yaml +14 -0
  757. package/templates/.poetic/config/task-type-aliases.presets/scrum.yaml +17 -0
  758. package/templates/.poetic/config/task-type-aliases.presets/xp.yaml +12 -0
  759. package/templates/.poetic/config/task-type-aliases.yaml +28 -0
  760. package/templates/.poetic/gitignore.template +55 -0
  761. package/templates/.poetic/task-types/analysis.yaml +40 -0
  762. package/templates/.poetic/task-types/architecture.yaml +38 -0
  763. package/templates/.poetic/task-types/doc.yaml +35 -0
  764. package/templates/.poetic/task-types/feature.yaml +23 -0
  765. package/templates/.poetic/task-types/general.yaml +6 -0
  766. package/templates/.poetic/task-types/security.yaml +39 -0
  767. package/templates/AGENTS.template.md +99 -0
  768. package/templates/CLAUDE.template.md +1 -0
  769. package/templates/GEMINI.template.md +1 -0
  770. package/templates/builtin-workflows/code-review.yaml +73 -0
  771. package/templates/builtin-workflows/compete-streak.yaml +78 -0
  772. package/templates/builtin-workflows/hello-verify.yaml +10 -0
  773. package/templates/builtin-workflows/judge-regression.yaml +114 -0
  774. package/templates/builtin-workflows/skills/code-review/SKILL.md +60 -0
  775. package/templates/builtin-workflows/skills/hello-verify/SKILL.md +6 -0
  776. package/templates/guard-kit/GUARD_SETUP.md.template +255 -0
  777. package/templates/guard-kit/check.mjs.template +777 -0
  778. package/templates/guard-kit/config.json.template +6 -0
  779. package/templates/guard-kit/poetic-guard.yml.template +189 -0
  780. package/templates/profiles/README.md +56 -0
  781. package/templates/profiles/frontier-claude.json +27 -0
  782. package/templates/profiles/frontier-codex.json +26 -0
@@ -0,0 +1,2440 @@
1
+ import {
2
+ stripPromptInjections
3
+ } from "./chunk-FQ7FSZRW.js";
4
+ import {
5
+ DomainAnalyzer
6
+ } from "./chunk-XEP5NQ5Y.js";
7
+ import {
8
+ TokenEstimator,
9
+ UTILIZATION_SPLIT_PERCENT,
10
+ UTILIZATION_WARN_PERCENT
11
+ } from "./chunk-ZSKKMTQJ.js";
12
+ import {
13
+ estimateTokensHeuristic
14
+ } from "./chunk-LFTQVYBB.js";
15
+ import {
16
+ resolveDefaultProvider,
17
+ resolveSplitterModel
18
+ } from "./chunk-XPU2XADL.js";
19
+ import {
20
+ parseJsonWithContext
21
+ } from "./chunk-QVZMFDYG.js";
22
+ import {
23
+ PROJECT_LANGUAGES
24
+ } from "./chunk-FHOWVDF5.js";
25
+ import {
26
+ languageForProjectPath
27
+ } from "./chunk-UDMS5AD3.js";
28
+ import {
29
+ debugLog,
30
+ emitCustomWarning,
31
+ emitWarning
32
+ } from "./chunk-EJGCZGUF.js";
33
+ import {
34
+ POETIC_SPLITTER_DEDUP_THRESHOLD,
35
+ POETIC_SPLITTER_SHADOW,
36
+ POETIC_SPLITTER_SHADOW_TIMEOUT_MS,
37
+ readEnv
38
+ } from "./chunk-5DLKYTQX.js";
39
+
40
+ // src/orchestrator/task-splitter.ts
41
+ import { createHash } from "crypto";
42
+
43
+ // src/core/routing/task-characteristics-analyzer.ts
44
+ var ROUTABLE_PROJECT_LANGUAGES = PROJECT_LANGUAGES.filter(
45
+ (language) => language !== "docs" && language !== "unknown"
46
+ );
47
+ var PROJECT_LANGUAGE_MATCHERS = {
48
+ node: [/\bnode(?:\.?js)?\b/i],
49
+ typescript: [/\btypescript\b/i, /\bts\b/i],
50
+ javascript: [/\bjavascript\b/i, /\bjs\b/i],
51
+ c: [/\bc language\b/i, /\blanguage c\b/i],
52
+ cpp: [/\bc\+\+(?:\d{2})?(?![\w+])/i, /\bcpp\b/i],
53
+ python: [/\bpython\b/i, /\bpy\b/i],
54
+ go: [
55
+ /\bgolang\b/i,
56
+ /\bgo language\b/i,
57
+ /\bgo (?:code|module|package|program(?:ming)?|service|binary|concurrency|goroutine|toolchain)\b/i,
58
+ /\b(?:written|write|rewritten|rewrite|ported|port|implement(?:ed|ing)?|using)\s+(?:in\s+)?go\b/i,
59
+ /\bin go\b/i
60
+ ],
61
+ rust: [/\brust\b/i],
62
+ java: [/\bjava\b/i],
63
+ // Explicit prose aliases only — never match arbitrary domains like example.net.
64
+ // Standalone/whitespace-delimited `.NET` requires a non-domain left boundary.
65
+ dotnet: [
66
+ /\bc#(?!\w)/i,
67
+ /\bcsharp\b/i,
68
+ /\bdotnet\b/i,
69
+ /\basp\.net\b/i,
70
+ /(?:^|[\s,;:()[\]{}"'`/])\.NET\b/i
71
+ ],
72
+ swift: [/\bswift\b/i],
73
+ kotlin: [/\bkotlin\b/i],
74
+ dart: [/\bdart\b/i],
75
+ ruby: [/\bruby\b/i, /\brb\b/i],
76
+ php: [/\bphp\b/i],
77
+ shell: [/\bshell script(?:ing)?\b/i, /\b(?:bash|zsh|fish|ksh)\b/i],
78
+ powershell: [/\bpowershell\b/i],
79
+ r: [/\br language\b/i, /\b(?:written|write|implemented|implement|using)\s+(?:in\s+)?r\b/i],
80
+ sql: [/\bsql\b/i]
81
+ };
82
+ var TaskCharacteristicsAnalyzer = class {
83
+ analyze(taskDescription, domainAnalysis) {
84
+ const characteristics = this.extractCharacteristics(taskDescription, domainAnalysis);
85
+ const confidence = this.calculateConfidence(characteristics);
86
+ const rationale = this.generateRationale(characteristics, domainAnalysis);
87
+ const recommendedApproach = this.recommendApproach(characteristics, domainAnalysis);
88
+ const estimatedComplexity = this.estimateComplexity(characteristics, domainAnalysis);
89
+ const timeEstimate = this.estimateTime(characteristics, domainAnalysis);
90
+ return {
91
+ characteristics,
92
+ confidence,
93
+ rationale,
94
+ recommendedApproach,
95
+ estimatedComplexity,
96
+ timeEstimate
97
+ };
98
+ }
99
+ extractCharacteristics(taskDescription, domainAnalysis) {
100
+ const lowerTask = taskDescription.toLowerCase();
101
+ return {
102
+ // File and language analysis
103
+ fileTypes: this.extractFileTypes(taskDescription),
104
+ programmingLanguages: this.extractProgrammingLanguages(taskDescription),
105
+ fileCount: domainAnalysis.filesMentioned.length,
106
+ // Complexity indicators
107
+ hasMultipleFiles: domainAnalysis.filesMentioned.length > 1,
108
+ hasComplexDependencies: this.hasComplexDependencies(lowerTask),
109
+ requiresRefactoring: this.requiresRefactoring(lowerTask),
110
+ requiresTesting: this.requiresTesting(lowerTask),
111
+ // Task intent analysis
112
+ isBugFix: this.isBugFix(lowerTask),
113
+ isFeatureAddition: this.isFeatureAddition(lowerTask),
114
+ isRefactoring: this.isRefactoring(lowerTask),
115
+ isDocumentation: this.isDocumentation(lowerTask),
116
+ isTesting: this.isTesting(lowerTask),
117
+ // Technical requirements
118
+ requiresDatabaseChanges: this.requiresDatabaseChanges(lowerTask),
119
+ requiresAPIIntegration: this.requiresAPIIntegration(lowerTask),
120
+ requiresUIImplementation: this.requiresUIImplementation(lowerTask),
121
+ requiresConfiguration: this.requiresConfiguration(lowerTask),
122
+ // Performance and quality indicators
123
+ requiresOptimization: this.requiresOptimization(lowerTask),
124
+ requiresSecurityReview: this.requiresSecurityReview(lowerTask),
125
+ requiresCodeReview: this.requiresCodeReview(lowerTask),
126
+ // Context and scope
127
+ isCriticalPath: this.isCriticalPath(lowerTask),
128
+ affectsMultipleModules: this.affectsMultipleModules(lowerTask, domainAnalysis),
129
+ requiresCoordination: this.requiresCoordination(lowerTask, domainAnalysis)
130
+ };
131
+ }
132
+ extractFileTypes(taskDescription) {
133
+ const filePattern = /\.([a-zA-Z0-9]+)\b/g;
134
+ const types = [];
135
+ for (const match of taskDescription.matchAll(filePattern)) {
136
+ const ext = match[1];
137
+ if (ext) types.push(ext);
138
+ }
139
+ return [...new Set(types)];
140
+ }
141
+ extractProgrammingLanguages(taskDescription) {
142
+ const detected = /* @__PURE__ */ new Set();
143
+ for (const language of ROUTABLE_PROJECT_LANGUAGES) {
144
+ const patterns = PROJECT_LANGUAGE_MATCHERS[language];
145
+ if (patterns.some((pattern) => pattern.test(taskDescription))) {
146
+ detected.add(language);
147
+ }
148
+ }
149
+ for (const ext of this.extractFileTypes(taskDescription)) {
150
+ const language = languageForProjectPath(`file.${ext}`);
151
+ if (language && language !== "docs" && language !== "unknown" && ROUTABLE_PROJECT_LANGUAGES.includes(language)) {
152
+ detected.add(language);
153
+ }
154
+ }
155
+ return ROUTABLE_PROJECT_LANGUAGES.filter((language) => detected.has(language));
156
+ }
157
+ hasComplexDependencies(taskDescription) {
158
+ const complexDependencyKeywords = [
159
+ "dependency",
160
+ "dependencies",
161
+ "import",
162
+ "require",
163
+ "module",
164
+ "package",
165
+ "library",
166
+ "framework",
167
+ "api",
168
+ "integration",
169
+ "external",
170
+ "third-party",
171
+ "npm",
172
+ "yarn",
173
+ "pip",
174
+ "maven"
175
+ ];
176
+ return complexDependencyKeywords.some((keyword) => taskDescription.includes(keyword));
177
+ }
178
+ requiresRefactoring(taskDescription) {
179
+ const refactoringKeywords = [
180
+ "refactor",
181
+ "refactoring",
182
+ "restructure",
183
+ "reorganize",
184
+ "clean up",
185
+ "cleanup",
186
+ "optimize",
187
+ "improve",
188
+ "modernize",
189
+ "update",
190
+ "upgrade",
191
+ "migrate",
192
+ "convert"
193
+ ];
194
+ return refactoringKeywords.some((keyword) => taskDescription.includes(keyword));
195
+ }
196
+ requiresTesting(taskDescription) {
197
+ const testingKeywords = [
198
+ "test",
199
+ "testing",
200
+ "spec",
201
+ "specification",
202
+ "unit test",
203
+ "integration test",
204
+ "e2e",
205
+ "end-to-end",
206
+ "coverage",
207
+ "assert",
208
+ "expect",
209
+ "mock",
210
+ "stub",
211
+ "fixture"
212
+ ];
213
+ return testingKeywords.some((keyword) => taskDescription.includes(keyword));
214
+ }
215
+ isBugFix(taskDescription) {
216
+ const bugFixKeywords = [
217
+ "bug",
218
+ "fix",
219
+ "error",
220
+ "issue",
221
+ "problem",
222
+ "bugfix",
223
+ "resolve",
224
+ "correct",
225
+ "repair",
226
+ "patch",
227
+ "hotfix"
228
+ ];
229
+ return bugFixKeywords.some((keyword) => taskDescription.includes(keyword));
230
+ }
231
+ isFeatureAddition(taskDescription) {
232
+ const featureKeywords = [
233
+ "add",
234
+ "create",
235
+ "implement",
236
+ "build",
237
+ "develop",
238
+ "feature",
239
+ "functionality",
240
+ "capability",
241
+ "new",
242
+ "enhancement",
243
+ "improvement",
244
+ "extension"
245
+ ];
246
+ return featureKeywords.some((keyword) => taskDescription.includes(keyword));
247
+ }
248
+ isRefactoring(taskDescription) {
249
+ const refactoringKeywords = [
250
+ "refactor",
251
+ "refactoring",
252
+ "restructure",
253
+ "reorganize",
254
+ "rewrite",
255
+ "redesign",
256
+ "rearchitect"
257
+ ];
258
+ return refactoringKeywords.some((keyword) => taskDescription.includes(keyword));
259
+ }
260
+ isDocumentation(taskDescription) {
261
+ const documentationKeywords = [
262
+ "documentation",
263
+ "docs",
264
+ "readme",
265
+ "comment",
266
+ "explain",
267
+ "describe",
268
+ "document",
269
+ "guide",
270
+ "tutorial",
271
+ "api docs"
272
+ ];
273
+ return documentationKeywords.some((keyword) => taskDescription.includes(keyword));
274
+ }
275
+ isTesting(taskDescription) {
276
+ const testingKeywords = [
277
+ "test",
278
+ "testing",
279
+ "spec",
280
+ "specification",
281
+ "unit test",
282
+ "integration test",
283
+ "e2e",
284
+ "end-to-end",
285
+ "coverage"
286
+ ];
287
+ return testingKeywords.some((keyword) => taskDescription.includes(keyword));
288
+ }
289
+ requiresDatabaseChanges(taskDescription) {
290
+ const databaseKeywords = [
291
+ "database",
292
+ "db",
293
+ "sql",
294
+ "query",
295
+ "table",
296
+ "schema",
297
+ "migration",
298
+ "migrate",
299
+ "data",
300
+ "record",
301
+ "entity",
302
+ "orm",
303
+ "sequelize",
304
+ "prisma",
305
+ "typeorm"
306
+ ];
307
+ return databaseKeywords.some((keyword) => taskDescription.includes(keyword));
308
+ }
309
+ requiresAPIIntegration(taskDescription) {
310
+ const apiKeywords = [
311
+ "api",
312
+ "endpoint",
313
+ "rest",
314
+ "graphql",
315
+ "http",
316
+ "request",
317
+ "response",
318
+ "fetch",
319
+ "axios",
320
+ "fetch",
321
+ "integration",
322
+ "service",
323
+ "microservice",
324
+ "webhook",
325
+ "callback"
326
+ ];
327
+ return apiKeywords.some((keyword) => taskDescription.includes(keyword));
328
+ }
329
+ requiresUIImplementation(taskDescription) {
330
+ const uiKeywords = [
331
+ "ui",
332
+ "user interface",
333
+ "frontend",
334
+ "component",
335
+ "react",
336
+ "vue",
337
+ "angular",
338
+ "html",
339
+ "css",
340
+ "styling",
341
+ "design",
342
+ "layout",
343
+ "responsive",
344
+ "mobile",
345
+ "desktop",
346
+ "button",
347
+ "form",
348
+ "input",
349
+ "modal",
350
+ "dialog",
351
+ "page"
352
+ ];
353
+ return uiKeywords.some((keyword) => taskDescription.includes(keyword));
354
+ }
355
+ requiresConfiguration(taskDescription) {
356
+ const configKeywords = [
357
+ "config",
358
+ "configuration",
359
+ "settings",
360
+ "environment",
361
+ "env",
362
+ "variables",
363
+ "properties",
364
+ "yaml",
365
+ "json",
366
+ "ini",
367
+ "toml",
368
+ "setup",
369
+ "install",
370
+ "deploy"
371
+ ];
372
+ return configKeywords.some((keyword) => taskDescription.includes(keyword));
373
+ }
374
+ requiresOptimization(taskDescription) {
375
+ const optimizationKeywords = [
376
+ "optimize",
377
+ "optimization",
378
+ "performance",
379
+ "speed",
380
+ "fast",
381
+ "efficient",
382
+ "memory",
383
+ "cpu",
384
+ "bottleneck",
385
+ "profiling",
386
+ "benchmark",
387
+ "improve",
388
+ "enhance"
389
+ ];
390
+ return optimizationKeywords.some((keyword) => taskDescription.includes(keyword));
391
+ }
392
+ requiresSecurityReview(taskDescription) {
393
+ const securityKeywords = [
394
+ "security",
395
+ "secure",
396
+ "vulnerability",
397
+ "auth",
398
+ "authentication",
399
+ "authorization",
400
+ "permission",
401
+ "access",
402
+ "encrypt",
403
+ "hash",
404
+ "password",
405
+ "token",
406
+ "jwt",
407
+ "oauth",
408
+ "ssl",
409
+ "tls"
410
+ ];
411
+ return securityKeywords.some((keyword) => taskDescription.includes(keyword));
412
+ }
413
+ requiresCodeReview(taskDescription) {
414
+ const reviewKeywords = [
415
+ "review",
416
+ "code review",
417
+ "pr",
418
+ "pull request",
419
+ "merge",
420
+ "approve",
421
+ "feedback",
422
+ "comment",
423
+ "suggestion"
424
+ ];
425
+ return reviewKeywords.some((keyword) => taskDescription.includes(keyword));
426
+ }
427
+ isCriticalPath(taskDescription) {
428
+ const criticalKeywords = [
429
+ "critical",
430
+ "urgent",
431
+ "priority",
432
+ "important",
433
+ "blocking",
434
+ "hotfix",
435
+ "emergency",
436
+ "asap",
437
+ "immediately",
438
+ "deadline"
439
+ ];
440
+ return criticalKeywords.some((keyword) => taskDescription.includes(keyword));
441
+ }
442
+ affectsMultipleModules(taskDescription, domainAnalysis) {
443
+ return domainAnalysis.filesMentioned.length > 3 || domainAnalysis.featureCount > 2 || taskDescription.toLowerCase().includes("multiple") || taskDescription.toLowerCase().includes("several");
444
+ }
445
+ requiresCoordination(taskDescription, domainAnalysis) {
446
+ return domainAnalysis.filesMentioned.length > 5 || taskDescription.toLowerCase().includes("team") || taskDescription.toLowerCase().includes("collaborate") || taskDescription.toLowerCase().includes("coordinate") || taskDescription.toLowerCase().includes("sync");
447
+ }
448
+ calculateConfidence(characteristics) {
449
+ let confidence = 0.5;
450
+ if (characteristics.fileCount > 0) confidence += 0.1;
451
+ if (characteristics.programmingLanguages.length > 0) confidence += 0.1;
452
+ if (characteristics.isBugFix || characteristics.isFeatureAddition) confidence += 0.1;
453
+ if (characteristics.requiresTesting) confidence += 0.1;
454
+ if (characteristics.requiresRefactoring) confidence += 0.1;
455
+ if (characteristics.fileCount === 0 && characteristics.programmingLanguages.length === 0) {
456
+ confidence -= 0.2;
457
+ }
458
+ return Math.min(1, Math.max(0, confidence));
459
+ }
460
+ generateRationale(characteristics, _domainAnalysis) {
461
+ const rationale = [];
462
+ rationale.push(`File types detected: ${characteristics.fileTypes.join(", ") || "none"}`);
463
+ rationale.push(
464
+ `Programming languages: ${characteristics.programmingLanguages.join(", ") || "none"}`
465
+ );
466
+ rationale.push(`File count: ${characteristics.fileCount}`);
467
+ if (characteristics.isBugFix) rationale.push("Task type: Bug fix");
468
+ if (characteristics.isFeatureAddition) rationale.push("Task type: Feature addition");
469
+ if (characteristics.isRefactoring) rationale.push("Task type: Refactoring");
470
+ if (characteristics.isDocumentation) rationale.push("Task type: Documentation");
471
+ if (characteristics.isTesting) rationale.push("Task type: Testing");
472
+ if (characteristics.requiresDatabaseChanges) rationale.push("Requires database changes");
473
+ if (characteristics.requiresAPIIntegration) rationale.push("Requires API integration");
474
+ if (characteristics.requiresUIImplementation) rationale.push("Requires UI implementation");
475
+ if (characteristics.requiresConfiguration) rationale.push("Requires configuration changes");
476
+ if (characteristics.isCriticalPath) rationale.push("Critical path task");
477
+ if (characteristics.affectsMultipleModules) rationale.push("Affects multiple modules");
478
+ if (characteristics.requiresCoordination) rationale.push("Requires coordination");
479
+ return rationale;
480
+ }
481
+ recommendApproach(characteristics, _domainAnalysis) {
482
+ if (characteristics.isCriticalPath || characteristics.isBugFix || characteristics.requiresSecurityReview) {
483
+ return "conservative";
484
+ }
485
+ if (characteristics.isFeatureAddition && !characteristics.isCriticalPath) {
486
+ return "innovative";
487
+ }
488
+ if (characteristics.isRefactoring && characteristics.affectsMultipleModules) {
489
+ return "hybrid";
490
+ }
491
+ return "hybrid";
492
+ }
493
+ estimateComplexity(characteristics, _domainAnalysis) {
494
+ let complexityScore = 0;
495
+ if (characteristics.fileCount > 10) complexityScore += 3;
496
+ else if (characteristics.fileCount > 5) complexityScore += 2;
497
+ else if (characteristics.fileCount > 1) complexityScore += 1;
498
+ if (characteristics.requiresDatabaseChanges) complexityScore += 2;
499
+ if (characteristics.requiresAPIIntegration) complexityScore += 2;
500
+ if (characteristics.requiresUIImplementation) complexityScore += 2;
501
+ if (characteristics.requiresConfiguration) complexityScore += 1;
502
+ if (characteristics.isRefactoring) complexityScore += 2;
503
+ if (characteristics.affectsMultipleModules) complexityScore += 2;
504
+ if (characteristics.requiresCoordination) complexityScore += 1;
505
+ if (_domainAnalysis.complexity === "high") complexityScore += 3;
506
+ else if (_domainAnalysis.complexity === "medium") complexityScore += 2;
507
+ else complexityScore += 1;
508
+ if (complexityScore >= 8) return "high";
509
+ if (complexityScore >= 4) return "medium";
510
+ return "low";
511
+ }
512
+ /**
513
+ * Estimate an advisory AI expected wall-clock runtime range (minutes) from a
514
+ * task's characteristics. AI-native bands per the estimation doctrine (minutes
515
+ * for simple work, up to a few hours for larger implementation) — NOT human
516
+ * effort. Advisory guidance only; never a gate ([B5]).
517
+ */
518
+ estimateTime(characteristics, domainAnalysis) {
519
+ const baseMinutes = 30;
520
+ let multiplier = 1;
521
+ let confidence = 0.7;
522
+ if (characteristics.fileCount > 10) multiplier += 2;
523
+ else if (characteristics.fileCount > 5) multiplier += 1.5;
524
+ else if (characteristics.fileCount > 1) multiplier += 0.5;
525
+ if (characteristics.requiresDatabaseChanges) multiplier += 1;
526
+ if (characteristics.requiresAPIIntegration) multiplier += 1;
527
+ if (characteristics.requiresUIImplementation) multiplier += 1;
528
+ if (characteristics.requiresConfiguration) multiplier += 0.5;
529
+ if (characteristics.isRefactoring) multiplier += 1.5;
530
+ if (characteristics.isTesting) multiplier += 0.5;
531
+ if (characteristics.isDocumentation) multiplier += 0.3;
532
+ if (domainAnalysis.complexity === "high") multiplier += 2;
533
+ else if (domainAnalysis.complexity === "medium") multiplier += 1;
534
+ const min = Math.round(baseMinutes * multiplier * 0.7);
535
+ const max = Math.round(baseMinutes * multiplier * 1.5);
536
+ if (characteristics.fileCount === 0) confidence -= 0.2;
537
+ if (characteristics.programmingLanguages.length === 0) confidence -= 0.1;
538
+ if (characteristics.affectsMultipleModules) confidence -= 0.1;
539
+ return {
540
+ min: Math.max(5, min),
541
+ // Floor: a few minutes for the smallest AI change
542
+ max: Math.min(480, max),
543
+ // Ceiling: cap advisory AI runtime at a few hours
544
+ confidence: Math.max(0.3, Math.min(1, confidence))
545
+ };
546
+ }
547
+ };
548
+
549
+ // src/orchestrator/task-splitter.ts
550
+ var SUBTASK_DEDUP_THRESHOLD = readEnv(POETIC_SPLITTER_DEDUP_THRESHOLD).value ?? 0.7;
551
+ var SPLITTER_SHADOW_TIMEOUT_MS = readEnv(POETIC_SPLITTER_SHADOW_TIMEOUT_MS).value ?? 45e3;
552
+ var FILE_PATH_TOKEN_REGEX = /(?:[a-zA-Z]:)?(?:\.?\.?\/)?(?:[a-zA-Z0-9_\-./\\]+?\.(?:ts|js|tsx|jsx|py|java|go|rs|cpp|c|h|mjs|cjs|json|md|yaml|yml))\b/g;
553
+ function isAnalysisSubTask(subTask) {
554
+ return subTask.executionIntent === "analysis" || subTask.editsAllowed === false;
555
+ }
556
+ var TaskSplitter = class _TaskSplitter {
557
+ // Strategies that are allowed to produce zero subtasks
558
+ static ALLOW_ZERO_SUBTASKS = /* @__PURE__ */ new Set([
559
+ "no-split"
560
+ // Future strategies that allow zero subtasks can be added here
561
+ ]);
562
+ domainAnalyzer;
563
+ taskCharacteristicsAnalyzer;
564
+ tokenEstimator;
565
+ splitterShadowRunner;
566
+ constructor(deps) {
567
+ this.domainAnalyzer = deps?.domainAnalyzer ?? new DomainAnalyzer();
568
+ this.taskCharacteristicsAnalyzer = deps?.taskCharacteristicsAnalyzer ?? new TaskCharacteristicsAnalyzer();
569
+ this.tokenEstimator = deps?.tokenEstimator ?? new TokenEstimator();
570
+ this.splitterShadowRunner = deps?.splitterShadowRunner ?? this.defaultSplitterShadowRunner;
571
+ }
572
+ /**
573
+ * Split a task into N parallel sub-tasks with routing decisions
574
+ *
575
+ * @param prompt - Original task description
576
+ * @param numAgents - Number of parallel agents to use
577
+ * @param routingOptions - Optional routing configuration
578
+ * @param splitOptions - Optional splitting configuration (e.g., sequential batching, token-aware)
579
+ * @returns Split task result with sub-tasks and routing decisions
580
+ */
581
+ async split(prompt, numAgents, routingOptions = {}, splitOptions) {
582
+ if (numAgents < 1) {
583
+ throw new Error("Number of agents must be at least 1");
584
+ }
585
+ const strippedPrompt = stripPromptInjections(prompt);
586
+ const heuristicPrompt = strippedPrompt.length > 0 ? strippedPrompt : prompt;
587
+ debugLog("[TaskSplitter] Splitting prompt:", prompt);
588
+ debugLog("[TaskSplitter] Requested agents:", numAgents);
589
+ let tokenAnalysis;
590
+ if (splitOptions?.contextMode === "auto") {
591
+ if (!splitOptions?.targetProvider || !splitOptions?.targetModel) {
592
+ emitWarning(
593
+ "CFG-002",
594
+ {
595
+ taskId: "unknown",
596
+ subsystem: "orchestrator",
597
+ executionPhase: "setup"
598
+ },
599
+ {
600
+ severity: "WARN" /* WARN */,
601
+ metadata: {
602
+ operation: "tokenAnalysis",
603
+ contextMode: "auto",
604
+ reason: "Missing targetProvider or targetModel"
605
+ },
606
+ recovered: true,
607
+ recoveryMechanism: "Skipping token analysis - using semantic splitting only"
608
+ }
609
+ );
610
+ } else if (splitOptions?.targetProvider && splitOptions?.targetModel) {
611
+ try {
612
+ tokenAnalysis = await this.tokenEstimator.analyzeTask(
613
+ prompt,
614
+ splitOptions.targetProvider,
615
+ splitOptions.targetModel
616
+ );
617
+ debugLog("[TaskSplitter] Token Analysis:");
618
+ debugLog(` Estimated tokens: ${tokenAnalysis.estimatedTokens}`);
619
+ debugLog(` Context window: ${tokenAnalysis.contextWindow}`);
620
+ debugLog(` Utilization: ${tokenAnalysis.utilizationPercent.toFixed(1)}%`);
621
+ debugLog(
622
+ ` Adjusted utilization: ${tokenAnalysis.adjustedUtilizationPercent.toFixed(1)}%`
623
+ );
624
+ debugLog(` Estimation confidence: ${tokenAnalysis.estimationConfidence.toFixed(2)}`);
625
+ debugLog(` Should split: ${tokenAnalysis.shouldSplit}`);
626
+ if (splitOptions.forceSplit) {
627
+ debugLog(
628
+ "[TaskSplitter] Force split enabled, will attempt splitting regardless of threshold"
629
+ );
630
+ }
631
+ if (tokenAnalysis.adjustedUtilizationPercent > UTILIZATION_WARN_PERCENT && tokenAnalysis.adjustedUtilizationPercent <= UTILIZATION_SPLIT_PERCENT) {
632
+ emitWarning(
633
+ "PERF-001",
634
+ {
635
+ taskId: "unknown",
636
+ subsystem: "orchestrator",
637
+ executionPhase: "setup"
638
+ },
639
+ {
640
+ severity: "WARN" /* WARN */,
641
+ metadata: {
642
+ operation: "tokenAnalysis",
643
+ adjustedUtilizationPercent: tokenAnalysis.adjustedUtilizationPercent,
644
+ estimatedTokens: tokenAnalysis.estimatedTokens,
645
+ contextWindow: tokenAnalysis.contextWindow
646
+ }
647
+ }
648
+ );
649
+ }
650
+ if (tokenAnalysis.adjustedUtilizationPercent > UTILIZATION_SPLIT_PERCENT) {
651
+ if (tokenAnalysis.estimationConfidence < 0.5) {
652
+ emitWarning(
653
+ "CFG-002",
654
+ {
655
+ taskId: "unknown",
656
+ subsystem: "orchestrator",
657
+ executionPhase: "setup"
658
+ },
659
+ {
660
+ severity: "WARN" /* WARN */,
661
+ metadata: {
662
+ operation: "tokenAnalysis",
663
+ estimationConfidence: tokenAnalysis.estimationConfidence,
664
+ adjustedUtilizationPercent: tokenAnalysis.adjustedUtilizationPercent
665
+ },
666
+ recovered: true,
667
+ recoveryMechanism: "Proceeding without auto-split (use --force-split to override)"
668
+ }
669
+ );
670
+ } else {
671
+ debugLog(
672
+ `[TaskSplitter] High confidence (${tokenAnalysis.estimationConfidence.toFixed(2)}), proceeding with split`
673
+ );
674
+ }
675
+ }
676
+ if (splitOptions.noSplit) {
677
+ debugLog("[TaskSplitter] No split forced, returning single task");
678
+ const result2 = {
679
+ subTasks: [
680
+ {
681
+ id: 1,
682
+ description: prompt,
683
+ files: [],
684
+ context: "",
685
+ dependencies: []
686
+ }
687
+ ],
688
+ pendingSubTasks: [],
689
+ strategy: "no-split",
690
+ reasoning: "Manual override: --no-split flag",
691
+ tokenAnalysis
692
+ };
693
+ this.validateCompleteExecution(result2);
694
+ return await this.finalizeSplitResult(result2, prompt, numAgents, splitOptions);
695
+ }
696
+ if (!tokenAnalysis.shouldSplit && !splitOptions.forceSplit) {
697
+ const earlySignals = this.analyzeCouplingSignals(heuristicPrompt);
698
+ const hasSemanticRoutingNeed = earlySignals.coupled || earlySignals.filePaths.length > 1 || this.hasIndependentMechanicalFileList(heuristicPrompt);
699
+ if (!hasSemanticRoutingNeed) {
700
+ debugLog(
701
+ `[TaskSplitter] Task within threshold (${tokenAnalysis.adjustedUtilizationPercent.toFixed(1)}%), no multi-file/coupling signals \u2014 no splitting needed`
702
+ );
703
+ const result2 = {
704
+ subTasks: [
705
+ {
706
+ id: 1,
707
+ description: prompt,
708
+ files: [],
709
+ context: "",
710
+ dependencies: []
711
+ }
712
+ ],
713
+ pendingSubTasks: [],
714
+ strategy: "no-split",
715
+ reasoning: `Task uses ${tokenAnalysis.adjustedUtilizationPercent.toFixed(1)}% of adjusted context window (under threshold)`,
716
+ tokenAnalysis
717
+ };
718
+ this.validateCompleteExecution(result2);
719
+ return await this.finalizeSplitResult(result2, prompt, numAgents, splitOptions);
720
+ }
721
+ debugLog(
722
+ "[TaskSplitter] Task within token threshold but multi-file/coupling signals present \u2014 continuing semantic routing"
723
+ );
724
+ }
725
+ if (tokenAnalysis.shouldSplit) {
726
+ debugLog(
727
+ `[TaskSplitter] Task exceeds threshold, applying ${tokenAnalysis.strategy} splitting`
728
+ );
729
+ }
730
+ if (tokenAnalysis.shouldSplit && tokenAnalysis.strategy === "sequential") {
731
+ const sequentialSignals = this.analyzeCouplingSignals(heuristicPrompt);
732
+ if (!sequentialSignals.coupled && sequentialSignals.filePaths.length <= 1) {
733
+ debugLog("[TaskSplitter] Using sequential chunking for very large task");
734
+ const sequentialResult = await this.splitSequentially(
735
+ prompt,
736
+ numAgents,
737
+ tokenAnalysis.estimatedTokens,
738
+ tokenAnalysis.thresholdTokens,
739
+ tokenAnalysis
740
+ );
741
+ return await this.finalizeSplitResult(
742
+ sequentialResult,
743
+ prompt,
744
+ numAgents,
745
+ splitOptions
746
+ );
747
+ }
748
+ debugLog(
749
+ "[TaskSplitter] Sequential token strategy deferred \u2014 multi-file/coupling requires semantic routing"
750
+ );
751
+ }
752
+ } catch (error) {
753
+ emitWarning(
754
+ "CFG-002",
755
+ {
756
+ taskId: "unknown",
757
+ subsystem: "orchestrator",
758
+ executionPhase: "setup"
759
+ },
760
+ {
761
+ severity: "WARN" /* WARN */,
762
+ metadata: {
763
+ operation: "tokenAnalysis",
764
+ error: error instanceof Error ? error.message : String(error)
765
+ },
766
+ recovered: true,
767
+ recoveryMechanism: "Proceeding without auto-decomposition - using semantic splitting"
768
+ }
769
+ );
770
+ }
771
+ }
772
+ } else {
773
+ debugLog("[TaskSplitter] Token analysis skipped (contextMode=off)");
774
+ if (splitOptions?.noSplit) {
775
+ debugLog("[TaskSplitter] No split forced, returning single task");
776
+ const result2 = {
777
+ subTasks: [
778
+ {
779
+ id: 1,
780
+ description: prompt,
781
+ files: [],
782
+ context: "",
783
+ dependencies: []
784
+ }
785
+ ],
786
+ pendingSubTasks: [],
787
+ strategy: "no-split",
788
+ reasoning: "Manual override: --no-split flag",
789
+ tokenAnalysis: void 0
790
+ };
791
+ this.validateCompleteExecution(result2);
792
+ return await this.finalizeSplitResult(result2, prompt, numAgents, splitOptions);
793
+ }
794
+ }
795
+ const domainAnalysis = await this.safeAnalyzeDomain(heuristicPrompt);
796
+ const taskAnalysis = this.safeAnalyzeTaskCharacteristics(heuristicPrompt, domainAnalysis);
797
+ const attachMetadata = (subTasks, heuristics2, strategy) => this.attachMetadataToSubTasks(
798
+ subTasks,
799
+ prompt,
800
+ heuristics2,
801
+ domainAnalysis,
802
+ taskAnalysis,
803
+ strategy
804
+ );
805
+ if (numAgents === 1) {
806
+ const heuristics2 = /* @__PURE__ */ new Set(["single-agent"]);
807
+ const result2 = {
808
+ subTasks: [
809
+ {
810
+ id: 1,
811
+ description: prompt,
812
+ files: [],
813
+ context: "",
814
+ dependencies: [],
815
+ metadata: this.createPlaceholderMetadata(
816
+ heuristics2,
817
+ domainAnalysis,
818
+ taskAnalysis,
819
+ prompt,
820
+ "single",
821
+ 1,
822
+ 0
823
+ )
824
+ }
825
+ ],
826
+ pendingSubTasks: [],
827
+ strategy: "single",
828
+ reasoning: "Only 1 agent requested, no splitting needed",
829
+ tokenAnalysis
830
+ // Include token analysis if available
831
+ };
832
+ result2.subTasks = attachMetadata(result2.subTasks, heuristics2, result2.strategy);
833
+ if (routingOptions.enableRouting) {
834
+ result2.routingDecisions = await this.generateRoutingDecisions(
835
+ result2.subTasks,
836
+ domainAnalysis,
837
+ routingOptions
838
+ );
839
+ }
840
+ this.validateCompleteExecution(result2);
841
+ return await this.finalizeSplitResult(result2, prompt, numAgents, splitOptions);
842
+ }
843
+ const coupling = this.analyzeCouplingSignals(heuristicPrompt);
844
+ if (coupling.coupled && numAgents > 1) {
845
+ debugLog(
846
+ `[TaskSplitter] Coupling signals detected (${coupling.signals.join(", ")}) \u2014 attempting provider semantic split`
847
+ );
848
+ const semanticResult = await this.tryProviderSemanticSplit(
849
+ heuristicPrompt,
850
+ prompt,
851
+ numAgents,
852
+ coupling,
853
+ tokenAnalysis
854
+ );
855
+ if (semanticResult) {
856
+ const heuristicsSemantic = /* @__PURE__ */ new Set([
857
+ "semantic-provider",
858
+ "coupling-detected",
859
+ ...coupling.signals.map((signal) => `coupling:${signal}`)
860
+ ]);
861
+ semanticResult.subTasks = attachMetadata(
862
+ semanticResult.subTasks,
863
+ heuristicsSemantic,
864
+ semanticResult.strategy
865
+ );
866
+ semanticResult.tokenAnalysis = tokenAnalysis;
867
+ if (routingOptions.enableRouting) {
868
+ semanticResult.routingDecisions = await this.generateRoutingDecisions(
869
+ semanticResult.subTasks,
870
+ domainAnalysis,
871
+ routingOptions
872
+ );
873
+ }
874
+ const hasDependencyEdges = semanticResult.subTasks.some(
875
+ (task) => task.dependencies.length > 0
876
+ );
877
+ if (splitOptions?.mode === "sequential" && !hasDependencyEdges) {
878
+ const batchedResult = this.applySequentialBatching(semanticResult, numAgents);
879
+ this.validateCompleteExecution(batchedResult);
880
+ return await this.finalizeSplitResult(batchedResult, prompt, numAgents, splitOptions);
881
+ }
882
+ this.validateCompleteExecution(semanticResult);
883
+ return await this.finalizeSplitResult(semanticResult, prompt, numAgents, splitOptions);
884
+ }
885
+ debugLog(
886
+ "[TaskSplitter] Coupled work could not be validated via provider semantic split \u2014 conservative unsplit"
887
+ );
888
+ const coupledHeuristics = /* @__PURE__ */ new Set([
889
+ "coupling-detected",
890
+ "semantic-fallback-unsplit",
891
+ ...coupling.signals.map((signal) => `coupling:${signal}`)
892
+ ]);
893
+ const unsplit = this.createSingleTask(
894
+ prompt,
895
+ `Coupled multi-file work detected (${coupling.signals.join(", ")}); conservatively keeping as single task after semantic split validation failure`
896
+ );
897
+ unsplit.subTasks = attachMetadata(unsplit.subTasks, coupledHeuristics, unsplit.strategy);
898
+ unsplit.tokenAnalysis = tokenAnalysis;
899
+ if (routingOptions.enableRouting) {
900
+ unsplit.routingDecisions = await this.generateRoutingDecisions(
901
+ unsplit.subTasks,
902
+ domainAnalysis,
903
+ routingOptions
904
+ );
905
+ }
906
+ this.validateCompleteExecution(unsplit);
907
+ return await this.finalizeSplitResult(unsplit, prompt, numAgents, splitOptions);
908
+ }
909
+ const fileSplit = this.splitByFiles(heuristicPrompt, numAgents);
910
+ const heuristicsFile = /* @__PURE__ */ new Set([
911
+ fileSplit.strategy === "focus-based" ? "focus-areas" : "file-based",
912
+ "work-unit-detection"
913
+ ]);
914
+ const fileSplitTasks = [...fileSplit.subTasks, ...fileSplit.pendingSubTasks.flat()];
915
+ const hasModuleInference = fileSplitTasks.some(
916
+ (task) => task.files.some((file) => !/\.[a-z0-9]+$/i.test(file))
917
+ );
918
+ if (hasModuleInference) {
919
+ heuristicsFile.add("module-inference");
920
+ }
921
+ const totalFileTasks = this.countTotalSubTasks(fileSplit);
922
+ if (totalFileTasks > 1) {
923
+ debugLog("[TaskSplitter] Strategy:", fileSplit.strategy);
924
+ debugLog("[TaskSplitter] Generated sub-tasks:");
925
+ fileSplit.subTasks.forEach((st, i) => {
926
+ debugLog(` ${i + 1}. "${st.description}"`);
927
+ debugLog(` Files: ${st.files.join(", ") || "none"}`);
928
+ });
929
+ if (fileSplit.pendingSubTasks.length > 0) {
930
+ const pendingCount = totalFileTasks - fileSplit.subTasks.length;
931
+ debugLog(
932
+ ` Pending batches: ${fileSplit.pendingSubTasks.length} (${pendingCount} additional task(s))`
933
+ );
934
+ }
935
+ const validSubTasks = fileSplit.subTasks.filter((st) => this.validateSubTask(st));
936
+ if (validSubTasks.length < fileSplit.subTasks.length) {
937
+ console.warn(
938
+ `[Task Splitter] Validation: ${validSubTasks.length}/${fileSplit.subTasks.length} valid sub-tasks`
939
+ );
940
+ debugLog(
941
+ "[DEBUG] Failed sub-tasks:",
942
+ fileSplit.subTasks.filter((st) => !this.validateSubTask(st))
943
+ );
944
+ }
945
+ if (validSubTasks.length === 0) {
946
+ console.warn(
947
+ "[Task Splitter] All file-based sub-tasks failed validation, falling back to single task"
948
+ );
949
+ debugLog("[DEBUG] Attempted file split:", fileSplit);
950
+ const fallbackHeuristics = /* @__PURE__ */ new Set([...heuristicsFile, "fallback-single"]);
951
+ const single = this.createSingleTask(
952
+ prompt,
953
+ "Generated sub-tasks failed validation, falling back to single task"
954
+ );
955
+ single.subTasks = attachMetadata(single.subTasks, fallbackHeuristics, single.strategy);
956
+ single.tokenAnalysis = tokenAnalysis;
957
+ if (routingOptions.enableRouting) {
958
+ single.routingDecisions = await this.generateRoutingDecisions(
959
+ single.subTasks,
960
+ domainAnalysis,
961
+ routingOptions
962
+ );
963
+ }
964
+ this.validateCompleteExecution(single);
965
+ return await this.finalizeSplitResult(single, prompt, numAgents, splitOptions);
966
+ }
967
+ const result2 = {
968
+ ...fileSplit,
969
+ subTasks: attachMetadata(validSubTasks, heuristicsFile, fileSplit.strategy),
970
+ tokenAnalysis
971
+ // Include token analysis if available
972
+ };
973
+ if (routingOptions.enableRouting) {
974
+ result2.routingDecisions = await this.generateRoutingDecisions(
975
+ result2.subTasks,
976
+ domainAnalysis,
977
+ routingOptions
978
+ );
979
+ }
980
+ if (splitOptions?.mode === "sequential") {
981
+ const batchedResult = this.applySequentialBatching(result2, numAgents);
982
+ this.validateCompleteExecution(batchedResult);
983
+ return await this.finalizeSplitResult(batchedResult, prompt, numAgents, splitOptions);
984
+ }
985
+ this.validateCompleteExecution(result2);
986
+ return await this.finalizeSplitResult(result2, prompt, numAgents, splitOptions);
987
+ }
988
+ const featureSplit = this.splitByFeatures(heuristicPrompt, numAgents);
989
+ const heuristicsFeature = /* @__PURE__ */ new Set(["feature-based"]);
990
+ const totalFeatureTasks = this.countTotalSubTasks(featureSplit);
991
+ if (totalFeatureTasks > 1) {
992
+ debugLog("[TaskSplitter] Strategy:", featureSplit.strategy);
993
+ debugLog("[TaskSplitter] Generated sub-tasks:");
994
+ featureSplit.subTasks.forEach((st, i) => {
995
+ debugLog(` ${i + 1}. "${st.description}"`);
996
+ });
997
+ if (featureSplit.pendingSubTasks.length > 0) {
998
+ const pendingCount = totalFeatureTasks - featureSplit.subTasks.length;
999
+ debugLog(
1000
+ ` Pending batches: ${featureSplit.pendingSubTasks.length} (${pendingCount} additional task(s))`
1001
+ );
1002
+ }
1003
+ const validSubTasks = featureSplit.subTasks.filter((st) => this.validateSubTask(st));
1004
+ if (validSubTasks.length < featureSplit.subTasks.length) {
1005
+ console.warn(
1006
+ `[Task Splitter] Validation: ${validSubTasks.length}/${featureSplit.subTasks.length} valid sub-tasks`
1007
+ );
1008
+ debugLog(
1009
+ "[DEBUG] Failed sub-tasks:",
1010
+ featureSplit.subTasks.filter((st) => !this.validateSubTask(st))
1011
+ );
1012
+ }
1013
+ if (validSubTasks.length === 0) {
1014
+ console.warn(
1015
+ "[Task Splitter] All feature-based sub-tasks failed validation, falling back to single task"
1016
+ );
1017
+ debugLog("[DEBUG] Attempted feature split:", featureSplit);
1018
+ const fallbackHeuristics = /* @__PURE__ */ new Set([...heuristicsFeature, "fallback-single"]);
1019
+ const single = this.createSingleTask(
1020
+ prompt,
1021
+ "Generated sub-tasks failed validation, falling back to single task"
1022
+ );
1023
+ single.subTasks = attachMetadata(single.subTasks, fallbackHeuristics, single.strategy);
1024
+ single.tokenAnalysis = tokenAnalysis;
1025
+ if (routingOptions.enableRouting) {
1026
+ single.routingDecisions = await this.generateRoutingDecisions(
1027
+ single.subTasks,
1028
+ domainAnalysis,
1029
+ routingOptions
1030
+ );
1031
+ }
1032
+ this.validateCompleteExecution(single);
1033
+ return await this.finalizeSplitResult(single, prompt, numAgents, splitOptions);
1034
+ }
1035
+ const result2 = {
1036
+ ...featureSplit,
1037
+ subTasks: attachMetadata(validSubTasks, heuristicsFeature, featureSplit.strategy),
1038
+ tokenAnalysis
1039
+ // Include token analysis if available
1040
+ };
1041
+ if (routingOptions.enableRouting) {
1042
+ result2.routingDecisions = await this.generateRoutingDecisions(
1043
+ result2.subTasks,
1044
+ domainAnalysis,
1045
+ routingOptions
1046
+ );
1047
+ }
1048
+ if (splitOptions?.mode === "sequential") {
1049
+ const batchedResult = this.applySequentialBatching(result2, numAgents);
1050
+ this.validateCompleteExecution(batchedResult);
1051
+ return await this.finalizeSplitResult(batchedResult, prompt, numAgents, splitOptions);
1052
+ }
1053
+ this.validateCompleteExecution(result2);
1054
+ return await this.finalizeSplitResult(result2, prompt, numAgents, splitOptions);
1055
+ }
1056
+ debugLog("[TaskSplitter] No splitting strategy applicable, returning single task");
1057
+ const heuristics = /* @__PURE__ */ new Set(["single-fallback"]);
1058
+ const result = this.createSingleTask(
1059
+ prompt,
1060
+ "Task cannot be split - too atomic or no clear work units"
1061
+ );
1062
+ result.subTasks = attachMetadata(result.subTasks, heuristics, result.strategy);
1063
+ result.tokenAnalysis = tokenAnalysis;
1064
+ if (routingOptions.enableRouting) {
1065
+ result.routingDecisions = await this.generateRoutingDecisions(
1066
+ result.subTasks,
1067
+ domainAnalysis,
1068
+ routingOptions
1069
+ );
1070
+ }
1071
+ this.validateCompleteExecution(result);
1072
+ return await this.finalizeSplitResult(result, prompt, numAgents, splitOptions);
1073
+ }
1074
+ /**
1075
+ * Split task by files mentioned in prompt
1076
+ *
1077
+ * Example:
1078
+ * "Generate tests for auth.ts, config.ts, metadata.ts"
1079
+ * → 3 sub-tasks, one per file
1080
+ */
1081
+ splitByFiles(prompt, maxAgents) {
1082
+ const focusPattern = /\bfocus(?:ing)?\s+on\s+(?:testing\s+)?(.+)/i;
1083
+ const focusMatch = prompt.match(focusPattern);
1084
+ if (focusMatch) {
1085
+ const focusText = focusMatch[1] || "";
1086
+ const focusAreas = this.extractFocusAreas(focusText);
1087
+ if (focusAreas.length > 1) {
1088
+ const context2 = this.buildContextFromFocus(prompt, focusText || "");
1089
+ return this.createFocusBasedSubTasks(context2, focusAreas, maxAgents);
1090
+ }
1091
+ }
1092
+ const fileRegex = /([a-zA-Z0-9_\-/]+\.(?:ts|js|tsx|jsx|py|java|go|rs|cpp|c|h))\b/g;
1093
+ const matches = [...prompt.matchAll(fileRegex)];
1094
+ const files = matches.map((m) => m[1]?.trim() || "");
1095
+ let modules = [];
1096
+ let moduleCountWasCapped = false;
1097
+ const hasColonPattern = /^(.+?):\s*(.+)$/.test(prompt);
1098
+ if (!hasColonPattern) {
1099
+ modules = this.extractExplicitModuleList(prompt);
1100
+ if (files.length > 0) {
1101
+ modules = [...modules, ...this.extractInlineModulesWhenFilesPresent(prompt)];
1102
+ } else if (modules.length === 0) {
1103
+ modules = this.extractInstructionPrefixedModuleList(prompt);
1104
+ }
1105
+ modules = modules.filter((moduleName) => {
1106
+ return !files.some((f) => f.startsWith(`${moduleName}.`));
1107
+ });
1108
+ }
1109
+ if (files.length === 0 && modules.length > maxAgents * 2) {
1110
+ moduleCountWasCapped = true;
1111
+ console.warn(
1112
+ `[Task Splitter] Suspicious module detection: ${modules.length} modules for ${maxAgents} agents. Capping to ${maxAgents * 2}.`
1113
+ );
1114
+ modules = modules.slice(0, maxAgents * 2);
1115
+ }
1116
+ const allWorkUnits = [...files, ...modules].filter((v, i, a) => a.indexOf(v) === i);
1117
+ if (allWorkUnits.length === 0) {
1118
+ return {
1119
+ subTasks: [],
1120
+ pendingSubTasks: [],
1121
+ strategy: "file-based",
1122
+ reasoning: "No files or modules found in prompt"
1123
+ };
1124
+ }
1125
+ const moduleSet = new Set(modules);
1126
+ const fullPrompt = prompt.trim();
1127
+ const context = this.extractContext(prompt, allWorkUnits);
1128
+ const { firstBatch, pendingBatches } = this.buildBatchedSubTasks(
1129
+ allWorkUnits,
1130
+ maxAgents,
1131
+ (unit, id) => ({
1132
+ id,
1133
+ description: moduleSet.has(unit) ? fullPrompt ? `${fullPrompt} Focus specifically on ${unit}.` : unit : context ? `${context} for ${unit}` : unit,
1134
+ files: [unit],
1135
+ context: moduleSet.has(unit) ? fullPrompt : context,
1136
+ dependencies: []
1137
+ })
1138
+ );
1139
+ const sanitized = this.sanitizeBatches(firstBatch, pendingBatches);
1140
+ const baseReasoning = allWorkUnits.length < maxAgents ? `Found ${allWorkUnits.length} file(s)/module(s) in prompt; requested ${maxAgents} agents but only ${allWorkUnits.length} work unit(s) were detected` : `Found ${allWorkUnits.length} file(s)/module(s) in prompt`;
1141
+ const reasoning = moduleCountWasCapped ? `${baseReasoning} (module detection capped at ${maxAgents * 2} to avoid over-splitting)` : baseReasoning;
1142
+ const result = {
1143
+ subTasks: sanitized.subTasks,
1144
+ pendingSubTasks: sanitized.pendingSubTasks,
1145
+ strategy: "file-based",
1146
+ reasoning
1147
+ };
1148
+ return result;
1149
+ }
1150
+ extractExplicitModuleList(prompt) {
1151
+ const modules = /* @__PURE__ */ new Set();
1152
+ const addFromList = (listText) => {
1153
+ const parsed = this.parseModuleListCandidate(listText);
1154
+ if (!parsed) return;
1155
+ for (const item of parsed) {
1156
+ modules.add(item);
1157
+ }
1158
+ };
1159
+ const labeledListPattern = /\b(?:modules?|files?)\s*:\s*([^\n]+)/gi;
1160
+ for (const match of prompt.matchAll(labeledListPattern)) {
1161
+ addFromList(match[1] || "");
1162
+ }
1163
+ const scopedListPattern = /\b(?:for|in|on|across|within)\s+((?:[a-z][a-z0-9_-]{2,}\s*,\s*)+[a-z][a-z0-9_-]{2,}(?:\s*,?\s*and\s+[a-z][a-z0-9_-]{2,})?)(?=\s*(?:$|[.;:!?]))/gi;
1164
+ for (const match of prompt.matchAll(scopedListPattern)) {
1165
+ addFromList(match[1] || "");
1166
+ }
1167
+ const trimmed = prompt.trim();
1168
+ const standaloneListPattern = /^(?:[a-z][a-z0-9_-]{2,}\s*,\s*)+[a-z][a-z0-9_-]{2,}(?:\s*,?\s*and\s+[a-z][a-z0-9_-]{2,})?$/i;
1169
+ if (standaloneListPattern.test(trimmed)) {
1170
+ addFromList(trimmed);
1171
+ }
1172
+ return [...modules];
1173
+ }
1174
+ extractInlineModulesWhenFilesPresent(prompt) {
1175
+ if (!prompt.includes(",")) return [];
1176
+ const modules = /* @__PURE__ */ new Set();
1177
+ const parts = prompt.split(/\s*,\s*/).map((part) => part.trim());
1178
+ for (const part of parts) {
1179
+ const normalized = part.replace(/^[`"'([{]+|[`"')\]}.!?:;]+$/g, "").trim();
1180
+ if (/^[a-z][a-z0-9_-]{2,}$/i.test(normalized)) {
1181
+ modules.add(normalized);
1182
+ }
1183
+ }
1184
+ return [...modules];
1185
+ }
1186
+ extractInstructionPrefixedModuleList(prompt) {
1187
+ if (!prompt.includes(",")) return [];
1188
+ const parts = prompt.split(/\s*,\s*/).map((part) => part.replace(/^[`"'([{]+|[`"')\]}.!?:;]+$/g, "").trim()).filter((part) => part.length > 0);
1189
+ if (parts.length < 2) return [];
1190
+ const allowedLeadVerbs = /* @__PURE__ */ new Set([
1191
+ "test",
1192
+ "generate",
1193
+ "create",
1194
+ "update",
1195
+ "refactor",
1196
+ "review",
1197
+ "analyze",
1198
+ "audit",
1199
+ "fix",
1200
+ "implement",
1201
+ "add",
1202
+ "write",
1203
+ "check",
1204
+ "validate",
1205
+ "verify",
1206
+ "improve",
1207
+ "optimize"
1208
+ ]);
1209
+ const firstMatch = parts[0]?.match(/^([a-z]+)\s+([a-z][a-z0-9_-]{2,})$/i);
1210
+ if (!firstMatch || !allowedLeadVerbs.has(firstMatch[1]?.toLowerCase() || "")) {
1211
+ return [];
1212
+ }
1213
+ const modules = [firstMatch[2] || ""];
1214
+ for (const part of parts.slice(1)) {
1215
+ const normalized = part.replace(/^and\s+/i, "").trim();
1216
+ if (!/^[a-z][a-z0-9_-]{2,}$/i.test(normalized)) {
1217
+ return [];
1218
+ }
1219
+ modules.push(normalized);
1220
+ }
1221
+ return modules.filter((moduleName) => moduleName.length > 0);
1222
+ }
1223
+ parseModuleListCandidate(listText) {
1224
+ const normalized = listText.replace(/\s*,\s*and\s+/gi, ", ").replace(/\s+and\s+/gi, ", ").trim();
1225
+ if (!normalized.includes(",")) return null;
1226
+ const parts = normalized.split(/\s*,\s*/).map((part) => part.replace(/^[`"'([{]+|[`"')\]}.!?:;]+$/g, "").trim()).filter((part) => part.length > 0);
1227
+ if (parts.length < 2) return null;
1228
+ if (!parts.every((part) => /^[a-z][a-z0-9_-]{2,}$/i.test(part))) {
1229
+ return null;
1230
+ }
1231
+ return parts;
1232
+ }
1233
+ /**
1234
+ * Split task by features/functionality
1235
+ *
1236
+ * Example:
1237
+ * "Implement authentication: login, signup, password reset, session management"
1238
+ * → 4 sub-tasks
1239
+ */
1240
+ splitByFeatures(prompt, maxAgents) {
1241
+ const separatorIndex = this.findFeatureListSeparator(prompt);
1242
+ if (separatorIndex >= 0) {
1243
+ const baseTask = prompt.slice(0, separatorIndex).trim();
1244
+ const featureList = prompt.slice(separatorIndex + 1);
1245
+ const features = this.parseBoundedFeatureList(featureList);
1246
+ if (baseTask && features.length > 1) {
1247
+ const { firstBatch, pendingBatches } = this.buildBatchedSubTasks(
1248
+ features,
1249
+ maxAgents,
1250
+ (feature, id) => ({
1251
+ id,
1252
+ description: `${baseTask}: ${feature}`,
1253
+ files: [],
1254
+ context: baseTask,
1255
+ dependencies: []
1256
+ })
1257
+ );
1258
+ const sanitized = this.sanitizeBatches(firstBatch, pendingBatches);
1259
+ const result = {
1260
+ subTasks: sanitized.subTasks,
1261
+ pendingSubTasks: sanitized.pendingSubTasks,
1262
+ strategy: "feature-based",
1263
+ reasoning: features.length < maxAgents ? `Found ${features.length} feature(s) in colon-separated list; requested ${maxAgents} agents but only ${features.length} work unit(s) were detected` : `Found ${features.length} feature(s) in colon-separated list`
1264
+ };
1265
+ return result;
1266
+ }
1267
+ }
1268
+ return {
1269
+ subTasks: [],
1270
+ pendingSubTasks: [],
1271
+ strategy: "feature-based",
1272
+ reasoning: "No clear feature list found"
1273
+ };
1274
+ }
1275
+ findFeatureListSeparator(prompt) {
1276
+ let parenDepth = 0;
1277
+ let bracketDepth = 0;
1278
+ let braceDepth = 0;
1279
+ for (let i = 0; i < prompt.length; i += 1) {
1280
+ const char = prompt[i];
1281
+ if (char === "(") parenDepth += 1;
1282
+ else if (char === ")" && parenDepth > 0) parenDepth -= 1;
1283
+ else if (char === "[") bracketDepth += 1;
1284
+ else if (char === "]" && bracketDepth > 0) bracketDepth -= 1;
1285
+ else if (char === "{") braceDepth += 1;
1286
+ else if (char === "}" && braceDepth > 0) braceDepth -= 1;
1287
+ else if (char === ":" && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
1288
+ return i;
1289
+ }
1290
+ }
1291
+ return -1;
1292
+ }
1293
+ parseBoundedFeatureList(featureList) {
1294
+ const features = featureList.split(/\s*,\s*|\s+and\s+/i).map((feature) => feature.trim()).filter((feature) => feature.length > 0);
1295
+ if (features.length < 2) return [];
1296
+ if (!features.every((feature) => this.isBoundedFeatureItem(feature))) return [];
1297
+ return features;
1298
+ }
1299
+ isBoundedFeatureItem(feature) {
1300
+ const normalized = feature.replace(/^[`"'([{]+|[`"')\]}.!?:;]+$/g, "").trim();
1301
+ if (!normalized) return false;
1302
+ if (normalized.length > 56) return false;
1303
+ const words = normalized.split(/\s+/).filter((word) => word.length > 0);
1304
+ if (words.length > 6) return false;
1305
+ if (/[.!?;]/.test(normalized)) return false;
1306
+ if (!this.hasBalancedDelimiters(normalized)) return false;
1307
+ if (this.containsCodeLikeToken(normalized)) return false;
1308
+ const firstWord = words[0]?.toLowerCase() ?? "";
1309
+ const imperativeLeads = /* @__PURE__ */ new Set([
1310
+ "add",
1311
+ "assert",
1312
+ "capture",
1313
+ "check",
1314
+ "compute",
1315
+ "create",
1316
+ "do",
1317
+ "emit",
1318
+ "ensure",
1319
+ "fix",
1320
+ "implement",
1321
+ "keep",
1322
+ "raise",
1323
+ "return",
1324
+ "run",
1325
+ "update",
1326
+ "validate",
1327
+ "verify",
1328
+ "write"
1329
+ ]);
1330
+ if (imperativeLeads.has(firstWord)) return false;
1331
+ return /^[a-z0-9][a-z0-9_\- /]+$/i.test(normalized);
1332
+ }
1333
+ hasBalancedDelimiters(text) {
1334
+ const pairs = /* @__PURE__ */ new Map([
1335
+ [")", "("],
1336
+ ["]", "["],
1337
+ ["}", "{"]
1338
+ ]);
1339
+ const stack = [];
1340
+ for (const char of text) {
1341
+ if (char === "(" || char === "[" || char === "{") {
1342
+ stack.push(char);
1343
+ } else if (pairs.has(char)) {
1344
+ if (stack.pop() !== pairs.get(char)) return false;
1345
+ }
1346
+ }
1347
+ return stack.length === 0;
1348
+ }
1349
+ containsCodeLikeToken(text) {
1350
+ return /[`=<>]|->|::/.test(text) || /\b(?:cargo|npm|pnpm|yarn|python|pytest|unittest|go\s+test|make)\b/i.test(text);
1351
+ }
1352
+ /**
1353
+ * Extract shared context from prompt, removing file/module references
1354
+ *
1355
+ * Example:
1356
+ * Input: "Generate tests for auth.ts, config.ts, metadata.ts"
1357
+ * Output: "Generate tests"
1358
+ */
1359
+ extractContext(prompt, workUnits) {
1360
+ const normalizedPrompt = prompt.replace(/\s+/g, " ").trim();
1361
+ if (!normalizedPrompt) {
1362
+ return "";
1363
+ }
1364
+ const colonSplit = normalizedPrompt.match(/^(.+?):\s*(.+)$/);
1365
+ if (colonSplit) {
1366
+ const left = colonSplit[1]?.trim() ?? "";
1367
+ const right = colonSplit[2]?.toLowerCase() ?? "";
1368
+ const referencesKnownUnit = workUnits.some((unit) => right.includes(unit.toLowerCase()));
1369
+ if (left.length > 0 && referencesKnownUnit) {
1370
+ return left;
1371
+ }
1372
+ }
1373
+ let firstUnitIndex = Number.POSITIVE_INFINITY;
1374
+ for (const unit of workUnits) {
1375
+ const idx = normalizedPrompt.toLowerCase().indexOf(unit.toLowerCase());
1376
+ if (idx >= 0 && idx < firstUnitIndex) {
1377
+ firstUnitIndex = idx;
1378
+ }
1379
+ }
1380
+ if (Number.isFinite(firstUnitIndex) && firstUnitIndex > 0) {
1381
+ const candidate = normalizedPrompt.slice(0, firstUnitIndex);
1382
+ const cleaned = candidate.replace(/[,:;]\s*$/g, "").replace(/\b(?:for|in|on|across|within|and)\s*$/i, "").replace(/\s+/g, " ").trim();
1383
+ if (cleaned.length > 0) {
1384
+ return cleaned;
1385
+ }
1386
+ }
1387
+ const prepositionPrefix = normalizedPrompt.match(/^(.+?)\b(?:for|in|on|across|within)\b\s+/i);
1388
+ if (prepositionPrefix?.[1]) {
1389
+ const cleaned = prepositionPrefix[1].trim();
1390
+ if (cleaned.length > 0) {
1391
+ return cleaned;
1392
+ }
1393
+ }
1394
+ return normalizedPrompt;
1395
+ }
1396
+ buildBatchedSubTasks(workUnits, maxAgents, builder) {
1397
+ if (maxAgents <= 0 || workUnits.length === 0) {
1398
+ return { firstBatch: [], pendingBatches: [] };
1399
+ }
1400
+ const batches = [];
1401
+ let nextId = 1;
1402
+ for (let i = 0; i < workUnits.length; i += maxAgents) {
1403
+ const slice = workUnits.slice(i, i + maxAgents);
1404
+ if (slice.length === 0) {
1405
+ continue;
1406
+ }
1407
+ const batchIndex = batches.length;
1408
+ const batch = slice.map((unit) => builder(unit, nextId++, batchIndex));
1409
+ batches.push(batch);
1410
+ }
1411
+ const [firstBatch = [], ...pendingBatches] = batches;
1412
+ return { firstBatch, pendingBatches };
1413
+ }
1414
+ sanitizeBatches(firstBatch, pendingBatches) {
1415
+ const batches = [firstBatch, ...pendingBatches];
1416
+ const validBatches = [];
1417
+ for (const batch of batches) {
1418
+ const valid = batch.filter((task) => this.validateSubTask(task));
1419
+ if (valid.length > 0) {
1420
+ validBatches.push(valid);
1421
+ }
1422
+ }
1423
+ if (validBatches.length === 0) {
1424
+ return { subTasks: [], pendingSubTasks: [] };
1425
+ }
1426
+ let nextId = 1;
1427
+ const reindexed = validBatches.map(
1428
+ (batch) => batch.map((task) => ({
1429
+ ...task,
1430
+ id: nextId++
1431
+ }))
1432
+ );
1433
+ const [subTasks = [], ...pendingSubTasks] = reindexed;
1434
+ return { subTasks, pendingSubTasks };
1435
+ }
1436
+ countTotalSubTasks(result) {
1437
+ const pendingCount = result.pendingSubTasks.reduce((sum, batch) => sum + batch.length, 0);
1438
+ return result.subTasks.length + pendingCount;
1439
+ }
1440
+ /**
1441
+ * Extract focus areas from a focus clause
1442
+ *
1443
+ * Example:
1444
+ * "lock acquisition, release, timeout scenarios, and edge cases"
1445
+ * → ["lock acquisition", "release", "timeout scenarios", "edge cases"]
1446
+ */
1447
+ extractFocusAreas(focusText) {
1448
+ const areas = focusText.split(/,\s*(?:and\s+)?|\s+and\s+/i).map((a) => a.trim()).filter((a) => a.length > 0);
1449
+ return areas;
1450
+ }
1451
+ /**
1452
+ * Build context by removing focus clause from prompt
1453
+ *
1454
+ * Example:
1455
+ * Input: "Generate tests for X. Focus on A, B, C"
1456
+ * Output: "Generate tests for X"
1457
+ */
1458
+ buildContextFromFocus(prompt, _focusText) {
1459
+ const focusPattern = /\bfocus(?:ing)?\s+on\s+(?:testing\s+)?(.+)/i;
1460
+ const context = prompt.replace(focusPattern, "").trim();
1461
+ return context.replace(/[,.\s]+$/, "");
1462
+ }
1463
+ /**
1464
+ * Create sub-tasks from focus areas
1465
+ */
1466
+ createFocusBasedSubTasks(context, focusAreas, maxAgents) {
1467
+ const { firstBatch, pendingBatches } = this.buildBatchedSubTasks(
1468
+ focusAreas,
1469
+ maxAgents,
1470
+ (area, id) => ({
1471
+ id,
1472
+ description: `${context}. Focus on testing ${area}`,
1473
+ files: [],
1474
+ context,
1475
+ dependencies: []
1476
+ })
1477
+ );
1478
+ const sanitized = this.sanitizeBatches(firstBatch, pendingBatches);
1479
+ return {
1480
+ subTasks: sanitized.subTasks,
1481
+ pendingSubTasks: sanitized.pendingSubTasks,
1482
+ // Mark this strategy explicitly as focus-based so callers can
1483
+ // set appropriate heuristics (e.g., include 'focus-areas').
1484
+ strategy: "focus-based",
1485
+ reasoning: focusAreas.length < maxAgents ? `Found ${focusAreas.length} focus area(s) in prompt; requested ${maxAgents} agents but only ${focusAreas.length} work unit(s) were detected` : `Found ${focusAreas.length} focus area(s) in prompt`
1486
+ };
1487
+ }
1488
+ /**
1489
+ * Validate a sub-task for malformations
1490
+ *
1491
+ * Checks for common issues like:
1492
+ * - Mangled context (e.g., "in .", "for .")
1493
+ * - Trailing incomplete phrases
1494
+ * - Too short descriptions (but allow feature-based tasks like "Add: feature1")
1495
+ */
1496
+ validateSubTask(subTask) {
1497
+ const desc = subTask.description;
1498
+ const issues = [
1499
+ desc.includes(" . "),
1500
+ // Mangled context: "in ."
1501
+ desc.includes(" for ."),
1502
+ // Mangled target: "for ."
1503
+ desc.trim().endsWith(" for"),
1504
+ // Trailing "for"
1505
+ desc.trim().endsWith(" in"),
1506
+ // Trailing "in"
1507
+ desc.length < 5
1508
+ // Too short (relaxed from 10 to allow "Add: X")
1509
+ // Removed word count check - feature-based tasks like "Implement: login" are valid with 2 words
1510
+ ];
1511
+ const isValid = !issues.some((issue) => issue);
1512
+ if (!isValid) {
1513
+ console.warn("[Task Splitter] Invalid sub-task rejected:", desc);
1514
+ debugLog("[DEBUG] Validation failures:", {
1515
+ hasMangled: desc.includes(" . "),
1516
+ hasMangledTarget: desc.includes(" for ."),
1517
+ trailingFor: desc.trim().endsWith(" for"),
1518
+ trailingIn: desc.trim().endsWith(" in"),
1519
+ tooShort: desc.length < 5
1520
+ });
1521
+ }
1522
+ return isValid;
1523
+ }
1524
+ async finalizeSplitResult(result, prompt, numAgents, splitOptions) {
1525
+ this.emitSubTaskDedupTelemetry(result);
1526
+ await this.runLlmSplitterShadow(prompt, numAgents, result, splitOptions);
1527
+ return result;
1528
+ }
1529
+ getAllSubTasks(result) {
1530
+ return [...result.subTasks, ...result.pendingSubTasks.flat()];
1531
+ }
1532
+ tokenizeForSimilarity(text) {
1533
+ return new Set(
1534
+ text.toLowerCase().split(/[^a-z0-9]+/g).map((token) => token.trim()).filter((token) => token.length > 0)
1535
+ );
1536
+ }
1537
+ calculateJaccardSimilarity(a, b) {
1538
+ if (a.size === 0 && b.size === 0) return 1;
1539
+ if (a.size === 0 || b.size === 0) return 0;
1540
+ let intersection = 0;
1541
+ for (const token of a) {
1542
+ if (b.has(token)) {
1543
+ intersection += 1;
1544
+ }
1545
+ }
1546
+ const union = a.size + b.size - intersection;
1547
+ return union > 0 ? intersection / union : 0;
1548
+ }
1549
+ emitSubTaskDedupTelemetry(result) {
1550
+ const subTasks = this.getAllSubTasks(result);
1551
+ if (subTasks.length < 2) return;
1552
+ for (let i = 0; i < subTasks.length; i += 1) {
1553
+ const left = subTasks[i];
1554
+ if (!left) continue;
1555
+ const leftTokens = this.tokenizeForSimilarity(left.description);
1556
+ for (let j = i + 1; j < subTasks.length; j += 1) {
1557
+ const right = subTasks[j];
1558
+ if (!right) continue;
1559
+ const rightTokens = this.tokenizeForSimilarity(right.description);
1560
+ const similarity = this.calculateJaccardSimilarity(leftTokens, rightTokens);
1561
+ if (similarity > SUBTASK_DEDUP_THRESHOLD) {
1562
+ emitCustomWarning(
1563
+ "WARN" /* WARN */,
1564
+ "validation" /* VALIDATION */,
1565
+ "Task splitter detected potential duplicate subtasks",
1566
+ {
1567
+ subsystem: "orchestrator",
1568
+ executionPhase: "setup"
1569
+ },
1570
+ {
1571
+ metadata: {
1572
+ threshold: SUBTASK_DEDUP_THRESHOLD,
1573
+ similarity,
1574
+ pair: {
1575
+ left: {
1576
+ id: left.id,
1577
+ description: left.description,
1578
+ files: left.files
1579
+ },
1580
+ right: {
1581
+ id: right.id,
1582
+ description: right.description,
1583
+ files: right.files
1584
+ }
1585
+ }
1586
+ }
1587
+ }
1588
+ );
1589
+ }
1590
+ }
1591
+ }
1592
+ }
1593
+ shouldRunLlmShadow(splitOptions) {
1594
+ if (splitOptions?.llmShadow === true) return true;
1595
+ return readEnv(POETIC_SPLITTER_SHADOW).value ?? false;
1596
+ }
1597
+ createSplitterShadowPrompt(prompt, numAgents) {
1598
+ return `Split this task into up to ${numAgents} coding subtasks.
1599
+
1600
+ Task:
1601
+ ${prompt}
1602
+
1603
+ Return ONLY a pure JSON object (optional surrounding whitespace). No markdown fences, no prose.
1604
+ Schema:
1605
+ {
1606
+ "subtasks": [
1607
+ {
1608
+ "id": 1,
1609
+ "description": "string",
1610
+ "targetFiles": ["optional/path.ts"],
1611
+ "dependencies": [],
1612
+ "boundary": "short boundary note"
1613
+ }
1614
+ ]
1615
+ }
1616
+
1617
+ Rules:
1618
+ - ids must be unique positive integers.
1619
+ - dependencies lists prerequisite subtask ids that must complete first.
1620
+ - Ordered work MUST declare real dependency edges (dependents list prerequisite ids).
1621
+ - Keep subtasks distinct with non-overlapping targetFiles.
1622
+ - Focus on executable implementation work.
1623
+ - Do not include markdown or prose outside JSON.`;
1624
+ }
1625
+ /**
1626
+ * Strict JSON object parse: accept only a pure JSON object with optional
1627
+ * surrounding whitespace. Prose wrappers, markdown fences, and substring
1628
+ * extraction from mixed text are malformed.
1629
+ */
1630
+ parseStrictJsonObject(raw, context) {
1631
+ const trimmed = raw.trim();
1632
+ if (!trimmed) return null;
1633
+ if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
1634
+ return null;
1635
+ }
1636
+ try {
1637
+ const parsed = parseJsonWithContext(trimmed, context);
1638
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1639
+ return null;
1640
+ }
1641
+ return parsed;
1642
+ } catch {
1643
+ return null;
1644
+ }
1645
+ }
1646
+ parseSplitterShadowResult(raw) {
1647
+ const parsed = this.parseStrictJsonObject(raw, "TaskSplitter shadow split response");
1648
+ if (parsed === null) return null;
1649
+ const subtasksRaw = parsed.subtasks;
1650
+ if (!Array.isArray(subtasksRaw)) return null;
1651
+ const subtasks = [];
1652
+ for (const item of subtasksRaw) {
1653
+ if (typeof item !== "object" || item === null) return null;
1654
+ const record = item;
1655
+ if (typeof record.description !== "string" || record.description.trim().length === 0) {
1656
+ return null;
1657
+ }
1658
+ const targetFiles = Array.isArray(record.targetFiles) ? record.targetFiles.filter((entry) => typeof entry === "string") : void 0;
1659
+ let dependencies;
1660
+ if (Array.isArray(record.dependencies)) {
1661
+ const parsedDeps = [];
1662
+ for (const entry of record.dependencies) {
1663
+ if (typeof entry !== "number" || !Number.isInteger(entry)) {
1664
+ return null;
1665
+ }
1666
+ parsedDeps.push(entry);
1667
+ }
1668
+ dependencies = parsedDeps;
1669
+ }
1670
+ const id = typeof record.id === "number" && Number.isInteger(record.id) ? record.id : void 0;
1671
+ subtasks.push({
1672
+ id,
1673
+ description: record.description.trim(),
1674
+ targetFiles,
1675
+ dependencies,
1676
+ boundary: typeof record.boundary === "string" ? record.boundary : void 0
1677
+ });
1678
+ }
1679
+ return { subtasks };
1680
+ }
1681
+ /**
1682
+ * Detect cross-file renames, shared contracts, and other coupling invariants.
1683
+ * Scans the full stripped prompt — no fixed 8K truncation window.
1684
+ */
1685
+ analyzeCouplingSignals(prompt) {
1686
+ const signals = [];
1687
+ const text = prompt;
1688
+ const filePaths = this.extractFilePathTokens(text);
1689
+ const renamePatterns = [
1690
+ { name: "rename-to", pattern: /\brename\s+(?:file\s+)?(\S+)\s+to\s+(\S+)/i },
1691
+ { name: "rename-arrow", pattern: /\brename\s+(\S+)\s*->\s*(\S+)/i },
1692
+ { name: "move-to", pattern: /\b(?:move|mv)\s+(\S+\.\w+)\s+to\s+(\S+)/i },
1693
+ {
1694
+ name: "from-to-paths",
1695
+ pattern: /\bfrom\s+[`'"]?([^\s`'"]+\.[a-zA-Z0-9]+)[`'"]?\s+to\s+[`'"]?([^\s`'"]+\.[a-zA-Z0-9]+)/i
1696
+ },
1697
+ {
1698
+ name: "rename-from-to",
1699
+ pattern: /\brename\s+from\s+(\S+)\s+to\s+(\S+)/i
1700
+ }
1701
+ ];
1702
+ for (const { name, pattern } of renamePatterns) {
1703
+ if (pattern.test(text)) {
1704
+ signals.push(name);
1705
+ }
1706
+ }
1707
+ if (/\bshared\s+(?:types?|contracts?|interfaces?|schemas?|models?)\b/i.test(text) || /\bshar(?:e|es|ed)\b[\s\S]{0,48}\b(?:types?|contracts?|interfaces?|schemas?|models?)\b/i.test(
1708
+ text
1709
+ )) {
1710
+ signals.push("shared-types");
1711
+ }
1712
+ if (/\b(?:type|interface|contract|schema)\b[\s\S]{0,80}\b(?:shared|across|between)\b/i.test(text)) {
1713
+ signals.push("shared-contract-span");
1714
+ }
1715
+ if (/\bcross[- ]file\b/i.test(text)) {
1716
+ signals.push("cross-file");
1717
+ }
1718
+ if (/\b(?:across|between)\s+(?:all\s+)?(?:the\s+)?(?:files|modules)\b/i.test(text)) {
1719
+ signals.push("across-files");
1720
+ }
1721
+ if (/\bkeep\b[\s\S]{0,80}\bin\s+sync\b/i.test(text)) {
1722
+ signals.push("keep-in-sync");
1723
+ }
1724
+ if (/\bmust\s+(?:agree|match|stay\s+consistent)\b/i.test(text)) {
1725
+ signals.push("must-agree");
1726
+ }
1727
+ if (/\b(?:api|endpoint)(?:\s+and\s+|\s*\+\s*)(?:impl(?:ementation)?|handler|service)\b/i.test(
1728
+ text
1729
+ ) || /\bimplementation\s+and\s+(?:the\s+)?(?:api|interface|contract)\b/i.test(text)) {
1730
+ signals.push("api-impl-pair");
1731
+ }
1732
+ if (/\bupdate\s+all\s+(?:call\s*sites?|references|imports|usages)\b/i.test(text)) {
1733
+ signals.push("update-all-references");
1734
+ }
1735
+ if (/\bbreaking\s+change\b/i.test(text)) {
1736
+ signals.push("breaking-change");
1737
+ }
1738
+ if (filePaths.length > 1 && /\b(?:depends?\s+on|prerequisite|must\s+(?:happen|run|complete)\s+(?:before|after))\b/i.test(
1739
+ text
1740
+ )) {
1741
+ signals.push("ordered-dependency");
1742
+ }
1743
+ if (filePaths.length > 1 && /\b(?:invariant|consistency|atomic(?:ally)?)\b/i.test(text)) {
1744
+ signals.push("cross-file-invariant");
1745
+ }
1746
+ return {
1747
+ coupled: signals.length > 0,
1748
+ signals: [...new Set(signals)],
1749
+ filePaths
1750
+ };
1751
+ }
1752
+ extractFilePathTokens(prompt) {
1753
+ const matches = prompt.match(FILE_PATH_TOKEN_REGEX) ?? [];
1754
+ const unique = [];
1755
+ const seen = /* @__PURE__ */ new Set();
1756
+ for (const match of matches) {
1757
+ const canonical = this.canonicalizeOwnedPath(match);
1758
+ if (!canonical || seen.has(canonical)) continue;
1759
+ seen.add(canonical);
1760
+ unique.push(canonical);
1761
+ }
1762
+ return unique;
1763
+ }
1764
+ /**
1765
+ * Independent mechanical multi-file lists (e.g. "generate tests for a.ts, b.ts")
1766
+ * may still use lexical file-based splitting.
1767
+ */
1768
+ hasIndependentMechanicalFileList(prompt) {
1769
+ const files = this.extractFilePathTokens(prompt);
1770
+ if (files.length > 1) return true;
1771
+ const modules = this.extractExplicitModuleList(prompt);
1772
+ if (modules.length > 1) return true;
1773
+ const instructionModules = this.extractInstructionPrefixedModuleList(prompt);
1774
+ return instructionModules.length > 1;
1775
+ }
1776
+ /**
1777
+ * Canonicalize a path for ownership comparison.
1778
+ * Rejects workspace escapes, absolute paths, and ambiguous Windows drive-relative forms.
1779
+ * Treats `./a.ts` and `a.ts` as the same ownership key.
1780
+ */
1781
+ canonicalizeOwnedPath(filePath) {
1782
+ const raw = filePath.trim();
1783
+ if (!raw || raw.includes("\0")) return null;
1784
+ if (raw.startsWith("\\\\") || raw.startsWith("//")) return null;
1785
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(raw)) return null;
1786
+ if (raw.startsWith("/")) return null;
1787
+ if (/^[a-zA-Z]:[\\/]/.test(raw)) return null;
1788
+ if (/^[a-zA-Z]:[^\\/]/.test(raw)) return null;
1789
+ const normalized = raw.replace(/\\/g, "/");
1790
+ const segments = normalized.split("/");
1791
+ const stack = [];
1792
+ for (const segment of segments) {
1793
+ if (segment === "" || segment === ".") continue;
1794
+ if (segment === "..") {
1795
+ if (stack.length === 0) return null;
1796
+ stack.pop();
1797
+ continue;
1798
+ }
1799
+ stack.push(segment);
1800
+ }
1801
+ if (stack.length === 0) return null;
1802
+ return stack.join("/");
1803
+ }
1804
+ validateSemanticSplitGraph(subTasks) {
1805
+ if (subTasks.length === 0) {
1806
+ return { valid: false, reason: "empty-subtasks" };
1807
+ }
1808
+ const ids = /* @__PURE__ */ new Set();
1809
+ for (const task of subTasks) {
1810
+ if (!Number.isInteger(task.id) || task.id <= 0) {
1811
+ return { valid: false, reason: `invalid-id:${task.id}` };
1812
+ }
1813
+ if (ids.has(task.id)) {
1814
+ return { valid: false, reason: `duplicate-id:${task.id}` };
1815
+ }
1816
+ ids.add(task.id);
1817
+ }
1818
+ for (const task of subTasks) {
1819
+ for (const depId of task.dependencies) {
1820
+ if (!Number.isInteger(depId) || depId <= 0) {
1821
+ return { valid: false, reason: `invalid-dependency:${task.id}->${depId}` };
1822
+ }
1823
+ if (!ids.has(depId)) {
1824
+ return { valid: false, reason: `missing-dependency:${task.id}->${depId}` };
1825
+ }
1826
+ if (depId === task.id) {
1827
+ return { valid: false, reason: `self-dependency:${task.id}` };
1828
+ }
1829
+ }
1830
+ }
1831
+ const adjacency = /* @__PURE__ */ new Map();
1832
+ for (const task of subTasks) {
1833
+ adjacency.set(task.id, [...task.dependencies]);
1834
+ }
1835
+ const WHITE = 0;
1836
+ const GRAY = 1;
1837
+ const BLACK = 2;
1838
+ const color = /* @__PURE__ */ new Map();
1839
+ for (const id of ids) color.set(id, WHITE);
1840
+ const hasCycle = (node) => {
1841
+ color.set(node, GRAY);
1842
+ for (const dep of adjacency.get(node) ?? []) {
1843
+ const depColor = color.get(dep) ?? WHITE;
1844
+ if (depColor === GRAY) return true;
1845
+ if (depColor === WHITE && hasCycle(dep)) return true;
1846
+ }
1847
+ color.set(node, BLACK);
1848
+ return false;
1849
+ };
1850
+ for (const id of ids) {
1851
+ if ((color.get(id) ?? WHITE) === WHITE && hasCycle(id)) {
1852
+ return { valid: false, reason: "cyclic-dependencies" };
1853
+ }
1854
+ }
1855
+ const ownership = /* @__PURE__ */ new Map();
1856
+ for (const task of subTasks) {
1857
+ for (const file of task.files) {
1858
+ const canonical = this.canonicalizeOwnedPath(file);
1859
+ if (canonical === null) {
1860
+ return { valid: false, reason: `unsafe-path:${file}` };
1861
+ }
1862
+ const owner = ownership.get(canonical);
1863
+ if (owner !== void 0 && owner !== task.id) {
1864
+ return {
1865
+ valid: false,
1866
+ reason: `overlapping-ownership:${canonical}:${owner},${task.id}`
1867
+ };
1868
+ }
1869
+ ownership.set(canonical, task.id);
1870
+ }
1871
+ }
1872
+ return { valid: true };
1873
+ }
1874
+ materializeSemanticSubTasks(parsed, originalPrompt) {
1875
+ if (parsed.subtasks.length === 0) return null;
1876
+ const hasExplicitIds = parsed.subtasks.every(
1877
+ (task) => typeof task.id === "number" && Number.isInteger(task.id)
1878
+ );
1879
+ const subTasks = parsed.subtasks.map((task, index) => {
1880
+ const id = hasExplicitIds ? task.id : index + 1;
1881
+ const files = (task.targetFiles ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
1882
+ return {
1883
+ id,
1884
+ description: task.description,
1885
+ files,
1886
+ context: task.boundary ?? originalPrompt,
1887
+ dependencies: Array.isArray(task.dependencies) ? [...task.dependencies] : []
1888
+ };
1889
+ });
1890
+ if (!hasExplicitIds) {
1891
+ for (const task of subTasks) {
1892
+ if (task.dependencies.length > 0) {
1893
+ return null;
1894
+ }
1895
+ }
1896
+ }
1897
+ const validation = this.validateSemanticSplitGraph(subTasks);
1898
+ if (!validation.valid) {
1899
+ debugLog(`[TaskSplitter] Semantic split graph rejected: ${validation.reason}`);
1900
+ return null;
1901
+ }
1902
+ return subTasks;
1903
+ }
1904
+ async tryProviderSemanticSplit(heuristicPrompt, originalPrompt, numAgents, coupling, tokenAnalysis) {
1905
+ try {
1906
+ const model = resolveSplitterModel(void 0, process.cwd()).value;
1907
+ const providerPrompt = heuristicPrompt.length > 0 ? heuristicPrompt : originalPrompt;
1908
+ const raw = await this.splitterShadowRunner({
1909
+ prompt: providerPrompt,
1910
+ numAgents,
1911
+ model
1912
+ });
1913
+ const parsed = this.parseSplitterShadowResult(raw);
1914
+ if (!parsed || parsed.subtasks.length === 0) {
1915
+ debugLog("[TaskSplitter] Provider semantic split returned malformed/empty JSON");
1916
+ return null;
1917
+ }
1918
+ const subTasks = this.materializeSemanticSubTasks(parsed, originalPrompt);
1919
+ if (!subTasks || subTasks.length === 0) {
1920
+ return null;
1921
+ }
1922
+ const hasDeps = subTasks.some((task) => task.dependencies.length > 0);
1923
+ if (hasDeps || subTasks.length <= numAgents) {
1924
+ return {
1925
+ subTasks,
1926
+ pendingSubTasks: [],
1927
+ strategy: "semantic",
1928
+ reasoning: hasDeps ? `Provider semantic split produced ${subTasks.length} sub-tasks with dependency edges (signals: ${coupling.signals.join(", ")})` : `Provider semantic split produced ${subTasks.length} sub-tasks with validated ownership (signals: ${coupling.signals.join(", ")})`,
1929
+ tokenAnalysis
1930
+ };
1931
+ }
1932
+ const firstBatch = subTasks.slice(0, numAgents);
1933
+ const remainder = subTasks.slice(numAgents);
1934
+ const pendingSubTasks = [];
1935
+ for (let i = 0; i < remainder.length; i += numAgents) {
1936
+ pendingSubTasks.push(remainder.slice(i, i + numAgents));
1937
+ }
1938
+ return {
1939
+ subTasks: firstBatch,
1940
+ pendingSubTasks,
1941
+ strategy: "semantic",
1942
+ reasoning: `Provider semantic split produced ${subTasks.length} sub-tasks (signals: ${coupling.signals.join(", ")})`,
1943
+ tokenAnalysis
1944
+ };
1945
+ } catch (error) {
1946
+ debugLog(
1947
+ `[TaskSplitter] Provider semantic split failed: ${error instanceof Error ? error.message : String(error)}`
1948
+ );
1949
+ return null;
1950
+ }
1951
+ }
1952
+ defaultSplitterShadowRunner = async (input) => {
1953
+ const { registry } = await import("./registry-YODFY77A.js");
1954
+ const provider = resolveDefaultProvider(void 0, process.cwd()).value;
1955
+ const engine = registry.get(provider);
1956
+ if (!engine) {
1957
+ throw new Error(`Provider "${provider}" not found for splitter shadow mode`);
1958
+ }
1959
+ let timeoutHandle;
1960
+ const result = await Promise.race([
1961
+ engine.run({
1962
+ prompt: this.createSplitterShadowPrompt(input.prompt, input.numAgents),
1963
+ workingDir: process.cwd(),
1964
+ model: input.model,
1965
+ profile: "default",
1966
+ // Shadow splitting only parses stdout. This calls engine.run directly,
1967
+ // so it does not inherit runProviderNative's read-only derivation.
1968
+ executionIntent: "analysis",
1969
+ readOnlyWorkingDir: true
1970
+ }),
1971
+ new Promise((_, reject) => {
1972
+ timeoutHandle = setTimeout(() => {
1973
+ reject(new Error(`Splitter shadow timed out after ${SPLITTER_SHADOW_TIMEOUT_MS}ms`));
1974
+ }, SPLITTER_SHADOW_TIMEOUT_MS);
1975
+ })
1976
+ ]).finally(() => {
1977
+ if (timeoutHandle) {
1978
+ clearTimeout(timeoutHandle);
1979
+ }
1980
+ });
1981
+ if (result.exitCode !== 0) {
1982
+ throw new Error(result.stderr || "Splitter shadow provider call failed");
1983
+ }
1984
+ return result.stdout || "";
1985
+ };
1986
+ async runLlmSplitterShadow(prompt, numAgents, heuristicResult, splitOptions) {
1987
+ if (!this.shouldRunLlmShadow(splitOptions)) {
1988
+ return;
1989
+ }
1990
+ let parsedShadow = null;
1991
+ let model = "auto";
1992
+ let errorMessage;
1993
+ try {
1994
+ model = resolveSplitterModel(void 0, process.cwd()).value;
1995
+ const stripped = stripPromptInjections(prompt);
1996
+ const providerPrompt = stripped.length > 0 ? stripped : prompt;
1997
+ const raw = await this.splitterShadowRunner({
1998
+ prompt: providerPrompt,
1999
+ numAgents,
2000
+ model
2001
+ });
2002
+ parsedShadow = this.parseSplitterShadowResult(raw);
2003
+ if (!parsedShadow) {
2004
+ errorMessage = "Malformed provider JSON (strict pure-object parse failed)";
2005
+ }
2006
+ } catch (error) {
2007
+ errorMessage = error instanceof Error ? error.message : String(error);
2008
+ }
2009
+ const heuristicSubTasks = this.getAllSubTasks(heuristicResult).map((task) => ({
2010
+ id: task.id,
2011
+ description: task.description,
2012
+ files: task.files,
2013
+ boundary: task.context,
2014
+ dependencies: task.dependencies
2015
+ }));
2016
+ const shadowSubTasks = parsedShadow?.subtasks.map((task, index) => ({
2017
+ id: typeof task.id === "number" ? task.id : index + 1,
2018
+ description: task.description,
2019
+ files: task.targetFiles ?? [],
2020
+ boundary: task.boundary,
2021
+ dependencies: task.dependencies ?? []
2022
+ })) ?? [];
2023
+ emitCustomWarning(
2024
+ errorMessage ? "WARN" /* WARN */ : "INFO" /* INFO */,
2025
+ "validation" /* VALIDATION */,
2026
+ errorMessage ? "Task splitter LLM shadow split failed" : "Task splitter LLM shadow split comparison recorded",
2027
+ {
2028
+ subsystem: "orchestrator",
2029
+ executionPhase: "setup"
2030
+ },
2031
+ {
2032
+ metadata: {
2033
+ model,
2034
+ strategy: heuristicResult.strategy,
2035
+ heuristicSubTaskCount: heuristicSubTasks.length,
2036
+ llmSubTaskCount: shadowSubTasks.length,
2037
+ heuristicSubTasks,
2038
+ llmSubTasks: shadowSubTasks,
2039
+ error: errorMessage
2040
+ },
2041
+ // Keep console quiet by default; telemetry capture remains structured.
2042
+ skipConsole: true
2043
+ }
2044
+ );
2045
+ }
2046
+ /**
2047
+ * Generate routing decisions for sub-tasks using RoutingPlanner
2048
+ *
2049
+ * @param subTasks - Array of sub-tasks to generate routing for
2050
+ * @param domainAnalysis - Domain analysis result for context
2051
+ * @returns Array of routing decisions for each sub-task
2052
+ */
2053
+ async generateRoutingDecisions(subTasks, domainAnalysis, routingOptions = {}) {
2054
+ const { RoutingPlanner } = await import("./routing-planner-F5WQEUOM.js");
2055
+ const { routingTelemetry } = await import("./routing-events-DHPUZDDF.js");
2056
+ const planner = new RoutingPlanner();
2057
+ const routingDecisions = [];
2058
+ await routingTelemetry.emitEvent({
2059
+ type: "task_split_with_routing",
2060
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2061
+ subTaskCount: subTasks.length,
2062
+ strategy: "file-based",
2063
+ // This will be updated by the caller
2064
+ routingDecisionsCount: 0,
2065
+ // Will be updated after generation
2066
+ hasRoutingDecisions: true,
2067
+ backlogSize: 0,
2068
+ scaffoldingAttached: false,
2069
+ domainTag: "general",
2070
+ complexityTag: "high"
2071
+ });
2072
+ for (const subTask of subTasks) {
2073
+ const generationStart = Date.now();
2074
+ try {
2075
+ const subTaskAnalysis = {
2076
+ ...domainAnalysis,
2077
+ domain: this.inferSubTaskDomain(subTask),
2078
+ confidence: Math.max(0.5, domainAnalysis.confidence - 0.1)
2079
+ // Slightly lower confidence for sub-tasks
2080
+ };
2081
+ const decision = planner.plan(subTaskAnalysis, {
2082
+ subTaskId: `subtask-${subTask.id}`,
2083
+ manualProvider: routingOptions.forceProvider,
2084
+ allowExperimental: routingOptions.allowExperimental
2085
+ });
2086
+ routingDecisions.push(decision);
2087
+ const inferredDomain = this.inferSubTaskDomain(subTask);
2088
+ await routingTelemetry.emitEvent({
2089
+ type: "subtask_routing_generated",
2090
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2091
+ subTaskId: `subtask-${subTask.id}`,
2092
+ subTaskDescription: subTask.description,
2093
+ primaryProvider: decision.primary.provider,
2094
+ providerConfidence: decision.primary.confidence,
2095
+ domainTag: inferredDomain,
2096
+ complexityTag: "medium",
2097
+ generationDuration: Date.now() - generationStart
2098
+ });
2099
+ } catch (_error) {
2100
+ const fallbackProvider = resolveDefaultProvider(void 0, process.cwd()).value;
2101
+ const fallbackDecision = {
2102
+ subTaskId: `subtask-${subTask.id}`,
2103
+ primary: {
2104
+ provider: fallbackProvider,
2105
+ confidence: 0.5,
2106
+ rationale: ["Fallback routing due to planning error"],
2107
+ setup: "local"
2108
+ },
2109
+ alternates: [],
2110
+ rationale: ["Error in routing planning, using fallback"]
2111
+ };
2112
+ routingDecisions.push(fallbackDecision);
2113
+ const fallbackDomain = this.inferSubTaskDomain(subTask);
2114
+ await routingTelemetry.emitEvent({
2115
+ type: "subtask_routing_generated",
2116
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2117
+ subTaskId: `subtask-${subTask.id}`,
2118
+ subTaskDescription: subTask.description,
2119
+ primaryProvider: fallbackProvider,
2120
+ providerConfidence: 0.5,
2121
+ domainTag: fallbackDomain,
2122
+ complexityTag: "medium",
2123
+ generationDuration: Date.now() - generationStart
2124
+ });
2125
+ }
2126
+ }
2127
+ return routingDecisions;
2128
+ }
2129
+ /**
2130
+ * Infer domain for a sub-task based on its content
2131
+ *
2132
+ * @param subTask - Sub-task to analyze
2133
+ * @returns Inferred domain category
2134
+ */
2135
+ inferSubTaskDomain(subTask) {
2136
+ const description = subTask.description.toLowerCase();
2137
+ const files = subTask.files.join(" ").toLowerCase();
2138
+ const content = `${description} ${files}`;
2139
+ if (content.includes("test") || content.includes("spec")) {
2140
+ return "testing";
2141
+ }
2142
+ if (content.includes("ui") || content.includes("component") || content.includes("react")) {
2143
+ return "frontend";
2144
+ }
2145
+ if (content.includes("api") || content.includes("endpoint") || content.includes("server")) {
2146
+ return "backend";
2147
+ }
2148
+ if (content.includes("doc") || content.includes("readme") || content.includes("guide")) {
2149
+ return "docs";
2150
+ }
2151
+ if (content.includes("config") || content.includes("setup") || content.includes("deploy")) {
2152
+ return "infra";
2153
+ }
2154
+ return "general";
2155
+ }
2156
+ /**
2157
+ * Create a single task result (helper for fallback cases)
2158
+ */
2159
+ createSingleTask(prompt, reasoning) {
2160
+ return {
2161
+ subTasks: [
2162
+ {
2163
+ id: 1,
2164
+ description: prompt,
2165
+ files: [],
2166
+ context: "",
2167
+ dependencies: []
2168
+ }
2169
+ ],
2170
+ pendingSubTasks: [],
2171
+ strategy: "single",
2172
+ reasoning
2173
+ };
2174
+ }
2175
+ async safeAnalyzeDomain(prompt) {
2176
+ try {
2177
+ return await this.domainAnalyzer.analyze(prompt);
2178
+ } catch {
2179
+ return this.createDefaultDomainAnalysis();
2180
+ }
2181
+ }
2182
+ safeAnalyzeTaskCharacteristics(prompt, domainAnalysis) {
2183
+ try {
2184
+ return this.taskCharacteristicsAnalyzer.analyze(prompt, domainAnalysis);
2185
+ } catch {
2186
+ return this.createDefaultTaskAnalysis();
2187
+ }
2188
+ }
2189
+ attachMetadataToSubTasks(subTasks, prompt, heuristics, domainAnalysis, taskAnalysis, strategy) {
2190
+ if (subTasks.length === 0) {
2191
+ return subTasks;
2192
+ }
2193
+ const promptHash = this.computePromptHash(prompt);
2194
+ const batchId = `plan-${promptHash.slice(0, 8)}-${subTasks.length}`;
2195
+ const heuristicsList = Array.from(heuristics).sort();
2196
+ return subTasks.map((subTask, index) => ({
2197
+ ...subTask,
2198
+ metadata: {
2199
+ heuristics: heuristicsList,
2200
+ domain: domainAnalysis.domain,
2201
+ domainConfidence: domainAnalysis.confidence,
2202
+ characteristics: taskAnalysis.characteristics,
2203
+ recommendedApproach: taskAnalysis.recommendedApproach,
2204
+ estimatedComplexity: taskAnalysis.estimatedComplexity,
2205
+ timeEstimate: taskAnalysis.timeEstimate,
2206
+ batching: {
2207
+ batchId,
2208
+ position: index,
2209
+ total: subTasks.length
2210
+ },
2211
+ persistence: {
2212
+ checkpointId: `${batchId}-subtask-${subTask.id}`,
2213
+ promptHash
2214
+ },
2215
+ strategy
2216
+ }
2217
+ }));
2218
+ }
2219
+ createPlaceholderMetadata(heuristics, domainAnalysis, taskAnalysis, prompt, strategy, total, index) {
2220
+ const promptHash = this.computePromptHash(prompt);
2221
+ const batchId = `plan-${promptHash.slice(0, 8)}-${total || 1}`;
2222
+ const heuristicsList = Array.from(heuristics).sort();
2223
+ return {
2224
+ heuristics: heuristicsList,
2225
+ domain: domainAnalysis.domain,
2226
+ domainConfidence: domainAnalysis.confidence,
2227
+ characteristics: taskAnalysis.characteristics,
2228
+ recommendedApproach: taskAnalysis.recommendedApproach,
2229
+ estimatedComplexity: taskAnalysis.estimatedComplexity,
2230
+ timeEstimate: taskAnalysis.timeEstimate,
2231
+ batching: {
2232
+ batchId,
2233
+ position: index,
2234
+ total: total || 1
2235
+ },
2236
+ persistence: {
2237
+ checkpointId: `${batchId}-subtask-${index + 1}`,
2238
+ promptHash
2239
+ },
2240
+ strategy
2241
+ };
2242
+ }
2243
+ createDefaultDomainAnalysis() {
2244
+ return {
2245
+ domain: "general",
2246
+ confidence: 0.5,
2247
+ filesMentioned: [],
2248
+ requestedFiles: [],
2249
+ featureCount: 0,
2250
+ compareIntent: false,
2251
+ speedIntent: false,
2252
+ complexity: "medium",
2253
+ isCritical: false,
2254
+ signals: {
2255
+ domainScores: {},
2256
+ heuristicsApplied: []
2257
+ }
2258
+ };
2259
+ }
2260
+ createDefaultTaskAnalysis() {
2261
+ return {
2262
+ characteristics: {
2263
+ fileTypes: [],
2264
+ programmingLanguages: [],
2265
+ fileCount: 0,
2266
+ hasMultipleFiles: false,
2267
+ hasComplexDependencies: false,
2268
+ requiresRefactoring: false,
2269
+ requiresTesting: false,
2270
+ isBugFix: false,
2271
+ isFeatureAddition: false,
2272
+ isRefactoring: false,
2273
+ isDocumentation: false,
2274
+ isTesting: false,
2275
+ requiresDatabaseChanges: false,
2276
+ requiresAPIIntegration: false,
2277
+ requiresUIImplementation: false,
2278
+ requiresConfiguration: false,
2279
+ requiresOptimization: false,
2280
+ requiresSecurityReview: false,
2281
+ requiresCodeReview: false,
2282
+ isCriticalPath: false,
2283
+ affectsMultipleModules: false,
2284
+ requiresCoordination: false
2285
+ },
2286
+ confidence: 0,
2287
+ rationale: [],
2288
+ recommendedApproach: "conservative",
2289
+ estimatedComplexity: "medium",
2290
+ timeEstimate: {
2291
+ min: 0,
2292
+ max: 0,
2293
+ confidence: 0
2294
+ }
2295
+ };
2296
+ }
2297
+ computePromptHash(prompt) {
2298
+ return createHash("sha256").update(prompt).digest("hex");
2299
+ }
2300
+ /**
2301
+ * Apply sequential batching to a task split result
2302
+ * Divides sub-tasks into batches for sequential execution
2303
+ *
2304
+ * @param result - Task split result with sub-tasks
2305
+ * @param numAgents - Number of agents per batch
2306
+ * @returns Modified result with first batch in subTasks, rest in pendingSubTasks
2307
+ */
2308
+ applySequentialBatching(result, numAgents) {
2309
+ if (result.subTasks.length > numAgents) {
2310
+ const batches = [];
2311
+ for (let i = 0; i < result.subTasks.length; i += numAgents) {
2312
+ batches.push(result.subTasks.slice(i, i + numAgents));
2313
+ }
2314
+ return {
2315
+ ...result,
2316
+ subTasks: batches[0] || [],
2317
+ pendingSubTasks: batches.slice(1),
2318
+ reasoning: `${result.reasoning} (sequential batching: ${batches.length} phases)`
2319
+ };
2320
+ }
2321
+ return result;
2322
+ }
2323
+ /**
2324
+ * Split task into sequential chunks when it's very large
2325
+ * Used when task exceeds 2x the recommended threshold
2326
+ *
2327
+ * @param prompt - Task description
2328
+ * @param maxAgents - Max agents per chunk
2329
+ * @param estimatedTokens - Total estimated tokens
2330
+ * @param thresholdTokens - Recommended threshold
2331
+ * @param tokenAnalysis - Token analysis result to include in response
2332
+ * @returns Task split result with sequential chunks
2333
+ */
2334
+ async splitSequentially(prompt, maxAgents, estimatedTokens, thresholdTokens, tokenAnalysis) {
2335
+ const chunks = [];
2336
+ const targetTokensPerChunk = thresholdTokens;
2337
+ const sections = prompt.split(/\n\n+/);
2338
+ let currentChunk = "";
2339
+ let currentTokens = 0;
2340
+ for (const section of sections) {
2341
+ const sectionTokens = estimateTokensHeuristic(section);
2342
+ if (currentTokens + sectionTokens > targetTokensPerChunk && currentChunk) {
2343
+ chunks.push(currentChunk.trim());
2344
+ currentChunk = section;
2345
+ currentTokens = sectionTokens;
2346
+ } else {
2347
+ currentChunk += (currentChunk ? "\n\n" : "") + section;
2348
+ currentTokens += sectionTokens;
2349
+ }
2350
+ }
2351
+ if (currentChunk.trim()) {
2352
+ chunks.push(currentChunk.trim());
2353
+ }
2354
+ if (chunks.length === 1) {
2355
+ const targetCharsPerChunk = Math.ceil(
2356
+ prompt.length / Math.ceil(estimatedTokens / thresholdTokens)
2357
+ );
2358
+ chunks.length = 0;
2359
+ for (let i = 0; i < prompt.length; i += targetCharsPerChunk) {
2360
+ chunks.push(prompt.slice(i, i + targetCharsPerChunk));
2361
+ }
2362
+ }
2363
+ const { firstBatch, pendingBatches } = this.buildBatchedSubTasks(
2364
+ chunks,
2365
+ maxAgents,
2366
+ (chunk, id) => ({
2367
+ id,
2368
+ description: chunk,
2369
+ files: [],
2370
+ context: "Sequential chunk of large task",
2371
+ dependencies: id > 1 ? [id - 1] : []
2372
+ })
2373
+ );
2374
+ const sanitized = this.sanitizeBatches(firstBatch, pendingBatches);
2375
+ const result = {
2376
+ subTasks: sanitized.subTasks,
2377
+ pendingSubTasks: sanitized.pendingSubTasks,
2378
+ strategy: "sequential",
2379
+ reasoning: `Task split into ${chunks.length} sequential chunks to fit context window (estimated ${estimatedTokens} tokens)`,
2380
+ tokenAnalysis
2381
+ };
2382
+ this.validateCompleteExecution(result);
2383
+ return result;
2384
+ }
2385
+ /**
2386
+ * Validate that a split result guarantees complete execution
2387
+ * Ensures all subtasks are valid and have proper dependencies
2388
+ *
2389
+ * @param result - Task split result to validate
2390
+ * @throws Error if validation fails
2391
+ */
2392
+ validateCompleteExecution(result) {
2393
+ const totalSubTasks = result.subTasks.length + result.pendingSubTasks.reduce((sum, batch) => sum + batch.length, 0);
2394
+ if (totalSubTasks === 0 && !_TaskSplitter.ALLOW_ZERO_SUBTASKS.has(result.strategy)) {
2395
+ console.error("[Task Splitter] CRITICAL: Split resulted in zero subtasks");
2396
+ debugLog("[DEBUG] Split result:", result);
2397
+ throw new Error(
2398
+ "CRITICAL: Split resulted in zero subtasks. This is a bug. All tasks must produce at least one subtask."
2399
+ );
2400
+ }
2401
+ const allSubTasks = [...result.subTasks, ...result.pendingSubTasks.flat()];
2402
+ const ids = /* @__PURE__ */ new Set();
2403
+ for (const subtask of allSubTasks) {
2404
+ if (ids.has(subtask.id)) {
2405
+ console.error(`[Task Splitter] CRITICAL: Duplicate subtask ID detected: ${subtask.id}`);
2406
+ debugLog("[DEBUG] All subtasks:", allSubTasks);
2407
+ throw new Error(
2408
+ `CRITICAL: Duplicate subtask ID detected: ${subtask.id}. This violates subtask uniqueness guarantee.`
2409
+ );
2410
+ }
2411
+ ids.add(subtask.id);
2412
+ }
2413
+ for (const subtask of allSubTasks) {
2414
+ for (const depId of subtask.dependencies) {
2415
+ if (!ids.has(depId)) {
2416
+ console.error(
2417
+ `[Task Splitter] CRITICAL: Subtask ${subtask.id} depends on non-existent task ${depId}`
2418
+ );
2419
+ debugLog("[DEBUG] Subtask:", subtask);
2420
+ debugLog("[DEBUG] Valid IDs:", Array.from(ids));
2421
+ throw new Error(
2422
+ `CRITICAL: Subtask ${subtask.id} depends on non-existent task ${depId}. This would cause execution deadlock or failure.`
2423
+ );
2424
+ }
2425
+ }
2426
+ }
2427
+ }
2428
+ /**
2429
+ * Cleanup resources (e.g., token estimator caches)
2430
+ */
2431
+ cleanup() {
2432
+ this.tokenEstimator.cleanup();
2433
+ }
2434
+ };
2435
+
2436
+ export {
2437
+ isAnalysisSubTask,
2438
+ TaskSplitter
2439
+ };
2440
+ //# sourceMappingURL=chunk-JQNJB2BB.js.map