@unbrained/pm-cli 2026.7.5 → 2026.7.7

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 (597) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/cli/commands/annotation-command.d.ts +1 -0
  3. package/dist/cli/commands/annotation-command.js +29 -2
  4. package/dist/cli/commands/annotation-command.js.map +1 -1
  5. package/dist/cli/commands/comments.js +3 -4
  6. package/dist/cli/commands/comments.js.map +1 -1
  7. package/dist/cli/commands/extension/bundled-catalog.d.ts +3 -0
  8. package/dist/cli/commands/extension/bundled-catalog.js +38 -28
  9. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  10. package/dist/cli/commands/extension/install-sources.js +81 -18
  11. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  12. package/dist/cli/commands/health.js +9 -5
  13. package/dist/cli/commands/health.js.map +1 -1
  14. package/dist/cli/commands/learnings.js +5 -3
  15. package/dist/cli/commands/learnings.js.map +1 -1
  16. package/dist/cli/commands/notes.js +5 -3
  17. package/dist/cli/commands/notes.js.map +1 -1
  18. package/dist/cli/commands/reindex.js +4 -3
  19. package/dist/cli/commands/reindex.js.map +1 -1
  20. package/dist/cli/commands/search.js +3 -3
  21. package/dist/cli/commands/search.js.map +1 -1
  22. package/dist/cli/commands/test.d.ts +9 -0
  23. package/dist/cli/commands/test.js +144 -105
  24. package/dist/cli/commands/test.js.map +1 -1
  25. package/dist/cli/extension-command-help.js +10 -2
  26. package/dist/cli/extension-command-help.js.map +1 -1
  27. package/dist/cli/register-list-query.d.ts +1 -1
  28. package/dist/cli/register-list-query.js +18 -27
  29. package/dist/cli/register-list-query.js.map +1 -1
  30. package/dist/cli/register-operations.d.ts +0 -8
  31. package/dist/cli/register-operations.js +41 -46
  32. package/dist/cli/register-operations.js.map +1 -1
  33. package/dist/cli/register-setup.js +113 -13
  34. package/dist/cli/register-setup.js.map +1 -1
  35. package/dist/cli/registration-helpers.d.ts +5 -1
  36. package/dist/cli/registration-helpers.js +14 -2
  37. package/dist/cli/registration-helpers.js.map +1 -1
  38. package/dist/cli-bundle/chunks/append-F7WPGIQL.js +11 -0
  39. package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js → append-PVCTBVJG.js} +8 -9
  40. package/dist/cli-bundle/chunks/{chunk-PPE4YUQM.js → chunk-2APXX4TZ.js} +17 -28
  41. package/dist/cli-bundle/chunks/chunk-2APXX4TZ.js.map +1 -0
  42. package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js → chunk-2LEJGRQ7.js} +3 -12
  43. package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js.map → chunk-2LEJGRQ7.js.map} +1 -1
  44. package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js → chunk-2TILG6F2.js} +3 -3
  45. package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js → chunk-3G6UMXT3.js} +6 -8
  46. package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js.map → chunk-3G6UMXT3.js.map} +1 -1
  47. package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js → chunk-3TYOW6RR.js} +8 -8
  48. package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js → chunk-3X542TEY.js} +7 -7
  49. package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js → chunk-42LXP4VO.js} +14 -21
  50. package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js.map → chunk-42LXP4VO.js.map} +1 -1
  51. package/dist/cli-bundle/chunks/{chunk-5J2XPTAD.js → chunk-43SIHQND.js} +36 -15
  52. package/dist/cli-bundle/chunks/chunk-43SIHQND.js.map +7 -0
  53. package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js → chunk-43UQN754.js} +12 -19
  54. package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js.map → chunk-43UQN754.js.map} +1 -1
  55. package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js → chunk-43YSKY75.js} +4 -6
  56. package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js.map → chunk-43YSKY75.js.map} +1 -1
  57. package/dist/cli-bundle/chunks/{notes-72YXN5JX.js → chunk-4BKDAEDF.js} +6 -13
  58. package/dist/cli-bundle/chunks/{notes-72YXN5JX.js.map → chunk-4BKDAEDF.js.map} +2 -2
  59. package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js → chunk-4IQKDKGE.js} +18 -32
  60. package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js.map → chunk-4IQKDKGE.js.map} +1 -1
  61. package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js → chunk-4MZOKTI2.js} +6 -8
  62. package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js.map → chunk-4MZOKTI2.js.map} +1 -1
  63. package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js → chunk-52NS7JDP.js} +14 -20
  64. package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js.map → chunk-52NS7JDP.js.map} +1 -1
  65. package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js → chunk-565WYS5W.js} +12 -16
  66. package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js.map → chunk-565WYS5W.js.map} +1 -1
  67. package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js → chunk-5FIQ4EX3.js} +13 -19
  68. package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js.map → chunk-5FIQ4EX3.js.map} +1 -1
  69. package/dist/cli-bundle/chunks/{config-V57QD47V.js → chunk-6G6O3OPQ.js} +259 -41
  70. package/dist/cli-bundle/chunks/chunk-6G6O3OPQ.js.map +1 -0
  71. package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js → chunk-6LCJRGPD.js} +9 -13
  72. package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js.map → chunk-6LCJRGPD.js.map} +1 -1
  73. package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js → chunk-6UQCNWFV.js} +6 -8
  74. package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js.map → chunk-6UQCNWFV.js.map} +1 -1
  75. package/dist/cli-bundle/chunks/{chunk-LEKT4K7I.js → chunk-6XTSYPPO.js} +1216 -387
  76. package/dist/cli-bundle/chunks/chunk-6XTSYPPO.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js +5434 -0
  78. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js.map +1 -0
  79. package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js → chunk-7PNQA24K.js} +30 -36
  80. package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js.map → chunk-7PNQA24K.js.map} +1 -1
  81. package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js → chunk-7VQ3JJN5.js} +2 -2
  82. package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js → chunk-7Y5N34HX.js} +8 -12
  83. package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js.map → chunk-7Y5N34HX.js.map} +1 -1
  84. package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js → chunk-AGAVEDIE.js} +7 -7
  85. package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js → chunk-AJUON7E6.js} +3 -3
  86. package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js → chunk-ARKHKYYS.js} +16 -30
  87. package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js.map → chunk-ARKHKYYS.js.map} +1 -1
  88. package/dist/cli-bundle/chunks/{chunk-7EQNAZX2.js → chunk-C5ACVMOI.js} +99 -51
  89. package/dist/cli-bundle/chunks/chunk-C5ACVMOI.js.map +7 -0
  90. package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js → chunk-CJQM7O7R.js} +16 -20
  91. package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js.map → chunk-CJQM7O7R.js.map} +1 -1
  92. package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js → chunk-D2DCTFTL.js} +7 -9
  93. package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js.map → chunk-D2DCTFTL.js.map} +1 -1
  94. package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js → chunk-DDDWVPID.js} +7 -11
  95. package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js.map → chunk-DDDWVPID.js.map} +1 -1
  96. package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js → chunk-DG6BSXZ7.js} +6 -13
  97. package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js.map → chunk-DG6BSXZ7.js.map} +2 -2
  98. package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js → chunk-DR2V5OIV.js} +3 -3
  99. package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js → chunk-E3LWJUGF.js} +4 -6
  100. package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js.map → chunk-E3LWJUGF.js.map} +1 -1
  101. package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js → chunk-E3YQFSFE.js} +6 -10
  102. package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js.map → chunk-E3YQFSFE.js.map} +1 -1
  103. package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js → chunk-EDO7VXSO.js} +2 -2
  104. package/dist/cli-bundle/chunks/{chunk-FDBARR33.js → chunk-EIUBK2LT.js} +12 -18
  105. package/dist/cli-bundle/chunks/{chunk-FDBARR33.js.map → chunk-EIUBK2LT.js.map} +1 -1
  106. package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js → chunk-EMXPI36L.js} +14 -20
  107. package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js.map → chunk-EMXPI36L.js.map} +1 -1
  108. package/dist/cli-bundle/chunks/{chunk-4OFLJHX6.js → chunk-EOUVR7JN.js} +13 -8
  109. package/dist/cli-bundle/chunks/chunk-EOUVR7JN.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js → chunk-EVEPHNXJ.js} +4 -4
  111. package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js → chunk-F6MT7KKE.js} +6 -10
  112. package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js.map → chunk-F6MT7KKE.js.map} +1 -1
  113. package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js → chunk-F6YC2A6X.js} +7 -11
  114. package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js.map → chunk-F6YC2A6X.js.map} +1 -1
  115. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js +5514 -0
  116. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js → chunk-FN6SB4HU.js} +2 -2
  118. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js +5359 -0
  119. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js.map +1 -0
  120. package/dist/cli-bundle/chunks/{chunk-JLA7EVYV.js → chunk-GLS6VMWI.js} +37 -16
  121. package/dist/cli-bundle/chunks/chunk-GLS6VMWI.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js → chunk-GPIDUMMN.js} +10 -17
  123. package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js.map → chunk-GPIDUMMN.js.map} +1 -1
  124. package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js → chunk-GTM5HQL4.js} +15 -21
  125. package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js.map → chunk-GTM5HQL4.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js → chunk-H2SMKL2N.js} +8 -8
  127. package/dist/cli-bundle/chunks/{chunk-S4APD35C.js → chunk-HHEWQXPD.js} +6 -6
  128. package/dist/cli-bundle/chunks/chunk-HHEWQXPD.js.map +7 -0
  129. package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js → chunk-HX6QXV5P.js} +2 -2
  130. package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js → chunk-I74FMIWA.js} +11 -17
  131. package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js.map → chunk-I74FMIWA.js.map} +1 -1
  132. package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js +804 -0
  133. package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js.map +7 -0
  134. package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js → chunk-II7R6KD4.js} +9 -13
  135. package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js.map → chunk-II7R6KD4.js.map} +1 -1
  136. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js +10320 -0
  137. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js.map +1 -0
  138. package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js → chunk-J7BOLHAV.js} +5 -7
  139. package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js.map → chunk-J7BOLHAV.js.map} +1 -1
  140. package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js → chunk-KTGJ2CBU.js} +4 -6
  141. package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js.map → chunk-KTGJ2CBU.js.map} +1 -1
  142. package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js → chunk-LCFJ7XAM.js} +32 -2
  143. package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js.map → chunk-LCFJ7XAM.js.map} +3 -3
  144. package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js → chunk-LZQU6XJG.js} +28 -34
  145. package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js.map → chunk-LZQU6XJG.js.map} +1 -1
  146. package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js → chunk-M62RO3XK.js} +10 -14
  147. package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js.map → chunk-M62RO3XK.js.map} +1 -1
  148. package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js → chunk-MCEUKJKW.js} +9 -11
  149. package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js.map → chunk-MCEUKJKW.js.map} +1 -1
  150. package/dist/cli-bundle/chunks/{chunk-T5Y3QSNF.js → chunk-MHNMCDWR.js} +1447 -86
  151. package/dist/cli-bundle/chunks/chunk-MHNMCDWR.js.map +1 -0
  152. package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js → chunk-MRFWUSVA.js} +4 -6
  153. package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js.map → chunk-MRFWUSVA.js.map} +1 -1
  154. package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js → chunk-N6ZHDLUY.js} +6 -8
  155. package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js.map → chunk-N6ZHDLUY.js.map} +1 -1
  156. package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js → chunk-NWWL22C7.js} +8 -12
  157. package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js.map → chunk-NWWL22C7.js.map} +1 -1
  158. package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js → chunk-P3MJJW7P.js} +2 -2
  159. package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js → chunk-PDXJXEZJ.js} +2 -2
  160. package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js → chunk-Q64AYQYW.js} +9 -13
  161. package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js.map → chunk-Q64AYQYW.js.map} +1 -1
  162. package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js → chunk-QDABF2RB.js} +26 -47
  163. package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js.map → chunk-QDABF2RB.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{chunk-NBFCNJ7Q.js → chunk-QFBSP3NI.js} +529 -46
  165. package/dist/cli-bundle/chunks/chunk-QFBSP3NI.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js → chunk-RB3KLPAH.js} +11 -16
  167. package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js.map → chunk-RB3KLPAH.js.map} +1 -1
  168. package/dist/cli-bundle/chunks/{chunk-YSAH5FY5.js → chunk-RY7PTTUB.js} +94 -53
  169. package/dist/cli-bundle/chunks/chunk-RY7PTTUB.js.map +1 -0
  170. package/dist/cli-bundle/chunks/{chunk-WVSGSZ6J.js → chunk-S547WBYG.js} +1477 -86
  171. package/dist/cli-bundle/chunks/chunk-S547WBYG.js.map +7 -0
  172. package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js → chunk-S5BNGFN5.js} +24 -45
  173. package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js.map → chunk-S5BNGFN5.js.map} +1 -1
  174. package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js → chunk-S6VC2A2K.js} +9 -14
  175. package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js.map → chunk-S6VC2A2K.js.map} +1 -1
  176. package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js → chunk-SIM5JDON.js} +7 -14
  177. package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js.map → chunk-SIM5JDON.js.map} +1 -1
  178. package/dist/cli-bundle/chunks/{chunk-ZD34OFFQ.js → chunk-SY75LYXR.js} +12 -7
  179. package/dist/cli-bundle/chunks/chunk-SY75LYXR.js.map +7 -0
  180. package/dist/cli-bundle/chunks/{chunk-TT42JUMF.js → chunk-TEISGNSH.js} +7 -7
  181. package/dist/cli-bundle/chunks/chunk-TEISGNSH.js.map +1 -0
  182. package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js → chunk-TEKZOS7M.js} +2 -2
  183. package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js → chunk-TGUK6XN6.js} +14 -18
  184. package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js.map → chunk-TGUK6XN6.js.map} +1 -1
  185. package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js → chunk-TNC6MZUD.js} +10 -21
  186. package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js.map → chunk-TNC6MZUD.js.map} +1 -1
  187. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js +10498 -0
  188. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js.map +7 -0
  189. package/dist/cli-bundle/chunks/{chunk-YD5FML7K.js → chunk-UO7XAZK6.js} +27 -4
  190. package/dist/cli-bundle/chunks/chunk-UO7XAZK6.js.map +1 -0
  191. package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js → chunk-V5ZWKJNY.js} +5 -14
  192. package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js.map → chunk-V5ZWKJNY.js.map} +1 -1
  193. package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js → chunk-VGO73OCK.js} +7 -14
  194. package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js.map → chunk-VGO73OCK.js.map} +1 -1
  195. package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js → chunk-VLEA2UTQ.js} +2 -2
  196. package/dist/cli-bundle/chunks/{files-6P57MRKL.js → chunk-W5HXHC7C.js} +8 -15
  197. package/dist/cli-bundle/chunks/{files-6P57MRKL.js.map → chunk-W5HXHC7C.js.map} +1 -1
  198. package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js → chunk-WCWVEXGA.js} +2 -2
  199. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js +6690 -0
  200. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js.map +7 -0
  201. package/dist/cli-bundle/chunks/{delete-62JQTYT4.js → chunk-XBX5CBRQ.js} +6 -10
  202. package/dist/cli-bundle/chunks/{delete-62JQTYT4.js.map → chunk-XBX5CBRQ.js.map} +1 -1
  203. package/dist/cli-bundle/chunks/{chunk-MTTXDAK4.js → chunk-XC3X7BQR.js} +541 -44
  204. package/dist/cli-bundle/chunks/chunk-XC3X7BQR.js.map +7 -0
  205. package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js → chunk-XHCVAZGM.js} +17 -23
  206. package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js.map → chunk-XHCVAZGM.js.map} +1 -1
  207. package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js → chunk-XPMXPR7K.js} +7 -9
  208. package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js.map → chunk-XPMXPR7K.js.map} +1 -1
  209. package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js → chunk-XS2TMNXR.js} +8 -12
  210. package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js.map → chunk-XS2TMNXR.js.map} +1 -1
  211. package/dist/cli-bundle/chunks/{plan-XWY5T67S.js → chunk-XXIYUTLK.js} +12 -23
  212. package/dist/cli-bundle/chunks/{plan-XWY5T67S.js.map → chunk-XXIYUTLK.js.map} +1 -1
  213. package/dist/cli-bundle/chunks/{chunk-7QH7DHUB.js → chunk-XZWL7VNE.js} +1220 -398
  214. package/dist/cli-bundle/chunks/chunk-XZWL7VNE.js.map +1 -0
  215. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js +6624 -0
  216. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js → chunk-Y7KYVCZM.js} +12 -18
  218. package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js.map → chunk-Y7KYVCZM.js.map} +1 -1
  219. package/dist/cli-bundle/chunks/{chunk-UI5BJ6DO.js → chunk-YCVWWIKY.js} +17 -28
  220. package/dist/cli-bundle/chunks/chunk-YCVWWIKY.js.map +7 -0
  221. package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js +780 -0
  222. package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js.map +1 -0
  223. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js +5509 -0
  224. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js.map +7 -0
  225. package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js → chunk-YPD7SQ5P.js} +8 -12
  226. package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js.map → chunk-YPD7SQ5P.js.map} +2 -2
  227. package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js → chunk-YPMZMKN7.js} +2 -2
  228. package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js → chunk-YTD5GICJ.js} +4 -4
  229. package/dist/cli-bundle/chunks/{config-DJJKZB5R.js → chunk-ZNEG2UDO.js} +264 -39
  230. package/dist/cli-bundle/chunks/{config-DJJKZB5R.js.map → chunk-ZNEG2UDO.js.map} +4 -4
  231. package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js → chunk-ZO7CLOY2.js} +3 -3
  232. package/dist/cli-bundle/chunks/{close-3YRR3XY6.js → close-3YYQ5OG2.js} +5 -9
  233. package/dist/cli-bundle/chunks/close-Z3Q4U7TS.js +12 -0
  234. package/dist/cli-bundle/chunks/close-many-3L2RXH3M.js +22 -0
  235. package/dist/cli-bundle/chunks/close-many-D366FTIG.js +26 -0
  236. package/dist/cli-bundle/chunks/comments-54XDJNFE.js +17 -0
  237. package/dist/cli-bundle/chunks/comments-HGHC2PN6.js +13 -0
  238. package/dist/cli-bundle/chunks/copy-44RT5GDW.js +13 -0
  239. package/dist/cli-bundle/chunks/copy-UGMUGHZA.js +9 -0
  240. package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js → create-4GWJWPXG.js} +9 -14
  241. package/dist/cli-bundle/chunks/create-AZXCUYKP.js +25 -0
  242. package/dist/cli-bundle/chunks/delete-Y6SXIQ4X.js +10 -0
  243. package/dist/cli-bundle/chunks/delete-YQ2VPXNF.js +14 -0
  244. package/dist/cli-bundle/chunks/deps-BU5EBJDU.js +17 -0
  245. package/dist/cli-bundle/chunks/deps-FMANWFRP.js +13 -0
  246. package/dist/cli-bundle/chunks/docs-OQBSJNIA.js +18 -0
  247. package/dist/cli-bundle/chunks/docs-VNPBZXEL.js +14 -0
  248. package/dist/cli-bundle/chunks/files-72HZEBOE.js +18 -0
  249. package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js → files-HTSB2KJG.js} +13 -13
  250. package/dist/cli-bundle/chunks/focus-FOG4ALC2.js +14 -0
  251. package/dist/cli-bundle/chunks/focus-SUTMKXGX.js +10 -0
  252. package/dist/cli-bundle/chunks/history-compact-M6IFAMBP.js +25 -0
  253. package/dist/cli-bundle/chunks/history-compact-NEXRPP2O.js +21 -0
  254. package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js → history-redact-NQX3OGZP.js} +7 -11
  255. package/dist/cli-bundle/chunks/history-redact-WQJBZ3PX.js +17 -0
  256. package/dist/cli-bundle/chunks/history-repair-CBHMHAJO.js +19 -0
  257. package/dist/cli-bundle/chunks/history-repair-NHOJG7WO.js +23 -0
  258. package/dist/cli-bundle/chunks/learnings-M64NTSOR.js +13 -0
  259. package/dist/cli-bundle/chunks/learnings-T63JGKKN.js +17 -0
  260. package/dist/cli-bundle/chunks/notes-73WE2UV2.js +13 -0
  261. package/dist/cli-bundle/chunks/notes-U7L6HQQ2.js +17 -0
  262. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js +24 -0
  263. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js.map +7 -0
  264. package/dist/cli-bundle/chunks/plan-TN537L24.js +28 -0
  265. package/dist/cli-bundle/chunks/plan-TN537L24.js.map +1 -0
  266. package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js +37 -0
  267. package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js.map +1 -0
  268. package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js +33 -0
  269. package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js.map +7 -0
  270. package/dist/cli-bundle/chunks/{register-list-query-5H66WFYF.js → register-list-query-OHXD7G5N.js} +41 -33
  271. package/dist/cli-bundle/chunks/register-list-query-OHXD7G5N.js.map +7 -0
  272. package/dist/cli-bundle/chunks/{register-list-query-FB3FNDLZ.js → register-list-query-ZCRABAPN.js} +42 -34
  273. package/dist/cli-bundle/chunks/register-list-query-ZCRABAPN.js.map +1 -0
  274. package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js → register-mutation-P3G4XP6Q.js} +36 -41
  275. package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js.map → register-mutation-P3G4XP6Q.js.map} +1 -1
  276. package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js → register-mutation-XX4H56PE.js} +34 -39
  277. package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js.map → register-mutation-XX4H56PE.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{register-operations-A3XAM5J7.js → register-operations-V6PIYEDU.js} +80 -52
  279. package/dist/cli-bundle/chunks/register-operations-V6PIYEDU.js.map +1 -0
  280. package/dist/cli-bundle/chunks/{register-operations-SG7HBSUP.js → register-operations-V6VKTG54.js} +79 -51
  281. package/dist/cli-bundle/chunks/register-operations-V6VKTG54.js.map +7 -0
  282. package/dist/cli-bundle/chunks/{register-setup-K6U3NVY5.js → register-setup-6RVAWT6W.js} +129 -31
  283. package/dist/cli-bundle/chunks/register-setup-6RVAWT6W.js.map +7 -0
  284. package/dist/cli-bundle/chunks/{register-setup-I45OGJUV.js → register-setup-6YVUSQYD.js} +130 -32
  285. package/dist/cli-bundle/chunks/register-setup-6YVUSQYD.js.map +1 -0
  286. package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js → restore-HC3YSWF7.js} +7 -11
  287. package/dist/cli-bundle/chunks/restore-HC3YSWF7.js.map +1 -0
  288. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js +15 -0
  289. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js.map +7 -0
  290. package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js → schema-DAGSYO6E.js} +6 -10
  291. package/dist/cli-bundle/chunks/schema-DAGSYO6E.js.map +7 -0
  292. package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js → schema-UBXJCQAC.js} +6 -10
  293. package/dist/cli-bundle/chunks/schema-UBXJCQAC.js.map +1 -0
  294. package/dist/cli-bundle/chunks/update-CJGG5WMV.js +21 -0
  295. package/dist/cli-bundle/chunks/update-CJGG5WMV.js.map +7 -0
  296. package/dist/cli-bundle/chunks/update-LKD64AFP.js +25 -0
  297. package/dist/cli-bundle/chunks/update-LKD64AFP.js.map +1 -0
  298. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js +31 -0
  299. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js.map +7 -0
  300. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js +35 -0
  301. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js.map +1 -0
  302. package/dist/cli-bundle/main.js +29 -31
  303. package/dist/cli-bundle/main.js.map +2 -2
  304. package/dist/cli-bundle/sdk-runtime.js +136 -54
  305. package/dist/cli-bundle/sdk-testing.js +7 -8
  306. package/dist/cli-bundle/sdk.js +132 -84
  307. package/dist/cli-bundle/sdk.js.map +2 -2
  308. package/dist/core/history/drift-scan.js +3 -8
  309. package/dist/core/history/drift-scan.js.map +1 -1
  310. package/dist/core/output/mutation-projection.js +11 -5
  311. package/dist/core/output/mutation-projection.js.map +1 -1
  312. package/dist/core/search/cache.js +3 -3
  313. package/dist/core/search/cache.js.map +1 -1
  314. package/dist/core/search/semantic-defaults.d.ts +2 -0
  315. package/dist/core/search/semantic-defaults.js +11 -4
  316. package/dist/core/search/semantic-defaults.js.map +1 -1
  317. package/dist/core/search/vector-stores.d.ts +1 -1
  318. package/dist/core/search/vector-stores.js +33 -7
  319. package/dist/core/search/vector-stores.js.map +1 -1
  320. package/dist/mcp/server.d.ts +22 -50
  321. package/dist/mcp/server.js +62 -916
  322. package/dist/mcp/server.js.map +1 -1
  323. package/dist/sdk/cli-contracts/flag-contracts.js +7 -7
  324. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  325. package/dist/sdk/cli-contracts/tool-schema.js +9 -7
  326. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  327. package/dist/sdk/index.d.ts +4 -2
  328. package/dist/sdk/index.js +4 -4
  329. package/dist/sdk/index.js.map +1 -1
  330. package/dist/sdk/runtime.d.ts +312 -5
  331. package/dist/sdk/runtime.js +1391 -26
  332. package/dist/sdk/runtime.js.map +1 -1
  333. package/dist/sdk/start-task-status.d.ts +13 -0
  334. package/dist/sdk/start-task-status.js +19 -0
  335. package/dist/sdk/start-task-status.js.map +1 -0
  336. package/dist/sdk/workspace-contracts-cache.d.ts +17 -0
  337. package/dist/sdk/workspace-contracts-cache.js +36 -0
  338. package/dist/sdk/workspace-contracts-cache.js.map +1 -0
  339. package/docs/COMMANDS.md +10 -1
  340. package/docs/RELEASING.md +3 -1
  341. package/docs/SDK.md +81 -0
  342. package/docs/TESTING.md +3 -0
  343. package/docs/examples/sdk-app-embedding/run-embedded-pm.mjs +16 -2
  344. package/docs/examples/sdk-contract-consumer/inspect-contracts.mjs +16 -1
  345. package/package.json +1 -1
  346. package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +0 -18
  347. package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js +0 -375
  348. package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js.map +0 -7
  349. package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js +0 -372
  350. package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js.map +0 -1
  351. package/dist/cli-bundle/chunks/chunk-37E72CNS.js +0 -217
  352. package/dist/cli-bundle/chunks/chunk-37E72CNS.js.map +0 -1
  353. package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js +0 -1961
  354. package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js.map +0 -1
  355. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js +0 -1749
  356. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +0 -7
  357. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js +0 -87
  358. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js.map +0 -7
  359. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js +0 -822
  360. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js.map +0 -7
  361. package/dist/cli-bundle/chunks/chunk-4OFLJHX6.js.map +0 -1
  362. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js +0 -2181
  363. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +0 -1
  364. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js +0 -1704
  365. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +0 -1
  366. package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js +0 -2330
  367. package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js.map +0 -7
  368. package/dist/cli-bundle/chunks/chunk-5J2XPTAD.js.map +0 -7
  369. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js +0 -995
  370. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js.map +0 -1
  371. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js +0 -819
  372. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js.map +0 -1
  373. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +0 -23
  374. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +0 -7
  375. package/dist/cli-bundle/chunks/chunk-7EQNAZX2.js.map +0 -7
  376. package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +0 -1
  377. package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js +0 -530
  378. package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js.map +0 -7
  379. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +0 -275
  380. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +0 -7
  381. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js +0 -231
  382. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +0 -7
  383. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js +0 -2184
  384. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js.map +0 -7
  385. package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js +0 -1615
  386. package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js.map +0 -7
  387. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js +0 -228
  388. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +0 -1
  389. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js +0 -3237
  390. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +0 -7
  391. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js +0 -1570
  392. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +0 -1
  393. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js +0 -3206
  394. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +0 -1
  395. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js +0 -371
  396. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js.map +0 -7
  397. package/dist/cli-bundle/chunks/chunk-JLA7EVYV.js.map +0 -1
  398. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +0 -76
  399. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +0 -1
  400. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +0 -79
  401. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +0 -7
  402. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +0 -915
  403. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +0 -1
  404. package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js +0 -218
  405. package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js.map +0 -7
  406. package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +0 -7
  407. package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js +0 -1858
  408. package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js.map +0 -1
  409. package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +0 -7
  410. package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js +0 -520
  411. package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js.map +0 -1
  412. package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js +0 -1041
  413. package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js.map +0 -7
  414. package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +0 -1
  415. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +0 -20
  416. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +0 -1
  417. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +0 -918
  418. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +0 -7
  419. package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js +0 -1985
  420. package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js.map +0 -7
  421. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +0 -238
  422. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +0 -1
  423. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +0 -1977
  424. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +0 -7
  425. package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js +0 -1031
  426. package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js.map +0 -1
  427. package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +0 -1
  428. package/dist/cli-bundle/chunks/chunk-QZ342C63.js +0 -220
  429. package/dist/cli-bundle/chunks/chunk-QZ342C63.js.map +0 -7
  430. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js +0 -368
  431. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js.map +0 -1
  432. package/dist/cli-bundle/chunks/chunk-S4APD35C.js.map +0 -7
  433. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js +0 -1149
  434. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +0 -1
  435. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +0 -272
  436. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +0 -1
  437. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +0 -1
  438. package/dist/cli-bundle/chunks/chunk-TT42JUMF.js.map +0 -1
  439. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +0 -165
  440. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +0 -1
  441. package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +0 -7
  442. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +0 -1932
  443. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +0 -1
  444. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +0 -175
  445. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +0 -7
  446. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js +0 -84
  447. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js.map +0 -1
  448. package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js +0 -1868
  449. package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js.map +0 -7
  450. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +0 -7
  451. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js +0 -1152
  452. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +0 -7
  453. package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +0 -1
  454. package/dist/cli-bundle/chunks/chunk-YSAH5FY5.js.map +0 -1
  455. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js +0 -1005
  456. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js.map +0 -7
  457. package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js +0 -215
  458. package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js.map +0 -1
  459. package/dist/cli-bundle/chunks/chunk-ZD34OFFQ.js.map +0 -7
  460. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js +0 -2306
  461. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +0 -1
  462. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +0 -241
  463. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +0 -7
  464. package/dist/cli-bundle/chunks/claim-4DROPSIS.js +0 -144
  465. package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +0 -1
  466. package/dist/cli-bundle/chunks/claim-VX54TV5U.js +0 -147
  467. package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +0 -7
  468. package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +0 -16
  469. package/dist/cli-bundle/chunks/config-V57QD47V.js.map +0 -1
  470. package/dist/cli-bundle/chunks/context-4OQGIPSO.js +0 -45
  471. package/dist/cli-bundle/chunks/context-WLA6IAWE.js +0 -49
  472. package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +0 -12
  473. package/dist/cli-bundle/chunks/create-WKOZKPQR.js +0 -30
  474. package/dist/cli-bundle/chunks/eval-N6UHFWVO.js +0 -288
  475. package/dist/cli-bundle/chunks/eval-N6UHFWVO.js.map +0 -7
  476. package/dist/cli-bundle/chunks/eval-PHOTWYHI.js +0 -278
  477. package/dist/cli-bundle/chunks/eval-PHOTWYHI.js.map +0 -1
  478. package/dist/cli-bundle/chunks/extension-NBAH62ML.js +0 -40
  479. package/dist/cli-bundle/chunks/extension-ZF6ZZPOU.js +0 -44
  480. package/dist/cli-bundle/chunks/gc-AETFKZ44.js +0 -398
  481. package/dist/cli-bundle/chunks/gc-AETFKZ44.js.map +0 -7
  482. package/dist/cli-bundle/chunks/gc-RLBP4QVN.js +0 -388
  483. package/dist/cli-bundle/chunks/gc-RLBP4QVN.js.map +0 -1
  484. package/dist/cli-bundle/chunks/get-NH2MPBCI.js +0 -283
  485. package/dist/cli-bundle/chunks/get-NH2MPBCI.js.map +0 -1
  486. package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js +0 -286
  487. package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js.map +0 -7
  488. package/dist/cli-bundle/chunks/health-3GVPMQBL.js +0 -1612
  489. package/dist/cli-bundle/chunks/health-3GVPMQBL.js.map +0 -1
  490. package/dist/cli-bundle/chunks/health-DNTM72GJ.js +0 -1615
  491. package/dist/cli-bundle/chunks/health-DNTM72GJ.js.map +0 -7
  492. package/dist/cli-bundle/chunks/history-RYKLC72X.js +0 -20
  493. package/dist/cli-bundle/chunks/history-SGPYRAFT.js +0 -24
  494. package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +0 -21
  495. package/dist/cli-bundle/chunks/init-RPIPQUNV.js +0 -32
  496. package/dist/cli-bundle/chunks/init-SKQAESQS.js +0 -28
  497. package/dist/cli-bundle/chunks/list-64LHZ3HM.js +0 -32
  498. package/dist/cli-bundle/chunks/list-7LXBTEKI.js +0 -36
  499. package/dist/cli-bundle/chunks/next-7ODPAQ4U.js +0 -306
  500. package/dist/cli-bundle/chunks/next-7ODPAQ4U.js.map +0 -7
  501. package/dist/cli-bundle/chunks/next-ODJUM4ZM.js +0 -303
  502. package/dist/cli-bundle/chunks/next-ODJUM4ZM.js.map +0 -1
  503. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +0 -397
  504. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +0 -1
  505. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +0 -400
  506. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +0 -7
  507. package/dist/cli-bundle/chunks/register-list-query-5H66WFYF.js.map +0 -7
  508. package/dist/cli-bundle/chunks/register-list-query-FB3FNDLZ.js.map +0 -1
  509. package/dist/cli-bundle/chunks/register-operations-A3XAM5J7.js.map +0 -1
  510. package/dist/cli-bundle/chunks/register-operations-SG7HBSUP.js.map +0 -7
  511. package/dist/cli-bundle/chunks/register-setup-I45OGJUV.js.map +0 -1
  512. package/dist/cli-bundle/chunks/register-setup-K6U3NVY5.js.map +0 -7
  513. package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +0 -19
  514. package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js +0 -91
  515. package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js.map +0 -7
  516. package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js +0 -88
  517. package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js.map +0 -1
  518. package/dist/cli-bundle/chunks/search-3S72CTD6.js +0 -38
  519. package/dist/cli-bundle/chunks/search-WNUNBQXO.js +0 -34
  520. package/dist/cli-bundle/chunks/stats-IJYTRQGV.js +0 -250
  521. package/dist/cli-bundle/chunks/stats-IJYTRQGV.js.map +0 -7
  522. package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js +0 -240
  523. package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js.map +0 -1
  524. package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js +0 -309
  525. package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js.map +0 -7
  526. package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js +0 -306
  527. package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js.map +0 -1
  528. package/dist/cli-bundle/chunks/test-DQ2QFJ7W.js +0 -45
  529. package/dist/cli-bundle/chunks/test-W7QBLVJS.js +0 -41
  530. package/dist/cli-bundle/chunks/test-all-636NTRTT.js +0 -434
  531. package/dist/cli-bundle/chunks/test-all-636NTRTT.js.map +0 -1
  532. package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js +0 -437
  533. package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js.map +0 -7
  534. package/dist/cli-bundle/chunks/test-runs-245OINZR.js +0 -28
  535. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +0 -24
  536. package/dist/cli-bundle/chunks/update-SFLZPJXX.js +0 -30
  537. package/dist/cli-bundle/chunks/update-SJZ6S77U.js +0 -26
  538. package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js +0 -290
  539. package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js.map +0 -7
  540. package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js +0 -287
  541. package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js.map +0 -1
  542. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js +0 -2143
  543. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js.map +0 -7
  544. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js +0 -2105
  545. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js.map +0 -1
  546. /package/dist/cli-bundle/chunks/{activity-4XQIDNM5.js.map → append-F7WPGIQL.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js.map → append-PVCTBVJG.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js.map → chunk-2TILG6F2.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js.map → chunk-3TYOW6RR.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js.map → chunk-3X542TEY.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js.map → chunk-7VQ3JJN5.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js.map → chunk-AGAVEDIE.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js.map → chunk-AJUON7E6.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js.map → chunk-DR2V5OIV.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js.map → chunk-EDO7VXSO.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js.map → chunk-EVEPHNXJ.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js.map → chunk-FN6SB4HU.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js.map → chunk-H2SMKL2N.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js.map → chunk-HX6QXV5P.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js.map → chunk-P3MJJW7P.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js.map → chunk-PDXJXEZJ.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js.map → chunk-TEKZOS7M.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js.map → chunk-VLEA2UTQ.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js.map → chunk-WCWVEXGA.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js.map → chunk-YPMZMKN7.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js.map → chunk-YTD5GICJ.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js.map → chunk-ZO7CLOY2.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{close-3YRR3XY6.js.map → close-3YYQ5OG2.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{close-OB2Y4QP5.js.map → close-Z3Q4U7TS.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{context-4OQGIPSO.js.map → close-many-3L2RXH3M.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{context-WLA6IAWE.js.map → close-many-D366FTIG.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js.map → comments-54XDJNFE.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{contracts-HXJLKCRI.js.map → comments-HGHC2PN6.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js.map → copy-44RT5GDW.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{create-WKOZKPQR.js.map → copy-UGMUGHZA.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{extension-ZF6ZZPOU.js.map → create-4GWJWPXG.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{extension-NBAH62ML.js.map → create-AZXCUYKP.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{history-RYKLC72X.js.map → delete-Y6SXIQ4X.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{history-SGPYRAFT.js.map → delete-YQ2VPXNF.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js.map → deps-BU5EBJDU.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{history-redact-4H3FCKF3.js.map → deps-FMANWFRP.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{init-RPIPQUNV.js.map → docs-OQBSJNIA.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{init-SKQAESQS.js.map → docs-VNPBZXEL.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{list-64LHZ3HM.js.map → files-72HZEBOE.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{list-7LXBTEKI.js.map → files-HTSB2KJG.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js.map → focus-FOG4ALC2.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{restore-PXOFL6AM.js.map → focus-SUTMKXGX.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js.map → history-compact-M6IFAMBP.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js.map → history-compact-NEXRPP2O.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{search-3S72CTD6.js.map → history-redact-NQX3OGZP.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{search-WNUNBQXO.js.map → history-redact-WQJBZ3PX.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{test-W7QBLVJS.js.map → history-repair-CBHMHAJO.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{test-DQ2QFJ7W.js.map → history-repair-NHOJG7WO.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{test-runs-ZRD4GCTT.js.map → learnings-M64NTSOR.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{test-runs-245OINZR.js.map → learnings-T63JGKKN.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{update-SJZ6S77U.js.map → notes-73WE2UV2.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{update-SFLZPJXX.js.map → notes-U7L6HQQ2.js.map} +0 -0
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/history-repair.ts"],
4
4
  "sourcesContent": ["/**\n * @module cli/commands/history-repair\n *\n * Implements the pm history repair command surface and its agent-facing runtime behavior.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { pathExists, readFileIfExists } from \"../../core/fs/fs-utils.js\";\nimport { executeHistoryRewrite, writeHistoryRawWithRollback } from \"../../core/history/history-rewrite.js\";\nimport {\n historyEntriesToRaw,\n reanchorHistoryEntries,\n replayHash,\n toReplayDocument,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { scanHistoryDrift } from \"../../core/history/drift-scan.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { getActiveExtensionRegistrations, runActiveOnWriteHooks } from \"../../core/extensions/index.js\";\nimport { listAllFrontMatterWithBody, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemMetadata } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\n/**\n * Documents the history repair command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRepairCommandOptions {\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/**\n * Documents the history repair result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRepairResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n history: {\n path: string;\n entries_scanned: number;\n chain_drift_before: boolean;\n entries_rehashed: number;\n entries_patch_repaired: number;\n converted_replace_to_add: number;\n skipped_ops: number;\n reconciled_with_item: boolean;\n audit_entry_added: boolean;\n verify_ok: boolean;\n verify_errors: string[];\n };\n item: {\n exists: boolean;\n path: string | null;\n matched_chain_before: boolean | null;\n };\n warnings: string[];\n generated_at: string;\n}\n\ninterface HistoryRepairItemReplayContext {\n currentItemReplay: ReplayDocument | null;\n currentItemPath: string | null;\n matchedChainBefore: boolean | null;\n currentItemRawBeforeLock: string | null;\n loadedItem: Awaited<ReturnType<typeof readLocatedItem>> | null;\n}\n\nfunction toAuthor(candidate: string | undefined, defaultAuthor: string): string {\n /* c8 ignore next -- PM_AUTHOR fallback branch is environment-dependent in CI. */\n const resolved = candidate ?? process.env.PM_AUTHOR ?? defaultAuthor;\n const trimmed = resolved.trim();\n return trimmed.length > 0 ? trimmed : \"unknown\";\n}\n\nasync function loadHistoryRepairItemReplay(\n subject: Awaited<ReturnType<typeof resolveHistorySubject>>,\n settings: Awaited<ReturnType<typeof readSettings>>,\n historyEntries: HistoryEntry[],\n): Promise<HistoryRepairItemReplayContext> {\n const currentItemPath = subject.located?.itemPath ?? null;\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n if (!loadedItem) {\n return {\n currentItemReplay: null,\n currentItemPath,\n matchedChainBefore: null,\n currentItemRawBeforeLock: null,\n loadedItem: null,\n };\n }\n const currentItemReplay = toReplayDocument(loadedItem.document);\n const lastOriginalAfterHash = historyEntries[historyEntries.length - 1]?.after_hash;\n return {\n currentItemReplay,\n currentItemPath,\n matchedChainBefore: replayHash(currentItemReplay) === lastOriginalAfterHash,\n currentItemRawBeforeLock: loadedItem.raw,\n loadedItem,\n };\n}\n\nfunction buildHistoryRepairMessage(params: {\n message: string | undefined;\n entriesRehashed: number;\n entriesPatchRepaired: number;\n reconcileNeeded: boolean;\n}): string {\n if (typeof params.message === \"string\" && params.message.trim().length > 0) {\n return params.message;\n }\n /* v8 ignore start -- message suffix/plural variants are deterministic formatting fallbacks around the covered repair outcomes */\n return `history-repair re-anchored ${params.entriesRehashed} entr${\n params.entriesRehashed === 1 ? \"y\" : \"ies\"\n }${params.entriesPatchRepaired > 0 ? `, repaired ${params.entriesPatchRepaired} patch(es)` : \"\"}${\n params.reconcileNeeded ? \", reconciled chain with on-disk item\" : \"\"\n }.`;\n /* v8 ignore stop */\n}\n\nfunction buildHistoryRepairEntries(params: {\n reanchorEntries: HistoryEntry[];\n changed: boolean;\n reconcileNeeded: boolean;\n currentItemReplay: ReplayDocument | null;\n finalReplay: ReplayDocument;\n author: string;\n message: string;\n}): { rewrittenEntries: HistoryEntry[]; auditEntryAdded: boolean } {\n const rewrittenEntries: HistoryEntry[] = [...params.reanchorEntries];\n if (!params.changed) {\n return { rewrittenEntries, auditEntryAdded: false };\n }\n const afterReplay = params.reconcileNeeded && params.currentItemReplay ? params.currentItemReplay : params.finalReplay;\n rewrittenEntries.push({\n ts: nowIso(),\n author: params.author,\n op: \"history_repair\",\n patch: params.reconcileNeeded && params.currentItemReplay\n ? (jsonPatch.compare(params.finalReplay, params.currentItemReplay) as HistoryPatchOp[])\n : [],\n before_hash: replayHash(params.finalReplay),\n after_hash: replayHash(afterReplay),\n message: params.message,\n });\n return { rewrittenEntries, auditEntryAdded: true };\n}\n\nfunction collectHistoryRepairWarnings(changed: boolean, skippedOps: number): string[] {\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_repair_no_changes\");\n }\n if (skippedOps > 0) {\n warnings.push(`history_repair_skipped_unresolvable_ops:${skippedOps}`);\n }\n return warnings;\n}\n\nasync function applyHistoryRepairRewrite(params: {\n pmRoot: string;\n subject: Awaited<ReturnType<typeof resolveHistorySubject>>;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>;\n historyRawBeforeLock: string | null;\n currentItemRawBeforeLock: string | null;\n author: string;\n force: boolean | undefined;\n loadedItem: Awaited<ReturnType<typeof readLocatedItem>> | null;\n historyPath: string;\n rewrittenEntries: HistoryEntry[];\n}): Promise<string[]> {\n return executeHistoryRewrite({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItemRawBeforeLock,\n operation: \"history-repair\",\n author: params.author,\n force: params.force,\n itemDocument: params.loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) =>\n writeHistoryRawWithRollback({\n historyPath: params.historyPath,\n nextHistoryRaw: historyEntriesToRaw(params.rewrittenEntries),\n historyRawUnderLock,\n }),\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: params.historyPath,\n scope: \"project\",\n op: \"history_repair:history\",\n }),\n });\n}\n\n/**\n * Implements run history repair for the public runtime surface of this module.\n */\nexport async function runHistoryRepair(\n id: string,\n options: HistoryRepairCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryRepairResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n\n if (!(await pathExists(subject.historyPath))) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const historyEntries = await readHistoryEntries(subject.historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to repair.`, EXIT_CODE.USAGE);\n }\n\n const chainBefore = verifyHistoryChain(historyEntries);\n const reanchor = reanchorHistoryEntries(historyEntries);\n\n const itemReplayContext = await loadHistoryRepairItemReplay(subject, settings, historyEntries);\n\n const finalReplay = reanchor.finalDocument;\n const reconcileNeeded =\n itemReplayContext.currentItemReplay !== null && replayHash(finalReplay) !== replayHash(itemReplayContext.currentItemReplay);\n\n const changed = reanchor.entriesRehashed > 0 || reanchor.entriesPatchRepaired > 0 || reconcileNeeded;\n const author = toAuthor(options.author, settings.author_default);\n const dryRun = Boolean(options.dryRun);\n\n const repairMessage = buildHistoryRepairMessage({\n message: options.message,\n entriesRehashed: reanchor.entriesRehashed,\n entriesPatchRepaired: reanchor.entriesPatchRepaired,\n reconcileNeeded,\n });\n const { rewrittenEntries, auditEntryAdded } = buildHistoryRepairEntries({\n reanchorEntries: reanchor.entries,\n changed,\n reconcileNeeded,\n currentItemReplay: itemReplayContext.currentItemReplay,\n finalReplay,\n author,\n message: repairMessage,\n });\n\n const historyVerify = verifyHistoryChain(rewrittenEntries);\n if (!historyVerify.ok) {\n throw new PmCliError(\n `history-repair produced an invalid rewritten chain (${historyVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n const warnings = collectHistoryRepairWarnings(changed, reanchor.skippedOps);\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await applyHistoryRepairRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock: itemReplayContext.currentItemRawBeforeLock,\n author,\n force: options.force,\n loadedItem: itemReplayContext.loadedItem,\n historyPath: subject.historyPath,\n rewrittenEntries,\n })),\n );\n }\n\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n history: {\n path: subject.historyPath,\n entries_scanned: historyEntries.length,\n chain_drift_before: !chainBefore.ok,\n entries_rehashed: reanchor.entriesRehashed,\n entries_patch_repaired: reanchor.entriesPatchRepaired,\n converted_replace_to_add: reanchor.convertedReplaceToAdd,\n skipped_ops: reanchor.skippedOps,\n reconciled_with_item: reconcileNeeded,\n audit_entry_added: auditEntryAdded,\n verify_ok: historyVerify.ok,\n verify_errors: historyVerify.errors,\n },\n item: {\n exists: itemReplayContext.currentItemPath !== null,\n path: itemReplayContext.currentItemPath,\n matched_chain_before: itemReplayContext.matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n\n/**\n * Documents the history repair all stream result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRepairAllStreamResult {\n id: string;\n outcome: \"repaired\" | \"skipped_clean\" | \"failed\";\n entries_rehashed?: number;\n entries_patch_repaired?: number;\n reconciled_with_item?: boolean;\n error?: string;\n}\n\n/**\n * Documents the history repair all result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRepairAllResult {\n all: true;\n dry_run: boolean;\n scanned_streams: number;\n drifted_streams: number;\n /** One compact row per drifted stream (clean streams are summarized by the counts only). */\n streams: HistoryRepairAllStreamResult[];\n totals: { repaired: number; skipped_clean: number; failed: number };\n warnings: string[];\n generated_at: string;\n}\n\n/**\n * Enforce the `pm history-repair` target contract shared by the CLI and MCP\n * surfaces: exactly one of an item `<id>` or `--all` must be provided.\n */\nexport function assertHistoryRepairTarget(id: string | undefined, all: boolean): void {\n if (all && id !== undefined) {\n throw new PmCliError(\n \"history-repair: <id> and --all are mutually exclusive; pass an item id to repair one stream or --all to repair every drifted stream.\",\n EXIT_CODE.USAGE,\n );\n }\n if (!all && id === undefined) {\n throw new PmCliError(\n \"history-repair: provide an item <id> or pass --all to repair every drifted stream.\",\n EXIT_CODE.USAGE,\n );\n }\n}\n\n/**\n * Bulk drift repair: scan every item's history stream with the same drift scan\n * `pm health` uses, then run the audited single-stream repair (ownership check,\n * lock, no-drift verification, audit marker) for each drifted stream. One\n * failing stream never aborts the rest; failures are collected per row and the\n * caller decides the exit code from `totals.failed`.\n */\nexport async function runHistoryRepairAll(\n options: HistoryRepairCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryRepairAllResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const itemReadWarnings: string[] = [];\n const items = await listAllFrontMatterWithBody(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n itemReadWarnings,\n settings.schema,\n );\n const drift = await scanHistoryDrift(pmRoot, items as Array<ItemMetadata & { body: string }>);\n\n const streams: HistoryRepairAllStreamResult[] = [];\n const totals = { repaired: 0, skipped_clean: 0, failed: 0 };\n for (const driftedId of drift.driftedItems) {\n try {\n const result = await runHistoryRepair(driftedId, options, global);\n /* c8 ignore next -- mixed repaired/clean outcomes depend on live drift composition. */\n const outcome = result.changed ? \"repaired\" : \"skipped_clean\";\n totals[outcome] += 1;\n streams.push({\n id: driftedId,\n outcome,\n entries_rehashed: result.history.entries_rehashed,\n entries_patch_repaired: result.history.entries_patch_repaired,\n reconciled_with_item: result.history.reconciled_with_item,\n });\n } catch (error) {\n totals.failed += 1;\n streams.push({\n id: driftedId,\n outcome: \"failed\",\n /* c8 ignore next -- non-Error throws are normalized in defensive fallback. */\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return {\n all: true,\n dry_run: Boolean(options.dryRun),\n scanned_streams: items.length,\n drifted_streams: drift.driftedItems.length,\n streams,\n totals,\n warnings: [...new Set(itemReadWarnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,eAAe;;;;;;;;AAwEtB,SAAS,SAAS,WAA+B,eAAqB;AAEpE,QAAM,WAAW,a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OAC7D;IACH;EACF;AAEA,SAAO;IACL,KAAK;IACL,SAAS,QAAQ,QAAQ,MAAM;IAC/B,iBAAiB,MAAM;IACvB,iBAAiB,MAAM,aAAa;IACpC;IACA;IACA,UAAU,CAAC,GAAG,IAAI,IAAI,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IACxF,cAAc,OAAM;;AAExB;",
6
6
  "names": ["global"]
7
7
  }
@@ -1,12 +1,10 @@
1
1
  import {
2
+ PmCliError,
2
3
  normalizeItemId
3
- } from "./chunk-EZFKWSC7.js";
4
- import {
5
- PmCliError
6
- } from "./chunk-P5YORJRH.js";
4
+ } from "./chunk-YNCFP5AR.js";
7
5
  import {
8
6
  EXIT_CODE
9
- } from "./chunk-5VVUKE3U.js";
7
+ } from "./chunk-LCFJ7XAM.js";
10
8
 
11
9
  // dist/core/item/parent-reference-policy.js
12
10
  !(function() {
@@ -109,4 +107,4 @@ export {
109
107
  normalizeSprintReleaseFormatPolicy,
110
108
  validateSprintOrReleaseValue
111
109
  };
112
- //# sourceMappingURL=chunk-OWTIRHX4.js.map
110
+ //# sourceMappingURL=chunk-43YSKY75.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../core/item/parent-reference-policy.ts", "../../../../../../../../core/item/sprint-release-format.ts"],
4
4
  "sourcesContent": ["/**\n * @module core/item/parent-reference-policy\n *\n * Defines item parsing, formatting, and lifecycle helpers for Parent Reference Policy.\n */\nimport type { ParentReferencePolicy } from \"../../types/index.js\";\nimport { normalizeItemId } from \"./id.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\n\nconst PLACEHOLDER_REFERENCE_TOKENS = new Set([\"none\", \"null\", \"undefined\"]);\n\n/**\n * Implements normalize parent reference policy for the public runtime surface of this module.\n */\nexport function normalizeParentReferencePolicy(value: string | undefined): ParentReferencePolicy {\n const normalized = value?.trim().toLowerCase().replaceAll(\"-\", \"_\");\n if (normalized === \"warn\" || normalized === \"strict_error\") {\n return normalized;\n }\n if (normalized === \"strict\") {\n return \"strict_error\";\n }\n throw new PmCliError(\n \"Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)\",\n EXIT_CODE.USAGE,\n );\n}\n\n/**\n * Implements normalize parent reference value for the public runtime surface of this module.\n */\nexport function normalizeParentReferenceValue(rawValue: unknown): string {\n if (typeof rawValue !== \"string\") {\n throw new PmCliError(\"--parent must be a string. Use --unset parent to clear this field.\", EXIT_CODE.USAGE);\n }\n const value = rawValue.trim();\n if (value.length === 0) {\n throw new PmCliError(\"--parent must not be empty. Use --parent none to unset.\", EXIT_CODE.USAGE);\n }\n if (isPlaceholderReferenceToken(value)) {\n throw new PmCliError(\n `--parent must not use placeholder token \"${value}\". Use --unset parent to clear this field.`,\n EXIT_CODE.USAGE,\n );\n }\n return value;\n}\n\n/**\n * Detects parent-style placeholder tokens that should never become stored ids.\n */\nexport function isPlaceholderReferenceToken(value: string): boolean {\n return PLACEHOLDER_REFERENCE_TOKENS.has(value.trim().toLowerCase());\n}\n\n/**\n * Implements validate missing parent reference for the public runtime surface of this module.\n */\nexport function validateMissingParentReference(\n parentId: string,\n policy: ParentReferencePolicy,\n): { warnings: string[] } {\n if (policy === \"strict_error\") {\n throw new PmCliError(\n `Parent item \"${parentId}\" was not found. Create it first or use --parent none.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n warnings: [`validation_warning:parent_reference_missing:${parentId}`],\n };\n}\n\n/**\n * Rejects the one-node hierarchy cycle where an item points at itself.\n */\nexport function assertParentReferenceIsNotSelf(itemId: string, parentId: string, prefix: string): void {\n const normalizedItemId = normalizeItemId(itemId, prefix);\n const normalizedParentId = normalizeItemId(parentId, prefix);\n if (normalizedItemId !== normalizedParentId) {\n return;\n }\n const normalizationDetail =\n parentId !== normalizedParentId || itemId !== normalizedItemId\n ? ` (normalized from parent \"${parentId}\" and item \"${itemId}\")`\n : \"\";\n throw new PmCliError(\n `Parent item \"${normalizedParentId}\" cannot be the same as item \"${normalizedItemId}\"${normalizationDetail}. Use --unset parent to clear this field.`,\n EXIT_CODE.USAGE,\n );\n}\n", "/**\n * @module core/item/sprint-release-format\n *\n * Defines item parsing, formatting, and lifecycle helpers for Sprint Release Format.\n */\nimport type { SprintReleaseFormatPolicy } from \"../../types/index.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\n\nconst SPRINT_RELEASE_VALUE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;\nconst SPRINT_RELEASE_MAX_LENGTH = 64;\n\n/**\n * Implements normalize sprint release format policy for the public runtime surface of this module.\n */\nexport function normalizeSprintReleaseFormatPolicy(value: string | undefined): SprintReleaseFormatPolicy {\n const normalized = value?.trim().toLowerCase().replaceAll(\"-\", \"_\");\n if (normalized === \"warn\" || normalized === \"strict_error\") {\n return normalized;\n }\n if (normalized === \"strict\") {\n return \"strict_error\";\n }\n throw new PmCliError(\n \"Config set sprint-release-format-policy requires --policy with one of: warn, strict_error (alias: strict)\",\n EXIT_CODE.USAGE,\n );\n}\n\n/**\n * Implements validate sprint or release value for the public runtime surface of this module.\n */\nexport function validateSprintOrReleaseValue(\n field: \"sprint\" | \"release\",\n rawValue: string,\n policy: SprintReleaseFormatPolicy,\n): { value: string; warnings: string[] } {\n const value = rawValue.trim();\n if (value.length === 0) {\n throw new PmCliError(`--${field} must not be empty. Use --${field} none to unset.`, EXIT_CODE.USAGE);\n }\n const isValid = value.length <= SPRINT_RELEASE_MAX_LENGTH && SPRINT_RELEASE_VALUE_PATTERN.test(value);\n if (isValid) {\n return { value, warnings: [] };\n }\n const guidance = \"Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._/-]* (no spaces).\";\n if (policy === \"strict_error\") {\n throw new PmCliError(`Invalid --${field} value \"${value}\". ${guidance}`, EXIT_CODE.USAGE);\n }\n return {\n value,\n warnings: [`validation_warning:${field}_format:${value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ACd,OACA,UACA,QAAiC;AAEjC,QAAM,QAAQ,SAAS,KAAI;AAC3B,MAAI,MAAM,WAAW,GAAG;AACtB,UAAM,IAAI,WAAW,KAAK,KAAK,6BAA6B,KAAK,mBAAmB,UAAU,KAAK;EACrG;AACA,QAAM,UAAU,MAAM,UAAU,6BAA6B,6BAA6B,KAAK,KAAK;AACpG,MAAI,SAAS;AACX,WAAO,EAAE,OAAO,UAAU,CAAA,EAAE;EAC9B;AACA,QAAM,WAAW;AACjB,MAAI,WAAW,gBAAgB;AAC7B,UAAM,IAAI,WAAW,aAAa,KAAK,WAAW,KAAK,MAAM,QAAQ,IAAI,UAAU,KAAK;EAC1F;AACA,SAAO;IACL;IACA,UAAU,CAAC,sBAAsB,KAAK,WAAW,KAAK,EAAE;;AAE5D;",
6
6
  "names": []
7
7
  }
@@ -1,24 +1,16 @@
1
1
  import {
2
2
  parseAnnotationTextInput,
3
3
  runAnnotationCommand
4
- } from "./chunk-5J2XPTAD.js";
5
- import "./chunk-WW4E2DC3.js";
4
+ } from "./chunk-43SIHQND.js";
6
5
  import {
7
6
  createStdinTokenResolver
8
- } from "./chunk-T3ABIMGW.js";
9
- import "./chunk-EEY54JMF.js";
10
- import "./chunk-3U3VEWK6.js";
11
- import "./chunk-EZFKWSC7.js";
12
- import "./chunk-DRBV5UC2.js";
13
- import "./chunk-P5YORJRH.js";
14
- import "./chunk-7C2O74AE.js";
15
- import "./chunk-5VVUKE3U.js";
7
+ } from "./chunk-2TILG6F2.js";
16
8
 
17
9
  // dist/cli/commands/notes.js
18
10
  !(function() {
19
11
  try {
20
12
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
21
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "663f833c-36de-5ef9-8ed7-4ff5c2b55110");
13
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "a43d68a5-885e-54f6-b266-03d8debc1a3a");
22
14
  } catch (e2) {
23
15
  }
24
16
  })();
@@ -27,7 +19,7 @@ async function runNotes(id, options, global2) {
27
19
  const addInput = options.add === void 0 ? void 0 : await stdinResolver.resolveValue(options.add, "--add");
28
20
  return runAnnotationCommand(id, options, global2, {
29
21
  // addInput is defined whenever options.add is defined (see resolveValue), so the cast is safe.
30
- input: options.add === void 0 ? { mode: "list" } : { mode: "add", value: addInput, emptyFlag: "--add" },
22
+ input: options.add === void 0 ? { mode: "list" } : { mode: "add", value: addInput, rawValue: options.add, emptyFlag: "--add" },
31
23
  collectionKey: "notes",
32
24
  op: "note_add",
33
25
  parseText: (raw) => parseAnnotationTextInput(raw),
@@ -42,7 +34,8 @@ async function runNotes(id, options, global2) {
42
34
  }
43
35
  });
44
36
  }
37
+
45
38
  export {
46
39
  runNotes
47
40
  };
48
- //# sourceMappingURL=notes-72YXN5JX.js.map
41
+ //# sourceMappingURL=chunk-4BKDAEDF.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/notes.ts"],
4
- "sourcesContent": ["/**\n * @module cli/commands/notes\n *\n * Implements the pm notes command surface and its agent-facing runtime behavior.\n */\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { createStdinTokenResolver } from \"../../core/item/parse.js\";\nimport type { LogNote } from \"../../types/index.js\";\nimport { parseAnnotationTextInput, runAnnotationCommand } from \"./annotation-command.js\";\n\n/**\n * Documents the notes command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface NotesCommandOptions {\n add?: string;\n limit?: string;\n author?: string;\n message?: string;\n allowAuditNote?: boolean;\n allowAuditComment?: boolean;\n force?: boolean;\n}\n\n/**\n * Documents the notes result payload exchanged by command, SDK, and package integrations.\n */\nexport interface NotesResult {\n id: string;\n notes: LogNote[];\n count: number;\n}\n\n/**\n * Implements run notes for the public runtime surface of this module.\n */\nexport async function runNotes(id: string, options: NotesCommandOptions, global: GlobalOptions): Promise<NotesResult> {\n const stdinResolver = createStdinTokenResolver();\n const addInput = options.add === undefined ? undefined : await stdinResolver.resolveValue(options.add, \"--add\");\n\n return runAnnotationCommand<\"notes\", LogNote>(id, options, global, {\n // addInput is defined whenever options.add is defined (see resolveValue), so the cast is safe.\n input: options.add === undefined ? { mode: \"list\" } : { mode: \"add\", value: addInput as string, emptyFlag: \"--add\" },\n collectionKey: \"notes\",\n op: \"note_add\",\n parseText: (raw) => parseAnnotationTextInput(raw),\n allowAuditBypass: Boolean(options.allowAuditNote || options.allowAuditComment),\n conflictGuidance: {\n required:\n \"For append-only note audits on another owner's item, prefer --allow-audit-note (legacy alias: --allow-audit-comment) before considering --force.\",\n examples: ['pm notes pm-a1b2 --add \"audit note\" --author \"reviewer\" --allow-audit-note'],\n nextSteps: [\n \"Retry with --allow-audit-note (or legacy --allow-audit-comment) for append-only note audits that do not mutate item metadata beyond notes.\",\n \"Use --force only when an ownership override is explicitly approved.\",\n ],\n },\n });\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAsB,SAAS,IAAY,SAA8BA,SAAqB;AAC5F,QAAM,gBAAgB,yBAAwB;AAC9C,QAAM,WAAW,QAAQ,QAAQ,SAAY,SAAY,MAAM,cAAc,aAAa,QAAQ,KAAK,OAAO;AAE9G,SAAO,qBAAuC,IAAI,SAASA,SAAQ;;IAEjE,OAAO,QAAQ,QAAQ,SAAY,EAAE,MAAM,OAAM,IAAK,EAAE,MAAM,OAAO,OAAO,UAAoB,WAAW,QAAO;IAClH,eAAe;IACf,IAAI;IACJ,WAAW,CAAC,QAAQ,yBAAyB,GAAG;IAChD,kBAAkB,QAAQ,QAAQ,kBAAkB,QAAQ,iBAAiB;IAC7E,kBAAkB;MAChB,UACE;MACF,UAAU,CAAC,4EAA4E;MACvF,WAAW;QACT;QACA;;;GAGL;AACH;",
4
+ "sourcesContent": ["/**\n * @module cli/commands/notes\n *\n * Implements the pm notes command surface and its agent-facing runtime behavior.\n */\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { createStdinTokenResolver } from \"../../core/item/parse.js\";\nimport type { LogNote } from \"../../types/index.js\";\nimport { parseAnnotationTextInput, runAnnotationCommand } from \"./annotation-command.js\";\n\n/**\n * Documents the notes command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface NotesCommandOptions {\n add?: string;\n limit?: string;\n author?: string;\n message?: string;\n allowAuditNote?: boolean;\n allowAuditComment?: boolean;\n force?: boolean;\n}\n\n/**\n * Documents the notes result payload exchanged by command, SDK, and package integrations.\n */\nexport interface NotesResult {\n id: string;\n notes: LogNote[];\n count: number;\n}\n\n/**\n * Implements run notes for the public runtime surface of this module.\n */\nexport async function runNotes(id: string, options: NotesCommandOptions, global: GlobalOptions): Promise<NotesResult> {\n const stdinResolver = createStdinTokenResolver();\n const addInput = options.add === undefined ? undefined : await stdinResolver.resolveValue(options.add, \"--add\");\n\n return runAnnotationCommand<\"notes\", LogNote>(id, options, global, {\n // addInput is defined whenever options.add is defined (see resolveValue), so the cast is safe.\n input: options.add === undefined\n ? { mode: \"list\" }\n : { mode: \"add\", value: addInput as string, rawValue: options.add, emptyFlag: \"--add\" },\n collectionKey: \"notes\",\n op: \"note_add\",\n parseText: (raw) => parseAnnotationTextInput(raw),\n allowAuditBypass: Boolean(options.allowAuditNote || options.allowAuditComment),\n conflictGuidance: {\n required:\n \"For append-only note audits on another owner's item, prefer --allow-audit-note (legacy alias: --allow-audit-comment) before considering --force.\",\n examples: ['pm notes pm-a1b2 --add \"audit note\" --author \"reviewer\" --allow-audit-note'],\n nextSteps: [\n \"Retry with --allow-audit-note (or legacy --allow-audit-comment) for append-only note audits that do not mutate item metadata beyond notes.\",\n \"Use --force only when an ownership override is explicitly approved.\",\n ],\n },\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAmCA,eAAsB,SAAS,IAAY,SAA8BA,SAAqB;AAC5F,QAAM,gBAAgB,yBAAwB;AAC9C,QAAM,WAAW,QAAQ,QAAQ,SAAY,SAAY,MAAM,cAAc,aAAa,QAAQ,KAAK,OAAO;AAE9G,SAAO,qBAAuC,IAAI,SAASA,SAAQ;;IAEjE,OAAO,QAAQ,QAAQ,SACnB,EAAE,MAAM,OAAM,IACd,EAAE,MAAM,OAAO,OAAO,UAAoB,UAAU,QAAQ,KAAK,WAAW,QAAO;IACvF,eAAe;IACf,IAAI;IACJ,WAAW,CAAC,QAAQ,yBAAyB,GAAG;IAChD,kBAAkB,QAAQ,QAAQ,kBAAkB,QAAQ,iBAAiB;IAC7E,kBAAkB;MAChB,UACE;MACF,UAAU,CAAC,4EAA4E;MACvF,WAAW;QACT;QACA;;;GAGL;AACH;",
6
6
  "names": ["global"]
7
7
  }
@@ -1,47 +1,32 @@
1
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]="36947f0b-c1fc-5c0e-8d0e-bd968315cecc")}catch(e){}}();
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]="0a9c0e97-1d91-55f1-830c-2822eb0a32bb")}catch(e){}}();
3
3
  import {
4
4
  createCheckpointId,
5
5
  loadMutationCheckpoint,
6
6
  restoreCheckpointItems,
7
7
  writeMutationCheckpoint
8
- } from "./chunk-S5AYOUT5.js";
8
+ } from "./chunk-3G6UMXT3.js";
9
9
  import {
10
10
  runRestore
11
- } from "./chunk-HBYZDSK5.js";
12
- import {
13
- resolveAuthor
14
- } from "./chunk-T5RRNDA7.js";
15
- import "./chunk-T3F4DF23.js";
16
- import "./chunk-BFVHCAOO.js";
11
+ } from "./chunk-EMXPI36L.js";
17
12
  import {
18
13
  runClose
19
- } from "./chunk-K3AGVXSF.js";
14
+ } from "./chunk-6LCJRGPD.js";
20
15
  import {
21
- hasListFilters
22
- } from "./chunk-VY3VQ22F.js";
23
- import "./chunk-N6DNM2FA.js";
16
+ resolveAuthor
17
+ } from "./chunk-T5RRNDA7.js";
24
18
  import {
19
+ hasListFilters,
25
20
  runList
26
- } from "./chunk-YSAH5FY5.js";
27
- import "./chunk-QB7XMHJW.js";
28
- import "./chunk-5JE6SMYS.js";
29
- import "./chunk-YFIE7YK6.js";
30
- import {
31
- listAllFrontMatterLight
32
- } from "./chunk-57C2RLW5.js";
33
- import {
34
- isTerminalStatus
35
- } from "./chunk-HK72NWAD.js";
36
- import {
37
- nowIso
38
- } from "./chunk-FJRKQREY.js";
21
+ } from "./chunk-RY7PTTUB.js";
39
22
  import {
40
23
  PmCliError,
41
24
  getActiveExtensionRegistrations,
25
+ isTerminalStatus,
26
+ listAllFrontMatterLight,
27
+ nowIso,
42
28
  readSettings
43
- } from "./chunk-US3T3W5J.js";
44
- import "./chunk-NNHHXJB2.js";
29
+ } from "./chunk-GH73UOSJ.js";
45
30
  import {
46
31
  EXIT_CODE,
47
32
  getSettingsPath,
@@ -50,7 +35,7 @@ import {
50
35
  resolvePmRoot,
51
36
  resolveRuntimeStatusRegistry,
52
37
  toErrorMessage
53
- } from "./chunk-YD5FML7K.js";
38
+ } from "./chunk-UO7XAZK6.js";
54
39
 
55
40
  // dist/cli/commands/close-many.js
56
41
  var CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION = 1;
@@ -388,10 +373,11 @@ var _testOnly = {
388
373
  rejectBlankIdsFilter,
389
374
  resolveReason
390
375
  };
376
+
391
377
  export {
392
- _testOnly,
393
- runCloseMany
378
+ runCloseMany,
379
+ _testOnly
394
380
  };
395
- //# sourceMappingURL=close-many-AP4MWU36.js.map
381
+ //# sourceMappingURL=chunk-4IQKDKGE.js.map
396
382
 
397
- //# debugId=36947f0b-c1fc-5c0e-8d0e-bd968315cecc
383
+ //# debugId=0a9c0e97-1d91-55f1-830c-2822eb0a32bb
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../cli/commands/close-many.ts"],"sourcesContent":["/**\n * @module cli/commands/close-many\n *\n * Implements the pm close many command surface and its agent-facing runtime behavior.\n */\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport {\n createCheckpointId,\n loadMutationCheckpoint,\n restoreCheckpointItems,\n writeMutationCheckpoint,\n type MutationCheckpointItem,\n} from \"../../core/checkpoint/mutation-checkpoint.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { isTerminalStatus } from \"../../core/item/status.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { resolveRuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { toErrorMessage } from \"../../core/shared/primitives.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { runClose, type CloseCommandOptions } from \"./close.js\";\nimport { hasListFilters } from \"./list-filter-shared.js\";\nimport { runList, type ListOptions, type ListedItem } from \"./list.js\";\nimport { runRestore } from \"./restore.js\";\n\nconst CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION = 1;\nconst CLOSE_MANY_CHECKPOINT_SUBDIR = \"close-many\";\n\nconst CLOSE_MANY_FILTER_GUIDANCE = [\n \"--filter-status\",\n \"--filter-type\",\n \"--filter-tag\",\n \"--filter-priority\",\n \"--filter-sprint\",\n \"--filter-release\",\n \"--filter-parent\",\n \"--filter-assignee\",\n \"--filter-updated-before\",\n \"--ids\",\n].join(\", \");\n\n/**\n * Documents the close many command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseManyCommandOptions {\n status?: string;\n list?: ListOptions;\n reason?: string;\n resolution?: string;\n expectedResult?: string;\n actualResult?: string;\n validateClose?: string;\n author?: string;\n message?: string;\n force?: boolean;\n dryRun?: boolean;\n rollback?: string;\n checkpoint?: boolean;\n}\n\ninterface CloseManyPlanRow {\n id: string;\n title: string;\n status: string;\n action: \"close\" | \"skip\";\n skip_reason?: string;\n active_child_ids?: string[];\n}\n\ninterface CloseManyApplyRow {\n id: string;\n status: \"closed\" | \"skipped\" | \"failed\";\n skip_reason?: string;\n changed_fields?: string[];\n warnings?: string[];\n error?: string;\n}\n\ninterface CloseManyPlanContext {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>;\n reason: string | undefined;\n validateCloseMode: string | undefined;\n force: boolean;\n listed: Awaited<ReturnType<typeof runList>>;\n matched: ListedItem[];\n planRows: CloseManyPlanRow[];\n}\n\n/**\n * Documents the close many result payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseManyResult {\n mode: \"dry_run\" | \"apply\" | \"rollback\";\n matched_count: number;\n dry_run: boolean;\n reason?: string;\n filters?: Record<string, unknown>;\n validate_close?: string;\n item_plans?: CloseManyPlanRow[];\n checkpoint?: {\n id: string;\n created_at: string;\n path: string;\n rollback_command: string;\n };\n closed_count?: number;\n skipped_count?: number;\n failed_count?: number;\n restored_count?: number;\n rollback_checkpoint_id?: string;\n rows?: CloseManyApplyRow[] | Array<{ id: string; status: \"restored\" | \"failed\"; changed_fields?: string[]; warnings?: string[]; error?: string }>;\n ids: string[];\n}\n\nfunction hasCloseManyFilters(list: ListOptions | undefined, status: string | undefined): boolean {\n return hasListFilters(list, status, { includePagination: false });\n}\n\nfunction hasCloseManyRollbackConflicts(list: ListOptions | undefined, status: string | undefined): boolean {\n return hasListFilters(list, status);\n}\n\nfunction rejectBlankIdsFilter(list: ListOptions | undefined): void {\n if (list?.ids != null && String(list.ids).trim().length === 0) {\n throw new PmCliError(\"--ids requires at least one non-empty item ID\", EXIT_CODE.USAGE);\n }\n}\n\nfunction activeListOptions(list: ListOptions | undefined): ListOptions {\n const active: ListOptions = {};\n if (!list) {\n return active;\n }\n for (const [key, value] of Object.entries(list) as Array<[keyof ListOptions, unknown]>) {\n if (value == null || (typeof value === \"string\" && !value.split(\",\").some((entry) => entry.trim().length > 0))) {\n continue;\n }\n (active as Record<string, unknown>)[key] = value;\n }\n return active;\n}\n\nfunction resolveReason(reason: unknown, required: boolean): string | undefined {\n const trimmed = String(reason ?? \"\").trim();\n if (trimmed.length > 0) {\n return trimmed;\n }\n if (required) {\n throw new PmCliError(\n \"pm close-many requires a shared close reason via --reason because governance.require_close_reason is enabled.\",\n EXIT_CODE.USAGE,\n {\n code: \"close_reason_required\",\n required: \"Provide a shared closing summary via --reason for the whole batch.\",\n why: \"governance.require_close_reason is enabled, so every close must record why the items are done.\",\n examples: [\n 'pm close-many --filter-sprint S-12 --reason \"Sprint S-12 acceptance criteria met\"',\n 'pm close-many --ids pm-a,pm-b --reason \"Superseded by redesign\"',\n ],\n nextSteps: [\n \"Re-run with --reason describing the shared outcome.\",\n \"To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled\",\n ],\n },\n );\n }\n return undefined;\n}\n\n// Build a parent -> non-terminal child id map in a single light scan so each\n// matched parent can be annotated with the active children that closing it\n// would orphan (the same signal runClose surfaces per item on apply).\nasync function buildActiveChildrenByParent(\n pmRoot: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n): Promise<{ childrenByParent: Map<string, string[]>; parentByChild: Map<string, string> }> {\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const items = await listAllFrontMatterLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n settings.schema,\n );\n const childrenByParent = new Map<string, string[]>();\n const parentByChild = new Map<string, string>();\n for (const item of items) {\n if (typeof item.parent !== \"string\" || item.parent.length === 0) {\n continue;\n }\n parentByChild.set(item.id, item.parent);\n if (isTerminalStatus(item.status, statusRegistry)) {\n continue;\n }\n const existing = childrenByParent.get(item.parent);\n if (existing) {\n existing.push(item.id);\n } else {\n childrenByParent.set(item.parent, [item.id]);\n }\n }\n for (const ids of childrenByParent.values()) {\n ids.sort((left, right) => left.localeCompare(right));\n }\n return { childrenByParent, parentByChild };\n}\n\nfunction hierarchyDepth(id: string, parentByChild: Map<string, string>, cache?: Map<string, number>): number {\n const cached = cache?.get(id);\n if (cached !== undefined) {\n return cached;\n }\n let depth = 0;\n let current = parentByChild.get(id);\n const path: string[] = [];\n const visited = new Set<string>();\n let hasCycle = false;\n while (current !== undefined && !visited.has(current)) {\n const cachedCurrent = cache?.get(current);\n if (cachedCurrent !== undefined) {\n depth += cachedCurrent + 1;\n break;\n }\n visited.add(current);\n path.push(current);\n depth += 1;\n current = parentByChild.get(current);\n }\n if (current !== undefined && visited.has(current)) {\n hasCycle = true;\n }\n if (!hasCycle) {\n cache?.set(id, depth);\n for (const [index, ancestorId] of path.entries()) {\n cache?.set(ancestorId, depth - index - 1);\n }\n }\n return depth;\n}\n\nasync function runCloseManyRollback(params: {\n pmRoot: string;\n rollbackId: string;\n options: CloseManyCommandOptions;\n global: GlobalOptions;\n}): Promise<CloseManyResult> {\n const checkpoint = await loadMutationCheckpoint(\n params.pmRoot,\n CLOSE_MANY_CHECKPOINT_SUBDIR,\n params.rollbackId,\n CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION,\n );\n const restoreMessage = params.options.message ?? `Rollback close-many checkpoint ${checkpoint.id}`;\n const rollback = await restoreCheckpointItems(checkpoint.items, (id, targetUpdatedAt) =>\n runRestore(id, targetUpdatedAt, { author: params.options.author, message: restoreMessage, force: true }, params.global),\n );\n return {\n mode: \"rollback\",\n matched_count: checkpoint.items.length,\n dry_run: false,\n rollback_checkpoint_id: checkpoint.id,\n checkpoint: {\n id: checkpoint.id,\n created_at: checkpoint.created_at,\n path: checkpoint.path,\n rollback_command: `pm close-many --rollback ${checkpoint.id}`,\n },\n restored_count: rollback.restored_ids.length,\n failed_count: rollback.failed_count,\n rows: rollback.rows,\n ids: rollback.restored_ids,\n };\n}\n\nfunction planCloseManyRows(\n matched: ListedItem[],\n childrenByParent: Map<string, string[]>,\n closePlannedIds: Set<string>,\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>,\n force: boolean,\n): CloseManyPlanRow[] {\n return matched.map((item) => {\n const activeChildIds = (childrenByParent.get(item.id) ?? []).filter((childId) => !closePlannedIds.has(childId));\n const willSkip = !canCloseManyItem(item, statusRegistry, force);\n return {\n id: item.id,\n title: typeof item.title === \"string\" ? item.title : \"\",\n status: item.status,\n action: willSkip ? \"skip\" : \"close\",\n ...(willSkip ? { skip_reason: \"already_terminal\" } : {}),\n ...(activeChildIds.length > 0 ? { active_child_ids: activeChildIds } : {}),\n };\n });\n}\n\nasync function writeCloseManyCheckpoint(params: {\n pmRoot: string;\n checkpointId: string;\n nowValue: string;\n options: CloseManyCommandOptions;\n reason: string | undefined;\n filters: Record<string, unknown>;\n checkpointItems: MutationCheckpointItem[];\n}): Promise<CloseManyResult[\"checkpoint\"]> {\n const checkpointPath = await writeMutationCheckpoint(params.pmRoot, CLOSE_MANY_CHECKPOINT_SUBDIR, params.checkpointId, {\n schema_version: CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION,\n id: params.checkpointId,\n created_at: params.nowValue,\n author: resolveAuthor(params.options.author, \"unknown\"),\n ...(params.reason !== undefined ? { reason: params.reason } : {}),\n filters: params.filters,\n items: params.checkpointItems,\n });\n return {\n id: params.checkpointId,\n created_at: params.nowValue,\n path: checkpointPath,\n rollback_command: `pm close-many --rollback ${params.checkpointId}`,\n };\n}\n\nasync function applyCloseManyRows(params: {\n matched: ListedItem[];\n closableIds: Set<string>;\n reason: string | undefined;\n closeOptions: CloseCommandOptions;\n global: GlobalOptions;\n}): Promise<{ rows: CloseManyApplyRow[]; closedIds: string[] }> {\n const rows: CloseManyApplyRow[] = [];\n const closedIds: string[] = [];\n for (const item of params.matched) {\n if (!params.closableIds.has(item.id)) {\n rows.push({ id: item.id, status: \"skipped\", skip_reason: \"already_terminal\" });\n continue;\n }\n try {\n const result = await runClose(item.id, params.reason, params.closeOptions, params.global);\n rows.push({\n id: item.id,\n status: \"closed\",\n changed_fields: result.changed_fields,\n ...(result.warnings && result.warnings.length > 0 ? { warnings: result.warnings } : {}),\n });\n closedIds.push(item.id);\n } catch (error: unknown) {\n rows.push({ id: item.id, status: \"failed\", error: toErrorMessage(error) });\n }\n }\n return { rows, closedIds };\n}\n\nfunction resolveCloseManyRollbackId(options: CloseManyCommandOptions): string | undefined {\n return typeof options.rollback === \"string\" ? options.rollback : undefined;\n}\n\nfunction validateCloseManyRollbackOptions(options: CloseManyCommandOptions, rollbackId: string): void {\n if (rollbackId.trim().length === 0) {\n throw new PmCliError(\"--rollback requires a checkpoint id\", EXIT_CODE.USAGE);\n }\n if (options.dryRun === true) {\n throw new PmCliError(\"--dry-run cannot be combined with --rollback\", EXIT_CODE.USAGE);\n }\n if (hasCloseManyRollbackConflicts(options.list, options.status)) {\n throw new PmCliError(\"Rollback mode does not accept filter options\", EXIT_CODE.USAGE);\n }\n}\n\nfunction assertCloseManyHasFilters(options: CloseManyCommandOptions): void {\n if (hasCloseManyFilters(options.list, options.status)) {\n return;\n }\n throw new PmCliError(\n `close-many requires at least one filter to scope the close (for example: ${CLOSE_MANY_FILTER_GUIDANCE}). Refusing to match every item.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction sortCloseManyMatchedItems(matched: ListedItem[], parentByChild: Map<string, string>): ListedItem[] {\n const depthCache = new Map<string, number>();\n return [...matched].sort((left, right) => {\n const depthDelta = hierarchyDepth(right.id, parentByChild, depthCache) - hierarchyDepth(left.id, parentByChild, depthCache);\n return depthDelta !== 0 ? depthDelta : left.id.localeCompare(right.id);\n });\n}\n\nfunction canCloseManyItem(\n item: ListedItem,\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>,\n force: boolean,\n): boolean {\n return force || !isTerminalStatus(item.status, statusRegistry);\n}\n\nfunction resolveCloseManyPlannedIds(\n matched: ListedItem[],\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>,\n force: boolean,\n): Set<string> {\n return new Set(matched.filter((item) => canCloseManyItem(item, statusRegistry, force)).map((item) => item.id));\n}\n\nasync function buildCloseManyPlanContext(params: {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n options: CloseManyCommandOptions;\n global: GlobalOptions;\n}): Promise<CloseManyPlanContext> {\n assertCloseManyHasFilters(params.options);\n const statusRegistry = resolveRuntimeStatusRegistry(params.settings.schema);\n const reason = resolveReason(params.options.reason, params.settings.governance.require_close_reason);\n const force = params.options.force === true;\n const listed = await runList(params.options.status, activeListOptions(params.options.list), params.global);\n const { childrenByParent, parentByChild } = await buildActiveChildrenByParent(params.pmRoot, params.settings);\n const matched = sortCloseManyMatchedItems(listed.items as ListedItem[], parentByChild);\n const closePlannedIds = resolveCloseManyPlannedIds(matched, statusRegistry, force);\n return {\n pmRoot: params.pmRoot,\n settings: params.settings,\n statusRegistry,\n reason,\n validateCloseMode: params.options.validateClose,\n force,\n listed,\n matched,\n planRows: planCloseManyRows(matched, childrenByParent, closePlannedIds, statusRegistry, force),\n };\n}\n\nfunction buildCloseManyDryRunResult(context: CloseManyPlanContext): CloseManyResult {\n return {\n mode: \"dry_run\",\n matched_count: context.matched.length,\n dry_run: true,\n ...(context.reason !== undefined ? { reason: context.reason } : {}),\n filters: context.listed.filters,\n ...(context.validateCloseMode ? { validate_close: context.validateCloseMode } : {}),\n item_plans: context.planRows,\n ids: [],\n };\n}\n\nasync function resolveCloseManyCheckpointInfo(params: {\n context: CloseManyPlanContext;\n options: CloseManyCommandOptions;\n closableIds: Set<string>;\n checkpointId: string;\n nowValue: string;\n}): Promise<CloseManyResult[\"checkpoint\"]> {\n if (params.options.checkpoint === false || params.closableIds.size === 0) {\n return undefined;\n }\n const checkpointItems: MutationCheckpointItem[] = params.context.matched\n .filter((item) => params.closableIds.has(item.id))\n .map((item) => ({ id: item.id, target_updated_at: item.updated_at }));\n return writeCloseManyCheckpoint({\n pmRoot: params.context.pmRoot,\n checkpointId: params.checkpointId,\n nowValue: params.nowValue,\n options: params.options,\n reason: params.context.reason,\n filters: params.context.listed.filters,\n checkpointItems,\n });\n}\n\n/**\n * Implements run close many for the public runtime surface of this module.\n */\nexport async function runCloseMany(options: CloseManyCommandOptions, global: GlobalOptions): Promise<CloseManyResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n const settings = await readSettings(pmRoot);\n\n const dryRun = options.dryRun === true;\n const rollbackId = resolveCloseManyRollbackId(options);\n rejectBlankIdsFilter(options.list);\n\n if (rollbackId !== undefined) {\n validateCloseManyRollbackOptions(options, rollbackId);\n return runCloseManyRollback({ pmRoot, rollbackId, options, global });\n }\n\n const context = await buildCloseManyPlanContext({ pmRoot, settings, options, global });\n\n if (dryRun) {\n return buildCloseManyDryRunResult(context);\n }\n\n const closableIds = new Set(context.planRows.filter((row) => row.action === \"close\").map((row) => row.id));\n const nowValue = nowIso();\n const checkpointId = createCheckpointId(CLOSE_MANY_CHECKPOINT_SUBDIR, nowValue);\n const checkpointInfo = await resolveCloseManyCheckpointInfo({ context, options, closableIds, checkpointId, nowValue });\n\n const closeOptions: CloseCommandOptions = {\n author: options.author,\n message: options.message ?? `close-many apply ${checkpointId}`,\n validateClose: context.validateCloseMode,\n force: context.force,\n resolution: options.resolution,\n expectedResult: options.expectedResult,\n actualResult: options.actualResult,\n };\n\n const { rows, closedIds } = await applyCloseManyRows({\n matched: context.matched,\n closableIds,\n reason: context.reason,\n closeOptions,\n global,\n });\n\n return {\n mode: \"apply\",\n matched_count: context.matched.length,\n dry_run: false,\n ...(context.reason !== undefined ? { reason: context.reason } : {}),\n filters: context.listed.filters,\n ...(context.validateCloseMode ? { validate_close: context.validateCloseMode } : {}),\n ...(checkpointInfo ? { checkpoint: checkpointInfo } : {}),\n closed_count: rows.filter((row) => row.status === \"closed\").length,\n skipped_count: rows.filter((row) => row.status === \"skipped\").length,\n failed_count: rows.filter((row) => row.status === \"failed\").length,\n rows,\n ids: closedIds,\n };\n}\n\nexport const _testOnly = {\n activeListOptions,\n buildActiveChildrenByParent,\n hasCloseManyFilters,\n hasCloseManyRollbackConflicts,\n hierarchyDepth,\n rejectBlankIdsFilter,\n resolveReason,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,uCAAuC;AAC7C,IAAM,+BAA+B;AAErC,IAAM,6BAA6B;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,KAAK,IAAI;AA6EX,SAAS,oBAAoB,MAA+B,QAA0B;AACpF,SAAO,eAAe,MAAM,QAAQ,EAAE,mBAAmB,MAAK,CAAE;AAClE;AAEA,SAAS,8BAA8B,MAA+B,QAA0B;AAC9F,SAAO,eAAe,MAAM,MAAM;AACpC;AAEA,SAAS,qBAAqB,MAA6B;AACzD,MAAI,MAAM,OAAO,QAAQ,OAAO,KAAK,GAAG,EAAE,KAAI,EAAG,WAAW,GAAG;AAC7D,UAAM,IAAI,WAAW,iDAAiD,UAAU,KAAK;EACvF;AACF;AAEA,SAAS,kBAAkB,MAA6B;AACtD,QAAM,SAAsB,CAAA;AAC5B,MAAI,CAAC,MAAM;AACT,WAAO;EACT;AACA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAA0C;AACtF,QAAI,SAAS,QAAS,OAAO,UAAU,YAAY,CAAC,MAAM,MAAM,GAAG,EAAE,KAAK,CAAC,UAAU,MAAM,KAAI,EA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AAa,cAAc,SAAQ,CAAE;AAErH,QAAM,eAAoC;IACxC,QAAQ,QAAQ;IAChB,SAAS,QAAQ,WAAW,oBAAoB,YAAY;IAC5D,eAAe,QAAQ;IACvB,OAAO,QAAQ;IACf,YAAY,QAAQ;IACpB,gBAAgB,QAAQ;IACxB,cAAc,QAAQ;;AAGxB,QAAM,EAAE,MAAM,UAAS,IAAK,MAAM,mBAAmB;IACnD,SAAS,QAAQ;IACjB;IACA,QAAQ,QAAQ;IAChB;IACA;GACD;AAED,SAAO;IACL,MAAM;IACN,eAAe,QAAQ,QAAQ;IAC/B,SAAS;IACT,GAAI,QAAQ,WAAW,SAAY,EAAE,QAAQ,QAAQ,OAAM,IAAK,CAAA;IAChE,SAAS,QAAQ,OAAO;IACxB,GAAI,QAAQ,oBAAoB,EAAE,gBAAgB,QAAQ,kBAAiB,IAAK,CAAA;IAChF,GAAI,iBAAiB,EAAE,YAAY,eAAc,IAAK,CAAA;IACtD,cAAc,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,QAAQ,EAAE;IAC5D,eAAe,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,SAAS,EAAE;IAC9D,cAAc,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,QAAQ,EAAE;IAC5D;IACA,KAAK;;AAET;AAEO,IAAM,YAAY;EACvB;EACA;EACA;EACA;EACA;EACA;EACA","debugId":"36947f0b-c1fc-5c0e-8d0e-bd968315cecc"}
1
+ {"version":3,"sources":["../../../../../../../../cli/commands/close-many.ts"],"sourcesContent":["/**\n * @module cli/commands/close-many\n *\n * Implements the pm close many command surface and its agent-facing runtime behavior.\n */\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport {\n createCheckpointId,\n loadMutationCheckpoint,\n restoreCheckpointItems,\n writeMutationCheckpoint,\n type MutationCheckpointItem,\n} from \"../../core/checkpoint/mutation-checkpoint.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { isTerminalStatus } from \"../../core/item/status.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { resolveRuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { toErrorMessage } from \"../../core/shared/primitives.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { runClose, type CloseCommandOptions } from \"./close.js\";\nimport { hasListFilters } from \"./list-filter-shared.js\";\nimport { runList, type ListOptions, type ListedItem } from \"./list.js\";\nimport { runRestore } from \"./restore.js\";\n\nconst CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION = 1;\nconst CLOSE_MANY_CHECKPOINT_SUBDIR = \"close-many\";\n\nconst CLOSE_MANY_FILTER_GUIDANCE = [\n \"--filter-status\",\n \"--filter-type\",\n \"--filter-tag\",\n \"--filter-priority\",\n \"--filter-sprint\",\n \"--filter-release\",\n \"--filter-parent\",\n \"--filter-assignee\",\n \"--filter-updated-before\",\n \"--ids\",\n].join(\", \");\n\n/**\n * Documents the close many command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseManyCommandOptions {\n status?: string;\n list?: ListOptions;\n reason?: string;\n resolution?: string;\n expectedResult?: string;\n actualResult?: string;\n validateClose?: string;\n author?: string;\n message?: string;\n force?: boolean;\n dryRun?: boolean;\n rollback?: string;\n checkpoint?: boolean;\n}\n\ninterface CloseManyPlanRow {\n id: string;\n title: string;\n status: string;\n action: \"close\" | \"skip\";\n skip_reason?: string;\n active_child_ids?: string[];\n}\n\ninterface CloseManyApplyRow {\n id: string;\n status: \"closed\" | \"skipped\" | \"failed\";\n skip_reason?: string;\n changed_fields?: string[];\n warnings?: string[];\n error?: string;\n}\n\ninterface CloseManyPlanContext {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>;\n reason: string | undefined;\n validateCloseMode: string | undefined;\n force: boolean;\n listed: Awaited<ReturnType<typeof runList>>;\n matched: ListedItem[];\n planRows: CloseManyPlanRow[];\n}\n\n/**\n * Documents the close many result payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseManyResult {\n mode: \"dry_run\" | \"apply\" | \"rollback\";\n matched_count: number;\n dry_run: boolean;\n reason?: string;\n filters?: Record<string, unknown>;\n validate_close?: string;\n item_plans?: CloseManyPlanRow[];\n checkpoint?: {\n id: string;\n created_at: string;\n path: string;\n rollback_command: string;\n };\n closed_count?: number;\n skipped_count?: number;\n failed_count?: number;\n restored_count?: number;\n rollback_checkpoint_id?: string;\n rows?: CloseManyApplyRow[] | Array<{ id: string; status: \"restored\" | \"failed\"; changed_fields?: string[]; warnings?: string[]; error?: string }>;\n ids: string[];\n}\n\nfunction hasCloseManyFilters(list: ListOptions | undefined, status: string | undefined): boolean {\n return hasListFilters(list, status, { includePagination: false });\n}\n\nfunction hasCloseManyRollbackConflicts(list: ListOptions | undefined, status: string | undefined): boolean {\n return hasListFilters(list, status);\n}\n\nfunction rejectBlankIdsFilter(list: ListOptions | undefined): void {\n if (list?.ids != null && String(list.ids).trim().length === 0) {\n throw new PmCliError(\"--ids requires at least one non-empty item ID\", EXIT_CODE.USAGE);\n }\n}\n\nfunction activeListOptions(list: ListOptions | undefined): ListOptions {\n const active: ListOptions = {};\n if (!list) {\n return active;\n }\n for (const [key, value] of Object.entries(list) as Array<[keyof ListOptions, unknown]>) {\n if (value == null || (typeof value === \"string\" && !value.split(\",\").some((entry) => entry.trim().length > 0))) {\n continue;\n }\n (active as Record<string, unknown>)[key] = value;\n }\n return active;\n}\n\nfunction resolveReason(reason: unknown, required: boolean): string | undefined {\n const trimmed = String(reason ?? \"\").trim();\n if (trimmed.length > 0) {\n return trimmed;\n }\n if (required) {\n throw new PmCliError(\n \"pm close-many requires a shared close reason via --reason because governance.require_close_reason is enabled.\",\n EXIT_CODE.USAGE,\n {\n code: \"close_reason_required\",\n required: \"Provide a shared closing summary via --reason for the whole batch.\",\n why: \"governance.require_close_reason is enabled, so every close must record why the items are done.\",\n examples: [\n 'pm close-many --filter-sprint S-12 --reason \"Sprint S-12 acceptance criteria met\"',\n 'pm close-many --ids pm-a,pm-b --reason \"Superseded by redesign\"',\n ],\n nextSteps: [\n \"Re-run with --reason describing the shared outcome.\",\n \"To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled\",\n ],\n },\n );\n }\n return undefined;\n}\n\n// Build a parent -> non-terminal child id map in a single light scan so each\n// matched parent can be annotated with the active children that closing it\n// would orphan (the same signal runClose surfaces per item on apply).\nasync function buildActiveChildrenByParent(\n pmRoot: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n): Promise<{ childrenByParent: Map<string, string[]>; parentByChild: Map<string, string> }> {\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const items = await listAllFrontMatterLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n settings.schema,\n );\n const childrenByParent = new Map<string, string[]>();\n const parentByChild = new Map<string, string>();\n for (const item of items) {\n if (typeof item.parent !== \"string\" || item.parent.length === 0) {\n continue;\n }\n parentByChild.set(item.id, item.parent);\n if (isTerminalStatus(item.status, statusRegistry)) {\n continue;\n }\n const existing = childrenByParent.get(item.parent);\n if (existing) {\n existing.push(item.id);\n } else {\n childrenByParent.set(item.parent, [item.id]);\n }\n }\n for (const ids of childrenByParent.values()) {\n ids.sort((left, right) => left.localeCompare(right));\n }\n return { childrenByParent, parentByChild };\n}\n\nfunction hierarchyDepth(id: string, parentByChild: Map<string, string>, cache?: Map<string, number>): number {\n const cached = cache?.get(id);\n if (cached !== undefined) {\n return cached;\n }\n let depth = 0;\n let current = parentByChild.get(id);\n const path: string[] = [];\n const visited = new Set<string>();\n let hasCycle = false;\n while (current !== undefined && !visited.has(current)) {\n const cachedCurrent = cache?.get(current);\n if (cachedCurrent !== undefined) {\n depth += cachedCurrent + 1;\n break;\n }\n visited.add(current);\n path.push(current);\n depth += 1;\n current = parentByChild.get(current);\n }\n if (current !== undefined && visited.has(current)) {\n hasCycle = true;\n }\n if (!hasCycle) {\n cache?.set(id, depth);\n for (const [index, ancestorId] of path.entries()) {\n cache?.set(ancestorId, depth - index - 1);\n }\n }\n return depth;\n}\n\nasync function runCloseManyRollback(params: {\n pmRoot: string;\n rollbackId: string;\n options: CloseManyCommandOptions;\n global: GlobalOptions;\n}): Promise<CloseManyResult> {\n const checkpoint = await loadMutationCheckpoint(\n params.pmRoot,\n CLOSE_MANY_CHECKPOINT_SUBDIR,\n params.rollbackId,\n CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION,\n );\n const restoreMessage = params.options.message ?? `Rollback close-many checkpoint ${checkpoint.id}`;\n const rollback = await restoreCheckpointItems(checkpoint.items, (id, targetUpdatedAt) =>\n runRestore(id, targetUpdatedAt, { author: params.options.author, message: restoreMessage, force: true }, params.global),\n );\n return {\n mode: \"rollback\",\n matched_count: checkpoint.items.length,\n dry_run: false,\n rollback_checkpoint_id: checkpoint.id,\n checkpoint: {\n id: checkpoint.id,\n created_at: checkpoint.created_at,\n path: checkpoint.path,\n rollback_command: `pm close-many --rollback ${checkpoint.id}`,\n },\n restored_count: rollback.restored_ids.length,\n failed_count: rollback.failed_count,\n rows: rollback.rows,\n ids: rollback.restored_ids,\n };\n}\n\nfunction planCloseManyRows(\n matched: ListedItem[],\n childrenByParent: Map<string, string[]>,\n closePlannedIds: Set<string>,\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>,\n force: boolean,\n): CloseManyPlanRow[] {\n return matched.map((item) => {\n const activeChildIds = (childrenByParent.get(item.id) ?? []).filter((childId) => !closePlannedIds.has(childId));\n const willSkip = !canCloseManyItem(item, statusRegistry, force);\n return {\n id: item.id,\n title: typeof item.title === \"string\" ? item.title : \"\",\n status: item.status,\n action: willSkip ? \"skip\" : \"close\",\n ...(willSkip ? { skip_reason: \"already_terminal\" } : {}),\n ...(activeChildIds.length > 0 ? { active_child_ids: activeChildIds } : {}),\n };\n });\n}\n\nasync function writeCloseManyCheckpoint(params: {\n pmRoot: string;\n checkpointId: string;\n nowValue: string;\n options: CloseManyCommandOptions;\n reason: string | undefined;\n filters: Record<string, unknown>;\n checkpointItems: MutationCheckpointItem[];\n}): Promise<CloseManyResult[\"checkpoint\"]> {\n const checkpointPath = await writeMutationCheckpoint(params.pmRoot, CLOSE_MANY_CHECKPOINT_SUBDIR, params.checkpointId, {\n schema_version: CLOSE_MANY_CHECKPOINT_SCHEMA_VERSION,\n id: params.checkpointId,\n created_at: params.nowValue,\n author: resolveAuthor(params.options.author, \"unknown\"),\n ...(params.reason !== undefined ? { reason: params.reason } : {}),\n filters: params.filters,\n items: params.checkpointItems,\n });\n return {\n id: params.checkpointId,\n created_at: params.nowValue,\n path: checkpointPath,\n rollback_command: `pm close-many --rollback ${params.checkpointId}`,\n };\n}\n\nasync function applyCloseManyRows(params: {\n matched: ListedItem[];\n closableIds: Set<string>;\n reason: string | undefined;\n closeOptions: CloseCommandOptions;\n global: GlobalOptions;\n}): Promise<{ rows: CloseManyApplyRow[]; closedIds: string[] }> {\n const rows: CloseManyApplyRow[] = [];\n const closedIds: string[] = [];\n for (const item of params.matched) {\n if (!params.closableIds.has(item.id)) {\n rows.push({ id: item.id, status: \"skipped\", skip_reason: \"already_terminal\" });\n continue;\n }\n try {\n const result = await runClose(item.id, params.reason, params.closeOptions, params.global);\n rows.push({\n id: item.id,\n status: \"closed\",\n changed_fields: result.changed_fields,\n ...(result.warnings && result.warnings.length > 0 ? { warnings: result.warnings } : {}),\n });\n closedIds.push(item.id);\n } catch (error: unknown) {\n rows.push({ id: item.id, status: \"failed\", error: toErrorMessage(error) });\n }\n }\n return { rows, closedIds };\n}\n\nfunction resolveCloseManyRollbackId(options: CloseManyCommandOptions): string | undefined {\n return typeof options.rollback === \"string\" ? options.rollback : undefined;\n}\n\nfunction validateCloseManyRollbackOptions(options: CloseManyCommandOptions, rollbackId: string): void {\n if (rollbackId.trim().length === 0) {\n throw new PmCliError(\"--rollback requires a checkpoint id\", EXIT_CODE.USAGE);\n }\n if (options.dryRun === true) {\n throw new PmCliError(\"--dry-run cannot be combined with --rollback\", EXIT_CODE.USAGE);\n }\n if (hasCloseManyRollbackConflicts(options.list, options.status)) {\n throw new PmCliError(\"Rollback mode does not accept filter options\", EXIT_CODE.USAGE);\n }\n}\n\nfunction assertCloseManyHasFilters(options: CloseManyCommandOptions): void {\n if (hasCloseManyFilters(options.list, options.status)) {\n return;\n }\n throw new PmCliError(\n `close-many requires at least one filter to scope the close (for example: ${CLOSE_MANY_FILTER_GUIDANCE}). Refusing to match every item.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction sortCloseManyMatchedItems(matched: ListedItem[], parentByChild: Map<string, string>): ListedItem[] {\n const depthCache = new Map<string, number>();\n return [...matched].sort((left, right) => {\n const depthDelta = hierarchyDepth(right.id, parentByChild, depthCache) - hierarchyDepth(left.id, parentByChild, depthCache);\n return depthDelta !== 0 ? depthDelta : left.id.localeCompare(right.id);\n });\n}\n\nfunction canCloseManyItem(\n item: ListedItem,\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>,\n force: boolean,\n): boolean {\n return force || !isTerminalStatus(item.status, statusRegistry);\n}\n\nfunction resolveCloseManyPlannedIds(\n matched: ListedItem[],\n statusRegistry: ReturnType<typeof resolveRuntimeStatusRegistry>,\n force: boolean,\n): Set<string> {\n return new Set(matched.filter((item) => canCloseManyItem(item, statusRegistry, force)).map((item) => item.id));\n}\n\nasync function buildCloseManyPlanContext(params: {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n options: CloseManyCommandOptions;\n global: GlobalOptions;\n}): Promise<CloseManyPlanContext> {\n assertCloseManyHasFilters(params.options);\n const statusRegistry = resolveRuntimeStatusRegistry(params.settings.schema);\n const reason = resolveReason(params.options.reason, params.settings.governance.require_close_reason);\n const force = params.options.force === true;\n const listed = await runList(params.options.status, activeListOptions(params.options.list), params.global);\n const { childrenByParent, parentByChild } = await buildActiveChildrenByParent(params.pmRoot, params.settings);\n const matched = sortCloseManyMatchedItems(listed.items as ListedItem[], parentByChild);\n const closePlannedIds = resolveCloseManyPlannedIds(matched, statusRegistry, force);\n return {\n pmRoot: params.pmRoot,\n settings: params.settings,\n statusRegistry,\n reason,\n validateCloseMode: params.options.validateClose,\n force,\n listed,\n matched,\n planRows: planCloseManyRows(matched, childrenByParent, closePlannedIds, statusRegistry, force),\n };\n}\n\nfunction buildCloseManyDryRunResult(context: CloseManyPlanContext): CloseManyResult {\n return {\n mode: \"dry_run\",\n matched_count: context.matched.length,\n dry_run: true,\n ...(context.reason !== undefined ? { reason: context.reason } : {}),\n filters: context.listed.filters,\n ...(context.validateCloseMode ? { validate_close: context.validateCloseMode } : {}),\n item_plans: context.planRows,\n ids: [],\n };\n}\n\nasync function resolveCloseManyCheckpointInfo(params: {\n context: CloseManyPlanContext;\n options: CloseManyCommandOptions;\n closableIds: Set<string>;\n checkpointId: string;\n nowValue: string;\n}): Promise<CloseManyResult[\"checkpoint\"]> {\n if (params.options.checkpoint === false || params.closableIds.size === 0) {\n return undefined;\n }\n const checkpointItems: MutationCheckpointItem[] = params.context.matched\n .filter((item) => params.closableIds.has(item.id))\n .map((item) => ({ id: item.id, target_updated_at: item.updated_at }));\n return writeCloseManyCheckpoint({\n pmRoot: params.context.pmRoot,\n checkpointId: params.checkpointId,\n nowValue: params.nowValue,\n options: params.options,\n reason: params.context.reason,\n filters: params.context.listed.filters,\n checkpointItems,\n });\n}\n\n/**\n * Implements run close many for the public runtime surface of this module.\n */\nexport async function runCloseMany(options: CloseManyCommandOptions, global: GlobalOptions): Promise<CloseManyResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n const settings = await readSettings(pmRoot);\n\n const dryRun = options.dryRun === true;\n const rollbackId = resolveCloseManyRollbackId(options);\n rejectBlankIdsFilter(options.list);\n\n if (rollbackId !== undefined) {\n validateCloseManyRollbackOptions(options, rollbackId);\n return runCloseManyRollback({ pmRoot, rollbackId, options, global });\n }\n\n const context = await buildCloseManyPlanContext({ pmRoot, settings, options, global });\n\n if (dryRun) {\n return buildCloseManyDryRunResult(context);\n }\n\n const closableIds = new Set(context.planRows.filter((row) => row.action === \"close\").map((row) => row.id));\n const nowValue = nowIso();\n const checkpointId = createCheckpointId(CLOSE_MANY_CHECKPOINT_SUBDIR, nowValue);\n const checkpointInfo = await resolveCloseManyCheckpointInfo({ context, options, closableIds, checkpointId, nowValue });\n\n const closeOptions: CloseCommandOptions = {\n author: options.author,\n message: options.message ?? `close-many apply ${checkpointId}`,\n validateClose: context.validateCloseMode,\n force: context.force,\n resolution: options.resolution,\n expectedResult: options.expectedResult,\n actualResult: options.actualResult,\n };\n\n const { rows, closedIds } = await applyCloseManyRows({\n matched: context.matched,\n closableIds,\n reason: context.reason,\n closeOptions,\n global,\n });\n\n return {\n mode: \"apply\",\n matched_count: context.matched.length,\n dry_run: false,\n ...(context.reason !== undefined ? { reason: context.reason } : {}),\n filters: context.listed.filters,\n ...(context.validateCloseMode ? { validate_close: context.validateCloseMode } : {}),\n ...(checkpointInfo ? { checkpoint: checkpointInfo } : {}),\n closed_count: rows.filter((row) => row.status === \"closed\").length,\n skipped_count: rows.filter((row) => row.status === \"skipped\").length,\n failed_count: rows.filter((row) => row.status === \"failed\").length,\n rows,\n ids: closedIds,\n };\n}\n\nexport const _testOnly = {\n activeListOptions,\n buildActiveChildrenByParent,\n hasCloseManyFilters,\n hasCloseManyRollbackConflicts,\n hierarchyD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AAE,QAAQ,QAAQ,OAAM,IAAK,CAAA;IAChE,SAAS,QAAQ,OAAO;IACxB,GAAI,QAAQ,oBAAoB,EAAE,gBAAgB,QAAQ,kBAAiB,IAAK,CAAA;IAChF,GAAI,iBAAiB,EAAE,YAAY,eAAc,IAAK,CAAA;IACtD,cAAc,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,QAAQ,EAAE;IAC5D,eAAe,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,SAAS,EAAE;IAC9D,cAAc,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,QAAQ,EAAE;IAC5D;IACA,KAAK;;AAET;AAEO,IAAM,YAAY;EACvB;EACA;EACA;EACA;EACA;EACA;EACA","debugId":"0a9c0e97-1d91-55f1-830c-2822eb0a32bb"}
@@ -1,12 +1,10 @@
1
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]="d421445d-3cb5-5ecd-84ba-b8af7024405c")}catch(e){}}();
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]="cc3f7b67-0ee9-5ac6-b79b-74b3d34cb9e2")}catch(e){}}();
3
3
  import {
4
4
  parseItemDocument,
5
+ runActiveOnWriteHooks,
5
6
  serializeItemDocument
6
- } from "./chunk-HK72NWAD.js";
7
- import {
8
- runActiveOnWriteHooks
9
- } from "./chunk-US3T3W5J.js";
7
+ } from "./chunk-GH73UOSJ.js";
10
8
  import {
11
9
  TYPE_TO_FOLDER,
12
10
  getItemFormatFromPath,
@@ -14,7 +12,7 @@ import {
14
12
  readFileIfExists,
15
13
  removeFileIfExists,
16
14
  writeFileAtomic
17
- } from "./chunk-YD5FML7K.js";
15
+ } from "./chunk-UO7XAZK6.js";
18
16
 
