@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,2193 @@
1
+ import {
2
+ renderJsonError,
3
+ renderJsonResult
4
+ } from "./chunk-Q3RO7N35.js";
5
+ import {
6
+ readJudgeTypeEnv,
7
+ resolveCompeteConfig
8
+ } from "./chunk-WTOKKE2V.js";
9
+ import {
10
+ ExitCodeError
11
+ } from "./chunk-FUVP64ER.js";
12
+ import {
13
+ ConfigManager
14
+ } from "./chunk-H66DXFS5.js";
15
+ import {
16
+ isSensitiveConfigPath,
17
+ redactSensitiveConfig
18
+ } from "./chunk-3M57DADF.js";
19
+ import {
20
+ generateValidationReport,
21
+ validatePoeticConfig
22
+ } from "./chunk-CUSRN6RJ.js";
23
+ import {
24
+ registry
25
+ } from "./chunk-Z2KYOFHS.js";
26
+ import {
27
+ resolveExecutionRoles,
28
+ resolveExecutorRoleTarget
29
+ } from "./chunk-YB3JD4E6.js";
30
+ import {
31
+ formatResolvedValue,
32
+ getConfigSummary,
33
+ resolveConfig
34
+ } from "./chunk-XPU2XADL.js";
35
+ import {
36
+ getConfigDiagnostics
37
+ } from "./chunk-SZ7DL357.js";
38
+ import {
39
+ normalizeEngineId
40
+ } from "./chunk-SURZ2WFE.js";
41
+ import {
42
+ isPoeticConfigReadError
43
+ } from "./chunk-G36W2T2S.js";
44
+ import {
45
+ parseJsonWithContext
46
+ } from "./chunk-QVZMFDYG.js";
47
+ import {
48
+ safeJsonParse
49
+ } from "./chunk-S54MKU6V.js";
50
+ import {
51
+ ValidationError
52
+ } from "./chunk-LUVKFFWR.js";
53
+ import {
54
+ BooleanFlagSchema,
55
+ ExistingFilePathSchema,
56
+ FilePathSchema,
57
+ formatValidationErrors,
58
+ validateCommandOptions
59
+ } from "./chunk-QOCOVLUH.js";
60
+ import {
61
+ ProviderRegistry
62
+ } from "./chunk-AT4TNPWW.js";
63
+ import {
64
+ getConfigPaths
65
+ } from "./chunk-L6OM4A22.js";
66
+ import {
67
+ sanitizeString,
68
+ sanitizeValue
69
+ } from "./chunk-LPITVM7M.js";
70
+ import {
71
+ POETIC_MATRIX_BORDERLINE_MARGIN,
72
+ POETIC_MATRIX_CLOSE_CALL_MARGIN,
73
+ POETIC_MATRIX_CONFIDENCE_THRESHOLD,
74
+ readEnv
75
+ } from "./chunk-5DLKYTQX.js";
76
+
77
+ // src/cli/commands/config.ts
78
+ import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
79
+ import chalk2 from "chalk";
80
+ import { Command as Command2 } from "commander";
81
+ import { z } from "zod";
82
+
83
+ // src/cli/commands/config-migrate.ts
84
+ import { existsSync as existsSync2, readFileSync as readFileSync2, statSync, writeFileSync } from "fs";
85
+ import { glob } from "fs/promises";
86
+ import { basename, dirname, extname, join, resolve as resolve2 } from "path";
87
+ import chalk from "chalk";
88
+ import { Command } from "commander";
89
+
90
+ // src/config/migration-tools.ts
91
+ import { XMLParser } from "fast-xml-parser";
92
+ import yaml from "js-yaml";
93
+
94
+ // src/config/schema-validator.ts
95
+ import { existsSync, readFileSync } from "fs";
96
+ import path, { resolve } from "path";
97
+ import { fileURLToPath } from "url";
98
+ import Ajv from "ajv";
99
+ import addFormats from "ajv-formats";
100
+ var __filename = fileURLToPath(import.meta.url);
101
+ var __dirname = path.dirname(__filename);
102
+ function resolveDefaultSchemaDir() {
103
+ const candidates = [
104
+ // Source execution: src/config/schema-validator.ts -> repo/schemas
105
+ resolve(__dirname, "../../schemas"),
106
+ // Bundled package execution: dist/*.js -> package/schemas
107
+ resolve(__dirname, "../schemas")
108
+ ];
109
+ return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
110
+ }
111
+ var SchemaValidator = class {
112
+ ajv;
113
+ schemaCache = /* @__PURE__ */ new Map();
114
+ schemaDir;
115
+ constructor(schemaDir) {
116
+ this.schemaDir = schemaDir || resolveDefaultSchemaDir();
117
+ this.ajv = new Ajv({
118
+ allErrors: true,
119
+ // Report all errors, not just the first
120
+ verbose: true,
121
+ // Include schema information in errors
122
+ strict: false,
123
+ // Allow unknown keywords
124
+ validateFormats: true,
125
+ // Validate format keywords
126
+ loadSchema: this.loadExternalSchema.bind(this)
127
+ });
128
+ addFormats(this.ajv);
129
+ }
130
+ /**
131
+ * Load external schema file ($ref support)
132
+ */
133
+ async loadExternalSchema(uri) {
134
+ let schemaPath;
135
+ if (uri.startsWith("https://poetic.dev/schemas/")) {
136
+ const fileName = uri.replace("https://poetic.dev/schemas/", "");
137
+ schemaPath = resolve(this.schemaDir, fileName);
138
+ } else if (uri.endsWith(".schema.json")) {
139
+ schemaPath = resolve(this.schemaDir, uri);
140
+ } else {
141
+ throw new Error(`Cannot resolve schema URI: ${uri}`);
142
+ }
143
+ try {
144
+ const schemaContent = readFileSync(schemaPath, "utf-8");
145
+ return safeJsonParse(schemaContent, {
146
+ maxDepth: 100,
147
+ context: `external schema URI: ${uri}`
148
+ });
149
+ } catch (error) {
150
+ throw new Error(`Failed to load schema from ${schemaPath}: ${error}`);
151
+ }
152
+ }
153
+ /**
154
+ * Load and compile a JSON schema
155
+ */
156
+ async loadSchema(schemaName) {
157
+ if (this.schemaCache.has(schemaName)) {
158
+ return this.schemaCache.get(schemaName);
159
+ }
160
+ const schemaPath = resolve(this.schemaDir, schemaName);
161
+ const schemaContent = readFileSync(schemaPath, "utf-8");
162
+ const schema = safeJsonParse(schemaContent, {
163
+ maxDepth: 100,
164
+ context: `schema file: ${schemaName}`
165
+ });
166
+ const validate = await this.ajv.compileAsync(schema);
167
+ this.schemaCache.set(schemaName, validate);
168
+ return validate;
169
+ }
170
+ /**
171
+ * Validate configuration against schema
172
+ */
173
+ async validateConfig(config, schemaName = "poetic.config.schema.json") {
174
+ const startTime = performance.now();
175
+ try {
176
+ const validate = await this.loadSchema(schemaName);
177
+ const valid = validate(config);
178
+ const validationTimeMs = performance.now() - startTime;
179
+ if (valid) {
180
+ return {
181
+ valid: true,
182
+ performance: { validationTimeMs }
183
+ };
184
+ }
185
+ const errors = this.formatErrors(validate.errors || []);
186
+ return {
187
+ valid: false,
188
+ errors,
189
+ performance: { validationTimeMs }
190
+ };
191
+ } catch (error) {
192
+ return {
193
+ valid: false,
194
+ errors: [
195
+ {
196
+ name: "ValidationError",
197
+ path: "",
198
+ message: `Schema validation failed: ${error}`,
199
+ suggestion: "Check that the schema file exists and is valid JSON"
200
+ }
201
+ ]
202
+ };
203
+ }
204
+ }
205
+ /**
206
+ * Format AJV errors into user-friendly messages
207
+ */
208
+ formatErrors(ajvErrors) {
209
+ return ajvErrors.map((error) => {
210
+ const path2 = error.instancePath || "/";
211
+ let message = error.message || "Validation failed";
212
+ let suggestion;
213
+ switch (error.keyword) {
214
+ case "type":
215
+ message = `Expected ${error.params.type}, got ${typeof error.data}`;
216
+ suggestion = `Change the value to a ${error.params.type}`;
217
+ break;
218
+ case "required":
219
+ message = `Missing required field: ${error.params.missingProperty}`;
220
+ suggestion = `Add the "${error.params.missingProperty}" field to your configuration`;
221
+ break;
222
+ case "enum":
223
+ message = `Invalid value. Allowed values: ${error.params.allowedValues.join(", ")}`;
224
+ suggestion = `Choose one of: ${error.params.allowedValues.join(", ")}`;
225
+ break;
226
+ case "minimum":
227
+ message = `Value must be >= ${error.params.limit}`;
228
+ suggestion = `Increase the value to at least ${error.params.limit}`;
229
+ break;
230
+ case "maximum":
231
+ message = `Value must be <= ${error.params.limit}`;
232
+ suggestion = `Decrease the value to at most ${error.params.limit}`;
233
+ break;
234
+ case "minLength":
235
+ message = `String must be at least ${error.params.limit} characters`;
236
+ suggestion = "Provide a longer value";
237
+ break;
238
+ case "pattern":
239
+ message = `String must match pattern: ${error.params.pattern}`;
240
+ suggestion = "Check the format requirements in the schema documentation";
241
+ break;
242
+ case "format":
243
+ message = `Invalid ${error.params.format} format`;
244
+ if (error.params.format === "date-time") {
245
+ suggestion = "Use ISO 8601 format: YYYY-MM-DDTHH:mm:ssZ";
246
+ } else if (error.params.format === "uri") {
247
+ suggestion = "Provide a valid URL (e.g., https://example.com)";
248
+ }
249
+ break;
250
+ case "additionalProperties":
251
+ message = `Unknown field: ${error.params.additionalProperty}`;
252
+ suggestion = "Remove this field or check for typos";
253
+ break;
254
+ }
255
+ return {
256
+ name: "ValidationError",
257
+ path: path2 === "/" ? "(root)" : path2.replace(/^\//, ""),
258
+ message,
259
+ value: error.data,
260
+ expected: error.schema,
261
+ suggestion
262
+ };
263
+ });
264
+ }
265
+ /**
266
+ * Validate and throw on error (for convenience)
267
+ */
268
+ async validateOrThrow(config, schemaName) {
269
+ const result = await this.validateConfig(config, schemaName);
270
+ if (!result.valid) {
271
+ const errorMessages = result.errors?.map((err) => {
272
+ let msg = ` \u2022 ${err.path}: ${err.message}`;
273
+ if (err.suggestion) {
274
+ msg += `
275
+ \u2192 ${err.suggestion}`;
276
+ }
277
+ return msg;
278
+ }).join("\n");
279
+ throw new SchemaValidationError(`Configuration validation failed:
280
+ ${errorMessages}`);
281
+ }
282
+ }
283
+ /**
284
+ * Clear schema cache (useful for testing)
285
+ */
286
+ clearCache() {
287
+ this.schemaCache.clear();
288
+ }
289
+ /**
290
+ * Get cache statistics
291
+ */
292
+ getCacheStats() {
293
+ return {
294
+ size: this.schemaCache.size,
295
+ schemas: Array.from(this.schemaCache.keys())
296
+ };
297
+ }
298
+ };
299
+ var SchemaValidationError = class extends Error {
300
+ constructor(message) {
301
+ super(message);
302
+ this.name = "SchemaValidationError";
303
+ }
304
+ };
305
+ var validatorInstance = null;
306
+ function getValidator() {
307
+ if (!validatorInstance) {
308
+ validatorInstance = new SchemaValidator();
309
+ }
310
+ return validatorInstance;
311
+ }
312
+ async function validateConfig(config, schemaName) {
313
+ return getValidator().validateConfig(config, schemaName);
314
+ }
315
+
316
+ // src/config/migration-tools.ts
317
+ function detectFormat(content, fileName) {
318
+ const trimmed = content.trim();
319
+ if (fileName) {
320
+ if (fileName.endsWith(".json")) return "json";
321
+ if (fileName.endsWith(".xml")) return "xml";
322
+ if (fileName.endsWith(".yml") || fileName.endsWith(".yaml")) return "yaml";
323
+ }
324
+ if (trimmed.startsWith("<")) {
325
+ return "xml";
326
+ }
327
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
328
+ try {
329
+ parseJsonWithContext(content, "config format detection");
330
+ return "json";
331
+ } catch {
332
+ }
333
+ }
334
+ if (trimmed.includes(":") && (trimmed.includes("\n") || trimmed.includes("\r")) && !trimmed.startsWith("<")) {
335
+ return "yaml";
336
+ }
337
+ return "unknown";
338
+ }
339
+ function parseXML(content) {
340
+ const parser = new XMLParser({
341
+ ignoreAttributes: false,
342
+ attributeNamePrefix: "",
343
+ textNodeName: "#text",
344
+ // Keep attributes as strings so identifiers and versions such as "1.0" are preserved.
345
+ parseAttributeValue: false,
346
+ parseTagValue: true,
347
+ trimValues: true,
348
+ // Handle CDATA
349
+ cdataPropName: "#cdata"
350
+ });
351
+ const parsed = parser.parse(content);
352
+ return cleanXMLStructure(parsed);
353
+ }
354
+ function cleanXMLStructure(obj) {
355
+ if (obj === null || obj === void 0) {
356
+ return obj;
357
+ }
358
+ if (typeof obj !== "object") {
359
+ return obj;
360
+ }
361
+ if (Array.isArray(obj)) {
362
+ return obj.map((item) => cleanXMLStructure(item));
363
+ }
364
+ const cleaned = {};
365
+ for (const [key, value] of Object.entries(obj)) {
366
+ if (key.startsWith("?xml")) {
367
+ continue;
368
+ }
369
+ if (typeof value === "object" && value !== null) {
370
+ if ("#text" in value && Object.keys(value).length === 1) {
371
+ cleaned[key] = value["#text"];
372
+ } else {
373
+ cleaned[key] = cleanXMLStructure(value);
374
+ }
375
+ } else {
376
+ cleaned[key] = value;
377
+ }
378
+ }
379
+ return cleaned;
380
+ }
381
+ async function xmlToJson(content, options = {}) {
382
+ try {
383
+ const data = parseXML(content);
384
+ const json = JSON.stringify(data, null, options.prettyPrint !== false ? 2 : 0);
385
+ let validation;
386
+ if (options.validate && options.schemaName) {
387
+ validation = await validateConfig(data, options.schemaName);
388
+ if (!validation.valid) {
389
+ return {
390
+ success: false,
391
+ format: "xml",
392
+ data,
393
+ json,
394
+ validation,
395
+ errors: validation.errors && validation.errors.length > 0 ? validation.errors.map(
396
+ (err) => `Schema validation failed at ${err.path}: ${err.message}`
397
+ ) : ["Schema validation failed"]
398
+ };
399
+ }
400
+ }
401
+ return {
402
+ success: true,
403
+ format: "xml",
404
+ data,
405
+ json,
406
+ validation
407
+ };
408
+ } catch (error) {
409
+ return {
410
+ success: false,
411
+ format: "xml",
412
+ errors: [`XML parsing failed: ${error}`]
413
+ };
414
+ }
415
+ }
416
+ async function yamlToJson(content, options = {}) {
417
+ try {
418
+ const data = yaml.load(content, { schema: yaml.JSON_SCHEMA });
419
+ const json = JSON.stringify(data, null, options.prettyPrint !== false ? 2 : 0);
420
+ let validation;
421
+ if (options.validate && options.schemaName) {
422
+ validation = await validateConfig(data, options.schemaName);
423
+ if (!validation.valid) {
424
+ return {
425
+ success: false,
426
+ format: "yaml",
427
+ data,
428
+ json,
429
+ validation,
430
+ errors: validation.errors && validation.errors.length > 0 ? validation.errors.map(
431
+ (err) => `Schema validation failed at ${err.path}: ${err.message}`
432
+ ) : ["Schema validation failed"]
433
+ };
434
+ }
435
+ }
436
+ return {
437
+ success: true,
438
+ format: "yaml",
439
+ data,
440
+ json,
441
+ validation
442
+ };
443
+ } catch (error) {
444
+ return {
445
+ success: false,
446
+ format: "yaml",
447
+ errors: [`YAML parsing failed: ${error}`]
448
+ };
449
+ }
450
+ }
451
+ async function migrateToJson(content, fileName, options = {}) {
452
+ const format = detectFormat(content, fileName);
453
+ switch (format) {
454
+ case "json":
455
+ try {
456
+ const data = parseJsonWithContext(content, "user config migration");
457
+ const json = options.prettyPrint !== false ? JSON.stringify(data, null, 2) : content;
458
+ let validation;
459
+ if (options.validate && options.schemaName) {
460
+ validation = await validateConfig(data, options.schemaName);
461
+ if (!validation.valid) {
462
+ return {
463
+ success: false,
464
+ format: "json",
465
+ data,
466
+ json,
467
+ validation,
468
+ errors: validation.errors && validation.errors.length > 0 ? validation.errors.map(
469
+ (err) => `Schema validation failed at ${err.path}: ${err.message}`
470
+ ) : ["Schema validation failed"],
471
+ warnings: ["File is already in JSON format"]
472
+ };
473
+ }
474
+ }
475
+ return {
476
+ success: true,
477
+ format: "json",
478
+ data,
479
+ json,
480
+ validation,
481
+ warnings: ["File is already in JSON format"]
482
+ };
483
+ } catch (error) {
484
+ return {
485
+ success: false,
486
+ format: "json",
487
+ errors: [`Invalid JSON: ${error}`]
488
+ };
489
+ }
490
+ case "xml":
491
+ return xmlToJson(content, options);
492
+ case "yaml":
493
+ return yamlToJson(content, options);
494
+ default:
495
+ return {
496
+ success: false,
497
+ format: "unknown",
498
+ errors: ["Could not detect configuration format"]
499
+ };
500
+ }
501
+ }
502
+ async function batchMigrate(files, options = {}) {
503
+ const results = [];
504
+ let successful = 0;
505
+ let failed = 0;
506
+ for (const file of files) {
507
+ const result = await migrateToJson(file.content, file.name, options);
508
+ results.push({ fileName: file.name, result });
509
+ if (result.success) {
510
+ successful++;
511
+ } else {
512
+ failed++;
513
+ }
514
+ }
515
+ return {
516
+ total: files.length,
517
+ successful,
518
+ failed,
519
+ results
520
+ };
521
+ }
522
+ function generateMigrationReport(results) {
523
+ const lines = [];
524
+ lines.push("# Configuration Migration Report");
525
+ lines.push("");
526
+ lines.push(`Total files: ${results.total}`);
527
+ lines.push(`Successful: ${results.successful}`);
528
+ lines.push(`Failed: ${results.failed}`);
529
+ lines.push("");
530
+ if (results.successful > 0) {
531
+ lines.push("## Successful Migrations");
532
+ lines.push("");
533
+ for (const { fileName, result } of results.results) {
534
+ if (result.success) {
535
+ lines.push(`- OK: ${fileName} (${result.format} -> JSON)`);
536
+ if (result.warnings && result.warnings.length > 0) {
537
+ for (const warning of result.warnings) {
538
+ lines.push(` Warning: ${warning}`);
539
+ }
540
+ }
541
+ if (result.validation && !result.validation.valid) {
542
+ lines.push(" Error: Validation failed");
543
+ }
544
+ }
545
+ }
546
+ lines.push("");
547
+ }
548
+ if (results.failed > 0) {
549
+ lines.push("## Failed Migrations");
550
+ lines.push("");
551
+ for (const { fileName, result } of results.results) {
552
+ if (!result.success) {
553
+ lines.push(`- Error: ${fileName}`);
554
+ if (result.errors) {
555
+ for (const error of result.errors) {
556
+ lines.push(` ${error}`);
557
+ }
558
+ }
559
+ }
560
+ }
561
+ lines.push("");
562
+ }
563
+ return lines.join("\n");
564
+ }
565
+
566
+ // src/cli/commands/config-migrate.ts
567
+ function migratedOutputPath(inputPath) {
568
+ const extension = extname(inputPath);
569
+ if (/^\.(xml|yml|yaml)$/i.test(extension)) {
570
+ return `${inputPath.slice(0, -extension.length)}.json`;
571
+ }
572
+ const directory = dirname(inputPath);
573
+ const baseName = basename(inputPath, extension);
574
+ const suffix = extension.toLowerCase() === ".json" ? ".migrated.json" : ".json";
575
+ return join(directory, `${baseName}${suffix}`);
576
+ }
577
+ function uniqueBackupPath(filePath) {
578
+ let candidate = `${filePath}.backup`;
579
+ let index = 1;
580
+ while (existsSync2(candidate)) {
581
+ if (index > 1e3) {
582
+ throw new Error(`Unable to allocate unique backup path for ${filePath}`);
583
+ }
584
+ candidate = `${filePath}.backup.${index}`;
585
+ index += 1;
586
+ }
587
+ return candidate;
588
+ }
589
+ function createConfigMigrateCommand() {
590
+ const migrateCommand = new Command("migrate").description(
591
+ "Migrate configuration files from legacy formats (XML, YAML) to JSON"
592
+ );
593
+ migrateCommand.command("file").description("Migrate a single configuration file to JSON").argument("<input>", "Input file path (XML, YAML, or JSON)").option("-o, --output <path>", "Output file path (default: same name with .json extension)").option(
594
+ "--no-validate",
595
+ "Skip schema validation after migration (explicit unchecked-output override)"
596
+ ).option("--schema <name>", "Schema name to validate against", "poetic.config.schema.json").option("--dry-run", "Show migration result without writing file").option("--no-backup", "Skip creating backup of original file").action(async (input, options) => {
597
+ try {
598
+ const inputPath = resolve2(input);
599
+ if (!existsSync2(inputPath)) {
600
+ console.error(chalk.red(`Error: File not found: ${inputPath}`));
601
+ process.exit(1);
602
+ }
603
+ const content = readFileSync2(inputPath, "utf-8");
604
+ const format = detectFormat(content, inputPath);
605
+ console.log(chalk.blue(`Migrating ${format.toUpperCase()} configuration...`));
606
+ console.log(chalk.gray(` Input: ${inputPath}`));
607
+ const migrationOptions = {
608
+ validate: options.validate !== false,
609
+ schemaName: options.schema,
610
+ prettyPrint: true
611
+ };
612
+ const result = await migrateToJson(content, inputPath, migrationOptions);
613
+ if (!result.success) {
614
+ console.error(chalk.red("\nError: Migration failed:"));
615
+ for (const error of result.errors || []) {
616
+ console.error(chalk.red(` ${error}`));
617
+ }
618
+ if (result.validation && !result.validation.valid) {
619
+ console.error(chalk.red("\nError: Validation issues:"));
620
+ for (const error of result.validation.errors || []) {
621
+ console.error(chalk.red(` \u2022 ${error.path}: ${error.message}`));
622
+ if (error.suggestion) {
623
+ console.error(chalk.gray(` \u2192 ${error.suggestion}`));
624
+ }
625
+ }
626
+ }
627
+ process.exit(1);
628
+ }
629
+ if (result.warnings && result.warnings.length > 0) {
630
+ console.log(chalk.yellow("\nWarning: Warnings:"));
631
+ for (const warning of result.warnings) {
632
+ console.log(chalk.yellow(` ${warning}`));
633
+ }
634
+ }
635
+ const outputPath = options.output ? resolve2(options.output) : migratedOutputPath(inputPath);
636
+ if (options.dryRun) {
637
+ console.log(chalk.green("\nOK: Migration successful (dry run)"));
638
+ console.log(chalk.gray(` Would write to: ${outputPath}`));
639
+ console.log(chalk.cyan("\nMigrated JSON:"));
640
+ console.log(result.json);
641
+ } else {
642
+ if (options.backup !== false && (format !== "json" || outputPath === inputPath)) {
643
+ const backupPath = uniqueBackupPath(inputPath);
644
+ writeFileSync(backupPath, content, "utf-8");
645
+ console.log(chalk.gray(` Backup: ${backupPath}`));
646
+ }
647
+ const outputContent = outputPath.endsWith(".js") || outputPath.endsWith(".mjs") ? `export default ${result.json};
648
+ ` : result.json;
649
+ writeFileSync(outputPath, outputContent, "utf-8");
650
+ console.log(chalk.green("\nOK: Migration successful"));
651
+ console.log(chalk.gray(` Output: ${outputPath}`));
652
+ }
653
+ if (result.validation) {
654
+ const validationTimeMs = result.validation.performance?.validationTimeMs;
655
+ console.log(
656
+ chalk.gray(
657
+ ` Validation: ${typeof validationTimeMs === "number" ? validationTimeMs.toFixed(2) : "n/a"}ms`
658
+ )
659
+ );
660
+ }
661
+ } catch (error) {
662
+ console.error(chalk.red(`
663
+ Error: Migration failed: ${error}`));
664
+ process.exit(1);
665
+ }
666
+ });
667
+ migrateCommand.command("batch").description("Migrate multiple configuration files").argument("<pattern>", 'Glob pattern for files to migrate (e.g., "config/**/*.xml")').option(
668
+ "--no-validate",
669
+ "Skip schema validation after migration (explicit unchecked-output override)"
670
+ ).option("--schema <name>", "Schema name to validate against", "poetic.config.schema.json").option("--dry-run", "Show what would be migrated without writing files").option("--no-backup", "Skip creating backups of original files").action(async (pattern, options) => {
671
+ try {
672
+ console.log(chalk.blue(`Searching for files matching: ${pattern}`));
673
+ const files = [];
674
+ for await (const entry of glob(pattern)) {
675
+ if (typeof entry === "string") {
676
+ try {
677
+ const stats = statSync(entry);
678
+ if (stats.isFile()) {
679
+ files.push(entry);
680
+ }
681
+ } catch {
682
+ }
683
+ }
684
+ }
685
+ if (files.length === 0) {
686
+ console.log(chalk.yellow("Warning: No files found"));
687
+ return;
688
+ }
689
+ console.log(chalk.blue(`Found ${files.length} file(s) to migrate
690
+ `));
691
+ const fileContents = files.map((filePath) => ({
692
+ name: filePath,
693
+ content: readFileSync2(filePath, "utf-8")
694
+ }));
695
+ const migrationOptions = {
696
+ validate: options.validate !== false,
697
+ schemaName: options.schema,
698
+ prettyPrint: true
699
+ };
700
+ const batchResult = await batchMigrate(fileContents, migrationOptions);
701
+ const report = generateMigrationReport(batchResult);
702
+ console.log(report);
703
+ const hasFailure = batchResult.failed > 0 || batchResult.results.some(({ result }) => !result.success);
704
+ if (hasFailure) {
705
+ console.error(
706
+ chalk.red(
707
+ `
708
+ Error: Batch migration failed (${batchResult.failed}/${batchResult.total} file(s)); no files written`
709
+ )
710
+ );
711
+ process.exit(1);
712
+ }
713
+ if (!options.dryRun) {
714
+ for (const { fileName, result } of batchResult.results) {
715
+ if (result.success && result.json) {
716
+ const outputPath = migratedOutputPath(fileName);
717
+ const format = result.format;
718
+ if (options.backup !== false && (format !== "json" || outputPath === fileName)) {
719
+ const backupPath = uniqueBackupPath(fileName);
720
+ const fileContent = fileContents.find(
721
+ (f) => f.name === fileName
722
+ );
723
+ if (fileContent) {
724
+ writeFileSync(backupPath, fileContent.content, "utf-8");
725
+ }
726
+ }
727
+ writeFileSync(outputPath, result.json, "utf-8");
728
+ }
729
+ }
730
+ console.log(chalk.green("\nOK: Batch migration complete"));
731
+ console.log(chalk.gray(` Migrated: ${batchResult.successful}/${batchResult.total}`));
732
+ } else {
733
+ console.log(chalk.blue("\nDry run complete (no files written)"));
734
+ }
735
+ } catch (error) {
736
+ console.error(chalk.red(`
737
+ Error: Batch migration failed: ${error}`));
738
+ process.exit(1);
739
+ }
740
+ });
741
+ migrateCommand.command("validate").description("Validate configuration file against JSON Schema").argument("<input>", "Configuration file to validate").option("--schema <name>", "Schema name to validate against", "poetic.config.schema.json").option("-v, --verbose", "Show detailed validation information").action(async (input, options) => {
742
+ try {
743
+ const inputPath = resolve2(input);
744
+ if (!existsSync2(inputPath)) {
745
+ console.error(chalk.red(`Error: File not found: ${inputPath}`));
746
+ process.exit(1);
747
+ }
748
+ console.log(chalk.blue("Validating configuration..."));
749
+ console.log(chalk.gray(` File: ${inputPath}`));
750
+ console.log(chalk.gray(` Schema: ${options.schema}
751
+ `));
752
+ const content = readFileSync2(inputPath, "utf-8");
753
+ const config = parseJsonWithContext(
754
+ content,
755
+ `Config file (${inputPath})`
756
+ );
757
+ const result = await validateConfig(config, options.schema);
758
+ if (result.valid) {
759
+ console.log(chalk.green("OK: Configuration is valid"));
760
+ if (options.verbose && result.performance) {
761
+ console.log(
762
+ chalk.gray(` Validation time: ${result.performance.validationTimeMs.toFixed(2)}ms`)
763
+ );
764
+ }
765
+ } else {
766
+ console.log(chalk.red("Error: Configuration validation failed:"));
767
+ for (const error of result.errors || []) {
768
+ console.log(chalk.red(` \u2022 ${error.path}: ${error.message}`));
769
+ if (error.suggestion) {
770
+ console.log(chalk.gray(` \u2192 ${error.suggestion}`));
771
+ }
772
+ }
773
+ process.exit(1);
774
+ }
775
+ } catch (error) {
776
+ if (error instanceof SyntaxError) {
777
+ console.error(chalk.red(`Error: Invalid JSON: ${error.message}`));
778
+ } else {
779
+ console.error(chalk.red(`Error: Validation failed: ${error}`));
780
+ }
781
+ process.exit(1);
782
+ }
783
+ });
784
+ return migrateCommand;
785
+ }
786
+
787
+ // src/cli/commands/config.ts
788
+ var REDACTED_CONFIG_VALUE = "<redacted>";
789
+ function qualityGateStatus(enabled) {
790
+ return enabled ? chalk2.green("OK") : chalk2.gray("Disabled");
791
+ }
792
+ function isPlainRecord(value) {
793
+ return typeof value === "object" && value !== null && !Array.isArray(value);
794
+ }
795
+ function sanitizeConfigStrings(value) {
796
+ if (typeof value === "string") {
797
+ return sanitizeString(value);
798
+ }
799
+ if (Array.isArray(value)) {
800
+ return value.map((item) => sanitizeConfigStrings(item));
801
+ }
802
+ if (isPlainRecord(value)) {
803
+ const sanitized = {};
804
+ for (const [key, item] of Object.entries(value)) {
805
+ sanitized[key] = sanitizeConfigStrings(item);
806
+ }
807
+ return sanitized;
808
+ }
809
+ return value;
810
+ }
811
+ function redactConfigValueForDisplay(path2, value) {
812
+ if (isSensitiveConfigPath(path2)) {
813
+ return REDACTED_CONFIG_VALUE;
814
+ }
815
+ return sanitizeConfigStrings(redactSensitiveConfig(value, path2.split(".").filter(Boolean)));
816
+ }
817
+ function formatConfigGetValueForDisplay(path2, value) {
818
+ const displayValue = redactConfigValueForDisplay(path2, value);
819
+ return typeof displayValue === "string" ? displayValue : JSON.stringify(displayValue, null, 2);
820
+ }
821
+ function formatConfigSetValueForDisplay(path2, value) {
822
+ if (isSensitiveConfigPath(path2)) {
823
+ return "<redacted>";
824
+ }
825
+ const displayValue = redactConfigValueForDisplay(path2, value);
826
+ return typeof displayValue === "string" ? displayValue : JSON.stringify(displayValue);
827
+ }
828
+ function buildConfigGetJsonPayload(path2, scope, value) {
829
+ const found = value !== void 0;
830
+ return {
831
+ path: path2,
832
+ scope,
833
+ found,
834
+ value: found ? redactConfigValueForDisplay(path2, value) : null
835
+ };
836
+ }
837
+ function buildConfigScopeMissLines(path2, scope, alternateScopeValue) {
838
+ const lines = [`${path2} is not set (scope: ${scope})`];
839
+ if (alternateScopeValue !== void 0) {
840
+ const alternateScope = scope === "project" ? "user" : "project";
841
+ const retryHint = alternateScope === "user" ? "poetic config get --scope user" : "poetic config get";
842
+ lines.push(
843
+ ` Tip: value is set in ${alternateScope} scope; retry with \`${retryHint} ${path2}\` or use \`poetic config resolved\` for the effective value.`
844
+ );
845
+ }
846
+ return lines;
847
+ }
848
+ async function printConfigScopeMiss(path2, scope, getConfigValue) {
849
+ const alternateScope = scope === "project" ? "user" : "project";
850
+ const alternateScopeValue = await getConfigValue(path2, alternateScope);
851
+ for (const line of buildConfigScopeMissLines(path2, scope, alternateScopeValue)) {
852
+ console.log(chalk2.yellow(line));
853
+ }
854
+ }
855
+ function formatResolvedConfigSummaryLine(summary) {
856
+ return ` ${chalk2.cyan(summary.provider)} \xB7 ${chalk2.cyan(summary.model)} \xB7 ${chalk2.cyan(summary.strategy)} \xB7 routing:${chalk2.cyan(summary.routingPolicy)} \xB7 blockers:${chalk2.cyan(summary.blockerMode)} \xB7 transport:${chalk2.cyan(summary.transport)} \xB7 judge:${chalk2.cyan(summary.judge.type)}`;
857
+ }
858
+ function errorMessage(error) {
859
+ return sanitizeValue(error);
860
+ }
861
+ function configReadRepairHint(error) {
862
+ return `Fix or remove ${error.filePath}; Poetic will not ignore an existing invalid config file.`;
863
+ }
864
+ function renderConfigReadFailure(error, json = false) {
865
+ if (!isPoeticConfigReadError(error)) return false;
866
+ const repairHint = configReadRepairHint(error);
867
+ if (json) {
868
+ renderJsonError(
869
+ new ValidationError(error.message, {
870
+ code: error.code,
871
+ filePath: error.filePath,
872
+ reason: error.reason,
873
+ diagnostics: error.diagnostics,
874
+ repairHint
875
+ })
876
+ );
877
+ return true;
878
+ }
879
+ writeConfigError(chalk2.red(`Error: ${error.message}`));
880
+ writeConfigError(chalk2.gray(repairHint));
881
+ return true;
882
+ }
883
+ function writeConfigLine(line = "") {
884
+ process.stdout.write(`${line}
885
+ `);
886
+ }
887
+ function writeConfigError(line) {
888
+ process.stderr.write(`${line}
889
+ `);
890
+ }
891
+ function printResolvedRoles(roles) {
892
+ const src = (r) => chalk2.gray(`[${r.sourcePath ?? r.source}]`);
893
+ const { orchestrator, executor, reviewer } = roles;
894
+ writeConfigLine(chalk2.bold.blue("\nExecution Roles\n"));
895
+ if (orchestrator.provider) {
896
+ writeConfigLine(
897
+ ` roles.orchestrator.provider: ${chalk2.cyan(orchestrator.provider.value)} ${src(orchestrator.provider)}`
898
+ );
899
+ }
900
+ if (orchestrator.model) {
901
+ writeConfigLine(
902
+ ` roles.orchestrator.model: ${chalk2.cyan(orchestrator.model.value)} ${src(orchestrator.model)}`
903
+ );
904
+ }
905
+ if (orchestrator.fallbackModel) {
906
+ writeConfigLine(
907
+ ` roles.orchestrator.fallback: ${chalk2.cyan(orchestrator.fallbackModel.value)} ${src(orchestrator.fallbackModel)}`
908
+ );
909
+ }
910
+ writeConfigLine(
911
+ ` roles.executor.provider: ${chalk2.cyan(executor.provider.value)} ${src(executor.provider)}`
912
+ );
913
+ writeConfigLine(
914
+ ` roles.executor.model: ${chalk2.cyan(executor.model.value)} ${src(executor.model)}`
915
+ );
916
+ writeConfigLine(
917
+ ` roles.executor.subagents: ${chalk2.cyan(String(executor.subagents.value))} ${src(executor.subagents)}`
918
+ );
919
+ writeConfigLine(
920
+ ` roles.executor.transport: ${chalk2.cyan(executor.transport.value)} ${src(executor.transport)}`
921
+ );
922
+ writeConfigLine(
923
+ ` roles.reviewer.provider: ${chalk2.cyan(reviewer.provider.value)} ${src(reviewer.provider)}`
924
+ );
925
+ writeConfigLine(
926
+ ` roles.reviewer.model: ${chalk2.cyan(reviewer.model.value)} ${src(reviewer.model)}`
927
+ );
928
+ writeConfigLine(
929
+ ` roles.reviewer.gate: ${chalk2.cyan(reviewer.gate.value)} ${src(reviewer.gate)}`
930
+ );
931
+ if (roles.sameVendorReview) {
932
+ writeConfigLine(
933
+ ` ${chalk2.yellow("Note:")} reviewer matches an executor provider; executor separation is unavailable`
934
+ );
935
+ }
936
+ }
937
+ async function buildResolvedExecutorModelQuery(provider, cwd) {
938
+ const executor = resolveExecutorRoleTarget({
939
+ cwd,
940
+ providerOverride: provider
941
+ });
942
+ const providerModule = registry.get(provider);
943
+ const bridge = providerModule?.resolveModelSelection;
944
+ const selection = bridge ? await bridge({ modelInput: executor.model.value }) : {
945
+ modelInput: executor.model.value,
946
+ effectiveModel: executor.model.value,
947
+ nativeDefault: null,
948
+ emitModelArg: null,
949
+ emittedModel: null,
950
+ cliVersion: null,
951
+ discoveryStatus: "unsupported",
952
+ availableModels: [],
953
+ selectedModelAvailable: null
954
+ };
955
+ return {
956
+ schemaVersion: 1,
957
+ role: "executor",
958
+ provider: executor.provider,
959
+ model: {
960
+ input: selection.modelInput,
961
+ effective: selection.effectiveModel,
962
+ source: executor.model.source,
963
+ ...executor.model.sourcePath ? { sourcePath: executor.model.sourcePath } : {},
964
+ ...executor.modelRole ? { modelRole: executor.modelRole } : {},
965
+ nativeDefault: selection.nativeDefault,
966
+ emitModelArg: selection.emitModelArg,
967
+ emittedModel: selection.emittedModel,
968
+ cliVersion: selection.cliVersion,
969
+ discoveryStatus: selection.discoveryStatus,
970
+ bridgeStatus: bridge ? "supported" : "unsupported",
971
+ availableModels: selection.availableModels,
972
+ selectedModelAvailable: selection.selectedModelAvailable
973
+ }
974
+ };
975
+ }
976
+ async function buildExecutionPreview(resolved) {
977
+ const envOverrideKeys = [
978
+ "POETIC_DEFAULT_PROVIDER",
979
+ "POETIC_DEFAULT_STRATEGY",
980
+ "POETIC_JUDGE_TYPE",
981
+ "POETIC_JUDGE",
982
+ "POETIC_JUDGE_RUN",
983
+ "POETIC_JUDGE_PRIMARY",
984
+ "POETIC_AI_JUDGE_RUN",
985
+ "POETIC_AI_JUDGE_PRIMARY",
986
+ "POETIC_COMPLETION_MODE",
987
+ "POETIC_TIMEOUT_MS",
988
+ "POETIC_CLAUDE_EXECUTION_TRANSPORT",
989
+ "POETIC_CODEX_EXECUTION_TRANSPORT",
990
+ "POETIC_PROVIDER_EXECUTION_TRANSPORT",
991
+ "POETIC_EXECUTION_TRANSPORT",
992
+ "POETIC_SYNTHESIS_STRATEGY",
993
+ "POETIC_SYNTHESIS_AI_FIRST"
994
+ ];
995
+ let compete;
996
+ try {
997
+ compete = await resolveCompeteConfig({}, { projectRoot: process.cwd() });
998
+ } catch (error) {
999
+ compete = { error: errorMessage(error) };
1000
+ }
1001
+ return {
1002
+ run: {
1003
+ provider: formatResolvedValue(resolved.defaultProvider),
1004
+ model: formatResolvedValue(resolved.defaultModel),
1005
+ strategy: formatResolvedValue(resolved.defaultStrategy),
1006
+ transport: formatResolvedValue(resolved.providerExecutionTransport.current),
1007
+ judge: {
1008
+ type: formatResolvedValue(resolved.judge.type),
1009
+ provider: formatResolvedValue(resolved.judge.provider),
1010
+ model: formatResolvedValue(resolved.judge.model)
1011
+ }
1012
+ },
1013
+ compete,
1014
+ envOverrides: envOverrideKeys.filter((key) => process.env[key]?.trim())
1015
+ };
1016
+ }
1017
+ function printExplainRow(result) {
1018
+ const parts = [
1019
+ chalk2.cyan(result.name),
1020
+ result.type,
1021
+ `default=${result.default !== void 0 ? String(result.default) : "(none)"}`,
1022
+ `source=${result.source}`,
1023
+ `category=${result.category}`
1024
+ ];
1025
+ if (result.status === "deprecated") {
1026
+ parts.push(chalk2.yellow(`deprecated${result.replacement ? `->${result.replacement}` : ""}`));
1027
+ }
1028
+ if (result.error !== void 0) {
1029
+ parts.push(chalk2.red(`error: ${result.error}`));
1030
+ }
1031
+ console.log(parts.join(" "));
1032
+ }
1033
+ function createConfigCommand() {
1034
+ const configCommand = new Command2("config").alias("settings").description("Manage Poetic configuration and preferences");
1035
+ const ShowOptionsSchema = z.object({
1036
+ verbose: BooleanFlagSchema.optional(),
1037
+ json: BooleanFlagSchema.optional()
1038
+ }).strict();
1039
+ const ValidateOptionsSchema = z.object({
1040
+ fix: BooleanFlagSchema.optional(),
1041
+ verbose: BooleanFlagSchema.optional(),
1042
+ json: BooleanFlagSchema.optional()
1043
+ }).strict();
1044
+ const DiagnoseOptionsSchema = z.object({
1045
+ fix: BooleanFlagSchema.optional()
1046
+ }).strict();
1047
+ const ResetOptionsSchema = z.object({
1048
+ level: z.enum(["user", "project", "all"]).optional().default("project"),
1049
+ backup: BooleanFlagSchema.optional()
1050
+ }).strict();
1051
+ const ExportOptionsSchema = z.object({
1052
+ output: FilePathSchema.optional().default("poetic-config-export.json"),
1053
+ includePreferences: BooleanFlagSchema.optional()
1054
+ }).strict();
1055
+ const ImportOptionsSchema = z.object({
1056
+ importPreferences: BooleanFlagSchema.optional()
1057
+ }).strict();
1058
+ configCommand.command("show").description("Display current configuration with source information").option("-v, --verbose", "Show detailed configuration with sources").option("-j, --json", "Output configuration as JSON").action(async (options) => {
1059
+ try {
1060
+ const validatedOptions = validateCommandOptions(ShowOptionsSchema, options);
1061
+ options = validatedOptions;
1062
+ } catch (error) {
1063
+ if (error instanceof z.ZodError) {
1064
+ console.error(chalk2.red("\nError: Invalid command options:"));
1065
+ console.error(formatValidationErrors(error));
1066
+ console.error(
1067
+ chalk2.gray('\nTip: Use "poetic config <subcommand> --help" for valid options')
1068
+ );
1069
+ throw new ExitCodeError(1);
1070
+ }
1071
+ throw error;
1072
+ }
1073
+ const configManager = new ConfigManager();
1074
+ try {
1075
+ const config = await configManager.loadConfig();
1076
+ const resolved = configManager.resolveExecutionConfig();
1077
+ if (options.json) {
1078
+ renderJsonResult(
1079
+ redactConfigValueForDisplay("", {
1080
+ config: config.config,
1081
+ resolved,
1082
+ sources: config.sources,
1083
+ effectiveModel: config.effectiveModel,
1084
+ isFirstTimeUser: config.isFirstTimeUser,
1085
+ loadTime: config.loadTime
1086
+ })
1087
+ );
1088
+ return;
1089
+ }
1090
+ console.log(chalk2.bold.blue("\nPoetic Configuration\n"));
1091
+ console.log(chalk2.bold("Effective Settings:"));
1092
+ console.log(` Default Provider: ${chalk2.cyan(resolved.defaultProvider.value)}`);
1093
+ console.log(` Default Model: ${chalk2.cyan(resolved.defaultModel.value)}`);
1094
+ console.log(` Default Strategy: ${chalk2.cyan(resolved.defaultStrategy.value)}`);
1095
+ console.log(` First-time User: ${chalk2.cyan(config.isFirstTimeUser ? "Yes" : "No")}`);
1096
+ console.log(` Load Time: ${chalk2.gray(`${config.loadTime}ms`)}`);
1097
+ console.log();
1098
+ const enabledProviders = ProviderRegistry.getEnabledProviders();
1099
+ if (enabledProviders.length > 0) {
1100
+ console.log(chalk2.bold("Provider Configuration:"));
1101
+ for (const provider of enabledProviders) {
1102
+ const model = resolved.providerModels[provider.id]?.value ?? provider.models.default;
1103
+ console.log(` ${provider.id}: ${chalk2.cyan(String(model))}`);
1104
+ }
1105
+ console.log();
1106
+ }
1107
+ if (options.verbose) {
1108
+ console.log(chalk2.bold("Configuration Sources (by priority):"));
1109
+ for (const source of config.sources.sort((a, b) => b.priority - a.priority)) {
1110
+ const status = source.data ? chalk2.green("OK") : chalk2.red("Error");
1111
+ console.log(` ${status} ${source.type} (priority: ${source.priority})`);
1112
+ if (source.path) {
1113
+ console.log(` Path: ${chalk2.gray(source.path)}`);
1114
+ }
1115
+ }
1116
+ console.log();
1117
+ }
1118
+ if (config.config.quality) {
1119
+ console.log(chalk2.bold("Quality Gates:"));
1120
+ const quality = config.config.quality;
1121
+ if (quality.coverage) {
1122
+ console.log(
1123
+ ` ${qualityGateStatus(quality.coverage.enabled)} Coverage: ${chalk2.cyan(
1124
+ `${quality.coverage.threshold}%`
1125
+ )}`
1126
+ );
1127
+ }
1128
+ if (quality.lint) {
1129
+ console.log(` ${qualityGateStatus(quality.lint.enabled)} Linting`);
1130
+ }
1131
+ if (quality.security) {
1132
+ console.log(` ${qualityGateStatus(quality.security.enabled)} Security`);
1133
+ }
1134
+ console.log();
1135
+ }
1136
+ } catch (error) {
1137
+ if (error instanceof ExitCodeError) throw error;
1138
+ if (renderConfigReadFailure(error, Boolean(options.json))) throw new ExitCodeError(1);
1139
+ console.error(chalk2.red("Error loading configuration:"), errorMessage(error));
1140
+ throw new ExitCodeError(1);
1141
+ }
1142
+ });
1143
+ configCommand.command("list").description("List all configuration values").option("-j, --json", "Output configuration as JSON").action(async (options) => {
1144
+ try {
1145
+ const configManager = new ConfigManager();
1146
+ const config = await configManager.loadConfig();
1147
+ const resolved = configManager.resolveExecutionConfig();
1148
+ if (options.json) {
1149
+ renderJsonResult(
1150
+ redactConfigValueForDisplay("", {
1151
+ config: config.config,
1152
+ resolved,
1153
+ sources: config.sources,
1154
+ effectiveModel: config.effectiveModel
1155
+ })
1156
+ );
1157
+ return;
1158
+ }
1159
+ console.log(chalk2.bold.blue("\nConfiguration Values\n"));
1160
+ const configData = config.config;
1161
+ console.log(`Default Provider: ${chalk2.cyan(resolved.defaultProvider.value)}`);
1162
+ console.log(`Effective Model: ${chalk2.cyan(resolved.defaultModel.value)}`);
1163
+ console.log(`Default Strategy: ${chalk2.cyan(resolved.defaultStrategy.value)}`);
1164
+ const enabledProviders = ProviderRegistry.getEnabledProviders();
1165
+ if (enabledProviders.length > 0) {
1166
+ console.log("\nProviders:");
1167
+ for (const provider of enabledProviders) {
1168
+ const model = resolved.providerModels[provider.id]?.value ?? provider.models.default;
1169
+ console.log(` ${provider.id}: ${chalk2.cyan(String(model))}`);
1170
+ }
1171
+ }
1172
+ if (configData.quality) {
1173
+ console.log("\nQuality Gates:");
1174
+ const quality = configData.quality;
1175
+ if (quality.coverage) {
1176
+ console.log(
1177
+ ` ${qualityGateStatus(quality.coverage.enabled)} Coverage: ${chalk2.cyan(
1178
+ `${quality.coverage.threshold}%`
1179
+ )}`
1180
+ );
1181
+ }
1182
+ if (quality.lint) {
1183
+ console.log(` ${qualityGateStatus(quality.lint.enabled)} Linting`);
1184
+ }
1185
+ if (quality.security) {
1186
+ console.log(` ${qualityGateStatus(quality.security.enabled)} Security`);
1187
+ }
1188
+ }
1189
+ console.log("\nConfiguration Sources:");
1190
+ for (const source of config.sources.filter((s) => s.data).sort((a, b) => b.priority - a.priority)) {
1191
+ const status = source.data ? chalk2.green("OK") : chalk2.red("Error");
1192
+ console.log(` ${status} ${source.type} (priority: ${source.priority})`);
1193
+ }
1194
+ console.log();
1195
+ } catch (error) {
1196
+ if (error instanceof ExitCodeError) throw error;
1197
+ if (renderConfigReadFailure(error, Boolean(options.json))) throw new ExitCodeError(1);
1198
+ console.error(chalk2.red("Error listing configuration:"), errorMessage(error));
1199
+ throw new ExitCodeError(1);
1200
+ }
1201
+ });
1202
+ configCommand.command("validate").description("Validate configuration files and report issues").option("--fix", "Attempt to auto-fix fixable issues").option("-v, --verbose", "Show detailed validation information").option("-j, --json", "Output validation result as JSON").action(async (options) => {
1203
+ const wantsJson = Boolean(options.json);
1204
+ try {
1205
+ const validatedOptions = validateCommandOptions(ValidateOptionsSchema, options);
1206
+ options = validatedOptions;
1207
+ } catch (error) {
1208
+ if (error instanceof z.ZodError) {
1209
+ if (wantsJson) {
1210
+ renderJsonError(
1211
+ new ValidationError("Invalid command options", {
1212
+ details: formatValidationErrors(error)
1213
+ })
1214
+ );
1215
+ throw new ExitCodeError(1);
1216
+ }
1217
+ console.error(chalk2.red("\nError: Invalid command options:"));
1218
+ console.error(formatValidationErrors(error));
1219
+ console.error(
1220
+ chalk2.gray('\nTip: Use "poetic config <subcommand> --help" for valid options')
1221
+ );
1222
+ throw new ExitCodeError(1);
1223
+ }
1224
+ throw error;
1225
+ }
1226
+ const configManager = new ConfigManager();
1227
+ try {
1228
+ const config = await configManager.loadConfig();
1229
+ const validation = validatePoeticConfig(config.config, {
1230
+ includeWarnings: true,
1231
+ includeSuggestions: true,
1232
+ cwd: process.cwd()
1233
+ });
1234
+ let providerRegistryError;
1235
+ try {
1236
+ ProviderRegistry.reload();
1237
+ ProviderRegistry.load();
1238
+ } catch (error) {
1239
+ providerRegistryError = errorMessage(error);
1240
+ }
1241
+ const jsonPayload = {
1242
+ isValid: validation.isValid && !providerRegistryError,
1243
+ validation,
1244
+ providerRegistryError: providerRegistryError ?? null
1245
+ };
1246
+ if (options.fix && !validation.isValid) {
1247
+ const { autoFixConfig } = await import("./config-validator-KKOHOW7O.js");
1248
+ const fixResult = autoFixConfig(config.config);
1249
+ const saveResult = fixResult.changes.length > 0 ? await configManager.writeProjectConfig(fixResult.fixedConfig) : { success: true, error: void 0 };
1250
+ jsonPayload.fix = {
1251
+ changes: fixResult.changes,
1252
+ remainingErrors: fixResult.remainingErrors,
1253
+ saved: saveResult.success,
1254
+ saveError: saveResult.success ? null : saveResult.error
1255
+ };
1256
+ if (!options.json) {
1257
+ console.log(chalk2.bold.yellow("\nAttempting to auto-fix issues..."));
1258
+ if (fixResult.changes.length > 0) {
1259
+ console.log(chalk2.green("Fixed issues:"));
1260
+ fixResult.changes.forEach((change) => {
1261
+ console.log(` OK ${change}`);
1262
+ });
1263
+ if (saveResult.success) {
1264
+ console.log(chalk2.green("\nOK: Configuration saved successfully."));
1265
+ } else {
1266
+ console.log(
1267
+ chalk2.red(`
1268
+ Error: Failed to save configuration: ${saveResult.error}`)
1269
+ );
1270
+ }
1271
+ }
1272
+ if (fixResult.remainingErrors.length > 0) {
1273
+ console.log(chalk2.yellow("\nRemaining issues that require manual fix:"));
1274
+ fixResult.remainingErrors.forEach((error) => {
1275
+ console.log(
1276
+ ` Warning: ${sanitizeString(error.path.join("."))}: ${sanitizeString(error.message)}`
1277
+ );
1278
+ });
1279
+ }
1280
+ }
1281
+ }
1282
+ if (options.json) {
1283
+ renderJsonResult(jsonPayload);
1284
+ if (!validation.isValid || providerRegistryError) {
1285
+ throw new ExitCodeError(1);
1286
+ }
1287
+ return;
1288
+ }
1289
+ console.log(chalk2.bold.blue("\nConfiguration Validation\n"));
1290
+ const report = generateValidationReport(validation);
1291
+ console.log(report);
1292
+ if (providerRegistryError) {
1293
+ console.log(chalk2.red("\nProvider registry: invalid"));
1294
+ console.log(chalk2.red(` Error: ${providerRegistryError}`));
1295
+ }
1296
+ if (!validation.isValid || providerRegistryError) {
1297
+ throw new ExitCodeError(1);
1298
+ }
1299
+ } catch (error) {
1300
+ if (error instanceof ExitCodeError) throw error;
1301
+ if (renderConfigReadFailure(error, Boolean(options.json))) throw new ExitCodeError(1);
1302
+ if (options.json) {
1303
+ renderJsonError(error);
1304
+ throw new ExitCodeError(1);
1305
+ }
1306
+ console.error(chalk2.red("Error validating configuration:"), errorMessage(error));
1307
+ throw new ExitCodeError(1);
1308
+ }
1309
+ });
1310
+ configCommand.command("diagnose").description("Run comprehensive diagnostics on configuration system").option("--fix", "Attempt to fix detected issues").action(async (options) => {
1311
+ try {
1312
+ const validatedOptions = validateCommandOptions(DiagnoseOptionsSchema, options);
1313
+ options = validatedOptions;
1314
+ } catch (error) {
1315
+ if (error instanceof z.ZodError) {
1316
+ console.error(chalk2.red("\nError: Invalid command options:"));
1317
+ console.error(formatValidationErrors(error));
1318
+ console.error(
1319
+ chalk2.gray('\nTip: Use "poetic config <subcommand> --help" for valid options')
1320
+ );
1321
+ throw new ExitCodeError(1);
1322
+ }
1323
+ throw error;
1324
+ }
1325
+ try {
1326
+ console.log(chalk2.bold.blue("\nConfiguration Diagnostics\n"));
1327
+ const configManager = new ConfigManager();
1328
+ const diagnostics = await configManager.getDiagnostics();
1329
+ console.log(chalk2.bold("Configuration Paths:"));
1330
+ for (const [name, info] of Object.entries(diagnostics.paths)) {
1331
+ const status = info.exists ? chalk2.green("OK") : chalk2.red("Error");
1332
+ let writable = "";
1333
+ if (info.writable !== void 0) {
1334
+ writable = info.writable ? chalk2.green("(writable)") : chalk2.red("(read-only)");
1335
+ }
1336
+ console.log(
1337
+ ` ${status} ${name}: ${chalk2.gray(info.exists ? "exists" : "missing")} ${writable}`
1338
+ );
1339
+ }
1340
+ console.log();
1341
+ console.log(chalk2.bold("Configuration Cache:"));
1342
+ console.log(` Enabled: ${chalk2.cyan(diagnostics.cache.enabled ? "Yes" : "No")}`);
1343
+ console.log(` Size: ${chalk2.cyan(diagnostics.cache.size)} entries`);
1344
+ if (diagnostics.cache.entries.length > 0) {
1345
+ console.log(" Recent entries:");
1346
+ diagnostics.cache.entries.slice(0, 5).forEach((entry) => {
1347
+ console.log(` ${chalk2.gray(entry.key)} (${chalk2.cyan(`${entry.age}ms ago`)})`);
1348
+ });
1349
+ }
1350
+ console.log();
1351
+ console.log(chalk2.bold("Configuration Validation:"));
1352
+ if (diagnostics.validation.isValid) {
1353
+ console.log(chalk2.green(" OK Configuration is valid"));
1354
+ } else {
1355
+ console.log(chalk2.red(" Error Configuration has issues"));
1356
+ console.log(` Errors: ${chalk2.red(diagnostics.validation.errors.length)}`);
1357
+ console.log(` Warnings: ${chalk2.yellow(diagnostics.validation.warnings.length)}`);
1358
+ }
1359
+ console.log();
1360
+ console.log(chalk2.bold("Performance Metrics:"));
1361
+ console.log(
1362
+ ` Average Load Time: ${chalk2.cyan(`${diagnostics.performance.avgLoadTime}ms`)}`
1363
+ );
1364
+ console.log(` Cache Hit Rate: ${chalk2.cyan(`${diagnostics.performance.cacheHitRate}%`)}`);
1365
+ console.log();
1366
+ const systemDiagnostics = await getConfigDiagnostics();
1367
+ console.log(chalk2.bold("Source Loading:"));
1368
+ console.log(` Load Time: ${chalk2.cyan(`${systemDiagnostics.loadTime}ms`)}`);
1369
+ console.log(` Sources Found: ${chalk2.cyan(systemDiagnostics.summary.loadedSources)}`);
1370
+ console.log(` Valid Sources: ${chalk2.cyan(systemDiagnostics.summary.validSources)}`);
1371
+ console.log();
1372
+ if (options.fix) {
1373
+ console.log(chalk2.bold.yellow("Attempting to auto-fix configuration issues..."));
1374
+ const configManager2 = new ConfigManager();
1375
+ const config = await configManager2.loadConfig();
1376
+ const { autoFixConfig } = await import("./config-validator-KKOHOW7O.js");
1377
+ const fixResult = autoFixConfig(config.config);
1378
+ if (fixResult.changes.length > 0) {
1379
+ console.log(chalk2.green("Fixed issues:"));
1380
+ fixResult.changes.forEach((change) => {
1381
+ console.log(` OK ${change}`);
1382
+ });
1383
+ const saveResult = await configManager2.writeProjectConfig(fixResult.fixedConfig);
1384
+ if (saveResult.success) {
1385
+ console.log(chalk2.green("\nOK: Configuration saved successfully."));
1386
+ } else {
1387
+ console.log(chalk2.red(`
1388
+ Error: Failed to save configuration: ${saveResult.error}`));
1389
+ }
1390
+ } else {
1391
+ console.log(chalk2.gray("No auto-fixable issues detected."));
1392
+ }
1393
+ if (fixResult.remainingErrors.length > 0) {
1394
+ console.log(chalk2.yellow("\nRemaining issues that require manual fix:"));
1395
+ fixResult.remainingErrors.forEach((error) => {
1396
+ console.log(
1397
+ ` Warning: ${sanitizeString(error.path.join("."))}: ${sanitizeString(error.message)}`
1398
+ );
1399
+ });
1400
+ }
1401
+ }
1402
+ } catch (error) {
1403
+ if (error instanceof ExitCodeError) throw error;
1404
+ if (renderConfigReadFailure(error)) throw new ExitCodeError(1);
1405
+ console.error(chalk2.red("Error running diagnostics:"), errorMessage(error));
1406
+ throw new ExitCodeError(1);
1407
+ }
1408
+ });
1409
+ configCommand.command("reset").description("Reset configuration to defaults").option("--level <level>", "Reset level: user, project, or all", "project").option("--backup", "Create backup before resetting").action(async (options) => {
1410
+ try {
1411
+ const validatedOptions = validateCommandOptions(ResetOptionsSchema, options);
1412
+ options = validatedOptions;
1413
+ } catch (error) {
1414
+ if (error instanceof z.ZodError) {
1415
+ console.error(chalk2.red("\nError: Invalid command options:"));
1416
+ console.error(formatValidationErrors(error));
1417
+ console.error(
1418
+ chalk2.gray('\nTip: Use "poetic config <subcommand> --help" for valid options')
1419
+ );
1420
+ throw new ExitCodeError(1);
1421
+ }
1422
+ throw error;
1423
+ }
1424
+ const configManager = new ConfigManager();
1425
+ try {
1426
+ console.log(chalk2.bold.yellow(`
1427
+ Resetting configuration (level: ${options.level})
1428
+ `));
1429
+ if (options.backup) {
1430
+ const backup = redactConfigValueForDisplay("", await configManager.exportConfig(true));
1431
+ const backupPath = `poetic-config-backup-${Date.now()}.json`;
1432
+ writeFileSync2(backupPath, JSON.stringify(backup, null, 2));
1433
+ console.log(chalk2.green(`OK Backup created: ${backupPath}`));
1434
+ }
1435
+ const result = await configManager.resetToDefaults(
1436
+ options.level
1437
+ );
1438
+ if (result.success) {
1439
+ console.log(chalk2.green("OK: Configuration reset successfully."));
1440
+ console.log(chalk2.gray('\nRun "poetic init" to reconfigure with optimal defaults.'));
1441
+ } else {
1442
+ console.log(chalk2.red(`Error: Failed to reset configuration: ${result.error}`));
1443
+ throw new ExitCodeError(1);
1444
+ }
1445
+ } catch (error) {
1446
+ if (error instanceof ExitCodeError) throw error;
1447
+ console.error(chalk2.red("Error resetting configuration:"), errorMessage(error));
1448
+ throw new ExitCodeError(1);
1449
+ }
1450
+ });
1451
+ configCommand.command("export").description("Export configuration to file").option("-o, --output <file>", "Output file path", "poetic-config-export.json").option("--include-preferences", "Include user preferences in export").action(async (options) => {
1452
+ try {
1453
+ const validatedOptions = validateCommandOptions(ExportOptionsSchema, options);
1454
+ options = validatedOptions;
1455
+ } catch (error) {
1456
+ if (error instanceof z.ZodError) {
1457
+ console.error(chalk2.red("\nError: Invalid command options:"));
1458
+ console.error(formatValidationErrors(error));
1459
+ console.error(
1460
+ chalk2.gray('\nTip: Use "poetic config <subcommand> --help" for valid options')
1461
+ );
1462
+ throw new ExitCodeError(1);
1463
+ }
1464
+ throw error;
1465
+ }
1466
+ const configManager = new ConfigManager();
1467
+ try {
1468
+ const exportData = redactConfigValueForDisplay(
1469
+ "",
1470
+ await configManager.exportConfig(options.includePreferences)
1471
+ );
1472
+ writeFileSync2(options.output, JSON.stringify(exportData, null, 2));
1473
+ console.log(chalk2.bold.green(`
1474
+ OK: Configuration exported to: ${options.output}`));
1475
+ console.log(chalk2.gray(` Exported at: ${exportData.metadata.exportedAt}`));
1476
+ console.log(chalk2.gray(` Version: ${exportData.metadata.version}`));
1477
+ if (options.includePreferences) {
1478
+ console.log(chalk2.gray(" User preferences: included"));
1479
+ }
1480
+ } catch (error) {
1481
+ if (error instanceof ExitCodeError) throw error;
1482
+ if (renderConfigReadFailure(error)) throw new ExitCodeError(1);
1483
+ console.error(chalk2.red("Error exporting configuration:"), errorMessage(error));
1484
+ throw new ExitCodeError(1);
1485
+ }
1486
+ });
1487
+ configCommand.command("import").description("Import configuration from file").argument("<file>", "Configuration file to import").option("--import-preferences", "Import user preferences from file").action(async (file, options) => {
1488
+ try {
1489
+ validateCommandOptions(ExistingFilePathSchema, file);
1490
+ const validatedOptions = validateCommandOptions(ImportOptionsSchema, options);
1491
+ options = validatedOptions;
1492
+ } catch (error) {
1493
+ if (error instanceof z.ZodError) {
1494
+ console.error(chalk2.red("\nError: Invalid command options:"));
1495
+ console.error(formatValidationErrors(error));
1496
+ console.error(
1497
+ chalk2.gray('\nTip: Use "poetic config <subcommand> --help" for valid options')
1498
+ );
1499
+ throw new ExitCodeError(1);
1500
+ }
1501
+ throw error;
1502
+ }
1503
+ const configManager = new ConfigManager();
1504
+ try {
1505
+ if (!existsSync3(file)) {
1506
+ console.error(chalk2.red(`Configuration file not found: ${file}`));
1507
+ throw new ExitCodeError(1);
1508
+ }
1509
+ const importData = parseJsonWithContext(
1510
+ readFileSync3(file, "utf8"),
1511
+ `Config import (${file})`
1512
+ );
1513
+ const result = await configManager.importConfig(
1514
+ importData,
1515
+ options.importPreferences
1516
+ );
1517
+ if (result.success) {
1518
+ console.log(chalk2.bold.green(`
1519
+ OK: Configuration imported from: ${file}`));
1520
+ console.log(chalk2.gray("Configuration has been successfully applied."));
1521
+ } else {
1522
+ console.log(chalk2.red(`Error: Failed to import configuration: ${result.error}`));
1523
+ throw new ExitCodeError(1);
1524
+ }
1525
+ } catch (error) {
1526
+ if (error instanceof ExitCodeError) throw error;
1527
+ console.error(chalk2.red("Error importing configuration:"), errorMessage(error));
1528
+ throw new ExitCodeError(1);
1529
+ }
1530
+ });
1531
+ configCommand.command("precedence").description("Display configuration precedence order and current values").action(async () => {
1532
+ const configManager = new ConfigManager();
1533
+ try {
1534
+ const config = await configManager.loadConfig();
1535
+ const resolved = configManager.resolveExecutionConfig();
1536
+ console.log(chalk2.bold.blue("\nConfiguration Precedence\n"));
1537
+ console.log(chalk2.gray("Priority (highest to lowest):"));
1538
+ console.log(chalk2.gray(" 1. CLI flags (--model, --provider, --strategy, etc.)"));
1539
+ console.log(
1540
+ chalk2.gray(
1541
+ " 2. Environment variables (POETIC_DEFAULT_PROVIDER, POETIC_<PROVIDER>_DEFAULT_MODEL, etc.)"
1542
+ )
1543
+ );
1544
+ console.log(chalk2.gray(" 3. Active profile (~/.config/poetic/profiles/<name>.json)"));
1545
+ console.log(chalk2.gray(" 4. Project config (.poetic/config/poetic.config.jsonc)"));
1546
+ console.log(chalk2.gray(" 5. User config (~/.config/poetic/poetic.config.jsonc)"));
1547
+ console.log(chalk2.gray(" 6. Registry defaults (.poetic/config/providers.yaml)"));
1548
+ console.log(chalk2.gray(" 7. Hardcoded fallback"));
1549
+ console.log();
1550
+ console.log(chalk2.bold("Current Source Values:"));
1551
+ for (const source of config.sources.sort((a, b) => b.priority - a.priority)) {
1552
+ if (source.data && source.type !== "default") {
1553
+ console.log(chalk2.cyan(`${source.type.toUpperCase()} (priority: ${source.priority}):`));
1554
+ const configData = source.data;
1555
+ if (configData.defaults?.provider || configData.defaultProvider) {
1556
+ console.log(
1557
+ ` Default Provider: ${configData.defaults?.provider ?? configData.defaultProvider}`
1558
+ );
1559
+ }
1560
+ for (const [provider, providerConfig] of Object.entries(configData.providers ?? {})) {
1561
+ if (providerConfig && "model" in providerConfig && providerConfig.model) {
1562
+ console.log(` ${provider} Model: ${String(providerConfig.model)}`);
1563
+ }
1564
+ }
1565
+ console.log();
1566
+ }
1567
+ }
1568
+ console.log(chalk2.bold("Final Resolved Configuration:"));
1569
+ console.log(` Default Provider: ${chalk2.cyan(resolved.defaultProvider.value)}`);
1570
+ console.log(` Effective Model: ${chalk2.cyan(resolved.defaultModel.value)}`);
1571
+ console.log(` Default Strategy: ${chalk2.cyan(resolved.defaultStrategy.value)}`);
1572
+ } catch (error) {
1573
+ if (error instanceof ExitCodeError) throw error;
1574
+ if (renderConfigReadFailure(error)) throw new ExitCodeError(1);
1575
+ console.error(chalk2.red("Error showing precedence:"), errorMessage(error));
1576
+ throw new ExitCodeError(1);
1577
+ }
1578
+ });
1579
+ const aliasesCommand = new Command2("aliases").description(
1580
+ 'Manage user model aliases (stored in user config)\n\nExamples:\n poetic config aliases list\n poetic config aliases list --provider opencode\n poetic provider alias set opencode fast "openrouter/provider/model-name"'
1581
+ );
1582
+ aliasesCommand.command("list").description("List user model aliases (provider-scoped)").option("-p, --provider <provider>", "Filter to a single provider (e.g., opencode)").option("-j, --json", "Output as JSON").action(async (options) => {
1583
+ try {
1584
+ const configManager = new ConfigManager();
1585
+ const providers = await configManager.getConfigValue("providers", "user");
1586
+ const out = {};
1587
+ for (const [providerId, providerConfig] of Object.entries(providers ?? {})) {
1588
+ if (options.provider && providerId.toLowerCase() !== String(options.provider).toLowerCase())
1589
+ continue;
1590
+ if (!providerConfig || typeof providerConfig !== "object") continue;
1591
+ const aliases = providerConfig.aliases;
1592
+ const models = aliases && typeof aliases === "object" ? aliases.models : null;
1593
+ if (!models || typeof models !== "object") continue;
1594
+ const record = {};
1595
+ for (const [k, v] of Object.entries(models)) {
1596
+ if (typeof k !== "string" || typeof v !== "string") continue;
1597
+ record[k] = v;
1598
+ }
1599
+ if (Object.keys(record).length > 0) out[providerId] = record;
1600
+ }
1601
+ if (options.json) {
1602
+ console.log(JSON.stringify(out, null, 2));
1603
+ return;
1604
+ }
1605
+ const providersWithAliases = Object.keys(out);
1606
+ if (providersWithAliases.length === 0) {
1607
+ console.log(chalk2.yellow("No user model aliases found."));
1608
+ console.log(
1609
+ chalk2.gray(
1610
+ 'Tip: Use "poetic provider alias set <provider> <alias> <model>" or "poetic config set --scope user providers.<provider>.aliases.models.<alias> <model>".'
1611
+ )
1612
+ );
1613
+ return;
1614
+ }
1615
+ for (const providerId of providersWithAliases.sort()) {
1616
+ console.log(chalk2.bold(`${providerId}:`));
1617
+ const models = out[providerId] ?? {};
1618
+ for (const [aliasKey, modelId] of Object.entries(models).sort(
1619
+ ([a], [b]) => a.localeCompare(b)
1620
+ )) {
1621
+ console.log(` ${chalk2.cyan(aliasKey)} -> ${chalk2.gray(modelId)}`);
1622
+ }
1623
+ }
1624
+ } catch (error) {
1625
+ if (error instanceof ExitCodeError) throw error;
1626
+ console.error(chalk2.red("Error listing aliases:"), errorMessage(error));
1627
+ throw new ExitCodeError(1);
1628
+ }
1629
+ });
1630
+ configCommand.addCommand(aliasesCommand);
1631
+ configCommand.command("resolved").description("Show resolved configuration with source attribution").option("-j, --json", "Output as JSON").option("-p, --provider <provider>", "Show resolved model for specific provider").option("--role <role>", "Show a role-scoped model decision (currently: executor)").option("--summary", "Output compact planning-critical fields only").option("--compete", "Show compete defaults with source attribution per tier").option("--optimization", "Show fast/best/cheap optimization recipes and provider availability").action(async (options) => {
1632
+ try {
1633
+ if (options.role && (options.summary || options.compete || options.optimization)) {
1634
+ writeConfigError(
1635
+ chalk2.red(
1636
+ "Error: --role cannot be combined with --summary, --compete, or --optimization"
1637
+ )
1638
+ );
1639
+ throw new ExitCodeError(1);
1640
+ }
1641
+ if (options.optimization) {
1642
+ const { resolveOptimizationConfig, summarizeOptimizationConfig } = await import("./optimization-config-resolver-O6WKR47U.js");
1643
+ const resolved2 = await resolveOptimizationConfig(process.cwd());
1644
+ const summary = summarizeOptimizationConfig(resolved2);
1645
+ if (options.json) {
1646
+ console.log(JSON.stringify(redactConfigValueForDisplay("", summary), null, 2));
1647
+ return;
1648
+ }
1649
+ console.log(chalk2.bold.blue("\nOptimization recipes (resolved):\n"));
1650
+ console.log(` Source: ${chalk2.cyan(summary.source)}`);
1651
+ console.log(
1652
+ ` Available: ${chalk2.cyan(summary.availableProviders.join(", ") || "(none)")}`
1653
+ );
1654
+ if (summary.unavailableProviders.length > 0) {
1655
+ console.log(` Unavailable: ${chalk2.gray(summary.unavailableProviders.join(", "))}`);
1656
+ }
1657
+ const recipes = summary.recipes.optimization;
1658
+ if (recipes) {
1659
+ const speedProviders = recipes.speed?.providerPreference?.join(", ") ?? "(default)";
1660
+ const costProviders = recipes.cost?.providerPreference?.join(", ") ?? "(default)";
1661
+ const qualityVariants = recipes.quality?.variants?.map(
1662
+ (variant) => `${variant.provider}:${variant.model ?? variant.modelRole ?? "default"}:${variant.strategy}:${variant.mode ?? "local"}`
1663
+ ).join(", ") ?? "(default)";
1664
+ console.log();
1665
+ console.log(` speed: ${chalk2.cyan(speedProviders)}`);
1666
+ console.log(` quality: ${chalk2.cyan(qualityVariants)}`);
1667
+ console.log(` cost: ${chalk2.cyan(costProviders)}`);
1668
+ console.log(
1669
+ ` autoloop: ${chalk2.cyan(recipes.autoloop?.semanticVerifierProviderPreference?.join(", ") ?? "(default)")}`
1670
+ );
1671
+ }
1672
+ console.log();
1673
+ console.log(
1674
+ chalk2.gray(
1675
+ "Note: optimization.* applies to poetic fast/best/cheap and poetic run --optimize. Bare poetic compete keeps its compete resolver defaults; sprint/flywheel execution keeps DomainAnalyzer/RoutingPlanner routing."
1676
+ )
1677
+ );
1678
+ console.log();
1679
+ return;
1680
+ }
1681
+ if (options.compete) {
1682
+ const competeResolved = await resolveCompeteConfig({}, { projectRoot: process.cwd() });
1683
+ if (options.json) {
1684
+ console.log(JSON.stringify(redactConfigValueForDisplay("", competeResolved), null, 2));
1685
+ return;
1686
+ }
1687
+ console.log(chalk2.bold.blue("\nCompete defaults (resolved):\n"));
1688
+ const pad = (s, n) => s.padEnd(n);
1689
+ const w = 20;
1690
+ const fmtSrc = (src) => chalk2.gray(`[${src}]`);
1691
+ console.log(
1692
+ ` ${pad("variants:", w)} ${chalk2.cyan(competeResolved.variants.join(", ") || "(auto-discovered)")} ${fmtSrc(competeResolved.sources.variants)}`
1693
+ );
1694
+ console.log(
1695
+ ` ${pad("judge:", w)} ${chalk2.cyan(competeResolved.judge)} ${fmtSrc(competeResolved.sources.judge)}`
1696
+ );
1697
+ if (competeResolved.judgeRun) {
1698
+ console.log(
1699
+ ` ${pad("judgeRun:", w)} ${chalk2.cyan(competeResolved.judgeRun)} ${fmtSrc(competeResolved.sources.judgeRun ?? competeResolved.sources.judge)}`
1700
+ );
1701
+ }
1702
+ if (competeResolved.judgePrimary) {
1703
+ console.log(
1704
+ ` ${pad("judgePrimary:", w)} ${chalk2.cyan(competeResolved.judgePrimary)} ${fmtSrc(competeResolved.sources.judgePrimary ?? competeResolved.sources.judge)}`
1705
+ );
1706
+ }
1707
+ console.log(
1708
+ ` ${pad("completionMode:", w)} ${chalk2.cyan(competeResolved.completionMode)} ${fmtSrc(competeResolved.sources.completionMode)}`
1709
+ );
1710
+ console.log(
1711
+ ` ${pad("timeout:", w)} ${chalk2.cyan(`${competeResolved.timeout}m`)} ${fmtSrc(competeResolved.sources.timeout)}`
1712
+ );
1713
+ console.log(
1714
+ ` ${pad("requireMinVariants:", w)} ${chalk2.cyan(String(competeResolved.requireMinVariants))} ${fmtSrc(competeResolved.sources.requireMinVariants)}`
1715
+ );
1716
+ console.log(
1717
+ ` ${pad("matrixEscalation:", w)} ${chalk2.cyan(`close<=${competeResolved.matrixEscalation?.closeCallMargin ?? 5}, borderline<=${competeResolved.matrixEscalation?.borderlineMargin ?? 7}, confidence<${competeResolved.matrixEscalation?.confidenceThreshold ?? 0.75}`)} ${fmtSrc(competeResolved.sources.matrixEscalation ?? "built-in")}`
1718
+ );
1719
+ const envOverrides = [];
1720
+ if (process.env.POETIC_COMPLETION_MODE?.trim()) {
1721
+ envOverrides.push(
1722
+ ` POETIC_COMPLETION_MODE=${process.env.POETIC_COMPLETION_MODE} \u2192 completionMode: ${competeResolved.completionMode}`
1723
+ );
1724
+ }
1725
+ const activeJudgeEnv = readJudgeTypeEnv();
1726
+ if (activeJudgeEnv?.trim()) {
1727
+ const legacyActive = process.env.POETIC_JUDGE_TYPE === void 0 && process.env.POETIC_JUDGE !== void 0;
1728
+ const label = legacyActive ? "POETIC_JUDGE (deprecated alias for POETIC_JUDGE_TYPE)" : "POETIC_JUDGE_TYPE";
1729
+ envOverrides.push(` ${label}=${activeJudgeEnv} \u2192 judge: ${competeResolved.judge}`);
1730
+ }
1731
+ if (process.env.POETIC_TIMEOUT_MS?.trim()) {
1732
+ const ms = parseInt(process.env.POETIC_TIMEOUT_MS, 10);
1733
+ if (!Number.isNaN(ms)) {
1734
+ envOverrides.push(
1735
+ ` POETIC_TIMEOUT_MS=${process.env.POETIC_TIMEOUT_MS} \u2192 timeout: ${Math.ceil(ms / 6e4)}m`
1736
+ );
1737
+ }
1738
+ }
1739
+ if (process.env.POETIC_JUDGE_RUN?.trim() || process.env.POETIC_AI_JUDGE_RUN?.trim()) {
1740
+ const key = process.env.POETIC_JUDGE_RUN?.trim() ? "POETIC_JUDGE_RUN" : "POETIC_AI_JUDGE_RUN";
1741
+ envOverrides.push(
1742
+ ` ${key}=${process.env[key]} \u2192 judgeRun: ${competeResolved.judgeRun ?? "ai"}`
1743
+ );
1744
+ }
1745
+ if (process.env.POETIC_JUDGE_PRIMARY?.trim() || process.env.POETIC_AI_JUDGE_PRIMARY?.trim()) {
1746
+ const key = process.env.POETIC_JUDGE_PRIMARY?.trim() ? "POETIC_JUDGE_PRIMARY" : "POETIC_AI_JUDGE_PRIMARY";
1747
+ envOverrides.push(
1748
+ ` ${key}=${process.env[key]} \u2192 judgePrimary: ${competeResolved.judgePrimary ?? "ai"}`
1749
+ );
1750
+ }
1751
+ const hasMatrixEscalationEnvOverride = readEnv(POETIC_MATRIX_CLOSE_CALL_MARGIN).source === "env" || readEnv(POETIC_MATRIX_BORDERLINE_MARGIN).source === "env" || readEnv(POETIC_MATRIX_CONFIDENCE_THRESHOLD).source === "env";
1752
+ if (hasMatrixEscalationEnvOverride) {
1753
+ envOverrides.push(
1754
+ ` POETIC_MATRIX_* \u2192 matrixEscalation: close<=${competeResolved.matrixEscalation?.closeCallMargin ?? 5}, borderline<=${competeResolved.matrixEscalation?.borderlineMargin ?? 7}, confidence<${competeResolved.matrixEscalation?.confidenceThreshold ?? 0.75}`
1755
+ );
1756
+ }
1757
+ if (envOverrides.length > 0) {
1758
+ console.log("\nActive POETIC_* overrides:");
1759
+ for (const line of envOverrides) {
1760
+ console.log(chalk2.yellow(line));
1761
+ }
1762
+ }
1763
+ console.log();
1764
+ return;
1765
+ }
1766
+ const resolved = resolveConfig(void 0, process.cwd(), { strictSynthesisModel: false });
1767
+ if (options.summary && (options.provider || options.role)) {
1768
+ console.error(chalk2.red("Error: --summary cannot be combined with --provider or --role"));
1769
+ throw new ExitCodeError(1);
1770
+ }
1771
+ if (options.summary) {
1772
+ const enabledProviders = ProviderRegistry.getEnabledProviders().map((p) => p.id);
1773
+ const summary = {
1774
+ provider: resolved.defaultProvider.value,
1775
+ model: resolved.defaultModel.value,
1776
+ strategy: resolved.defaultStrategy.value,
1777
+ routingPolicy: resolved.decompositionRoutingPolicy.value,
1778
+ blockerMode: resolved.planExecute.blockerMode.value,
1779
+ transport: resolved.providerExecutionTransport.current.value,
1780
+ judge: {
1781
+ type: resolved.judge.type.value,
1782
+ model: resolved.judge.model.value
1783
+ },
1784
+ availableProviders: enabledProviders
1785
+ };
1786
+ if (options.json) {
1787
+ console.log(JSON.stringify(redactSensitiveConfig(summary), null, 2));
1788
+ } else {
1789
+ console.log(chalk2.bold.blue("\nResolved Config Summary\n"));
1790
+ console.log(formatResolvedConfigSummaryLine(summary));
1791
+ console.log();
1792
+ console.log(` Provider: ${chalk2.cyan(summary.provider)}`);
1793
+ console.log(` Model: ${chalk2.cyan(summary.model)}`);
1794
+ console.log(` Strategy: ${chalk2.cyan(summary.strategy)}`);
1795
+ console.log(` Routing: ${chalk2.cyan(summary.routingPolicy)}`);
1796
+ console.log(` Blockers: ${chalk2.cyan(summary.blockerMode)}`);
1797
+ console.log(` Transport: ${chalk2.cyan(summary.transport)}`);
1798
+ console.log(
1799
+ ` Judge: ${chalk2.cyan(`${summary.judge.type} (${summary.judge.model})`)}`
1800
+ );
1801
+ console.log(` Available: ${chalk2.cyan(summary.availableProviders.join(", "))}`);
1802
+ console.log();
1803
+ }
1804
+ return;
1805
+ }
1806
+ if (options.role) {
1807
+ if (options.role !== "executor") {
1808
+ writeConfigError(chalk2.red(`Error: Unsupported role: ${options.role}`));
1809
+ throw new ExitCodeError(1);
1810
+ }
1811
+ if (!options.provider) {
1812
+ writeConfigError(chalk2.red("Error: --role requires --provider"));
1813
+ throw new ExitCodeError(1);
1814
+ }
1815
+ const normalizedProvider = normalizeEngineId(String(options.provider));
1816
+ if (!resolved.providerModels[normalizedProvider]) {
1817
+ if (options.json) {
1818
+ renderJsonError(
1819
+ new ValidationError(`Unknown provider: ${options.provider}`, {
1820
+ provider: options.provider
1821
+ })
1822
+ );
1823
+ throw new ExitCodeError(1);
1824
+ }
1825
+ writeConfigError(chalk2.red(`Unknown provider: ${options.provider}`));
1826
+ throw new ExitCodeError(1);
1827
+ }
1828
+ const query = await buildResolvedExecutorModelQuery(normalizedProvider, process.cwd());
1829
+ if (options.json) {
1830
+ renderJsonResult(redactConfigValueForDisplay("", query));
1831
+ } else {
1832
+ const model = query.model;
1833
+ writeConfigLine(`roles.executor.provider: ${normalizedProvider}`);
1834
+ writeConfigLine(`roles.executor.model.input: ${String(model.input)}`);
1835
+ writeConfigLine(`roles.executor.model.effective: ${String(model.effective)}`);
1836
+ writeConfigLine(`roles.executor.model.source: ${String(model.source)}`);
1837
+ writeConfigLine(`roles.executor.model.discovery: ${String(model.discoveryStatus)}`);
1838
+ writeConfigLine(`roles.executor.model.emitArg: ${String(model.emitModelArg)}`);
1839
+ }
1840
+ return;
1841
+ }
1842
+ if (options.provider) {
1843
+ const normalizedProvider = normalizeEngineId(String(options.provider));
1844
+ const providerModel = resolved.providerModels[normalizedProvider];
1845
+ if (!providerModel) {
1846
+ if (options.json) {
1847
+ renderJsonError(
1848
+ new ValidationError(`Unknown provider: ${options.provider}`, {
1849
+ provider: options.provider
1850
+ })
1851
+ );
1852
+ throw new ExitCodeError(1);
1853
+ }
1854
+ console.error(chalk2.red(`Unknown provider: ${options.provider}`));
1855
+ throw new ExitCodeError(1);
1856
+ }
1857
+ if (options.json) {
1858
+ console.log(
1859
+ JSON.stringify(
1860
+ redactConfigValueForDisplay(normalizedProvider, providerModel),
1861
+ null,
1862
+ 2
1863
+ )
1864
+ );
1865
+ } else {
1866
+ console.log(formatResolvedValue(providerModel));
1867
+ }
1868
+ return;
1869
+ }
1870
+ const roles = resolveExecutionRoles({ cwd: process.cwd() });
1871
+ if (options.json) {
1872
+ const executionPreview2 = await buildExecutionPreview(resolved);
1873
+ console.log(
1874
+ JSON.stringify(
1875
+ redactConfigValueForDisplay("", { ...resolved, roles, executionPreview: executionPreview2 }),
1876
+ null,
1877
+ 2
1878
+ )
1879
+ );
1880
+ return;
1881
+ }
1882
+ console.log(chalk2.bold.blue("\nResolved Configuration\n"));
1883
+ console.log(getConfigSummary());
1884
+ const executionPreview = await buildExecutionPreview(resolved);
1885
+ console.log(chalk2.bold.blue("Execution Preview\n"));
1886
+ console.log(` run.provider: ${chalk2.cyan(executionPreview.run.provider)}`);
1887
+ console.log(` run.model: ${chalk2.cyan(executionPreview.run.model)}`);
1888
+ console.log(` run.strategy: ${chalk2.cyan(executionPreview.run.strategy)}`);
1889
+ console.log(` run.transport: ${chalk2.cyan(executionPreview.run.transport)}`);
1890
+ console.log(
1891
+ ` run.judge: ${chalk2.cyan(`${executionPreview.run.judge.type}; ${executionPreview.run.judge.provider}; ${executionPreview.run.judge.model}`)}`
1892
+ );
1893
+ if ("error" in executionPreview.compete) {
1894
+ console.log(` compete: ${chalk2.yellow(executionPreview.compete.error)}`);
1895
+ } else {
1896
+ const compete = executionPreview.compete;
1897
+ console.log(
1898
+ ` compete.variants: ${chalk2.cyan(compete.variants.join(", "))} ${chalk2.gray(`[${compete.sources.variants}]`)}`
1899
+ );
1900
+ console.log(
1901
+ ` compete.judge: ${chalk2.cyan(compete.judge)} ${chalk2.gray(`[${compete.sources.judge}]`)}`
1902
+ );
1903
+ if (compete.judgeRun) {
1904
+ console.log(
1905
+ ` compete.judgeRun: ${chalk2.cyan(compete.judgeRun)} ${chalk2.gray(`[${compete.sources.judgeRun ?? compete.sources.judge}]`)}`
1906
+ );
1907
+ }
1908
+ }
1909
+ console.log(
1910
+ ` env.overrides: ${chalk2.cyan(executionPreview.envOverrides.length > 0 ? executionPreview.envOverrides.join(", ") : "none")}`
1911
+ );
1912
+ printResolvedRoles(roles);
1913
+ console.log();
1914
+ } catch (error) {
1915
+ if (error instanceof ExitCodeError) throw error;
1916
+ if (renderConfigReadFailure(error, Boolean(options.json))) throw new ExitCodeError(1);
1917
+ console.error(chalk2.red("Error resolving configuration:"), errorMessage(error));
1918
+ throw new ExitCodeError(1);
1919
+ }
1920
+ });
1921
+ configCommand.command("set").description("Set configuration value using dot-notation path").argument(
1922
+ "<path>",
1923
+ "Config path (e.g., defaults.provider, automation.flywheel.merge.biomeRepair)"
1924
+ ).argument("<value>", "Value to set").option("--scope <scope>", "Configuration scope: user or project", "project").action(async (path2, value, options) => {
1925
+ try {
1926
+ const scope = options.scope;
1927
+ if (scope !== "user" && scope !== "project") {
1928
+ console.error(chalk2.red(`Invalid scope: ${scope}. Use 'user' or 'project'.`));
1929
+ throw new ExitCodeError(1);
1930
+ }
1931
+ const configManager = new ConfigManager();
1932
+ const result = await configManager.setConfigValue(path2, value, scope);
1933
+ if (result.success) {
1934
+ console.log(
1935
+ chalk2.green(`OK: Set ${path2} = ${formatConfigSetValueForDisplay(path2, value)}`)
1936
+ );
1937
+ console.log(chalk2.gray(` Scope: ${scope}`));
1938
+ if (result.previousValue !== void 0) {
1939
+ console.log(
1940
+ chalk2.gray(
1941
+ ` Previous: ${formatConfigSetValueForDisplay(path2, result.previousValue)}`
1942
+ )
1943
+ );
1944
+ }
1945
+ } else {
1946
+ console.error(chalk2.red(`Error: Failed to set configuration: ${result.error}`));
1947
+ throw new ExitCodeError(1);
1948
+ }
1949
+ } catch (error) {
1950
+ if (error instanceof ExitCodeError) throw error;
1951
+ console.error(chalk2.red("Error setting configuration:"), errorMessage(error));
1952
+ throw new ExitCodeError(1);
1953
+ }
1954
+ });
1955
+ configCommand.command("get").description("Get configuration value using dot-notation path").argument("<path>", "Config path (e.g., defaults.provider, execution.defaultTimeout)").option("--scope <scope>", "Configuration scope: user or project", "project").option("-j, --json", "Output as JSON").action(async (path2, options) => {
1956
+ try {
1957
+ const scope = options.scope;
1958
+ if (scope !== "user" && scope !== "project") {
1959
+ console.error(chalk2.red(`Invalid scope: ${scope}. Use 'user' or 'project'.`));
1960
+ throw new ExitCodeError(1);
1961
+ }
1962
+ const configManager = new ConfigManager();
1963
+ const value = await configManager.getConfigValue(path2, scope);
1964
+ if (options.json) {
1965
+ console.log(JSON.stringify(buildConfigGetJsonPayload(path2, scope, value), null, 2));
1966
+ } else if (value === void 0) {
1967
+ await printConfigScopeMiss(
1968
+ path2,
1969
+ scope,
1970
+ (configPath, configScope) => configManager.getConfigValue(configPath, configScope)
1971
+ );
1972
+ } else {
1973
+ console.log(chalk2.cyan(`${path2}`), "=", formatConfigGetValueForDisplay(path2, value));
1974
+ }
1975
+ } catch (error) {
1976
+ if (error instanceof ExitCodeError) throw error;
1977
+ if (renderConfigReadFailure(error, Boolean(options.json))) throw new ExitCodeError(1);
1978
+ console.error(chalk2.red("Error getting configuration:"), errorMessage(error));
1979
+ throw new ExitCodeError(1);
1980
+ }
1981
+ });
1982
+ const userCommand = new Command2("user").description("Manage user-scope configuration values");
1983
+ userCommand.command("set").description("Set a user-scope configuration value using dot-notation path").argument("<path>", "Config path (e.g., defaults.provider)").argument("<value>", "Value to set").action(async (path2, value) => {
1984
+ try {
1985
+ const configManager = new ConfigManager();
1986
+ const result = await configManager.setConfigValue(path2, value, "user");
1987
+ if (result.success) {
1988
+ console.log(
1989
+ chalk2.green(`OK: Set ${path2} = ${formatConfigSetValueForDisplay(path2, value)}`)
1990
+ );
1991
+ console.log(chalk2.gray(" Scope: user"));
1992
+ if (result.previousValue !== void 0) {
1993
+ console.log(
1994
+ chalk2.gray(
1995
+ ` Previous: ${formatConfigSetValueForDisplay(path2, result.previousValue)}`
1996
+ )
1997
+ );
1998
+ }
1999
+ return;
2000
+ }
2001
+ console.error(chalk2.red(`Error: Failed to set configuration: ${result.error}`));
2002
+ throw new ExitCodeError(1);
2003
+ } catch (error) {
2004
+ if (error instanceof ExitCodeError) throw error;
2005
+ console.error(chalk2.red("Error setting configuration:"), errorMessage(error));
2006
+ throw new ExitCodeError(1);
2007
+ }
2008
+ });
2009
+ userCommand.command("get").description("Get a user-scope configuration value using dot-notation path").argument("<path>", "Config path (e.g., defaults.provider)").option("-j, --json", "Output as JSON").action(async (path2, options) => {
2010
+ try {
2011
+ const configManager = new ConfigManager();
2012
+ const value = await configManager.getConfigValue(path2, "user");
2013
+ if (options.json) {
2014
+ console.log(JSON.stringify(buildConfigGetJsonPayload(path2, "user", value), null, 2));
2015
+ } else if (value === void 0) {
2016
+ await printConfigScopeMiss(
2017
+ path2,
2018
+ "user",
2019
+ (configPath, configScope) => configManager.getConfigValue(configPath, configScope)
2020
+ );
2021
+ } else {
2022
+ console.log(chalk2.cyan(`${path2}`), "=", formatConfigGetValueForDisplay(path2, value));
2023
+ }
2024
+ } catch (error) {
2025
+ if (error instanceof ExitCodeError) throw error;
2026
+ console.error(chalk2.red("Error getting configuration:"), errorMessage(error));
2027
+ throw new ExitCodeError(1);
2028
+ }
2029
+ });
2030
+ configCommand.addCommand(userCommand);
2031
+ configCommand.command("cleanup").description("Clean up configuration artifacts").option("--backups", "Remove old backup files (keeps last 3)").option("--dry-run", "Show what would be deleted without actually deleting").action(async (options) => {
2032
+ try {
2033
+ const { existsSync: existsSync4, readdirSync, unlinkSync, statSync: statSync2 } = await import("fs");
2034
+ const { join: join2 } = await import("path");
2035
+ console.log(chalk2.bold.blue("\nConfiguration Cleanup\n"));
2036
+ if (options.backups) {
2037
+ const configDir = getConfigPaths(process.cwd()).projectConfigDir;
2038
+ if (!existsSync4(configDir)) {
2039
+ console.log(chalk2.yellow("No .poetic/config directory found."));
2040
+ return;
2041
+ }
2042
+ const files = readdirSync(configDir);
2043
+ const backupFiles = files.filter((f) => f.startsWith("poetic.config.backup.")).map((f) => ({
2044
+ name: f,
2045
+ path: join2(configDir, f),
2046
+ mtime: statSync2(join2(configDir, f)).mtime.getTime()
2047
+ })).sort((a, b) => b.mtime - a.mtime);
2048
+ if (backupFiles.length === 0) {
2049
+ console.log(chalk2.green("No backup files found."));
2050
+ return;
2051
+ }
2052
+ const toDelete = backupFiles.slice(3);
2053
+ const toKeep = backupFiles.slice(0, 3);
2054
+ console.log(chalk2.gray(`Found ${backupFiles.length} backup files.`));
2055
+ console.log(chalk2.green(`Keeping ${toKeep.length} most recent:`));
2056
+ for (const f of toKeep) {
2057
+ console.log(chalk2.gray(` OK ${f.name}`));
2058
+ }
2059
+ if (toDelete.length === 0) {
2060
+ console.log(chalk2.green("\nNo files to delete."));
2061
+ return;
2062
+ }
2063
+ console.log(chalk2.yellow(`
2064
+ Deleting ${toDelete.length} old backups:`));
2065
+ for (const f of toDelete) {
2066
+ console.log(chalk2.gray(` Error ${f.name}`));
2067
+ if (!options.dryRun) {
2068
+ unlinkSync(f.path);
2069
+ }
2070
+ }
2071
+ if (options.dryRun) {
2072
+ console.log(chalk2.yellow("\n(Dry run - no files were actually deleted)"));
2073
+ } else {
2074
+ console.log(chalk2.green(`
2075
+ OK: Deleted ${toDelete.length} backup files.`));
2076
+ }
2077
+ } else {
2078
+ console.log(chalk2.gray("Use --backups to remove old backup files."));
2079
+ console.log(chalk2.gray("Example: poetic config cleanup --backups"));
2080
+ }
2081
+ } catch (error) {
2082
+ if (error instanceof ExitCodeError) throw error;
2083
+ console.error(chalk2.red("Error during cleanup:"), errorMessage(error));
2084
+ throw new ExitCodeError(1);
2085
+ }
2086
+ });
2087
+ configCommand.command("explain [key]").description("Show env-registry key details (type, default, current value, source)").option("-j, --json", "Output as JSON").option(
2088
+ "--category <name>",
2089
+ "Filter to one category (core/provider/judge/feature/orchestrator/telemetry/sandbox/autoloop/test/worktree/repair)"
2090
+ ).option("--show-deprecated", "Include deprecated keys (hidden by default)").option("--source <source>", "Filter by source: env | default | unset").action(
2091
+ async (key, options) => {
2092
+ try {
2093
+ const { explainEnvKey, explainAllEnvKeys } = await import("./config-explain-TNILDEVJ.js");
2094
+ if (key !== void 0) {
2095
+ const result = explainEnvKey(key);
2096
+ if (result === void 0) {
2097
+ if (options.json) {
2098
+ renderJsonError(
2099
+ new ValidationError(`Unknown env key: ${key}`, {
2100
+ key
2101
+ })
2102
+ );
2103
+ throw new ExitCodeError(1);
2104
+ }
2105
+ console.error(`Error: Unknown env key: ${key}`);
2106
+ throw new ExitCodeError(1);
2107
+ }
2108
+ if (options.json) {
2109
+ console.log(JSON.stringify(redactConfigValueForDisplay("", result), null, 2));
2110
+ return;
2111
+ }
2112
+ printExplainRow(result);
2113
+ return;
2114
+ }
2115
+ const results = explainAllEnvKeys({
2116
+ category: options.category,
2117
+ showDeprecated: options.showDeprecated ?? false,
2118
+ source: options.source
2119
+ });
2120
+ if (options.json) {
2121
+ console.log(JSON.stringify(redactConfigValueForDisplay("", results), null, 2));
2122
+ return;
2123
+ }
2124
+ for (const result of results) {
2125
+ printExplainRow(result);
2126
+ }
2127
+ } catch (error) {
2128
+ if (error instanceof ExitCodeError) throw error;
2129
+ console.error(chalk2.red("Error running config explain:"), errorMessage(error));
2130
+ throw new ExitCodeError(1);
2131
+ }
2132
+ }
2133
+ );
2134
+ configCommand.command("audit").description(
2135
+ "Audit configuration: report direct env reads, unregistered vars, deprecated aliases, and migration risks"
2136
+ ).option("--fix-plan", "Output a structured fix plan").option("-j, --json", "JSON output").option("--severity <level>", "Filter findings (error|warn|info)").action(async (options) => {
2137
+ try {
2138
+ const { runAudit, formatAuditPlain, formatAuditJson } = await import("./config-audit-EL3GHXS7.js");
2139
+ let findings = await runAudit({ cwd: process.cwd() });
2140
+ if (options.severity) {
2141
+ const level = options.severity;
2142
+ if (!["error", "warn", "info"].includes(level)) {
2143
+ console.error(`Error: Invalid severity filter "${level}". Use error, warn, or info.`);
2144
+ throw new ExitCodeError(1);
2145
+ }
2146
+ findings = findings.filter((f) => f.severity === level);
2147
+ }
2148
+ const errors = findings.filter((f) => f.severity === "error").length;
2149
+ if (options.json) {
2150
+ console.log(formatAuditJson(findings));
2151
+ if (errors > 0) {
2152
+ throw new ExitCodeError(1);
2153
+ }
2154
+ return;
2155
+ }
2156
+ if (options.fixPlan) {
2157
+ console.log("Config audit fix plan\n");
2158
+ console.log(formatAuditPlain(findings));
2159
+ return;
2160
+ }
2161
+ const warns = findings.filter((f) => f.severity === "warn").length;
2162
+ const infos = findings.filter((f) => f.severity === "info").length;
2163
+ if (findings.length === 0) {
2164
+ console.log("OK: No audit findings.");
2165
+ return;
2166
+ }
2167
+ console.log(`Audit: ${errors} error(s), ${warns} warn(s), ${infos} info(s)`);
2168
+ for (const f of findings) {
2169
+ const loc = f.location?.path ? ` [${f.location.line ? `${f.location.path}:${f.location.line}` : f.location.path}]` : "";
2170
+ console.log(`[${f.severity}] ${f.title}${loc}`);
2171
+ }
2172
+ if (errors > 0) {
2173
+ throw new ExitCodeError(1);
2174
+ }
2175
+ } catch (error) {
2176
+ if (error instanceof ExitCodeError) throw error;
2177
+ console.error("Error running config audit:", errorMessage(error));
2178
+ throw new ExitCodeError(1);
2179
+ }
2180
+ });
2181
+ configCommand.addCommand(createConfigMigrateCommand());
2182
+ return configCommand;
2183
+ }
2184
+
2185
+ export {
2186
+ redactConfigValueForDisplay,
2187
+ formatConfigGetValueForDisplay,
2188
+ formatConfigSetValueForDisplay,
2189
+ buildConfigGetJsonPayload,
2190
+ buildConfigScopeMissLines,
2191
+ createConfigCommand
2192
+ };
2193
+ //# sourceMappingURL=chunk-2N42MS2Z.js.map