@hawkeyexl/manni 4.21.0 → 4.23.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 (316) hide show
  1. package/README.md +1 -1
  2. package/dist/{batch-C534YIAU.js → batch-DPYBMRVD.js} +21 -22
  3. package/dist/build-LEKUMGEC.js +36 -0
  4. package/dist/calibrate-TYONPNG4.js +42 -0
  5. package/dist/capture-2EPHIAZT.js +37 -0
  6. package/dist/check-ADCSXGBK.js +57 -0
  7. package/dist/check-HWEDHABD.js +30 -0
  8. package/dist/check-J2KQI7IW.js +33 -0
  9. package/dist/check-L5AUSTE6.js +57 -0
  10. package/dist/{check-LKPQPQWJ.js → check-SQVQE4E4.js} +23 -23
  11. package/dist/{chunk-D4QHRVDJ.js → chunk-2GPF4OEF.js} +3 -157
  12. package/dist/chunk-2GPF4OEF.js.map +1 -0
  13. package/dist/{chunk-IOJD2RFG.js → chunk-2MOXVM6H.js} +2 -2
  14. package/dist/{chunk-762MM6NA.js → chunk-2QK25SLZ.js} +4 -4
  15. package/dist/{chunk-HHJ2HFPP.js → chunk-2UJOQ6CB.js} +9 -9
  16. package/dist/{chunk-H5YWCCBO.js → chunk-3CBGLUJX.js} +3 -3
  17. package/dist/{chunk-E23KWEPL.js → chunk-3USSSKLA.js} +2 -2
  18. package/dist/{chunk-PTGXEZQD.js → chunk-3ZVRGBK6.js} +4 -4
  19. package/dist/{chunk-XI3BNZG4.js → chunk-5JXA75XB.js} +46 -7
  20. package/dist/chunk-5JXA75XB.js.map +1 -0
  21. package/dist/{chunk-IN5T22FP.js → chunk-6QNA7UX2.js} +2 -2
  22. package/dist/{chunk-CZIO37J5.js → chunk-6RENCXLC.js} +10 -5
  23. package/dist/chunk-6RENCXLC.js.map +1 -0
  24. package/dist/{chunk-WHVFHBL3.js → chunk-72UN462G.js} +11 -3
  25. package/dist/chunk-72UN462G.js.map +1 -0
  26. package/dist/{chunk-OWJLB2AF.js → chunk-76Y3JATE.js} +2 -2
  27. package/dist/chunk-7M3MBFG7.js +38 -0
  28. package/dist/chunk-7M3MBFG7.js.map +1 -0
  29. package/dist/{chunk-BHGFLRXM.js → chunk-7NSFGAAQ.js} +8 -7
  30. package/dist/chunk-7NSFGAAQ.js.map +1 -0
  31. package/dist/{chunk-3SFAB75L.js → chunk-AJCUKL43.js} +6 -6
  32. package/dist/{chunk-CREFJCWZ.js → chunk-AOLCEULZ.js} +8 -8
  33. package/dist/{chunk-Q76T6Y6X.js → chunk-AZKNB2T3.js} +3635 -3409
  34. package/dist/chunk-AZKNB2T3.js.map +1 -0
  35. package/dist/{chunk-2NGFDLIM.js → chunk-B4ECIBLF.js} +4 -4
  36. package/dist/{chunk-5UJKXOAD.js → chunk-B4POKRCS.js} +6 -6
  37. package/dist/chunk-BA7BQBWV.js +311 -0
  38. package/dist/chunk-BA7BQBWV.js.map +1 -0
  39. package/dist/{chunk-KBSTXL6L.js → chunk-BOCJTOKA.js} +4 -4
  40. package/dist/{chunk-CFMI74TP.js → chunk-BZ74YUYE.js} +2 -2
  41. package/dist/{chunk-NLJ3XIKT.js → chunk-C2QE4FSZ.js} +3 -3
  42. package/dist/{chunk-DENZLZ3Z.js → chunk-CLUUSZDY.js} +26 -17
  43. package/dist/chunk-CLUUSZDY.js.map +1 -0
  44. package/dist/{chunk-PACZEDOH.js → chunk-CWPRB7SA.js} +19 -15
  45. package/dist/chunk-CWPRB7SA.js.map +1 -0
  46. package/dist/{chunk-245W2Q7C.js → chunk-D4BGNAN5.js} +2 -2
  47. package/dist/{chunk-XBJKYXOR.js → chunk-DWUK6YNX.js} +11 -11
  48. package/dist/{chunk-MTCOBRCX.js → chunk-E75CMOR3.js} +4 -4
  49. package/dist/{chunk-TFVNEPMF.js → chunk-EAF4K7IK.js} +4 -4
  50. package/dist/{chunk-TFVNEPMF.js.map → chunk-EAF4K7IK.js.map} +1 -1
  51. package/dist/{chunk-KCWNJMSS.js → chunk-EBBJFXMX.js} +3 -3
  52. package/dist/{chunk-LWBNHK72.js → chunk-EPN67ZNX.js} +47 -29
  53. package/dist/chunk-EPN67ZNX.js.map +1 -0
  54. package/dist/{chunk-6XK3NTL5.js → chunk-FBIBR4CH.js} +35 -40
  55. package/dist/chunk-FBIBR4CH.js.map +1 -0
  56. package/dist/{chunk-5LE4NH3Z.js → chunk-FJYIPHWK.js} +6 -4
  57. package/dist/{chunk-5LE4NH3Z.js.map → chunk-FJYIPHWK.js.map} +1 -1
  58. package/dist/{chunk-A4QNKEX4.js → chunk-GCHEVTCJ.js} +2 -2
  59. package/dist/{chunk-GMOAW2EG.js → chunk-GIHIONJH.js} +3 -2
  60. package/dist/chunk-GIHIONJH.js.map +1 -0
  61. package/dist/{chunk-P7HAXMFN.js → chunk-I4KDAO6P.js} +5 -3
  62. package/dist/{chunk-P7HAXMFN.js.map → chunk-I4KDAO6P.js.map} +1 -1
  63. package/dist/chunk-INOVEO32.js +28 -0
  64. package/dist/chunk-INOVEO32.js.map +1 -0
  65. package/dist/{chunk-B2242FYO.js → chunk-JF4BC7ZD.js} +38 -3
  66. package/dist/chunk-JF4BC7ZD.js.map +1 -0
  67. package/dist/{chunk-RKACUTY5.js → chunk-JZWQQOUN.js} +9 -11
  68. package/dist/{chunk-RKACUTY5.js.map → chunk-JZWQQOUN.js.map} +1 -1
  69. package/dist/{chunk-BXCVOHEX.js → chunk-K4YR4PY2.js} +15 -13
  70. package/dist/{chunk-BXCVOHEX.js.map → chunk-K4YR4PY2.js.map} +1 -1
  71. package/dist/{chunk-BXE4L52Q.js → chunk-KX6HRTLH.js} +6599 -3508
  72. package/dist/chunk-KX6HRTLH.js.map +1 -0
  73. package/dist/{chunk-V2XJJEEF.js → chunk-L3DOX3UL.js} +4 -4
  74. package/dist/{chunk-FHJIH6XP.js → chunk-LHP56Q45.js} +16 -7
  75. package/dist/chunk-LHP56Q45.js.map +1 -0
  76. package/dist/{chunk-BLXRIAV2.js → chunk-LT3STF5K.js} +29 -4
  77. package/dist/chunk-LT3STF5K.js.map +1 -0
  78. package/dist/{chunk-SHXPE4D4.js → chunk-MGQNGW6I.js} +2 -2
  79. package/dist/{chunk-SHXPE4D4.js.map → chunk-MGQNGW6I.js.map} +1 -1
  80. package/dist/{chunk-JUUCCML3.js → chunk-MPRVAMO3.js} +4 -4
  81. package/dist/{chunk-JQA6RF4R.js → chunk-N2T6RLSE.js} +2 -2
  82. package/dist/{chunk-JQA6RF4R.js.map → chunk-N2T6RLSE.js.map} +1 -1
  83. package/dist/{chunk-JCTHXG33.js → chunk-NHOGTAPK.js} +2 -2
  84. package/dist/{chunk-VM7VAFJW.js → chunk-NVYDWVXN.js} +2 -1
  85. package/dist/{chunk-ARNI3SJT.js → chunk-OL3Z7KPQ.js} +9 -9
  86. package/dist/chunk-P6LRDWMJ.js +1875 -0
  87. package/dist/chunk-P6LRDWMJ.js.map +1 -0
  88. package/dist/{chunk-NUQF5F5J.js → chunk-PNDEKFF3.js} +2 -2
  89. package/dist/chunk-QJGPOFNB.js +409 -0
  90. package/dist/chunk-QJGPOFNB.js.map +1 -0
  91. package/dist/{chunk-DMVBIIP3.js → chunk-QJL57GPX.js} +3 -3
  92. package/dist/{chunk-AE6KBAAU.js → chunk-QR55QXJ7.js} +11 -11
  93. package/dist/{chunk-BJUEOC4G.js → chunk-QWVIGKBM.js} +3 -3
  94. package/dist/{chunk-E7OG5F6S.js → chunk-RZ6OONZU.js} +13 -11
  95. package/dist/{chunk-E7OG5F6S.js.map → chunk-RZ6OONZU.js.map} +1 -1
  96. package/dist/{chunk-U4OJ7U45.js → chunk-SZMJ24FR.js} +9 -9
  97. package/dist/{chunk-KQDRO6N6.js → chunk-TLY44PCL.js} +2 -2
  98. package/dist/{chunk-VLRIP4BQ.js → chunk-TOVSR2YO.js} +2 -2
  99. package/dist/chunk-TT5UDTDM.js +888 -0
  100. package/dist/chunk-TT5UDTDM.js.map +1 -0
  101. package/dist/{chunk-2YKUSTHS.js → chunk-TVLIJ6ZM.js} +5 -5
  102. package/dist/{chunk-RQPEKHZH.js → chunk-UQYDLEBS.js} +80 -16
  103. package/dist/chunk-UQYDLEBS.js.map +1 -0
  104. package/dist/{chunk-GMLOAKOA.js → chunk-VSDXZAQU.js} +4 -22
  105. package/dist/chunk-VSDXZAQU.js.map +1 -0
  106. package/dist/{chunk-22WGKOQ7.js → chunk-VTJAY3WN.js} +7 -7
  107. package/dist/{chunk-DPDG3FHL.js → chunk-WHECOVH2.js} +3 -3
  108. package/dist/{chunk-BKY6GAFA.js → chunk-WPHPLVS3.js} +53 -918
  109. package/dist/chunk-WPHPLVS3.js.map +1 -0
  110. package/dist/{chunk-SSQZB5SQ.js → chunk-XG6PVB5S.js} +11 -1
  111. package/dist/chunk-XG6PVB5S.js.map +1 -0
  112. package/dist/{chunk-R2CR62JV.js → chunk-XVL7DYWM.js} +4 -4
  113. package/dist/{chunk-CLPC3LKX.js → chunk-Y4O737F7.js} +4 -4
  114. package/dist/{chunk-YSZNJ2ID.js → chunk-YBPXVBSY.js} +2 -2
  115. package/dist/{chunk-2HOWRAWK.js → chunk-YJHH2DHV.js} +2 -2
  116. package/dist/{chunk-APAF4VWW.js → chunk-YUCH6WJY.js} +6 -405
  117. package/dist/chunk-YUCH6WJY.js.map +1 -0
  118. package/dist/chunk-ZAOJYN2D.js +159 -0
  119. package/dist/chunk-ZAOJYN2D.js.map +1 -0
  120. package/dist/{cli-77A46SB2.js → cli-4R5HIGG4.js} +33 -21
  121. package/dist/{cli-77A46SB2.js.map → cli-4R5HIGG4.js.map} +1 -1
  122. package/dist/{cli-6NKE6RMT.js → cli-BF6KB3EJ.js} +34 -22
  123. package/dist/{cli-6NKE6RMT.js.map → cli-BF6KB3EJ.js.map} +1 -1
  124. package/dist/{cli-3PBRPPMQ.js → cli-DXOHHWZK.js} +16 -19
  125. package/dist/{cli-3PBRPPMQ.js.map → cli-DXOHHWZK.js.map} +1 -1
  126. package/dist/{cli-AVHLY2AI.js → cli-MPMECIQH.js} +154 -65
  127. package/dist/cli-MPMECIQH.js.map +1 -0
  128. package/dist/cli-NDYBQ755.js +152 -0
  129. package/dist/cli-NDYBQ755.js.map +1 -0
  130. package/dist/{cli-K47XWDLJ.js → cli-SJA66MIP.js} +29 -30
  131. package/dist/{cli-K47XWDLJ.js.map → cli-SJA66MIP.js.map} +1 -1
  132. package/dist/{cli-FDXU7CGZ.js → cli-TBAOKTMV.js} +16 -19
  133. package/dist/{cli-FDXU7CGZ.js.map → cli-TBAOKTMV.js.map} +1 -1
  134. package/dist/{cli-MQXOK64K.js → cli-TWGGMUXX.js} +89 -45
  135. package/dist/cli-TWGGMUXX.js.map +1 -0
  136. package/dist/{cli-FSDJY5OC.js → cli-V2BJYNMF.js} +4 -4
  137. package/dist/{cli-JNYL6LB7.js → cli-XGCK2LUV.js} +19 -22
  138. package/dist/{cli-JNYL6LB7.js.map → cli-XGCK2LUV.js.map} +1 -1
  139. package/dist/{cli-MOKRUHZT.js → cli-XXN75A42.js} +9 -11
  140. package/dist/cli.js +15 -15
  141. package/dist/cli.js.map +1 -1
  142. package/dist/{config-BMWDC66C.js → config-2YJPJ36T.js} +5 -5
  143. package/dist/docmeta.js +8 -10
  144. package/dist/docmeta.js.map +1 -1
  145. package/dist/github-NQQTH5JK.js +33 -0
  146. package/dist/github-NWL2XGE7.js +48 -0
  147. package/dist/github-WBIEYSM7.js +28 -0
  148. package/dist/graph/runtime.js.map +1 -1
  149. package/dist/{host-YSTYO5DX.js → host-JT27OWTC.js} +3 -3
  150. package/dist/index.d.ts +363 -25
  151. package/dist/index.js +289 -270
  152. package/dist/index.js.map +1 -1
  153. package/dist/json-IVHRVOGQ.js +40 -0
  154. package/dist/{json-YTKUFNO3.js → json-J4TONMKY.js} +2 -2
  155. package/dist/{json-YIK72XAL.js → json-QQAK73QQ.js} +12 -15
  156. package/dist/{labels-X633ZPK7.js → labels-VI2I5YFD.js} +11 -14
  157. package/dist/{labels-X633ZPK7.js.map → labels-VI2I5YFD.js.map} +1 -1
  158. package/dist/lint-VB5A3ENL.js +32 -0
  159. package/dist/list-3XRFX2Y3.js +33 -0
  160. package/dist/list-LMYCD5G5.js +37 -0
  161. package/dist/list-LOS7FTFD.js +30 -0
  162. package/dist/{page-OMPEACUN.js → page-3Y4EGYUO.js} +11 -14
  163. package/dist/{prepare-B4JVDVOV.js → prepare-JK6XKBZB.js} +20 -22
  164. package/dist/{prepare-B4JVDVOV.js.map → prepare-JK6XKBZB.js.map} +1 -1
  165. package/dist/{pretty-U7ATCFBN.js → pretty-DR4GHOJG.js} +12 -15
  166. package/dist/pretty-G2J5UEXC.js +41 -0
  167. package/dist/pretty-GCEIQ3FP.js +65 -0
  168. package/dist/{provider-JY2I3VLF.js → provider-YWNTTQPA.js} +3 -3
  169. package/dist/{release-VHHASAG7.js → release-EFLQT3FW.js} +3 -3
  170. package/dist/{reporters-FAIEOTC4.js → reporters-43LBUWEE.js} +11 -14
  171. package/dist/{reporters-KE7AZR6C.js → reporters-OWYFZD4S.js} +6 -6
  172. package/dist/run-G6G55SWJ.js +36 -0
  173. package/dist/{sarif-DOGRSGTB.js → sarif-CN7RSIKH.js} +10 -13
  174. package/dist/sarif-FR26WNVT.js +49 -0
  175. package/dist/sarif-GWTNYCZJ.js +28 -0
  176. package/dist/strategy-3EZUOE2T.js +59 -0
  177. package/dist/{term-MDN3NJDW.js → term-5WITRS3M.js} +21 -25
  178. package/dist/{term-MDN3NJDW.js.map → term-5WITRS3M.js.map} +1 -1
  179. package/dist/{validate-QDYQ642J.js → validate-TDIEFXRQ.js} +6 -7
  180. package/package.json +1 -1
  181. package/plugin/manni/.claude-plugin/plugin.json +1 -1
  182. package/plugin/manni/hooks/graph-server.mjs +3 -3
  183. package/plugin/manni/hooks/page-metadata.mjs +81 -7
  184. package/plugin/manni/skills/fix/SKILL.md +3 -3
  185. package/shapes/graph/shapes-1.3.0.ttl +1250 -0
  186. package/dist/build-SVKT7QFU.js +0 -39
  187. package/dist/calibrate-AL3MH7TY.js +0 -43
  188. package/dist/capture-2F7B4DAD.js +0 -39
  189. package/dist/check-BI7OGIVE.js +0 -48
  190. package/dist/check-JZINDP3F.js +0 -45
  191. package/dist/check-OPUMZEVK.js +0 -35
  192. package/dist/check-OW7UD73D.js +0 -33
  193. package/dist/chunk-6XK3NTL5.js.map +0 -1
  194. package/dist/chunk-APAF4VWW.js.map +0 -1
  195. package/dist/chunk-B2242FYO.js.map +0 -1
  196. package/dist/chunk-BHGFLRXM.js.map +0 -1
  197. package/dist/chunk-BKY6GAFA.js.map +0 -1
  198. package/dist/chunk-BLXRIAV2.js.map +0 -1
  199. package/dist/chunk-BXE4L52Q.js.map +0 -1
  200. package/dist/chunk-CZIO37J5.js.map +0 -1
  201. package/dist/chunk-D4QHRVDJ.js.map +0 -1
  202. package/dist/chunk-D5GBYKDU.js +0 -164
  203. package/dist/chunk-D5GBYKDU.js.map +0 -1
  204. package/dist/chunk-DENZLZ3Z.js.map +0 -1
  205. package/dist/chunk-FHJIH6XP.js.map +0 -1
  206. package/dist/chunk-GMLOAKOA.js.map +0 -1
  207. package/dist/chunk-GMOAW2EG.js.map +0 -1
  208. package/dist/chunk-LWBNHK72.js.map +0 -1
  209. package/dist/chunk-PACZEDOH.js.map +0 -1
  210. package/dist/chunk-Q76T6Y6X.js.map +0 -1
  211. package/dist/chunk-RQPEKHZH.js.map +0 -1
  212. package/dist/chunk-RWXR3GJI.js +0 -441
  213. package/dist/chunk-RWXR3GJI.js.map +0 -1
  214. package/dist/chunk-S5G6T4VC.js +0 -3200
  215. package/dist/chunk-S5G6T4VC.js.map +0 -1
  216. package/dist/chunk-SSQZB5SQ.js.map +0 -1
  217. package/dist/chunk-UP6NBQ62.js +0 -2
  218. package/dist/chunk-WHVFHBL3.js.map +0 -1
  219. package/dist/chunk-XI3BNZG4.js.map +0 -1
  220. package/dist/chunk-ZPLVANY2.js +0 -15
  221. package/dist/chunk-ZPLVANY2.js.map +0 -1
  222. package/dist/cli-AVHLY2AI.js.map +0 -1
  223. package/dist/cli-LP5OE3BL.js +0 -84
  224. package/dist/cli-LP5OE3BL.js.map +0 -1
  225. package/dist/cli-MQXOK64K.js.map +0 -1
  226. package/dist/github-6GYTPSGV.js +0 -35
  227. package/dist/github-DJOLVNDD.js +0 -31
  228. package/dist/github-ZF2TQ3RP.js +0 -35
  229. package/dist/json-Y7625EFE.js +0 -42
  230. package/dist/lint-RF3B55W7.js +0 -35
  231. package/dist/list-5DW4QZ7P.js +0 -36
  232. package/dist/list-7CHWJ633.js +0 -39
  233. package/dist/list-UNWG6NPD.js +0 -33
  234. package/dist/pretty-PPNHHOEN.js +0 -52
  235. package/dist/pretty-XGYQ25PH.js +0 -43
  236. package/dist/run-MHJ3AYKG.js +0 -39
  237. package/dist/sarif-MIEMQOIK.js +0 -30
  238. package/dist/sarif-RGRG7VFX.js +0 -36
  239. package/dist/strategy-EK5VY5DG.js +0 -223
  240. package/dist/strategy-EK5VY5DG.js.map +0 -1
  241. /package/dist/{batch-C534YIAU.js.map → batch-DPYBMRVD.js.map} +0 -0
  242. /package/dist/{build-SVKT7QFU.js.map → build-LEKUMGEC.js.map} +0 -0
  243. /package/dist/{calibrate-AL3MH7TY.js.map → calibrate-TYONPNG4.js.map} +0 -0
  244. /package/dist/{capture-2F7B4DAD.js.map → capture-2EPHIAZT.js.map} +0 -0
  245. /package/dist/{check-BI7OGIVE.js.map → check-ADCSXGBK.js.map} +0 -0
  246. /package/dist/{check-JZINDP3F.js.map → check-HWEDHABD.js.map} +0 -0
  247. /package/dist/{check-OPUMZEVK.js.map → check-J2KQI7IW.js.map} +0 -0
  248. /package/dist/{check-OW7UD73D.js.map → check-L5AUSTE6.js.map} +0 -0
  249. /package/dist/{check-LKPQPQWJ.js.map → check-SQVQE4E4.js.map} +0 -0
  250. /package/dist/{chunk-IOJD2RFG.js.map → chunk-2MOXVM6H.js.map} +0 -0
  251. /package/dist/{chunk-762MM6NA.js.map → chunk-2QK25SLZ.js.map} +0 -0
  252. /package/dist/{chunk-HHJ2HFPP.js.map → chunk-2UJOQ6CB.js.map} +0 -0
  253. /package/dist/{chunk-H5YWCCBO.js.map → chunk-3CBGLUJX.js.map} +0 -0
  254. /package/dist/{chunk-E23KWEPL.js.map → chunk-3USSSKLA.js.map} +0 -0
  255. /package/dist/{chunk-PTGXEZQD.js.map → chunk-3ZVRGBK6.js.map} +0 -0
  256. /package/dist/{chunk-IN5T22FP.js.map → chunk-6QNA7UX2.js.map} +0 -0
  257. /package/dist/{chunk-OWJLB2AF.js.map → chunk-76Y3JATE.js.map} +0 -0
  258. /package/dist/{chunk-3SFAB75L.js.map → chunk-AJCUKL43.js.map} +0 -0
  259. /package/dist/{chunk-CREFJCWZ.js.map → chunk-AOLCEULZ.js.map} +0 -0
  260. /package/dist/{chunk-2NGFDLIM.js.map → chunk-B4ECIBLF.js.map} +0 -0
  261. /package/dist/{chunk-5UJKXOAD.js.map → chunk-B4POKRCS.js.map} +0 -0
  262. /package/dist/{chunk-KBSTXL6L.js.map → chunk-BOCJTOKA.js.map} +0 -0
  263. /package/dist/{chunk-CFMI74TP.js.map → chunk-BZ74YUYE.js.map} +0 -0
  264. /package/dist/{chunk-NLJ3XIKT.js.map → chunk-C2QE4FSZ.js.map} +0 -0
  265. /package/dist/{chunk-245W2Q7C.js.map → chunk-D4BGNAN5.js.map} +0 -0
  266. /package/dist/{chunk-XBJKYXOR.js.map → chunk-DWUK6YNX.js.map} +0 -0
  267. /package/dist/{chunk-MTCOBRCX.js.map → chunk-E75CMOR3.js.map} +0 -0
  268. /package/dist/{chunk-KCWNJMSS.js.map → chunk-EBBJFXMX.js.map} +0 -0
  269. /package/dist/{chunk-A4QNKEX4.js.map → chunk-GCHEVTCJ.js.map} +0 -0
  270. /package/dist/{chunk-V2XJJEEF.js.map → chunk-L3DOX3UL.js.map} +0 -0
  271. /package/dist/{chunk-JUUCCML3.js.map → chunk-MPRVAMO3.js.map} +0 -0
  272. /package/dist/{chunk-JCTHXG33.js.map → chunk-NHOGTAPK.js.map} +0 -0
  273. /package/dist/{chunk-VM7VAFJW.js.map → chunk-NVYDWVXN.js.map} +0 -0
  274. /package/dist/{chunk-ARNI3SJT.js.map → chunk-OL3Z7KPQ.js.map} +0 -0
  275. /package/dist/{chunk-NUQF5F5J.js.map → chunk-PNDEKFF3.js.map} +0 -0
  276. /package/dist/{chunk-DMVBIIP3.js.map → chunk-QJL57GPX.js.map} +0 -0
  277. /package/dist/{chunk-AE6KBAAU.js.map → chunk-QR55QXJ7.js.map} +0 -0
  278. /package/dist/{chunk-BJUEOC4G.js.map → chunk-QWVIGKBM.js.map} +0 -0
  279. /package/dist/{chunk-U4OJ7U45.js.map → chunk-SZMJ24FR.js.map} +0 -0
  280. /package/dist/{chunk-KQDRO6N6.js.map → chunk-TLY44PCL.js.map} +0 -0
  281. /package/dist/{chunk-VLRIP4BQ.js.map → chunk-TOVSR2YO.js.map} +0 -0
  282. /package/dist/{chunk-2YKUSTHS.js.map → chunk-TVLIJ6ZM.js.map} +0 -0
  283. /package/dist/{chunk-22WGKOQ7.js.map → chunk-VTJAY3WN.js.map} +0 -0
  284. /package/dist/{chunk-DPDG3FHL.js.map → chunk-WHECOVH2.js.map} +0 -0
  285. /package/dist/{chunk-R2CR62JV.js.map → chunk-XVL7DYWM.js.map} +0 -0
  286. /package/dist/{chunk-CLPC3LKX.js.map → chunk-Y4O737F7.js.map} +0 -0
  287. /package/dist/{chunk-YSZNJ2ID.js.map → chunk-YBPXVBSY.js.map} +0 -0
  288. /package/dist/{chunk-2HOWRAWK.js.map → chunk-YJHH2DHV.js.map} +0 -0
  289. /package/dist/{cli-FSDJY5OC.js.map → cli-V2BJYNMF.js.map} +0 -0
  290. /package/dist/{chunk-UP6NBQ62.js.map → cli-XXN75A42.js.map} +0 -0
  291. /package/dist/{cli-MOKRUHZT.js.map → config-2YJPJ36T.js.map} +0 -0
  292. /package/dist/{config-BMWDC66C.js.map → github-NQQTH5JK.js.map} +0 -0
  293. /package/dist/{github-6GYTPSGV.js.map → github-NWL2XGE7.js.map} +0 -0
  294. /package/dist/{github-DJOLVNDD.js.map → github-WBIEYSM7.js.map} +0 -0
  295. /package/dist/{github-ZF2TQ3RP.js.map → host-JT27OWTC.js.map} +0 -0
  296. /package/dist/{host-YSTYO5DX.js.map → json-IVHRVOGQ.js.map} +0 -0
  297. /package/dist/{json-Y7625EFE.js.map → json-J4TONMKY.js.map} +0 -0
  298. /package/dist/{json-YIK72XAL.js.map → json-QQAK73QQ.js.map} +0 -0
  299. /package/dist/{json-YTKUFNO3.js.map → lint-VB5A3ENL.js.map} +0 -0
  300. /package/dist/{lint-RF3B55W7.js.map → list-3XRFX2Y3.js.map} +0 -0
  301. /package/dist/{list-5DW4QZ7P.js.map → list-LMYCD5G5.js.map} +0 -0
  302. /package/dist/{list-7CHWJ633.js.map → list-LOS7FTFD.js.map} +0 -0
  303. /package/dist/{list-UNWG6NPD.js.map → page-3Y4EGYUO.js.map} +0 -0
  304. /package/dist/{page-OMPEACUN.js.map → pretty-DR4GHOJG.js.map} +0 -0
  305. /package/dist/{pretty-PPNHHOEN.js.map → pretty-G2J5UEXC.js.map} +0 -0
  306. /package/dist/{pretty-U7ATCFBN.js.map → pretty-GCEIQ3FP.js.map} +0 -0
  307. /package/dist/{pretty-XGYQ25PH.js.map → provider-YWNTTQPA.js.map} +0 -0
  308. /package/dist/{release-VHHASAG7.js.map → release-EFLQT3FW.js.map} +0 -0
  309. /package/dist/{provider-JY2I3VLF.js.map → reporters-43LBUWEE.js.map} +0 -0
  310. /package/dist/{reporters-FAIEOTC4.js.map → reporters-OWYFZD4S.js.map} +0 -0
  311. /package/dist/{reporters-KE7AZR6C.js.map → run-G6G55SWJ.js.map} +0 -0
  312. /package/dist/{run-MHJ3AYKG.js.map → sarif-CN7RSIKH.js.map} +0 -0
  313. /package/dist/{sarif-DOGRSGTB.js.map → sarif-FR26WNVT.js.map} +0 -0
  314. /package/dist/{sarif-MIEMQOIK.js.map → sarif-GWTNYCZJ.js.map} +0 -0
  315. /package/dist/{sarif-RGRG7VFX.js.map → strategy-3EZUOE2T.js.map} +0 -0
  316. /package/dist/{validate-QDYQ642J.js.map → validate-TDIEFXRQ.js.map} +0 -0