19
17
  // dist/core/store/item-format-migration.js
20
18
  import fs from "node:fs/promises";
@@ -116,6 +114,6 @@ async function migrateItemFilesToFormat(pmRoot, targetFormat, op = "item_format:
116
114
  export {
117
115
  migrateItemFilesToFormat
118
116
  };
119
- //# sourceMappingURL=chunk-ZCJAA3JK.js.map
117
+ //# sourceMappingURL=chunk-4MZOKTI2.js.map
120
118
 
121
- //# debugId=d421445d-3cb5-5ecd-84ba-b8af7024405c
119
+ //# debugId=cc3f7b67-0ee9-5ac6-b79b-74b3d34cb9e2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../core/store/item-format-migration.ts"],"sourcesContent":["/**\n * @module core/store/item-format-migration\n *\n * Reads and writes tracker storage with format-aware helpers for Item Format Migration.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { runActiveOnWriteHooks } from \"../extensions/index.js\";\nimport { readFileIfExists, removeFileIfExists, writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { parseItemDocument, serializeItemDocument } from \"../item/item-format.js\";\nimport { TYPE_TO_FOLDER } from \"../shared/constants.js\";\nimport { getItemFormatFromPath, getItemPath } from \"./paths.js\";\nimport type { ItemFormat, ItemType, RuntimeSchemaSettings } from \"../../types/index.js\";\n\ninterface ItemPathVariants {\n json_markdown?: string;\n toon?: string;\n}\n\n/**\n * Documents the item format migration result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ItemFormatMigrationResult {\n target_format: ItemFormat;\n scanned: number;\n migrated: string[];\n removed: string[];\n warnings: string[];\n}\n\nfunction alternateItemFormat(_targetFormat: ItemFormat): ItemFormat {\n return \"json_markdown\";\n}\n\nfunction normalizeRelativePath(pmRoot: string, absolutePath: string): string {\n return path.relative(pmRoot, absolutePath).replaceAll(\"\\\\\", \"/\");\n}\n\nfunction errorSummary(error: unknown): string {\n return String(error).replaceAll(/[^a-zA-Z0-9._-]+/g, \"_\").slice(0, 120);\n}\n\n/**\n * Implements migrate item files to format for the public runtime surface of this module.\n */\nexport async function migrateItemFilesToFormat(\n pmRoot: string,\n targetFormat: ItemFormat,\n op = \"item_format:migrate\",\n typeToFolder: Record<string, string> = TYPE_TO_FOLDER,\n schema?: RuntimeSchemaSettings,\n): Promise<ItemFormatMigrationResult> {\n if (targetFormat !== \"toon\") {\n throw new Error(\"Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.\");\n }\n const migratedIds = new Set<string>();\n const removedPaths = new Set<string>();\n const warnings: string[] = [];\n let scanned = 0;\n const alternateFormat = alternateItemFormat(targetFormat);\n const typeEntries = Object.entries(typeToFolder) as Array<[ItemType, string]>;\n\n for (const [itemType, folder] of typeEntries) {\n const directoryPath = path.join(pmRoot, folder);\n let files: string[] = [];\n try {\n files = await fs.readdir(directoryPath);\n } catch {\n continue;\n }\n\n const variantsById = new Map<string, ItemPathVariants>();\n for (const file of files) {\n const absolutePath = path.join(directoryPath, file);\n const itemFormat = getItemFormatFromPath(absolutePath);\n if (!itemFormat) {\n continue;\n }\n const extension = path.extname(file);\n const itemId = file.slice(0, file.length - extension.length).trim();\n if (itemId.length === 0) {\n continue;\n }\n const entry = variantsById.get(itemId) ?? {};\n entry[itemFormat] = absolutePath;\n variantsById.set(itemId, entry);\n }\n\n const itemIds = [...variantsById.keys()].sort((left, right) => left.localeCompare(right));\n for (const itemId of itemIds) {\n const variants = variantsById.get(itemId) as ItemPathVariants;\n scanned += 1;\n // Items already present only in the target format need no migration: there\n // is no legacy alternate-format file to convert or remove. Skip the\n // read/parse/serialize/compare round-trip for them. This is the dominant\n // cost of the pre-mutation format sync, which runs on every mutation and\n // would otherwise re-parse the entire corpus (O(items)) each time.\n const alternatePath = variants[alternateFormat];\n if (!alternatePath) {\n continue;\n }\n const sourcePath = variants[targetFormat] ?? alternatePath;\n const sourceFormat = sourcePath === variants[targetFormat] ? targetFormat : alternateFormat;\n try {\n const sourceRaw = await fs.readFile(sourcePath, \"utf8\");\n const parsedDocument = parseItemDocument(sourceRaw, {\n format: sourceFormat,\n schema,\n onWarning: (warning) => warnings.push(`item_format_migration_parse_warning:${itemId}:${warning}`),\n });\n const targetPath = getItemPath(pmRoot, itemType, itemId, targetFormat, typeToFolder);\n const serializedTarget = serializeItemDocument(parsedDocument, { format: targetFormat, schema });\n const existingTargetRaw = await readFileIfExists(targetPath);\n if (existingTargetRaw !== serializedTarget) {\n await writeFileAtomic(targetPath, serializedTarget);\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: targetPath,\n scope: \"project\",\n op,\n })),\n );\n migratedIds.add(itemId);\n }\n\n // The legacy alternate (.md) was enumerated from disk above and is always\n // a distinct path from the .toon target, so once the parse succeeds we\n // remove it unconditionally. removeFileIfExists tolerates a concurrently\n // removed file, so no pre-check is needed.\n await removeFileIfExists(alternatePath);\n removedPaths.add(normalizeRelativePath(pmRoot, alternatePath));\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: alternatePath,\n scope: \"project\",\n op: `${op}:remove`,\n })),\n );\n migratedIds.add(itemId);\n } catch (error) {\n warnings.push(\n `item_format_migration_skipped:${normalizeRelativePath(pmRoot, sourcePath)}:${errorSummary(error)}`,\n );\n }\n }\n }\n\n return {\n target_format: targetFormat,\n scanned,\n migrated: [...migratedIds].sort((left, right) => left.localeCompare(right)),\n removed: [...removedPaths].sort((left, right) => left.localeCompare(right)),\n warnings,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;AAwBjB,SAAS,oBAAoB,eAAyB;AACpD,SAAO;AACT;AAEA,SAAS,sBAAsB,QAAgB,cAAoB;AACjE,SAAO,KAAK,SAAS,QAAQ,YAAY,EAAE,WAAW,MAAM,GAAG;AACjE;AAEA,SAAS,aAAa,OAAc;AAClC,SAAO,OAAO,KAAK,EAAE,WAAW,qBAAqB,GAAG,EAAE,MAAM,GAAG,GAAG;AACxE;AAKA,eAAsB,yBACpB,QACA,cACA,KAAK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AAI;AACF,cAAM,YAAY,MAAM,GAAG,SAAS,YAAY,MAAM;AACtD,cAAM,iBAAiB,kBAAkB,WAAW;UAClD,QAAQ;UACR;UACA,WAAW,CAAC,YAAY,SAAS,KAAK,uCAAuC,MAAM,IAAI,OAAO,EAAE;SACjG;AACD,cAAM,aAAa,YAAY,QAAQ,UAAU,QAAQ,cAAc,YAAY;AACnF,cAAM,mBAAmB,sBAAsB,gBAAgB,EAAE,QAAQ,cAAc,OAAM,CAAE;AAC/F,cAAM,oBAAoB,MAAM,iBAAiB,UAAU;AAC3D,YAAI,sBAAsB,kBAAkB;AAC1C,gBAAM,gBAAgB,YAAY,gBAAgB;AAClD,mBAAS,KACP,GAAI,MAAM,sBAAsB;YAC9B,MAAM;YACN,OAAO;YACP;WACD,CAAE;AAEL,sBAAY,IAAI,MAAM;QACxB;AAMA,cAAM,mBAAmB,aAAa;AACtC,qBAAa,IAAI,sBAAsB,QAAQ,aAAa,CAAC;AAC7D,iBAAS,KACP,GAAI,MAAM,sBAAsB;UAC9B,MAAM;UACN,OAAO;UACP,IAAI,GAAG,EAAE;SACV,CAAE;AAEL,oBAAY,IAAI,MAAM;MACxB,SAAS,OAAO;AACd,iBAAS,KACP,iCAAiC,sBAAsB,QAAQ,UAAU,CAAC,IAAI,aAAa,KAAK,CAAC,EAAE;MAEvG;IACF;EACF;AAEA,SAAO;IACL,eAAe;IACf;IACA,UAAU,CAAC,GAAG,WAAW,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAC1E,SAAS,CAAC,GAAG,YAAY,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAC1E;;AAEJ","debugId":"d421445d-3cb5-5ecd-84ba-b8af7024405c"}
1
+ {"version":3,"sources":["../../../../../../../../core/store/item-format-migration.ts"],"sourcesContent":["/**\n * @module core/store/item-format-migration\n *\n * Reads and writes tracker storage with format-aware helpers for Item Format Migration.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { runActiveOnWriteHooks } from \"../extensions/index.js\";\nimport { readFileIfExists, removeFileIfExists, writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { parseItemDocument, serializeItemDocument } from \"../item/item-format.js\";\nimport { TYPE_TO_FOLDER } from \"../shared/constants.js\";\nimport { getItemFormatFromPath, getItemPath } from \"./paths.js\";\nimport type { ItemFormat, ItemType, RuntimeSchemaSettings } from \"../../types/index.js\";\n\ninterface ItemPathVariants {\n json_markdown?: string;\n toon?: string;\n}\n\n/**\n * Documents the item format migration result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ItemFormatMigrationResult {\n target_format: ItemFormat;\n scanned: number;\n migrated: string[];\n removed: string[];\n warnings: string[];\n}\n\nfunction alternateItemFormat(_targetFormat: ItemFormat): ItemFormat {\n return \"json_markdown\";\n}\n\nfunction normalizeRelativePath(pmRoot: string, absolutePath: string): string {\n return path.relative(pmRoot, absolutePath).replaceAll(\"\\\\\", \"/\");\n}\n\nfunction errorSummary(error: unknown): string {\n return String(error).replaceAll(/[^a-zA-Z0-9._-]+/g, \"_\").slice(0, 120);\n}\n\n/**\n * Implements migrate item files to format for the public runtime surface of this module.\n */\nexport async function migrateItemFilesToFormat(\n pmRoot: string,\n targetFormat: ItemFormat,\n op = \"item_format:migrate\",\n typeToFolder: Record<string, string> = TYPE_TO_FOLDER,\n schema?: RuntimeSchemaSettings,\n): Promise<ItemFormatMigrationResult> {\n if (targetFormat !== \"toon\") {\n throw new Error(\"Only toon item-format migration targets are supported. Markdown item files are legacy read-only input.\");\n }\n const migratedIds = new Set<string>();\n const removedPaths = new Set<string>();\n const warnings: string[] = [];\n let scanned = 0;\n const alternateFormat = alternateItemFormat(targetFormat);\n const typeEntries = Object.entries(typeToFolder) as Array<[ItemType, string]>;\n\n for (const [itemType, folder] of typeEntries) {\n const directoryPath = path.join(pmRoot, folder);\n let files: string[] = [];\n try {\n files = await fs.readdir(directoryPath);\n } catch {\n continue;\n }\n\n const variantsById = new Map<string, ItemPathVariants>();\n for (const file of files) {\n const absolutePath = path.join(directoryPath, file);\n const itemFormat = getItemFormatFromPath(absolutePath);\n if (!itemFormat) {\n continue;\n }\n const extension = path.extname(file);\n const itemId = file.slice(0, file.length - extension.length).trim();\n if (itemId.length === 0) {\n continue;\n }\n const entry = variantsById.get(itemId) ?? {};\n entry[itemFormat] = absolutePath;\n variantsById.set(itemId, entry);\n }\n\n const itemIds = [...variantsById.keys()].sort((left, right) => left.localeCompare(right));\n for (const itemId of itemIds) {\n const variants = variantsById.get(itemId) as ItemPathVariants;\n scanned += 1;\n // Items already present only in the target format need no migration: there\n // is no legacy alternate-format file to convert or remove. Skip the\n // read/parse/serialize/compare round-trip for them. This is the dominant\n // cost of the pre-mutation format sync, which runs on every mutation and\n // would otherwise re-parse the entire corpus (O(items)) each time.\n const alternatePath = variants[alternateFormat];\n if (!alternatePath) {\n continue;\n }\n const sourcePath = variants[targetFormat] ?? alternatePath;\n const sourceFormat = sourcePath === variants[targetFormat] ? targetFormat : alternateFormat;\n try {\n const sourceRaw = await fs.readFile(sourcePath, \"utf8\");\n const parsedDocument = parseItemDocument(sourceRaw, {\n format: sourceFormat,\n schema,\n onWarning: (warning) => warnings.push(`item_format_migration_parse_warning:${itemId}:${warning}`),\n });\n const targetPath = getItemPath(pmRoot, itemType, itemId, targetFormat, typeToFolder);\n const serializedTarget = serializeItemDocument(parsedDocument, { format: targetFormat, schema });\n const existingTargetRaw = await readFileIfExists(targetPath);\n if (existingTargetRaw !== serializedTarget) {\n await writeFileAtomic(targetPath, serializedTarget);\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: targetPath,\n scope: \"project\",\n op,\n })),\n );\n migratedIds.add(itemId);\n }\n\n // The legacy alternate (.md) was enumerated from disk above and is always\n // a distinct path from the .toon target, so once the parse succeeds we\n // remove it unconditionally. removeFileIfExists tolerates a concurrently\n // removed file, so no pre-check is needed.\n await removeFileIfExists(alternatePath);\n removedPaths.add(normalizeRelativePath(pmRoot, alternatePath));\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: alternatePath,\n scope: \"project\",\n op: `${op}:remove`,\n })),\n );\n migratedIds.add(itemId);\n } catch (error) {\n warnings.push(\n `item_format_migration_skipped:${normalizeRelativePath(pmRoot, sourcePath)}:${errorSummary(error)}`,\n );\n }\n }\n }\n\n return {\n target_format: targetFormat,\n scanned,\n migrated: [...migratedIds].sort((left, right) => left.localeCompare(right)),\n removed: [...removedPaths].sort((left, right) => left.localeCompare(right)),\n warnings,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;AAwBjB,SAAS,oBAAoB,eAAyB;AACpD,SAAO;AACT;AAEA,SAAS,sBAAsB,QAAgB,cAAoB;AACjE,SAAO,KAAK,SAAS,QAAQ,YAAY,EAAE,WAAW,MAAM,GAAG;AACjE;AAEA,SAAS,aAAa,OAAc;AAClC,SAAO,OAAO,KAAK,EAAE,WAAW,qBAAqB,GAAG,EAAE,MAAM,GAAG,GAAG;AACxE;AAKA,eAAsB,yBACpB,QACA,cACA,KAAK,uBACL,eAAuC,gBACvC,QAA8B;AAE9B,MAAI,iBAAiB,QAAQ;AAC3B,UAAM,IAAI,MAAM,wGAAwG;EAC1H;AACA,QAAM,cAAc,oBAAI,IAAG;AAC3B,QAAM,eAAe,oBAAI,IAAG;AAC5B,QAAM,WAAqB,CAAA;AAC3B,MAAI,UAAU;AACd,QAAM,kBAAkB,oBAAoB,YAAY;AACxD,QAAM,cAAc,OAAO,QAAQ,YAAY;AAE/C,aAAW,CAAC,UAAU,MAAM,KAAK,aAAa;AAC5C,UAAM,gBAAgB,KAAK,KAAK,QAAQ,MAAM;AAC9C,QAAI,QAAkB,CAAA;AACtB,QAAI;AACF,cAAQ,MAAM,GAAG,QAAQ,aAAa;IACxC,QAAQ;AACN;IACF;AAEA,UAAM,eAAe,oBAAI,IAAG;AAC5B,eAAW,QAAQ,OAAO;AACxB,YAAM,eAAe,KAAK,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ACtC,qBAAa,IAAI,sBAAsB,QAAQ,aAAa,CAAC;AAC7D,iBAAS,KACP,GAAI,MAAM,sBAAsB;UAC9B,MAAM;UACN,OAAO;UACP,IAAI,GAAG,EAAE;SACV,CAAE;AAEL,oBAAY,IAAI,MAAM;MACxB,SAAS,OAAO;AACd,iBAAS,KACP,iCAAiC,sBAAsB,QAAQ,UAAU,CAAC,IAAI,aAAa,KAAK,CAAC,EAAE;MAEvG;IACF;EACF;AAEA,SAAO;IACL,eAAe;IACf;IACA,UAAU,CAAC,GAAG,WAAW,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAC1E,SAAS,CAAC,GAAG,YAAY,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAC1E;;AAEJ","debugId":"cc3f7b67-0ee9-5ac6-b79b-74b3d34cb9e2"}
@@ -1,11 +1,11 @@
1
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]="486ead3c-861e-5236-bc1f-af9094097a77")}catch(e){}}();
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]="dfca79bb-75b6-55a7-84b0-07b24f504e5b")}catch(e){}}();
3
3
  import {
4
4
  resolveAuthor
5
5
  } from "./chunk-T5RRNDA7.js";
