@unbrained/pm-cli 2026.5.31 → 2026.6.5

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 (586) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/dist/cli/argv-utils.js +7 -3
  3. package/dist/cli/argv-utils.js.map +1 -1
  4. package/dist/cli/bootstrap-args.d.ts +1 -0
  5. package/dist/cli/bootstrap-args.js +23 -3
  6. package/dist/cli/bootstrap-args.js.map +1 -1
  7. package/dist/cli/commands/calendar.js +17 -3
  8. package/dist/cli/commands/calendar.js.map +1 -1
  9. package/dist/cli/commands/close-many.d.ts +63 -0
  10. package/dist/cli/commands/close-many.js +302 -0
  11. package/dist/cli/commands/close-many.js.map +1 -0
  12. package/dist/cli/commands/completion.d.ts +1 -0
  13. package/dist/cli/commands/completion.js +241 -27
  14. package/dist/cli/commands/completion.js.map +1 -1
  15. package/dist/cli/commands/config.d.ts +4 -4
  16. package/dist/cli/commands/config.js +115 -3
  17. package/dist/cli/commands/config.js.map +1 -1
  18. package/dist/cli/commands/contracts.js +191 -162
  19. package/dist/cli/commands/contracts.js.map +1 -1
  20. package/dist/cli/commands/create.d.ts +1 -0
  21. package/dist/cli/commands/create.js +77 -114
  22. package/dist/cli/commands/create.js.map +1 -1
  23. package/dist/cli/commands/extension/doctor.d.ts +12 -0
  24. package/dist/cli/commands/extension/doctor.js +97 -2
  25. package/dist/cli/commands/extension/doctor.js.map +1 -1
  26. package/dist/cli/commands/extension/scaffold.js +49 -48
  27. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  28. package/dist/cli/commands/extension.js +51 -23
  29. package/dist/cli/commands/extension.js.map +1 -1
  30. package/dist/cli/commands/get.js +7 -7
  31. package/dist/cli/commands/get.js.map +1 -1
  32. package/dist/cli/commands/health.js +38 -3
  33. package/dist/cli/commands/health.js.map +1 -1
  34. package/dist/cli/commands/index.d.ts +2 -1
  35. package/dist/cli/commands/index.js +4 -3
  36. package/dist/cli/commands/index.js.map +1 -1
  37. package/dist/cli/commands/init.d.ts +10 -0
  38. package/dist/cli/commands/init.js +107 -4
  39. package/dist/cli/commands/init.js.map +1 -1
  40. package/dist/cli/commands/list.d.ts +5 -0
  41. package/dist/cli/commands/list.js +58 -26
  42. package/dist/cli/commands/list.js.map +1 -1
  43. package/dist/cli/commands/reindex.js +163 -47
  44. package/dist/cli/commands/reindex.js.map +1 -1
  45. package/dist/cli/commands/repeatable-metadata-parsers.d.ts +15 -0
  46. package/dist/cli/commands/repeatable-metadata-parsers.js +120 -0
  47. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -0
  48. package/dist/cli/commands/restore.js +25 -4
  49. package/dist/cli/commands/restore.js.map +1 -1
  50. package/dist/cli/commands/schema.d.ts +122 -1
  51. package/dist/cli/commands/schema.js +536 -6
  52. package/dist/cli/commands/schema.js.map +1 -1
  53. package/dist/cli/commands/search.d.ts +1 -0
  54. package/dist/cli/commands/search.js +18 -4
  55. package/dist/cli/commands/search.js.map +1 -1
  56. package/dist/cli/commands/test.js +4 -3
  57. package/dist/cli/commands/test.js.map +1 -1
  58. package/dist/cli/commands/update-many.js +69 -140
  59. package/dist/cli/commands/update-many.js.map +1 -1
  60. package/dist/cli/commands/update.d.ts +2 -0
  61. package/dist/cli/commands/update.js +138 -119
  62. package/dist/cli/commands/update.js.map +1 -1
  63. package/dist/cli/commands/validate.d.ts +1 -0
  64. package/dist/cli/commands/validate.js +63 -33
  65. package/dist/cli/commands/validate.js.map +1 -1
  66. package/dist/cli/error-guidance.js +26 -3
  67. package/dist/cli/error-guidance.js.map +1 -1
  68. package/dist/cli/help-content.js +82 -3
  69. package/dist/cli/help-content.js.map +1 -1
  70. package/dist/cli/main.js +377 -23
  71. package/dist/cli/main.js.map +1 -1
  72. package/dist/cli/register-list-query.js +9 -3
  73. package/dist/cli/register-list-query.js.map +1 -1
  74. package/dist/cli/register-mutation.js +200 -28
  75. package/dist/cli/register-mutation.js.map +1 -1
  76. package/dist/cli/register-operations.js +4 -2
  77. package/dist/cli/register-operations.js.map +1 -1
  78. package/dist/cli/register-setup.js +4 -2
  79. package/dist/cli/register-setup.js.map +1 -1
  80. package/dist/cli/registration-helpers.js +31 -4
  81. package/dist/cli/registration-helpers.js.map +1 -1
  82. package/dist/cli-bundle/chunks/activity-3RWRRNOW.js +20 -0
  83. package/dist/cli-bundle/chunks/activity-3RWRRNOW.js.map +1 -0
  84. package/dist/cli-bundle/chunks/activity-P5BUMWP3.js +16 -0
  85. package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js +206 -0
  86. package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js.map +1 -0
  87. package/dist/cli-bundle/chunks/{aggregate-ADUOSFRO.js → aggregate-OOAGKWRG.js} +11 -11
  88. package/dist/cli-bundle/chunks/{append-JD2DETU7.js → append-5JE3YGXU.js} +8 -9
  89. package/dist/cli-bundle/chunks/{append-JD2DETU7.js.map → append-5JE3YGXU.js.map} +1 -1
  90. package/dist/cli-bundle/chunks/append-PNN6UIBZ.js +69 -0
  91. package/dist/cli-bundle/chunks/append-PNN6UIBZ.js.map +1 -0
  92. package/dist/cli-bundle/chunks/chunk-26KTVXJW.js +218 -0
  93. package/dist/cli-bundle/chunks/chunk-26KTVXJW.js.map +1 -0
  94. package/dist/cli-bundle/chunks/{chunk-JULRTHJQ.js → chunk-3OH4DAEB.js} +119 -6
  95. package/dist/cli-bundle/chunks/chunk-3OH4DAEB.js.map +7 -0
  96. package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js +5553 -0
  97. package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js.map +1 -0
  98. package/dist/cli-bundle/chunks/{chunk-WDPXDQFG.js → chunk-4PJQSECJ.js} +6 -4
  99. package/dist/cli-bundle/chunks/chunk-4PJQSECJ.js.map +7 -0
  100. package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js +1832 -0
  101. package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js.map +1 -0
  102. package/dist/cli-bundle/chunks/{chunk-6HT2F4TK.js → chunk-5IRA6IYD.js} +175 -54
  103. package/dist/cli-bundle/chunks/chunk-5IRA6IYD.js.map +7 -0
  104. package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js +412 -0
  105. package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js.map +1 -0
  106. package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js +182 -0
  107. package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js.map +1 -0
  108. package/dist/cli-bundle/chunks/chunk-7K24QB23.js +698 -0
  109. package/dist/cli-bundle/chunks/chunk-7K24QB23.js.map +1 -0
  110. package/dist/cli-bundle/chunks/chunk-A6PEXMYN.js +380 -0
  111. package/dist/cli-bundle/chunks/chunk-A6PEXMYN.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-ASQM3IF5.js +230 -0
  113. package/dist/cli-bundle/chunks/chunk-ASQM3IF5.js.map +1 -0
  114. package/dist/cli-bundle/chunks/{chunk-G57E5D7T.js → chunk-ATBVS6WW.js} +5 -5
  115. package/dist/cli-bundle/chunks/chunk-AXXKLVTW.js +332 -0
  116. package/dist/cli-bundle/chunks/chunk-AXXKLVTW.js.map +1 -0
  117. package/dist/cli-bundle/chunks/{chunk-PXUAZUUY.js → chunk-B3N4TKNL.js} +12 -11
  118. package/dist/cli-bundle/chunks/chunk-B3N4TKNL.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-KBQY3YG5.js → chunk-BNL6S7QH.js} +3 -3
  120. package/dist/cli-bundle/chunks/chunk-CCUFLH4J.js +154 -0
  121. package/dist/cli-bundle/chunks/chunk-CCUFLH4J.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-NGN7UV5K.js → chunk-CJDQB2ED.js} +2 -2
  123. package/dist/cli-bundle/chunks/chunk-CWT53EYT.js +1340 -0
  124. package/dist/cli-bundle/chunks/chunk-CWT53EYT.js.map +1 -0
  125. package/dist/cli-bundle/chunks/{chunk-D7AOMPRH.js → chunk-D3WUNETC.js} +5 -5
  126. package/dist/cli-bundle/chunks/{chunk-3M73P3G6.js → chunk-D5X7N6FI.js} +210 -132
  127. package/dist/cli-bundle/chunks/chunk-D5X7N6FI.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-6YCV7WSL.js → chunk-DFIZGAI5.js} +10 -12
  129. package/dist/cli-bundle/chunks/{chunk-6YCV7WSL.js.map → chunk-DFIZGAI5.js.map} +1 -1
  130. package/dist/cli-bundle/chunks/chunk-DFUSXJDE.js +1704 -0
  131. package/dist/cli-bundle/chunks/chunk-DFUSXJDE.js.map +1 -0
  132. package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js +2988 -0
  133. package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js.map +1 -0
  134. package/dist/cli-bundle/chunks/chunk-FVXM3GKS.js +128 -0
  135. package/dist/cli-bundle/chunks/chunk-FVXM3GKS.js.map +1 -0
  136. package/dist/cli-bundle/chunks/chunk-G5BACLYH.js +454 -0
  137. package/dist/cli-bundle/chunks/chunk-G5BACLYH.js.map +1 -0
  138. package/dist/cli-bundle/chunks/{chunk-U7FMKRXH.js → chunk-GCAVRLGE.js} +37 -16
  139. package/dist/cli-bundle/chunks/chunk-GCAVRLGE.js.map +7 -0
  140. package/dist/cli-bundle/chunks/chunk-GFWHHMVV.js +57 -0
  141. package/dist/cli-bundle/chunks/chunk-GFWHHMVV.js.map +1 -0
  142. package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js +3860 -0
  143. package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js.map +1 -0
  144. package/dist/cli-bundle/chunks/chunk-GPGAYASV.js +346 -0
  145. package/dist/cli-bundle/chunks/chunk-GPGAYASV.js.map +1 -0
  146. package/dist/cli-bundle/chunks/{chunk-MD7K4JYF.js → chunk-HPH6X4ZZ.js} +26 -15
  147. package/dist/cli-bundle/chunks/chunk-HPH6X4ZZ.js.map +7 -0
  148. package/dist/cli-bundle/chunks/{chunk-5HSEP75M.js → chunk-HZOS2UG5.js} +18 -6
  149. package/dist/cli-bundle/chunks/chunk-HZOS2UG5.js.map +7 -0
  150. package/dist/cli-bundle/chunks/chunk-IUV734HF.js +17 -0
  151. package/dist/cli-bundle/chunks/chunk-IUV734HF.js.map +1 -0
  152. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js +15 -0
  153. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js.map +1 -0
  154. package/dist/cli-bundle/chunks/{chunk-L2FXEKDB.js → chunk-JB4RGL4V.js} +7 -7
  155. package/dist/cli-bundle/chunks/chunk-JQI2HE55.js +130 -0
  156. package/dist/cli-bundle/chunks/chunk-JQI2HE55.js.map +1 -0
  157. package/dist/cli-bundle/chunks/{chunk-SEXQN4KL.js → chunk-K47WAYQV.js} +3 -3
  158. package/dist/cli-bundle/chunks/{chunk-CEFIVZPG.js → chunk-KA24HME7.js} +2 -2
  159. package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js +1325 -0
  160. package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js.map +1 -0
  161. package/dist/cli-bundle/chunks/chunk-KCMIYKTA.js +242 -0
  162. package/dist/cli-bundle/chunks/chunk-KCMIYKTA.js.map +1 -0
  163. package/dist/cli-bundle/chunks/{chunk-7Y53ZJIQ.js → chunk-KK6YPGH3.js} +22 -3
  164. package/dist/cli-bundle/chunks/chunk-KK6YPGH3.js.map +7 -0
  165. package/dist/cli-bundle/chunks/{chunk-A7E7PUVX.js → chunk-LDJK7SHN.js} +7 -7
  166. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js +24 -0
  167. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js.map +1 -0
  168. package/dist/cli-bundle/chunks/chunk-MISYRLEP.js +80 -0
  169. package/dist/cli-bundle/chunks/chunk-MISYRLEP.js.map +1 -0
  170. package/dist/cli-bundle/chunks/{chunk-FQE6XZDB.js → chunk-N5YF3VFN.js} +54 -32
  171. package/dist/cli-bundle/chunks/chunk-N5YF3VFN.js.map +7 -0
  172. package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js +173 -0
  173. package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js.map +1 -0
  174. package/dist/cli-bundle/chunks/chunk-O5IBJE6S.js +338 -0
  175. package/dist/cli-bundle/chunks/chunk-O5IBJE6S.js.map +1 -0
  176. package/dist/cli-bundle/chunks/{chunk-OGZEG5TT.js → chunk-OIQIXTNB.js} +164 -53
  177. package/dist/cli-bundle/chunks/chunk-OIQIXTNB.js.map +7 -0
  178. package/dist/cli-bundle/chunks/chunk-ORTLYVA4.js +751 -0
  179. package/dist/cli-bundle/chunks/chunk-ORTLYVA4.js.map +1 -0
  180. package/dist/cli-bundle/chunks/{chunk-JTWRXG4B.js → chunk-OUF3ARDX.js} +251 -251
  181. package/dist/cli-bundle/chunks/chunk-OUF3ARDX.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{chunk-PVNQLCIS.js → chunk-RANZIID5.js} +2 -2
  183. package/dist/cli-bundle/chunks/chunk-RQAWLSUU.js +140 -0
  184. package/dist/cli-bundle/chunks/chunk-RQAWLSUU.js.map +7 -0
  185. package/dist/cli-bundle/chunks/{chunk-JFWUHHS2.js → chunk-S3CV7JGJ.js} +4 -4
  186. package/dist/cli-bundle/chunks/{chunk-LSXGH6NE.js → chunk-SRVKTWPR.js} +748 -196
  187. package/dist/cli-bundle/chunks/chunk-SRVKTWPR.js.map +7 -0
  188. package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js +76 -0
  189. package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js.map +1 -0
  190. package/dist/cli-bundle/chunks/chunk-SZQCER6S.js +631 -0
  191. package/dist/cli-bundle/chunks/chunk-SZQCER6S.js.map +1 -0
  192. package/dist/cli-bundle/chunks/chunk-T2ORWB6D.js +540 -0
  193. package/dist/cli-bundle/chunks/chunk-T2ORWB6D.js.map +1 -0
  194. package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js +422 -0
  195. package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js.map +7 -0
  196. package/dist/cli-bundle/chunks/{chunk-P53TN6IA.js → chunk-TK633IVD.js} +35 -8
  197. package/dist/cli-bundle/chunks/chunk-TK633IVD.js.map +7 -0
  198. package/dist/cli-bundle/chunks/chunk-TQ3ZK6VD.js +131 -0
  199. package/dist/cli-bundle/chunks/chunk-TQ3ZK6VD.js.map +7 -0
  200. package/dist/cli-bundle/chunks/chunk-UFCG3SWR.js +119 -0
  201. package/dist/cli-bundle/chunks/chunk-UFCG3SWR.js.map +1 -0
  202. package/dist/cli-bundle/chunks/chunk-UOVLWB47.js +1664 -0
  203. package/dist/cli-bundle/chunks/chunk-UOVLWB47.js.map +1 -0
  204. package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js +186 -0
  205. package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js.map +1 -0
  206. package/dist/cli-bundle/chunks/chunk-VGO2T3TY.js +182 -0
  207. package/dist/cli-bundle/chunks/chunk-VGO2T3TY.js.map +1 -0
  208. package/dist/cli-bundle/chunks/{chunk-LRBOHPUE.js → chunk-WIKR7KFL.js} +8 -8
  209. package/dist/cli-bundle/chunks/{chunk-BUPWJ3IJ.js → chunk-XG7RJYHV.js} +484 -49
  210. package/dist/cli-bundle/chunks/chunk-XG7RJYHV.js.map +7 -0
  211. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js +53 -0
  212. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js.map +1 -0
  213. package/dist/cli-bundle/chunks/{chunk-AKOOMO3T.js → chunk-XX5LRINW.js} +2 -2
  214. package/dist/cli-bundle/chunks/{chunk-WJ2NAC37.js → chunk-Y2AKE2HS.js} +3 -3
  215. package/dist/cli-bundle/chunks/{chunk-GN7IJPCD.js → chunk-ZQ4F6EC4.js} +301 -24
  216. package/dist/cli-bundle/chunks/chunk-ZQ4F6EC4.js.map +7 -0
  217. package/dist/cli-bundle/chunks/chunk-ZRVSMOMR.js +1809 -0
  218. package/dist/cli-bundle/chunks/chunk-ZRVSMOMR.js.map +1 -0
  219. package/dist/cli-bundle/chunks/{claim-EE4TKKCV.js → claim-AZLP7YFO.js} +10 -11
  220. package/dist/cli-bundle/chunks/{claim-EE4TKKCV.js.map → claim-AZLP7YFO.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/claim-ZFA7HKU4.js +129 -0
  222. package/dist/cli-bundle/chunks/claim-ZFA7HKU4.js.map +1 -0
  223. package/dist/cli-bundle/chunks/close-65DFYAVS.js +17 -0
  224. package/dist/cli-bundle/chunks/close-65DFYAVS.js.map +1 -0
  225. package/dist/cli-bundle/chunks/close-RMHQ3KWH.js +13 -0
  226. package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js +311 -0
  227. package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js.map +1 -0
  228. package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js +314 -0
  229. package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js.map +7 -0
  230. package/dist/cli-bundle/chunks/{comments-AAKJQ6LW.js → comments-AGBNSJJH.js} +10 -11
  231. package/dist/cli-bundle/chunks/{comments-AAKJQ6LW.js.map → comments-AGBNSJJH.js.map} +1 -1
  232. package/dist/cli-bundle/chunks/comments-CJWXQI7X.js +100 -0
  233. package/dist/cli-bundle/chunks/comments-CJWXQI7X.js.map +1 -0
  234. package/dist/cli-bundle/chunks/{config-V3FZOKLI.js → config-5ON3ADRH.js} +121 -10
  235. package/dist/cli-bundle/chunks/config-5ON3ADRH.js.map +7 -0
  236. package/dist/cli-bundle/chunks/config-DDPYIA6J.js +1671 -0
  237. package/dist/cli-bundle/chunks/config-DDPYIA6J.js.map +1 -0
  238. package/dist/cli-bundle/chunks/{context-RZ5QPNJB.js → context-E6U3DWVM.js} +32 -19
  239. package/dist/cli-bundle/chunks/{context-RZ5QPNJB.js.map → context-E6U3DWVM.js.map} +2 -2
  240. package/dist/cli-bundle/chunks/context-ZOJEN5VT.js +1461 -0
  241. package/dist/cli-bundle/chunks/context-ZOJEN5VT.js.map +1 -0
  242. package/dist/cli-bundle/chunks/{contracts-YLMH33VU.js → contracts-CXSFM45B.js} +194 -162
  243. package/dist/cli-bundle/chunks/contracts-CXSFM45B.js.map +7 -0
  244. package/dist/cli-bundle/chunks/contracts-LCSX5R53.js +1274 -0
  245. package/dist/cli-bundle/chunks/contracts-LCSX5R53.js.map +1 -0
  246. package/dist/cli-bundle/chunks/create-ATONSAZW.js +27 -0
  247. package/dist/cli-bundle/chunks/create-WYFKN2U4.js +31 -0
  248. package/dist/cli-bundle/chunks/create-WYFKN2U4.js.map +1 -0
  249. package/dist/cli-bundle/chunks/{delete-RHCTEORS.js → delete-RONNH4F4.js} +7 -8
  250. package/dist/cli-bundle/chunks/{delete-RHCTEORS.js.map → delete-RONNH4F4.js.map} +1 -1
  251. package/dist/cli-bundle/chunks/delete-ZXWC56WO.js +55 -0
  252. package/dist/cli-bundle/chunks/delete-ZXWC56WO.js.map +1 -0
  253. package/dist/cli-bundle/chunks/deps-EHXIFOZR.js +225 -0
  254. package/dist/cli-bundle/chunks/deps-EHXIFOZR.js.map +1 -0
  255. package/dist/cli-bundle/chunks/{deps-MZYCMLAO.js → deps-WII3O4HB.js} +7 -8
  256. package/dist/cli-bundle/chunks/{deps-MZYCMLAO.js.map → deps-WII3O4HB.js.map} +1 -1
  257. package/dist/cli-bundle/chunks/{docs-FXXUCZYU.js → docs-JMVCFNHH.js} +9 -10
  258. package/dist/cli-bundle/chunks/{docs-FXXUCZYU.js.map → docs-JMVCFNHH.js.map} +1 -1
  259. package/dist/cli-bundle/chunks/docs-PDREIMLS.js +31 -0
  260. package/dist/cli-bundle/chunks/docs-PDREIMLS.js.map +1 -0
  261. package/dist/cli-bundle/chunks/extension-B4ROVWJD.js +28 -0
  262. package/dist/cli-bundle/chunks/extension-B4ROVWJD.js.map +1 -0
  263. package/dist/cli-bundle/chunks/{extension-B4WL7BQU.js → extension-G6UXSM5S.js} +4 -5
  264. package/dist/cli-bundle/chunks/files-2PN7UM2D.js +282 -0
  265. package/dist/cli-bundle/chunks/files-2PN7UM2D.js.map +1 -0
  266. package/dist/cli-bundle/chunks/{files-WVOX67PE.js → files-MXYS5W4M.js} +9 -10
  267. package/dist/cli-bundle/chunks/{files-WVOX67PE.js.map → files-MXYS5W4M.js.map} +1 -1
  268. package/dist/cli-bundle/chunks/gc-GT552UJH.js +178 -0
  269. package/dist/cli-bundle/chunks/gc-GT552UJH.js.map +1 -0
  270. package/dist/cli-bundle/chunks/{gc-JWNF66EC.js → gc-QNBRJG6H.js} +3 -3
  271. package/dist/cli-bundle/chunks/{get-LTK3HOCQ.js → get-CINFEUIY.js} +16 -17
  272. package/dist/cli-bundle/chunks/get-CINFEUIY.js.map +7 -0
  273. package/dist/cli-bundle/chunks/get-WXMLRG7M.js +194 -0
  274. package/dist/cli-bundle/chunks/get-WXMLRG7M.js.map +1 -0
  275. package/dist/cli-bundle/chunks/health-5VPOJQ53.js +1258 -0
  276. package/dist/cli-bundle/chunks/health-5VPOJQ53.js.map +1 -0
  277. package/dist/cli-bundle/chunks/{health-TCWL55KM.js → health-IT5DBPRJ.js} +43 -15
  278. package/dist/cli-bundle/chunks/health-IT5DBPRJ.js.map +7 -0
  279. package/dist/cli-bundle/chunks/history-6FC4H6HI.js +20 -0
  280. package/dist/cli-bundle/chunks/history-FLZIP7PM.js +24 -0
  281. package/dist/cli-bundle/chunks/history-FLZIP7PM.js.map +1 -0
  282. package/dist/cli-bundle/chunks/history-redact-SSZBAD76.js +23 -0
  283. package/dist/cli-bundle/chunks/history-redact-SSZBAD76.js.map +1 -0
  284. package/dist/cli-bundle/chunks/history-redact-XKYEZDBL.js +19 -0
  285. package/dist/cli-bundle/chunks/{history-repair-ZWSTDRH2.js → history-repair-KC5ZOJRZ.js} +12 -14
  286. package/dist/cli-bundle/chunks/{history-repair-ZWSTDRH2.js.map → history-repair-KC5ZOJRZ.js.map} +1 -1
  287. package/dist/cli-bundle/chunks/history-repair-X7CO5JJZ.js +193 -0
  288. package/dist/cli-bundle/chunks/history-repair-X7CO5JJZ.js.map +1 -0
  289. package/dist/cli-bundle/chunks/init-6MRFVOLH.js +20 -0
  290. package/dist/cli-bundle/chunks/init-6MRFVOLH.js.map +1 -0
  291. package/dist/cli-bundle/chunks/init-KHX3FEEM.js +16 -0
  292. package/dist/cli-bundle/chunks/{learnings-NXTWE3FR.js → learnings-A3CLB5CO.js} +10 -11
  293. package/dist/cli-bundle/chunks/{learnings-NXTWE3FR.js.map → learnings-A3CLB5CO.js.map} +1 -1
  294. package/dist/cli-bundle/chunks/learnings-DCX55BNX.js +44 -0
  295. package/dist/cli-bundle/chunks/learnings-DCX55BNX.js.map +1 -0
  296. package/dist/cli-bundle/chunks/list-53LZ2AEO.js +20 -0
  297. package/dist/cli-bundle/chunks/list-DBRECOG4.js +24 -0
  298. package/dist/cli-bundle/chunks/list-DBRECOG4.js.map +1 -0
  299. package/dist/cli-bundle/chunks/{notes-DFS5ZGOO.js → notes-42LIC3UE.js} +10 -11
  300. package/dist/cli-bundle/chunks/{notes-DFS5ZGOO.js.map → notes-42LIC3UE.js.map} +1 -1
  301. package/dist/cli-bundle/chunks/notes-P5O3VMQ3.js +44 -0
  302. package/dist/cli-bundle/chunks/notes-P5O3VMQ3.js.map +1 -0
  303. package/dist/cli-bundle/chunks/{plan-67AB2PLM.js → plan-HDQXEUKD.js} +13 -14
  304. package/dist/cli-bundle/chunks/{plan-67AB2PLM.js.map → plan-HDQXEUKD.js.map} +1 -1
  305. package/dist/cli-bundle/chunks/plan-IGTE3WOJ.js +1171 -0
  306. package/dist/cli-bundle/chunks/plan-IGTE3WOJ.js.map +1 -0
  307. package/dist/cli-bundle/chunks/{register-list-query-UP3VRUFS.js → register-list-query-AG3XKXWL.js} +22 -24
  308. package/dist/cli-bundle/chunks/register-list-query-AG3XKXWL.js.map +7 -0
  309. package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js +227 -0
  310. package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js.map +1 -0
  311. package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js +813 -0
  312. package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js.map +1 -0
  313. package/dist/cli-bundle/chunks/{register-mutation-YWSBF545.js → register-mutation-RSMT6DPK.js} +154 -43
  314. package/dist/cli-bundle/chunks/register-mutation-RSMT6DPK.js.map +7 -0
  315. package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js +370 -0
  316. package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js.map +1 -0
  317. package/dist/cli-bundle/chunks/{register-operations-3BDTGSDH.js → register-operations-Q54JQZUN.js} +33 -34
  318. package/dist/cli-bundle/chunks/register-operations-Q54JQZUN.js.map +7 -0
  319. package/dist/cli-bundle/chunks/register-setup-DI6P7X75.js +242 -0
  320. package/dist/cli-bundle/chunks/register-setup-DI6P7X75.js.map +1 -0
  321. package/dist/cli-bundle/chunks/{register-setup-V56GDRUS.js → register-setup-YJKIQRKA.js} +18 -19
  322. package/dist/cli-bundle/chunks/{register-setup-V56GDRUS.js.map → register-setup-YJKIQRKA.js.map} +2 -2
  323. package/dist/cli-bundle/chunks/restore-2XVTBLKQ.js +21 -0
  324. package/dist/cli-bundle/chunks/restore-2XVTBLKQ.js.map +1 -0
  325. package/dist/cli-bundle/chunks/restore-JL5QIH7H.js +17 -0
  326. package/dist/cli-bundle/chunks/schema-LVXZWFGY.js +770 -0
  327. package/dist/cli-bundle/chunks/schema-LVXZWFGY.js.map +1 -0
  328. package/dist/cli-bundle/chunks/schema-V6BX65Q2.js +780 -0
  329. package/dist/cli-bundle/chunks/schema-V6BX65Q2.js.map +7 -0
  330. package/dist/cli-bundle/chunks/{search-HENBL456.js → search-5A3BMFA7.js} +25 -16
  331. package/dist/cli-bundle/chunks/search-5A3BMFA7.js.map +7 -0
  332. package/dist/cli-bundle/chunks/search-C7NPB7G7.js +1127 -0
  333. package/dist/cli-bundle/chunks/search-C7NPB7G7.js.map +1 -0
  334. package/dist/cli-bundle/chunks/stats-FNLYVXTB.js +120 -0
  335. package/dist/cli-bundle/chunks/stats-FNLYVXTB.js.map +1 -0
  336. package/dist/cli-bundle/chunks/{stats-N6H3YP2F.js → stats-Y2CBTZSL.js} +7 -8
  337. package/dist/cli-bundle/chunks/{stats-N6H3YP2F.js.map → stats-Y2CBTZSL.js.map} +1 -1
  338. package/dist/cli-bundle/chunks/test-OFYONO3C.js +35 -0
  339. package/dist/cli-bundle/chunks/test-OFYONO3C.js.map +1 -0
  340. package/dist/cli-bundle/chunks/test-RJ4ZF35X.js +31 -0
  341. package/dist/cli-bundle/chunks/{test-all-G2AZOHXI.js → test-all-EEMKNTGU.js} +13 -14
  342. package/dist/cli-bundle/chunks/{test-all-G2AZOHXI.js.map → test-all-EEMKNTGU.js.map} +1 -1
  343. package/dist/cli-bundle/chunks/test-all-OJE6CIO7.js +328 -0
  344. package/dist/cli-bundle/chunks/test-all-OJE6CIO7.js.map +1 -0
  345. package/dist/cli-bundle/chunks/test-runs-IPOPFOAF.js +929 -0
  346. package/dist/cli-bundle/chunks/test-runs-IPOPFOAF.js.map +1 -0
  347. package/dist/cli-bundle/chunks/{test-runs-GX5HTPSF.js → test-runs-L2M7WKH7.js} +5 -5
  348. package/dist/cli-bundle/chunks/update-6YEHPVXH.js +25 -0
  349. package/dist/cli-bundle/chunks/update-6YEHPVXH.js.map +1 -0
  350. package/dist/cli-bundle/chunks/update-PYLVHMRD.js +21 -0
  351. package/dist/cli-bundle/chunks/{update-many-46HRSP2Q.js → update-many-322CCH2L.js} +78 -146
  352. package/dist/cli-bundle/chunks/update-many-322CCH2L.js.map +7 -0
  353. package/dist/cli-bundle/chunks/update-many-DYWGW57M.js +605 -0
  354. package/dist/cli-bundle/chunks/update-many-DYWGW57M.js.map +1 -0
  355. package/dist/cli-bundle/chunks/{upgrade-H5HHM5UV.js → upgrade-2U727SAM.js} +5 -7
  356. package/dist/cli-bundle/chunks/{upgrade-H5HHM5UV.js.map → upgrade-2U727SAM.js.map} +1 -1
  357. package/dist/cli-bundle/chunks/upgrade-3W3RVSNM.js +266 -0
  358. package/dist/cli-bundle/chunks/upgrade-3W3RVSNM.js.map +1 -0
  359. package/dist/cli-bundle/chunks/validate-GZ24NYHO.js +1120 -0
  360. package/dist/cli-bundle/chunks/validate-GZ24NYHO.js.map +1 -0
  361. package/dist/cli-bundle/chunks/{validate-TMCVKIGZ.js → validate-ZFVWPEEN.js} +61 -48
  362. package/dist/cli-bundle/chunks/validate-ZFVWPEEN.js.map +7 -0
  363. package/dist/cli-bundle/main.js +490 -52
  364. package/dist/cli-bundle/main.js.map +2 -2
  365. package/dist/core/checkpoint/mutation-checkpoint.d.ts +44 -0
  366. package/dist/core/checkpoint/mutation-checkpoint.js +119 -0
  367. package/dist/core/checkpoint/mutation-checkpoint.js.map +1 -0
  368. package/dist/core/config/positional-value.js +4 -2
  369. package/dist/core/config/positional-value.js.map +1 -1
  370. package/dist/core/diagnostics/remediation.d.ts +73 -0
  371. package/dist/core/diagnostics/remediation.js +328 -0
  372. package/dist/core/diagnostics/remediation.js.map +1 -0
  373. package/dist/core/extensions/extension-hook-runtime.js +9 -2
  374. package/dist/core/extensions/extension-hook-runtime.js.map +1 -1
  375. package/dist/core/extensions/extension-types.d.ts +60 -4
  376. package/dist/core/extensions/extension-types.js +2 -2
  377. package/dist/core/extensions/extension-types.js.map +1 -1
  378. package/dist/core/extensions/index.d.ts +5 -1
  379. package/dist/core/extensions/index.js +61 -2
  380. package/dist/core/extensions/index.js.map +1 -1
  381. package/dist/core/extensions/item-fields.d.ts +5 -1
  382. package/dist/core/extensions/item-fields.js +126 -4
  383. package/dist/core/extensions/item-fields.js.map +1 -1
  384. package/dist/core/extensions/loader.js +283 -8
  385. package/dist/core/extensions/loader.js.map +1 -1
  386. package/dist/core/item/item-format.d.ts +3 -2
  387. package/dist/core/item/item-format.js +15 -10
  388. package/dist/core/item/item-format.js.map +1 -1
  389. package/dist/core/item/status-filter.d.ts +29 -0
  390. package/dist/core/item/status-filter.js +97 -0
  391. package/dist/core/item/status-filter.js.map +1 -0
  392. package/dist/core/item/type-registry.js +4 -2
  393. package/dist/core/item/type-registry.js.map +1 -1
  394. package/dist/core/output/output.js +17 -5
  395. package/dist/core/output/output.js.map +1 -1
  396. package/dist/core/schema/item-types-file.d.ts +15 -0
  397. package/dist/core/schema/item-types-file.js +27 -2
  398. package/dist/core/schema/item-types-file.js.map +1 -1
  399. package/dist/core/schema/runtime-field-filters.js +4 -3
  400. package/dist/core/schema/runtime-field-filters.js.map +1 -1
  401. package/dist/core/schema/runtime-field-values.d.ts +1 -1
  402. package/dist/core/schema/runtime-field-values.js +10 -4
  403. package/dist/core/schema/runtime-field-values.js.map +1 -1
  404. package/dist/core/schema/runtime-schema.js +75 -2
  405. package/dist/core/schema/runtime-schema.js.map +1 -1
  406. package/dist/core/schema/status-defs-file.d.ts +113 -0
  407. package/dist/core/schema/status-defs-file.js +260 -0
  408. package/dist/core/schema/status-defs-file.js.map +1 -0
  409. package/dist/core/schema/type-workflows.d.ts +64 -0
  410. package/dist/core/schema/type-workflows.js +98 -0
  411. package/dist/core/schema/type-workflows.js.map +1 -0
  412. package/dist/core/search/cache.d.ts +3 -1
  413. package/dist/core/search/cache.js +104 -28
  414. package/dist/core/search/cache.js.map +1 -1
  415. package/dist/core/search/http-client.d.ts +2 -2
  416. package/dist/core/search/http-client.js +2 -2
  417. package/dist/core/search/http-client.js.map +1 -1
  418. package/dist/core/search/vector-stores.d.ts +1 -0
  419. package/dist/core/search/vector-stores.js +64 -14
  420. package/dist/core/search/vector-stores.js.map +1 -1
  421. package/dist/core/search/vectorization-metadata.d.ts +13 -0
  422. package/dist/core/search/vectorization-metadata.js +65 -0
  423. package/dist/core/search/vectorization-metadata.js.map +1 -0
  424. package/dist/core/shared/serialization.d.ts +1 -0
  425. package/dist/core/shared/serialization.js +86 -2
  426. package/dist/core/shared/serialization.js.map +1 -1
  427. package/dist/core/store/front-matter-cache.js +14 -5
  428. package/dist/core/store/front-matter-cache.js.map +1 -1
  429. package/dist/core/store/item-store.d.ts +2 -0
  430. package/dist/core/store/item-store.js +61 -6
  431. package/dist/core/store/item-store.js.map +1 -1
  432. package/dist/core/store/settings-validator.js +18 -2
  433. package/dist/core/store/settings-validator.js.map +1 -1
  434. package/dist/core/store/settings.js +40 -5
  435. package/dist/core/store/settings.js.map +1 -1
  436. package/dist/core/telemetry/consent.js +3 -3
  437. package/dist/core/telemetry/consent.js.map +1 -1
  438. package/dist/core/telemetry/observability.js +4 -3
  439. package/dist/core/telemetry/observability.js.map +1 -1
  440. package/dist/mcp/server.js +221 -12
  441. package/dist/mcp/server.js.map +1 -1
  442. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -2
  443. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  444. package/dist/sdk/cli-contracts/commander-types.js +7 -2
  445. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  446. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  447. package/dist/sdk/cli-contracts/enum-contracts.js +4 -2
  448. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  449. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -0
  450. package/dist/sdk/cli-contracts/tool-option-contracts.js +53 -3
  451. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  452. package/dist/sdk/cli-contracts/tool-parameter-tables.js +35 -6
  453. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  454. package/dist/sdk/cli-contracts.d.ts +19 -1
  455. package/dist/sdk/cli-contracts.js +187 -15
  456. package/dist/sdk/cli-contracts.js.map +1 -1
  457. package/dist/sdk/errors.d.ts +22 -0
  458. package/dist/sdk/errors.js +46 -0
  459. package/dist/sdk/errors.js.map +1 -0
  460. package/dist/sdk/index.d.ts +2 -1
  461. package/dist/sdk/index.js +3 -2
  462. package/dist/sdk/index.js.map +1 -1
  463. package/dist/sdk/package-import-adapters.js +14 -3
  464. package/dist/sdk/package-import-adapters.js.map +1 -1
  465. package/dist/sdk/runtime.d.ts +1 -0
  466. package/dist/sdk/runtime.js +3 -2
  467. package/dist/sdk/runtime.js.map +1 -1
  468. package/dist/sdk/testing.d.ts +77 -0
  469. package/dist/sdk/testing.js +239 -0
  470. package/dist/sdk/testing.js.map +1 -0
  471. package/dist/types.d.ts +19 -0
  472. package/dist/types.js +3 -2
  473. package/dist/types.js.map +1 -1
  474. package/docs/AGENT_GUIDE.md +21 -2
  475. package/docs/COMMANDS.md +85 -5
  476. package/docs/CONFIGURATION.md +49 -2
  477. package/docs/EXTENSIONS.md +118 -6
  478. package/docs/QUICKSTART.md +2 -0
  479. package/docs/RELEASING.md +2 -2
  480. package/docs/SDK.md +273 -1
  481. package/docs/TESTING.md +17 -0
  482. package/docs/examples/policy-restricted-extension/manifest.json +1 -0
  483. package/docs/examples/starter-extension/index.js +9 -1
  484. package/docs/examples/starter-extension/manifest.json +1 -0
  485. package/package.json +12 -6
  486. package/packages/pm-beads/extensions/beads/index.js +2 -4
  487. package/packages/pm-beads/extensions/beads/index.ts +43 -33
  488. package/packages/pm-beads/extensions/beads/manifest.json +12 -1
  489. package/packages/pm-calendar/README.md +6 -0
  490. package/packages/pm-calendar/extensions/calendar/index.js +6 -1
  491. package/packages/pm-calendar/extensions/calendar/index.ts +6 -1
  492. package/packages/pm-calendar/extensions/calendar/manifest.json +6 -1
  493. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +6 -1
  494. package/packages/pm-guide-shell/README.md +4 -0
  495. package/packages/pm-guide-shell/extensions/guide-shell/index.js +22 -0
  496. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +22 -0
  497. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +6 -1
  498. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +74 -3
  499. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +84 -4
  500. package/packages/pm-lifecycle-hooks/README.md +29 -0
  501. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +18 -0
  502. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +20 -0
  503. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +9 -0
  504. package/packages/pm-lifecycle-hooks/package.json +52 -0
  505. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +13 -1
  506. package/packages/pm-search-advanced/extensions/search-advanced/index.js +69 -1
  507. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +91 -2
  508. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +13 -1
  509. package/packages/pm-templates/extensions/templates/manifest.json +6 -1
  510. package/packages/pm-todos/extensions/todos/index.js +3 -7
  511. package/packages/pm-todos/extensions/todos/index.ts +55 -42
  512. package/packages/pm-todos/extensions/todos/manifest.json +13 -1
  513. package/scripts/bundle-cli.mjs +121 -17
  514. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +0 -17
  515. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +0 -7
  516. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +0 -189
  517. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +0 -7
  518. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +0 -7
  519. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +0 -7
  520. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +0 -7
  521. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +0 -7
  522. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +0 -47
  523. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +0 -7
  524. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +0 -56
  525. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +0 -7
  526. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +0 -7
  527. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +0 -7
  528. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +0 -7
  529. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +0 -7
  530. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +0 -7
  531. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +0 -7
  532. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +0 -7
  533. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +0 -7
  534. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +0 -7
  535. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +0 -7
  536. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +0 -141
  537. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +0 -7
  538. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +0 -7
  539. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +0 -14
  540. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +0 -7
  541. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +0 -7
  542. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +0 -28
  543. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +0 -7
  544. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +0 -7
  545. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +0 -21
  546. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +0 -20
  547. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +0 -16
  548. package/dist/cli-bundle/chunks/list-OGWQPC26.js +0 -20
  549. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +0 -7
  550. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +0 -7
  551. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +0 -7
  552. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +0 -18
  553. package/dist/cli-bundle/chunks/schema-Q622KC46.js +0 -119
  554. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +0 -7
  555. package/dist/cli-bundle/chunks/search-HENBL456.js.map +0 -7
  556. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +0 -32
  557. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +0 -22
  558. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +0 -7
  559. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +0 -7
  560. /package/dist/cli-bundle/chunks/{activity-OWYSUZOY.js.map → activity-P5BUMWP3.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{aggregate-ADUOSFRO.js.map → aggregate-OOAGKWRG.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-G57E5D7T.js.map → chunk-ATBVS6WW.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-KBQY3YG5.js.map → chunk-BNL6S7QH.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-NGN7UV5K.js.map → chunk-CJDQB2ED.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-D7AOMPRH.js.map → chunk-D3WUNETC.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-L2FXEKDB.js.map → chunk-JB4RGL4V.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-SEXQN4KL.js.map → chunk-K47WAYQV.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{chunk-CEFIVZPG.js.map → chunk-KA24HME7.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{chunk-A7E7PUVX.js.map → chunk-LDJK7SHN.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{chunk-PVNQLCIS.js.map → chunk-RANZIID5.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{chunk-JFWUHHS2.js.map → chunk-S3CV7JGJ.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{chunk-LRBOHPUE.js.map → chunk-WIKR7KFL.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{chunk-AKOOMO3T.js.map → chunk-XX5LRINW.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{chunk-WJ2NAC37.js.map → chunk-Y2AKE2HS.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{close-XY4CSAYF.js.map → close-RMHQ3KWH.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{create-PZVHRIZQ.js.map → create-ATONSAZW.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{extension-B4WL7BQU.js.map → extension-G6UXSM5S.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{gc-JWNF66EC.js.map → gc-QNBRJG6H.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{history-A2JUDXUE.js.map → history-6FC4H6HI.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{history-redact-ED6RFCPL.js.map → history-redact-XKYEZDBL.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{init-M2WUB4YH.js.map → init-KHX3FEEM.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{list-OGWQPC26.js.map → list-53LZ2AEO.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{restore-MB2ISME7.js.map → restore-JL5QIH7H.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{test-VNBDRJ4Z.js.map → test-RJ4ZF35X.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{test-runs-GX5HTPSF.js.map → test-runs-L2M7WKH7.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{update-H6SCWNMA.js.map → update-PYLVHMRD.js.map} +0 -0
@@ -0,0 +1,1664 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fb2ef78d-78c8-5583-8c98-89541410a9ff")}catch(e){}}();
3
+ import {
4
+ LINKED_TEST_PM_CONTEXT_MODE_VALUES,
5
+ LINKED_TEST_PROTECTED_ENV_KEYS,
6
+ looksLikeStructuredLinkedTestEntry,
7
+ normalizeStructuredLinkedTestEntry,
8
+ parseLinkedTestAssertionEqualsMap,
9
+ parseLinkedTestAssertionGteMap,
10
+ parseLinkedTestBoolean,
11
+ parseLinkedTestContextMode,
12
+ parseLinkedTestEnvClear,
13
+ parseLinkedTestEnvSet,
14
+ parseLinkedTestMinLines,
15
+ parseLinkedTestRegexList,
16
+ parseLinkedTestStringList
17
+ } from "./chunk-KCMIYKTA.js";
18
+ import {
19
+ createStdinTokenResolver,
20
+ parseCsvKv,
21
+ parseOptionalNumber
22
+ } from "./chunk-O5IBJE6S.js";
23
+ import {
24
+ runInit
25
+ } from "./chunk-ORTLYVA4.js";
26
+ import {
27
+ locateItem,
28
+ mutateItem,
29
+ readLocatedItem
30
+ } from "./chunk-CWT53EYT.js";
31
+ import {
32
+ resolveItemTypeRegistry
33
+ } from "./chunk-SZQCER6S.js";
34
+ import {
35
+ compareTimestampStrings,
36
+ nowIso
37
+ } from "./chunk-NQP3ECKF.js";
38
+ import {
39
+ EXIT_CODE,
40
+ ITEM_FILE_EXTENSIONS,
41
+ PmCliError,
42
+ SCOPE_VALUES,
43
+ getActiveExtensionRegistrations,
44
+ getSettingsPath,
45
+ pathExists,
46
+ readSettings,
47
+ resolveGlobalPmRoot,
48
+ resolvePmRoot,
49
+ stableValueEquals
50
+ } from "./chunk-4LTBNUYT.js";
51
+
52
+ // dist/cli/commands/test.js
53
+ import { spawn } from "node:child_process";
54
+ import { cp, mkdir, mkdtemp, readdir, rm } from "node:fs/promises";
55
+ import { tmpdir } from "node:os";
56
+ import path from "node:path";
57
+
58
+ // dist/core/test/item-test-run-tracking.js
59
+ var DEFAULT_TRACKED_TEST_RUN_HISTORY_LIMIT = 20;
60
+ function trackedTestRunHistoryLimit() {
61
+ const raw = process.env.PM_TRACKED_TEST_RUN_HISTORY_LIMIT;
62
+ if (!raw || raw.trim().length === 0) {
63
+ return DEFAULT_TRACKED_TEST_RUN_HISTORY_LIMIT;
64
+ }
65
+ const parsed = Number.parseInt(raw, 10);
66
+ if (!Number.isFinite(parsed) || parsed <= 0) {
67
+ return DEFAULT_TRACKED_TEST_RUN_HISTORY_LIMIT;
68
+ }
69
+ return parsed;
70
+ }
71
+ function normalizeTrackedTestRunSummaries(entries) {
72
+ return [...entries].filter((entry) => entry.run_id.trim().length > 0 && entry.started_at.trim().length > 0 && entry.finished_at.trim().length > 0 && entry.recorded_at.trim().length > 0).sort((left, right) => {
73
+ const byRecorded = compareTimestampStrings(left.recorded_at, right.recorded_at);
74
+ if (byRecorded !== 0)
75
+ return byRecorded;
76
+ const byRunId = left.run_id.localeCompare(right.run_id);
77
+ if (byRunId !== 0)
78
+ return byRunId;
79
+ return left.kind.localeCompare(right.kind);
80
+ });
81
+ }
82
+ async function appendTrackedTestRunSummary(options) {
83
+ const historyLimit = trackedTestRunHistoryLimit();
84
+ await mutateItem({
85
+ pmRoot: options.pmRoot,
86
+ settings: options.settings,
87
+ id: options.itemId,
88
+ op: "test_run_track",
89
+ author: options.author,
90
+ message: options.message,
91
+ force: false,
92
+ mutate(document) {
93
+ const current = document.metadata.test_runs ?? [];
94
+ const next = normalizeTrackedTestRunSummaries([...current, options.entry]);
95
+ const bounded = next.length > historyLimit ? next.slice(next.length - historyLimit) : next;
96
+ document.metadata.test_runs = bounded;
97
+ return { changedFields: ["test_runs"] };
98
+ }
99
+ });
100
+ }
101
+
102
+ // dist/cli/commands/test/linked-command-detection.js
103
+ var PM_GLOBAL_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["--path"]);
104
+ var NPX_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["-p", "--package", "-c", "--call"]);
105
+ var PNPM_GLOBAL_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set([
106
+ "-c",
107
+ "-C",
108
+ "--config",
109
+ "--dir",
110
+ "--filter",
111
+ "--workspace-dir"
112
+ ]);
113
+ var NPM_GLOBAL_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["-C", "--prefix", "--userconfig", "--cache"]);
114
+ var YARN_GLOBAL_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["--cwd"]);
115
+ var BUN_GLOBAL_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["--cwd"]);
116
+ var NPM_EXEC_SUBCOMMANDS = /* @__PURE__ */ new Set(["exec", "x"]);
117
+ var SCRIPT_RUN_SUBCOMMANDS = /* @__PURE__ */ new Set(["run", "run-script"]);
118
+ var SCRIPT_RUN_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["-C", "--dir", "--cwd", "-w", "--workspace", "--filter"]);
119
+ function splitNormalizedCommandSegments(normalizedCommand) {
120
+ return normalizedCommand.split(/&&|\|\||\||;/).map((segment) => segment.trim()).filter((segment) => segment.length > 0);
121
+ }
122
+ function stripLeadingEnvAssignments(tokens) {
123
+ let start = 0;
124
+ if (tokens[start] === "env") {
125
+ start += 1;
126
+ }
127
+ while (start < tokens.length) {
128
+ const token = tokens[start];
129
+ if (/^(?:[a-z_][a-z0-9_]*|\$env:[a-z_][a-z0-9_]*)=.*/.test(token)) {
130
+ start += 1;
131
+ continue;
132
+ }
133
+ break;
134
+ }
135
+ return tokens.slice(start);
136
+ }
137
+ function firstPmSubcommand(args) {
138
+ let index = 0;
139
+ while (index < args.length) {
140
+ const token = args[index];
141
+ if (token === "--") {
142
+ index += 1;
143
+ continue;
144
+ }
145
+ if (token.startsWith("-")) {
146
+ if (PM_GLOBAL_FLAGS_WITH_VALUE.has(token)) {
147
+ index += 2;
148
+ continue;
149
+ }
150
+ index += 1;
151
+ continue;
152
+ }
153
+ return token;
154
+ }
155
+ return void 0;
156
+ }
157
+ function isPmExecutableToken(token) {
158
+ return token === "pm" || token === "pm.cmd" || token === "pm.exe" || token.endsWith("/pm") || token.endsWith("/pm.cmd") || token.endsWith("/pm.exe");
159
+ }
160
+ function normalizePackageSpecifier(token) {
161
+ const trimmed = token.trim();
162
+ if (!trimmed.startsWith("@")) {
163
+ const versionSeparator2 = trimmed.indexOf("@");
164
+ return versionSeparator2 === -1 ? trimmed : trimmed.slice(0, versionSeparator2);
165
+ }
166
+ const scopeSeparator = trimmed.indexOf("/");
167
+ if (scopeSeparator === -1) {
168
+ return trimmed;
169
+ }
170
+ const versionSeparator = trimmed.indexOf("@", scopeSeparator + 1);
171
+ return versionSeparator === -1 ? trimmed : trimmed.slice(0, versionSeparator);
172
+ }
173
+ function isPmCliPackageToken(token) {
174
+ const normalizedSpecifier = normalizePackageSpecifier(token);
175
+ return normalizedSpecifier === "pm-cli" || normalizedSpecifier.endsWith("/pm-cli") || token === "pm-cli" || token.endsWith("/pm-cli");
176
+ }
177
+ function isPmCliScriptToken(token) {
178
+ return token === "dist/cli.js" || token === "./dist/cli.js" || token.endsWith("/dist/cli.js");
179
+ }
180
+ function parseNpxCommand(tokens) {
181
+ let index = 0;
182
+ while (index < tokens.length) {
183
+ const token = tokens[index];
184
+ if (token === "--") {
185
+ index += 1;
186
+ break;
187
+ }
188
+ if (!token.startsWith("-")) {
189
+ break;
190
+ }
191
+ if (token.includes("=")) {
192
+ index += 1;
193
+ continue;
194
+ }
195
+ if (NPX_FLAGS_WITH_VALUE.has(token)) {
196
+ index += 2;
197
+ continue;
198
+ }
199
+ index += 1;
200
+ }
201
+ const command = tokens[index];
202
+ if (!command) {
203
+ return null;
204
+ }
205
+ return {
206
+ command,
207
+ args: tokens.slice(index + 1)
208
+ };
209
+ }
210
+ function parseLauncherSubcommand(tokens, flagsWithValue) {
211
+ let index = 0;
212
+ while (index < tokens.length) {
213
+ const token = tokens[index];
214
+ if (token === "--") {
215
+ index += 1;
216
+ continue;
217
+ }
218
+ if (token.startsWith("-")) {
219
+ if (token.includes("=")) {
220
+ index += 1;
221
+ continue;
222
+ }
223
+ if (flagsWithValue.has(token)) {
224
+ index += 2;
225
+ continue;
226
+ }
227
+ index += 1;
228
+ continue;
229
+ }
230
+ return {
231
+ subcommand: token,
232
+ args: tokens.slice(index + 1)
233
+ };
234
+ }
235
+ return null;
236
+ }
237
+ function parsePnpmDlxCommand(tokens) {
238
+ const parsed = parseLauncherSubcommand(tokens, PNPM_GLOBAL_FLAGS_WITH_VALUE);
239
+ if (parsed?.subcommand !== "dlx") {
240
+ return null;
241
+ }
242
+ return parseNpxCommand(parsed.args);
243
+ }
244
+ function parseNpmExecCommand(tokens) {
245
+ const parsed = parseLauncherSubcommand(tokens, NPM_GLOBAL_FLAGS_WITH_VALUE);
246
+ if (!parsed || !NPM_EXEC_SUBCOMMANDS.has(parsed.subcommand)) {
247
+ return null;
248
+ }
249
+ return parseNpxCommand(parsed.args);
250
+ }
251
+ function resolvePmSubcommandContext(args) {
252
+ let index = 0;
253
+ while (index < args.length) {
254
+ const token = args[index];
255
+ if (token === "--") {
256
+ index += 1;
257
+ continue;
258
+ }
259
+ if (token.startsWith("-")) {
260
+ if (PM_GLOBAL_FLAGS_WITH_VALUE.has(token)) {
261
+ index += 2;
262
+ continue;
263
+ }
264
+ index += 1;
265
+ continue;
266
+ }
267
+ return {
268
+ subcommand: token,
269
+ remaining: args.slice(index + 1)
270
+ };
271
+ }
272
+ return null;
273
+ }
274
+ function firstPositionalToken(tokens) {
275
+ for (const token of tokens) {
276
+ if (!token.startsWith("-")) {
277
+ return token;
278
+ }
279
+ }
280
+ return void 0;
281
+ }
282
+
283
+ // dist/cli/commands/test.js
284
+ var TEST_OUTPUT_MAX_BUFFER_BYTES = 20 * 1024 * 1024;
285
+ var DEFAULT_LINKED_TEST_TIMEOUT_FORCE_KILL_DELAY_MS = 3e3;
286
+ var DEFAULT_LINKED_TEST_HEARTBEAT_INTERVAL_MS = 1e4;
287
+ var MAX_LINKED_TEST_COMMAND_LABEL_LENGTH = 120;
288
+ var LINKED_TEST_TRACKER_DIRS_TO_SKIP = /* @__PURE__ */ new Set(["locks", "extensions", "runtime"]);
289
+ var LINKED_TEST_ITEM_COUNT_DIRS_TO_SKIP = /* @__PURE__ */ new Set(["history", "index", "search", "extensions", "locks", "runtime"]);
290
+ var LINKED_TEST_INFRA_COLLISION_PATTERNS = [
291
+ /eaddrinuse/i,
292
+ /address already in use/i,
293
+ /port\s+\d+\s+is already in use/i,
294
+ /web server[^.\n]*already running/i,
295
+ /failed to listen on/i
296
+ ];
297
+ var PM_SUBCOMMANDS_WITH_ITEM_REFERENCE = /* @__PURE__ */ new Set([
298
+ "get",
299
+ "history",
300
+ "restore",
301
+ "update",
302
+ "close",
303
+ "delete",
304
+ "append",
305
+ "claim",
306
+ "release",
307
+ "comments",
308
+ "notes",
309
+ "learnings",
310
+ "files",
311
+ "docs",
312
+ "deps",
313
+ "test"
314
+ ]);
315
+ var PM_TRACKER_READ_SUBCOMMANDS = /* @__PURE__ */ new Set([
316
+ "activity",
317
+ "calendar",
318
+ "context",
319
+ "ctx",
320
+ "deps",
321
+ "get",
322
+ "health",
323
+ "history",
324
+ "list",
325
+ "list-all",
326
+ "list-blocked",
327
+ "list-canceled",
328
+ "list-closed",
329
+ "list-draft",
330
+ "list-in-progress",
331
+ "list-open",
332
+ "search",
333
+ "stats",
334
+ "test-all",
335
+ "validate"
336
+ ]);
337
+ function readPositiveIntegerEnv(name, fallback) {
338
+ const raw = process.env[name];
339
+ if (typeof raw !== "string" || raw.trim().length === 0) {
340
+ return fallback;
341
+ }
342
+ const parsed = Number.parseInt(raw, 10);
343
+ if (!Number.isFinite(parsed) || parsed <= 0) {
344
+ return fallback;
345
+ }
346
+ return parsed;
347
+ }
348
+ function linkedTestTimeoutForceKillDelayMs() {
349
+ return readPositiveIntegerEnv("PM_LINKED_TEST_TIMEOUT_FORCE_KILL_DELAY_MS", DEFAULT_LINKED_TEST_TIMEOUT_FORCE_KILL_DELAY_MS);
350
+ }
351
+ function linkedTestHeartbeatIntervalMs() {
352
+ return readPositiveIntegerEnv("PM_LINKED_TEST_HEARTBEAT_INTERVAL_MS", DEFAULT_LINKED_TEST_HEARTBEAT_INTERVAL_MS);
353
+ }
354
+ function resolveAuthor(candidate, fallback) {
355
+ const resolved = candidate ?? process.env.PM_AUTHOR ?? fallback;
356
+ const trimmed = resolved.trim();
357
+ return trimmed || "unknown";
358
+ }
359
+ function resolveTrackedRunId(kind) {
360
+ const fromEnv = process.env.PM_BACKGROUND_TEST_RUN_ID?.trim();
361
+ if (fromEnv && fromEnv.length > 0) {
362
+ return fromEnv;
363
+ }
364
+ return `${kind}-local-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
365
+ }
366
+ function summarizeRunResultStatuses(results) {
367
+ let passed = 0;
368
+ let failed = 0;
369
+ let skipped = 0;
370
+ for (const entry of results) {
371
+ if (entry.status === "passed") {
372
+ passed += 1;
373
+ continue;
374
+ }
375
+ if (entry.status === "failed") {
376
+ failed += 1;
377
+ continue;
378
+ }
379
+ skipped += 1;
380
+ }
381
+ return { passed, failed, skipped };
382
+ }
383
+ function summarizeContextPreflight(runResults) {
384
+ let checkedPmCommands = 0;
385
+ let trackerReadCommands = 0;
386
+ let mismatches = 0;
387
+ let autoRemediated = 0;
388
+ for (const result of runResults) {
389
+ const context = result.execution_context;
390
+ if (!context || context.is_pm_command !== true) {
391
+ continue;
392
+ }
393
+ checkedPmCommands += 1;
394
+ if (context.is_pm_tracker_read_command === true) {
395
+ trackerReadCommands += 1;
396
+ }
397
+ if (context.mismatch_detected === true) {
398
+ mismatches += 1;
399
+ }
400
+ if (context.auto_pm_context_applied === true) {
401
+ autoRemediated += 1;
402
+ }
403
+ }
404
+ return {
405
+ checked_pm_commands: checkedPmCommands,
406
+ tracker_read_commands: trackerReadCommands,
407
+ mismatches,
408
+ auto_remediated: autoRemediated
409
+ };
410
+ }
411
+ function ensureScope(raw) {
412
+ const value = raw ?? "project";
413
+ if (!SCOPE_VALUES.includes(value)) {
414
+ throw new PmCliError(`Invalid scope "${raw}"`, EXIT_CODE.USAGE);
415
+ }
416
+ return value;
417
+ }
418
+ function parsePmContextMode(raw) {
419
+ if (!raw) {
420
+ return "schema";
421
+ }
422
+ const normalized = raw.trim().toLowerCase();
423
+ if (LINKED_TEST_PM_CONTEXT_MODE_VALUES.includes(normalized)) {
424
+ return normalized;
425
+ }
426
+ throw new PmCliError(`Invalid --pm-context value "${raw}". Expected one of: ${LINKED_TEST_PM_CONTEXT_MODE_VALUES.join(", ")}`, EXIT_CODE.USAGE);
427
+ }
428
+ function resolveLinkedTestRequestedContextMode(linkedTest, runLevelMode, overrideLinkedPmContext) {
429
+ if (overrideLinkedPmContext) {
430
+ return runLevelMode;
431
+ }
432
+ if (typeof linkedTest.pm_context_mode !== "string" || linkedTest.pm_context_mode.trim().length === 0) {
433
+ return runLevelMode;
434
+ }
435
+ return parsePmContextMode(linkedTest.pm_context_mode);
436
+ }
437
+ function resolveLinkedTestEffectiveContextMode(requestedMode, isPmTrackerReadCommand) {
438
+ if (requestedMode === "auto") {
439
+ return isPmTrackerReadCommand ? "tracker" : "schema";
440
+ }
441
+ return requestedMode;
442
+ }
443
+ function hasLinkedTestAssertions(linkedTest) {
444
+ return (linkedTest.assert_stdout_contains?.length ?? 0) > 0 || (linkedTest.assert_stdout_regex?.length ?? 0) > 0 || (linkedTest.assert_stderr_contains?.length ?? 0) > 0 || (linkedTest.assert_stderr_regex?.length ?? 0) > 0 || typeof linkedTest.assert_stdout_min_lines === "number" || Object.keys(linkedTest.assert_json_field_equals ?? {}).length > 0 || Object.keys(linkedTest.assert_json_field_gte ?? {}).length > 0;
445
+ }
446
+ function buildPmContextMismatchHint(params) {
447
+ const { executionContext, runLevelPmContextMode, linkedOverridePmContextMode } = params;
448
+ if (!executionContext.is_pm_tracker_read_command || !executionContext.mismatch_detected) {
449
+ return "";
450
+ }
451
+ if (runLevelPmContextMode === "tracker" && linkedOverridePmContextMode === "schema") {
452
+ return " Linked test metadata pm_context_mode=schema overrides run-level --pm-context tracker. Set pm_context_mode=tracker (or auto) on the linked test, or remove the override, to run against seeded tracker data.";
453
+ }
454
+ if (executionContext.pm_context_mode === "schema") {
455
+ return " Use --pm-context tracker to run PM tracker-read commands against seeded tracker data.";
456
+ }
457
+ return "";
458
+ }
459
+ function mergeEnvSetDirectives(entries, optionName) {
460
+ const merged = {};
461
+ if (!entries) {
462
+ return merged;
463
+ }
464
+ for (const entry of entries) {
465
+ const parsed = parseLinkedTestEnvSet(entry, optionName);
466
+ if (!parsed) {
467
+ continue;
468
+ }
469
+ for (const [key, value] of Object.entries(parsed)) {
470
+ merged[key] = value;
471
+ }
472
+ }
473
+ return merged;
474
+ }
475
+ function mergeEnvClearDirectives(entries, optionName) {
476
+ if (!entries) {
477
+ return [];
478
+ }
479
+ const values = [];
480
+ for (const entry of entries) {
481
+ const parsed = parseLinkedTestEnvClear(entry, optionName);
482
+ if (parsed) {
483
+ values.push(...parsed);
484
+ }
485
+ }
486
+ return [...new Set(values)];
487
+ }
488
+ function looksLikePrefixedItemId(token, idPrefix) {
489
+ const normalizedPrefix = idPrefix.trim().toLowerCase().replace(/-+$/, "");
490
+ if (normalizedPrefix.length === 0) {
491
+ return false;
492
+ }
493
+ const normalized = token.trim().toLowerCase();
494
+ if (!normalized.startsWith(`${normalizedPrefix}-`)) {
495
+ return false;
496
+ }
497
+ return normalized.length > normalizedPrefix.length + 1;
498
+ }
499
+ function extractPmInvocationArgsFromSegment(segment) {
500
+ const rawTokens = segment.split(" ").filter((token) => token.length > 0);
501
+ const tokens = stripLeadingEnvAssignments(rawTokens);
502
+ if (tokens.length === 0) {
503
+ return null;
504
+ }
505
+ const [executable, ...args] = tokens;
506
+ if (isPmExecutableToken(executable) || isPmCliScriptToken(executable)) {
507
+ return args;
508
+ }
509
+ if (executable === "node" && args.length > 0 && isPmCliScriptToken(args[0])) {
510
+ return args.slice(1);
511
+ }
512
+ if (executable === "npx") {
513
+ const parsed = parseNpxCommand(args);
514
+ if (parsed && (isPmExecutableToken(parsed.command) || isPmCliPackageToken(parsed.command))) {
515
+ return parsed.args;
516
+ }
517
+ }
518
+ if (executable === "pnpm") {
519
+ const parsed = parsePnpmDlxCommand(args);
520
+ if (parsed && (isPmExecutableToken(parsed.command) || isPmCliPackageToken(parsed.command))) {
521
+ return parsed.args;
522
+ }
523
+ }
524
+ if (executable === "npm") {
525
+ const parsed = parseNpmExecCommand(args);
526
+ if (parsed && (isPmExecutableToken(parsed.command) || isPmCliPackageToken(parsed.command))) {
527
+ return parsed.args;
528
+ }
529
+ }
530
+ return null;
531
+ }
532
+ function commandInvokesPmCli(command) {
533
+ const normalizedCommand = normalizeCommandForValidation(command);
534
+ return splitNormalizedCommandSegments(normalizedCommand).some((segment) => extractPmInvocationArgsFromSegment(segment) !== null);
535
+ }
536
+ function commandInvokesPmTrackerReadCommand(command) {
537
+ const normalizedCommand = normalizeCommandForValidation(command);
538
+ return splitNormalizedCommandSegments(normalizedCommand).some((segment) => {
539
+ const invocationArgs = extractPmInvocationArgsFromSegment(segment);
540
+ if (!invocationArgs) {
541
+ return false;
542
+ }
543
+ const context = resolvePmSubcommandContext(invocationArgs);
544
+ if (!context) {
545
+ return false;
546
+ }
547
+ return PM_TRACKER_READ_SUBCOMMANDS.has(context.subcommand);
548
+ });
549
+ }
550
+ function extractReferencedPmItemIdsFromCommand(command, idPrefix = "pm") {
551
+ const normalizedCommand = normalizeCommandForValidation(command);
552
+ const ids = /* @__PURE__ */ new Set();
553
+ for (const segment of splitNormalizedCommandSegments(normalizedCommand)) {
554
+ const invocationArgs = extractPmInvocationArgsFromSegment(segment);
555
+ if (!invocationArgs) {
556
+ continue;
557
+ }
558
+ const context = resolvePmSubcommandContext(invocationArgs);
559
+ if (!context) {
560
+ continue;
561
+ }
562
+ if (!PM_SUBCOMMANDS_WITH_ITEM_REFERENCE.has(context.subcommand)) {
563
+ continue;
564
+ }
565
+ const candidate = firstPositionalToken(context.remaining);
566
+ if (!candidate) {
567
+ continue;
568
+ }
569
+ if (looksLikePrefixedItemId(candidate, idPrefix)) {
570
+ ids.add(candidate);
571
+ }
572
+ }
573
+ return [...ids].sort((left, right) => left.localeCompare(right));
574
+ }
575
+ function resolveDirectRunnerSubcommand(parsed) {
576
+ if (!parsed) {
577
+ return void 0;
578
+ }
579
+ if (!SCRIPT_RUN_SUBCOMMANDS.has(parsed.subcommand)) {
580
+ return parsed.subcommand;
581
+ }
582
+ return parseLauncherSubcommand(parsed.args, SCRIPT_RUN_FLAGS_WITH_VALUE)?.subcommand;
583
+ }
584
+ function firstDirectTestRunnerSubcommand(executable, args) {
585
+ if (executable === "npx") {
586
+ return parseNpxCommand(args)?.command;
587
+ }
588
+ if (executable === "pnpm") {
589
+ return resolveDirectRunnerSubcommand(parseLauncherSubcommand(args, PNPM_GLOBAL_FLAGS_WITH_VALUE));
590
+ }
591
+ if (executable === "npm") {
592
+ return resolveDirectRunnerSubcommand(parseLauncherSubcommand(args, NPM_GLOBAL_FLAGS_WITH_VALUE));
593
+ }
594
+ if (executable === "yarn") {
595
+ return resolveDirectRunnerSubcommand(parseLauncherSubcommand(args, YARN_GLOBAL_FLAGS_WITH_VALUE));
596
+ }
597
+ if (executable === "bun") {
598
+ return resolveDirectRunnerSubcommand(parseLauncherSubcommand(args, BUN_GLOBAL_FLAGS_WITH_VALUE));
599
+ }
600
+ return void 0;
601
+ }
602
+ function isDirectTestRunnerSubcommand(token) {
603
+ if (!token) {
604
+ return false;
605
+ }
606
+ return token === "vitest" || token === "test" || token.startsWith("test:");
607
+ }
608
+ function parsedLauncherInvokesRecursiveTestAll(parsed) {
609
+ if (!parsed) {
610
+ return false;
611
+ }
612
+ if (!isPmExecutableToken(parsed.command) && !isPmCliPackageToken(parsed.command)) {
613
+ return false;
614
+ }
615
+ return firstPmSubcommand(parsed.args) === "test-all";
616
+ }
617
+ function segmentInvokesRecursiveTestAll(segment) {
618
+ const rawTokens = segment.split(" ").filter((token) => token.length > 0);
619
+ const tokens = stripLeadingEnvAssignments(rawTokens);
620
+ if (tokens.length === 0) {
621
+ return false;
622
+ }
623
+ const [executable, ...args] = tokens;
624
+ if (isPmExecutableToken(executable) || isPmCliScriptToken(executable)) {
625
+ return firstPmSubcommand(args) === "test-all";
626
+ }
627
+ if (executable === "node" && args.length > 0 && isPmCliScriptToken(args[0])) {
628
+ return firstPmSubcommand(args.slice(1)) === "test-all";
629
+ }
630
+ if (executable === "npx") {
631
+ return parsedLauncherInvokesRecursiveTestAll(parseNpxCommand(args));
632
+ }
633
+ if (executable === "pnpm") {
634
+ return parsedLauncherInvokesRecursiveTestAll(parsePnpmDlxCommand(args));
635
+ }
636
+ if (executable === "npm") {
637
+ return parsedLauncherInvokesRecursiveTestAll(parseNpmExecCommand(args));
638
+ }
639
+ return false;
640
+ }
641
+ function invokesRecursiveTestAllCommand(command) {
642
+ const normalized = normalizeCommandForValidation(command);
643
+ return splitNormalizedCommandSegments(normalized).some((segment) => segmentInvokesRecursiveTestAll(segment));
644
+ }
645
+ function assertNoRecursiveTestAllCommand(command) {
646
+ if (!invokesRecursiveTestAllCommand(command))
647
+ return;
648
+ throw new PmCliError('Linked test commands must not invoke "pm test-all"; this creates recursive orchestration.', EXIT_CODE.USAGE);
649
+ }
650
+ function normalizeCommandForValidation(command) {
651
+ return command.trim().replaceAll("\\", "/").replaceAll('"', "").replaceAll("'", "").replaceAll(/\s+/g, " ").toLowerCase();
652
+ }
653
+ function commandUsesSandboxRunner(normalizedCommand) {
654
+ return normalizedCommand.includes("node scripts/run-tests.mjs ") || normalizedCommand.endsWith("node scripts/run-tests.mjs") || normalizedCommand.includes("node ./scripts/run-tests.mjs ") || normalizedCommand.endsWith("node ./scripts/run-tests.mjs");
655
+ }
656
+ function segmentHasExplicitSandboxEnv(normalizedSegment) {
657
+ const hasExplicitPmPath = /\bpm_path\s*=/.test(normalizedSegment) || /\$env:pm_path\s*=/.test(normalizedSegment);
658
+ const hasExplicitPmGlobalPath = /\bpm_global_path\s*=/.test(normalizedSegment) || /\$env:pm_global_path\s*=/.test(normalizedSegment);
659
+ return hasExplicitPmPath && hasExplicitPmGlobalPath;
660
+ }
661
+ function commandInvokesDirectTestRunner(normalizedCommand) {
662
+ const rawTokens = normalizedCommand.split(" ").filter((token) => token.length > 0);
663
+ const tokens = stripLeadingEnvAssignments(rawTokens);
664
+ if (tokens.length === 0) {
665
+ return false;
666
+ }
667
+ const [executable, ...args] = tokens;
668
+ if (executable === "vitest" || executable.endsWith("/vitest") || executable.endsWith("/vitest.mjs")) {
669
+ return true;
670
+ }
671
+ if (executable === "node") {
672
+ return args[0] === "--test" || Boolean(args[0]?.endsWith("/vitest") || args[0]?.endsWith("/vitest.mjs"));
673
+ }
674
+ const subcommand = firstDirectTestRunnerSubcommand(executable, args);
675
+ return isDirectTestRunnerSubcommand(subcommand);
676
+ }
677
+ function assertSandboxSafeTestRunnerCommand(command) {
678
+ const normalized = normalizeCommandForValidation(command);
679
+ const segments = splitNormalizedCommandSegments(normalized);
680
+ const hasUnsafeDirectRunnerSegment = segments.some((segment) => !commandUsesSandboxRunner(segment) && commandInvokesDirectTestRunner(segment) && !segmentHasExplicitSandboxEnv(segment));
681
+ if (!hasUnsafeDirectRunnerSegment) {
682
+ return;
683
+ }
684
+ throw new PmCliError('Linked test runner commands must be sandbox-safe: use "node scripts/run-tests.mjs <test|coverage>" or include PM_PATH=... PM_GLOBAL_PATH=... INLINE in the command string (exporting them in your shell environment is not checked). Example: "PM_PATH=/tmp/pm-x PM_GLOBAL_PATH=/tmp/pm-x-g vitest run".', EXIT_CODE.USAGE);
685
+ }
686
+ function getRuntimeSafetySkipReason(command) {
687
+ if (!invokesRecursiveTestAllCommand(command))
688
+ return void 0;
689
+ return 'Linked test command skipped: Linked test commands must not invoke "pm test-all"; this creates recursive orchestration.';
690
+ }
691
+ function parseAddEntries(raw) {
692
+ if (!raw)
693
+ return [];
694
+ return raw.map((entry) => {
695
+ const trimmed = entry.trim();
696
+ const kv = looksLikeStructuredLinkedTestEntry(trimmed) ? normalizeStructuredLinkedTestEntry(parseCsvKv(entry, "--add"), "--add") : { command: trimmed };
697
+ const command = kv.command?.trim() || void 0;
698
+ const filePath = kv.path?.trim() || void 0;
699
+ if (!command) {
700
+ throw new PmCliError("--add requires command=<value> or a bare command (path=<value> is optional metadata)", EXIT_CODE.USAGE);
701
+ }
702
+ if (command) {
703
+ assertNoRecursiveTestAllCommand(command);
704
+ assertSandboxSafeTestRunnerCommand(command);
705
+ }
706
+ const timeoutSecondsRaw = kv.timeout_seconds?.trim();
707
+ const timeoutAliasRaw = kv.timeout?.trim();
708
+ if (timeoutSecondsRaw && timeoutAliasRaw && timeoutSecondsRaw !== timeoutAliasRaw) {
709
+ throw new PmCliError("--add timeout and timeout_seconds must match when both are provided", EXIT_CODE.USAGE);
710
+ }
711
+ const timeoutRaw = timeoutSecondsRaw ?? timeoutAliasRaw;
712
+ const timeoutSeconds = timeoutRaw === void 0 ? void 0 : Math.floor(parseOptionalNumber(timeoutRaw, "timeout_seconds"));
713
+ const envSet = parseLinkedTestEnvSet(kv.env_set?.trim(), "--add");
714
+ const envClear = parseLinkedTestEnvClear(kv.env_clear?.trim(), "--add");
715
+ const pmContextMode = parseLinkedTestContextMode(kv.pm_context_mode?.trim(), "--add");
716
+ const sharedHostSafe = parseLinkedTestBoolean(kv.shared_host_safe?.trim(), "--add", "shared_host_safe");
717
+ return {
718
+ command,
719
+ path: filePath,
720
+ scope: ensureScope(kv.scope),
721
+ timeout_seconds: timeoutSeconds,
722
+ pm_context_mode: pmContextMode,
723
+ env_set: envSet,
724
+ env_clear: envClear,
725
+ shared_host_safe: sharedHostSafe,
726
+ assert_stdout_contains: parseLinkedTestStringList(kv.assert_stdout_contains?.trim()),
727
+ assert_stdout_regex: parseLinkedTestRegexList(kv.assert_stdout_regex?.trim(), "--add", "assert_stdout_regex"),
728
+ assert_stderr_contains: parseLinkedTestStringList(kv.assert_stderr_contains?.trim()),
729
+ assert_stderr_regex: parseLinkedTestRegexList(kv.assert_stderr_regex?.trim(), "--add", "assert_stderr_regex"),
730
+ assert_stdout_min_lines: parseLinkedTestMinLines(kv.assert_stdout_min_lines?.trim(), "--add"),
731
+ assert_json_field_equals: parseLinkedTestAssertionEqualsMap(kv.assert_json_field_equals?.trim(), "--add"),
732
+ assert_json_field_gte: parseLinkedTestAssertionGteMap(kv.assert_json_field_gte?.trim(), "--add"),
733
+ note: kv.note?.trim() || void 0
734
+ };
735
+ });
736
+ }
737
+ function parseRemoveEntries(raw) {
738
+ if (!raw)
739
+ return [];
740
+ return raw.map((entry) => {
741
+ const trimmed = entry.trim();
742
+ if (!trimmed) {
743
+ throw new PmCliError("--remove requires command or path value", EXIT_CODE.USAGE);
744
+ }
745
+ if (trimmed.includes("=") || /^(?:[-*+]\s+)?(?:path|command)\s*[:=]/i.test(trimmed) || trimmed.startsWith("```")) {
746
+ const kv = parseCsvKv(trimmed, "--remove");
747
+ const value = kv.path ?? kv.command;
748
+ if (!value?.trim()) {
749
+ throw new PmCliError("--remove requires command=<value> and/or path=<value>", EXIT_CODE.USAGE);
750
+ }
751
+ return value.trim();
752
+ }
753
+ return trimmed;
754
+ });
755
+ }
756
+ function closeLinkedTestStdin(child) {
757
+ try {
758
+ child.stdin?.end();
759
+ } catch {
760
+ }
761
+ }
762
+ function summarizeLinkedTestCommand(command) {
763
+ const normalized = command.trim().replaceAll(/\s+/g, " ");
764
+ if (normalized.length <= MAX_LINKED_TEST_COMMAND_LABEL_LENGTH) {
765
+ return normalized;
766
+ }
767
+ return `${normalized.slice(0, MAX_LINKED_TEST_COMMAND_LABEL_LENGTH - 3)}...`;
768
+ }
769
+ function shouldEmitLinkedTestProgress(mode) {
770
+ if (mode === "off") {
771
+ return false;
772
+ }
773
+ if (mode === "always") {
774
+ return true;
775
+ }
776
+ return process.stderr.isTTY === true;
777
+ }
778
+ function emitLinkedTestProgress(message) {
779
+ try {
780
+ process.stderr.write(`${message}
781
+ `);
782
+ } catch {
783
+ }
784
+ }
785
+ function beginLinkedTestProgress(context, mode) {
786
+ if (!shouldEmitLinkedTestProgress(mode)) {
787
+ return null;
788
+ }
789
+ const commandLabel = summarizeLinkedTestCommand(context.command);
790
+ const startAt = Date.now();
791
+ emitLinkedTestProgress(`[pm test] linked-test ${context.index}/${context.total} start timeout_ms=${context.timeoutMs} command="${commandLabel}"`);
792
+ const heartbeat = setInterval(() => {
793
+ const elapsedMs = Date.now() - startAt;
794
+ emitLinkedTestProgress(`[pm test] linked-test ${context.index}/${context.total} running elapsed_ms=${elapsedMs} command="${commandLabel}"`);
795
+ }, linkedTestHeartbeatIntervalMs());
796
+ heartbeat.unref?.();
797
+ return heartbeat;
798
+ }
799
+ function endLinkedTestProgress(context, executionResult, startedAt, mode) {
800
+ if (!shouldEmitLinkedTestProgress(mode)) {
801
+ return;
802
+ }
803
+ const commandLabel = summarizeLinkedTestCommand(context.command);
804
+ const elapsedMs = Date.now() - startedAt;
805
+ const failed = executionResult.timedOut || executionResult.maxBufferExceeded || executionResult.exitCode !== 0;
806
+ const statusLabel = failed ? "failed" : "passed";
807
+ const reasonTokens = [];
808
+ if (executionResult.timedOut) {
809
+ reasonTokens.push("reason=timeout");
810
+ }
811
+ if (executionResult.maxBufferExceeded) {
812
+ reasonTokens.push("reason=max_buffer");
813
+ }
814
+ if (executionResult.signal) {
815
+ reasonTokens.push(`signal=${executionResult.signal}`);
816
+ }
817
+ const exitLabel = executionResult.exitCode === null ? "null" : String(executionResult.exitCode);
818
+ const reasonSuffix = reasonTokens.length > 0 ? ` ${reasonTokens.join(" ")}` : "";
819
+ emitLinkedTestProgress(`[pm test] linked-test ${context.index}/${context.total} end status=${statusLabel} exit_code=${exitLabel} elapsed_ms=${elapsedMs}${reasonSuffix} command="${commandLabel}"`);
820
+ }
821
+ async function killProcessTree(pid) {
822
+ if (!Number.isInteger(pid) || pid <= 0) {
823
+ return;
824
+ }
825
+ if (process.platform === "win32") {
826
+ await new Promise((resolve) => {
827
+ const killer = spawn("taskkill", ["/pid", String(pid), "/T", "/F"], {
828
+ stdio: "ignore",
829
+ windowsHide: true
830
+ });
831
+ killer.on("error", () => resolve());
832
+ killer.on("close", () => resolve());
833
+ });
834
+ return;
835
+ }
836
+ try {
837
+ process.kill(-pid, "SIGKILL");
838
+ return;
839
+ } catch {
840
+ }
841
+ try {
842
+ process.kill(pid, "SIGKILL");
843
+ } catch {
844
+ }
845
+ }
846
+ async function runLinkedTestCommand(command, timeoutMs, env, progressContext, progressMode) {
847
+ const startedAt = Date.now();
848
+ const heartbeat = beginLinkedTestProgress(progressContext, progressMode);
849
+ const child = spawn(command, {
850
+ cwd: process.cwd(),
851
+ env,
852
+ shell: true,
853
+ windowsHide: true,
854
+ detached: process.platform !== "win32",
855
+ stdio: ["pipe", "pipe", "pipe"]
856
+ });
857
+ closeLinkedTestStdin(child);
858
+ let stdout = "";
859
+ let stderr = "";
860
+ let stdoutBytes = 0;
861
+ let stderrBytes = 0;
862
+ let timedOut = false;
863
+ let maxBufferExceeded = false;
864
+ let spawnError;
865
+ let forceKillTimer = null;
866
+ let timedOutTimer = null;
867
+ let terminationRequested = false;
868
+ const clearTimers = () => {
869
+ if (heartbeat) {
870
+ clearInterval(heartbeat);
871
+ }
872
+ if (timedOutTimer) {
873
+ clearTimeout(timedOutTimer);
874
+ timedOutTimer = null;
875
+ }
876
+ if (forceKillTimer) {
877
+ clearTimeout(forceKillTimer);
878
+ forceKillTimer = null;
879
+ }
880
+ };
881
+ const requestTermination = async () => {
882
+ if (terminationRequested) {
883
+ return;
884
+ }
885
+ terminationRequested = true;
886
+ const pid = child.pid;
887
+ if (!pid || pid <= 0) {
888
+ try {
889
+ child.kill("SIGTERM");
890
+ } catch {
891
+ }
892
+ return;
893
+ }
894
+ if (process.platform === "win32") {
895
+ await killProcessTree(pid);
896
+ return;
897
+ }
898
+ try {
899
+ process.kill(-pid, "SIGTERM");
900
+ } catch {
901
+ try {
902
+ child.kill("SIGTERM");
903
+ } catch {
904
+ }
905
+ }
906
+ forceKillTimer = setTimeout(() => {
907
+ void killProcessTree(pid);
908
+ }, linkedTestTimeoutForceKillDelayMs());
909
+ forceKillTimer.unref?.();
910
+ };
911
+ const appendChunk = (chunk, target) => {
912
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
913
+ const bytes = Buffer.byteLength(text);
914
+ if (target === "stdout") {
915
+ stdoutBytes += bytes;
916
+ if (stdoutBytes <= TEST_OUTPUT_MAX_BUFFER_BYTES) {
917
+ stdout += text;
918
+ }
919
+ } else {
920
+ stderrBytes += bytes;
921
+ if (stderrBytes <= TEST_OUTPUT_MAX_BUFFER_BYTES) {
922
+ stderr += text;
923
+ }
924
+ }
925
+ if (!maxBufferExceeded && (stdoutBytes > TEST_OUTPUT_MAX_BUFFER_BYTES || stderrBytes > TEST_OUTPUT_MAX_BUFFER_BYTES)) {
926
+ maxBufferExceeded = true;
927
+ void requestTermination();
928
+ }
929
+ };
930
+ child.stdout?.on("data", (chunk) => appendChunk(chunk, "stdout"));
931
+ child.stderr?.on("data", (chunk) => appendChunk(chunk, "stderr"));
932
+ child.on("error", (error) => {
933
+ spawnError = error.message;
934
+ });
935
+ timedOutTimer = setTimeout(() => {
936
+ timedOut = true;
937
+ void requestTermination();
938
+ }, timeoutMs);
939
+ timedOutTimer.unref?.();
940
+ const { code, signal } = await new Promise((resolve) => {
941
+ child.on("close", (closeCode, closeSignal) => {
942
+ resolve({
943
+ code: closeCode,
944
+ signal: closeSignal
945
+ });
946
+ });
947
+ });
948
+ clearTimers();
949
+ const executionResult = {
950
+ stdout,
951
+ stderr,
952
+ exitCode: code,
953
+ signal,
954
+ timedOut,
955
+ maxBufferExceeded,
956
+ spawnError
957
+ };
958
+ endLinkedTestProgress(progressContext, executionResult, startedAt, progressMode);
959
+ return executionResult;
960
+ }
961
+ function formatLinkedTestExecutionError(result, timeoutMs) {
962
+ const details = [];
963
+ if (result.maxBufferExceeded) {
964
+ details.push(`Linked test output exceeded maxBuffer=${TEST_OUTPUT_MAX_BUFFER_BYTES} bytes. Reduce output volume or split the command.`);
965
+ }
966
+ if (result.timedOut && timeoutMs > 0) {
967
+ details.push(`Linked test timed out after ${timeoutMs}ms.`);
968
+ }
969
+ const signalMessage = result.signal ? `Linked test command terminated by signal ${result.signal}.` : void 0;
970
+ const baseMessage = result.spawnError?.trim() || signalMessage || "Linked test command failed.";
971
+ if (details.length === 0) {
972
+ return baseMessage;
973
+ }
974
+ return `${baseMessage} ${details.join(" ")}`;
975
+ }
976
+ function hasInfraCollisionSignal(result) {
977
+ const combined = [result.spawnError ?? "", result.stderr, result.stdout].join("\n");
978
+ return LINKED_TEST_INFRA_COLLISION_PATTERNS.some((pattern) => pattern.test(combined));
979
+ }
980
+ function classifyLinkedTestFailure(result) {
981
+ if (hasInfraCollisionSignal(result)) {
982
+ return "infra_collision";
983
+ }
984
+ if (result.timedOut) {
985
+ return "timeout";
986
+ }
987
+ if (result.maxBufferExceeded) {
988
+ return "max_buffer";
989
+ }
990
+ if (result.spawnError) {
991
+ return "spawn_error";
992
+ }
993
+ if (result.signal) {
994
+ return "signal";
995
+ }
996
+ return "assertion_failure";
997
+ }
998
+ function createEmptyFailureCategoryCounts() {
999
+ return {
1000
+ infra_collision: 0,
1001
+ assertion_failure: 0,
1002
+ empty_run: 0,
1003
+ timeout: 0,
1004
+ max_buffer: 0,
1005
+ spawn_error: 0,
1006
+ signal: 0
1007
+ };
1008
+ }
1009
+ function countFailureCategories(runResults) {
1010
+ const counts = createEmptyFailureCategoryCounts();
1011
+ for (const result of runResults) {
1012
+ if (result.status !== "failed" || !result.failure_category) {
1013
+ continue;
1014
+ }
1015
+ counts[result.failure_category] += 1;
1016
+ }
1017
+ return counts;
1018
+ }
1019
+ function applyEnvDirectiveStage(env, directives) {
1020
+ for (const [key, value] of Object.entries(directives.env_set)) {
1021
+ if (LINKED_TEST_PROTECTED_ENV_KEYS.has(key.toUpperCase())) {
1022
+ continue;
1023
+ }
1024
+ env[key] = value;
1025
+ }
1026
+ for (const key of directives.env_clear) {
1027
+ if (LINKED_TEST_PROTECTED_ENV_KEYS.has(key.toUpperCase())) {
1028
+ continue;
1029
+ }
1030
+ delete env[key];
1031
+ }
1032
+ }
1033
+ function applySharedHostSafeDefaults(env) {
1034
+ if (env.PORT === void 0) {
1035
+ env.PORT = "0";
1036
+ }
1037
+ if (env.HOST === void 0) {
1038
+ env.HOST = "127.0.0.1";
1039
+ }
1040
+ if (env.PM_SHARED_HOST_SAFE === void 0) {
1041
+ env.PM_SHARED_HOST_SAFE = "1";
1042
+ }
1043
+ if (env.PLAYWRIGHT_HTML_OPEN === void 0) {
1044
+ env.PLAYWRIGHT_HTML_OPEN = "never";
1045
+ }
1046
+ if (env.PW_TEST_HTML_REPORT_OPEN === void 0) {
1047
+ env.PW_TEST_HTML_REPORT_OPEN = "never";
1048
+ }
1049
+ }
1050
+ function resolveEffectiveLinkedTestDirectives(runtimeDirectives, linkedTest) {
1051
+ const envSet = { ...runtimeDirectives.env_set, ...linkedTest.env_set ?? {} };
1052
+ const envClear = [.../* @__PURE__ */ new Set([...runtimeDirectives.env_clear, ...linkedTest.env_clear ?? []])];
1053
+ const sharedHostSafe = linkedTest.shared_host_safe ?? runtimeDirectives.shared_host_safe;
1054
+ return {
1055
+ env_set: envSet,
1056
+ env_clear: envClear,
1057
+ shared_host_safe: sharedHostSafe
1058
+ };
1059
+ }
1060
+ function resolveRuntimeDirectives(envSetEntries, envClearEntries, sharedHostSafe) {
1061
+ return {
1062
+ env_set: mergeEnvSetDirectives(envSetEntries, "--env-set"),
1063
+ env_clear: mergeEnvClearDirectives(envClearEntries, "--env-clear"),
1064
+ shared_host_safe: sharedHostSafe === true
1065
+ };
1066
+ }
1067
+ async function copyIntoSandboxIfPresent(sourcePath, targetPath, recursive = false) {
1068
+ if (!await pathExists(sourcePath)) {
1069
+ return;
1070
+ }
1071
+ await mkdir(path.dirname(targetPath), { recursive: true });
1072
+ try {
1073
+ if (recursive) {
1074
+ await cp(sourcePath, targetPath, { recursive: true, force: true });
1075
+ return;
1076
+ }
1077
+ await cp(sourcePath, targetPath, { force: true });
1078
+ } catch (error) {
1079
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
1080
+ return;
1081
+ }
1082
+ throw error;
1083
+ }
1084
+ }
1085
+ async function seedLinkedTestSandbox(sandboxPmPath, sandboxGlobalPath, sourceRoots) {
1086
+ await copyIntoSandboxIfPresent(getSettingsPath(sourceRoots.projectPmRoot), getSettingsPath(sandboxPmPath));
1087
+ await copyIntoSandboxIfPresent(path.join(sourceRoots.projectPmRoot, "extensions"), path.join(sandboxPmPath, "extensions"), true);
1088
+ await copyIntoSandboxIfPresent(getSettingsPath(sourceRoots.globalPmRoot), getSettingsPath(sandboxGlobalPath));
1089
+ await copyIntoSandboxIfPresent(path.join(sourceRoots.globalPmRoot, "extensions"), path.join(sandboxGlobalPath, "extensions"), true);
1090
+ }
1091
+ async function seedLinkedTestTrackerData(sourceRoot, sandboxRoot) {
1092
+ if (!await pathExists(sourceRoot)) {
1093
+ return;
1094
+ }
1095
+ const entries = await readdir(sourceRoot, { withFileTypes: true });
1096
+ for (const entry of entries) {
1097
+ if (LINKED_TEST_TRACKER_DIRS_TO_SKIP.has(entry.name)) {
1098
+ continue;
1099
+ }
1100
+ const sourcePath = path.join(sourceRoot, entry.name);
1101
+ const targetPath = path.join(sandboxRoot, entry.name);
1102
+ if (entry.isDirectory()) {
1103
+ await copyIntoSandboxIfPresent(sourcePath, targetPath, true);
1104
+ continue;
1105
+ }
1106
+ if (entry.isFile()) {
1107
+ await copyIntoSandboxIfPresent(sourcePath, targetPath);
1108
+ }
1109
+ }
1110
+ }
1111
+ async function countLinkedTestItemFiles(pmRoot) {
1112
+ if (!await pathExists(pmRoot)) {
1113
+ return 0;
1114
+ }
1115
+ let total = 0;
1116
+ const entries = await readdir(pmRoot, { withFileTypes: true });
1117
+ for (const entry of entries) {
1118
+ if (!entry.isDirectory() || LINKED_TEST_ITEM_COUNT_DIRS_TO_SKIP.has(entry.name)) {
1119
+ continue;
1120
+ }
1121
+ const folderPath = path.join(pmRoot, entry.name);
1122
+ let files;
1123
+ try {
1124
+ files = await readdir(folderPath, { withFileTypes: true });
1125
+ } catch {
1126
+ continue;
1127
+ }
1128
+ for (const file of files) {
1129
+ if (!file.isFile()) {
1130
+ continue;
1131
+ }
1132
+ if (ITEM_FILE_EXTENSIONS.some((extension) => file.name.toLowerCase().endsWith(extension))) {
1133
+ total += 1;
1134
+ }
1135
+ }
1136
+ }
1137
+ return total;
1138
+ }
1139
+ function resolveLinkedTestFailureExitCode(execution) {
1140
+ const rawExitCode = typeof execution.exitCode === "number" ? execution.exitCode : 1;
1141
+ if ((execution.timedOut || execution.maxBufferExceeded) && rawExitCode === 0) {
1142
+ return 1;
1143
+ }
1144
+ return rawExitCode;
1145
+ }
1146
+ function splitJsonPathSegments(fieldPath) {
1147
+ const segments = [];
1148
+ const tokens = fieldPath.match(/[^.[\]]+|\[\d+\]/g) ?? [];
1149
+ for (const token of tokens) {
1150
+ if (token.startsWith("[") && token.endsWith("]")) {
1151
+ const parsedIndex = Number.parseInt(token.slice(1, -1), 10);
1152
+ if (!Number.isInteger(parsedIndex) || parsedIndex < 0) {
1153
+ return [];
1154
+ }
1155
+ segments.push(parsedIndex);
1156
+ continue;
1157
+ }
1158
+ segments.push(token);
1159
+ }
1160
+ return segments;
1161
+ }
1162
+ function readJsonPathValue(root, fieldPath) {
1163
+ const normalizedPath = fieldPath.trim();
1164
+ if (normalizedPath.length === 0) {
1165
+ return { found: false, value: void 0 };
1166
+ }
1167
+ const segments = splitJsonPathSegments(normalizedPath);
1168
+ if (segments.length === 0) {
1169
+ return { found: false, value: void 0 };
1170
+ }
1171
+ let current = root;
1172
+ for (const segment of segments) {
1173
+ if (typeof segment === "number") {
1174
+ if (!Array.isArray(current) || segment >= current.length) {
1175
+ return { found: false, value: void 0 };
1176
+ }
1177
+ current = current[segment];
1178
+ continue;
1179
+ }
1180
+ if (typeof current !== "object" || current === null || !(segment in current)) {
1181
+ return { found: false, value: void 0 };
1182
+ }
1183
+ current = current[segment];
1184
+ }
1185
+ return { found: true, value: current };
1186
+ }
1187
+ function parseAssertionLiteral(raw) {
1188
+ const trimmed = raw.trim();
1189
+ if (trimmed === "true") {
1190
+ return true;
1191
+ }
1192
+ if (trimmed === "false") {
1193
+ return false;
1194
+ }
1195
+ if (trimmed === "null") {
1196
+ return null;
1197
+ }
1198
+ const numeric = Number(trimmed);
1199
+ if (trimmed.length > 0 && Number.isFinite(numeric)) {
1200
+ return numeric;
1201
+ }
1202
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
1203
+ try {
1204
+ return JSON.parse(trimmed);
1205
+ } catch {
1206
+ }
1207
+ }
1208
+ return trimmed;
1209
+ }
1210
+ function compareAssertionValues(actual, expected) {
1211
+ if (typeof actual === "object" && actual !== null && typeof expected === "object" && expected !== null) {
1212
+ return stableValueEquals(actual, expected);
1213
+ }
1214
+ return Object.is(actual, expected);
1215
+ }
1216
+ function evaluateLinkedTestAssertions(linkedTest, stdout, stderr) {
1217
+ const failures = [];
1218
+ for (const expected of linkedTest.assert_stdout_contains ?? []) {
1219
+ if (!stdout.includes(expected)) {
1220
+ failures.push(`stdout missing required text: "${expected}"`);
1221
+ }
1222
+ }
1223
+ for (const pattern of linkedTest.assert_stdout_regex ?? []) {
1224
+ try {
1225
+ const regex = new RegExp(pattern, "m");
1226
+ if (!regex.test(stdout)) {
1227
+ failures.push(`stdout failed regex assertion: /${pattern}/m`);
1228
+ }
1229
+ } catch (error) {
1230
+ failures.push(`stdout regex assertion is invalid: /${pattern}/ (${error instanceof Error ? error.message : String(error)})`);
1231
+ }
1232
+ }
1233
+ for (const expected of linkedTest.assert_stderr_contains ?? []) {
1234
+ if (!stderr.includes(expected)) {
1235
+ failures.push(`stderr missing required text: "${expected}"`);
1236
+ }
1237
+ }
1238
+ for (const pattern of linkedTest.assert_stderr_regex ?? []) {
1239
+ try {
1240
+ const regex = new RegExp(pattern, "m");
1241
+ if (!regex.test(stderr)) {
1242
+ failures.push(`stderr failed regex assertion: /${pattern}/m`);
1243
+ }
1244
+ } catch (error) {
1245
+ failures.push(`stderr regex assertion is invalid: /${pattern}/ (${error instanceof Error ? error.message : String(error)})`);
1246
+ }
1247
+ }
1248
+ if (typeof linkedTest.assert_stdout_min_lines === "number") {
1249
+ const lineCount = stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).length;
1250
+ if (lineCount < linkedTest.assert_stdout_min_lines) {
1251
+ failures.push(`stdout line count ${lineCount} is below required minimum ${linkedTest.assert_stdout_min_lines}`);
1252
+ }
1253
+ }
1254
+ const jsonEqualsAssertions = linkedTest.assert_json_field_equals ?? {};
1255
+ const jsonGteAssertions = linkedTest.assert_json_field_gte ?? {};
1256
+ const needsJsonAssertions = Object.keys(jsonEqualsAssertions).length > 0 || Object.keys(jsonGteAssertions).length > 0;
1257
+ if (!needsJsonAssertions) {
1258
+ return failures;
1259
+ }
1260
+ let parsedJson;
1261
+ try {
1262
+ parsedJson = JSON.parse(stdout);
1263
+ } catch (error) {
1264
+ failures.push(`stdout is not valid JSON for assert_json_field_* checks: ${error instanceof Error ? error.message : String(error)}`);
1265
+ return failures;
1266
+ }
1267
+ for (const [fieldPath, expectedRaw] of Object.entries(jsonEqualsAssertions)) {
1268
+ const resolved = readJsonPathValue(parsedJson, fieldPath);
1269
+ if (!resolved.found) {
1270
+ failures.push(`assert_json_field_equals missing path "${fieldPath}"`);
1271
+ continue;
1272
+ }
1273
+ const expected = parseAssertionLiteral(expectedRaw);
1274
+ if (!compareAssertionValues(resolved.value, expected)) {
1275
+ failures.push(`assert_json_field_equals mismatch at "${fieldPath}" (expected=${JSON.stringify(expected)} actual=${JSON.stringify(resolved.value)})`);
1276
+ }
1277
+ }
1278
+ for (const [fieldPath, expectedMinimum] of Object.entries(jsonGteAssertions)) {
1279
+ const resolved = readJsonPathValue(parsedJson, fieldPath);
1280
+ if (!resolved.found) {
1281
+ failures.push(`assert_json_field_gte missing path "${fieldPath}"`);
1282
+ continue;
1283
+ }
1284
+ if (typeof resolved.value !== "number" || !Number.isFinite(resolved.value)) {
1285
+ failures.push(`assert_json_field_gte path "${fieldPath}" resolved to non-numeric value`);
1286
+ continue;
1287
+ }
1288
+ if (resolved.value < expectedMinimum) {
1289
+ failures.push(`assert_json_field_gte failed at "${fieldPath}" (expected >= ${expectedMinimum}, actual ${resolved.value})`);
1290
+ }
1291
+ }
1292
+ return failures;
1293
+ }
1294
+ var EMPTY_LINKED_TEST_RUN_PATTERNS = [
1295
+ { code: "no_projects_matched_filters", regex: /\bNo projects matched the filters\b/i },
1296
+ { code: "no_test_files_found", regex: /\bNo test files found\b/i },
1297
+ { code: "no_tests_found", regex: /\bNo tests found\b/i },
1298
+ { code: "no_matching_tests", regex: /\bNo matching tests?\b/i },
1299
+ { code: "collected_zero_items", regex: /\bcollected 0 items?\b/i }
1300
+ ];
1301
+ function detectEmptyLinkedTestRun(stdout, stderr) {
1302
+ const combined = `${stdout}
1303
+ ${stderr}`;
1304
+ for (const pattern of EMPTY_LINKED_TEST_RUN_PATTERNS) {
1305
+ if (pattern.regex.test(combined)) {
1306
+ return pattern.code;
1307
+ }
1308
+ }
1309
+ return null;
1310
+ }
1311
+ async function runLinkedTests(tests, defaultTimeoutSeconds, options) {
1312
+ const results = [];
1313
+ const sandboxRoot = await mkdtemp(path.join(tmpdir(), "pm-linked-test-"));
1314
+ const schemaSandboxPmPath = path.join(sandboxRoot, "schema", "project", ".agents", "pm");
1315
+ const schemaSandboxGlobalPath = path.join(sandboxRoot, "schema", "global");
1316
+ const trackerSandboxPmPath = path.join(sandboxRoot, "tracker", "project", ".agents", "pm");
1317
+ const trackerSandboxGlobalPath = path.join(sandboxRoot, "tracker", "global");
1318
+ const runLevelPmContextMode = parsePmContextMode(options?.pmContext);
1319
+ const progressMode = options?.progress === true ? "always" : "auto";
1320
+ const runtimeDirectives = resolveRuntimeDirectives(options?.envSet, options?.envClear, options?.sharedHostSafe);
1321
+ let sourceProjectItemCount = 0;
1322
+ let sourceGlobalItemCount = 0;
1323
+ let schemaSandboxProjectItemCount = 0;
1324
+ let schemaSandboxGlobalItemCount = 0;
1325
+ let trackerSandboxProjectItemCount = 0;
1326
+ let trackerSandboxGlobalItemCount = 0;
1327
+ const sourceRoots = options?.sourceRoots;
1328
+ const projectExtensionsSeeded = Boolean(sourceRoots);
1329
+ const globalExtensionsSeeded = Boolean(sourceRoots);
1330
+ try {
1331
+ await runInit(void 0, { path: schemaSandboxPmPath });
1332
+ await runInit(void 0, { path: schemaSandboxGlobalPath });
1333
+ await runInit(void 0, { path: trackerSandboxPmPath });
1334
+ await runInit(void 0, { path: trackerSandboxGlobalPath });
1335
+ if (sourceRoots) {
1336
+ await seedLinkedTestSandbox(schemaSandboxPmPath, schemaSandboxGlobalPath, sourceRoots);
1337
+ await seedLinkedTestSandbox(trackerSandboxPmPath, trackerSandboxGlobalPath, sourceRoots);
1338
+ await seedLinkedTestTrackerData(sourceRoots.projectPmRoot, trackerSandboxPmPath);
1339
+ await seedLinkedTestTrackerData(sourceRoots.globalPmRoot, trackerSandboxGlobalPath);
1340
+ sourceProjectItemCount = await countLinkedTestItemFiles(sourceRoots.projectPmRoot);
1341
+ sourceGlobalItemCount = await countLinkedTestItemFiles(sourceRoots.globalPmRoot);
1342
+ }
1343
+ schemaSandboxProjectItemCount = await countLinkedTestItemFiles(schemaSandboxPmPath);
1344
+ schemaSandboxGlobalItemCount = await countLinkedTestItemFiles(schemaSandboxGlobalPath);
1345
+ trackerSandboxProjectItemCount = await countLinkedTestItemFiles(trackerSandboxPmPath);
1346
+ trackerSandboxGlobalItemCount = await countLinkedTestItemFiles(trackerSandboxGlobalPath);
1347
+ const buildExecutionContext = (isPmCommand, isPmTrackerReadCommand, requestedPmContextMode, effectivePmContextMode, autoPmContextApplied) => {
1348
+ const selectedSandboxProjectPmPath = effectivePmContextMode === "tracker" ? trackerSandboxPmPath : schemaSandboxPmPath;
1349
+ const selectedSandboxGlobalPmPath = effectivePmContextMode === "tracker" ? trackerSandboxGlobalPath : schemaSandboxGlobalPath;
1350
+ const selectedSandboxProjectItemCount = effectivePmContextMode === "tracker" ? trackerSandboxProjectItemCount : schemaSandboxProjectItemCount;
1351
+ const selectedSandboxGlobalItemCount = effectivePmContextMode === "tracker" ? trackerSandboxGlobalItemCount : schemaSandboxGlobalItemCount;
1352
+ const mismatchDetected = isPmCommand && sourceProjectItemCount !== selectedSandboxProjectItemCount;
1353
+ return {
1354
+ requested_pm_context_mode: requestedPmContextMode,
1355
+ pm_context_mode: effectivePmContextMode,
1356
+ auto_pm_context_applied: autoPmContextApplied,
1357
+ is_pm_command: isPmCommand,
1358
+ is_pm_tracker_read_command: isPmTrackerReadCommand,
1359
+ source_project_pm_path: sourceRoots?.projectPmRoot ?? "",
1360
+ sandbox_project_pm_path: selectedSandboxProjectPmPath,
1361
+ source_global_pm_path: sourceRoots?.globalPmRoot ?? "",
1362
+ sandbox_global_pm_path: selectedSandboxGlobalPmPath,
1363
+ source_project_item_count: sourceProjectItemCount,
1364
+ sandbox_project_item_count: selectedSandboxProjectItemCount,
1365
+ source_global_item_count: sourceGlobalItemCount,
1366
+ sandbox_global_item_count: selectedSandboxGlobalItemCount,
1367
+ mismatch_detected: mismatchDetected,
1368
+ project_extensions_seeded: projectExtensionsSeeded,
1369
+ global_extensions_seeded: globalExtensionsSeeded
1370
+ };
1371
+ };
1372
+ for (let index = 0; index < tests.length; index += 1) {
1373
+ const linkedTest = tests[index];
1374
+ const linkedOverridePmContextMode = typeof linkedTest.pm_context_mode === "string" && linkedTest.pm_context_mode.trim().length > 0 ? parsePmContextMode(linkedTest.pm_context_mode) : void 0;
1375
+ const isPmCommand = typeof linkedTest.command === "string" && linkedTest.command.length > 0 ? commandInvokesPmCli(linkedTest.command) : false;
1376
+ const isPmTrackerReadCommand = isPmCommand && typeof linkedTest.command === "string" && linkedTest.command.length > 0 ? commandInvokesPmTrackerReadCommand(linkedTest.command) : false;
1377
+ const autoPmContextApplied = options?.autoPmContext === true && isPmTrackerReadCommand;
1378
+ const requestedPmContextMode = autoPmContextApplied ? "auto" : resolveLinkedTestRequestedContextMode(linkedTest, runLevelPmContextMode, options?.overrideLinkedPmContext === true);
1379
+ const effectivePmContextMode = resolveLinkedTestEffectiveContextMode(requestedPmContextMode, isPmTrackerReadCommand);
1380
+ const executionContext = buildExecutionContext(isPmCommand, isPmTrackerReadCommand, requestedPmContextMode, effectivePmContextMode, autoPmContextApplied);
1381
+ if (!linkedTest.command) {
1382
+ results.push({
1383
+ command: linkedTest.command,
1384
+ path: linkedTest.path,
1385
+ status: "skipped",
1386
+ execution_context: executionContext,
1387
+ error: "No command configured for this linked test."
1388
+ });
1389
+ continue;
1390
+ }
1391
+ const runtimeSafetySkipReason = getRuntimeSafetySkipReason(linkedTest.command);
1392
+ if (runtimeSafetySkipReason) {
1393
+ results.push({
1394
+ command: linkedTest.command,
1395
+ path: linkedTest.path,
1396
+ status: "skipped",
1397
+ execution_context: executionContext,
1398
+ error: runtimeSafetySkipReason
1399
+ });
1400
+ continue;
1401
+ }
1402
+ const failOnMismatchByDefault = executionContext.pm_context_mode === "schema" && executionContext.is_pm_tracker_read_command && executionContext.mismatch_detected;
1403
+ const failOnMismatchByFlag = options?.failOnContextMismatch === true && executionContext.is_pm_command && executionContext.mismatch_detected;
1404
+ if (failOnMismatchByDefault || failOnMismatchByFlag) {
1405
+ const mismatchHint = buildPmContextMismatchHint({
1406
+ executionContext,
1407
+ runLevelPmContextMode,
1408
+ linkedOverridePmContextMode
1409
+ });
1410
+ const mismatchPrefix = options?.checkContext === true ? "Linked test preflight PM context mismatch detected" : "Linked test PM context mismatch detected";
1411
+ results.push({
1412
+ command: linkedTest.command,
1413
+ path: linkedTest.path,
1414
+ status: "failed",
1415
+ exit_code: 1,
1416
+ failure_category: "assertion_failure",
1417
+ execution_context: executionContext,
1418
+ error: `${mismatchPrefix} (source_project_items=${executionContext.source_project_item_count}, sandbox_project_items=${executionContext.sandbox_project_item_count}).${mismatchHint}`
1419
+ });
1420
+ continue;
1421
+ }
1422
+ if (options?.requireAssertionsForPm === true && executionContext.is_pm_command && !hasLinkedTestAssertions(linkedTest)) {
1423
+ results.push({
1424
+ command: linkedTest.command,
1425
+ path: linkedTest.path,
1426
+ status: "failed",
1427
+ exit_code: 1,
1428
+ failure_category: "assertion_failure",
1429
+ execution_context: executionContext,
1430
+ error: "Linked PM command requires assertions when --require-assertions-for-pm is enabled."
1431
+ });
1432
+ continue;
1433
+ }
1434
+ const timeoutMs = (linkedTest.timeout_seconds ?? defaultTimeoutSeconds ?? 120) * 1e3;
1435
+ const effectiveDirectives = resolveEffectiveLinkedTestDirectives(runtimeDirectives, linkedTest);
1436
+ const executionEnv = { ...process.env };
1437
+ applyEnvDirectiveStage(executionEnv, runtimeDirectives);
1438
+ applyEnvDirectiveStage(executionEnv, {
1439
+ env_set: linkedTest.env_set ?? {},
1440
+ env_clear: linkedTest.env_clear ?? []
1441
+ });
1442
+ if (effectiveDirectives.shared_host_safe) {
1443
+ applySharedHostSafeDefaults(executionEnv);
1444
+ }
1445
+ executionEnv.FORCE_COLOR = "0";
1446
+ executionEnv.PM_PATH = executionContext.sandbox_project_pm_path;
1447
+ executionEnv.PM_GLOBAL_PATH = executionContext.sandbox_global_pm_path;
1448
+ const execution = await runLinkedTestCommand(linkedTest.command, timeoutMs, executionEnv, {
1449
+ index: index + 1,
1450
+ total: tests.length,
1451
+ timeoutMs,
1452
+ command: linkedTest.command
1453
+ }, progressMode);
1454
+ const passed = execution.exitCode === 0 && !execution.timedOut && !execution.maxBufferExceeded;
1455
+ if (passed) {
1456
+ if (options?.failOnEmptyTestRun === true) {
1457
+ const emptyRunSignal = detectEmptyLinkedTestRun(execution.stdout, execution.stderr);
1458
+ if (emptyRunSignal) {
1459
+ results.push({
1460
+ command: linkedTest.command,
1461
+ path: linkedTest.path,
1462
+ status: "failed",
1463
+ exit_code: 1,
1464
+ failure_category: "empty_run",
1465
+ execution_context: executionContext,
1466
+ stdout: execution.stdout,
1467
+ stderr: execution.stderr,
1468
+ error: `Linked test reported an empty test run (${emptyRunSignal}) while --fail-on-empty-test-run is enabled. Update test selection or disable --fail-on-empty-test-run for this run.`
1469
+ });
1470
+ continue;
1471
+ }
1472
+ }
1473
+ const assertionFailures = evaluateLinkedTestAssertions(linkedTest, execution.stdout, execution.stderr);
1474
+ if (assertionFailures.length > 0) {
1475
+ results.push({
1476
+ command: linkedTest.command,
1477
+ path: linkedTest.path,
1478
+ status: "failed",
1479
+ exit_code: 1,
1480
+ failure_category: "assertion_failure",
1481
+ execution_context: executionContext,
1482
+ stdout: execution.stdout,
1483
+ stderr: execution.stderr,
1484
+ error: `Linked test assertion(s) failed: ${assertionFailures.join("; ")}`
1485
+ });
1486
+ continue;
1487
+ }
1488
+ results.push({
1489
+ command: linkedTest.command,
1490
+ path: linkedTest.path,
1491
+ status: "passed",
1492
+ exit_code: 0,
1493
+ execution_context: executionContext,
1494
+ stdout: execution.stdout,
1495
+ stderr: execution.stderr
1496
+ });
1497
+ continue;
1498
+ }
1499
+ const failureCategory = classifyLinkedTestFailure(execution);
1500
+ results.push({
1501
+ command: linkedTest.command,
1502
+ path: linkedTest.path,
1503
+ status: "failed",
1504
+ exit_code: resolveLinkedTestFailureExitCode(execution),
1505
+ failure_category: failureCategory,
1506
+ execution_context: executionContext,
1507
+ stdout: execution.stdout,
1508
+ stderr: execution.stderr,
1509
+ error: formatLinkedTestExecutionError(execution, timeoutMs)
1510
+ });
1511
+ }
1512
+ } finally {
1513
+ await rm(sandboxRoot, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
1514
+ }
1515
+ return results;
1516
+ }
1517
+ async function runTest(id, options, global) {
1518
+ const stdinResolver = createStdinTokenResolver();
1519
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
1520
+ if (!await pathExists(getSettingsPath(pmRoot))) {
1521
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
1522
+ }
1523
+ const settings = await readSettings(pmRoot);
1524
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
1525
+ const resolvedAdds = await stdinResolver.resolveList(options.add, "--add");
1526
+ const resolvedRemoves = await stdinResolver.resolveList(options.remove, "--remove");
1527
+ const adds = parseAddEntries(resolvedAdds);
1528
+ const removes = parseRemoveEntries(resolvedRemoves);
1529
+ const shouldMutate = adds.length > 0 || removes.length > 0;
1530
+ let tests = [];
1531
+ let itemId;
1532
+ if (shouldMutate) {
1533
+ const author = resolveAuthor(options.author, settings.author_default);
1534
+ const result = await mutateItem({
1535
+ pmRoot,
1536
+ settings,
1537
+ id,
1538
+ op: "tests_add",
1539
+ author,
1540
+ message: options.message,
1541
+ force: options.force,
1542
+ mutate(document) {
1543
+ const next = [...document.metadata.tests ?? []];
1544
+ for (const add of adds) {
1545
+ const exists = next.some((entry) => entry.command === add.command && entry.path === add.path && entry.scope === add.scope && entry.pm_context_mode === add.pm_context_mode);
1546
+ if (!exists) {
1547
+ next.push(add);
1548
+ }
1549
+ }
1550
+ if (removes.length > 0) {
1551
+ for (let i = next.length - 1; i >= 0; i -= 1) {
1552
+ const entry = next[i];
1553
+ if (removes.includes(entry.path ?? "") || removes.includes(entry.command ?? "")) {
1554
+ next.splice(i, 1);
1555
+ }
1556
+ }
1557
+ }
1558
+ document.metadata.tests = next;
1559
+ return { changedFields: ["tests"] };
1560
+ }
1561
+ });
1562
+ tests = result.item.tests ?? [];
1563
+ itemId = result.item.id;
1564
+ } else {
1565
+ const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1566
+ if (!located) {
1567
+ throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);
1568
+ }
1569
+ itemId = located.id;
1570
+ const loaded = await readLocatedItem(located, { schema: settings.schema });
1571
+ tests = loaded.document.metadata.tests ?? [];
1572
+ }
1573
+ let defaultTimeoutSeconds;
1574
+ if (options.timeout !== void 0) {
1575
+ defaultTimeoutSeconds = parseOptionalNumber(options.timeout, "timeout");
1576
+ }
1577
+ const pmContextMode = parsePmContextMode(options.pmContext);
1578
+ const hasRuntimeDirectiveFlags = (options.envSet?.length ?? 0) > 0 || (options.envClear?.length ?? 0) > 0 || options.sharedHostSafe === true || options.pmContext !== void 0 || options.overrideLinkedPmContext === true || options.failOnContextMismatch === true || options.failOnSkipped === true || options.failOnEmptyTestRun === true || options.requireAssertionsForPm === true || options.checkContext === true || options.autoPmContext === true;
1579
+ if (hasRuntimeDirectiveFlags && options.run !== true) {
1580
+ throw new PmCliError("--env-set, --env-clear, --shared-host-safe, --pm-context, --override-linked-pm-context, --fail-on-context-mismatch, --fail-on-skipped, --fail-on-empty-test-run, --require-assertions-for-pm, --check-context, and --auto-pm-context require --run", EXIT_CODE.USAGE);
1581
+ }
1582
+ const runStartedAt = options.run === true ? nowIso() : void 0;
1583
+ const runResults = options.run === true ? await runLinkedTests(tests, defaultTimeoutSeconds, {
1584
+ progress: options.progress,
1585
+ envSet: options.envSet,
1586
+ envClear: options.envClear,
1587
+ sharedHostSafe: options.sharedHostSafe,
1588
+ pmContext: pmContextMode,
1589
+ overrideLinkedPmContext: options.overrideLinkedPmContext,
1590
+ failOnContextMismatch: options.failOnContextMismatch,
1591
+ failOnEmptyTestRun: options.failOnEmptyTestRun,
1592
+ requireAssertionsForPm: options.requireAssertionsForPm,
1593
+ checkContext: options.checkContext,
1594
+ autoPmContext: options.autoPmContext,
1595
+ sourceRoots: {
1596
+ projectPmRoot: pmRoot,
1597
+ globalPmRoot: resolveGlobalPmRoot(process.cwd())
1598
+ }
1599
+ }) : [];
1600
+ const failureCategories = countFailureCategories(runResults);
1601
+ const failOnSkippedTriggered = options.run === true && options.failOnSkipped === true && runResults.some((entry) => entry.status === "skipped");
1602
+ const warnings = [];
1603
+ if (options.run === true && options.checkContext === true) {
1604
+ const preflight = summarizeContextPreflight(runResults);
1605
+ warnings.push(`context_preflight:checked_pm_commands=${preflight.checked_pm_commands};tracker_read_commands=${preflight.tracker_read_commands};mismatches=${preflight.mismatches};auto_remediated=${preflight.auto_remediated}`);
1606
+ }
1607
+ if (options.run === true && runStartedAt && settings.testing.record_results_to_items === true) {
1608
+ const summary = summarizeRunResultStatuses(runResults);
1609
+ const trackedRunId = resolveTrackedRunId("test");
1610
+ const attemptRaw = process.env.PM_BACKGROUND_TEST_RUN_ATTEMPT?.trim();
1611
+ const parsedAttempt = attemptRaw ? Number.parseInt(attemptRaw, 10) : Number.NaN;
1612
+ const resumedFrom = process.env.PM_BACKGROUND_TEST_RUN_RESUMED_FROM?.trim();
1613
+ try {
1614
+ await appendTrackedTestRunSummary({
1615
+ pmRoot,
1616
+ settings,
1617
+ itemId,
1618
+ author: resolveAuthor(options.author, settings.author_default),
1619
+ message: `Track test run summary (${trackedRunId})`,
1620
+ entry: {
1621
+ run_id: trackedRunId,
1622
+ kind: "test",
1623
+ status: summary.failed > 0 || failOnSkippedTriggered === true ? "failed" : "passed",
1624
+ started_at: runStartedAt,
1625
+ finished_at: nowIso(),
1626
+ recorded_at: nowIso(),
1627
+ attempt: Number.isFinite(parsedAttempt) && parsedAttempt >= 1 ? parsedAttempt : void 0,
1628
+ resumed_from: resumedFrom && resumedFrom.length > 0 ? resumedFrom : void 0,
1629
+ passed: summary.passed,
1630
+ failed: summary.failed,
1631
+ skipped: summary.skipped,
1632
+ fail_on_skipped_triggered: failOnSkippedTriggered ? true : void 0
1633
+ }
1634
+ });
1635
+ } catch (error) {
1636
+ warnings.push(`test_result_tracking_failed:${itemId}:${error instanceof Error ? error.message : String(error)}`);
1637
+ }
1638
+ }
1639
+ return {
1640
+ ok: runResults.every((entry) => entry.status !== "failed") && failOnSkippedTriggered !== true,
1641
+ id: itemId,
1642
+ tests,
1643
+ run_results: runResults,
1644
+ failure_categories: failureCategories,
1645
+ fail_on_skipped_triggered: failOnSkippedTriggered ? true : void 0,
1646
+ warnings: warnings.length > 0 ? warnings : void 0,
1647
+ changed: shouldMutate,
1648
+ count: tests.length
1649
+ };
1650
+ }
1651
+
1652
+ export {
1653
+ appendTrackedTestRunSummary,
1654
+ summarizeContextPreflight,
1655
+ extractReferencedPmItemIdsFromCommand,
1656
+ classifyLinkedTestFailure,
1657
+ countFailureCategories,
1658
+ resolveLinkedTestFailureExitCode,
1659
+ runLinkedTests,
1660
+ runTest
1661
+ };
1662
+ //# sourceMappingURL=chunk-UOVLWB47.js.map
1663
+
1664
+ //# debugId=fb2ef78d-78c8-5583-8c98-89541410a9ff