@@ -0,0 +1,1875 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ graderFor,
4
+ makeTraceJudge
5
+ } from "./chunk-TT5UDTDM.js";
6
+ import {
7
+ parseTraceFile
8
+ } from "./chunk-2GPF4OEF.js";
9
+ import {
10
+ REDO_OR_FIX
11
+ } from "./chunk-VHJ72YCD.js";
12
+ import {
13
+ artifactEvalsErrors,
14
+ normalizeEntry
15
+ } from "./chunk-QJGPOFNB.js";
16
+ import {
17
+ parseConfig
18
+ } from "./chunk-3ZVRGBK6.js";
19
+ import {
20
+ makeRedactor
21
+ } from "./chunk-6WJUZQQX.js";
22
+ import {
23
+ constructProvider,
24
+ makeJudgeProvider,
25
+ resolveProviderIdentity
26
+ } from "./chunk-NHOGTAPK.js";
27
+ import {
28
+ TracevalsError
29
+ } from "./chunk-ZINZTHWO.js";
30
+ import {
31
+ outputTail,
32
+ realExec
33
+ } from "./chunk-XG6PVB5S.js";
34
+ import {
35
+ evidenceVerdict
36
+ } from "./chunk-QS2Z3SWL.js";
37
+ import {
38
+ unknownRecordMessage
39
+ } from "./chunk-7M3MBFG7.js";
40
+ import {
41
+ indexSet,
42
+ loadStrategy
43
+ } from "./chunk-FBIBR4CH.js";
44
+ import {
45
+ mapConcurrent
46
+ } from "./chunk-KX6HRTLH.js";
47
+ import {
48
+ DEFAULT_IGNORE,
49
+ STDIN_TOKEN,
50
+ extractorForExtension,
51
+ notFoundMessage,
52
+ resolveTargetSet
53
+ } from "./chunk-QWVIGKBM.js";
54
+ import {
55
+ escapeWorkflowCommandMessage,
56
+ escapeWorkflowCommandProperty,
57
+ guidanceLines
58
+ } from "./chunk-QK6VYJHV.js";
59
+ import {
60
+ palette
61
+ } from "./chunk-RNVYGWIC.js";
62
+ import {
63
+ DEFAULT_CLAUDE_CLI_MAX_TURNS,
64
+ claudeCliMcpConfigPath,
65
+ docDetectiveConfigPath,
66
+ findConfigFile,
67
+ readConfigFile,
68
+ selectCollections
69
+ } from "./chunk-JF4BC7ZD.js";
70
+ import {
71
+ notice,
72
+ warn
73
+ } from "./chunk-HX44GB4Z.js";
74
+ import {
75
+ LOCAL_PROVIDER
76
+ } from "./chunk-NVYDWVXN.js";
77
+ import {
78
+ ToolError,
79
+ errorMessage
80
+ } from "./chunk-G3T47CFV.js";
81
+
82
+ // src/test/errors.ts
83
+ var TestError = class extends ToolError {
84
+ constructor(message) {
85
+ super(message);
86
+ this.name = "TestError";
87
+ }
88
+ };
89
+
90
+ // src/test/commands/procedures.ts
91
+ import { existsSync } from "node:fs";
92
+ import { mkdtemp, readdir, readFile, rm } from "node:fs/promises";
93
+ import { tmpdir } from "node:os";
94
+ import { join as join2, relative as relative2, resolve } from "node:path";
95
+ import fg from "fast-glob";
96
+ import picomatch from "picomatch";
97
+
98
+ // src/test/core/doc-detective.ts
99
+ import { spawn } from "node:child_process";
100
+ import { statSync } from "node:fs";
101
+ import { join } from "node:path";
102
+ var NOT_ON_PATH = "doc-detective is not on PATH. Install Doc Detective (npm install -g doc-detective) to run doc tests.";
103
+ var COMMAND_LINE_LIMIT = "the selected inputs exceed the command-line limit. Narrow the collection, or set input in the Doc Detective config.";
104
+ var NO_TIMEOUT = 2 ** 31 - 1;
105
+ function launchFor(args, host) {
106
+ if (host.platform !== "win32") return { command: "doc-detective", args, viaShim: false };
107
+ for (const entry of host.path.split(";")) {
108
+ const dir = entry.replace(/^"(.*)"$/, "$1");
109
+ if (dir === "" || !host.isFile(join(dir, "doc-detective.cmd"))) continue;
110
+ const script = join(dir, "node_modules", "doc-detective", "bin", "doc-detective.js");
111
+ if (host.isFile(script)) {
112
+ return { command: process.execPath, args: [script, ...args], viaShim: false };
113
+ }
114
+ break;
115
+ }
116
+ return { command: "doc-detective", args, viaShim: true };
117
+ }
118
+ function assertFitsCommandLine(launch, platform) {
119
+ if (platform !== "win32") return;
120
+ const length = [launch.command, ...launch.args].reduce((n, arg) => n + arg.length + 3, 0);
121
+ if (length > (launch.viaShim ? 8191 : 32767)) throw new TestError(COMMAND_LINE_LIMIT);
122
+ }
123
+ function isFile(path) {
124
+ try {
125
+ return statSync(path).isFile();
126
+ } catch {
127
+ return false;
128
+ }
129
+ }
130
+ function streamed(launch, opts) {
131
+ return new Promise((settle) => {
132
+ let stdout = "";
133
+ let stderr = "";
134
+ const child = spawn(launch.command, launch.args, {
135
+ cwd: opts.cwd,
136
+ stdio: ["ignore", "pipe", "pipe"],
137
+ windowsHide: true
138
+ });
139
+ child.stdout.setEncoding("utf8");
140
+ child.stderr.setEncoding("utf8");
141
+ child.stdout.on("data", (chunk) => {
142
+ stdout += chunk;
143
+ if (opts.progress) process.stderr.write(chunk);
144
+ });
145
+ child.stderr.on("data", (chunk) => {
146
+ stderr += chunk;
147
+ if (opts.progress) process.stderr.write(chunk);
148
+ });
149
+ child.on("error", (err) => {
150
+ settle({ code: null, stdout, stderr, timedOut: false, spawnError: err.message });
151
+ });
152
+ child.on("close", (code) => {
153
+ settle({ code, stdout, stderr, timedOut: false });
154
+ });
155
+ });
156
+ }
157
+ var realSpawn = async (args, opts) => {
158
+ const launch = launchFor(args, {
159
+ platform: process.platform,
160
+ path: process.env["PATH"] ?? "",
161
+ isFile
162
+ });
163
+ assertFitsCommandLine(launch, process.platform);
164
+ if (!launch.viaShim) return streamed(launch, opts);
165
+ const result = await realExec([launch.command, ...launch.args], {
166
+ cwd: opts.cwd,
167
+ timeoutMs: NO_TIMEOUT
168
+ });
169
+ if (opts.progress) process.stderr.write(result.stdout + result.stderr);
170
+ return result;
171
+ };
172
+
173
+ // src/test/core/results.ts
174
+ import { relative } from "node:path";
175
+ var ACTIONS = /* @__PURE__ */ new Set([
176
+ "checkLink",
177
+ "click",
178
+ "dragAndDrop",
179
+ "find",
180
+ "goTo",
181
+ "httpRequest",
182
+ "loadCookie",
183
+ "loadVariables",
184
+ "record",
185
+ "runCode",
186
+ "runShell",
187
+ "saveCookie",
188
+ "screenshot",
189
+ "stopRecord",
190
+ "type",
191
+ "wait"
192
+ ]);
193
+ var ACTIONS_GUIDE = "https://docs.doc-detective.com/docs/actions/";
194
+ var ZERO_COUNTS = { pass: 0, fail: 0, warning: 0, skipped: 0 };
195
+ function isRecord(value) {
196
+ return typeof value === "object" && value !== null && !Array.isArray(value);
197
+ }
198
+ function records(value) {
199
+ return Array.isArray(value) ? value.filter(isRecord) : [];
200
+ }
201
+ function counts(value) {
202
+ if (!isRecord(value)) return void 0;
203
+ const out = { ...ZERO_COUNTS };
204
+ for (const key of Object.keys(out)) {
205
+ const n = value[key];
206
+ if (typeof n !== "number") return void 0;
207
+ out[key] = n;
208
+ }
209
+ return out;
210
+ }
211
+ function parseResults(text2) {
212
+ let parsed;
213
+ try {
214
+ parsed = JSON.parse(text2);
215
+ } catch {
216
+ return void 0;
217
+ }
218
+ if (parsed === null) return null;
219
+ if (!isRecord(parsed) || !isRecord(parsed["summary"])) return void 0;
220
+ if (counts(parsed["summary"]["tests"]) === void 0) return void 0;
221
+ if (!Array.isArray(parsed["specs"])) return void 0;
222
+ return parsed;
223
+ }
224
+ function testCounts(results) {
225
+ if (results === null || !isRecord(results["summary"])) return { ...ZERO_COUNTS };
226
+ return counts(results["summary"]["tests"]) ?? { ...ZERO_COUNTS };
227
+ }
228
+ function anyFailed(results) {
229
+ if (results === null) return false;
230
+ const summary = results["summary"];
231
+ if (!isRecord(summary)) return false;
232
+ return Object.values(summary).some((level) => (counts(level)?.fail ?? 0) > 0);
233
+ }
234
+ function collectFindings(results, cwd) {
235
+ if (results === null) return [];
236
+ const out = [];
237
+ const seen = /* @__PURE__ */ new Set();
238
+ for (const spec of records(results["specs"])) {
239
+ for (const test of records(spec["tests"])) {
240
+ const contentPath = test["contentPath"] ?? spec["contentPath"];
241
+ const file = typeof contentPath !== "string" ? "" : /^[a-z][a-z0-9+.-]*:\/\//i.test(contentPath) ? contentPath : relative(cwd, contentPath).replace(/\\/g, "/");
242
+ for (const context of records(test["contexts"])) {
243
+ for (const step of records(context["steps"])) {
244
+ const result = step["result"];
245
+ if (result !== "FAIL" && result !== "WARNING") continue;
246
+ const location = step["location"];
247
+ const line = isRecord(location) ? location["line"] : void 0;
248
+ const resultDescription = step["resultDescription"];
249
+ const description = typeof resultDescription === "string" ? resultDescription : "";
250
+ const action = Object.keys(step).find((key2) => ACTIONS.has(key2));
251
+ const key = JSON.stringify([file, line, action, result, description]);
252
+ if (seen.has(key)) continue;
253
+ seen.add(key);
254
+ const stated = step["description"];
255
+ out.push({
256
+ file,
257
+ ...typeof line === "number" ? { line } : {},
258
+ result,
259
+ description,
260
+ ...action === void 0 ? {} : { action },
261
+ guidance: {
262
+ id: "Doc Detective",
263
+ rule: action ?? null,
264
+ description: typeof stated === "string" && stated !== "" ? stated : null,
265
+ guide: action === void 0 ? null : `${ACTIONS_GUIDE}${action.toLowerCase()}`
266
+ }
267
+ });
268
+ }
269
+ }
270
+ }
271
+ }
272
+ return out;
273
+ }
274
+
275
+ // src/test/commands/procedures.ts
276
+ var DOC_DETECTIVE_CONFIG_NAMES = [".doc-detective.json", ".doc-detective.yaml", ".doc-detective.yml"];
277
+ var NO_RESULTS = "Doc Detective wrote no results to read. Run doc-detective directly to see why.";
278
+ function empty(results = null) {
279
+ return { results, findings: [], tests: { pass: 0, fail: 0, warning: 0, skipped: 0 }, exitCode: 0 };
280
+ }
281
+ var toError = (message) => new TestError(message);
282
+ async function asTestError(work) {
283
+ try {
284
+ return await work();
285
+ } catch (err) {
286
+ if (err instanceof ToolError && !(err instanceof TestError)) throw new TestError(err.message);
287
+ throw err;
288
+ }
289
+ }
290
+ async function loadConfig(cwd, configPath) {
291
+ const opts = { section: "test", legacyNames: [], toError };
292
+ const file = configPath === void 0 ? await findConfigFile(cwd, opts) : await readConfigFile(configPath, cwd, opts);
293
+ if (file !== null && file.wrapped && file.value !== null) {
294
+ throw new TestError(
295
+ `${file.source}: test has no keys. Doc Detective's settings live under tools.doc-detective, and Claude Code's under tools.claude-cli.`
296
+ );
297
+ }
298
+ return file;
299
+ }
300
+ async function positionalInputs(paths, cwd, allowEmpty) {
301
+ const inputs = [];
302
+ const missing = [];
303
+ for (const path of paths) {
304
+ const posix = path.replace(/\\/g, "/");
305
+ if (existsSync(resolve(cwd, posix))) {
306
+ inputs.push(path);
307
+ } else if (picomatch.scan(posix).isGlob) {
308
+ const found = await fg(posix, { cwd, ignore: DEFAULT_IGNORE, onlyFiles: true, dot: false });
309
+ inputs.push(...found.sort());
310
+ } else {
311
+ missing.push(posix);
312
+ }
313
+ }
314
+ if (missing.length > 0 && !allowEmpty) throw new TestError(notFoundMessage(missing));
315
+ return inputs;
316
+ }
317
+ async function collectionInputs(file, names, cwd, allowEmpty) {
318
+ const collections = selectCollections(file.collections, names, file.source, toError);
319
+ const { files } = await asTestError(
320
+ () => resolveTargetSet({
321
+ inputs: collections.flatMap((c) => c.paths),
322
+ exclude: collections.flatMap((c) => c.exclude),
323
+ cwd: file.dir,
324
+ allowEmpty
325
+ })
326
+ );
327
+ return files.map((f) => relative2(cwd, resolve(file.dir, f)).replace(/\\/g, "/"));
328
+ }
329
+ async function readResults(outDir) {
330
+ const names = (await readdir(outDir)).filter((n) => /^testResults-.*\.json$/.test(n)).sort();
331
+ const last = names.at(-1);
332
+ if (last === void 0) throw new TestError(NO_RESULTS);
333
+ const results = parseResults(await readFile(join2(outDir, last), "utf8"));
334
+ if (results === void 0) throw new TestError(NO_RESULTS);
335
+ return results;
336
+ }
337
+ async function runProcedures(opts = {}) {
338
+ const cwd = resolve(opts.cwd ?? process.cwd());
339
+ const paths = opts.paths ?? [];
340
+ const wanted = opts.collection ?? [];
341
+ const allowEmpty = opts.allowEmpty ?? false;
342
+ if (paths.includes(STDIN_TOKEN)) {
343
+ throw new TestError("test procedures reads files; Doc Detective has no stdin. Pass a path.");
344
+ }
345
+ if (wanted.length > 0 && paths.length > 0) {
346
+ throw new TestError(
347
+ "--collection selects a configured collection; it cannot be combined with paths."
348
+ );
349
+ }
350
+ const file = await loadConfig(cwd, opts.configPath);
351
+ if (wanted.length > 0 && file === null) {
352
+ throw new TestError("--collection needs a config file to select from.");
353
+ }
354
+ const written = file?.tools["doc-detective"]?.config;
355
+ let ddConfig;
356
+ if (file !== null && written !== void 0) {
357
+ ddConfig = docDetectiveConfigPath(file.tools, file.dir);
358
+ if (ddConfig !== void 0 && !existsSync(ddConfig)) {
359
+ throw new TestError(`${file.source}: tools.doc-detective.config "${written}" does not exist.`);
360
+ }
361
+ }
362
+ let inputs;
363
+ if (paths.length > 0) {
364
+ inputs = await positionalInputs(paths, cwd, allowEmpty);
365
+ if (inputs.length === 0) {
366
+ if (allowEmpty) return empty();
367
+ const tried = paths.map((p) => `"${p}"`).join(", ");
368
+ throw new TestError(
369
+ `No files matched. Patterns tried: ${tried}. Pass --allow-empty if that is expected.`
370
+ );
371
+ }
372
+ } else if (file !== null && wanted.length > 0) {
373
+ inputs = await collectionInputs(file, wanted, cwd, allowEmpty);
374
+ if (inputs.length === 0) {
375
+ if (allowEmpty) return empty();
376
+ throw new TestError("--collection matched no files. Pass --allow-empty if that is expected.");
377
+ }
378
+ } else if (ddConfig === void 0 && !DOC_DETECTIVE_CONFIG_NAMES.some((name) => existsSync(join2(cwd, name)))) {
379
+ throw new TestError(
380
+ "test procedures needs paths or a Doc Detective config. Pass paths, or add .doc-detective.json."
381
+ );
382
+ }
383
+ const outDir = await mkdtemp(join2(tmpdir(), "manni-test-"));
384
+ try {
385
+ const args = [
386
+ // ponytail: Doc Detective splits -i on commas, so a path holding a comma
387
+ // is two inputs. Upgrade path: a generated config whose input is a list.
388
+ ...inputs === void 0 ? [] : ["-i", inputs.join(",")],
389
+ ...ddConfig === void 0 ? [] : ["-c", ddConfig],
390
+ "-r",
391
+ "json",
392
+ "-o",
393
+ outDir
394
+ ];
395
+ const run = await (opts.spawn ?? realSpawn)(args, { cwd, progress: opts.progress ?? false });
396
+ if (run.spawnError !== void 0) throw new TestError(NOT_ON_PATH);
397
+ if (run.code !== 0) {
398
+ const how = run.code === null ? "killed before exiting" : `exit ${String(run.code)}`;
399
+ throw new TestError(`Doc Detective failed (${how}):
400
+ ${outputTail(run)}`);
401
+ }
402
+ const results = await readResults(outDir);
403
+ const tests = testCounts(results);
404
+ const total = tests.pass + tests.fail + tests.warning + tests.skipped;
405
+ if (total === 0) {
406
+ if (allowEmpty) return empty(results);
407
+ throw new TestError(
408
+ "Doc Detective found no tests in the inputs. Pass --allow-empty if that is expected."
409
+ );
410
+ }
411
+ return {
412
+ results,
413
+ findings: collectFindings(results, cwd),
414
+ tests,
415
+ exitCode: anyFailed(results) ? 1 : 0
416
+ };
417
+ } finally {
418
+ await rm(outDir, { recursive: true, force: true });
419
+ }
420
+ }
421
+
422
+ // src/test/commands/tasks.ts
423
+ import { existsSync as existsSync2 } from "node:fs";
424
+ import { appendFile, mkdir as mkdir2, rm as rm2, writeFile } from "node:fs/promises";
425
+ import { join as join7, relative as relative8, resolve as resolve5, sep as sep6 } from "node:path";
426
+
427
+ // src/test/core/claude-code.ts
428
+ import { spawn as spawn2 } from "node:child_process";
429
+ import { readFileSync, statSync as statSync2 } from "node:fs";
430
+ import { isAbsolute, join as join3, relative as relative3, sep, win32 } from "node:path";
431
+ var CLAUDE_CODE_NOT_ON_PATH = "Claude Code is not on PATH. Install it with npm install -g @anthropic-ai/claude-code, sign in, and run again.";
432
+ var TASK_TOOLS = ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "WebFetch"];
433
+ var NO_TIMEOUT2 = 2 ** 31 - 1;
434
+ function claudeCodeArgs(opts) {
435
+ const tools = TASK_TOOLS.join(",");
436
+ const allowed = [...TASK_TOOLS, ...opts.mcpServers.map((name) => `mcp__${name}`)].join(",");
437
+ return [
438
+ "-p",
439
+ "--output-format",
440
+ "stream-json",
441
+ "--verbose",
442
+ "--no-session-persistence",
443
+ "--setting-sources",
444
+ "",
445
+ "--strict-mcp-config",
446
+ ...opts.mcpConfig === void 0 ? [] : ["--mcp-config", opts.mcpConfig],
447
+ "--tools",
448
+ tools,
449
+ "--allowedTools",
450
+ allowed,
451
+ "--permission-mode",
452
+ "dontAsk",
453
+ "--append-system-prompt-file",
454
+ opts.roleFile,
455
+ "--max-turns",
456
+ String(opts.maxTurns),
457
+ ...opts.model === void 0 ? [] : ["--model", opts.model],
458
+ ...opts.docsDir === null ? [] : ["--add-dir", opts.docsDir]
459
+ ];
460
+ }
461
+ function mcpServerNames(path, label2) {
462
+ let parsed;
463
+ try {
464
+ parsed = JSON.parse(readFileSync(path, "utf8"));
465
+ } catch {
466
+ throw new TestError(`${label2} is not a JSON file Claude Code can read.`);
467
+ }
468
+ const servers = typeof parsed === "object" && parsed !== null ? parsed["mcpServers"] : void 0;
469
+ return typeof servers === "object" && servers !== null && !Array.isArray(servers) ? Object.keys(servers) : [];
470
+ }
471
+ function claudeCodeEnv(globalDir, env = process.env, platform = process.platform) {
472
+ const pathKey2 = Object.keys(env).find((key) => key.toUpperCase() === "PATH") ?? "PATH";
473
+ const bin = platform === "win32" ? globalDir : join3(globalDir, "bin");
474
+ const current = env[pathKey2];
475
+ const sepr = platform === "win32" ? ";" : ":";
476
+ return {
477
+ ...env,
478
+ NPM_CONFIG_PREFIX: globalDir,
479
+ [pathKey2]: current === void 0 || current === "" ? bin : `${bin}${sepr}${current}`
480
+ };
481
+ }
482
+ function progressLine(who, tool, input, workspaceDir) {
483
+ const main = ["file_path", "path", "command", "pattern", "url", "query"].map((k) => input[k]).find((v) => typeof v === "string") ?? Object.values(input).find((v) => typeof v === "string");
484
+ let shown = typeof main === "string" ? main.replace(/\s+/g, " ").trim() : "";
485
+ if (isAbsolute(shown) && !/\s/.test(shown)) {
486
+ shown = relative3(workspaceDir, shown).split(sep).join("/");
487
+ }
488
+ return ` ${who} \u203A ${tool}${shown === "" ? "" : ` ${shown.slice(0, 80)}`}`;
489
+ }
490
+ function toolUses(line) {
491
+ const rec = parseLine(line);
492
+ if (rec?.["type"] !== "assistant") return [];
493
+ const message = rec["message"];
494
+ const content = typeof message === "object" && message !== null ? message["content"] : void 0;
495
+ if (!Array.isArray(content)) return [];
496
+ return content.flatMap((block) => {
497
+ if (typeof block !== "object" || block === null) return [];
498
+ const b = block;
499
+ if (b["type"] !== "tool_use" || typeof b["name"] !== "string") return [];
500
+ const input = typeof b["input"] === "object" && b["input"] !== null ? b["input"] : {};
501
+ return [{ name: b["name"], input }];
502
+ });
503
+ }
504
+ function parseLine(line) {
505
+ try {
506
+ const rec = JSON.parse(line);
507
+ return typeof rec === "object" && rec !== null && !Array.isArray(rec) ? rec : void 0;
508
+ } catch {
509
+ return void 0;
510
+ }
511
+ }
512
+ function lineSplitter(onLine) {
513
+ let buffer = "";
514
+ return {
515
+ push(chunk) {
516
+ buffer += chunk;
517
+ let at3 = buffer.indexOf("\n");
518
+ while (at3 !== -1) {
519
+ onLine(buffer.slice(0, at3).trim());
520
+ buffer = buffer.slice(at3 + 1);
521
+ at3 = buffer.indexOf("\n");
522
+ }
523
+ },
524
+ end() {
525
+ if (buffer.trim() !== "") onLine(buffer.trim());
526
+ buffer = "";
527
+ }
528
+ };
529
+ }
530
+ function classifyRun(result, label2) {
531
+ if (result.spawnError !== void 0) throw new TestError(CLAUDE_CODE_NOT_ON_PATH);
532
+ let last;
533
+ for (const line of result.stdout.split("\n")) {
534
+ const rec = parseLine(line.trim());
535
+ if (rec?.["type"] === "result") last = rec;
536
+ }
537
+ const durationMs = typeof last?.["duration_ms"] === "number" ? last["duration_ms"] : 0;
538
+ if (last?.["subtype"] === "error_max_turns") return { stoppedAtLimit: true, durationMs };
539
+ if (last !== void 0 && last["is_error"] !== true) return { stoppedAtLimit: false, durationMs };
540
+ const said2 = typeof last?.["result"] === "string" && last["result"].trim() !== "" ? last["result"].trim() : void 0;
541
+ const why = said2 ?? (outputTail(result) || `exit ${String(result.code)}`);
542
+ throw new TestError(`Claude Code stopped without a result for ${label2}: ${why}`);
543
+ }
544
+ function claudeLaunchFor(args, host) {
545
+ if (host.platform !== "win32") return { command: "claude", args, viaShim: false };
546
+ for (const entry of host.path.split(";")) {
547
+ const dir = entry.replace(/^"(.*)"$/, "$1");
548
+ if (dir === "") continue;
549
+ const exe = win32.join(dir, "claude.exe");
550
+ if (host.isFile(exe)) return { command: exe, args, viaShim: false };
551
+ const shim = win32.join(dir, "claude.cmd");
552
+ if (!host.isFile(shim)) continue;
553
+ const target = /"%~?dp0%?\\([^"]+)"/.exec(host.read(shim))?.[1];
554
+ const abs = target === void 0 ? void 0 : win32.resolve(win32.dirname(shim), target);
555
+ if (abs !== void 0 && host.isFile(abs)) {
556
+ const ext = win32.extname(abs).toLowerCase();
557
+ if (ext === ".js" || ext === ".cjs" || ext === ".mjs") {
558
+ return { command: process.execPath, args: [abs, ...args], viaShim: false };
559
+ }
560
+ if (ext === ".exe") return { command: abs, args, viaShim: false };
561
+ }
562
+ break;
563
+ }
564
+ return { command: "claude", args, viaShim: true };
565
+ }
566
+ function isFile2(path) {
567
+ try {
568
+ return statSync2(path).isFile();
569
+ } catch {
570
+ return false;
571
+ }
572
+ }
573
+ var realClaudeCodeSpawn = async (args, opts) => {
574
+ const launch = claudeLaunchFor(args, {
575
+ platform: process.platform,
576
+ path: process.env["PATH"] ?? "",
577
+ isFile: isFile2,
578
+ read: (path) => readFileSync(path, "utf8")
579
+ });
580
+ if (launch.viaShim) {
581
+ const result = await realExec([launch.command, ...launch.args], {
582
+ cwd: opts.cwd,
583
+ env: opts.env,
584
+ input: opts.stdin,
585
+ timeoutMs: NO_TIMEOUT2
586
+ });
587
+ opts.onStdout(result.stdout);
588
+ return result;
589
+ }
590
+ return new Promise((settle) => {
591
+ let stdout = "";
592
+ let stderr = "";
593
+ const child = spawn2(launch.command, launch.args, {
594
+ cwd: opts.cwd,
595
+ env: opts.env,
596
+ stdio: ["pipe", "pipe", "pipe"],
597
+ windowsHide: true
598
+ });
599
+ child.stdin.on("error", () => void 0);
600
+ child.stdin.end(opts.stdin);
601
+ child.stdout.setEncoding("utf8");
602
+ child.stderr.setEncoding("utf8");
603
+ child.stdout.on("data", (chunk) => {
604
+ stdout += chunk;
605
+ opts.onStdout(chunk);
606
+ });
607
+ child.stderr.on("data", (chunk) => {
608
+ stderr += chunk;
609
+ });
610
+ child.on("error", (err) => {
611
+ settle({ code: null, stdout, stderr, timedOut: false, spawnError: err.message });
612
+ });
613
+ child.on("close", (code) => {
614
+ settle({ code, stdout, stderr, timedOut: false });
615
+ });
616
+ });
617
+ };
618
+
619
+ // src/test/core/judge-run.ts
620
+ import { join as join5, relative as relative5, sep as sep3 } from "node:path";
621
+
622
+ // src/test/core/evidence.ts
623
+ import { readFileSync as readFileSync2, realpathSync } from "node:fs";
624
+ import { isAbsolute as isAbsolute2, join as join4, relative as relative4, resolve as resolve2, sep as sep2 } from "node:path";
625
+ var MAX_TOOL_RESULT_CHARS = 2e3;
626
+ var MAX_FILE_CHARS = 4e3;
627
+ var MAX_WORKSPACE_CHARS = 2e4;
628
+ var MAX_DOCS_CHARS = 4e4;
629
+ var scrub = makeRedactor();
630
+ function clip(text2, max) {
631
+ return budgeted(text2, max).body;
632
+ }
633
+ function budgeted(text2, max) {
634
+ const safe = scrub(text2);
635
+ if (safe.length <= max) return { body: safe, used: safe.length };
636
+ return {
637
+ body: `${safe.slice(0, max)} [manni shortened this for the judge; the reader received ${String(safe.length - max)} more characters]`,
638
+ used: max
639
+ };
640
+ }
641
+ function renderEvidence(evidence) {
642
+ const results = toolResults(evidence.trace.events);
643
+ const { text: docsText, docs } = renderDocs(evidence, results);
644
+ const text2 = [
645
+ "## The trace",
646
+ renderTrace(evidence, results),
647
+ "## The workspace",
648
+ renderWorkspace(evidence),
649
+ "## The docs the reader had",
650
+ docsText
651
+ ].join("\n\n");
652
+ return { text: text2, docsText, docs };
653
+ }
654
+ function taskBrief(evidence) {
655
+ const { spec } = evidence;
656
+ const lines = [spec.task];
657
+ if (spec.journey?.trigger !== void 0) lines.push(`What started this: ${spec.journey.trigger}`);
658
+ if (spec.journey?.successCriteria !== void 0) {
659
+ lines.push(`You're done when: ${spec.journey.successCriteria.text}`);
660
+ }
661
+ lines.push(`Start here: ${startName(evidence)}`);
662
+ return [...lines, "", whoTheReaderIs(spec)].join("\n");
663
+ }
664
+ function startName(evidence) {
665
+ const { start } = evidence.spec;
666
+ if (start.kind === "url") return start.url;
667
+ if (evidence.docsDir !== null && evidence.startCopy !== null) {
668
+ return toPosix(relative4(real(evidence.docsDir), real(evidence.startCopy)));
669
+ }
670
+ return start.display;
671
+ }
672
+ function whoTheReaderIs(spec) {
673
+ const p = spec.persona;
674
+ if (p === null) return "The reader: someone new to this product, with the task above and no other context.";
675
+ const lines = [`The reader: ${[p.title ?? p.id, p.description].filter(Boolean).join(". ")}`];
676
+ if (p.role !== void 0) lines.push(`Role: ${p.role}`);
677
+ if (p.proficiency.length > 0) lines.push(`Already good at: ${p.proficiency.join("; ")}`);
678
+ if (p.prerequisites.length > 0) lines.push(`Knows before starting: ${p.prerequisites.join("; ")}`);
679
+ return lines.join("\n");
680
+ }
681
+ function toolResults(events) {
682
+ const out = /* @__PURE__ */ new Map();
683
+ for (const event of events) {
684
+ if (event.kind !== "tool_result") continue;
685
+ const message = event.raw.message;
686
+ const content = isRecord2(message) ? message.content : void 0;
687
+ if (!Array.isArray(content)) continue;
688
+ const found = [];
689
+ for (const block of content) {
690
+ if (!isRecord2(block) || block.type !== "tool_result") continue;
691
+ if (typeof block.tool_use_id !== "string") continue;
692
+ found.push({ id: block.tool_use_id, text: resultText(block.content) });
693
+ }
694
+ out.set(event.index, found);
695
+ }
696
+ return out;
697
+ }
698
+ function resultText(content) {
699
+ if (typeof content === "string") return content;
700
+ if (!Array.isArray(content)) return "";
701
+ return content.map((b) => isRecord2(b) && typeof b.text === "string" ? b.text : "").filter((t) => t !== "").join("\n");
702
+ }
703
+ function renderTrace(evidence, results) {
704
+ const { trace } = evidence;
705
+ const callName = /* @__PURE__ */ new Map();
706
+ const lines = [];
707
+ for (const event of trace.events) {
708
+ switch (event.kind) {
709
+ case "user":
710
+ if (event.text) lines.push(`[user] ${clip(event.text, MAX_TOOL_RESULT_CHARS)}`);
711
+ break;
712
+ case "assistant":
713
+ if (event.text) lines.push(`[assistant] ${clip(event.text, MAX_TOOL_RESULT_CHARS)}`);
714
+ break;
715
+ case "tool_call": {
716
+ const name = event.toolName ?? "?";
717
+ if (typeof event.raw.id === "string") callName.set(event.raw.id, name);
718
+ const input = JSON.stringify(event.raw.input ?? {});
719
+ lines.push(`[tool] ${name} ${clip(input, MAX_TOOL_RESULT_CHARS)}`);
720
+ break;
721
+ }
722
+ case "tool_result":
723
+ for (const r of results.get(event.index) ?? []) {
724
+ lines.push(`[result of ${callName.get(r.id) ?? r.id}] ${clip(r.text, MAX_TOOL_RESULT_CHARS)}`);
725
+ }
726
+ break;
727
+ default:
728
+ break;
729
+ }
730
+ }
731
+ return lines.length > 0 ? lines.join("\n") : "(no events)";
732
+ }
733
+ function renderWorkspace(evidence) {
734
+ const { added, changed, removed } = evidence.changes;
735
+ const lines = [];
736
+ if (added.length > 0) lines.push(`added: ${added.join(", ")}`);
737
+ if (changed.length > 0) lines.push(`changed: ${changed.join(", ")}`);
738
+ if (removed.length > 0) lines.push(`removed: ${removed.join(", ")}`);
739
+ if (lines.length === 0) return "No file was added, changed or removed.";
740
+ let room = MAX_WORKSPACE_CHARS;
741
+ for (const file of [...added, ...changed]) {
742
+ const content = readText(join4(evidence.workspaceDir, file));
743
+ if (content === void 0) continue;
744
+ if (room <= 0) {
745
+ lines.push(`
746
+ ### ${file}
747
+ [left out: the workspace's ${String(MAX_WORKSPACE_CHARS)}-character limit is reached]`);
748
+ continue;
749
+ }
750
+ const { body, used } = budgeted(content, Math.min(MAX_FILE_CHARS, room));
751
+ room -= used;
752
+ lines.push(`
753
+ ### ${file}
754
+ ${body}`);
755
+ }
756
+ return lines.join("\n");
757
+ }
758
+ function renderDocs(evidence, results) {
759
+ const { trace, spec, docsDir, startCopy } = evidence;
760
+ const fetched = /* @__PURE__ */ new Map();
761
+ const byId = /* @__PURE__ */ new Map();
762
+ for (const list2 of results.values()) for (const r of list2) byId.set(r.id, r.text);
763
+ const pages = [];
764
+ const seen = /* @__PURE__ */ new Set();
765
+ const add = (key, page) => {
766
+ if (page === void 0 || seen.has(key)) return;
767
+ seen.add(key);
768
+ pages.push(page);
769
+ };
770
+ const docsRoot = docsDir === null ? null : real(docsDir);
771
+ const docPage = (file) => {
772
+ if (docsRoot === null) return void 0;
773
+ const rel = relative4(docsRoot, real(file));
774
+ if (rel === "" || rel === ".." || rel.startsWith(`..${sep2}`) || isAbsolute2(rel)) return void 0;
775
+ const text2 = readText(file);
776
+ return text2 === void 0 ? void 0 : { name: toPosix(rel), text: text2 };
777
+ };
778
+ for (const event of trace.events) {
779
+ if (event.kind !== "tool_call" || event.toolName !== "WebFetch") continue;
780
+ const url = inputOf(event).url;
781
+ const id = event.raw.id;
782
+ if (typeof url === "string" && typeof id === "string" && !fetched.has(url)) {
783
+ fetched.set(url, byId.get(id) ?? "");
784
+ }
785
+ }
786
+ if (spec.start.kind === "url") {
787
+ const text2 = fetched.get(spec.start.url);
788
+ if (text2 !== void 0) add(urlKey(spec.start.url), { name: spec.start.url, text: text2 });
789
+ } else if (startCopy !== null) {
790
+ add(pathKey(startCopy), docPage(startCopy));
791
+ }
792
+ for (const event of trace.events) {
793
+ if (event.kind !== "tool_call") continue;
794
+ const input = inputOf(event);
795
+ if (event.toolName === "Read" && typeof input.file_path === "string") {
796
+ add(pathKey(input.file_path), docPage(input.file_path));
797
+ } else if (event.toolName === "WebFetch" && typeof input.url === "string") {
798
+ add(urlKey(input.url), { name: input.url, text: fetched.get(input.url) ?? "" });
799
+ }
800
+ }
801
+ const blocks = [];
802
+ const docs = [];
803
+ let room = MAX_DOCS_CHARS;
804
+ for (const page of pages) {
805
+ if (room <= 0) break;
806
+ const { body, used } = budgeted(page.text, room);
807
+ blocks.push(`### ${page.name}
808
+ ${body}`);
809
+ room -= used;
810
+ docs.push(page.name);
811
+ }
812
+ return {
813
+ text: blocks.length > 0 ? blocks.join("\n\n") : "The reader opened no page of the docs.",
814
+ docs
815
+ };
816
+ }
817
+ function inputOf(event) {
818
+ const input = event.raw.input;
819
+ return isRecord2(input) ? input : {};
820
+ }
821
+ function pathKey(file) {
822
+ const key = real(file);
823
+ return process.platform === "win32" ? `file:${key.toLowerCase()}` : `file:${key}`;
824
+ }
825
+ function urlKey(url) {
826
+ return `url:${url}`;
827
+ }
828
+ function real(file) {
829
+ try {
830
+ return realpathSync.native(file);
831
+ } catch {
832
+ return resolve2(file);
833
+ }
834
+ }
835
+ function readText(file) {
836
+ let bytes;
837
+ try {
838
+ bytes = readFileSync2(file);
839
+ } catch {
840
+ return void 0;
841
+ }
842
+ if (bytes.subarray(0, 8e3).includes(0)) return void 0;
843
+ return bytes.toString("utf8");
844
+ }
845
+ function toPosix(path) {
846
+ return path.split(sep2).join("/");
847
+ }
848
+ function isRecord2(value) {
849
+ return typeof value === "object" && value !== null && !Array.isArray(value);
850
+ }
851
+
852
+ // src/test/core/judge-run.ts
853
+ var FOLLOWED_THE_DOCS_ID = "followed-the-docs";
854
+ var FOLLOWED_THE_DOCS = "Every step the reader took came from the docs it had, or from what the persona already knows. It did not guess or lean on outside knowledge.";
855
+ var SUCCESS_ID = "success";
856
+ var COMPLETED_ID = "completed";
857
+ var CONSTRAINT_ID = "constraint";
858
+ var judgeRun = async (evidence, options) => {
859
+ const { spec } = evidence;
860
+ const seen = renderEvidence(evidence);
861
+ const artifact = {
862
+ name: spec.journey?.id ?? "task",
863
+ type: "project-rules",
864
+ path: spec.journey === null ? "task" : join5(evidence.configDir, spec.journey.file),
865
+ content: taskBrief(evidence),
866
+ origin: "project"
867
+ };
868
+ const providers = await providersFor(options);
869
+ const source = taskSource(evidence);
870
+ const slots = [];
871
+ const judged = (id, assertion, severity, location) => ({
872
+ base: { id, grader: "ai", severity, assertion, location },
873
+ plan: {
874
+ artifact,
875
+ evalName: id,
876
+ assertion,
877
+ grader: "ai",
878
+ severity,
879
+ implicit: false,
880
+ location: planLocation(location)
881
+ }
882
+ });
883
+ const journey = spec.journey;
884
+ if (journey?.successCriteria !== void 0) {
885
+ const { text: text2, location } = journey.successCriteria;
886
+ slots.push(judged(SUCCESS_ID, text2, "error", location));
887
+ }
888
+ for (const { entry, location } of journey?.evals ?? []) {
889
+ slots.push({
890
+ base: {
891
+ id: entry.id,
892
+ grader: entry.grader,
893
+ severity: entry.severity,
894
+ assertion: entry.assertion,
895
+ location
896
+ },
897
+ plan: planFor(entry, artifact, location)
898
+ });
899
+ }
900
+ if (slots.length === 0) {
901
+ slots.push(judged(COMPLETED_ID, `The reader completed the task: ${spec.task}`, "error", source));
902
+ }
903
+ slots.push(judged(FOLLOWED_THE_DOCS_ID, FOLLOWED_THE_DOCS, "warning", source));
904
+ for (const c of spec.persona?.constraints ?? []) {
905
+ slots.push(judged(CONSTRAINT_ID, c.text, "warning", c.location));
906
+ }
907
+ const outcomes = [];
908
+ const toJudge = [];
909
+ for (const [i, slot] of slots.entries()) {
910
+ if (slot.plan.skipped === true) {
911
+ outcomes[i] = { outcome: "skipped", message: slot.plan.skipReason };
912
+ } else if (slot.plan.grader === "ai") {
913
+ toJudge.push({ i, plan: slot.plan });
914
+ } else {
915
+ outcomes[i] = await gradeDeterministic(slot.plan, evidence);
916
+ }
917
+ }
918
+ if (toJudge.length > 0) {
919
+ const judge = makeTraceJudge({
920
+ provider: providers.judge,
921
+ ...providers.providerFor === void 0 ? {} : { providerFor: providers.providerFor },
922
+ noCache: true
923
+ });
924
+ const verdicts = await mapConcurrent(
925
+ toJudge,
926
+ providers.concurrency,
927
+ async (j) => judge([j.plan], () => seen.text, { trace: evidence.trace, projectRoot: evidence.workspaceDir })
928
+ );
929
+ verdicts.forEach(([v], n) => {
930
+ const i = toJudge[n]?.i;
931
+ if (i !== void 0 && v !== void 0) outcomes[i] = fromVerdict(v);
932
+ });
933
+ }
934
+ return {
935
+ evals: slots.map((slot, i) => ({
936
+ ...slot.base,
937
+ ...outcomes[i] ?? { outcome: "error", message: "the judge returned no verdict for this eval" }
938
+ })),
939
+ docs: seen.docs
940
+ };
941
+ };
942
+ var JUDGE_CONCURRENCY = 4;
943
+ async function providersFor(options) {
944
+ if (options.judgeProvider !== void 0) {
945
+ return { judge: options.judgeProvider, concurrency: 1 };
946
+ }
947
+ try {
948
+ const config = parseConfig({}, { providers: options.providers });
949
+ const flags = {
950
+ ...options.provider === void 0 ? {} : { provider: options.provider },
951
+ ...options.model === void 0 ? {} : { model: options.model }
952
+ };
953
+ const identity = await resolveProviderIdentity(config, flags);
954
+ return {
955
+ judge: constructProvider(config, identity),
956
+ providerFor: (choice) => makeJudgeProvider(config, flags, choice),
957
+ concurrency: identity.provider === LOCAL_PROVIDER ? 1 : JUDGE_CONCURRENCY
958
+ };
959
+ } catch (err) {
960
+ if (err instanceof TracevalsError) throw new TestError(err.message);
961
+ throw err;
962
+ }
963
+ }
964
+ function taskSource(evidence) {
965
+ const { journey, start } = evidence.spec;
966
+ if (journey !== null) return journey.titleLocation;
967
+ if (start.kind === "url") return null;
968
+ return {
969
+ file: relative5(evidence.configDir, start.abs).split(sep3).join("/"),
970
+ line: 1
971
+ };
972
+ }
973
+ function planLocation(location) {
974
+ return location ?? { file: "task" };
975
+ }
976
+ function planFor(entry, artifact, location) {
977
+ return {
978
+ artifact,
979
+ evalName: entry.id,
980
+ assertion: entry.assertion,
981
+ grader: entry.grader,
982
+ severity: entry.severity,
983
+ implicit: false,
984
+ location: planLocation(location),
985
+ options: entry.options,
986
+ evidence: entry.evidence,
987
+ examples: entry.examples,
988
+ provider: entry.provider,
989
+ model: entry.model,
990
+ runs: entry.runs,
991
+ target: entry.target,
992
+ command: entry.command,
993
+ successExitCodes: entry.successExitCodes,
994
+ timeoutMs: entry.timeoutMs,
995
+ generatedAssertionHash: entry.generatedAssertionHash,
996
+ ...entry.skip === true ? { skipped: true, skipReason: "eval skipped via its own skip: true" } : {}
997
+ };
998
+ }
999
+ async function gradeDeterministic(plan, evidence) {
1000
+ const grader = graderFor(plan.grader);
1001
+ if (grader === void 0) {
1002
+ return { outcome: "error", message: `no grader "${plan.grader}"` };
1003
+ }
1004
+ try {
1005
+ const result = await grader.grade({
1006
+ trace: evidence.trace,
1007
+ plan,
1008
+ projectRoot: evidence.workspaceDir
1009
+ });
1010
+ if (result.error !== void 0) return { outcome: "error", message: result.error };
1011
+ if (result.skipped !== void 0) return { outcome: "skipped", message: result.skipped };
1012
+ if (result.findings.length === 0) return { outcome: "pass" };
1013
+ return {
1014
+ outcome: "fail",
1015
+ // tracevals' advice names an artifact; a run is graded against a task.
1016
+ message: result.findings.map((f) => f.message.replace(` ${REDO_OR_FIX}`, "")).join(" ")
1017
+ };
1018
+ } catch (err) {
1019
+ return { outcome: "error", message: `${plan.grader}: ${errorMessage(err)}` };
1020
+ }
1021
+ }
1022
+ function fromVerdict(v) {
1023
+ const reasoning = v.consensus === void 0 ? void 0 : evidenceVerdict(v.consensus)?.reasoning;
1024
+ return {
1025
+ outcome: v.outcome,
1026
+ message: v.error ?? v.skipReason ?? reasoning,
1027
+ ...v.consensus === void 0 ? {} : {
1028
+ consensus: {
1029
+ votes: { ...v.consensus.votes },
1030
+ meanConfidence: v.consensus.meanConfidence
1031
+ }
1032
+ }
1033
+ };
1034
+ }
1035
+
1036
+ // src/test/core/prompts.ts
1037
+ var NEWCOMER = "Someone new to this product, with the task below and no other context.";
1038
+ var HOW_TO_WORK = [
1039
+ "How to work:",
1040
+ "- Use what the documentation tells you, and what this person would already know.",
1041
+ "- Nobody is available to answer questions. When stuck, do what this person",
1042
+ " would do, or give up.",
1043
+ "- The current directory is yours. Treat the documentation as read-only.",
1044
+ "- When you finish or give up, end with a short account in this person's voice:",
1045
+ " whether you got it done, where you got stuck, and what in the docs helped or",
1046
+ " confused you."
1047
+ ];
1048
+ function items(label2, values) {
1049
+ return values.length === 0 ? [] : [`${label2}:`, ...values.map((v) => `- ${v}`)];
1050
+ }
1051
+ function whoYouAre(persona) {
1052
+ if (persona === null) return [NEWCOMER];
1053
+ const lines = [[persona.title ?? persona.id, persona.description].filter((v) => v !== void 0).join(". ")];
1054
+ if (persona.role !== void 0) lines.push(`Role: ${persona.role}`);
1055
+ if (persona.teamContext !== void 0) lines.push(`Team: ${persona.teamContext}`);
1056
+ lines.push(
1057
+ ...items("Already good at", persona.proficiency),
1058
+ ...items("Knows before starting", persona.prerequisites),
1059
+ ...items("Wants", persona.goals),
1060
+ ...items("Frustrated by", persona.pains),
1061
+ ...items(
1062
+ "Your constraints",
1063
+ persona.constraints.map((c) => c.text)
1064
+ )
1065
+ );
1066
+ return lines;
1067
+ }
1068
+ function rolePrompt(persona) {
1069
+ return [
1070
+ "You are taking part in a usability test of some documentation. You are playing",
1071
+ "a person, not an assistant. Stay in that person's shoes for the whole session.",
1072
+ "",
1073
+ "Who you are:",
1074
+ ...whoYouAre(persona),
1075
+ "",
1076
+ ...HOW_TO_WORK,
1077
+ ""
1078
+ ].join("\n");
1079
+ }
1080
+ function taskBriefFor(spec, startFromWorkspace) {
1081
+ const lines = [spec.task];
1082
+ if (spec.journey?.trigger !== void 0) lines.push(`What started this: ${spec.journey.trigger}`);
1083
+ if (spec.journey?.successCriteria !== void 0) {
1084
+ lines.push(`You're done when: ${spec.journey.successCriteria.text}`);
1085
+ }
1086
+ const start = spec.start.kind === "url" ? spec.start.url : startFromWorkspace ?? spec.start.display;
1087
+ lines.push(`Start here: ${start}`);
1088
+ return `${lines.join("\n")}
1089
+ `;
1090
+ }
1091
+
1092
+ // src/test/core/task-records.ts
1093
+ import { readFile as readFile2 } from "node:fs/promises";
1094
+ import { extname, relative as relative6, resolve as resolve3, sep as sep4 } from "node:path";
1095
+ var TASK_GRADERS = [
1096
+ "ai",
1097
+ "command",
1098
+ "regex",
1099
+ "file-access",
1100
+ "tool-usage",
1101
+ "tool-order",
1102
+ "turn-count",
1103
+ "cost"
1104
+ ];
1105
+ var GRADER_LIST = `${TASK_GRADERS.slice(0, -1).join(", ")} or ${TASK_GRADERS.at(-1) ?? ""}`;
1106
+ function text(value) {
1107
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
1108
+ }
1109
+ function list(value) {
1110
+ if (typeof value === "string") return value.trim() === "" ? [] : [value];
1111
+ if (!Array.isArray(value)) return [];
1112
+ return value.filter((v) => typeof v === "string" && v.trim() !== "");
1113
+ }
1114
+ async function asTestError2(work) {
1115
+ try {
1116
+ return await work();
1117
+ } catch (err) {
1118
+ if (err instanceof ToolError && !(err instanceof TestError)) throw new TestError(err.message);
1119
+ throw err;
1120
+ }
1121
+ }
1122
+ function loadTaskRecords(file, cwd) {
1123
+ const configDir = file?.dir ?? cwd;
1124
+ let loaded;
1125
+ const load = () => {
1126
+ loaded ??= asTestError2(async () => {
1127
+ if (file === null || file.collections.length === 0) {
1128
+ const set2 = { records: [], references: [] };
1129
+ return { set: set2, index: indexSet(set2), base: configDir };
1130
+ }
1131
+ const { set, run } = await loadStrategy({ cwd, inputs: [], configPath: file.path, allowEmpty: true });
1132
+ return { set, index: indexSet(set), base: run.base };
1133
+ });
1134
+ return loaded;
1135
+ };
1136
+ const readRecord = async (record, base) => {
1137
+ const abs = resolve3(base, record.file);
1138
+ const file2 = relative6(configDir, abs).split(sep4).join("/");
1139
+ const extractor = extractorForExtension(extname(abs));
1140
+ if (extractor === void 0) throw new TestError(`${file2}: no reader for its extension.`);
1141
+ try {
1142
+ const extracted = extractor.extract(await readFile2(abs, "utf8"), abs);
1143
+ return { file: file2, dir: configDir, data: extracted.data, lineFor: extracted.lineFor };
1144
+ } catch (err) {
1145
+ throw new TestError(`${file2}: could not be read: ${errorMessage(err)}`);
1146
+ }
1147
+ };
1148
+ const byId = async (id, type, flag) => {
1149
+ const { set, index, base } = await load();
1150
+ const record = index.anyWithId(id);
1151
+ if (record === void 0) throw new TestError(unknownRecordMessage(id, set.records));
1152
+ if (record.type !== type) throw new TestError(`"${id}" is a ${record.type}; ${flag} takes a ${type}.`);
1153
+ return { record, ...await readRecord(record, base) };
1154
+ };
1155
+ const persona = async (id, journey) => {
1156
+ if (journey === void 0) {
1157
+ const { record: record2, ...rf } = await byId(id, "persona", "--persona");
1158
+ return personaOf(record2.id, rf);
1159
+ }
1160
+ const { index, base } = await load();
1161
+ const record = index.resolve("persona", id);
1162
+ if (record === void 0) {
1163
+ throw new TestError(`journey "${journey.id}" names persona "${id}", which has no record.`);
1164
+ }
1165
+ return personaOf(record.id, await readRecord(record, base));
1166
+ };
1167
+ return {
1168
+ journey: async (id) => {
1169
+ const { record, ...rf } = await byId(id, "journey", "--journey");
1170
+ return journeyOf(record.id, rf);
1171
+ },
1172
+ persona,
1173
+ golden: async () => {
1174
+ const { set, base } = await load();
1175
+ const out = [];
1176
+ for (const record of set.records) {
1177
+ if (record.type !== "journey") continue;
1178
+ const rf = await readRecord(record, base);
1179
+ if (rf.data["evals"] === void 0) continue;
1180
+ out.push(journeyOf(record.id, rf));
1181
+ }
1182
+ return out;
1183
+ }
1184
+ };
1185
+ }
1186
+ function at(rf, pointer) {
1187
+ return { file: rf.file, line: rf.lineFor(pointer) ?? 1 };
1188
+ }
1189
+ function personaOf(id, rf) {
1190
+ const { data } = rf;
1191
+ const title = text(data["title"]);
1192
+ const description = text(data["description"]);
1193
+ const role = text(data["role"]);
1194
+ const teamContext = text(data["team-context"]);
1195
+ const raw = data["constraints"];
1196
+ const constraints = Array.isArray(raw) ? raw.flatMap(
1197
+ (item, i) => typeof item === "string" && item.trim() !== "" ? [{ text: item, location: at(rf, `/constraints/${String(i)}`) }] : []
1198
+ ) : list(raw).map((item) => ({ text: item, location: at(rf, "/constraints") }));
1199
+ return {
1200
+ id,
1201
+ file: rf.file,
1202
+ ...title === void 0 ? {} : { title },
1203
+ ...description === void 0 ? {} : { description },
1204
+ ...role === void 0 ? {} : { role },
1205
+ ...teamContext === void 0 ? {} : { teamContext },
1206
+ proficiency: list(data["proficiency"]),
1207
+ prerequisites: list(data["prerequisites"]),
1208
+ goals: list(data["goals"]),
1209
+ pains: list(data["pains"]),
1210
+ constraints
1211
+ };
1212
+ }
1213
+ function journeyOf(id, rf) {
1214
+ const { data } = rf;
1215
+ const title = text(data["title"]);
1216
+ const trigger = text(data["trigger"]);
1217
+ const success = text(data["success-criteria"]);
1218
+ const entryPoint = text(data["entry-point"]);
1219
+ const workspace = text(data["workspace"]);
1220
+ return {
1221
+ id,
1222
+ file: rf.file,
1223
+ title: title ?? id,
1224
+ titleLocation: title === void 0 ? { file: rf.file, line: 1 } : at(rf, "/title"),
1225
+ ...trigger === void 0 ? {} : { trigger },
1226
+ ...success === void 0 ? {} : { successCriteria: { text: success, location: at(rf, "/success-criteria") } },
1227
+ ...entryPoint === void 0 ? {} : { entryPoint: { value: entryPoint, location: at(rf, "/entry-point") } },
1228
+ ...workspace === void 0 ? {} : { workspace: { value: workspace, location: at(rf, "/workspace") } },
1229
+ personas: list(data["personas"]),
1230
+ evals: journeyEvals(rf)
1231
+ };
1232
+ }
1233
+ function journeyEvals(rf) {
1234
+ const raw = rf.data["evals"];
1235
+ if (raw === void 0) return [];
1236
+ const where = (pointer) => `${rf.file}:${String(rf.lineFor(pointer) ?? 1)}`;
1237
+ if (!Array.isArray(raw)) throw new TestError(`${where("/evals")}: evals must be a list of eval entries.`);
1238
+ const seen = /* @__PURE__ */ new Map();
1239
+ for (const [i, entry] of raw.entries()) {
1240
+ const n = String(i);
1241
+ const obj = typeof entry === "object" && entry !== null && !Array.isArray(entry) ? entry : {};
1242
+ const id = text(obj["id"]);
1243
+ if (id === void 0) throw new TestError(`${where(`/evals/${n}`)}: evals[${n}] needs an id.`);
1244
+ const grader = typeof obj["grader"] === "string" ? obj["grader"] : "ai";
1245
+ if (!TASK_GRADERS.includes(grader)) {
1246
+ throw new TestError(
1247
+ `${where(`/evals/${n}/grader`)}: evals[${n}].grader "${grader}" cannot grade a task. Use ${GRADER_LIST}.`
1248
+ );
1249
+ }
1250
+ const first = seen.get(id);
1251
+ if (first !== void 0) {
1252
+ throw new TestError(`${where(`/evals/${n}/id`)}: evals[${n}].id "${id}" repeats evals[${String(first)}].`);
1253
+ }
1254
+ seen.set(id, i);
1255
+ }
1256
+ const errors = artifactEvalsErrors(
1257
+ { metadata: { evals: raw } },
1258
+ (pointer) => rf.lineFor(pointer.replace(/^\/metadata/, ""))
1259
+ );
1260
+ const firstError = errors[0];
1261
+ if (firstError !== void 0) {
1262
+ const path = firstError.instancePath.replace(/^\/metadata/, "");
1263
+ const m = /^\/evals\/(\d+)(.*)$/.exec(path);
1264
+ const label2 = m === null ? "evals" : `evals[${m[1] ?? ""}]${(m[2] ?? "").replaceAll("/", ".")}`;
1265
+ throw new TestError(`${where(path)}: ${label2} ${firstError.message}.`);
1266
+ }
1267
+ return raw.map((entry, i) => {
1268
+ const n = String(i);
1269
+ const normalized = normalizeEntry(entry, i);
1270
+ const validate = graderFor(normalized.grader)?.validateOptions;
1271
+ const invalid = validate?.(normalized.options ?? {});
1272
+ if (invalid !== void 0) {
1273
+ const pointer = normalized.options === void 0 ? `/evals/${n}` : `/evals/${n}/options`;
1274
+ throw new TestError(`${where(pointer)}: evals[${n}] ${invalid}`);
1275
+ }
1276
+ return { entry: normalized, location: at(rf, `/evals/${n}`) };
1277
+ });
1278
+ }
1279
+
1280
+ // src/test/core/workspace.ts
1281
+ import { createHash } from "node:crypto";
1282
+ import { realpathSync as realpathSync2, statSync as statSync3 } from "node:fs";
1283
+ import { cp, mkdir, mkdtemp as mkdtemp2, readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
1284
+ import { tmpdir as tmpdir2 } from "node:os";
1285
+ import { basename, dirname, isAbsolute as isAbsolute3, join as join6, relative as relative7, resolve as resolve4, sep as sep5 } from "node:path";
1286
+ import picomatch2 from "picomatch";
1287
+ var SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
1288
+ var keep = (src) => !SKIPPED_DIRS.has(basename(src));
1289
+ var toPosix2 = (path) => path.split(sep5).join("/");
1290
+ async function prepareRun(start, seed, file) {
1291
+ const root = realpathSync2.native(await mkdtemp2(join6(tmpdir2(), "manni-task-")));
1292
+ const workspaceDir = join6(root, "workspace");
1293
+ const globalDir = join6(root, "global");
1294
+ await mkdir(workspaceDir);
1295
+ await mkdir(globalDir);
1296
+ if (seed !== null) await cp(seed, workspaceDir, { recursive: true, filter: keep });
1297
+ if (start.kind === "url") return { root, workspaceDir, globalDir, docsDir: null, startCopy: null };
1298
+ const docsDir = join6(root, "docs");
1299
+ const startCopy = join6(docsDir, await copyDocs(start.abs, file, docsDir));
1300
+ return { root, workspaceDir, globalDir, docsDir, startCopy };
1301
+ }
1302
+ async function copyDocs(page, file, docsDir) {
1303
+ const collections = file === null ? [] : selectCollections(file.collections, [], file.source, (m) => new TestError(m));
1304
+ for (const collection of collections) {
1305
+ const dir = file?.dir ?? dirname(page);
1306
+ const { files } = await resolveTargetSet({
1307
+ inputs: collection.paths,
1308
+ exclude: collection.exclude,
1309
+ cwd: dir,
1310
+ allowEmpty: true
1311
+ });
1312
+ const abs = files.map((f) => resolve4(dir, f));
1313
+ if (!abs.some((f) => samePath(f, page))) continue;
1314
+ const base = globBase(collection.paths, dir);
1315
+ const pageRel = copyPathFor(base, page);
1316
+ if (pageRel === void 0) break;
1317
+ for (const f of abs) {
1318
+ const rel = copyPathFor(base, f);
1319
+ if (rel === void 0) continue;
1320
+ const dest = join6(docsDir, rel);
1321
+ await mkdir(dirname(dest), { recursive: true });
1322
+ await cp(f, dest);
1323
+ }
1324
+ return pageRel;
1325
+ }
1326
+ await cp(dirname(page), docsDir, { recursive: true, filter: keep });
1327
+ return basename(page);
1328
+ }
1329
+ function copyPathFor(base, file) {
1330
+ const rel = relative7(base, file);
1331
+ if (rel === "" || isAbsolute3(rel) || rel === ".." || rel.startsWith(`..${sep5}`)) return void 0;
1332
+ return rel;
1333
+ }
1334
+ function samePath(a, b) {
1335
+ return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
1336
+ }
1337
+ function globBase(paths, dir) {
1338
+ const bases = paths.map((p) => {
1339
+ const scan = picomatch2.scan(p.replace(/\\/g, "/"));
1340
+ const abs = resolve4(dir, scan.isGlob ? scan.base : p);
1341
+ return scan.isGlob || isDirectory(abs) ? abs : dirname(abs);
1342
+ });
1343
+ const [first, ...rest] = bases.map((b) => b.split(sep5));
1344
+ if (first === void 0) return dir;
1345
+ let depth = first.length;
1346
+ for (const parts of rest) {
1347
+ let i = 0;
1348
+ while (i < depth && i < parts.length && parts[i] === first[i]) i++;
1349
+ depth = i;
1350
+ }
1351
+ return first.slice(0, depth).join(sep5) || sep5;
1352
+ }
1353
+ function isDirectory(path) {
1354
+ try {
1355
+ return statSync3(path).isDirectory();
1356
+ } catch {
1357
+ return false;
1358
+ }
1359
+ }
1360
+ async function hashTree(dir) {
1361
+ const out = /* @__PURE__ */ new Map();
1362
+ const walk = async (at3) => {
1363
+ for (const entry of await readdir2(at3, { withFileTypes: true })) {
1364
+ const abs = join6(at3, entry.name);
1365
+ if (entry.isDirectory()) {
1366
+ if (!SKIPPED_DIRS.has(entry.name)) await walk(abs);
1367
+ } else if (entry.isFile()) {
1368
+ out.set(toPosix2(relative7(dir, abs)), createHash("sha256").update(await readFile3(abs)).digest("hex"));
1369
+ }
1370
+ }
1371
+ };
1372
+ await walk(dir);
1373
+ return out;
1374
+ }
1375
+ async function workspaceChanges(seed, workspaceDir) {
1376
+ const before = seed === null ? /* @__PURE__ */ new Map() : await hashTree(seed);
1377
+ const after = await hashTree(workspaceDir);
1378
+ const added = [];
1379
+ const changed = [];
1380
+ for (const [path, hash] of after) {
1381
+ const was = before.get(path);
1382
+ if (was === void 0) added.push(path);
1383
+ else if (was !== hash) changed.push(path);
1384
+ }
1385
+ const removed = [...before.keys()].filter((path) => !after.has(path));
1386
+ return { added: added.sort(), changed: changed.sort(), removed: removed.sort() };
1387
+ }
1388
+
1389
+ // src/test/commands/tasks.ts
1390
+ var NOTHING_TO_RUN = "nothing to run: no journey declares evals:. Pass --task with a page or URL, or --journey <id>.";
1391
+ var isUrl = (target) => /^https?:\/\//i.test(target);
1392
+ var toPosix3 = (path) => path.split(sep6).join("/");
1393
+ async function asTestError3(work) {
1394
+ try {
1395
+ return await work();
1396
+ } catch (err) {
1397
+ if (err instanceof ToolError && !(err instanceof TestError)) throw new TestError(err.message);
1398
+ throw err;
1399
+ }
1400
+ }
1401
+ var toError2 = (message) => new TestError(message);
1402
+ async function loadConfig2(cwd, configPath) {
1403
+ const opts = { section: "test", legacyNames: [], toError: toError2 };
1404
+ const file = configPath === void 0 ? await findConfigFile(cwd, opts) : await readConfigFile(configPath, cwd, opts);
1405
+ if (file !== null && file.wrapped && file.value !== null) {
1406
+ throw new TestError(
1407
+ `${file.source}: test has no keys. Doc Detective's settings live under tools.doc-detective, and Claude Code's under tools.claude-cli.`
1408
+ );
1409
+ }
1410
+ return file;
1411
+ }
1412
+ function stamp(date) {
1413
+ return date.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
1414
+ }
1415
+ function labelOf(spec) {
1416
+ return `${spec.journey?.id ?? "task"} as ${spec.persona?.id ?? "newcomer"}`;
1417
+ }
1418
+ function runOutcome(evals) {
1419
+ return evals.some((e) => e.severity === "error" && (e.outcome === "fail" || e.outcome === "error" || e.outcome === "needs-review")) ? "fail" : "pass";
1420
+ }
1421
+ async function runTasks(opts = {}) {
1422
+ const cwd = resolve5(opts.cwd ?? process.cwd());
1423
+ const targets = opts.targets ?? [];
1424
+ const journeyIds = opts.journeys ?? [];
1425
+ const personaIds = opts.personas ?? [];
1426
+ const task = opts.task;
1427
+ if (targets.includes(STDIN_TOKEN)) {
1428
+ throw new TestError("manni test tasks reads no stdin. Pass a page path or URL.");
1429
+ }
1430
+ if (task !== void 0 && journeyIds.length > 0) {
1431
+ throw new TestError("--task and --journey both name the task. Pass one.");
1432
+ }
1433
+ if (task !== void 0 && targets.length === 0) {
1434
+ throw new TestError("--task needs a page or URL to start from.");
1435
+ }
1436
+ if (task === void 0 && journeyIds.length === 0 && targets.length > 0) {
1437
+ throw new TestError('a start page needs a task. Pass --task "<what the reader wants>" or --journey <id>.');
1438
+ }
1439
+ const missing = targets.filter((t) => !isUrl(t) && !existsSync2(resolve5(cwd, t))).map((t) => t.replace(/\\/g, "/"));
1440
+ if (missing.length > 0) throw new TestError(notFoundMessage(missing));
1441
+ let workspaceOverride;
1442
+ if (opts.workspace !== void 0) {
1443
+ const abs = resolve5(cwd, opts.workspace);
1444
+ if (!existsSync2(abs)) throw new TestError(`--workspace "${opts.workspace}" does not exist.`);
1445
+ workspaceOverride = { abs, display: opts.workspace.replace(/\\/g, "/") };
1446
+ }
1447
+ const file = await loadConfig2(cwd, opts.configPath);
1448
+ const configDir = file?.dir ?? cwd;
1449
+ const claude = file?.tools["claude-cli"] ?? {};
1450
+ const mcpConfig = file === null ? void 0 : claudeCliMcpConfigPath(file.tools, file.dir);
1451
+ let mcpServers = [];
1452
+ if (file !== null && mcpConfig !== void 0) {
1453
+ const label2 = `${file.source}: tools.claude-cli.mcpConfig "${claude.mcpConfig ?? ""}"`;
1454
+ if (!existsSync2(mcpConfig)) throw new TestError(`${label2} does not exist.`);
1455
+ mcpServers = mcpServerNames(mcpConfig, label2);
1456
+ }
1457
+ const maxTurns = claude.maxTurns ?? DEFAULT_CLAUDE_CLI_MAX_TURNS;
1458
+ const records2 = loadTaskRecords(file, cwd);
1459
+ const pathStart = (abs) => ({ kind: "path", display: toPosix3(relative8(cwd, abs)) || ".", abs });
1460
+ const targetStarts = targets.map(
1461
+ (t) => isUrl(t) ? { kind: "url", url: t } : { kind: "path", display: t.replace(/\\/g, "/"), abs: resolve5(cwd, t) }
1462
+ );
1463
+ const explicitPersonas = [];
1464
+ for (const id of personaIds) explicitPersonas.push(await records2.persona(id));
1465
+ let journeys = [];
1466
+ if (task === void 0) {
1467
+ if (journeyIds.length > 0) {
1468
+ for (const id of journeyIds) journeys.push(await records2.journey(id));
1469
+ } else {
1470
+ journeys = await records2.golden();
1471
+ if (journeys.length === 0) {
1472
+ if (opts.allowEmpty === true) return { runs: [], summary: { runs: 0, passed: 0, failed: 0, warnings: 0 }, exitCode: 0 };
1473
+ throw new TestError(NOTHING_TO_RUN);
1474
+ }
1475
+ }
1476
+ }
1477
+ const specs = [];
1478
+ if (task !== void 0) {
1479
+ const personas = explicitPersonas.length > 0 ? explicitPersonas : [null];
1480
+ for (const start of targetStarts) {
1481
+ for (const persona of personas) {
1482
+ specs.push({
1483
+ task,
1484
+ journey: null,
1485
+ persona,
1486
+ start,
1487
+ workspaceSeed: workspaceOverride?.abs ?? null,
1488
+ workspaceDisplay: workspaceOverride?.display ?? null
1489
+ });
1490
+ }
1491
+ }
1492
+ }
1493
+ for (const journey of journeys) {
1494
+ let starts = targetStarts;
1495
+ if (starts.length === 0) {
1496
+ const entry = journey.entryPoint;
1497
+ if (entry === void 0) {
1498
+ throw new TestError(
1499
+ `journey "${journey.id}" has no entry-point:. Add one to ${journey.file}, or pass the page to start from.`
1500
+ );
1501
+ }
1502
+ if (isUrl(entry.value)) {
1503
+ starts = [{ kind: "url", url: entry.value }];
1504
+ } else {
1505
+ starts = [pathStart(recordedPath("entry-point", entry, configDir))];
1506
+ }
1507
+ }
1508
+ let seed = workspaceOverride ?? null;
1509
+ if (seed === null && journey.workspace !== void 0) {
1510
+ const abs = recordedPath("workspace", journey.workspace, configDir);
1511
+ seed = { abs, display: toPosix3(relative8(cwd, abs)) || "." };
1512
+ }
1513
+ let personas = explicitPersonas;
1514
+ if (personas.length === 0) {
1515
+ personas = [];
1516
+ for (const id of journey.personas) personas.push(await records2.persona(id, journey));
1517
+ if (personas.length === 0) personas = [null];
1518
+ }
1519
+ for (const start of starts) {
1520
+ for (const persona of personas) {
1521
+ specs.push({
1522
+ task: journey.title,
1523
+ journey,
1524
+ persona,
1525
+ start,
1526
+ workspaceSeed: seed?.abs ?? null,
1527
+ workspaceDisplay: seed?.display ?? null
1528
+ });
1529
+ }
1530
+ }
1531
+ }
1532
+ const runs = [];
1533
+ for (const spec of specs) {
1534
+ runs.push(
1535
+ await asTestError3(
1536
+ () => runOne(spec, {
1537
+ cwd,
1538
+ file,
1539
+ configDir,
1540
+ maxTurns,
1541
+ ...claude.model === void 0 ? {} : { model: claude.model },
1542
+ ...mcpConfig === void 0 ? {} : { mcpConfig },
1543
+ mcpServers,
1544
+ opts
1545
+ })
1546
+ )
1547
+ );
1548
+ }
1549
+ const passed = runs.filter((r) => r.outcome === "pass").length;
1550
+ const warnings = runs.flatMap((r) => r.evals).filter((e) => e.severity === "warning" && e.outcome !== "pass" && e.outcome !== "skipped").length;
1551
+ return {
1552
+ runs,
1553
+ summary: { runs: runs.length, passed, failed: runs.length - passed, warnings },
1554
+ exitCode: passed === runs.length ? 0 : 1
1555
+ };
1556
+ }
1557
+ function recordedPath(key, path, configDir) {
1558
+ const abs = resolve5(configDir, path.value);
1559
+ if (!existsSync2(abs)) {
1560
+ throw new TestError(`${path.location.file}:${String(path.location.line)}: ${key} "${path.value}" does not exist.`);
1561
+ }
1562
+ return abs;
1563
+ }
1564
+ async function claimRunDir(dir, base) {
1565
+ await mkdir2(dir, { recursive: true });
1566
+ for (let n = 1; ; n++) {
1567
+ const id = n === 1 ? base : `${base}-${String(n)}`;
1568
+ try {
1569
+ await mkdir2(join7(dir, id));
1570
+ return id;
1571
+ } catch (err) {
1572
+ if (!(err instanceof Error && "code" in err && err.code === "EEXIST")) throw err;
1573
+ }
1574
+ }
1575
+ }
1576
+ async function runOne(spec, ctx) {
1577
+ const { opts } = ctx;
1578
+ const label2 = labelOf(spec);
1579
+ const who = spec.persona?.id ?? "newcomer";
1580
+ const tasksDir = join7(ctx.configDir, ".manni", "test", "tasks");
1581
+ const id = await claimRunDir(tasksDir, `${stamp((opts.now ?? (() => /* @__PURE__ */ new Date()))())}-${spec.journey?.id ?? "task"}-${who}`);
1582
+ const runDir = join7(tasksDir, id);
1583
+ const tracePath = join7(runDir, "trace.jsonl");
1584
+ await writeFile(tracePath, "");
1585
+ const dirs = await prepareRun(spec.start, spec.workspaceSeed, ctx.file);
1586
+ try {
1587
+ const role = rolePrompt(spec.persona);
1588
+ const roleFile = join7(dirs.root, "role.md");
1589
+ const startFromWorkspace = dirs.startCopy === null ? null : toPosix3(relative8(dirs.workspaceDir, dirs.startCopy));
1590
+ const brief = taskBriefFor(spec, startFromWorkspace);
1591
+ await writeFile(roleFile, role);
1592
+ await writeFile(join7(runDir, "role.md"), role);
1593
+ await writeFile(join7(runDir, "brief.md"), brief);
1594
+ if (opts.progress === true) {
1595
+ const where = spec.workspaceDisplay === null ? "in an empty directory" : `in a fresh copy of ${spec.workspaceDisplay}`;
1596
+ process.stderr.write(`${label2}: starting ${where}
1597
+ `);
1598
+ }
1599
+ const lines = lineSplitter((line) => {
1600
+ if (opts.progress !== true || line === "") return;
1601
+ for (const use of toolUses(line)) {
1602
+ process.stderr.write(`${progressLine(who, use.name, use.input, dirs.workspaceDir)}
1603
+ `);
1604
+ }
1605
+ });
1606
+ let writing = Promise.resolve();
1607
+ const result = await (opts.spawn ?? realClaudeCodeSpawn)(
1608
+ claudeCodeArgs({
1609
+ roleFile,
1610
+ maxTurns: ctx.maxTurns,
1611
+ ...ctx.model === void 0 ? {} : { model: ctx.model },
1612
+ ...ctx.mcpConfig === void 0 ? {} : { mcpConfig: ctx.mcpConfig },
1613
+ mcpServers: ctx.mcpServers,
1614
+ docsDir: dirs.docsDir
1615
+ }),
1616
+ {
1617
+ cwd: dirs.workspaceDir,
1618
+ stdin: brief,
1619
+ env: claudeCodeEnv(dirs.globalDir),
1620
+ onStdout: (chunk) => {
1621
+ writing = writing.then(() => appendFile(tracePath, chunk));
1622
+ lines.push(chunk);
1623
+ }
1624
+ }
1625
+ );
1626
+ lines.end();
1627
+ await writing;
1628
+ const outcome = classifyRun(result, label2);
1629
+ const trace = await parseTraceFile(tracePath);
1630
+ const changes = await workspaceChanges(spec.workspaceSeed, dirs.workspaceDir);
1631
+ const account = trace.assistantTexts.at(-1) ?? "";
1632
+ const judged = await (opts.judge ?? judgeRun)(
1633
+ {
1634
+ spec,
1635
+ trace,
1636
+ tracePath,
1637
+ workspaceDir: dirs.workspaceDir,
1638
+ docsDir: dirs.docsDir,
1639
+ startCopy: dirs.startCopy,
1640
+ account,
1641
+ changes,
1642
+ configDir: ctx.configDir
1643
+ },
1644
+ {
1645
+ ...opts.provider === void 0 ? {} : { provider: opts.provider },
1646
+ ...opts.model === void 0 ? {} : { model: opts.model },
1647
+ providers: ctx.file?.providers ?? {},
1648
+ ...opts.judgeProvider === void 0 ? {} : { judgeProvider: opts.judgeProvider }
1649
+ }
1650
+ );
1651
+ let kept = null;
1652
+ if (opts.keep === true) {
1653
+ kept = dirs.workspaceDir;
1654
+ notice(`kept ${label2}'s workspace: ${kept}`);
1655
+ }
1656
+ const usage = trace.usage;
1657
+ return {
1658
+ id,
1659
+ journey: spec.journey?.id ?? null,
1660
+ task: spec.task,
1661
+ persona: spec.persona?.id ?? null,
1662
+ start: spec.start.kind === "url" ? spec.start.url : spec.start.display,
1663
+ workspace: spec.workspaceDisplay,
1664
+ kept,
1665
+ trace: toPosix3(relative8(ctx.cwd, tracePath)),
1666
+ turns: trace.turnCount,
1667
+ durationMs: outcome.durationMs,
1668
+ stoppedAtLimit: outcome.stoppedAtLimit,
1669
+ maxTurns: ctx.maxTurns,
1670
+ usage: {
1671
+ inputTokens: usage?.inputTokens ?? 0,
1672
+ outputTokens: usage?.outputTokens ?? 0,
1673
+ ...usage?.totalCostUsd === void 0 ? {} : { costUsd: usage.totalCostUsd }
1674
+ },
1675
+ docs: judged.docs,
1676
+ changes,
1677
+ account,
1678
+ evals: judged.evals,
1679
+ outcome: runOutcome(judged.evals)
1680
+ };
1681
+ } finally {
1682
+ if (opts.keep !== true) await removeRunDir(dirs.root, label2);
1683
+ }
1684
+ }
1685
+ async function removeRunDir(root, label2) {
1686
+ try {
1687
+ await rm2(root, { recursive: true, force: true, maxRetries: 3, retryDelay: 500 });
1688
+ } catch (err) {
1689
+ warn(
1690
+ `could not remove ${root} after ${label2}: ${errorMessage(err)}. A process the synthetic user started may still hold it; remove it by hand.`
1691
+ );
1692
+ }
1693
+ }
1694
+
1695
+ // src/test/reporters/finding.ts
1696
+ var FAIL_ADVICE = "Fix the step, fix the procedure it documents, or report a product regression.";
1697
+ function findingMessage(f) {
1698
+ if (f.result !== "FAIL") return f.description;
1699
+ if (f.description === "") return FAIL_ADVICE;
1700
+ const stop = f.description.endsWith(".") ? "" : ".";
1701
+ return `${f.description}${stop} ${FAIL_ADVICE}`;
1702
+ }
1703
+
1704
+ // src/test/reporters/summary.ts
1705
+ function summaryLine(tests) {
1706
+ const total = tests.pass + tests.fail + tests.warning + tests.skipped;
1707
+ const plural2 = (n, word) => `${String(n)} ${word}${n === 1 ? "" : "s"}`;
1708
+ return `${plural2(total, "test")}: ${String(tests.pass)} passed, ${String(tests.fail)} failed, ${plural2(tests.warning, "warning")}, ${String(tests.skipped)} skipped`;
1709
+ }
1710
+
1711
+ // src/test/reporters/github.ts
1712
+ function renderGithub(result) {
1713
+ const commands = result.findings.map((f) => {
1714
+ const level = f.result === "FAIL" ? "error" : "warning";
1715
+ const props = [
1716
+ ...f.file === "" ? [] : [`file=${escapeWorkflowCommandProperty(f.file)}`],
1717
+ ...f.line === void 0 ? [] : [`line=${String(f.line)}`],
1718
+ "title=Doc Detective"
1719
+ ].join(",");
1720
+ const message = [findingMessage(f), ...guidanceLines(f.guidance)].join("\n");
1721
+ return `::${level} ${props}::${escapeWorkflowCommandMessage(message)}`;
1722
+ });
1723
+ return [...commands, summaryLine(result.tests)].join("\n");
1724
+ }
1725
+
1726
+ // src/test/reporters/json.ts
1727
+ function renderJson(result) {
1728
+ return JSON.stringify(result.results, null, 2);
1729
+ }
1730
+
1731
+ // src/test/reporters/pretty.ts
1732
+ function renderPretty(result, opts) {
1733
+ const c = palette(opts.color);
1734
+ const byFile = /* @__PURE__ */ new Map();
1735
+ for (const finding of result.findings) {
1736
+ const list2 = byFile.get(finding.file);
1737
+ if (list2 === void 0) byFile.set(finding.file, [finding]);
1738
+ else list2.push(finding);
1739
+ }
1740
+ const width = Math.max(0, ...result.findings.map((f) => String(f.line ?? "").length));
1741
+ const indent = " ".repeat(2 + width + 2 + 7 + 2);
1742
+ const blocks = [...byFile].map(
1743
+ ([file, findings]) => [
1744
+ c.bold(file),
1745
+ ...findings.flatMap((f) => {
1746
+ const label2 = f.result.padEnd(7);
1747
+ const tag2 = f.result === "FAIL" ? c.red(label2) : c.yellow(label2);
1748
+ return [
1749
+ ` ${String(f.line ?? "").padStart(width)} ${tag2} ${findingMessage(f)}`,
1750
+ ...guidanceLines(f.guidance).map((line) => c.dim(`${indent}${line}`))
1751
+ ];
1752
+ })
1753
+ ].join("\n")
1754
+ );
1755
+ return [...blocks, summaryLine(result.tests)].join("\n\n");
1756
+ }
1757
+
1758
+ // src/test/reporters/tasks.ts
1759
+ var WIDTH = 78;
1760
+ var plural = (n, one) => `${String(n)} ${one}${n === 1 ? "" : "s"}`;
1761
+ function tasksTotal(summary) {
1762
+ let line = `${plural(summary.runs, "run")}: ${String(summary.passed)} passed`;
1763
+ if (summary.failed > 0) line += `, ${String(summary.failed)} failed`;
1764
+ if (summary.warnings > 0) line += ` \xB7 ${plural(summary.warnings, "warning")}`;
1765
+ return line;
1766
+ }
1767
+ function renderTasks(report, format, opts) {
1768
+ if (format === "json") return renderJson2(report);
1769
+ if (report.runs.length === 0) return "No tasks to run.";
1770
+ if (format === "github") return renderGithub2(report);
1771
+ const c = palette(opts.color);
1772
+ return [...report.runs.map((run) => runBlock(run, c)), tasksTotal(report.summary)].join("\n\n");
1773
+ }
1774
+ function renderJson2(report) {
1775
+ const runs = report.runs.map(({ maxTurns: _maxTurns, ...run }) => run);
1776
+ return JSON.stringify({ runs, summary: report.summary, exitCode: report.exitCode }, null, 2);
1777
+ }
1778
+ var label = (run) => `${run.journey ?? "task"} as ${run.persona ?? "newcomer"}`;
1779
+ var at2 = (e) => e.location === null ? "(no location)" : `${e.location.file}:${String(e.location.line)}`;
1780
+ function tag(e) {
1781
+ if (e.outcome === "pass") return "PASS";
1782
+ if (e.outcome === "skipped") return "SKIP";
1783
+ if (e.severity === "warning") return "WARN";
1784
+ if (e.severity === "notice") return "NOTE";
1785
+ return e.outcome === "fail" ? "FAIL" : e.outcome === "error" ? "ERROR" : "REVIEW";
1786
+ }
1787
+ function paint(text2, e, c) {
1788
+ const t = tag(e);
1789
+ if (t === "PASS") return c.green(text2);
1790
+ if (t === "WARN") return c.yellow(text2);
1791
+ if (t === "NOTE" || t === "SKIP") return c.dim(text2);
1792
+ return c.red(text2);
1793
+ }
1794
+ function duration(ms) {
1795
+ const s = Math.round(ms / 1e3);
1796
+ return `${String(Math.floor(s / 60))}m ${String(s % 60).padStart(2, "0")}s`;
1797
+ }
1798
+ function wrap(text2, indent) {
1799
+ const out = [];
1800
+ for (const paragraph of text2.split("\n")) {
1801
+ let line = "";
1802
+ for (const word of paragraph.split(/\s+/).filter((w) => w !== "")) {
1803
+ if (line !== "" && indent.length + line.length + 1 + word.length > WIDTH) {
1804
+ out.push(indent + line);
1805
+ line = word;
1806
+ } else {
1807
+ line = line === "" ? word : `${line} ${word}`;
1808
+ }
1809
+ }
1810
+ out.push(line === "" ? "" : indent + line);
1811
+ }
1812
+ return out;
1813
+ }
1814
+ function said(e) {
1815
+ if (e.consensus !== void 0) {
1816
+ const verdict = `AI judge: ${e.outcome} (confidence ${e.consensus.meanConfidence.toFixed(2)}).`;
1817
+ return e.message === void 0 ? verdict : `${verdict} ${e.message}`;
1818
+ }
1819
+ return e.message;
1820
+ }
1821
+ function runBlock(run, c) {
1822
+ const title = run.journey === null && run.task.length > 60 ? `${run.task.slice(0, 60)}\u2026` : run.task;
1823
+ const lines = [c.bold(`${run.journey ?? "task"} \xB7 ${title} \xB7 as ${run.persona ?? "newcomer"}`)];
1824
+ const field = (name, value) => ` ${name.padEnd(10)}${value}`;
1825
+ lines.push(field("start", run.start));
1826
+ if (run.docs.length > 0) lines.push(field("docs", run.docs.join(", ")));
1827
+ if (run.changes.added.length > 0) lines.push(field("added", run.changes.added.join(", ")));
1828
+ if (run.changes.changed.length > 0) lines.push(field("changed", run.changes.changed.join(", ")));
1829
+ if (run.changes.removed.length > 0) lines.push(field("removed", run.changes.removed.join(", ")));
1830
+ lines.push(` ${plural(run.turns, "turn")} \xB7 ${duration(run.durationMs)}`);
1831
+ const tagWidth = Math.max(4, ...run.evals.map((e) => tag(e).length));
1832
+ const idWidth = Math.max(0, ...run.evals.map((e) => e.id.length)) + 5;
1833
+ const detail = " ".repeat(2 + tagWidth + 1);
1834
+ for (const e of run.evals) {
1835
+ lines.push(` ${paint(tag(e).padEnd(tagWidth), e, c)} ${e.id.padEnd(idWidth)}${c.dim(at2(e))}`);
1836
+ if (e.outcome === "pass") continue;
1837
+ if (e.assertion !== void 0) lines.push(...wrap(e.assertion, detail));
1838
+ const message = said(e);
1839
+ if (message !== void 0) lines.push(...wrap(message, detail).map((l) => c.dim(l)));
1840
+ }
1841
+ if (run.stoppedAtLimit) lines.push(` stopped at the ${String(run.maxTurns)}-turn limit`);
1842
+ if (run.account.trim() !== "") lines.push(" Account", ...wrap(run.account.trim(), " "));
1843
+ if (run.kept !== null) lines.push(field("kept", run.kept));
1844
+ lines.push(field("trace", run.trace));
1845
+ return lines.join("\n");
1846
+ }
1847
+ function githubLine(run, e) {
1848
+ const level = e.severity === "notice" ? "notice" : e.severity === "warning" ? "warning" : "error";
1849
+ const props = [
1850
+ ...e.location === null ? [] : [`file=${escapeWorkflowCommandProperty(e.location.file)}`, `line=${String(e.location.line)}`],
1851
+ "title=manni test tasks"
1852
+ ].join(",");
1853
+ const what = e.id === "constraint" && e.outcome === "fail" ? `constraint "${e.assertion ?? ""}" not honored.` : `${e.id} ${e.outcome === "fail" ? "failed" : e.outcome === "error" ? "could not be graded" : "needs review"}.`;
1854
+ const message = [`${label(run)}: ${what}`, e.message].filter((m) => m !== void 0 && m !== "").join(" ");
1855
+ return `::${level} ${props}::${escapeWorkflowCommandMessage(message)}`;
1856
+ }
1857
+ function renderGithub2(report) {
1858
+ const commands = report.runs.flatMap(
1859
+ (run) => run.evals.filter((e) => e.outcome !== "pass" && e.outcome !== "skipped").map((e) => githubLine(run, e))
1860
+ );
1861
+ return [...commands, tasksTotal(report.summary)].join("\n");
1862
+ }
1863
+
1864
+ export {
1865
+ TestError,
1866
+ realSpawn,
1867
+ runProcedures,
1868
+ realClaudeCodeSpawn,
1869
+ runTasks,
1870
+ renderGithub,
1871
+ renderJson,
1872
+ renderPretty,
1873
+ renderTasks
1874
+ };
1875
+ //# sourceMappingURL=chunk-P6LRDWMJ.js.map