@unbrained/pm-cli 2026.5.30 → 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 (578) hide show
  1. package/CHANGELOG.md +152 -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 +96 -10
  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 +109 -116
  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/install-sources.d.ts +2 -0
  27. package/dist/cli/commands/extension/install-sources.js +11 -4
  28. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  29. package/dist/cli/commands/extension/scaffold.js +49 -48
  30. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  31. package/dist/cli/commands/extension.js +51 -23
  32. package/dist/cli/commands/extension.js.map +1 -1
  33. package/dist/cli/commands/get.js +7 -7
  34. package/dist/cli/commands/get.js.map +1 -1
  35. package/dist/cli/commands/health.js +38 -3
  36. package/dist/cli/commands/health.js.map +1 -1
  37. package/dist/cli/commands/index.d.ts +2 -1
  38. package/dist/cli/commands/index.js +4 -3
  39. package/dist/cli/commands/index.js.map +1 -1
  40. package/dist/cli/commands/init.d.ts +10 -0
  41. package/dist/cli/commands/init.js +107 -4
  42. package/dist/cli/commands/init.js.map +1 -1
  43. package/dist/cli/commands/list.d.ts +5 -0
  44. package/dist/cli/commands/list.js +58 -26
  45. package/dist/cli/commands/list.js.map +1 -1
  46. package/dist/cli/commands/reindex.js +164 -48
  47. package/dist/cli/commands/reindex.js.map +1 -1
  48. package/dist/cli/commands/repeatable-metadata-parsers.d.ts +15 -0
  49. package/dist/cli/commands/repeatable-metadata-parsers.js +120 -0
  50. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -0
  51. package/dist/cli/commands/restore.js +25 -4
  52. package/dist/cli/commands/restore.js.map +1 -1
  53. package/dist/cli/commands/schema.d.ts +122 -1
  54. package/dist/cli/commands/schema.js +536 -6
  55. package/dist/cli/commands/schema.js.map +1 -1
  56. package/dist/cli/commands/search.d.ts +18 -0
  57. package/dist/cli/commands/search.js +56 -12
  58. package/dist/cli/commands/search.js.map +1 -1
  59. package/dist/cli/commands/test.js +4 -3
  60. package/dist/cli/commands/test.js.map +1 -1
  61. package/dist/cli/commands/update-many.js +69 -140
  62. package/dist/cli/commands/update-many.js.map +1 -1
  63. package/dist/cli/commands/update.d.ts +2 -0
  64. package/dist/cli/commands/update.js +138 -119
  65. package/dist/cli/commands/update.js.map +1 -1
  66. package/dist/cli/commands/validate.d.ts +1 -0
  67. package/dist/cli/commands/validate.js +63 -33
  68. package/dist/cli/commands/validate.js.map +1 -1
  69. package/dist/cli/error-guidance.js +26 -3
  70. package/dist/cli/error-guidance.js.map +1 -1
  71. package/dist/cli/help-content.js +82 -3
  72. package/dist/cli/help-content.js.map +1 -1
  73. package/dist/cli/main.js +377 -23
  74. package/dist/cli/main.js.map +1 -1
  75. package/dist/cli/register-list-query.js +16 -12
  76. package/dist/cli/register-list-query.js.map +1 -1
  77. package/dist/cli/register-mutation.js +217 -47
  78. package/dist/cli/register-mutation.js.map +1 -1
  79. package/dist/cli/register-operations.js +34 -25
  80. package/dist/cli/register-operations.js.map +1 -1
  81. package/dist/cli/register-setup.js +8 -8
  82. package/dist/cli/register-setup.js.map +1 -1
  83. package/dist/cli/registration-helpers.js +35 -5
  84. package/dist/cli/registration-helpers.js.map +1 -1
  85. package/dist/cli/search-refresh.d.ts +2 -0
  86. package/dist/cli/search-refresh.js +13 -0
  87. package/dist/cli/search-refresh.js.map +1 -0
  88. package/dist/cli-bundle/chunks/activity-3RWRRNOW.js +20 -0
  89. package/dist/cli-bundle/chunks/activity-3RWRRNOW.js.map +1 -0
  90. package/dist/cli-bundle/chunks/activity-P5BUMWP3.js +16 -0
  91. package/dist/cli-bundle/chunks/activity-P5BUMWP3.js.map +7 -0
  92. package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js +206 -0
  93. package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js.map +1 -0
  94. package/dist/cli-bundle/chunks/aggregate-OOAGKWRG.js +209 -0
  95. package/dist/cli-bundle/chunks/aggregate-OOAGKWRG.js.map +7 -0
  96. package/dist/cli-bundle/chunks/append-5JE3YGXU.js +72 -0
  97. package/dist/cli-bundle/chunks/append-5JE3YGXU.js.map +7 -0
  98. package/dist/cli-bundle/chunks/append-PNN6UIBZ.js +69 -0
  99. package/dist/cli-bundle/chunks/append-PNN6UIBZ.js.map +1 -0
  100. package/dist/cli-bundle/chunks/chunk-26KTVXJW.js +218 -0
  101. package/dist/cli-bundle/chunks/chunk-26KTVXJW.js.map +1 -0
  102. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
  103. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
  104. package/dist/cli-bundle/chunks/chunk-3OH4DAEB.js +761 -0
  105. package/dist/cli-bundle/chunks/chunk-3OH4DAEB.js.map +7 -0
  106. package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js +5553 -0
  107. package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js.map +1 -0
  108. package/dist/cli-bundle/chunks/chunk-4PJQSECJ.js +634 -0
  109. package/dist/cli-bundle/chunks/chunk-4PJQSECJ.js.map +7 -0
  110. package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js +1832 -0
  111. package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-5IRA6IYD.js +1891 -0
  113. package/dist/cli-bundle/chunks/chunk-5IRA6IYD.js.map +7 -0
  114. package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js +412 -0
  115. package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js.map +1 -0
  116. package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js +182 -0
  117. package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js.map +1 -0
  118. package/dist/cli-bundle/chunks/chunk-7K24QB23.js +698 -0
  119. package/dist/cli-bundle/chunks/chunk-7K24QB23.js.map +1 -0
  120. package/dist/cli-bundle/chunks/chunk-A6PEXMYN.js +380 -0
  121. package/dist/cli-bundle/chunks/chunk-A6PEXMYN.js.map +1 -0
  122. package/dist/cli-bundle/chunks/chunk-ASQM3IF5.js +230 -0
  123. package/dist/cli-bundle/chunks/chunk-ASQM3IF5.js.map +1 -0
  124. package/dist/cli-bundle/chunks/chunk-ATBVS6WW.js +185 -0
  125. package/dist/cli-bundle/chunks/chunk-ATBVS6WW.js.map +7 -0
  126. package/dist/cli-bundle/chunks/chunk-AXXKLVTW.js +332 -0
  127. package/dist/cli-bundle/chunks/chunk-AXXKLVTW.js.map +1 -0
  128. package/dist/cli-bundle/chunks/chunk-B3N4TKNL.js +1681 -0
  129. package/dist/cli-bundle/chunks/chunk-B3N4TKNL.js.map +7 -0
  130. package/dist/cli-bundle/chunks/{chunk-PB2YU2E3.js → chunk-BNL6S7QH.js} +28 -70
  131. package/dist/cli-bundle/chunks/chunk-BNL6S7QH.js.map +7 -0
  132. package/dist/cli-bundle/chunks/chunk-CCUFLH4J.js +154 -0
  133. package/dist/cli-bundle/chunks/chunk-CCUFLH4J.js.map +1 -0
  134. package/dist/cli-bundle/chunks/chunk-CJDQB2ED.js +341 -0
  135. package/dist/cli-bundle/chunks/chunk-CJDQB2ED.js.map +7 -0
  136. package/dist/cli-bundle/chunks/chunk-CWT53EYT.js +1340 -0
  137. package/dist/cli-bundle/chunks/chunk-CWT53EYT.js.map +1 -0
  138. package/dist/cli-bundle/chunks/chunk-D3WUNETC.js +349 -0
  139. package/dist/cli-bundle/chunks/chunk-D3WUNETC.js.map +7 -0
  140. package/dist/cli-bundle/chunks/chunk-D5X7N6FI.js +1714 -0
  141. package/dist/cli-bundle/chunks/chunk-D5X7N6FI.js.map +7 -0
  142. package/dist/cli-bundle/chunks/chunk-DFIZGAI5.js +550 -0
  143. package/dist/cli-bundle/chunks/chunk-DFIZGAI5.js.map +7 -0
  144. package/dist/cli-bundle/chunks/chunk-DFUSXJDE.js +1704 -0
  145. package/dist/cli-bundle/chunks/chunk-DFUSXJDE.js.map +1 -0
  146. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
  147. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
  148. package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js +2988 -0
  149. package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js.map +1 -0
  150. package/dist/cli-bundle/chunks/chunk-FVXM3GKS.js +128 -0
  151. package/dist/cli-bundle/chunks/chunk-FVXM3GKS.js.map +1 -0
  152. package/dist/cli-bundle/chunks/chunk-G5BACLYH.js +454 -0
  153. package/dist/cli-bundle/chunks/chunk-G5BACLYH.js.map +1 -0
  154. package/dist/cli-bundle/chunks/chunk-GCAVRLGE.js +383 -0
  155. package/dist/cli-bundle/chunks/chunk-GCAVRLGE.js.map +7 -0
  156. package/dist/cli-bundle/chunks/chunk-GFWHHMVV.js +57 -0
  157. package/dist/cli-bundle/chunks/chunk-GFWHHMVV.js.map +1 -0
  158. package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js +3860 -0
  159. package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js.map +1 -0
  160. package/dist/cli-bundle/chunks/chunk-GPGAYASV.js +346 -0
  161. package/dist/cli-bundle/chunks/chunk-GPGAYASV.js.map +1 -0
  162. package/dist/cli-bundle/chunks/chunk-HPH6X4ZZ.js +1356 -0
  163. package/dist/cli-bundle/chunks/chunk-HPH6X4ZZ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/chunk-HZOS2UG5.js +342 -0
  165. package/dist/cli-bundle/chunks/chunk-HZOS2UG5.js.map +7 -0
  166. package/dist/cli-bundle/chunks/chunk-IUV734HF.js +17 -0
  167. package/dist/cli-bundle/chunks/chunk-IUV734HF.js.map +1 -0
  168. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js +15 -0
  169. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js.map +1 -0
  170. package/dist/cli-bundle/chunks/chunk-JB4RGL4V.js +185 -0
  171. package/dist/cli-bundle/chunks/chunk-JB4RGL4V.js.map +7 -0
  172. package/dist/cli-bundle/chunks/chunk-JQI2HE55.js +130 -0
  173. package/dist/cli-bundle/chunks/chunk-JQI2HE55.js.map +1 -0
  174. package/dist/cli-bundle/chunks/chunk-K47WAYQV.js +60 -0
  175. package/dist/cli-bundle/chunks/chunk-K47WAYQV.js.map +7 -0
  176. package/dist/cli-bundle/chunks/chunk-KA24HME7.js +79 -0
  177. package/dist/cli-bundle/chunks/chunk-KA24HME7.js.map +7 -0
  178. package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js +1325 -0
  179. package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js.map +1 -0
  180. package/dist/cli-bundle/chunks/chunk-KCMIYKTA.js +242 -0
  181. package/dist/cli-bundle/chunks/chunk-KCMIYKTA.js.map +1 -0
  182. package/dist/cli-bundle/chunks/chunk-KK6YPGH3.js +221 -0
  183. package/dist/cli-bundle/chunks/chunk-KK6YPGH3.js.map +7 -0
  184. package/dist/cli-bundle/chunks/chunk-LDJK7SHN.js +157 -0
  185. package/dist/cli-bundle/chunks/chunk-LDJK7SHN.js.map +7 -0
  186. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js +24 -0
  187. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js.map +1 -0
  188. package/dist/cli-bundle/chunks/chunk-MISYRLEP.js +80 -0
  189. package/dist/cli-bundle/chunks/chunk-MISYRLEP.js.map +1 -0
  190. package/dist/cli-bundle/chunks/chunk-N5YF3VFN.js +457 -0
  191. package/dist/cli-bundle/chunks/chunk-N5YF3VFN.js.map +7 -0
  192. package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js +173 -0
  193. package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js.map +1 -0
  194. package/dist/cli-bundle/chunks/chunk-O5IBJE6S.js +338 -0
  195. package/dist/cli-bundle/chunks/chunk-O5IBJE6S.js.map +1 -0
  196. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
  197. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
  198. package/dist/cli-bundle/chunks/chunk-OIQIXTNB.js +3040 -0
  199. package/dist/cli-bundle/chunks/chunk-OIQIXTNB.js.map +7 -0
  200. package/dist/cli-bundle/chunks/chunk-ORTLYVA4.js +751 -0
  201. package/dist/cli-bundle/chunks/chunk-ORTLYVA4.js.map +1 -0
  202. package/dist/cli-bundle/chunks/chunk-OUF3ARDX.js +1861 -0
  203. package/dist/cli-bundle/chunks/chunk-OUF3ARDX.js.map +7 -0
  204. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
  205. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
  206. package/dist/cli-bundle/chunks/chunk-RANZIID5.js +176 -0
  207. package/dist/cli-bundle/chunks/chunk-RANZIID5.js.map +7 -0
  208. package/dist/cli-bundle/chunks/chunk-RQAWLSUU.js +140 -0
  209. package/dist/cli-bundle/chunks/chunk-RQAWLSUU.js.map +7 -0
  210. package/dist/cli-bundle/chunks/chunk-S3CV7JGJ.js +233 -0
  211. package/dist/cli-bundle/chunks/chunk-S3CV7JGJ.js.map +7 -0
  212. package/dist/cli-bundle/chunks/chunk-SRVKTWPR.js +5705 -0
  213. package/dist/cli-bundle/chunks/chunk-SRVKTWPR.js.map +7 -0
  214. package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js +76 -0
  215. package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js.map +1 -0
  216. package/dist/cli-bundle/chunks/chunk-SZQCER6S.js +631 -0
  217. package/dist/cli-bundle/chunks/chunk-SZQCER6S.js.map +1 -0
  218. package/dist/cli-bundle/chunks/chunk-T2ORWB6D.js +540 -0
  219. package/dist/cli-bundle/chunks/chunk-T2ORWB6D.js.map +1 -0
  220. package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js +422 -0
  221. package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js.map +7 -0
  222. package/dist/cli-bundle/chunks/{chunk-RJONRNXN.js → chunk-TK633IVD.js} +51 -32
  223. package/dist/cli-bundle/chunks/chunk-TK633IVD.js.map +7 -0
  224. package/dist/cli-bundle/chunks/chunk-TQ3ZK6VD.js +131 -0
  225. package/dist/cli-bundle/chunks/chunk-TQ3ZK6VD.js.map +7 -0
  226. package/dist/cli-bundle/chunks/chunk-UFCG3SWR.js +119 -0
  227. package/dist/cli-bundle/chunks/chunk-UFCG3SWR.js.map +1 -0
  228. package/dist/cli-bundle/chunks/chunk-UOVLWB47.js +1664 -0
  229. package/dist/cli-bundle/chunks/chunk-UOVLWB47.js.map +1 -0
  230. package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js +186 -0
  231. package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js.map +1 -0
  232. package/dist/cli-bundle/chunks/chunk-VGO2T3TY.js +182 -0
  233. package/dist/cli-bundle/chunks/chunk-VGO2T3TY.js.map +1 -0
  234. package/dist/cli-bundle/chunks/chunk-WIKR7KFL.js +189 -0
  235. package/dist/cli-bundle/chunks/chunk-WIKR7KFL.js.map +7 -0
  236. package/dist/cli-bundle/chunks/chunk-XG7RJYHV.js +1385 -0
  237. package/dist/cli-bundle/chunks/chunk-XG7RJYHV.js.map +7 -0
  238. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js +53 -0
  239. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js.map +1 -0
  240. package/dist/cli-bundle/chunks/chunk-XX5LRINW.js +90 -0
  241. package/dist/cli-bundle/chunks/chunk-XX5LRINW.js.map +7 -0
  242. package/dist/cli-bundle/chunks/chunk-Y2AKE2HS.js +252 -0
  243. package/dist/cli-bundle/chunks/chunk-Y2AKE2HS.js.map +7 -0
  244. package/dist/cli-bundle/chunks/chunk-ZQ4F6EC4.js +3898 -0
  245. package/dist/cli-bundle/chunks/chunk-ZQ4F6EC4.js.map +7 -0
  246. package/dist/cli-bundle/chunks/chunk-ZRVSMOMR.js +1809 -0
  247. package/dist/cli-bundle/chunks/chunk-ZRVSMOMR.js.map +1 -0
  248. package/dist/cli-bundle/chunks/claim-AZLP7YFO.js +132 -0
  249. package/dist/cli-bundle/chunks/claim-AZLP7YFO.js.map +7 -0
  250. package/dist/cli-bundle/chunks/claim-ZFA7HKU4.js +129 -0
  251. package/dist/cli-bundle/chunks/claim-ZFA7HKU4.js.map +1 -0
  252. package/dist/cli-bundle/chunks/close-65DFYAVS.js +17 -0
  253. package/dist/cli-bundle/chunks/close-65DFYAVS.js.map +1 -0
  254. package/dist/cli-bundle/chunks/close-RMHQ3KWH.js +13 -0
  255. package/dist/cli-bundle/chunks/close-RMHQ3KWH.js.map +7 -0
  256. package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js +311 -0
  257. package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js.map +1 -0
  258. package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js +314 -0
  259. package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js.map +7 -0
  260. package/dist/cli-bundle/chunks/comments-AGBNSJJH.js +103 -0
  261. package/dist/cli-bundle/chunks/comments-AGBNSJJH.js.map +7 -0
  262. package/dist/cli-bundle/chunks/comments-CJWXQI7X.js +100 -0
  263. package/dist/cli-bundle/chunks/comments-CJWXQI7X.js.map +1 -0
  264. package/dist/cli-bundle/chunks/config-5ON3ADRH.js +1688 -0
  265. package/dist/cli-bundle/chunks/config-5ON3ADRH.js.map +7 -0
  266. package/dist/cli-bundle/chunks/config-DDPYIA6J.js +1671 -0
  267. package/dist/cli-bundle/chunks/config-DDPYIA6J.js.map +1 -0
  268. package/dist/cli-bundle/chunks/context-E6U3DWVM.js +1471 -0
  269. package/dist/cli-bundle/chunks/context-E6U3DWVM.js.map +7 -0
  270. package/dist/cli-bundle/chunks/context-ZOJEN5VT.js +1461 -0
  271. package/dist/cli-bundle/chunks/context-ZOJEN5VT.js.map +1 -0
  272. package/dist/cli-bundle/chunks/contracts-CXSFM45B.js +1277 -0
  273. package/dist/cli-bundle/chunks/contracts-CXSFM45B.js.map +7 -0
  274. package/dist/cli-bundle/chunks/contracts-LCSX5R53.js +1274 -0
  275. package/dist/cli-bundle/chunks/contracts-LCSX5R53.js.map +1 -0
  276. package/dist/cli-bundle/chunks/create-ATONSAZW.js +27 -0
  277. package/dist/cli-bundle/chunks/create-ATONSAZW.js.map +7 -0
  278. package/dist/cli-bundle/chunks/create-WYFKN2U4.js +31 -0
  279. package/dist/cli-bundle/chunks/create-WYFKN2U4.js.map +1 -0
  280. package/dist/cli-bundle/chunks/delete-RONNH4F4.js +58 -0
  281. package/dist/cli-bundle/chunks/delete-RONNH4F4.js.map +7 -0
  282. package/dist/cli-bundle/chunks/delete-ZXWC56WO.js +55 -0
  283. package/dist/cli-bundle/chunks/delete-ZXWC56WO.js.map +1 -0
  284. package/dist/cli-bundle/chunks/deps-EHXIFOZR.js +225 -0
  285. package/dist/cli-bundle/chunks/deps-EHXIFOZR.js.map +1 -0
  286. package/dist/cli-bundle/chunks/deps-WII3O4HB.js +228 -0
  287. package/dist/cli-bundle/chunks/deps-WII3O4HB.js.map +7 -0
  288. package/dist/cli-bundle/chunks/docs-JMVCFNHH.js +34 -0
  289. package/dist/cli-bundle/chunks/docs-JMVCFNHH.js.map +7 -0
  290. package/dist/cli-bundle/chunks/docs-PDREIMLS.js +31 -0
  291. package/dist/cli-bundle/chunks/docs-PDREIMLS.js.map +1 -0
  292. package/dist/cli-bundle/chunks/extension-B4ROVWJD.js +28 -0
  293. package/dist/cli-bundle/chunks/extension-B4ROVWJD.js.map +1 -0
  294. package/dist/cli-bundle/chunks/extension-G6UXSM5S.js +24 -0
  295. package/dist/cli-bundle/chunks/extension-G6UXSM5S.js.map +7 -0
  296. package/dist/cli-bundle/chunks/files-2PN7UM2D.js +282 -0
  297. package/dist/cli-bundle/chunks/files-2PN7UM2D.js.map +1 -0
  298. package/dist/cli-bundle/chunks/files-MXYS5W4M.js +285 -0
  299. package/dist/cli-bundle/chunks/files-MXYS5W4M.js.map +7 -0
  300. package/dist/cli-bundle/chunks/gc-GT552UJH.js +178 -0
  301. package/dist/cli-bundle/chunks/gc-GT552UJH.js.map +1 -0
  302. package/dist/cli-bundle/chunks/gc-QNBRJG6H.js +181 -0
  303. package/dist/cli-bundle/chunks/gc-QNBRJG6H.js.map +7 -0
  304. package/dist/cli-bundle/chunks/get-CINFEUIY.js +197 -0
  305. package/dist/cli-bundle/chunks/get-CINFEUIY.js.map +7 -0
  306. package/dist/cli-bundle/chunks/get-WXMLRG7M.js +194 -0
  307. package/dist/cli-bundle/chunks/get-WXMLRG7M.js.map +1 -0
  308. package/dist/cli-bundle/chunks/health-5VPOJQ53.js +1258 -0
  309. package/dist/cli-bundle/chunks/health-5VPOJQ53.js.map +1 -0
  310. package/dist/cli-bundle/chunks/health-IT5DBPRJ.js +1261 -0
  311. package/dist/cli-bundle/chunks/health-IT5DBPRJ.js.map +7 -0
  312. package/dist/cli-bundle/chunks/history-6FC4H6HI.js +20 -0
  313. package/dist/cli-bundle/chunks/history-6FC4H6HI.js.map +7 -0
  314. package/dist/cli-bundle/chunks/history-FLZIP7PM.js +24 -0
  315. package/dist/cli-bundle/chunks/history-FLZIP7PM.js.map +1 -0
  316. package/dist/cli-bundle/chunks/history-redact-SSZBAD76.js +23 -0
  317. package/dist/cli-bundle/chunks/history-redact-SSZBAD76.js.map +1 -0
  318. package/dist/cli-bundle/chunks/history-redact-XKYEZDBL.js +19 -0
  319. package/dist/cli-bundle/chunks/history-redact-XKYEZDBL.js.map +7 -0
  320. package/dist/cli-bundle/chunks/history-repair-KC5ZOJRZ.js +196 -0
  321. package/dist/cli-bundle/chunks/history-repair-KC5ZOJRZ.js.map +7 -0
  322. package/dist/cli-bundle/chunks/history-repair-X7CO5JJZ.js +193 -0
  323. package/dist/cli-bundle/chunks/history-repair-X7CO5JJZ.js.map +1 -0
  324. package/dist/cli-bundle/chunks/init-6MRFVOLH.js +20 -0
  325. package/dist/cli-bundle/chunks/init-6MRFVOLH.js.map +1 -0
  326. package/dist/cli-bundle/chunks/init-KHX3FEEM.js +16 -0
  327. package/dist/cli-bundle/chunks/init-KHX3FEEM.js.map +7 -0
  328. package/dist/cli-bundle/chunks/learnings-A3CLB5CO.js +47 -0
  329. package/dist/cli-bundle/chunks/learnings-A3CLB5CO.js.map +7 -0
  330. package/dist/cli-bundle/chunks/learnings-DCX55BNX.js +44 -0
  331. package/dist/cli-bundle/chunks/learnings-DCX55BNX.js.map +1 -0
  332. package/dist/cli-bundle/chunks/list-53LZ2AEO.js +20 -0
  333. package/dist/cli-bundle/chunks/list-53LZ2AEO.js.map +7 -0
  334. package/dist/cli-bundle/chunks/list-DBRECOG4.js +24 -0
  335. package/dist/cli-bundle/chunks/list-DBRECOG4.js.map +1 -0
  336. package/dist/cli-bundle/chunks/notes-42LIC3UE.js +47 -0
  337. package/dist/cli-bundle/chunks/notes-42LIC3UE.js.map +7 -0
  338. package/dist/cli-bundle/chunks/notes-P5O3VMQ3.js +44 -0
  339. package/dist/cli-bundle/chunks/notes-P5O3VMQ3.js.map +1 -0
  340. package/dist/cli-bundle/chunks/plan-HDQXEUKD.js +1174 -0
  341. package/dist/cli-bundle/chunks/plan-HDQXEUKD.js.map +7 -0
  342. package/dist/cli-bundle/chunks/plan-IGTE3WOJ.js +1171 -0
  343. package/dist/cli-bundle/chunks/plan-IGTE3WOJ.js.map +1 -0
  344. package/dist/cli-bundle/chunks/{register-list-query-EIVQ5FMR.js → register-list-query-AG3XKXWL.js} +25 -18
  345. package/dist/cli-bundle/chunks/register-list-query-AG3XKXWL.js.map +7 -0
  346. package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js +227 -0
  347. package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js.map +1 -0
  348. package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js +813 -0
  349. package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js.map +1 -0
  350. package/dist/cli-bundle/chunks/{register-mutation-RSZNPSGI.js → register-mutation-RSMT6DPK.js} +160 -39
  351. package/dist/cli-bundle/chunks/register-mutation-RSMT6DPK.js.map +7 -0
  352. package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js +370 -0
  353. package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js.map +1 -0
  354. package/dist/cli-bundle/chunks/{register-operations-APUSYDMR.js → register-operations-Q54JQZUN.js} +50 -32
  355. package/dist/cli-bundle/chunks/register-operations-Q54JQZUN.js.map +7 -0
  356. package/dist/cli-bundle/chunks/register-setup-DI6P7X75.js +242 -0
  357. package/dist/cli-bundle/chunks/register-setup-DI6P7X75.js.map +1 -0
  358. package/dist/cli-bundle/chunks/{register-setup-OZOKSMPJ.js → register-setup-YJKIQRKA.js} +21 -13
  359. package/dist/cli-bundle/chunks/register-setup-YJKIQRKA.js.map +7 -0
  360. package/dist/cli-bundle/chunks/restore-2XVTBLKQ.js +21 -0
  361. package/dist/cli-bundle/chunks/restore-2XVTBLKQ.js.map +1 -0
  362. package/dist/cli-bundle/chunks/restore-JL5QIH7H.js +17 -0
  363. package/dist/cli-bundle/chunks/restore-JL5QIH7H.js.map +7 -0
  364. package/dist/cli-bundle/chunks/schema-LVXZWFGY.js +770 -0
  365. package/dist/cli-bundle/chunks/schema-LVXZWFGY.js.map +1 -0
  366. package/dist/cli-bundle/chunks/schema-V6BX65Q2.js +780 -0
  367. package/dist/cli-bundle/chunks/schema-V6BX65Q2.js.map +7 -0
  368. package/dist/cli-bundle/chunks/search-5A3BMFA7.js +1144 -0
  369. package/dist/cli-bundle/chunks/search-5A3BMFA7.js.map +7 -0
  370. package/dist/cli-bundle/chunks/search-C7NPB7G7.js +1127 -0
  371. package/dist/cli-bundle/chunks/search-C7NPB7G7.js.map +1 -0
  372. package/dist/cli-bundle/chunks/stats-FNLYVXTB.js +120 -0
  373. package/dist/cli-bundle/chunks/stats-FNLYVXTB.js.map +1 -0
  374. package/dist/cli-bundle/chunks/stats-Y2CBTZSL.js +123 -0
  375. package/dist/cli-bundle/chunks/stats-Y2CBTZSL.js.map +7 -0
  376. package/dist/cli-bundle/chunks/test-OFYONO3C.js +35 -0
  377. package/dist/cli-bundle/chunks/test-OFYONO3C.js.map +1 -0
  378. package/dist/cli-bundle/chunks/test-RJ4ZF35X.js +31 -0
  379. package/dist/cli-bundle/chunks/test-RJ4ZF35X.js.map +7 -0
  380. package/dist/cli-bundle/chunks/test-all-EEMKNTGU.js +331 -0
  381. package/dist/cli-bundle/chunks/test-all-EEMKNTGU.js.map +7 -0
  382. package/dist/cli-bundle/chunks/test-all-OJE6CIO7.js +328 -0
  383. package/dist/cli-bundle/chunks/test-all-OJE6CIO7.js.map +1 -0
  384. package/dist/cli-bundle/chunks/test-runs-IPOPFOAF.js +929 -0
  385. package/dist/cli-bundle/chunks/test-runs-IPOPFOAF.js.map +1 -0
  386. package/dist/cli-bundle/chunks/test-runs-L2M7WKH7.js +939 -0
  387. package/dist/cli-bundle/chunks/test-runs-L2M7WKH7.js.map +7 -0
  388. package/dist/cli-bundle/chunks/update-6YEHPVXH.js +25 -0
  389. package/dist/cli-bundle/chunks/update-6YEHPVXH.js.map +1 -0
  390. package/dist/cli-bundle/chunks/update-PYLVHMRD.js +21 -0
  391. package/dist/cli-bundle/chunks/update-PYLVHMRD.js.map +7 -0
  392. package/dist/cli-bundle/chunks/update-many-322CCH2L.js +608 -0
  393. package/dist/cli-bundle/chunks/update-many-322CCH2L.js.map +7 -0
  394. package/dist/cli-bundle/chunks/update-many-DYWGW57M.js +605 -0
  395. package/dist/cli-bundle/chunks/update-many-DYWGW57M.js.map +1 -0
  396. package/dist/cli-bundle/chunks/upgrade-2U727SAM.js +269 -0
  397. package/dist/cli-bundle/chunks/upgrade-2U727SAM.js.map +7 -0
  398. package/dist/cli-bundle/chunks/upgrade-3W3RVSNM.js +266 -0
  399. package/dist/cli-bundle/chunks/upgrade-3W3RVSNM.js.map +1 -0
  400. package/dist/cli-bundle/chunks/validate-GZ24NYHO.js +1120 -0
  401. package/dist/cli-bundle/chunks/validate-GZ24NYHO.js.map +1 -0
  402. package/dist/cli-bundle/chunks/validate-ZFVWPEEN.js +1123 -0
  403. package/dist/cli-bundle/chunks/validate-ZFVWPEEN.js.map +7 -0
  404. package/dist/cli-bundle/main.js +615 -121
  405. package/dist/cli-bundle/main.js.map +4 -4
  406. package/dist/core/checkpoint/mutation-checkpoint.d.ts +44 -0
  407. package/dist/core/checkpoint/mutation-checkpoint.js +119 -0
  408. package/dist/core/checkpoint/mutation-checkpoint.js.map +1 -0
  409. package/dist/core/config/positional-value.js +4 -2
  410. package/dist/core/config/positional-value.js.map +1 -1
  411. package/dist/core/diagnostics/remediation.d.ts +73 -0
  412. package/dist/core/diagnostics/remediation.js +328 -0
  413. package/dist/core/diagnostics/remediation.js.map +1 -0
  414. package/dist/core/extensions/extension-hook-runtime.js +9 -2
  415. package/dist/core/extensions/extension-hook-runtime.js.map +1 -1
  416. package/dist/core/extensions/extension-types.d.ts +60 -4
  417. package/dist/core/extensions/extension-types.js +2 -2
  418. package/dist/core/extensions/extension-types.js.map +1 -1
  419. package/dist/core/extensions/index.d.ts +5 -1
  420. package/dist/core/extensions/index.js +61 -2
  421. package/dist/core/extensions/index.js.map +1 -1
  422. package/dist/core/extensions/item-fields.d.ts +5 -1
  423. package/dist/core/extensions/item-fields.js +126 -4
  424. package/dist/core/extensions/item-fields.js.map +1 -1
  425. package/dist/core/extensions/loader.js +283 -8
  426. package/dist/core/extensions/loader.js.map +1 -1
  427. package/dist/core/item/item-format.d.ts +3 -2
  428. package/dist/core/item/item-format.js +15 -10
  429. package/dist/core/item/item-format.js.map +1 -1
  430. package/dist/core/item/item-type-definition.js +6 -2
  431. package/dist/core/item/item-type-definition.js.map +1 -1
  432. package/dist/core/item/status-filter.d.ts +29 -0
  433. package/dist/core/item/status-filter.js +97 -0
  434. package/dist/core/item/status-filter.js.map +1 -0
  435. package/dist/core/item/type-registry.d.ts +4 -0
  436. package/dist/core/item/type-registry.js +12 -2
  437. package/dist/core/item/type-registry.js.map +1 -1
  438. package/dist/core/output/output.js +17 -5
  439. package/dist/core/output/output.js.map +1 -1
  440. package/dist/core/schema/item-types-file.d.ts +15 -0
  441. package/dist/core/schema/item-types-file.js +27 -2
  442. package/dist/core/schema/item-types-file.js.map +1 -1
  443. package/dist/core/schema/runtime-field-filters.js +4 -3
  444. package/dist/core/schema/runtime-field-filters.js.map +1 -1
  445. package/dist/core/schema/runtime-field-values.d.ts +1 -1
  446. package/dist/core/schema/runtime-field-values.js +10 -4
  447. package/dist/core/schema/runtime-field-values.js.map +1 -1
  448. package/dist/core/schema/runtime-schema.js +75 -2
  449. package/dist/core/schema/runtime-schema.js.map +1 -1
  450. package/dist/core/schema/status-defs-file.d.ts +113 -0
  451. package/dist/core/schema/status-defs-file.js +260 -0
  452. package/dist/core/schema/status-defs-file.js.map +1 -0
  453. package/dist/core/schema/type-workflows.d.ts +64 -0
  454. package/dist/core/schema/type-workflows.js +98 -0
  455. package/dist/core/schema/type-workflows.js.map +1 -0
  456. package/dist/core/search/background-refresh.d.ts +53 -0
  457. package/dist/core/search/background-refresh.js +286 -0
  458. package/dist/core/search/background-refresh.js.map +1 -0
  459. package/dist/core/search/cache.d.ts +23 -2
  460. package/dist/core/search/cache.js +135 -30
  461. package/dist/core/search/cache.js.map +1 -1
  462. package/dist/core/search/http-client.d.ts +2 -2
  463. package/dist/core/search/http-client.js +2 -2
  464. package/dist/core/search/http-client.js.map +1 -1
  465. package/dist/core/search/vector-stores.d.ts +1 -0
  466. package/dist/core/search/vector-stores.js +69 -15
  467. package/dist/core/search/vector-stores.js.map +1 -1
  468. package/dist/core/search/vectorization-metadata.d.ts +13 -0
  469. package/dist/core/search/vectorization-metadata.js +65 -0
  470. package/dist/core/search/vectorization-metadata.js.map +1 -0
  471. package/dist/core/shared/constants.d.ts +2 -2
  472. package/dist/core/shared/constants.js +2 -3
  473. package/dist/core/shared/constants.js.map +1 -1
  474. package/dist/core/shared/serialization.d.ts +1 -0
  475. package/dist/core/shared/serialization.js +86 -2
  476. package/dist/core/shared/serialization.js.map +1 -1
  477. package/dist/core/store/front-matter-cache.js +14 -5
  478. package/dist/core/store/front-matter-cache.js.map +1 -1
  479. package/dist/core/store/item-format-migration.js +25 -15
  480. package/dist/core/store/item-format-migration.js.map +1 -1
  481. package/dist/core/store/item-store.d.ts +2 -0
  482. package/dist/core/store/item-store.js +61 -6
  483. package/dist/core/store/item-store.js.map +1 -1
  484. package/dist/core/store/settings-validator.js +22 -2
  485. package/dist/core/store/settings-validator.js.map +1 -1
  486. package/dist/core/store/settings.js +40 -5
  487. package/dist/core/store/settings.js.map +1 -1
  488. package/dist/core/telemetry/consent.js +3 -3
  489. package/dist/core/telemetry/consent.js.map +1 -1
  490. package/dist/core/telemetry/observability.js +4 -3
  491. package/dist/core/telemetry/observability.js.map +1 -1
  492. package/dist/core/telemetry/runtime.d.ts +10 -0
  493. package/dist/core/telemetry/runtime.js +86 -2
  494. package/dist/core/telemetry/runtime.js.map +1 -1
  495. package/dist/mcp/server.js +221 -12
  496. package/dist/mcp/server.js.map +1 -1
  497. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -2
  498. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  499. package/dist/sdk/cli-contracts/commander-types.js +7 -2
  500. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  501. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  502. package/dist/sdk/cli-contracts/enum-contracts.js +4 -2
  503. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  504. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -0
  505. package/dist/sdk/cli-contracts/tool-option-contracts.js +53 -3
  506. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  507. package/dist/sdk/cli-contracts/tool-parameter-tables.js +37 -8
  508. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  509. package/dist/sdk/cli-contracts.d.ts +19 -1
  510. package/dist/sdk/cli-contracts.js +211 -18
  511. package/dist/sdk/cli-contracts.js.map +1 -1
  512. package/dist/sdk/errors.d.ts +22 -0
  513. package/dist/sdk/errors.js +46 -0
  514. package/dist/sdk/errors.js.map +1 -0
  515. package/dist/sdk/index.d.ts +2 -1
  516. package/dist/sdk/index.js +3 -2
  517. package/dist/sdk/index.js.map +1 -1
  518. package/dist/sdk/package-import-adapters.js +14 -3
  519. package/dist/sdk/package-import-adapters.js.map +1 -1
  520. package/dist/sdk/runtime.d.ts +1 -0
  521. package/dist/sdk/runtime.js +3 -2
  522. package/dist/sdk/runtime.js.map +1 -1
  523. package/dist/sdk/testing.d.ts +77 -0
  524. package/dist/sdk/testing.js +239 -0
  525. package/dist/sdk/testing.js.map +1 -0
  526. package/dist/types.d.ts +26 -1
  527. package/dist/types.js +3 -2
  528. package/dist/types.js.map +1 -1
  529. package/docs/AGENT_GUIDE.md +21 -2
  530. package/docs/COMMANDS.md +85 -5
  531. package/docs/CONFIGURATION.md +49 -2
  532. package/docs/EXTENSIONS.md +118 -6
  533. package/docs/QUICKSTART.md +2 -0
  534. package/docs/RELEASING.md +3 -3
  535. package/docs/SDK.md +273 -1
  536. package/docs/TESTING.md +17 -0
  537. package/docs/examples/policy-restricted-extension/manifest.json +1 -0
  538. package/docs/examples/starter-extension/index.js +9 -1
  539. package/docs/examples/starter-extension/manifest.json +1 -0
  540. package/package.json +12 -7
  541. package/packages/pm-beads/extensions/beads/index.js +2 -4
  542. package/packages/pm-beads/extensions/beads/index.ts +43 -33
  543. package/packages/pm-beads/extensions/beads/manifest.json +12 -1
  544. package/packages/pm-calendar/README.md +6 -0
  545. package/packages/pm-calendar/extensions/calendar/index.js +6 -1
  546. package/packages/pm-calendar/extensions/calendar/index.ts +6 -1
  547. package/packages/pm-calendar/extensions/calendar/manifest.json +6 -1
  548. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +6 -1
  549. package/packages/pm-guide-shell/README.md +4 -0
  550. package/packages/pm-guide-shell/extensions/guide-shell/index.js +22 -0
  551. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +22 -0
  552. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +6 -1
  553. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +74 -3
  554. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +84 -4
  555. package/packages/pm-lifecycle-hooks/README.md +29 -0
  556. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +18 -0
  557. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +20 -0
  558. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +9 -0
  559. package/packages/pm-lifecycle-hooks/package.json +52 -0
  560. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +13 -1
  561. package/packages/pm-search-advanced/extensions/search-advanced/index.js +69 -1
  562. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +91 -2
  563. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +13 -1
  564. package/packages/pm-templates/extensions/templates/manifest.json +6 -1
  565. package/packages/pm-todos/extensions/todos/index.js +3 -7
  566. package/packages/pm-todos/extensions/todos/index.ts +55 -42
  567. package/packages/pm-todos/extensions/todos/manifest.json +13 -1
  568. package/scripts/bundle-cli.mjs +121 -17
  569. package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js.map +0 -7
  570. package/dist/cli-bundle/chunks/chunk-RJONRNXN.js.map +0 -7
  571. package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js +0 -13864
  572. package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js.map +0 -7
  573. package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js +0 -24225
  574. package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js.map +0 -7
  575. package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js.map +0 -7
  576. package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js.map +0 -7
  577. package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js.map +0 -7
  578. package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js.map +0 -7