6
6
  import {
7
7
  readHistoryEntries
8
- } from "./chunk-T3F4DF23.js";
8
+ } from "./chunk-565WYS5W.js";
9
9
  import {
10
10
  EMPTY_REPLAY_DOCUMENT,
11
11
  historyEntriesToRaw,
@@ -13,29 +13,23 @@ import {
13
13
  replayToItemDocument,
14
14
  tryApplyReplayPatch,
15
15
  verifyHistoryChain
16
- } from "./chunk-BFVHCAOO.js";
16
+ } from "./chunk-7Y5N34HX.js";
17
17
  import {
18
+ PmCliError,
18
19
  acquireLock,
20
+ canonicalDocument,
19
21
  createHistoryEntry,
22
+ getActiveExtensionRegistrations,
20
23
  locateItem,
21
- readLocatedItem
22
- } from "./chunk-57C2RLW5.js";
23
- import {
24
- canonicalDocument,
25
24
  normalizeItemId,
26
25
  normalizeRawItemId,
27
- serializeItemDocument
28
- } from "./chunk-HK72NWAD.js";
29
- import {
30
- nowIso
31
- } from "./chunk-FJRKQREY.js";
32
- import {
33
- PmCliError,
34
- getActiveExtensionRegistrations,
26
+ nowIso,
27
+ readLocatedItem,
35
28
  readSettings,
36
29
  resolveGovernanceKnobs,
37
- runActiveOnWriteHooks
38
- } from "./chunk-US3T3W5J.js";
30
+ runActiveOnWriteHooks,
31
+ serializeItemDocument
32
+ } from "./chunk-GH73UOSJ.js";
39
33
  import {
40
34
  EXIT_CODE,
41
35
  getHistoryPath,
@@ -46,7 +40,7 @@ import {
46
40
  resolveItemTypeRegistry,
47
41
  resolvePmRoot,
48
42
  writeFileAtomic
49
- } from "./chunk-YD5FML7K.js";
43
+ } from "./chunk-UO7XAZK6.js";
50
44
 
51
45
  // dist/cli/commands/history-redact.js
52
46
  import fs2 from "node:fs/promises";
@@ -640,6 +634,6 @@ export {
640
634
  runHistoryRedact,
641
635
  _testOnly
642
636
  };
643
- //# sourceMappingURL=chunk-IJ6CO3JV.js.map
637
+ //# sourceMappingURL=chunk-52NS7JDP.js.map
644
638
 
645
- //# debugId=486ead3c-861e-5236-bc1f-af9094097a77
639
+ //# debugId=dfca79bb-75b6-55a7-84b0-07b24f504e5b