@@ -0,0 +1,939 @@
1
+ import {
2
+ parseLimit
3
+ } from "./chunk-K47WAYQV.js";
4
+ import "./chunk-4PJQSECJ.js";
5
+ import {
6
+ nowIso
7
+ } from "./chunk-RANZIID5.js";
8
+ import {
9
+ EXIT_CODE,
10
+ PmCliError,
11
+ ensureDir,
12
+ getSettingsPath,
13
+ getTestRunRecordPath,
14
+ getTestRunResultPath,
15
+ getTestRunStderrPath,
16
+ getTestRunStdoutPath,
17
+ getTestRunsPath,
18
+ getTestRunsRecordsPath,
19
+ getTestRunsResultsPath,
20
+ getTestRunsStderrPath,
21
+ getTestRunsStdoutPath,
22
+ pathExists,
23
+ readFileIfExists,
24
+ readSettings,
25
+ resolveGlobalPmRoot,
26
+ resolvePmRoot,
27
+ writeFileAtomic
28
+ } from "./chunk-SRVKTWPR.js";
29
+
30
+ // dist/cli/commands/test-runs.js
31
+ import os from "node:os";
32
+
33
+ // dist/core/test/background-runs.js
34
+ import fs from "node:fs/promises";
35
+ import { spawn } from "node:child_process";
36
+ import { createHash, randomBytes } from "node:crypto";
37
+ import path from "node:path";
38
+ !(function() {
39
+ try {
40
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
41
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "2ba2ffd6-1f2e-5ee4-8534-9ac9e3ba2c77");
42
+ } catch (e2) {
43
+ }
44
+ })();
45
+ var BACKGROUND_RUN_ACTIVE_STATUSES = /* @__PURE__ */ new Set(["queued", "running"]);
46
+ var BACKGROUND_RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["passed", "failed", "stopped", "canceled"]);
47
+ var DEFAULT_BACKGROUND_RUN_RESOURCE_SNAPSHOT_INTERVAL_MS = 3e3;
48
+ var DEFAULT_BACKGROUND_RUN_FORCE_KILL_DELAY_MS = 3e3;
49
+ var DEFAULT_BACKGROUND_RUN_HEARTBEAT_STALE_MS = 3e4;
50
+ var DEFAULT_BACKGROUND_RUN_LOG_TAIL_LINES = 100;
51
+ var PROC_STAT_TICKS_PER_SECOND = 100;
52
+ function nowMs() {
53
+ return Date.now();
54
+ }
55
+ function normalizeCommandArgs(args) {
56
+ return args.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
57
+ }
58
+ function summarizeCommandLabel(args) {
59
+ const joined = args.join(" ").replaceAll(/\s+/g, " ").trim();
60
+ if (joined.length <= 180) {
61
+ return joined;
62
+ }
63
+ return `${joined.slice(0, 177)}...`;
64
+ }
65
+ function buildRunId() {
66
+ const timePart = Date.now().toString(36);
67
+ const randomPart = randomBytes(3).toString("hex");
68
+ return `tr-${timePart}-${randomPart}`;
69
+ }
70
+ function buildBackgroundTestRunFingerprint(kind, commandArgs, pmRoot) {
71
+ const payload = {
72
+ kind,
73
+ command: normalizeCommandArgs(commandArgs),
74
+ pm_root: path.resolve(pmRoot)
75
+ };
76
+ return createHash("sha256").update(JSON.stringify(payload)).digest("hex");
77
+ }
78
+ function isPidRunning(pid) {
79
+ if (!Number.isInteger(pid) || !pid || pid <= 0) {
80
+ return false;
81
+ }
82
+ try {
83
+ process.kill(pid, 0);
84
+ return true;
85
+ } catch (error) {
86
+ const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
87
+ return code === "EPERM";
88
+ }
89
+ }
90
+ async function ensureBackgroundRunStorage(pmRoot) {
91
+ await ensureDir(getTestRunsPath(pmRoot));
92
+ await ensureDir(getTestRunsRecordsPath(pmRoot));
93
+ await ensureDir(getTestRunsStdoutPath(pmRoot));
94
+ await ensureDir(getTestRunsStderrPath(pmRoot));
95
+ await ensureDir(getTestRunsResultsPath(pmRoot));
96
+ }
97
+ async function parseBackgroundRunRecord(raw, recordPath) {
98
+ try {
99
+ const parsed = JSON.parse(raw);
100
+ if (!parsed || typeof parsed !== "object" || typeof parsed.id !== "string") {
101
+ throw new Error("invalid run record payload");
102
+ }
103
+ return parsed;
104
+ } catch (error) {
105
+ throw new PmCliError(`Failed to parse background test run record at ${recordPath}: ${error instanceof Error ? error.message : String(error)}`, EXIT_CODE.GENERIC_FAILURE);
106
+ }
107
+ }
108
+ async function writeBackgroundRunRecord(pmRoot, record) {
109
+ const next = {
110
+ ...record,
111
+ updated_at: nowIso()
112
+ };
113
+ await writeFileAtomic(getTestRunRecordPath(pmRoot, record.id), `${JSON.stringify(next, null, 2)}
114
+ `);
115
+ }
116
+ async function readBackgroundTestRunRecord(pmRoot, runId) {
117
+ const recordPath = getTestRunRecordPath(pmRoot, runId);
118
+ const raw = await readFileIfExists(recordPath);
119
+ if (!raw) {
120
+ return null;
121
+ }
122
+ return parseBackgroundRunRecord(raw, recordPath);
123
+ }
124
+ async function listBackgroundRunRecordPaths(pmRoot) {
125
+ const recordsRoot = getTestRunsRecordsPath(pmRoot);
126
+ if (!await pathExists(recordsRoot)) {
127
+ return [];
128
+ }
129
+ const entries = await fs.readdir(recordsRoot, { withFileTypes: true });
130
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path.join(recordsRoot, entry.name)).sort((left, right) => right.localeCompare(left));
131
+ }
132
+ async function readLinuxRssBytes(pid) {
133
+ if (process.platform !== "linux") {
134
+ return void 0;
135
+ }
136
+ try {
137
+ const raw = await fs.readFile(`/proc/${pid}/status`, "utf8");
138
+ const match = raw.match(/^VmRSS:\s+(\d+)\s+kB$/m);
139
+ if (!match) {
140
+ return void 0;
141
+ }
142
+ const value = Number.parseInt(match[1] ?? "", 10);
143
+ if (!Number.isFinite(value)) {
144
+ return void 0;
145
+ }
146
+ return value * 1024;
147
+ } catch {
148
+ return void 0;
149
+ }
150
+ }
151
+ async function readLinuxCpuSeconds(pid) {
152
+ if (process.platform !== "linux") {
153
+ return {};
154
+ }
155
+ try {
156
+ const raw = await fs.readFile(`/proc/${pid}/stat`, "utf8");
157
+ const closeParenIndex = raw.lastIndexOf(")");
158
+ if (closeParenIndex < 0) {
159
+ return {};
160
+ }
161
+ const remainder = raw.slice(closeParenIndex + 2).trim();
162
+ const parts = remainder.split(/\s+/);
163
+ const utimeTicks = Number.parseInt(parts[11] ?? "", 10);
164
+ const stimeTicks = Number.parseInt(parts[12] ?? "", 10);
165
+ if (!Number.isFinite(utimeTicks) || !Number.isFinite(stimeTicks)) {
166
+ return {};
167
+ }
168
+ return {
169
+ cpu_user_seconds: utimeTicks / PROC_STAT_TICKS_PER_SECOND,
170
+ cpu_system_seconds: stimeTicks / PROC_STAT_TICKS_PER_SECOND
171
+ };
172
+ } catch {
173
+ return {};
174
+ }
175
+ }
176
+ async function buildResourceSnapshot(record) {
177
+ const pid = record.child_pid ?? record.worker_pid;
178
+ if (!isPidRunning(pid)) {
179
+ return void 0;
180
+ }
181
+ const rssBytes = await readLinuxRssBytes(pid);
182
+ const cpu = await readLinuxCpuSeconds(pid);
183
+ const startedAtMs = record.started_at ? Date.parse(record.started_at) : Number.NaN;
184
+ const uptimeSeconds = Number.isFinite(startedAtMs) ? Math.max(0, (nowMs() - startedAtMs) / 1e3) : void 0;
185
+ return {
186
+ recorded_at: nowIso(),
187
+ rss_bytes: rssBytes,
188
+ cpu_user_seconds: cpu.cpu_user_seconds,
189
+ cpu_system_seconds: cpu.cpu_system_seconds,
190
+ uptime_seconds: uptimeSeconds
191
+ };
192
+ }
193
+ function readCount(value) {
194
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
195
+ }
196
+ function evaluateWorkerResult(kind, payload) {
197
+ if (!payload || typeof payload !== "object") {
198
+ return {
199
+ summary: {
200
+ passed: 0,
201
+ failed: 1,
202
+ skipped: 0
203
+ },
204
+ parsedResult: null
205
+ };
206
+ }
207
+ const record = payload;
208
+ if (kind === "test-all") {
209
+ const totals = record.totals ?? {};
210
+ return {
211
+ summary: {
212
+ items: typeof totals.items === "number" ? totals.items : void 0,
213
+ linked_tests: typeof totals.linked_tests === "number" ? totals.linked_tests : void 0,
214
+ passed: readCount(totals.passed),
215
+ failed: readCount(totals.failed),
216
+ skipped: readCount(totals.skipped),
217
+ fail_on_skipped_triggered: record.fail_on_skipped_triggered === true ? true : void 0
218
+ },
219
+ parsedResult: payload
220
+ };
221
+ }
222
+ const runResults = Array.isArray(record.run_results) ? record.run_results : [];
223
+ let passed = 0;
224
+ let failed = 0;
225
+ let skipped = 0;
226
+ for (const entry of runResults) {
227
+ if (!entry || typeof entry !== "object") {
228
+ continue;
229
+ }
230
+ const status = entry.status;
231
+ if (status === "passed") {
232
+ passed += 1;
233
+ continue;
234
+ }
235
+ if (status === "failed") {
236
+ failed += 1;
237
+ continue;
238
+ }
239
+ skipped += 1;
240
+ }
241
+ return {
242
+ summary: {
243
+ passed,
244
+ failed,
245
+ skipped,
246
+ fail_on_skipped_triggered: record.fail_on_skipped_triggered === true ? true : void 0
247
+ },
248
+ parsedResult: payload
249
+ };
250
+ }
251
+ function parseProgressLine(stderrLine) {
252
+ const line = stderrLine.trim();
253
+ if (line.length === 0) {
254
+ return null;
255
+ }
256
+ const match = line.match(/\[pm test\]\s+linked-test\s+(\d+)\/(\d+)\s+(start|running|end)(?:.*elapsed_ms=(\d+))?/i);
257
+ if (!match) {
258
+ return null;
259
+ }
260
+ const index = Number.parseInt(match[1] ?? "", 10);
261
+ const total = Number.parseInt(match[2] ?? "", 10);
262
+ const elapsed = match[4] ? Number.parseInt(match[4], 10) : void 0;
263
+ return {
264
+ linked_test_index: Number.isFinite(index) ? index : void 0,
265
+ linked_test_total: Number.isFinite(total) ? total : void 0,
266
+ elapsed_ms: Number.isFinite(elapsed) ? elapsed : void 0,
267
+ heartbeat_at: nowIso(),
268
+ phase: match[3]?.toLowerCase() === "end" ? "finished" : "running"
269
+ };
270
+ }
271
+ function splitLines(value) {
272
+ return value.split(/\r?\n/).map((entry) => entry.trimEnd()).filter((entry) => entry.length > 0);
273
+ }
274
+ function tailLines(value, limit) {
275
+ if (limit <= 0) {
276
+ return [];
277
+ }
278
+ const lines = splitLines(value);
279
+ if (lines.length <= limit) {
280
+ return lines;
281
+ }
282
+ return lines.slice(lines.length - limit);
283
+ }
284
+ async function resolveBackgroundCliEntry(cwd) {
285
+ const configured = process.env.PM_BACKGROUND_CLI_ENTRY?.trim();
286
+ if (configured && configured.length > 0) {
287
+ const resolvedConfigured = path.resolve(cwd, configured);
288
+ if (await pathExists(resolvedConfigured)) {
289
+ return resolvedConfigured;
290
+ }
291
+ }
292
+ const distEntry = path.resolve(cwd, "dist", "cli.js");
293
+ if (await pathExists(distEntry)) {
294
+ return distEntry;
295
+ }
296
+ const argvEntry = process.argv[1]?.trim();
297
+ if (argvEntry && argvEntry.length > 0) {
298
+ const resolvedArgvEntry = path.resolve(cwd, argvEntry);
299
+ if (await pathExists(resolvedArgvEntry)) {
300
+ return resolvedArgvEntry;
301
+ }
302
+ }
303
+ throw new PmCliError("Unable to resolve a CLI entrypoint for background test runs. Build the project or set PM_BACKGROUND_CLI_ENTRY.", EXIT_CODE.GENERIC_FAILURE);
304
+ }
305
+ async function refreshRunIfStale(pmRoot, record) {
306
+ if (!BACKGROUND_RUN_ACTIVE_STATUSES.has(record.status)) {
307
+ return record;
308
+ }
309
+ const workerAlive = isPidRunning(record.worker_pid);
310
+ if (workerAlive) {
311
+ return record;
312
+ }
313
+ if (record.finished_at) {
314
+ return record;
315
+ }
316
+ const next = {
317
+ ...record,
318
+ status: "failed",
319
+ finished_at: nowIso(),
320
+ error: record.error ?? "Background test run worker exited before writing terminal status."
321
+ };
322
+ await writeBackgroundRunRecord(pmRoot, next);
323
+ return next;
324
+ }
325
+ async function startBackgroundTestRun(options) {
326
+ await ensureBackgroundRunStorage(options.pmRoot);
327
+ const normalizedArgs = normalizeCommandArgs(options.commandArgs);
328
+ if (normalizedArgs.length === 0) {
329
+ throw new PmCliError("Background test run requires command arguments.", EXIT_CODE.USAGE);
330
+ }
331
+ const fingerprint = buildBackgroundTestRunFingerprint(options.kind, normalizedArgs, options.pmRoot);
332
+ const existingRuns = await listBackgroundTestRuns(options.pmRoot, {});
333
+ for (const existing of existingRuns) {
334
+ const refreshed = await refreshRunIfStale(options.pmRoot, existing);
335
+ if (refreshed.fingerprint !== fingerprint) {
336
+ continue;
337
+ }
338
+ if (!BACKGROUND_RUN_ACTIVE_STATUSES.has(refreshed.status)) {
339
+ continue;
340
+ }
341
+ if (!isPidRunning(refreshed.worker_pid)) {
342
+ continue;
343
+ }
344
+ return {
345
+ started: false,
346
+ run: {
347
+ ...refreshed,
348
+ duplicate_of: refreshed.id
349
+ },
350
+ duplicate_of: refreshed.id
351
+ };
352
+ }
353
+ const runId = buildRunId();
354
+ const createdAt = nowIso();
355
+ const stdoutPath = getTestRunStdoutPath(options.pmRoot, runId);
356
+ const stderrPath = getTestRunStderrPath(options.pmRoot, runId);
357
+ const resultPath = getTestRunResultPath(options.pmRoot, runId);
358
+ await fs.writeFile(stdoutPath, "", "utf8");
359
+ await fs.writeFile(stderrPath, "", "utf8");
360
+ const record = {
361
+ id: runId,
362
+ kind: options.kind,
363
+ status: "queued",
364
+ created_at: createdAt,
365
+ updated_at: createdAt,
366
+ requested_by: options.requestedBy,
367
+ fingerprint,
368
+ command_args: normalizedArgs,
369
+ command_label: summarizeCommandLabel(normalizedArgs),
370
+ pm_root: options.pmRoot,
371
+ global_pm_root: options.globalPmRoot,
372
+ target_id: options.targetId,
373
+ status_filter: options.statusFilter,
374
+ attempt: typeof options.attempt === "number" && Number.isFinite(options.attempt) && options.attempt >= 1 ? Math.floor(options.attempt) : 1,
375
+ resumed_from: options.resumedFrom,
376
+ resumed_by: options.resumedBy,
377
+ stdout_path: stdoutPath,
378
+ stderr_path: stderrPath,
379
+ result_path: resultPath,
380
+ progress: {
381
+ phase: "queued",
382
+ message: "Queued for background execution.",
383
+ heartbeat_at: createdAt
384
+ }
385
+ };
386
+ await writeBackgroundRunRecord(options.pmRoot, record);
387
+ return {
388
+ started: true,
389
+ run: record
390
+ };
391
+ }
392
+ async function spawnBackgroundTestRunWorker(options) {
393
+ const record = await readBackgroundTestRunRecord(options.pmRoot, options.runId);
394
+ if (!record) {
395
+ throw new PmCliError(`Background test run ${options.runId} not found`, EXIT_CODE.NOT_FOUND);
396
+ }
397
+ if (BACKGROUND_RUN_TERMINAL_STATUSES.has(record.status)) {
398
+ throw new PmCliError(`Background test run ${record.id} is already terminal (${record.status}).`, EXIT_CODE.CONFLICT);
399
+ }
400
+ const cliEntry = await resolveBackgroundCliEntry(process.cwd());
401
+ const args = [];
402
+ if (options.noExtensions === true) {
403
+ args.push("--no-extensions");
404
+ }
405
+ args.push("--path", record.pm_root, "test-runs-worker", record.id);
406
+ const env = {
407
+ ...process.env,
408
+ PM_PATH: record.pm_root,
409
+ PM_GLOBAL_PATH: record.global_pm_root,
410
+ PM_BACKGROUND_TEST_RUN_ID: record.id,
411
+ PM_BACKGROUND_TEST_RUN_ATTEMPT: String(record.attempt),
412
+ PM_BACKGROUND_TEST_RUN_RESUMED_FROM: record.resumed_from ?? "",
413
+ FORCE_COLOR: "0"
414
+ };
415
+ const child = spawn(process.execPath, [cliEntry, ...args], {
416
+ cwd: process.cwd(),
417
+ env,
418
+ detached: true,
419
+ stdio: "ignore",
420
+ windowsHide: true
421
+ });
422
+ child.unref();
423
+ const next = {
424
+ ...record,
425
+ status: "queued",
426
+ worker_pid: child.pid && child.pid > 0 ? child.pid : record.worker_pid,
427
+ progress: {
428
+ phase: "queued",
429
+ message: "Worker process started.",
430
+ heartbeat_at: nowIso()
431
+ }
432
+ };
433
+ await writeBackgroundRunRecord(options.pmRoot, next);
434
+ return next;
435
+ }
436
+ async function appendFileOrdered(queue, filePath, text) {
437
+ await queue;
438
+ await fs.appendFile(filePath, text, "utf8");
439
+ }
440
+ async function runBackgroundTestRunWorker(pmRoot, runId, noExtensions = false) {
441
+ const loaded = await readBackgroundTestRunRecord(pmRoot, runId);
442
+ if (!loaded) {
443
+ throw new PmCliError(`Background test run ${runId} not found`, EXIT_CODE.NOT_FOUND);
444
+ }
445
+ const record = {
446
+ ...loaded,
447
+ status: "running",
448
+ started_at: loaded.started_at ?? nowIso(),
449
+ worker_pid: process.pid,
450
+ progress: {
451
+ phase: "running",
452
+ message: "Worker started.",
453
+ heartbeat_at: nowIso()
454
+ }
455
+ };
456
+ const cliEntry = await resolveBackgroundCliEntry(process.cwd());
457
+ const env = {
458
+ ...process.env,
459
+ PM_PATH: record.pm_root,
460
+ PM_GLOBAL_PATH: record.global_pm_root,
461
+ FORCE_COLOR: "0"
462
+ };
463
+ await writeBackgroundRunRecord(pmRoot, record);
464
+ const childArgs = noExtensions ? ["--no-extensions", ...record.command_args] : [...record.command_args];
465
+ const child = spawn(process.execPath, [cliEntry, ...childArgs], {
466
+ cwd: process.cwd(),
467
+ env,
468
+ detached: false,
469
+ stdio: ["ignore", "pipe", "pipe"],
470
+ windowsHide: true
471
+ });
472
+ record.child_pid = child.pid && child.pid > 0 ? child.pid : void 0;
473
+ let writeQueue = Promise.resolve();
474
+ const scheduleRecordWrite = () => {
475
+ writeQueue = writeQueue.then(async () => {
476
+ await writeBackgroundRunRecord(pmRoot, record);
477
+ }).catch(() => {
478
+ });
479
+ };
480
+ let stdoutWriteQueue = Promise.resolve();
481
+ let stderrWriteQueue = Promise.resolve();
482
+ let stdoutBuffer = "";
483
+ let stopRequested = false;
484
+ const requestStop = async () => {
485
+ if (stopRequested) {
486
+ return;
487
+ }
488
+ stopRequested = true;
489
+ record.stop_requested_at = nowIso();
490
+ record.progress = {
491
+ ...record.progress,
492
+ phase: "stopping",
493
+ message: "Stop requested for background run.",
494
+ heartbeat_at: nowIso()
495
+ };
496
+ scheduleRecordWrite();
497
+ if (!child.pid || child.pid <= 0) {
498
+ return;
499
+ }
500
+ try {
501
+ child.kill("SIGTERM");
502
+ } catch {
503
+ }
504
+ const forceKillDelayMs = Number.parseInt(process.env.PM_BACKGROUND_RUN_FORCE_KILL_DELAY_MS ?? "", 10);
505
+ const delay = Number.isFinite(forceKillDelayMs) && forceKillDelayMs > 0 ? forceKillDelayMs : DEFAULT_BACKGROUND_RUN_FORCE_KILL_DELAY_MS;
506
+ const forceTimer = setTimeout(() => {
507
+ try {
508
+ child.kill("SIGKILL");
509
+ } catch {
510
+ }
511
+ }, delay);
512
+ forceTimer.unref?.();
513
+ };
514
+ const onSignal = () => {
515
+ void requestStop();
516
+ };
517
+ process.on("SIGTERM", onSignal);
518
+ process.on("SIGINT", onSignal);
519
+ const resourceIntervalMs = Number.parseInt(process.env.PM_BACKGROUND_RUN_RESOURCE_INTERVAL_MS ?? "", 10);
520
+ const resourceInterval = Number.isFinite(resourceIntervalMs) && resourceIntervalMs > 0 ? resourceIntervalMs : DEFAULT_BACKGROUND_RUN_RESOURCE_SNAPSHOT_INTERVAL_MS;
521
+ const resourceTimer = setInterval(() => {
522
+ void (async () => {
523
+ record.resource = await buildResourceSnapshot(record);
524
+ if (record.progress) {
525
+ record.progress.heartbeat_at = nowIso();
526
+ }
527
+ scheduleRecordWrite();
528
+ })();
529
+ }, resourceInterval);
530
+ resourceTimer.unref?.();
531
+ child.stdout?.on("data", (chunk) => {
532
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
533
+ stdoutBuffer += text;
534
+ stdoutWriteQueue = appendFileOrdered(stdoutWriteQueue, record.stdout_path, text);
535
+ });
536
+ child.stderr?.on("data", (chunk) => {
537
+ const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
538
+ stderrWriteQueue = appendFileOrdered(stderrWriteQueue, record.stderr_path, text);
539
+ const lines = splitLines(text);
540
+ const latestLine = lines.at(-1);
541
+ if (latestLine) {
542
+ const progressPatch = parseProgressLine(latestLine);
543
+ record.progress = {
544
+ phase: record.progress?.phase ?? "running",
545
+ message: latestLine,
546
+ heartbeat_at: nowIso(),
547
+ linked_test_index: progressPatch?.linked_test_index ?? record.progress?.linked_test_index,
548
+ linked_test_total: progressPatch?.linked_test_total ?? record.progress?.linked_test_total,
549
+ elapsed_ms: progressPatch?.elapsed_ms ?? record.progress?.elapsed_ms
550
+ };
551
+ if (progressPatch?.phase === "finished" && !stopRequested) {
552
+ record.progress.phase = "running";
553
+ }
554
+ scheduleRecordWrite();
555
+ }
556
+ });
557
+ let exitCode = null;
558
+ let signal = null;
559
+ try {
560
+ ({ code: exitCode, signal } = await new Promise((resolve) => {
561
+ child.on("close", (code, closeSignal) => {
562
+ resolve({ code, signal: closeSignal });
563
+ });
564
+ }));
565
+ } finally {
566
+ clearInterval(resourceTimer);
567
+ process.off("SIGTERM", onSignal);
568
+ process.off("SIGINT", onSignal);
569
+ }
570
+ await stdoutWriteQueue;
571
+ await stderrWriteQueue;
572
+ let parsedResult = null;
573
+ if (stdoutBuffer.trim().length > 0) {
574
+ try {
575
+ parsedResult = JSON.parse(stdoutBuffer);
576
+ } catch {
577
+ parsedResult = null;
578
+ }
579
+ }
580
+ const evaluated = evaluateWorkerResult(record.kind, parsedResult);
581
+ record.summary = evaluated.summary;
582
+ record.exit_code = typeof exitCode === "number" ? exitCode : void 0;
583
+ record.signal = signal ?? void 0;
584
+ record.finished_at = nowIso();
585
+ record.status = stopRequested ? "stopped" : record.exit_code === 0 && (record.summary.failed ?? 0) === 0 && record.summary.fail_on_skipped_triggered !== true ? "passed" : "failed";
586
+ record.progress = {
587
+ phase: "finished",
588
+ message: stopRequested ? "Background run stopped." : `Background run finished with status=${record.status}.`,
589
+ heartbeat_at: nowIso(),
590
+ linked_test_index: record.progress?.linked_test_index,
591
+ linked_test_total: record.progress?.linked_test_total,
592
+ elapsed_ms: record.progress?.elapsed_ms
593
+ };
594
+ record.resource = await buildResourceSnapshot(record);
595
+ if (parsedResult !== null) {
596
+ await writeFileAtomic(record.result_path, `${JSON.stringify(parsedResult, null, 2)}
597
+ `);
598
+ } else {
599
+ await writeFileAtomic(record.result_path, `${JSON.stringify({
600
+ parse_error: "Background run output was not valid JSON.",
601
+ stdout_excerpt: tailLines(stdoutBuffer, DEFAULT_BACKGROUND_RUN_LOG_TAIL_LINES)
602
+ }, null, 2)}
603
+ `);
604
+ }
605
+ await writeBackgroundRunRecord(pmRoot, record);
606
+ await writeQueue;
607
+ return record;
608
+ }
609
+ async function listBackgroundTestRuns(pmRoot, options) {
610
+ const recordPaths = await listBackgroundRunRecordPaths(pmRoot);
611
+ const runs = [];
612
+ for (const recordPath of recordPaths) {
613
+ const raw = await readFileIfExists(recordPath);
614
+ if (!raw) {
615
+ continue;
616
+ }
617
+ const parsed = await parseBackgroundRunRecord(raw, recordPath);
618
+ runs.push(parsed);
619
+ }
620
+ const refreshed = [];
621
+ for (const run of runs) {
622
+ refreshed.push(await refreshRunIfStale(pmRoot, run));
623
+ }
624
+ const filtered = options.status ? refreshed.filter((entry) => entry.status === options.status) : refreshed;
625
+ const sorted = filtered.sort((left, right) => {
626
+ const byUpdated = Date.parse(right.updated_at) - Date.parse(left.updated_at);
627
+ if (Number.isFinite(byUpdated) && byUpdated !== 0) {
628
+ return byUpdated;
629
+ }
630
+ return right.id.localeCompare(left.id);
631
+ });
632
+ const limit = typeof options.limit === "number" && options.limit >= 0 ? options.limit : void 0;
633
+ return limit === void 0 ? sorted : sorted.slice(0, limit);
634
+ }
635
+ async function getBackgroundTestRunStatus(pmRoot, runId) {
636
+ const loaded = await readBackgroundTestRunRecord(pmRoot, runId);
637
+ if (!loaded) {
638
+ throw new PmCliError(`Background test run ${runId} not found`, EXIT_CODE.NOT_FOUND);
639
+ }
640
+ const refreshed = await refreshRunIfStale(pmRoot, loaded);
641
+ const workerAlive = isPidRunning(refreshed.worker_pid);
642
+ const childAlive = isPidRunning(refreshed.child_pid);
643
+ if (refreshed.status === "running" && !childAlive && !refreshed.finished_at && !workerAlive) {
644
+ refreshed.status = "failed";
645
+ refreshed.finished_at = nowIso();
646
+ refreshed.error = refreshed.error ?? "Background run process exited unexpectedly.";
647
+ await writeBackgroundRunRecord(pmRoot, refreshed);
648
+ }
649
+ if (refreshed.status === "running") {
650
+ refreshed.resource = await buildResourceSnapshot(refreshed);
651
+ await writeBackgroundRunRecord(pmRoot, refreshed);
652
+ }
653
+ const heartbeatAt = refreshed.progress?.heartbeat_at;
654
+ const heartbeatAtMs = heartbeatAt ? Date.parse(heartbeatAt) : Number.NaN;
655
+ const lagMs = Number.isFinite(heartbeatAtMs) ? Math.max(0, nowMs() - heartbeatAtMs) : void 0;
656
+ const staleMs = Number.parseInt(process.env.PM_BACKGROUND_RUN_HEARTBEAT_STALE_MS ?? "", 10);
657
+ const staleThresholdMs = Number.isFinite(staleMs) && staleMs > 0 ? staleMs : DEFAULT_BACKGROUND_RUN_HEARTBEAT_STALE_MS;
658
+ const healthState = refreshed.status === "running" ? lagMs !== void 0 && lagMs > staleThresholdMs ? "stale" : "healthy" : "inactive";
659
+ return {
660
+ run: refreshed,
661
+ health: {
662
+ state: healthState,
663
+ last_heartbeat_at: heartbeatAt,
664
+ heartbeat_lag_ms: lagMs,
665
+ worker_alive: workerAlive,
666
+ child_alive: childAlive
667
+ }
668
+ };
669
+ }
670
+ async function stopBackgroundTestRun(pmRoot, runId, force = false) {
671
+ const loaded = await readBackgroundTestRunRecord(pmRoot, runId);
672
+ if (!loaded) {
673
+ throw new PmCliError(`Background test run ${runId} not found`, EXIT_CODE.NOT_FOUND);
674
+ }
675
+ const refreshed = await refreshRunIfStale(pmRoot, loaded);
676
+ if (BACKGROUND_RUN_TERMINAL_STATUSES.has(refreshed.status)) {
677
+ return {
678
+ run: refreshed,
679
+ signal_sent: "none"
680
+ };
681
+ }
682
+ let signalSent = "none";
683
+ const signal = force ? "SIGKILL" : "SIGTERM";
684
+ if (isPidRunning(refreshed.worker_pid) && refreshed.worker_pid) {
685
+ try {
686
+ process.kill(refreshed.worker_pid, signal);
687
+ signalSent = signal;
688
+ } catch {
689
+ signalSent = "none";
690
+ }
691
+ }
692
+ if (signalSent === "none") {
693
+ refreshed.status = "stopped";
694
+ refreshed.finished_at = refreshed.finished_at ?? nowIso();
695
+ }
696
+ refreshed.stop_requested_at = nowIso();
697
+ refreshed.progress = {
698
+ phase: "stopping",
699
+ message: signalSent === "none" ? "Run marked stopped." : `Stop requested via ${signalSent}.`,
700
+ heartbeat_at: nowIso(),
701
+ linked_test_index: refreshed.progress?.linked_test_index,
702
+ linked_test_total: refreshed.progress?.linked_test_total,
703
+ elapsed_ms: refreshed.progress?.elapsed_ms
704
+ };
705
+ await writeBackgroundRunRecord(pmRoot, refreshed);
706
+ return {
707
+ run: refreshed,
708
+ signal_sent: signalSent
709
+ };
710
+ }
711
+ async function resumeBackgroundTestRun(pmRoot, runId, requestedBy, noExtensions = false) {
712
+ const loaded = await readBackgroundTestRunRecord(pmRoot, runId);
713
+ if (!loaded) {
714
+ throw new PmCliError(`Background test run ${runId} not found`, EXIT_CODE.NOT_FOUND);
715
+ }
716
+ const refreshed = await refreshRunIfStale(pmRoot, loaded);
717
+ if (!BACKGROUND_RUN_TERMINAL_STATUSES.has(refreshed.status)) {
718
+ throw new PmCliError(`Background test run ${runId} is not terminal and cannot be resumed.`, EXIT_CODE.CONFLICT);
719
+ }
720
+ const started = await startBackgroundTestRun({
721
+ pmRoot: refreshed.pm_root,
722
+ globalPmRoot: refreshed.global_pm_root,
723
+ kind: refreshed.kind,
724
+ commandArgs: refreshed.command_args,
725
+ requestedBy,
726
+ targetId: refreshed.target_id,
727
+ statusFilter: refreshed.status_filter,
728
+ resumedFrom: refreshed.id,
729
+ resumedBy: requestedBy,
730
+ attempt: refreshed.attempt + 1
731
+ });
732
+ if (!started.started) {
733
+ return started.run;
734
+ }
735
+ const spawned = await spawnBackgroundTestRunWorker({
736
+ pmRoot,
737
+ runId: started.run.id,
738
+ noExtensions
739
+ });
740
+ const prior = {
741
+ ...refreshed,
742
+ resumed_by: spawned.id
743
+ };
744
+ await writeBackgroundRunRecord(pmRoot, prior);
745
+ return spawned;
746
+ }
747
+ async function readBackgroundTestRunLogs(pmRoot, runId, stream, tail) {
748
+ const loaded = await readBackgroundTestRunRecord(pmRoot, runId);
749
+ if (!loaded) {
750
+ throw new PmCliError(`Background test run ${runId} not found`, EXIT_CODE.NOT_FOUND);
751
+ }
752
+ const resolvedTail = typeof tail === "number" && Number.isFinite(tail) && tail >= 0 ? Math.floor(tail) : DEFAULT_BACKGROUND_RUN_LOG_TAIL_LINES;
753
+ const stdoutRaw = stream === "stdout" || stream === "both" ? await readFileIfExists(loaded.stdout_path) ?? "" : "";
754
+ const stderrRaw = stream === "stderr" || stream === "both" ? await readFileIfExists(loaded.stderr_path) ?? "" : "";
755
+ return {
756
+ run: loaded,
757
+ stream,
758
+ tail: resolvedTail,
759
+ stdout: stream === "stdout" || stream === "both" ? tailLines(stdoutRaw, resolvedTail) : [],
760
+ stderr: stream === "stderr" || stream === "both" ? tailLines(stderrRaw, resolvedTail) : []
761
+ };
762
+ }
763
+
764
+ // dist/cli/commands/test-runs.js
765
+ !(function() {
766
+ try {
767
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
768
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b7bca497-23bd-5560-be7d-948b4e73bde5");
769
+ } catch (e2) {
770
+ }
771
+ })();
772
+ var BACKGROUND_STATUS_VALUES = ["queued", "running", "passed", "failed", "stopped", "canceled"];
773
+ var BACKGROUND_STREAM_VALUES = ["stdout", "stderr", "both"];
774
+ function normalizeStatus(value) {
775
+ if (value === void 0) {
776
+ return void 0;
777
+ }
778
+ const normalized = value.trim().toLowerCase();
779
+ if (BACKGROUND_STATUS_VALUES.includes(normalized)) {
780
+ return normalized;
781
+ }
782
+ throw new PmCliError(`Invalid --status value "${value}"`, EXIT_CODE.USAGE);
783
+ }
784
+ function normalizeStream(value) {
785
+ if (value === void 0 || value.trim().length === 0) {
786
+ return "stderr";
787
+ }
788
+ const normalized = value.trim().toLowerCase();
789
+ if (BACKGROUND_STREAM_VALUES.includes(normalized)) {
790
+ return normalized;
791
+ }
792
+ throw new PmCliError(`Invalid --stream value "${value}"`, EXIT_CODE.USAGE);
793
+ }
794
+ function resolveWhoamiFallback() {
795
+ try {
796
+ const username = os.userInfo().username.trim();
797
+ if (username.length > 0) {
798
+ return username;
799
+ }
800
+ } catch {
801
+ }
802
+ return void 0;
803
+ }
804
+ function resolveRequestedBy(author, fallback) {
805
+ const candidates = [
806
+ author,
807
+ process.env.PM_AUTHOR,
808
+ fallback,
809
+ process.env.USER,
810
+ process.env.LOGNAME,
811
+ process.env.USERNAME,
812
+ resolveWhoamiFallback()
813
+ ];
814
+ for (const candidate of candidates) {
815
+ if (typeof candidate !== "string") {
816
+ continue;
817
+ }
818
+ const trimmed = candidate.trim();
819
+ if (trimmed.length > 0) {
820
+ return trimmed;
821
+ }
822
+ }
823
+ return "unknown";
824
+ }
825
+ async function ensureInitialized(pmRoot) {
826
+ if (!await pathExists(getSettingsPath(pmRoot))) {
827
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
828
+ }
829
+ }
830
+ async function runStartBackgroundRun(options, global2) {
831
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
832
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
833
+ await ensureInitialized(pmRoot);
834
+ const settings = await readSettings(pmRoot);
835
+ const requestedBy = resolveRequestedBy(options.author, settings.author_default);
836
+ const started = await startBackgroundTestRun({
837
+ pmRoot,
838
+ globalPmRoot,
839
+ kind: options.kind,
840
+ commandArgs: options.commandArgs,
841
+ requestedBy,
842
+ targetId: options.targetId,
843
+ statusFilter: options.statusFilter
844
+ });
845
+ if (!started.started) {
846
+ return {
847
+ started: false,
848
+ duplicate_of: started.duplicate_of,
849
+ run: started.run
850
+ };
851
+ }
852
+ const spawned = await spawnBackgroundTestRunWorker({
853
+ pmRoot,
854
+ runId: started.run.id,
855
+ noExtensions: options.noExtensions === true
856
+ });
857
+ return {
858
+ started: true,
859
+ run: spawned
860
+ };
861
+ }
862
+ async function runTestRunsList(options, global2) {
863
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
864
+ await ensureInitialized(pmRoot);
865
+ const status = normalizeStatus(options.status);
866
+ const limit = parseLimit(options.limit, "limit");
867
+ const runs = await listBackgroundTestRuns(pmRoot, { status, limit });
868
+ return {
869
+ runs,
870
+ count: runs.length,
871
+ filters: {
872
+ status,
873
+ limit
874
+ }
875
+ };
876
+ }
877
+ async function runTestRunsStatus(runId, global2) {
878
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
879
+ await ensureInitialized(pmRoot);
880
+ const status = await getBackgroundTestRunStatus(pmRoot, runId);
881
+ return {
882
+ run: status.run,
883
+ health: status.health
884
+ };
885
+ }
886
+ async function runTestRunsLogs(runId, options, global2) {
887
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
888
+ await ensureInitialized(pmRoot);
889
+ const stream = normalizeStream(options.stream);
890
+ const tail = parseLimit(options.tail, "tail");
891
+ const logs = await readBackgroundTestRunLogs(pmRoot, runId, stream, tail);
892
+ return {
893
+ run: logs.run,
894
+ stream: logs.stream,
895
+ tail: logs.tail,
896
+ stdout: logs.stdout,
897
+ stderr: logs.stderr
898
+ };
899
+ }
900
+ async function runTestRunsStop(runId, options, global2) {
901
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
902
+ await ensureInitialized(pmRoot);
903
+ const stopped = await stopBackgroundTestRun(pmRoot, runId, options.force === true);
904
+ return {
905
+ run: stopped.run,
906
+ signal_sent: stopped.signal_sent
907
+ };
908
+ }
909
+ async function runTestRunsResume(runId, options, global2) {
910
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
911
+ await ensureInitialized(pmRoot);
912
+ const settings = await readSettings(pmRoot);
913
+ const requestedBy = resolveRequestedBy(options.author, settings.author_default);
914
+ const resumed = await resumeBackgroundTestRun(pmRoot, runId, requestedBy, options.noExtensions === true);
915
+ return {
916
+ resumed_from: runId,
917
+ run: resumed
918
+ };
919
+ }
920
+ async function runTestRunsWorker(runId, global2) {
921
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
922
+ await ensureInitialized(pmRoot);
923
+ const finished = await runBackgroundTestRunWorker(pmRoot, runId, global2.noExtensions === true);
924
+ return {
925
+ id: finished.id,
926
+ status: finished.status,
927
+ exit_code: finished.exit_code
928
+ };
929
+ }
930
+ export {
931
+ runStartBackgroundRun,
932
+ runTestRunsList,
933
+ runTestRunsLogs,
934
+ runTestRunsResume,
935
+ runTestRunsStatus,
936
+ runTestRunsStop,
937
+ runTestRunsWorker
938
+ };
939
+ //# sourceMappingURL=test-runs-L2M7WKH7.js.map