@unbrained/pm-cli 2026.6.24 → 2026.6.30

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 (712) hide show
  1. package/CHANGELOG.md +93 -1
  2. package/CONTRIBUTING.md +30 -0
  3. package/README.md +16 -3
  4. package/dist/cli/commander-usage.js +3 -3
  5. package/dist/cli/commander-usage.js.map +1 -1
  6. package/dist/cli/commands/aggregate.js +8 -7
  7. package/dist/cli/commands/aggregate.js.map +1 -1
  8. package/dist/cli/commands/close.d.ts +2 -4
  9. package/dist/cli/commands/close.js +5 -17
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +158 -9
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/config.d.ts +1 -1
  14. package/dist/cli/commands/config.js +2 -2
  15. package/dist/cli/commands/config.js.map +1 -1
  16. package/dist/cli/commands/context.d.ts +31 -4
  17. package/dist/cli/commands/context.js +33 -10
  18. package/dist/cli/commands/context.js.map +1 -1
  19. package/dist/cli/commands/contracts.js +48 -8
  20. package/dist/cli/commands/contracts.js.map +1 -1
  21. package/dist/cli/commands/create.d.ts +1 -6
  22. package/dist/cli/commands/create.js +10 -155
  23. package/dist/cli/commands/create.js.map +1 -1
  24. package/dist/cli/commands/extension/describe.d.ts +15 -0
  25. package/dist/cli/commands/extension/describe.js +48 -2
  26. package/dist/cli/commands/extension/describe.js.map +1 -1
  27. package/dist/cli/commands/extension/doctor.js +5 -2
  28. package/dist/cli/commands/extension/doctor.js.map +1 -1
  29. package/dist/cli/commands/extension/install-sources.js +37 -7
  30. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  31. package/dist/cli/commands/extension/scaffold.d.ts +31 -8
  32. package/dist/cli/commands/extension/scaffold.js +1891 -205
  33. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  34. package/dist/cli/commands/extension.d.ts +22 -2
  35. package/dist/cli/commands/extension.js +186 -17
  36. package/dist/cli/commands/extension.js.map +1 -1
  37. package/dist/cli/commands/index.d.ts +3 -1
  38. package/dist/cli/commands/index.js +5 -3
  39. package/dist/cli/commands/index.js.map +1 -1
  40. package/dist/cli/commands/item-filter-options.d.ts +63 -0
  41. package/dist/cli/commands/item-filter-options.js +10 -0
  42. package/dist/cli/commands/item-filter-options.js.map +1 -0
  43. package/dist/cli/commands/legacy-none-tokens.d.ts +14 -0
  44. package/dist/cli/commands/legacy-none-tokens.js +31 -2
  45. package/dist/cli/commands/legacy-none-tokens.js.map +1 -1
  46. package/dist/cli/commands/linked-artifacts.d.ts +7 -0
  47. package/dist/cli/commands/linked-artifacts.js +12 -2
  48. package/dist/cli/commands/linked-artifacts.js.map +1 -1
  49. package/dist/cli/commands/list.d.ts +16 -39
  50. package/dist/cli/commands/list.js +127 -118
  51. package/dist/cli/commands/list.js.map +1 -1
  52. package/dist/cli/commands/next.d.ts +98 -0
  53. package/dist/cli/commands/next.js +304 -0
  54. package/dist/cli/commands/next.js.map +1 -0
  55. package/dist/cli/commands/profile.d.ts +208 -0
  56. package/dist/cli/commands/profile.js +418 -0
  57. package/dist/cli/commands/profile.js.map +1 -0
  58. package/dist/cli/commands/repeatable-metadata-parsers.js +12 -13
  59. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -1
  60. package/dist/cli/commands/schema.d.ts +7 -0
  61. package/dist/cli/commands/schema.js +9 -3
  62. package/dist/cli/commands/schema.js.map +1 -1
  63. package/dist/cli/commands/search.d.ts +2 -39
  64. package/dist/cli/commands/search.js +104 -106
  65. package/dist/cli/commands/search.js.map +1 -1
  66. package/dist/cli/commands/shared-unset-fields.d.ts +30 -0
  67. package/dist/cli/commands/shared-unset-fields.js +161 -0
  68. package/dist/cli/commands/shared-unset-fields.js.map +1 -0
  69. package/dist/cli/commands/stats.js +15 -3
  70. package/dist/cli/commands/stats.js.map +1 -1
  71. package/dist/cli/commands/test.js +9 -5
  72. package/dist/cli/commands/test.js.map +1 -1
  73. package/dist/cli/commands/update.d.ts +1 -6
  74. package/dist/cli/commands/update.js +12 -157
  75. package/dist/cli/commands/update.js.map +1 -1
  76. package/dist/cli/commands/validate.js +20 -5
  77. package/dist/cli/commands/validate.js.map +1 -1
  78. package/dist/cli/help-content.js +26 -2
  79. package/dist/cli/help-content.js.map +1 -1
  80. package/dist/cli/help-json-payload.js +3 -3
  81. package/dist/cli/help-json-payload.js.map +1 -1
  82. package/dist/cli/main.js +27 -12
  83. package/dist/cli/main.js.map +1 -1
  84. package/dist/cli/register-list-query.js +42 -3
  85. package/dist/cli/register-list-query.js.map +1 -1
  86. package/dist/cli/register-mutation.js +86 -2
  87. package/dist/cli/register-mutation.js.map +1 -1
  88. package/dist/cli/register-setup.js +67 -6
  89. package/dist/cli/register-setup.js.map +1 -1
  90. package/dist/cli/registration-helpers.d.ts +9 -1
  91. package/dist/cli/registration-helpers.js +34 -3
  92. package/dist/cli/registration-helpers.js.map +1 -1
  93. package/dist/cli-bundle/chunks/activity-EJBMXUBH.js +16 -0
  94. package/dist/cli-bundle/chunks/{activity-N7RVTLBQ.js → activity-MVSEND6D.js} +9 -11
  95. package/dist/cli-bundle/chunks/{aggregate-63NWNIBR.js → aggregate-MOC4TR2G.js} +16 -17
  96. package/dist/cli-bundle/chunks/aggregate-MOC4TR2G.js.map +1 -0
  97. package/dist/cli-bundle/chunks/{aggregate-YHCYX2EV.js → aggregate-XJHLZQ5X.js} +15 -16
  98. package/dist/cli-bundle/chunks/aggregate-XJHLZQ5X.js.map +7 -0
  99. package/dist/cli-bundle/chunks/{append-PUKREFV5.js → append-KDHT4GHI.js} +10 -12
  100. package/dist/cli-bundle/chunks/{append-PUKREFV5.js.map → append-KDHT4GHI.js.map} +1 -1
  101. package/dist/cli-bundle/chunks/{append-VLQQDHMJ.js → append-LEDBAM3K.js} +8 -10
  102. package/dist/cli-bundle/chunks/{append-VLQQDHMJ.js.map → append-LEDBAM3K.js.map} +1 -1
  103. package/dist/cli-bundle/chunks/{chunk-F32L4HR6.js → chunk-3JWQCLR5.js} +3 -3
  104. package/dist/cli-bundle/chunks/{chunk-YV2OSAMS.js → chunk-4TXTVZL3.js} +2 -2
  105. package/dist/cli-bundle/chunks/{chunk-AYPQUFCX.js → chunk-4YIMPANT.js} +3 -3
  106. package/dist/cli-bundle/chunks/{chunk-ALKFCIIB.js → chunk-53ARXF2O.js} +9 -11
  107. package/dist/cli-bundle/chunks/{chunk-ALKFCIIB.js.map → chunk-53ARXF2O.js.map} +1 -1
  108. package/dist/cli-bundle/chunks/chunk-5ABGFWR4.js +116 -0
  109. package/dist/cli-bundle/chunks/chunk-5ABGFWR4.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-OF7V47P3.js → chunk-5IRVSKPS.js} +2990 -2890
  111. package/dist/cli-bundle/chunks/chunk-5IRVSKPS.js.map +1 -0
  112. package/dist/cli-bundle/chunks/{chunk-XXKV4UWE.js → chunk-5T6WPLRO.js} +233 -190
  113. package/dist/cli-bundle/chunks/chunk-5T6WPLRO.js.map +7 -0
  114. package/dist/cli-bundle/chunks/{chunk-SMXSDY7J.js → chunk-6T5ZIWBS.js} +3011 -2888
  115. package/dist/cli-bundle/chunks/chunk-6T5ZIWBS.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-RAWA3Y7O.js → chunk-6YRAMXRS.js} +111 -114
  117. package/dist/cli-bundle/chunks/chunk-6YRAMXRS.js.map +1 -0
  118. package/dist/cli-bundle/chunks/{chunk-EOGBMLCE.js → chunk-73PTKMAE.js} +3 -3
  119. package/dist/cli-bundle/chunks/{chunk-GQYJEEFX.js → chunk-74PUWBGN.js} +53 -54
  120. package/dist/cli-bundle/chunks/chunk-74PUWBGN.js.map +1 -0
  121. package/dist/cli-bundle/chunks/{chunk-JV27C7OZ.js → chunk-7L6TXOOC.js} +4 -6
  122. package/dist/cli-bundle/chunks/{chunk-JV27C7OZ.js.map → chunk-7L6TXOOC.js.map} +1 -1
  123. package/dist/cli-bundle/chunks/chunk-7M2HAZEB.js +17 -0
  124. package/dist/cli-bundle/chunks/chunk-7M2HAZEB.js.map +7 -0
  125. package/dist/cli-bundle/chunks/{chunk-2WCYE3IF.js → chunk-7RIJGN4R.js} +2 -2
  126. package/dist/cli-bundle/chunks/{chunk-JKL6HRMV.js → chunk-7WDETKGP.js} +191 -117
  127. package/dist/cli-bundle/chunks/chunk-7WDETKGP.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-HBAEFWX3.js → chunk-A3UNLXNJ.js} +40 -260
  129. package/dist/cli-bundle/chunks/chunk-A3UNLXNJ.js.map +7 -0
  130. package/dist/cli-bundle/chunks/{chunk-6EBNFQOR.js → chunk-AWN4PPH5.js} +10 -14
  131. package/dist/cli-bundle/chunks/{chunk-6EBNFQOR.js.map → chunk-AWN4PPH5.js.map} +1 -1
  132. package/dist/cli-bundle/chunks/{chunk-CZIFFMZI.js → chunk-BN3CWK6G.js} +2 -2
  133. package/dist/cli-bundle/chunks/{chunk-SUREE24M.js → chunk-BOWQWXLI.js} +12 -24
  134. package/dist/cli-bundle/chunks/chunk-BOWQWXLI.js.map +1 -0
  135. package/dist/cli-bundle/chunks/{chunk-J3NMWFIN.js → chunk-C2KCIZKZ.js} +2 -2
  136. package/dist/cli-bundle/chunks/{chunk-TIM4OD74.js → chunk-CHRNYKNI.js} +2 -2
  137. package/dist/cli-bundle/chunks/{chunk-VSAABFGQ.js → chunk-CY5IJMUM.js} +1136 -419
  138. package/dist/cli-bundle/chunks/chunk-CY5IJMUM.js.map +1 -0
  139. package/dist/cli-bundle/chunks/chunk-CZVISY5A.js +87 -0
  140. package/dist/cli-bundle/chunks/chunk-CZVISY5A.js.map +7 -0
  141. package/dist/cli-bundle/chunks/{chunk-UACWNBL2.js → chunk-D5LYZVGB.js} +7 -9
  142. package/dist/cli-bundle/chunks/{chunk-UACWNBL2.js.map → chunk-D5LYZVGB.js.map} +1 -1
  143. package/dist/cli-bundle/chunks/{chunk-KIEAK7YE.js → chunk-D6USKAMA.js} +2 -2
  144. package/dist/cli-bundle/chunks/{context-5LB7UGKE.js → chunk-DJDXAU74.js} +19 -21
  145. package/dist/cli-bundle/chunks/chunk-DJDXAU74.js.map +7 -0
  146. package/dist/cli-bundle/chunks/{chunk-3BKH2CL3.js → chunk-DLDCPF5X.js} +3 -3
  147. package/dist/cli-bundle/chunks/{chunk-J7I4C5ZB.js → chunk-DORJSBGJ.js} +35 -9
  148. package/dist/cli-bundle/chunks/chunk-DORJSBGJ.js.map +7 -0
  149. package/dist/cli-bundle/chunks/{chunk-DTABLLVE.js → chunk-DRPF274X.js} +5 -7
  150. package/dist/cli-bundle/chunks/{chunk-DTABLLVE.js.map → chunk-DRPF274X.js.map} +2 -2
  151. package/dist/cli-bundle/chunks/{chunk-6EL7SW5C.js → chunk-DU66JUGT.js} +16 -14
  152. package/dist/cli-bundle/chunks/chunk-DU66JUGT.js.map +7 -0
  153. package/dist/cli-bundle/chunks/{chunk-CG3KP6I5.js → chunk-E2Q2ULMR.js} +4 -4
  154. package/dist/cli-bundle/chunks/{chunk-A66VYUOV.js → chunk-EVWYAG46.js} +9 -11
  155. package/dist/cli-bundle/chunks/{chunk-A66VYUOV.js.map → chunk-EVWYAG46.js.map} +1 -1
  156. package/dist/cli-bundle/chunks/{chunk-PEL2NLQE.js → chunk-F6VH3LFC.js} +2 -2
  157. package/dist/cli-bundle/chunks/{chunk-AEACLRVH.js → chunk-F7G53BOA.js} +18 -11
  158. package/dist/cli-bundle/chunks/chunk-F7G53BOA.js.map +7 -0
  159. package/dist/cli-bundle/chunks/{chunk-ABYCA5VX.js → chunk-FBZ5XAAF.js} +9 -11
  160. package/dist/cli-bundle/chunks/{chunk-ABYCA5VX.js.map → chunk-FBZ5XAAF.js.map} +1 -1
  161. package/dist/cli-bundle/chunks/{chunk-5BBEWX6C.js → chunk-FDEVKXC4.js} +2 -2
  162. package/dist/cli-bundle/chunks/{chunk-4XDGYFHL.js → chunk-GF7EAR22.js} +10 -14
  163. package/dist/cli-bundle/chunks/{chunk-4XDGYFHL.js.map → chunk-GF7EAR22.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{context-55VEOYI3.js → chunk-HIBK6H4S.js} +20 -22
  165. package/dist/cli-bundle/chunks/chunk-HIBK6H4S.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{chunk-QOUOMPHO.js → chunk-HUYYMTGW.js} +2 -2
  167. package/dist/cli-bundle/chunks/chunk-IBMFIKVS.js +14 -0
  168. package/dist/cli-bundle/chunks/chunk-IBMFIKVS.js.map +1 -0
  169. package/dist/cli-bundle/chunks/{chunk-LU36E6GU.js → chunk-IBU2LLWM.js} +8 -12
  170. package/dist/cli-bundle/chunks/{chunk-LU36E6GU.js.map → chunk-IBU2LLWM.js.map} +1 -1
  171. package/dist/cli-bundle/chunks/{chunk-MEXZ5XUM.js → chunk-IDYCAK35.js} +53 -54
  172. package/dist/cli-bundle/chunks/chunk-IDYCAK35.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-VFJYVXHL.js → chunk-IF4ERU6A.js} +7 -9
  174. package/dist/cli-bundle/chunks/{chunk-VFJYVXHL.js.map → chunk-IF4ERU6A.js.map} +1 -1
  175. package/dist/cli-bundle/chunks/{chunk-KKX4Z2SE.js → chunk-IHXXUIXS.js} +4 -4
  176. package/dist/cli-bundle/chunks/chunk-IZQOJR2B.js +2459 -0
  177. package/dist/cli-bundle/chunks/chunk-IZQOJR2B.js.map +7 -0
  178. package/dist/cli-bundle/chunks/{chunk-F4BNR2IN.js → chunk-JIP67N2K.js} +3 -3
  179. package/dist/cli-bundle/chunks/chunk-JJ4SG243.js +119 -0
  180. package/dist/cli-bundle/chunks/chunk-JJ4SG243.js.map +7 -0
  181. package/dist/cli-bundle/chunks/{chunk-EWRSXOIZ.js → chunk-JTRKME24.js} +11 -13
  182. package/dist/cli-bundle/chunks/{chunk-EWRSXOIZ.js.map → chunk-JTRKME24.js.map} +1 -1
  183. package/dist/cli-bundle/chunks/{chunk-V4UYNSEM.js → chunk-JVQ7UOYC.js} +6 -8
  184. package/dist/cli-bundle/chunks/{chunk-V4UYNSEM.js.map → chunk-JVQ7UOYC.js.map} +1 -1
  185. package/dist/cli-bundle/chunks/{chunk-L7UXKP2I.js → chunk-JZG5ADVE.js} +190 -102
  186. package/dist/cli-bundle/chunks/chunk-JZG5ADVE.js.map +1 -0
  187. package/dist/cli-bundle/chunks/{chunk-N5B6WZC5.js → chunk-K46GQ265.js} +17 -15
  188. package/dist/cli-bundle/chunks/chunk-K46GQ265.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-KJZOSF7J.js → chunk-KGQ3W65B.js} +100 -35
  190. package/dist/cli-bundle/chunks/chunk-KGQ3W65B.js.map +1 -0
  191. package/dist/cli-bundle/chunks/{chunk-FMWW2JDU.js → chunk-KRASIL6M.js} +2 -2
  192. package/dist/cli-bundle/chunks/{chunk-XVYKWZNL.js → chunk-KTMMTOIP.js} +127 -127
  193. package/dist/cli-bundle/chunks/chunk-KTMMTOIP.js.map +7 -0
  194. package/dist/cli-bundle/chunks/{chunk-HZF5RLKX.js → chunk-KYDYQMNW.js} +5 -7
  195. package/dist/cli-bundle/chunks/{chunk-HZF5RLKX.js.map → chunk-KYDYQMNW.js.map} +1 -1
  196. package/dist/cli-bundle/chunks/{chunk-OHDQNKJB.js → chunk-LBH7UYKY.js} +106 -34
  197. package/dist/cli-bundle/chunks/chunk-LBH7UYKY.js.map +7 -0
  198. package/dist/cli-bundle/chunks/{chunk-I6QMJ2XT.js → chunk-MLHX6DN5.js} +2 -2
  199. package/dist/cli-bundle/chunks/{chunk-HC2S36NB.js → chunk-NIBP3I7A.js} +36 -10
  200. package/dist/cli-bundle/chunks/chunk-NIBP3I7A.js.map +1 -0
  201. package/dist/cli-bundle/chunks/{schema-C6QA367T.js → chunk-NO6Y6FB2.js} +144 -67
  202. package/dist/cli-bundle/chunks/chunk-NO6Y6FB2.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-5S4ZGDB2.js → chunk-OB3RJV5F.js} +2 -2
  204. package/dist/cli-bundle/chunks/chunk-OKQ22KTH.js +379 -0
  205. package/dist/cli-bundle/chunks/chunk-OKQ22KTH.js.map +1 -0
  206. package/dist/cli-bundle/chunks/{chunk-SKC4UTRP.js → chunk-OUQ5JEFM.js} +3 -3
  207. package/dist/cli-bundle/chunks/{chunk-JPJDP4VU.js → chunk-QE5UFCCO.js} +2 -2
  208. package/dist/cli-bundle/chunks/{chunk-6W3Y65PL.js → chunk-RM6MHL6A.js} +110 -113
  209. package/dist/cli-bundle/chunks/chunk-RM6MHL6A.js.map +7 -0
  210. package/dist/cli-bundle/chunks/{chunk-RRP6D345.js → chunk-RPRW26NG.js} +12 -16
  211. package/dist/cli-bundle/chunks/{chunk-RRP6D345.js.map → chunk-RPRW26NG.js.map} +1 -1
  212. package/dist/cli-bundle/chunks/{chunk-WB5BYQMF.js → chunk-SJZTPVFT.js} +4 -4
  213. package/dist/cli-bundle/chunks/{chunk-EYPINTFR.js → chunk-SNUK7H5J.js} +1164 -440
  214. package/dist/cli-bundle/chunks/chunk-SNUK7H5J.js.map +7 -0
  215. package/dist/cli-bundle/chunks/chunk-T7ZMQI4J.js +2435 -0
  216. package/dist/cli-bundle/chunks/chunk-T7ZMQI4J.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-GDUMGZK3.js → chunk-TQ6E76BE.js} +11 -13
  218. package/dist/cli-bundle/chunks/{chunk-GDUMGZK3.js.map → chunk-TQ6E76BE.js.map} +1 -1
  219. package/dist/cli-bundle/chunks/{chunk-IAP5KYBQ.js → chunk-UB3V5WUI.js} +225 -189
  220. package/dist/cli-bundle/chunks/chunk-UB3V5WUI.js.map +1 -0
  221. package/dist/cli-bundle/chunks/{chunk-PRVTGX64.js → chunk-UFKNF23C.js} +11 -23
  222. package/dist/cli-bundle/chunks/chunk-UFKNF23C.js.map +7 -0
  223. package/dist/cli-bundle/chunks/{chunk-ZLWRPBOW.js → chunk-V3KLX7U7.js} +3 -3
  224. package/dist/cli-bundle/chunks/{chunk-LNEDHJNQ.js → chunk-VD3LKZFX.js} +41 -254
  225. package/dist/cli-bundle/chunks/chunk-VD3LKZFX.js.map +1 -0
  226. package/dist/cli-bundle/chunks/{chunk-MWMHZOZZ.js → chunk-VMY7MZEM.js} +10 -14
  227. package/dist/cli-bundle/chunks/{chunk-MWMHZOZZ.js.map → chunk-VMY7MZEM.js.map} +1 -1
  228. package/dist/cli-bundle/chunks/chunk-VZDBVEZR.js +382 -0
  229. package/dist/cli-bundle/chunks/chunk-VZDBVEZR.js.map +7 -0
  230. package/dist/cli-bundle/chunks/{chunk-M6TUBOGW.js → chunk-WFJZDUM7.js} +19 -12
  231. package/dist/cli-bundle/chunks/chunk-WFJZDUM7.js.map +1 -0
  232. package/dist/cli-bundle/chunks/{schema-QO5I4FBL.js → chunk-WTRUDJ3R.js} +136 -66
  233. package/dist/cli-bundle/chunks/chunk-WTRUDJ3R.js.map +1 -0
  234. package/dist/cli-bundle/chunks/{chunk-TSI32UEL.js → chunk-YEDFE4DC.js} +6 -8
  235. package/dist/cli-bundle/chunks/{chunk-TSI32UEL.js.map → chunk-YEDFE4DC.js.map} +1 -1
  236. package/dist/cli-bundle/chunks/chunk-YJIEJRZB.js +84 -0
  237. package/dist/cli-bundle/chunks/chunk-YJIEJRZB.js.map +1 -0
  238. package/dist/cli-bundle/chunks/{chunk-ALQKV6U7.js → chunk-Z55WX4IQ.js} +12 -16
  239. package/dist/cli-bundle/chunks/{chunk-ALQKV6U7.js.map → chunk-Z55WX4IQ.js.map} +1 -1
  240. package/dist/cli-bundle/chunks/{chunk-OQ2E64FH.js → chunk-Z5BM2FKQ.js} +4 -4
  241. package/dist/cli-bundle/chunks/{chunk-IXAZI443.js → chunk-ZEATCVAC.js} +2 -2
  242. package/dist/cli-bundle/chunks/{chunk-C4C3EJCJ.js → chunk-ZFIEEDTJ.js} +3 -3
  243. package/dist/cli-bundle/chunks/{chunk-BFFO3AIB.js → chunk-ZIE6WXJ2.js} +128 -128
  244. package/dist/cli-bundle/chunks/chunk-ZIE6WXJ2.js.map +1 -0
  245. package/dist/cli-bundle/chunks/{claim-FZZZCAY6.js → claim-6NINZYB3.js} +10 -12
  246. package/dist/cli-bundle/chunks/{claim-FZZZCAY6.js.map → claim-6NINZYB3.js.map} +1 -1
  247. package/dist/cli-bundle/chunks/{claim-XK5QBZE3.js → claim-HMCLSLUE.js} +8 -10
  248. package/dist/cli-bundle/chunks/{claim-XK5QBZE3.js.map → claim-HMCLSLUE.js.map} +1 -1
  249. package/dist/cli-bundle/chunks/close-37KEHLYM.js +14 -0
  250. package/dist/cli-bundle/chunks/{close-QHMVWM7M.js → close-OP3LK7Z2.js} +7 -8
  251. package/dist/cli-bundle/chunks/{close-many-OIXJE2JZ.js → close-many-BFMP6HHK.js} +15 -17
  252. package/dist/cli-bundle/chunks/{close-many-OIXJE2JZ.js.map → close-many-BFMP6HHK.js.map} +1 -1
  253. package/dist/cli-bundle/chunks/{close-many-SUU5BS2C.js → close-many-CXJBOWWY.js} +17 -19
  254. package/dist/cli-bundle/chunks/{close-many-SUU5BS2C.js.map → close-many-CXJBOWWY.js.map} +1 -1
  255. package/dist/cli-bundle/chunks/{comments-RH3IBIRH.js → comments-ETHABIY6.js} +9 -11
  256. package/dist/cli-bundle/chunks/{comments-RH3IBIRH.js.map → comments-ETHABIY6.js.map} +1 -1
  257. package/dist/cli-bundle/chunks/{comments-5YM62D75.js → comments-MU2WMBUY.js} +11 -13
  258. package/dist/cli-bundle/chunks/{comments-5YM62D75.js.map → comments-MU2WMBUY.js.map} +1 -1
  259. package/dist/cli-bundle/chunks/{config-NCNNWF6R.js → config-FIXJZEQK.js} +18 -387
  260. package/dist/cli-bundle/chunks/config-FIXJZEQK.js.map +7 -0
  261. package/dist/cli-bundle/chunks/{config-SW3U7XP2.js → config-X3ZVCUUG.js} +18 -380
  262. package/dist/cli-bundle/chunks/config-X3ZVCUUG.js.map +1 -0
  263. package/dist/cli-bundle/chunks/context-7ZEZV3BV.js +42 -0
  264. package/dist/cli-bundle/chunks/context-XDI4DKKT.js +46 -0
  265. package/dist/cli-bundle/chunks/{contracts-JXFGBOYT.js → contracts-KP4QAGVW.js} +72 -15
  266. package/dist/cli-bundle/chunks/contracts-KP4QAGVW.js.map +1 -0
  267. package/dist/cli-bundle/chunks/{contracts-SY6PDFIK.js → contracts-SMOAN5NF.js} +72 -15
  268. package/dist/cli-bundle/chunks/contracts-SMOAN5NF.js.map +7 -0
  269. package/dist/cli-bundle/chunks/{copy-N3GE6FYS.js → copy-CWM6SBY6.js} +7 -11
  270. package/dist/cli-bundle/chunks/{copy-N3GE6FYS.js.map → copy-CWM6SBY6.js.map} +1 -1
  271. package/dist/cli-bundle/chunks/{copy-IEDBJOOX.js → copy-JJ3KOQW2.js} +9 -13
  272. package/dist/cli-bundle/chunks/{copy-IEDBJOOX.js.map → copy-JJ3KOQW2.js.map} +1 -1
  273. package/dist/cli-bundle/chunks/create-DFMNBKBS.js +28 -0
  274. package/dist/cli-bundle/chunks/{create-O4VONGPG.js → create-J5Q2ELZT.js} +12 -14
  275. package/dist/cli-bundle/chunks/{delete-724EQ6OS.js → delete-2GZLQEUQ.js} +7 -9
  276. package/dist/cli-bundle/chunks/{delete-724EQ6OS.js.map → delete-2GZLQEUQ.js.map} +1 -1
  277. package/dist/cli-bundle/chunks/{delete-LPEIF7RU.js → delete-OOQS4KVD.js} +5 -7
  278. package/dist/cli-bundle/chunks/{delete-LPEIF7RU.js.map → delete-OOQS4KVD.js.map} +1 -1
  279. package/dist/cli-bundle/chunks/{deps-T3Y6Y7RT.js → deps-IF4IGL4R.js} +6 -9
  280. package/dist/cli-bundle/chunks/{deps-T3Y6Y7RT.js.map → deps-IF4IGL4R.js.map} +1 -1
  281. package/dist/cli-bundle/chunks/{deps-RSBU4SIU.js → deps-ZVGGCRR6.js} +8 -11
  282. package/dist/cli-bundle/chunks/{deps-RSBU4SIU.js.map → deps-ZVGGCRR6.js.map} +1 -1
  283. package/dist/cli-bundle/chunks/{docs-IFS7HZPP.js → docs-2TIFR62T.js} +8 -9
  284. package/dist/cli-bundle/chunks/{docs-IFS7HZPP.js.map → docs-2TIFR62T.js.map} +1 -1
  285. package/dist/cli-bundle/chunks/{docs-75ZLCO3G.js → docs-NFTBCQQC.js} +10 -11
  286. package/dist/cli-bundle/chunks/{docs-75ZLCO3G.js.map → docs-NFTBCQQC.js.map} +1 -1
  287. package/dist/cli-bundle/chunks/{eval-L2KD7W3M.js → eval-2F6EH4XN.js} +12 -14
  288. package/dist/cli-bundle/chunks/{eval-L2KD7W3M.js.map → eval-2F6EH4XN.js.map} +1 -1
  289. package/dist/cli-bundle/chunks/{eval-QGR7JCQO.js → eval-PFKXQR3B.js} +10 -12
  290. package/dist/cli-bundle/chunks/{eval-QGR7JCQO.js.map → eval-PFKXQR3B.js.map} +1 -1
  291. package/dist/cli-bundle/chunks/{extension-3JYWJ5K2.js → extension-3LRYX7SW.js} +11 -7
  292. package/dist/cli-bundle/chunks/{extension-YQF4CPIR.js → extension-GMVOIP4O.js} +11 -7
  293. package/dist/cli-bundle/chunks/{files-5BQWDRDT.js → files-DF3HO6XK.js} +11 -13
  294. package/dist/cli-bundle/chunks/{files-5BQWDRDT.js.map → files-DF3HO6XK.js.map} +1 -1
  295. package/dist/cli-bundle/chunks/{files-EPEJMJHQ.js → files-T5ODMETM.js} +9 -11
  296. package/dist/cli-bundle/chunks/{files-EPEJMJHQ.js.map → files-T5ODMETM.js.map} +1 -1
  297. package/dist/cli-bundle/chunks/{focus-RWGKD76E.js → focus-DLXKK4AH.js} +10 -14
  298. package/dist/cli-bundle/chunks/{focus-RWGKD76E.js.map → focus-DLXKK4AH.js.map} +1 -1
  299. package/dist/cli-bundle/chunks/{focus-DQVJAPOE.js → focus-MY5ARIEK.js} +8 -12
  300. package/dist/cli-bundle/chunks/{focus-DQVJAPOE.js.map → focus-MY5ARIEK.js.map} +1 -1
  301. package/dist/cli-bundle/chunks/{gc-BEJMQT64.js → gc-FULIVYR4.js} +3 -3
  302. package/dist/cli-bundle/chunks/{gc-JEFQDJPA.js → gc-MDGRR2SU.js} +3 -3
  303. package/dist/cli-bundle/chunks/{get-LQG6PEVG.js → get-AWK324RS.js} +10 -13
  304. package/dist/cli-bundle/chunks/{get-LQG6PEVG.js.map → get-AWK324RS.js.map} +1 -1
  305. package/dist/cli-bundle/chunks/{get-WVN75H42.js → get-VYPIICPC.js} +12 -15
  306. package/dist/cli-bundle/chunks/{get-WVN75H42.js.map → get-VYPIICPC.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/{health-P67NZ6TT.js → health-FBCVZGSX.js} +16 -17
  308. package/dist/cli-bundle/chunks/{health-P67NZ6TT.js.map → health-FBCVZGSX.js.map} +1 -1
  309. package/dist/cli-bundle/chunks/{health-JJJOY7DJ.js → health-Q66C43GN.js} +18 -19
  310. package/dist/cli-bundle/chunks/{health-JJJOY7DJ.js.map → health-Q66C43GN.js.map} +1 -1
  311. package/dist/cli-bundle/chunks/history-5XUSLAJA.js +18 -0
  312. package/dist/cli-bundle/chunks/{history-RUKPKNY7.js → history-X4OSES6K.js} +8 -10
  313. package/dist/cli-bundle/chunks/{history-compact-ZAOWR7GD.js → history-compact-2GHT32UX.js} +13 -16
  314. package/dist/cli-bundle/chunks/{history-compact-ZAOWR7GD.js.map → history-compact-2GHT32UX.js.map} +1 -1
  315. package/dist/cli-bundle/chunks/{history-compact-NQ7VPRVT.js → history-compact-WLCQEKXS.js} +11 -14
  316. package/dist/cli-bundle/chunks/{history-compact-NQ7VPRVT.js.map → history-compact-WLCQEKXS.js.map} +1 -1
  317. package/dist/cli-bundle/chunks/{history-redact-YY4XYVEP.js → history-redact-45YW65BK.js} +9 -11
  318. package/dist/cli-bundle/chunks/history-redact-BVHWDXPR.js +19 -0
  319. package/dist/cli-bundle/chunks/{history-repair-YSQH6SY6.js → history-repair-FY75IC26.js} +13 -16
  320. package/dist/cli-bundle/chunks/{history-repair-YSQH6SY6.js.map → history-repair-FY75IC26.js.map} +1 -1
  321. package/dist/cli-bundle/chunks/{history-repair-EHL4ODQY.js → history-repair-GABSDSVD.js} +11 -14
  322. package/dist/cli-bundle/chunks/{history-repair-EHL4ODQY.js.map → history-repair-GABSDSVD.js.map} +1 -1
  323. package/dist/cli-bundle/chunks/{init-HBFGYS66.js → init-KO7CGIRQ.js} +11 -11
  324. package/dist/cli-bundle/chunks/init-TRYJELH4.js +21 -0
  325. package/dist/cli-bundle/chunks/{learnings-KFQO7GEZ.js → learnings-3F7YLI45.js} +9 -11
  326. package/dist/cli-bundle/chunks/{learnings-KFQO7GEZ.js.map → learnings-3F7YLI45.js.map} +1 -1
  327. package/dist/cli-bundle/chunks/{learnings-J555ZFPD.js → learnings-LHZT5BHW.js} +11 -13
  328. package/dist/cli-bundle/chunks/{learnings-J555ZFPD.js.map → learnings-LHZT5BHW.js.map} +1 -1
  329. package/dist/cli-bundle/chunks/{list-C7R33MD5.js → list-ROT7JF62.js} +10 -10
  330. package/dist/cli-bundle/chunks/{list-DSN6UNFB.js → list-Y6AU5BJS.js} +10 -10
  331. package/dist/cli-bundle/chunks/next-66BJB4N2.js +277 -0
  332. package/dist/cli-bundle/chunks/next-66BJB4N2.js.map +7 -0
  333. package/dist/cli-bundle/chunks/next-N5MWJTBY.js +274 -0
  334. package/dist/cli-bundle/chunks/next-N5MWJTBY.js.map +1 -0
  335. package/dist/cli-bundle/chunks/{notes-VYJFN2A3.js → notes-EVJZ3VAB.js} +11 -13
  336. package/dist/cli-bundle/chunks/{notes-VYJFN2A3.js.map → notes-EVJZ3VAB.js.map} +1 -1
  337. package/dist/cli-bundle/chunks/{notes-V4VNIQL4.js → notes-FW6YFLND.js} +9 -11
  338. package/dist/cli-bundle/chunks/{notes-V4VNIQL4.js.map → notes-FW6YFLND.js.map} +1 -1
  339. package/dist/cli-bundle/chunks/{plan-RBHQ5PO7.js → plan-DQ7G4EDC.js} +15 -18
  340. package/dist/cli-bundle/chunks/{plan-RBHQ5PO7.js.map → plan-DQ7G4EDC.js.map} +1 -1
  341. package/dist/cli-bundle/chunks/{plan-DHRSVSHR.js → plan-ZHKZ7JVF.js} +17 -20
  342. package/dist/cli-bundle/chunks/{plan-DHRSVSHR.js.map → plan-ZHKZ7JVF.js.map} +1 -1
  343. package/dist/cli-bundle/chunks/profile-CHAW6SEA.js +1197 -0
  344. package/dist/cli-bundle/chunks/profile-CHAW6SEA.js.map +1 -0
  345. package/dist/cli-bundle/chunks/profile-UPZGCDOG.js +1235 -0
  346. package/dist/cli-bundle/chunks/profile-UPZGCDOG.js.map +7 -0
  347. package/dist/cli-bundle/chunks/{register-list-query-CCMHGZTF.js → register-list-query-KY6Z6WV7.js} +44 -20
  348. package/dist/cli-bundle/chunks/register-list-query-KY6Z6WV7.js.map +7 -0
  349. package/dist/cli-bundle/chunks/{register-list-query-OM3E2KMY.js → register-list-query-Y2VRHPCL.js} +45 -21
  350. package/dist/cli-bundle/chunks/register-list-query-Y2VRHPCL.js.map +1 -0
  351. package/dist/cli-bundle/chunks/{register-mutation-UXTTWL6N.js → register-mutation-N6AYSKPM.js} +103 -37
  352. package/dist/cli-bundle/chunks/register-mutation-N6AYSKPM.js.map +7 -0
  353. package/dist/cli-bundle/chunks/{register-mutation-N3CDEGZU.js → register-mutation-PCARIGZS.js} +104 -38
  354. package/dist/cli-bundle/chunks/register-mutation-PCARIGZS.js.map +1 -0
  355. package/dist/cli-bundle/chunks/{register-operations-R2FLOCRI.js → register-operations-L6CYTOIH.js} +30 -32
  356. package/dist/cli-bundle/chunks/{register-operations-R2FLOCRI.js.map → register-operations-L6CYTOIH.js.map} +1 -1
  357. package/dist/cli-bundle/chunks/{register-operations-UDIFMQKD.js → register-operations-YAT6FUUB.js} +32 -34
  358. package/dist/cli-bundle/chunks/{register-operations-UDIFMQKD.js.map → register-operations-YAT6FUUB.js.map} +1 -1
  359. package/dist/cli-bundle/chunks/{register-setup-TWHKICM2.js → register-setup-MPANILQF.js} +67 -24
  360. package/dist/cli-bundle/chunks/register-setup-MPANILQF.js.map +7 -0
  361. package/dist/cli-bundle/chunks/{register-setup-G5LTSFYK.js → register-setup-N7UGXYJC.js} +68 -25
  362. package/dist/cli-bundle/chunks/register-setup-N7UGXYJC.js.map +1 -0
  363. package/dist/cli-bundle/chunks/{restore-LL2WLEDG.js → restore-DKMCLPI5.js} +9 -11
  364. package/dist/cli-bundle/chunks/restore-IRAKSWIW.js +17 -0
  365. package/dist/cli-bundle/chunks/{scheduling-shortcuts-M4H2ZI64.js → scheduling-shortcuts-3F4QUEDH.js} +14 -16
  366. package/dist/cli-bundle/chunks/{scheduling-shortcuts-M4H2ZI64.js.map → scheduling-shortcuts-3F4QUEDH.js.map} +1 -1
  367. package/dist/cli-bundle/chunks/{scheduling-shortcuts-255GI3BU.js → scheduling-shortcuts-BNZLQK36.js} +12 -14
  368. package/dist/cli-bundle/chunks/{scheduling-shortcuts-255GI3BU.js.map → scheduling-shortcuts-BNZLQK36.js.map} +1 -1
  369. package/dist/cli-bundle/chunks/schema-OLT6LVKH.js +75 -0
  370. package/dist/cli-bundle/chunks/schema-XJXKJQF5.js +71 -0
  371. package/dist/cli-bundle/chunks/{search-2EI6EAXH.js → search-CX5UMV4H.js} +10 -12
  372. package/dist/cli-bundle/chunks/{search-QBFBLQRO.js → search-KP6H7COV.js} +10 -12
  373. package/dist/cli-bundle/chunks/{stats-TCW2SZQG.js → stats-7XW4OEMK.js} +20 -12
  374. package/dist/cli-bundle/chunks/stats-7XW4OEMK.js.map +7 -0
  375. package/dist/cli-bundle/chunks/{stats-TKC6CAKB.js → stats-QZUG6MX5.js} +21 -13
  376. package/dist/cli-bundle/chunks/stats-QZUG6MX5.js.map +1 -0
  377. package/dist/cli-bundle/chunks/{telemetry-LQ6FRTUT.js → telemetry-DIFPXCAT.js} +4 -4
  378. package/dist/cli-bundle/chunks/{telemetry-BT2VSWU2.js → telemetry-WTYFUPRL.js} +4 -4
  379. package/dist/cli-bundle/chunks/{test-NV2DRPUS.js → test-HU2BS7EY.js} +14 -16
  380. package/dist/cli-bundle/chunks/test-HU2BS7EY.js.map +1 -0
  381. package/dist/cli-bundle/chunks/test-QNDXZQCW.js +34 -0
  382. package/dist/cli-bundle/chunks/test-QNDXZQCW.js.map +7 -0
  383. package/dist/cli-bundle/chunks/{test-all-REW67LXT.js → test-all-PZTBLLQ6.js} +17 -20
  384. package/dist/cli-bundle/chunks/{test-all-REW67LXT.js.map → test-all-PZTBLLQ6.js.map} +1 -1
  385. package/dist/cli-bundle/chunks/{test-all-DZ76VTPQ.js → test-all-XLPI4USF.js} +19 -22
  386. package/dist/cli-bundle/chunks/{test-all-DZ76VTPQ.js.map → test-all-XLPI4USF.js.map} +1 -1
  387. package/dist/cli-bundle/chunks/{test-runs-FQ5WNQLP.js → test-runs-CA6K32RD.js} +6 -7
  388. package/dist/cli-bundle/chunks/test-runs-CA6K32RD.js.map +1 -0
  389. package/dist/cli-bundle/chunks/{test-runs-PX73DMMI.js → test-runs-LANLLPVO.js} +5 -6
  390. package/dist/cli-bundle/chunks/test-runs-LANLLPVO.js.map +7 -0
  391. package/dist/cli-bundle/chunks/update-DJKWLBWJ.js +28 -0
  392. package/dist/cli-bundle/chunks/update-DJKWLBWJ.js.map +1 -0
  393. package/dist/cli-bundle/chunks/update-UXDLTEOZ.js +24 -0
  394. package/dist/cli-bundle/chunks/update-UXDLTEOZ.js.map +7 -0
  395. package/dist/cli-bundle/chunks/{update-many-2ILP6E4Y.js → update-many-LU3SCNK5.js} +32 -33
  396. package/dist/cli-bundle/chunks/{update-many-2ILP6E4Y.js.map → update-many-LU3SCNK5.js.map} +1 -1
  397. package/dist/cli-bundle/chunks/{update-many-Q5ZEI64S.js → update-many-VW5DGF3S.js} +34 -35
  398. package/dist/cli-bundle/chunks/{update-many-Q5ZEI64S.js.map → update-many-VW5DGF3S.js.map} +1 -1
  399. package/dist/cli-bundle/chunks/{upgrade-FOZKQTQF.js → upgrade-77FRUAXN.js} +12 -8
  400. package/dist/cli-bundle/chunks/{upgrade-FOZKQTQF.js.map → upgrade-77FRUAXN.js.map} +1 -1
  401. package/dist/cli-bundle/chunks/{upgrade-DHL74PQH.js → upgrade-ICXY244R.js} +10 -6
  402. package/dist/cli-bundle/chunks/{upgrade-DHL74PQH.js.map → upgrade-ICXY244R.js.map} +1 -1
  403. package/dist/cli-bundle/chunks/{validate-HYZNIB6W.js → validate-2G566PKQ.js} +37 -28
  404. package/dist/cli-bundle/chunks/validate-2G566PKQ.js.map +7 -0
  405. package/dist/cli-bundle/chunks/{validate-54SYJ7QW.js → validate-BDPVXHHH.js} +38 -29
  406. package/dist/cli-bundle/chunks/validate-BDPVXHHH.js.map +1 -0
  407. package/dist/cli-bundle/main.js +56 -38
  408. package/dist/cli-bundle/main.js.map +2 -2
  409. package/dist/core/config/positional-value.d.ts +2 -0
  410. package/dist/core/config/positional-value.js +2 -2
  411. package/dist/core/config/positional-value.js.map +1 -1
  412. package/dist/core/extensions/activation-summary-markdown.d.ts +71 -0
  413. package/dist/core/extensions/activation-summary-markdown.js +140 -0
  414. package/dist/core/extensions/activation-summary-markdown.js.map +1 -0
  415. package/dist/core/extensions/activation-summary.d.ts +2 -0
  416. package/dist/core/extensions/activation-summary.js +3 -2
  417. package/dist/core/extensions/activation-summary.js.map +1 -1
  418. package/dist/core/extensions/capability-usage.d.ts +1 -1
  419. package/dist/core/extensions/capability-usage.js +4 -3
  420. package/dist/core/extensions/capability-usage.js.map +1 -1
  421. package/dist/core/extensions/extension-registries.js +3 -2
  422. package/dist/core/extensions/extension-registries.js.map +1 -1
  423. package/dist/core/extensions/extension-types.d.ts +21 -1
  424. package/dist/core/extensions/extension-types.js +3 -2
  425. package/dist/core/extensions/extension-types.js.map +1 -1
  426. package/dist/core/extensions/loader.js +131 -2
  427. package/dist/core/extensions/loader.js.map +1 -1
  428. package/dist/core/fs/fs-utils.js +27 -2
  429. package/dist/core/fs/fs-utils.js.map +1 -1
  430. package/dist/core/item/actionability.d.ts +57 -0
  431. package/dist/core/item/actionability.js +178 -0
  432. package/dist/core/item/actionability.js.map +1 -0
  433. package/dist/core/item/type-registry.js +18 -45
  434. package/dist/core/item/type-registry.js.map +1 -1
  435. package/dist/core/profile/profile-describe.d.ts +64 -0
  436. package/dist/core/profile/profile-describe.js +83 -0
  437. package/dist/core/profile/profile-describe.js.map +1 -0
  438. package/dist/core/profile/profile-lint.d.ts +53 -0
  439. package/dist/core/profile/profile-lint.js +422 -0
  440. package/dist/core/profile/profile-lint.js.map +1 -0
  441. package/dist/core/profile/profile-plan.d.ts +145 -0
  442. package/dist/core/profile/profile-plan.js +0 -0
  443. package/dist/core/profile/profile-plan.js.map +1 -0
  444. package/dist/core/profile/profile-presets.d.ts +218 -0
  445. package/dist/core/profile/profile-presets.js +325 -0
  446. package/dist/core/profile/profile-presets.js.map +1 -0
  447. package/dist/core/schema/fields-file.js +25 -25
  448. package/dist/core/schema/fields-file.js.map +1 -1
  449. package/dist/core/schema/item-types-file.js +3 -3
  450. package/dist/core/schema/item-types-file.js.map +1 -1
  451. package/dist/core/schema/runtime-schema.js +4 -4
  452. package/dist/core/schema/runtime-schema.js.map +1 -1
  453. package/dist/core/schema/status-defs-file.js +3 -3
  454. package/dist/core/schema/status-defs-file.js.map +1 -1
  455. package/dist/core/shared/serialization.js +83 -62
  456. package/dist/core/shared/serialization.js.map +1 -1
  457. package/dist/core/store/item-store.d.ts +1 -0
  458. package/dist/core/store/item-store.js +16 -8
  459. package/dist/core/store/item-store.js.map +1 -1
  460. package/dist/core/store/paths.js +4 -32
  461. package/dist/core/store/paths.js.map +1 -1
  462. package/dist/core/store/settings.js +14 -14
  463. package/dist/core/store/settings.js.map +1 -1
  464. package/dist/core/telemetry/observability.js +50 -54
  465. package/dist/core/telemetry/observability.js.map +1 -1
  466. package/dist/core/telemetry/runtime.js +11 -2
  467. package/dist/core/telemetry/runtime.js.map +1 -1
  468. package/dist/core/test/background-runs.js +3 -2
  469. package/dist/core/test/background-runs.js.map +1 -1
  470. package/dist/core/validate/linked-artifact-reference.d.ts +24 -0
  471. package/dist/core/validate/linked-artifact-reference.js +41 -0
  472. package/dist/core/validate/linked-artifact-reference.js.map +1 -0
  473. package/dist/mcp/server.js +183 -83
  474. package/dist/mcp/server.js.map +1 -1
  475. package/dist/mcp/tool-definitions.js +33 -2
  476. package/dist/mcp/tool-definitions.js.map +1 -1
  477. package/dist/sdk/cli-contracts/commander-types.d.ts +1 -0
  478. package/dist/sdk/cli-contracts/commander-types.js +15 -2
  479. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  480. package/dist/sdk/cli-contracts/enum-contracts.d.ts +3 -3
  481. package/dist/sdk/cli-contracts/enum-contracts.js +6 -2
  482. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  483. package/dist/sdk/cli-contracts/flag-contracts.d.ts +149 -0
  484. package/dist/sdk/cli-contracts/flag-contracts.js +1583 -0
  485. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -0
  486. package/dist/sdk/cli-contracts/string-lists.d.ts +14 -0
  487. package/dist/sdk/cli-contracts/string-lists.js +20 -0
  488. package/dist/sdk/cli-contracts/string-lists.js.map +1 -0
  489. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -1
  490. package/dist/sdk/cli-contracts/tool-option-contracts.js +51 -109
  491. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  492. package/dist/sdk/cli-contracts/tool-parameter-tables.d.ts +17 -0
  493. package/dist/sdk/cli-contracts/tool-parameter-tables.js +54 -5
  494. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  495. package/dist/sdk/cli-contracts/tool-schema.d.ts +74 -0
  496. package/dist/sdk/cli-contracts/tool-schema.js +840 -0
  497. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -0
  498. package/dist/sdk/cli-contracts.d.ts +13 -193
  499. package/dist/sdk/cli-contracts.js +5 -2277
  500. package/dist/sdk/cli-contracts.js.map +1 -1
  501. package/dist/sdk/compose.d.ts +7 -4
  502. package/dist/sdk/compose.js +64 -14
  503. package/dist/sdk/compose.js.map +1 -1
  504. package/dist/sdk/define.d.ts +14 -0
  505. package/dist/sdk/define.js +17 -2
  506. package/dist/sdk/define.js.map +1 -1
  507. package/dist/sdk/index.d.ts +14 -3
  508. package/dist/sdk/index.js +14 -3
  509. package/dist/sdk/index.js.map +1 -1
  510. package/dist/sdk/testing.d.ts +82 -2
  511. package/dist/sdk/testing.js +74 -3
  512. package/dist/sdk/testing.js.map +1 -1
  513. package/docs/AGENT_GUIDE.md +2 -0
  514. package/docs/CLAUDE_CODE_PLUGIN.md +2 -2
  515. package/docs/COMMANDS.md +37 -0
  516. package/docs/EXTENSIONS.md +12 -13
  517. package/docs/RELEASING.md +6 -1
  518. package/docs/SDK.md +184 -17
  519. package/docs/TESTING.md +12 -0
  520. package/docs/examples/policy-restricted-extension/README.md +6 -0
  521. package/docs/examples/policy-restricted-extension/index.ts +40 -0
  522. package/docs/examples/policy-restricted-extension/manifest.json +2 -2
  523. package/docs/examples/starter-extension/README.md +14 -2
  524. package/docs/examples/starter-extension/{index.js → index.ts} +51 -6
  525. package/docs/examples/starter-extension/manifest.json +2 -2
  526. package/package.json +20 -7
  527. package/packages/pm-beads/extensions/beads/index.ts +3 -3
  528. package/packages/pm-beads/extensions/beads/manifest.json +2 -2
  529. package/packages/pm-beads/extensions/beads/runtime-loader.ts +19 -7
  530. package/packages/pm-beads/extensions/beads/runtime.ts +155 -37
  531. package/packages/pm-calendar/extensions/calendar/index.ts +3 -3
  532. package/packages/pm-calendar/extensions/calendar/manifest.json +2 -2
  533. package/packages/pm-calendar/extensions/calendar/runtime.ts +2 -2
  534. package/packages/pm-command-kit/extensions/command-kit/index.ts +1 -1
  535. package/packages/pm-command-kit/extensions/command-kit/manifest.json +2 -2
  536. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +2 -2
  537. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +2 -2
  538. package/packages/pm-governance-audit/extensions/governance-audit/runtime.ts +1 -1
  539. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +2 -2
  540. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +2 -2
  541. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +1 -1
  542. package/packages/pm-kanban/README.md +97 -0
  543. package/packages/pm-kanban/extensions/kanban/index.ts +191 -0
  544. package/packages/pm-kanban/extensions/kanban/manifest.json +19 -0
  545. package/packages/pm-kanban/package.json +57 -0
  546. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +1 -1
  547. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +2 -2
  548. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.ts +2 -2
  549. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +2 -2
  550. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.ts +1 -1
  551. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +2 -2
  552. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +2 -2
  553. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +1 -1
  554. package/packages/pm-templates/extensions/templates/index.ts +2 -2
  555. package/packages/pm-templates/extensions/templates/manifest.json +2 -2
  556. package/packages/pm-templates/extensions/templates/runtime.ts +1 -1
  557. package/packages/pm-todos/extensions/todos/index.ts +3 -3
  558. package/packages/pm-todos/extensions/todos/manifest.json +2 -2
  559. package/packages/pm-todos/extensions/todos/runtime-loader.ts +19 -7
  560. package/packages/pm-todos/extensions/todos/runtime.ts +177 -43
  561. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +2 -2
  562. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +2 -2
  563. package/scripts/bundle-cli.mjs +1 -1
  564. package/dist/cli-bundle/chunks/activity-54TXGJ2T.js +0 -18
  565. package/dist/cli-bundle/chunks/aggregate-63NWNIBR.js.map +0 -1
  566. package/dist/cli-bundle/chunks/aggregate-YHCYX2EV.js.map +0 -7
  567. package/dist/cli-bundle/chunks/chunk-6EL7SW5C.js.map +0 -7
  568. package/dist/cli-bundle/chunks/chunk-6W3Y65PL.js.map +0 -7
  569. package/dist/cli-bundle/chunks/chunk-AEACLRVH.js.map +0 -7
  570. package/dist/cli-bundle/chunks/chunk-B74BP6IS.js +0 -78
  571. package/dist/cli-bundle/chunks/chunk-B74BP6IS.js.map +0 -7
  572. package/dist/cli-bundle/chunks/chunk-BFFO3AIB.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-EYPINTFR.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-FBLT6WGK.js +0 -75
  575. package/dist/cli-bundle/chunks/chunk-FBLT6WGK.js.map +0 -1
  576. package/dist/cli-bundle/chunks/chunk-GQYJEEFX.js.map +0 -1
  577. package/dist/cli-bundle/chunks/chunk-HBAEFWX3.js.map +0 -7
  578. package/dist/cli-bundle/chunks/chunk-HC2S36NB.js.map +0 -1
  579. package/dist/cli-bundle/chunks/chunk-IAP5KYBQ.js.map +0 -1
  580. package/dist/cli-bundle/chunks/chunk-INPHFO33.js +0 -764
  581. package/dist/cli-bundle/chunks/chunk-INPHFO33.js.map +0 -7
  582. package/dist/cli-bundle/chunks/chunk-IOT6WRL5.js +0 -86
  583. package/dist/cli-bundle/chunks/chunk-IOT6WRL5.js.map +0 -7
  584. package/dist/cli-bundle/chunks/chunk-J7I4C5ZB.js.map +0 -7
  585. package/dist/cli-bundle/chunks/chunk-JKL6HRMV.js.map +0 -7
  586. package/dist/cli-bundle/chunks/chunk-KJZOSF7J.js.map +0 -1
  587. package/dist/cli-bundle/chunks/chunk-L7UXKP2I.js.map +0 -1
  588. package/dist/cli-bundle/chunks/chunk-LNEDHJNQ.js.map +0 -1
  589. package/dist/cli-bundle/chunks/chunk-M6TUBOGW.js.map +0 -1
  590. package/dist/cli-bundle/chunks/chunk-MEXZ5XUM.js.map +0 -7
  591. package/dist/cli-bundle/chunks/chunk-N5B6WZC5.js.map +0 -1
  592. package/dist/cli-bundle/chunks/chunk-NJ73ALW2.js +0 -761
  593. package/dist/cli-bundle/chunks/chunk-NJ73ALW2.js.map +0 -1
  594. package/dist/cli-bundle/chunks/chunk-NVXGVEFD.js +0 -83
  595. package/dist/cli-bundle/chunks/chunk-NVXGVEFD.js.map +0 -1
  596. package/dist/cli-bundle/chunks/chunk-OF7V47P3.js.map +0 -1
  597. package/dist/cli-bundle/chunks/chunk-OHDQNKJB.js.map +0 -7
  598. package/dist/cli-bundle/chunks/chunk-PRVTGX64.js.map +0 -7
  599. package/dist/cli-bundle/chunks/chunk-RAWA3Y7O.js.map +0 -1
  600. package/dist/cli-bundle/chunks/chunk-SMXSDY7J.js.map +0 -7
  601. package/dist/cli-bundle/chunks/chunk-SUREE24M.js.map +0 -1
  602. package/dist/cli-bundle/chunks/chunk-TKPP4GOO.js +0 -654
  603. package/dist/cli-bundle/chunks/chunk-TKPP4GOO.js.map +0 -1
  604. package/dist/cli-bundle/chunks/chunk-VSAABFGQ.js.map +0 -1
  605. package/dist/cli-bundle/chunks/chunk-XVYKWZNL.js.map +0 -7
  606. package/dist/cli-bundle/chunks/chunk-XXKV4UWE.js.map +0 -7
  607. package/dist/cli-bundle/chunks/chunk-ZV7IQ23N.js +0 -657
  608. package/dist/cli-bundle/chunks/chunk-ZV7IQ23N.js.map +0 -7
  609. package/dist/cli-bundle/chunks/close-JEBZXONN.js +0 -15
  610. package/dist/cli-bundle/chunks/config-NCNNWF6R.js.map +0 -7
  611. package/dist/cli-bundle/chunks/config-SW3U7XP2.js.map +0 -1
  612. package/dist/cli-bundle/chunks/context-55VEOYI3.js.map +0 -1
  613. package/dist/cli-bundle/chunks/context-5LB7UGKE.js.map +0 -7
  614. package/dist/cli-bundle/chunks/contracts-JXFGBOYT.js.map +0 -1
  615. package/dist/cli-bundle/chunks/contracts-SY6PDFIK.js.map +0 -7
  616. package/dist/cli-bundle/chunks/create-CLSCHGJJ.js +0 -30
  617. package/dist/cli-bundle/chunks/history-ALTM2RRP.js +0 -20
  618. package/dist/cli-bundle/chunks/history-redact-5YGLWUDH.js +0 -21
  619. package/dist/cli-bundle/chunks/init-C4CRHW22.js +0 -21
  620. package/dist/cli-bundle/chunks/register-list-query-CCMHGZTF.js.map +0 -7
  621. package/dist/cli-bundle/chunks/register-list-query-OM3E2KMY.js.map +0 -1
  622. package/dist/cli-bundle/chunks/register-mutation-N3CDEGZU.js.map +0 -1
  623. package/dist/cli-bundle/chunks/register-mutation-UXTTWL6N.js.map +0 -7
  624. package/dist/cli-bundle/chunks/register-setup-G5LTSFYK.js.map +0 -1
  625. package/dist/cli-bundle/chunks/register-setup-TWHKICM2.js.map +0 -7
  626. package/dist/cli-bundle/chunks/restore-LQHXBAY5.js +0 -19
  627. package/dist/cli-bundle/chunks/schema-C6QA367T.js.map +0 -7
  628. package/dist/cli-bundle/chunks/schema-QO5I4FBL.js.map +0 -1
  629. package/dist/cli-bundle/chunks/stats-TCW2SZQG.js.map +0 -7
  630. package/dist/cli-bundle/chunks/stats-TKC6CAKB.js.map +0 -1
  631. package/dist/cli-bundle/chunks/test-WA6RZGM2.js +0 -36
  632. package/dist/cli-bundle/chunks/test-runs-FQ5WNQLP.js.map +0 -1
  633. package/dist/cli-bundle/chunks/test-runs-PX73DMMI.js.map +0 -7
  634. package/dist/cli-bundle/chunks/update-BSKMQOYH.js +0 -28
  635. package/dist/cli-bundle/chunks/update-FIGYNQ2I.js +0 -24
  636. package/dist/cli-bundle/chunks/validate-54SYJ7QW.js.map +0 -1
  637. package/dist/cli-bundle/chunks/validate-HYZNIB6W.js.map +0 -7
  638. package/docs/examples/policy-restricted-extension/index.js +0 -21
  639. package/packages/pm-beads/extensions/beads/index.js +0 -64
  640. package/packages/pm-beads/extensions/beads/runtime-loader.js +0 -86
  641. package/packages/pm-beads/extensions/beads/runtime.js +0 -482
  642. package/packages/pm-calendar/extensions/calendar/index.js +0 -150
  643. package/packages/pm-calendar/extensions/calendar/runtime.js +0 -126
  644. package/packages/pm-command-kit/extensions/command-kit/index.js +0 -181
  645. package/packages/pm-governance-audit/extensions/governance-audit/index.js +0 -177
  646. package/packages/pm-governance-audit/extensions/governance-audit/runtime.js +0 -153
  647. package/packages/pm-guide-shell/extensions/guide-shell/index.js +0 -98
  648. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +0 -294
  649. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +0 -18
  650. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.js +0 -124
  651. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.js +0 -110
  652. package/packages/pm-search-advanced/extensions/search-advanced/index.js +0 -258
  653. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +0 -361
  654. package/packages/pm-templates/extensions/templates/index.js +0 -132
  655. package/packages/pm-templates/extensions/templates/runtime.js +0 -35
  656. package/packages/pm-todos/extensions/todos/index.js +0 -81
  657. package/packages/pm-todos/extensions/todos/runtime-loader.js +0 -86
  658. package/packages/pm-todos/extensions/todos/runtime.js +0 -545
  659. /package/dist/cli-bundle/chunks/{activity-54TXGJ2T.js.map → activity-EJBMXUBH.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{activity-N7RVTLBQ.js.map → activity-MVSEND6D.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{chunk-F32L4HR6.js.map → chunk-3JWQCLR5.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{chunk-YV2OSAMS.js.map → chunk-4TXTVZL3.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{chunk-AYPQUFCX.js.map → chunk-4YIMPANT.js.map} +0 -0
  664. /package/dist/cli-bundle/chunks/{chunk-EOGBMLCE.js.map → chunk-73PTKMAE.js.map} +0 -0
  665. /package/dist/cli-bundle/chunks/{chunk-2WCYE3IF.js.map → chunk-7RIJGN4R.js.map} +0 -0
  666. /package/dist/cli-bundle/chunks/{chunk-CZIFFMZI.js.map → chunk-BN3CWK6G.js.map} +0 -0
  667. /package/dist/cli-bundle/chunks/{chunk-J3NMWFIN.js.map → chunk-C2KCIZKZ.js.map} +0 -0
  668. /package/dist/cli-bundle/chunks/{chunk-TIM4OD74.js.map → chunk-CHRNYKNI.js.map} +0 -0
  669. /package/dist/cli-bundle/chunks/{chunk-KIEAK7YE.js.map → chunk-D6USKAMA.js.map} +0 -0
  670. /package/dist/cli-bundle/chunks/{chunk-3BKH2CL3.js.map → chunk-DLDCPF5X.js.map} +0 -0
  671. /package/dist/cli-bundle/chunks/{chunk-CG3KP6I5.js.map → chunk-E2Q2ULMR.js.map} +0 -0
  672. /package/dist/cli-bundle/chunks/{chunk-PEL2NLQE.js.map → chunk-F6VH3LFC.js.map} +0 -0
  673. /package/dist/cli-bundle/chunks/{chunk-5BBEWX6C.js.map → chunk-FDEVKXC4.js.map} +0 -0
  674. /package/dist/cli-bundle/chunks/{chunk-QOUOMPHO.js.map → chunk-HUYYMTGW.js.map} +0 -0
  675. /package/dist/cli-bundle/chunks/{chunk-KKX4Z2SE.js.map → chunk-IHXXUIXS.js.map} +0 -0
  676. /package/dist/cli-bundle/chunks/{chunk-F4BNR2IN.js.map → chunk-JIP67N2K.js.map} +0 -0
  677. /package/dist/cli-bundle/chunks/{chunk-FMWW2JDU.js.map → chunk-KRASIL6M.js.map} +0 -0
  678. /package/dist/cli-bundle/chunks/{chunk-I6QMJ2XT.js.map → chunk-MLHX6DN5.js.map} +0 -0
  679. /package/dist/cli-bundle/chunks/{chunk-5S4ZGDB2.js.map → chunk-OB3RJV5F.js.map} +0 -0
  680. /package/dist/cli-bundle/chunks/{chunk-SKC4UTRP.js.map → chunk-OUQ5JEFM.js.map} +0 -0
  681. /package/dist/cli-bundle/chunks/{chunk-JPJDP4VU.js.map → chunk-QE5UFCCO.js.map} +0 -0
  682. /package/dist/cli-bundle/chunks/{chunk-WB5BYQMF.js.map → chunk-SJZTPVFT.js.map} +0 -0
  683. /package/dist/cli-bundle/chunks/{chunk-ZLWRPBOW.js.map → chunk-V3KLX7U7.js.map} +0 -0
  684. /package/dist/cli-bundle/chunks/{chunk-OQ2E64FH.js.map → chunk-Z5BM2FKQ.js.map} +0 -0
  685. /package/dist/cli-bundle/chunks/{chunk-IXAZI443.js.map → chunk-ZEATCVAC.js.map} +0 -0
  686. /package/dist/cli-bundle/chunks/{chunk-C4C3EJCJ.js.map → chunk-ZFIEEDTJ.js.map} +0 -0
  687. /package/dist/cli-bundle/chunks/{close-JEBZXONN.js.map → close-37KEHLYM.js.map} +0 -0
  688. /package/dist/cli-bundle/chunks/{close-QHMVWM7M.js.map → close-OP3LK7Z2.js.map} +0 -0
  689. /package/dist/cli-bundle/chunks/{create-CLSCHGJJ.js.map → context-7ZEZV3BV.js.map} +0 -0
  690. /package/dist/cli-bundle/chunks/{create-O4VONGPG.js.map → context-XDI4DKKT.js.map} +0 -0
  691. /package/dist/cli-bundle/chunks/{extension-YQF4CPIR.js.map → create-DFMNBKBS.js.map} +0 -0
  692. /package/dist/cli-bundle/chunks/{extension-3JYWJ5K2.js.map → create-J5Q2ELZT.js.map} +0 -0
  693. /package/dist/cli-bundle/chunks/{history-RUKPKNY7.js.map → extension-3LRYX7SW.js.map} +0 -0
  694. /package/dist/cli-bundle/chunks/{history-ALTM2RRP.js.map → extension-GMVOIP4O.js.map} +0 -0
  695. /package/dist/cli-bundle/chunks/{gc-BEJMQT64.js.map → gc-FULIVYR4.js.map} +0 -0
  696. /package/dist/cli-bundle/chunks/{gc-JEFQDJPA.js.map → gc-MDGRR2SU.js.map} +0 -0
  697. /package/dist/cli-bundle/chunks/{history-redact-5YGLWUDH.js.map → history-5XUSLAJA.js.map} +0 -0
  698. /package/dist/cli-bundle/chunks/{history-redact-YY4XYVEP.js.map → history-X4OSES6K.js.map} +0 -0
  699. /package/dist/cli-bundle/chunks/{init-HBFGYS66.js.map → history-redact-45YW65BK.js.map} +0 -0
  700. /package/dist/cli-bundle/chunks/{init-C4CRHW22.js.map → history-redact-BVHWDXPR.js.map} +0 -0
  701. /package/dist/cli-bundle/chunks/{list-C7R33MD5.js.map → init-KO7CGIRQ.js.map} +0 -0
  702. /package/dist/cli-bundle/chunks/{list-DSN6UNFB.js.map → init-TRYJELH4.js.map} +0 -0
  703. /package/dist/cli-bundle/chunks/{restore-LL2WLEDG.js.map → list-ROT7JF62.js.map} +0 -0
  704. /package/dist/cli-bundle/chunks/{restore-LQHXBAY5.js.map → list-Y6AU5BJS.js.map} +0 -0
  705. /package/dist/cli-bundle/chunks/{search-2EI6EAXH.js.map → restore-DKMCLPI5.js.map} +0 -0
  706. /package/dist/cli-bundle/chunks/{search-QBFBLQRO.js.map → restore-IRAKSWIW.js.map} +0 -0
  707. /package/dist/cli-bundle/chunks/{test-NV2DRPUS.js.map → schema-OLT6LVKH.js.map} +0 -0
  708. /package/dist/cli-bundle/chunks/{test-WA6RZGM2.js.map → schema-XJXKJQF5.js.map} +0 -0
  709. /package/dist/cli-bundle/chunks/{update-BSKMQOYH.js.map → search-CX5UMV4H.js.map} +0 -0
  710. /package/dist/cli-bundle/chunks/{update-FIGYNQ2I.js.map → search-KP6H7COV.js.map} +0 -0
  711. /package/dist/cli-bundle/chunks/{telemetry-LQ6FRTUT.js.map → telemetry-DIFPXCAT.js.map} +0 -0
  712. /package/dist/cli-bundle/chunks/{telemetry-BT2VSWU2.js.map → telemetry-WTYFUPRL.js.map} +0 -0
@@ -1,15 +1,15 @@
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]="41990cba-0a09-5d2a-a58b-f5d7b646cfb5")}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]="da381f85-75a5-5832-9c6d-741fbee57e08")}catch(e){}}();
3
3
  import {
4
4
  executeHistoryRewrite,
5
5
  resolveHistorySubject
6
- } from "./chunk-ALQKV6U7.js";
6
+ } from "./chunk-Z55WX4IQ.js";
7
7
  import {
8
8
  resolveAuthor
9
9
  } from "./chunk-T5RRNDA7.js";
10
10
  import {
11
11
  readHistoryEntries
12
- } from "./chunk-MWMHZOZZ.js";
12
+ } from "./chunk-VMY7MZEM.js";
13
13
  import {
14
14
  cloneEmptyReplayDocument,
15
15
  historyEntriesToRaw,
@@ -18,24 +18,20 @@ import {
18
18
  toReplayDocument,
19
19
  tryApplyReplayPatch,
20
20
  verifyHistoryChain
21
- } from "./chunk-WB5BYQMF.js";
21
+ } from "./chunk-SJZTPVFT.js";
22
22
  import {
23
23
  lifecycleClassifierFromStatusRegistry
24
- } from "./chunk-5BBEWX6C.js";
25
- import "./chunk-V4UYNSEM.js";
24
+ } from "./chunk-FDEVKXC4.js";
25
+ import "./chunk-JVQ7UOYC.js";
26
26
  import {
27
27
  createHistoryEntry,
28
28
  listAllFrontMatterLight,
29
29
  readLocatedItem
30
- } from "./chunk-KJZOSF7J.js";
31
- import "./chunk-FBLT6WGK.js";
32
- import "./chunk-ZLWRPBOW.js";
33
- import {
34
- resolveItemTypeRegistry
35
- } from "./chunk-TKPP4GOO.js";
30
+ } from "./chunk-KGQ3W65B.js";
31
+ import "./chunk-V3KLX7U7.js";
36
32
  import {
37
33
  nowIso
38
- } from "./chunk-FMWW2JDU.js";
34
+ } from "./chunk-KRASIL6M.js";
39
35
  import {
40
36
  EXIT_CODE,
41
37
  PmCliError,
@@ -44,12 +40,13 @@ import {
44
40
  pathExists,
45
41
  readFileIfExists,
46
42
  readSettings,
43
+ resolveItemTypeRegistry,
47
44
  resolvePmRoot,
48
45
  resolveRuntimeStatusRegistry,
49
46
  runActiveOnReadHooks,
50
47
  runActiveOnWriteHooks,
51
48
  writeFileAtomic
52
- } from "./chunk-VSAABFGQ.js";
49
+ } from "./chunk-CY5IJMUM.js";
53
50
 
54
51
  // dist/cli/commands/history-compact.js
55
52
  import fs from "node:fs/promises";
@@ -478,6 +475,6 @@ export {
478
475
  runHistoryCompact,
479
476
  runHistoryCompactBulk
480
477
  };
481
- //# sourceMappingURL=history-compact-ZAOWR7GD.js.map
478
+ //# sourceMappingURL=history-compact-2GHT32UX.js.map
482
479
 
483
- //# debugId=41990cba-0a09-5d2a-a58b-f5d7b646cfb5
480
+ //# debugId=da381f85-75a5-5832-9c6d-741fbee57e08
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../cli/commands/history-compact.ts","../../../../../../../../core/history/history-compact-bulk.ts"],"sourcesContent":["/**\n * @module cli/commands/history-compact\n *\n * Implements the pm history compact command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n selectHistoryCompactBulkTargets,\n type HistoryCompactBulkCandidate,\n type HistoryCompactBulkSkipReason,\n type HistoryCompactScope,\n} from \"../../core/history/history-compact-bulk.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n cloneEmptyReplayDocument,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n toReplayDocument,\n tryApplyReplayPatch,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { lifecycleClassifierFromStatusRegistry } from \"../../core/governance/metadata-coverage.js\";\nimport { resolveRuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.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 {\n getActiveExtensionRegistrations,\n runActiveOnReadHooks,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\n/**\n * Documents the history compact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactCommandOptions {\n before?: string;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\ntype HistoryCompactBoundaryKind = \"default\" | \"version\" | \"timestamp\";\n\ninterface HistoryCompactBoundary {\n kind: HistoryCompactBoundaryKind;\n raw: string | null;\n compactCount: number;\n retainedCount: number;\n}\n\n/**\n * Documents the history compact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n compact_boundary: {\n kind: HistoryCompactBoundaryKind;\n before: string | null;\n entries_compacted: number;\n entries_retained: number;\n first_retained_entry: number | null;\n };\n history: {\n path: string;\n entries_scanned: number;\n entries_after: number;\n baseline_entry_added: 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\nfunction parseBeforeBoundary(before: string | undefined, entries: HistoryEntry[]): HistoryCompactBoundary {\n if (before === undefined) {\n return {\n kind: \"default\",\n raw: null,\n compactCount: entries.length,\n retainedCount: 0,\n };\n }\n\n const raw = before.trim();\n if (raw.length === 0) {\n throw new PmCliError(\"history-compact --before requires a non-empty value.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(raw)) {\n const version = Number.parseInt(raw, 10);\n if (!Number.isSafeInteger(version) || version < 1 || version > entries.length + 1) {\n throw new PmCliError(\n `history-compact --before version must be between 1 and ${entries.length + 1}.`,\n EXIT_CODE.USAGE,\n );\n }\n const compactCount = Math.max(0, Math.min(entries.length, version - 1));\n return {\n kind: \"version\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n }\n\n const beforeTs = Date.parse(raw);\n if (!Number.isFinite(beforeTs)) {\n throw new PmCliError(\n `Invalid history-compact --before value \"${before}\". Use a version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let compactCount = 0;\n for (const [index, entry] of entries.entries()) {\n const entryTs = Date.parse(entry.ts);\n if (!Number.isFinite(entryTs)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${index + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTs >= beforeTs) {\n break;\n }\n compactCount += 1;\n }\n\n return {\n kind: \"timestamp\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n}\n\nfunction applyHistoryPatch(current: ReplayDocument, entry: HistoryEntry, entryNumber: number): ReplayDocument {\n const result = tryApplyReplayPatch(current, entry.patch);\n if (!result.ok) {\n throw new PmCliError(\n `history-compact failed to apply patch at entry ${entryNumber} (op=${entry.op}): ${\n result.error instanceof Error ? result.error.message : String(result.error)\n }`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n return result.document;\n}\n\nfunction replayHistoryAndResolveCheckpoint(\n entries: HistoryEntry[],\n compactCount: number,\n): {\n checkpoint: ReplayDocument;\n finalReplay: ReplayDocument;\n} {\n let replay = cloneEmptyReplayDocument();\n let checkpoint = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n throw new PmCliError(\n `history-compact detected before-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n replay = applyHistoryPatch(replay, entry, index + 1);\n if (replayHash(replay) !== entry.after_hash) {\n throw new PmCliError(\n `history-compact detected after-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (index + 1 === compactCount) {\n checkpoint = structuredClone(replay);\n }\n }\n return {\n checkpoint,\n finalReplay: replay,\n };\n}\n\nfunction reanchorRetainedEntries(\n retainedEntries: HistoryEntry[],\n seed: ReplayDocument,\n retainedEntryOffset: number,\n): {\n entries: HistoryEntry[];\n finalReplay: ReplayDocument;\n} {\n let replay = structuredClone(seed);\n const rewritten: HistoryEntry[] = [];\n for (const [index, entry] of retainedEntries.entries()) {\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(replay, entry, retainedEntryOffset + index + 1);\n rewritten.push({\n ...entry,\n before_hash: beforeHash,\n after_hash: replayHash(replay),\n });\n }\n return {\n entries: rewritten,\n finalReplay: replay,\n };\n}\n\n/**\n * Implements run history compact for the public runtime surface of this module.\n */\nexport async function runHistoryCompact(\n id: string,\n options: HistoryCompactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactResult> {\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 const historyPath = subject.historyPath;\n const historyRawBeforeLock = await readFileIfExists(historyPath);\n if (historyRawBeforeLock === null) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyEntries = await readHistoryEntries(historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to compact.`, EXIT_CODE.USAGE);\n }\n\n const chainVerification = verifyHistoryChain(historyEntries);\n if (!chainVerification.ok) {\n throw new PmCliError(\n `history-compact requires a valid history chain (${chainVerification.errors.join(\", \")}). Run pm history-repair ${subject.id} first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n\n const boundary = parseBeforeBoundary(options.before, historyEntries);\n const changed = boundary.compactCount > 0;\n const dryRun = Boolean(options.dryRun);\n const author = resolveAuthor(options.author, settings.author_default);\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_compact_noop_before_boundary\");\n }\n\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItem?.raw ?? null;\n const matchedChainBefore =\n loadedItem === null\n ? null\n : replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash;\n if (matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n let rewrittenEntries: HistoryEntry[] = historyEntries;\n let baselineEntryAdded = false;\n let auditEntryAdded = false;\n\n if (changed) {\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(historyEntries, boundary.compactCount);\n const retained = historyEntries.slice(boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message:\n boundary.raw === null\n ? `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`\n : `history-compact baseline snapshot before ${boundary.raw}.`,\n });\n rewrittenEntries = [baselineEntry, ...reanchored.entries];\n baselineEntryAdded = true;\n const compactMessage =\n typeof options.message === \"string\" && options.message.trim().length > 0\n ? options.message\n : boundary.raw === null\n ? `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`\n : `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n if (!dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: compactMessage,\n }),\n );\n auditEntryAdded = true;\n }\n }\n\n const rewrittenVerify = verifyHistoryChain(rewrittenEntries);\n if (!rewrittenVerify.ok) {\n throw new PmCliError(\n `history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await executeHistoryRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n operation: \"history-compact\",\n author,\n force: options.force,\n itemDocument: loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) => {\n try {\n await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));\n } catch (error) {\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\n })),\n );\n }\n\n const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n compact_boundary: {\n kind: boundary.kind,\n before: boundary.raw,\n entries_compacted: boundary.compactCount,\n entries_retained: boundary.retainedCount,\n first_retained_entry: firstRetainedEntry,\n },\n history: {\n path: historyPath,\n entries_scanned: historyEntries.length,\n entries_after: rewrittenEntries.length,\n baseline_entry_added: baselineEntryAdded,\n audit_entry_added: auditEntryAdded,\n verify_ok: rewrittenVerify.ok,\n verify_errors: rewrittenVerify.errors,\n },\n item: {\n exists: subject.located !== null,\n path: subject.located?.itemPath ?? null,\n matched_chain_before: matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n\n/** Default entry floor below which a stream is treated as already compact. */\nexport const HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES = 3;\n\n/**\n * Documents the bulk history compact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactBulkCommandOptions {\n ids?: string[];\n scope?: HistoryCompactScope;\n allOver?: number;\n minEntries?: number;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/** Per-item outcome row in a bulk compaction pass. */\nexport interface HistoryCompactBulkItemResult {\n id: string;\n outcome: \"compacted\" | \"skipped\" | \"errored\";\n entries_before: number;\n entries_after: number | null;\n skip_reason: HistoryCompactBulkSkipReason | null;\n changed: boolean;\n error: string | null;\n}\n\n/**\n * Documents the bulk history compact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactBulkResult {\n bulk: true;\n dry_run: boolean;\n mode: \"ids\" | \"scan\";\n scope: HistoryCompactScope | null;\n criteria: {\n min_entries: number;\n all_over: number | null;\n policy_threshold_applied: boolean;\n };\n totals: {\n streams_considered: number;\n selected: number;\n items_compacted: number;\n items_skipped: number;\n items_errored: number;\n };\n results: HistoryCompactBulkItemResult[];\n generated_at: string;\n}\n\n/**\n * Enforce the `pm history-compact` target contract shared by the CLI and MCP\n * surfaces: exactly one selection mode — a single item `<id>`, an explicit\n * `--ids` list, or a scan selector (`--all-over` / `--closed` / `--all-streams`).\n */\nexport function assertHistoryCompactTarget(\n id: string | undefined,\n bulk: { ids?: string[]; allOver?: number; scope?: HistoryCompactScope },\n): void {\n const hasIds = bulk.ids !== undefined && bulk.ids.length > 0;\n const hasScan = bulk.allOver !== undefined || bulk.scope !== undefined;\n const selectorCount = (id !== undefined ? 1 : 0) + (hasIds ? 1 : 0) + (hasScan ? 1 : 0);\n if (selectorCount === 0) {\n throw new PmCliError(\n \"history-compact: provide an item <id>, or a bulk selector (--ids, --all-over <N>, --closed, or --all-streams).\",\n EXIT_CODE.USAGE,\n );\n }\n if (id !== undefined && (hasIds || hasScan)) {\n throw new PmCliError(\n \"history-compact: <id> and bulk selectors (--ids/--all-over/--closed/--all-streams) are mutually exclusive; pass one item id, or use bulk mode without a positional id.\",\n EXIT_CODE.USAGE,\n );\n }\n if (hasIds && hasScan) {\n throw new PmCliError(\n \"history-compact: --ids is mutually exclusive with --all-over/--closed/--all-streams; pass an explicit id list or a scan selector, not both.\",\n EXIT_CODE.USAGE,\n );\n }\n}\n\nfunction countHistoryStreamEntries(raw: string): number {\n let count = 0;\n for (const line of raw.split(/\\r?\\n/)) {\n if (line.trim().length > 0) {\n count += 1;\n }\n }\n return count;\n}\n\n/**\n * Bulk history compaction: compact every history stream matching the requested\n * selection (explicit `--ids`, a `--scope` lifecycle filter, and/or an\n * `--all-over <N>` entry threshold) in one audited pass. Each selected stream is\n * compacted with the same single-item logic ({@link runHistoryCompact}); one\n * failing stream never aborts the rest, and the caller decides the exit code\n * from `totals.items_errored`.\n *\n * When `history.compact_policy` is enabled and no explicit `--all-over` is\n * given, the policy's `max_entries` is used as the scan threshold so the\n * configured policy drives the sweep.\n */\nexport async function runHistoryCompactBulk(\n options: HistoryCompactBulkCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactBulkResult> {\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 statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const classifier = lifecycleClassifierFromStatusRegistry(statusRegistry);\n const items = await listAllFrontMatterLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);\n const bucketById = new Map(items.map((item) => [item.id, classifier.classify(item.status)] as const));\n\n const historyDir = path.join(pmRoot, \"history\");\n const candidates: HistoryCompactBulkCandidate[] = [];\n // A stream that cannot be read during enumeration is isolated as an errored\n // row (mirroring per-stream compaction failures) rather than aborting the pass.\n const preselectionErrors: HistoryCompactBulkItemResult[] = [];\n if (await pathExists(historyDir)) {\n const historyFiles = (await fs.readdir(historyDir))\n .filter((entry) => entry.endsWith(\".jsonl\"))\n .sort((left, right) => left.localeCompare(right));\n for (const fileName of historyFiles) {\n const historyPath = path.join(historyDir, fileName);\n const id = fileName.slice(0, -\".jsonl\".length);\n try {\n const raw = await fs.readFile(historyPath, \"utf8\");\n await runActiveOnReadHooks({ path: historyPath, scope: \"project\" });\n candidates.push({ id, entries: countHistoryStreamEntries(raw), bucket: bucketById.get(id) ?? null });\n } catch (error) {\n preselectionErrors.push({\n id,\n outcome: \"errored\",\n entries_before: 0,\n entries_after: null,\n skip_reason: null,\n changed: false,\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\n const mode: \"ids\" | \"scan\" = options.ids !== undefined && options.ids.length > 0 ? \"ids\" : \"scan\";\n const minEntries = options.minEntries ?? HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES;\n const policy = settings.history.compact_policy;\n const policyThresholdApplied = mode === \"scan\" && options.allOver === undefined && policy.enabled;\n const allOver = options.allOver ?? (policyThresholdApplied ? policy.max_entries : undefined);\n\n const selection = selectHistoryCompactBulkTargets(candidates, {\n ids: options.ids,\n scope: options.scope,\n minEntries,\n allOver,\n });\n\n const dryRun = Boolean(options.dryRun);\n const results: HistoryCompactBulkItemResult[] = [...preselectionErrors];\n const totals = {\n streams_considered: candidates.length + preselectionErrors.length,\n selected: 0,\n items_compacted: 0,\n items_skipped: 0,\n items_errored: preselectionErrors.length,\n };\n for (const row of selection) {\n if (!row.selected) {\n totals.items_skipped += 1;\n results.push({\n id: row.id,\n outcome: \"skipped\",\n entries_before: row.entries,\n entries_after: null,\n skip_reason: row.skip_reason,\n changed: false,\n error: null,\n });\n continue;\n }\n totals.selected += 1;\n try {\n const result = await runHistoryCompact(\n row.id,\n {\n dryRun,\n author: options.author,\n message: options.message,\n force: options.force,\n },\n global,\n );\n totals.items_compacted += 1;\n results.push({\n id: row.id,\n outcome: \"compacted\",\n entries_before: row.entries,\n entries_after: result.history.entries_after,\n skip_reason: null,\n changed: result.changed,\n error: null,\n });\n } catch (error) {\n totals.items_errored += 1;\n results.push({\n id: row.id,\n outcome: \"errored\",\n entries_before: row.entries,\n entries_after: null,\n skip_reason: null,\n changed: false,\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 bulk: true,\n dry_run: dryRun,\n mode,\n scope: options.scope ?? null,\n criteria: {\n min_entries: minEntries,\n all_over: allOver ?? null,\n policy_threshold_applied: policyThresholdApplied,\n },\n totals,\n results,\n generated_at: nowIso(),\n };\n}\n","/**\n * @module core/history/history-compact-bulk\n *\n * Pure selection logic for bulk history-stream compaction. Given a set of\n * history-stream candidates (id, entry count, and lifecycle bucket of the\n * owning item) plus the requested selection criteria, this module decides which\n * streams should be compacted and which are skipped (and why).\n *\n * The module performs no filesystem access and imports no heavy runtime\n * dependencies — the command layer reads streams and item statuses, hands the\n * resolved candidates here, then executes per-item compaction on the selection\n * this module returns. Keeping selection pure makes the matrix of scope /\n * threshold / explicit-id rules trivially testable without touching disk.\n */\n\nimport type { LifecycleBucket } from \"../governance/metadata-coverage.js\";\n\n/** Bulk-compaction scope: only closed items, or every history stream. */\nexport type HistoryCompactScope = \"closed\" | \"all-streams\";\n\n/** Why a candidate stream was not selected for compaction. */\nexport type HistoryCompactBulkSkipReason = \"no_stream\" | \"already_compact\" | \"scope_mismatch\" | \"below_threshold\";\n\n/**\n * One history stream considered for bulk compaction.\n *\n * `bucket` is the lifecycle bucket of the owning item, or `null` when no item\n * matches the stream (an orphan history file). Orphan streams never satisfy a\n * `closed` scope filter but are eligible under `all-streams`.\n */\nexport interface HistoryCompactBulkCandidate {\n id: string;\n entries: number;\n bucket: LifecycleBucket | null;\n}\n\n/** Selection criteria resolved from the command flags + policy defaults. */\nexport interface HistoryCompactBulkCriteria {\n /**\n * Explicit, ordered list of item ids to compact. When non-empty the selection\n * runs in \"ids\" mode: scope/allOver are ignored and only the `minEntries`\n * floor applies. Duplicates are collapsed, preserving first-seen order.\n */\n ids?: string[];\n /** Lifecycle scope filter for scan mode (ignored in ids mode). */\n scope?: HistoryCompactScope;\n /**\n * Streams with at most this many entries are skipped as `already_compact`\n * (compaction collapses a stream to a 2-entry baseline+audit pair, so smaller\n * streams gain nothing). Applies in both modes.\n */\n minEntries: number;\n /**\n * Scan mode only: when set, only streams with strictly more entries than this\n * are selected. Streams above `minEntries` but at/below `allOver` are skipped\n * as `below_threshold`.\n */\n allOver?: number;\n}\n\n/** Per-candidate selection outcome. */\nexport interface HistoryCompactBulkSelectionRow {\n id: string;\n entries: number;\n selected: boolean;\n skip_reason: HistoryCompactBulkSkipReason | null;\n}\n\nfunction selectIdsMode(\n ids: string[],\n byId: ReadonlyMap<string, HistoryCompactBulkCandidate>,\n minEntries: number,\n): HistoryCompactBulkSelectionRow[] {\n const seen = new Set<string>();\n const rows: HistoryCompactBulkSelectionRow[] = [];\n for (const rawId of ids) {\n const id = rawId.trim();\n if (id.length === 0 || seen.has(id)) {\n continue;\n }\n seen.add(id);\n const candidate = byId.get(id);\n if (candidate === undefined) {\n rows.push({ id, entries: 0, selected: false, skip_reason: \"no_stream\" });\n continue;\n }\n if (candidate.entries <= minEntries) {\n rows.push({ id, entries: candidate.entries, selected: false, skip_reason: \"already_compact\" });\n continue;\n }\n rows.push({ id, entries: candidate.entries, selected: true, skip_reason: null });\n }\n return rows;\n}\n\nfunction selectScanMode(\n candidates: HistoryCompactBulkCandidate[],\n criteria: HistoryCompactBulkCriteria,\n): HistoryCompactBulkSelectionRow[] {\n const ordered = [...candidates].sort((a, b) => b.entries - a.entries || a.id.localeCompare(b.id));\n const rows: HistoryCompactBulkSelectionRow[] = [];\n for (const candidate of ordered) {\n if (criteria.scope === \"closed\" && candidate.bucket !== \"closed\") {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"scope_mismatch\" });\n continue;\n }\n if (candidate.entries <= criteria.minEntries) {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"already_compact\" });\n continue;\n }\n if (criteria.allOver !== undefined && candidate.entries <= criteria.allOver) {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"below_threshold\" });\n continue;\n }\n rows.push({ id: candidate.id, entries: candidate.entries, selected: true, skip_reason: null });\n }\n return rows;\n}\n\n/**\n * Decide which history streams to compact.\n *\n * Runs in \"ids\" mode when `criteria.ids` is non-empty (exact, ordered set,\n * honouring only the `minEntries` floor) and \"scan\" mode otherwise (every\n * candidate, filtered by scope and entry thresholds, ordered deepest-first).\n */\nexport function selectHistoryCompactBulkTargets(\n candidates: HistoryCompactBulkCandidate[],\n criteria: HistoryCompactBulkCriteria,\n): HistoryCompactBulkSelectionRow[] {\n if (criteria.ids !== undefined && criteria.ids.length > 0) {\n const byId = new Map(candidates.map((candidate) => [candidate.id, candidate]));\n return selectIdsMode(criteria.ids, byId, criteria.minEntries);\n }\n return selectScanMode(candidates, criteria);\n}\n"],"names":["compactCount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;;;AC8DjB,SAAS,cACP,KACA,MACA,YAAkB;AAElB,QAAM,OAAO,oBAAI,IAAG;AACpB,QAAM,OAAyC,CAAA;AAC/C,aAAW,SAAS,KAAK;AACvB,UAAM,KAAK,MAAM,KAAI;AACrB,QAAI,GAAG,WAAW,KAAK,KAAK,IAAI,EAAE,GAAG;AACnC;IACF;AACA,SAAK,IAAI,EAAE;AACX,UAAM,YAAY,KAAK,IAAI,EAAE;AAC7B,QAAI,cAAc,QAAW;AAC3B,WAAK,KAAK,EAAE,IAAI,SAAS,GAAG,UAAU,OAAO,aAAa,YAAW,CAAE;AACvE;IACF;AACA,QAAI,UAAU,WAAW,YAAY;AACnC,WAAK,KAAK,EAAE,IAAI,SA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eAAe;QACf,aAAa,IAAI;QACjB,SAAS;QACT,OAAO;OACR;AACD;IACF;AACA,WAAO,YAAY;AACnB,QAAI;AACF,YAAM,SAAS,MAAM,kBACnB,IAAI,IACJ;QACE;QACA,QAAQ,QAAQ;QAChB,SAAS,QAAQ;QACjB,OAAO,QAAQ;SAEjB,MAAM;AAER,aAAO,mBAAmB;AAC1B,cAAQ,KAAK;QACX,IAAI,IAAI;QACR,SAAS;QACT,gBAAgB,IAAI;QACpB,eAAe,OAAO,QAAQ;QAC9B,aAAa;QACb,SAAS,OAAO;QAChB,OAAO;OACR;IACH,SAAS,OAAO;AACd,aAAO,iBAAiB;AACxB,cAAQ,KAAK;QACX,IAAI,IAAI;QACR,SAAS;QACT,gBAAgB,IAAI;QACpB,eAAe;QACf,aAAa;QACb,SAAS;;QAET,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;OAC7D;IACH;EACF;AAEA,SAAO;IACL,MAAM;IACN,SAAS;IACT;IACA,OAAO,QAAQ,SAAS;IACxB,UAAU;MACR,aAAa;MACb,UAAU,WAAW;MACrB,0BAA0B;;IAE5B;IACA;IACA,cAAc,OAAM;;AAExB","debugId":"41990cba-0a09-5d2a-a58b-f5d7b646cfb5"}
1
+ {"version":3,"sources":["../../../../../../../../cli/commands/history-compact.ts","../../../../../../../../core/history/history-compact-bulk.ts"],"sourcesContent":["/**\n * @module cli/commands/history-compact\n *\n * Implements the pm history compact command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n selectHistoryCompactBulkTargets,\n type HistoryCompactBulkCandidate,\n type HistoryCompactBulkSkipReason,\n type HistoryCompactScope,\n} from \"../../core/history/history-compact-bulk.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n cloneEmptyReplayDocument,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n toReplayDocument,\n tryApplyReplayPatch,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { lifecycleClassifierFromStatusRegistry } from \"../../core/governance/metadata-coverage.js\";\nimport { resolveRuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.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 {\n getActiveExtensionRegistrations,\n runActiveOnReadHooks,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\n/**\n * Documents the history compact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactCommandOptions {\n before?: string;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\ntype HistoryCompactBoundaryKind = \"default\" | \"version\" | \"timestamp\";\n\ninterface HistoryCompactBoundary {\n kind: HistoryCompactBoundaryKind;\n raw: string | null;\n compactCount: number;\n retainedCount: number;\n}\n\n/**\n * Documents the history compact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n compact_boundary: {\n kind: HistoryCompactBoundaryKind;\n before: string | null;\n entries_compacted: number;\n entries_retained: number;\n first_retained_entry: number | null;\n };\n history: {\n path: string;\n entries_scanned: number;\n entries_after: number;\n baseline_entry_added: 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\nfunction parseBeforeBoundary(before: string | undefined, entries: HistoryEntry[]): HistoryCompactBoundary {\n if (before === undefined) {\n return {\n kind: \"default\",\n raw: null,\n compactCount: entries.length,\n retainedCount: 0,\n };\n }\n\n const raw = before.trim();\n if (raw.length === 0) {\n throw new PmCliError(\"history-compact --before requires a non-empty value.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(raw)) {\n const version = Number.parseInt(raw, 10);\n if (!Number.isSafeInteger(version) || version < 1 || version > entries.length + 1) {\n throw new PmCliError(\n `history-compact --before version must be between 1 and ${entries.length + 1}.`,\n EXIT_CODE.USAGE,\n );\n }\n const compactCount = Math.max(0, Math.min(entries.length, version - 1));\n return {\n kind: \"version\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n }\n\n const beforeTs = Date.parse(raw);\n if (!Number.isFinite(beforeTs)) {\n throw new PmCliError(\n `Invalid history-compact --before value \"${before}\". Use a version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let compactCount = 0;\n for (const [index, entry] of entries.entries()) {\n const entryTs = Date.parse(entry.ts);\n if (!Number.isFinite(entryTs)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${index + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTs >= beforeTs) {\n break;\n }\n compactCount += 1;\n }\n\n return {\n kind: \"timestamp\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n}\n\nfunction applyHistoryPatch(current: ReplayDocument, entry: HistoryEntry, entryNumber: number): ReplayDocument {\n const result = tryApplyReplayPatch(current, entry.patch);\n if (!result.ok) {\n throw new PmCliError(\n `history-compact failed to apply patch at entry ${entryNumber} (op=${entry.op}): ${\n result.error instanceof Error ? result.error.message : String(result.error)\n }`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n return result.document;\n}\n\nfunction replayHistoryAndResolveCheckpoint(\n entries: HistoryEntry[],\n compactCount: number,\n): {\n checkpoint: ReplayDocument;\n finalReplay: ReplayDocument;\n} {\n let replay = cloneEmptyReplayDocument();\n let checkpoint = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n throw new PmCliError(\n `history-compact detected before-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n replay = applyHistoryPatch(replay, entry, index + 1);\n if (replayHash(replay) !== entry.after_hash) {\n throw new PmCliError(\n `history-compact detected after-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (index + 1 === compactCount) {\n checkpoint = structuredClone(replay);\n }\n }\n return {\n checkpoint,\n finalReplay: replay,\n };\n}\n\nfunction reanchorRetainedEntries(\n retainedEntries: HistoryEntry[],\n seed: ReplayDocument,\n retainedEntryOffset: number,\n): {\n entries: HistoryEntry[];\n finalReplay: ReplayDocument;\n} {\n let replay = structuredClone(seed);\n const rewritten: HistoryEntry[] = [];\n for (const [index, entry] of retainedEntries.entries()) {\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(replay, entry, retainedEntryOffset + index + 1);\n rewritten.push({\n ...entry,\n before_hash: beforeHash,\n after_hash: replayHash(replay),\n });\n }\n return {\n entries: rewritten,\n finalReplay: replay,\n };\n}\n\n/**\n * Implements run history compact for the public runtime surface of this module.\n */\nexport async function runHistoryCompact(\n id: string,\n options: HistoryCompactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactResult> {\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 const historyPath = subject.historyPath;\n const historyRawBeforeLock = await readFileIfExists(historyPath);\n if (historyRawBeforeLock === null) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyEntries = await readHistoryEntries(historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to compact.`, EXIT_CODE.USAGE);\n }\n\n const chainVerification = verifyHistoryChain(historyEntries);\n if (!chainVerification.ok) {\n throw new PmCliError(\n `history-compact requires a valid history chain (${chainVerification.errors.join(\", \")}). Run pm history-repair ${subject.id} first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n\n const boundary = parseBeforeBoundary(options.before, historyEntries);\n const changed = boundary.compactCount > 0;\n const dryRun = Boolean(options.dryRun);\n const author = resolveAuthor(options.author, settings.author_default);\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_compact_noop_before_boundary\");\n }\n\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItem?.raw ?? null;\n const matchedChainBefore =\n loadedItem === null\n ? null\n : replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash;\n if (matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n let rewrittenEntries: HistoryEntry[] = historyEntries;\n let baselineEntryAdded = false;\n let auditEntryAdded = false;\n\n if (changed) {\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(historyEntries, boundary.compactCount);\n const retained = historyEntries.slice(boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message:\n boundary.raw === null\n ? `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`\n : `history-compact baseline snapshot before ${boundary.raw}.`,\n });\n rewrittenEntries = [baselineEntry, ...reanchored.entries];\n baselineEntryAdded = true;\n const compactMessage =\n typeof options.message === \"string\" && options.message.trim().length > 0\n ? options.message\n : boundary.raw === null\n ? `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`\n : `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n if (!dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: compactMessage,\n }),\n );\n auditEntryAdded = true;\n }\n }\n\n const rewrittenVerify = verifyHistoryChain(rewrittenEntries);\n if (!rewrittenVerify.ok) {\n throw new PmCliError(\n `history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await executeHistoryRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n operation: \"history-compact\",\n author,\n force: options.force,\n itemDocument: loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) => {\n try {\n await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));\n } catch (error) {\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\n })),\n );\n }\n\n const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n compact_boundary: {\n kind: boundary.kind,\n before: boundary.raw,\n entries_compacted: boundary.compactCount,\n entries_retained: boundary.retainedCount,\n first_retained_entry: firstRetainedEntry,\n },\n history: {\n path: historyPath,\n entries_scanned: historyEntries.length,\n entries_after: rewrittenEntries.length,\n baseline_entry_added: baselineEntryAdded,\n audit_entry_added: auditEntryAdded,\n verify_ok: rewrittenVerify.ok,\n verify_errors: rewrittenVerify.errors,\n },\n item: {\n exists: subject.located !== null,\n path: subject.located?.itemPath ?? null,\n matched_chain_before: matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n\n/** Default entry floor below which a stream is treated as already compact. */\nexport const HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES = 3;\n\n/**\n * Documents the bulk history compact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactBulkCommandOptions {\n ids?: string[];\n scope?: HistoryCompactScope;\n allOver?: number;\n minEntries?: number;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/** Per-item outcome row in a bulk compaction pass. */\nexport interface HistoryCompactBulkItemResult {\n id: string;\n outcome: \"compacted\" | \"skipped\" | \"errored\";\n entries_before: number;\n entries_after: number | null;\n skip_reason: HistoryCompactBulkSkipReason | null;\n changed: boolean;\n error: string | null;\n}\n\n/**\n * Documents the bulk history compact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactBulkResult {\n bulk: true;\n dry_run: boolean;\n mode: \"ids\" | \"scan\";\n scope: HistoryCompactScope | null;\n criteria: {\n min_entries: number;\n all_over: number | null;\n policy_threshold_applied: boolean;\n };\n totals: {\n streams_considered: number;\n selected: number;\n items_compacted: number;\n items_skipped: number;\n items_errored: number;\n };\n results: HistoryCompactBulkItemResult[];\n generated_at: string;\n}\n\n/**\n * Enforce the `pm history-compact` target contract shared by the CLI and MCP\n * surfaces: exactly one selection mode — a single item `<id>`, an explicit\n * `--ids` list, or a scan selector (`--all-over` / `--closed` / `--all-streams`).\n */\nexport function assertHistoryCompactTarget(\n id: string | undefined,\n bulk: { ids?: string[]; allOver?: number; scope?: HistoryCompactScope },\n): void {\n const hasIds = bulk.ids !== undefined && bulk.ids.length > 0;\n const hasScan = bulk.allOver !== undefined || bulk.scope !== undefined;\n const selectorCount = (id !== undefined ? 1 : 0) + (hasIds ? 1 : 0) + (hasScan ? 1 : 0);\n if (selectorCount === 0) {\n throw new PmCliError(\n \"history-compact: provide an item <id>, or a bulk selector (--ids, --all-over <N>, --closed, or --all-streams).\",\n EXIT_CODE.USAGE,\n );\n }\n if (id !== undefined && (hasIds || hasScan)) {\n throw new PmCliError(\n \"history-compact: <id> and bulk selectors (--ids/--all-over/--closed/--all-streams) are mutually exclusive; pass one item id, or use bulk mode without a positional id.\",\n EXIT_CODE.USAGE,\n );\n }\n if (hasIds && hasScan) {\n throw new PmCliError(\n \"history-compact: --ids is mutually exclusive with --all-over/--closed/--all-streams; pass an explicit id list or a scan selector, not both.\",\n EXIT_CODE.USAGE,\n );\n }\n}\n\nfunction countHistoryStreamEntries(raw: string): number {\n let count = 0;\n for (const line of raw.split(/\\r?\\n/)) {\n if (line.trim().length > 0) {\n count += 1;\n }\n }\n return count;\n}\n\n/**\n * Bulk history compaction: compact every history stream matching the requested\n * selection (explicit `--ids`, a `--scope` lifecycle filter, and/or an\n * `--all-over <N>` entry threshold) in one audited pass. Each selected stream is\n * compacted with the same single-item logic ({@link runHistoryCompact}); one\n * failing stream never aborts the rest, and the caller decides the exit code\n * from `totals.items_errored`.\n *\n * When `history.compact_policy` is enabled and no explicit `--all-over` is\n * given, the policy's `max_entries` is used as the scan threshold so the\n * configured policy drives the sweep.\n */\nexport async function runHistoryCompactBulk(\n options: HistoryCompactBulkCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactBulkResult> {\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 statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const classifier = lifecycleClassifierFromStatusRegistry(statusRegistry);\n const items = await listAllFrontMatterLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);\n const bucketById = new Map(items.map((item) => [item.id, classifier.classify(item.status)] as const));\n\n const historyDir = path.join(pmRoot, \"history\");\n const candidates: HistoryCompactBulkCandidate[] = [];\n // A stream that cannot be read during enumeration is isolated as an errored\n // row (mirroring per-stream compaction failures) rather than aborting the pass.\n const preselectionErrors: HistoryCompactBulkItemResult[] = [];\n if (await pathExists(historyDir)) {\n const historyFiles = (await fs.readdir(historyDir))\n .filter((entry) => entry.endsWith(\".jsonl\"))\n .sort((left, right) => left.localeCompare(right));\n for (const fileName of historyFiles) {\n const historyPath = path.join(historyDir, fileName);\n const id = fileName.slice(0, -\".jsonl\".length);\n try {\n const raw = await fs.readFile(historyPath, \"utf8\");\n await runActiveOnReadHooks({ path: historyPath, scope: \"project\" });\n candidates.push({ id, entries: countHistoryStreamEntries(raw), bucket: bucketById.get(id) ?? null });\n } catch (error) {\n preselectionErrors.push({\n id,\n outcome: \"errored\",\n entries_before: 0,\n entries_after: null,\n skip_reason: null,\n changed: false,\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\n const mode: \"ids\" | \"scan\" = options.ids !== undefined && options.ids.length > 0 ? \"ids\" : \"scan\";\n const minEntries = options.minEntries ?? HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES;\n const policy = settings.history.compact_policy;\n const policyThresholdApplied = mode === \"scan\" && options.allOver === undefined && policy.enabled;\n const allOver = options.allOver ?? (policyThresholdApplied ? policy.max_entries : undefined);\n\n const selection = selectHistoryCompactBulkTargets(candidates, {\n ids: options.ids,\n scope: options.scope,\n minEntries,\n allOver,\n });\n\n const dryRun = Boolean(options.dryRun);\n const results: HistoryCompactBulkItemResult[] = [...preselectionErrors];\n const totals = {\n streams_considered: candidates.length + preselectionErrors.length,\n selected: 0,\n items_compacted: 0,\n items_skipped: 0,\n items_errored: preselectionErrors.length,\n };\n for (const row of selection) {\n if (!row.selected) {\n totals.items_skipped += 1;\n results.push({\n id: row.id,\n outcome: \"skipped\",\n entries_before: row.entries,\n entries_after: null,\n skip_reason: row.skip_reason,\n changed: false,\n error: null,\n });\n continue;\n }\n totals.selected += 1;\n try {\n const result = await runHistoryCompact(\n row.id,\n {\n dryRun,\n author: options.author,\n message: options.message,\n force: options.force,\n },\n global,\n );\n totals.items_compacted += 1;\n results.push({\n id: row.id,\n outcome: \"compacted\",\n entries_before: row.entries,\n entries_after: result.history.entries_after,\n skip_reason: null,\n changed: result.changed,\n error: null,\n });\n } catch (error) {\n totals.items_errored += 1;\n results.push({\n id: row.id,\n outcome: \"errored\",\n entries_before: row.entries,\n entries_after: null,\n skip_reason: null,\n changed: false,\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 bulk: true,\n dry_run: dryRun,\n mode,\n scope: options.scope ?? null,\n criteria: {\n min_entries: minEntries,\n all_over: allOver ?? null,\n policy_threshold_applied: policyThresholdApplied,\n },\n totals,\n results,\n generated_at: nowIso(),\n };\n}\n","/**\n * @module core/history/history-compact-bulk\n *\n * Pure selection logic for bulk history-stream compaction. Given a set of\n * history-stream candidates (id, entry count, and lifecycle bucket of the\n * owning item) plus the requested selection criteria, this module decides which\n * streams should be compacted and which are skipped (and why).\n *\n * The module performs no filesystem access and imports no heavy runtime\n * dependencies — the command layer reads streams and item statuses, hands the\n * resolved candidates here, then executes per-item compaction on the selection\n * this module returns. Keeping selection pure makes the matrix of scope /\n * threshold / explicit-id rules trivially testable without touching disk.\n */\n\nimport type { LifecycleBucket } from \"../governance/metadata-coverage.js\";\n\n/** Bulk-compaction scope: only closed items, or every history stream. */\nexport type HistoryCompactScope = \"closed\" | \"all-streams\";\n\n/** Why a candidate stream was not selected for compaction. */\nexport type HistoryCompactBulkSkipReason = \"no_stream\" | \"already_compact\" | \"scope_mismatch\" | \"below_threshold\";\n\n/**\n * One history stream considered for bulk compaction.\n *\n * `bucket` is the lifecycle bucket of the owning item, or `null` when no item\n * matches the stream (an orphan history file). Orphan streams never satisfy a\n * `closed` scope filter but are eligible under `all-streams`.\n */\nexport interface HistoryCompactBulkCandidate {\n id: string;\n entries: number;\n bucket: LifecycleBucket | null;\n}\n\n/** Selection criteria resolved from the command flags + policy defaults. */\nexport interface HistoryCompactBulkCriteria {\n /**\n * Explicit, ordered list of item ids to compact. When non-empty the selection\n * runs in \"ids\" mode: scope/allOver are ignored and only the `minEntries`\n * floor applies. Duplicates are collapsed, preserving first-seen order.\n */\n ids?: string[];\n /** Lifecycle scope filter for scan mode (ignored in ids mode). */\n scope?: HistoryCompactScope;\n /**\n * Streams with at most this many entries are skipped as `already_compact`\n * (compaction collapses a stream to a 2-entry baseline+audit pair, so smaller\n * streams gain nothing). Applies in both modes.\n */\n minEntries: number;\n /**\n * Scan mode only: when set, only streams with strictly more entries than this\n * are selected. Streams above `minEntries` but at/below `allOver` are skipped\n * as `below_threshold`.\n */\n allOver?: number;\n}\n\n/** Per-candidate selection outcome. */\nexport interface HistoryCompactBulkSelectionRow {\n id: string;\n entries: number;\n selected: boolean;\n skip_reason: HistoryCompactBulkSkipReason | null;\n}\n\nfunction selectIdsMode(\n ids: string[],\n byId: ReadonlyMap<string, HistoryCompactBulkCandidate>,\n minEntries: number,\n): HistoryCompactBulkSelectionRow[] {\n const seen = new Set<string>();\n const rows: HistoryCompactBulkSelectionRow[] = [];\n for (const rawId of ids) {\n const id = rawId.trim();\n if (id.length === 0 || seen.has(id)) {\n continue;\n }\n seen.add(id);\n const candidate = byId.get(id);\n if (candidate === undefined) {\n rows.push({ id, entries: 0, selected: false, skip_reason: \"no_stream\" });\n continue;\n }\n if (candidate.entries <= minEntries) {\n rows.push({ id, entries: candidate.entries, selected: false, skip_reason: \"already_compact\" });\n continue;\n }\n rows.push({ id, entries: candidate.entries, selected: true, skip_reason: null });\n }\n return rows;\n}\n\nfunction selectScanMode(\n candidates: HistoryCompactBulkCandidate[],\n criteria: HistoryCompactBulkCriteria,\n): HistoryCompactBulkSelectionRow[] {\n const ordered = [...candidates].sort((a, b) => b.entries - a.entries || a.id.localeCompare(b.id));\n const rows: HistoryCompactBulkSelectionRow[] = [];\n for (const candidate of ordered) {\n if (criteria.scope === \"closed\" && candidate.bucket !== \"closed\") {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"scope_mismatch\" });\n continue;\n }\n if (candidate.entries <= criteria.minEntries) {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"already_compact\" });\n continue;\n }\n if (criteria.allOver !== undefined && candidate.entries <= criteria.allOver) {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"below_threshold\" });\n continue;\n }\n rows.push({ id: candidate.id, entries: candidate.entries, selected: true, skip_reason: null });\n }\n return rows;\n}\n\n/**\n * Decide which history streams to compact.\n *\n * Runs in \"ids\" mode when `criteria.ids` is non-empty (exact, ordered set,\n * honouring only the `minEntries` floor) and \"scan\" mode otherwise (every\n * candidate, filtered by scope and entry thresholds, ordered deepest-first).\n */\nexport function selectHistoryCompactBulkTargets(\n candidates: HistoryCompactBulkCandidate[],\n criteria: HistoryCompactBulkCriteria,\n): HistoryCompactBulkSelectionRow[] {\n if (criteria.ids !== undefined && criteria.ids.length > 0) {\n const byId = new Map(candidates.map((candidate) => [candidate.id, candidate]));\n return selectIdsMode(criteria.ids, byId, criteria.minEntries);\n }\n return selectScanMode(candidates, criteria);\n}\n"],"names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rB,0BAA0B;;IAE5B;IACA;IACA,cAAc,OAAM;;AAExB","debugId":"da381f85-75a5-5832-9c6d-741fbee57e08"}
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  executeHistoryRewrite,
3
3
  resolveHistorySubject
4
- } from "./chunk-6EBNFQOR.js";
4
+ } from "./chunk-AWN4PPH5.js";
5
5
  import {
6
6
  resolveAuthor
7
7
  } from "./chunk-WW4E2DC3.js";
8
8
  import {
9
9
  readHistoryEntries
10
- } from "./chunk-LU36E6GU.js";
10
+ } from "./chunk-IBU2LLWM.js";
11
11
  import {
12
12
  cloneEmptyReplayDocument,
13
13
  historyEntriesToRaw,
@@ -16,24 +16,20 @@ import {
16
16
  toReplayDocument,
17
17
  tryApplyReplayPatch,
18
18
  verifyHistoryChain
19
- } from "./chunk-CG3KP6I5.js";
19
+ } from "./chunk-E2Q2ULMR.js";
20
20
  import {
21
21
  lifecycleClassifierFromStatusRegistry
22
- } from "./chunk-IXAZI443.js";
23
- import "./chunk-JV27C7OZ.js";
22
+ } from "./chunk-ZEATCVAC.js";
23
+ import "./chunk-7L6TXOOC.js";
24
24
  import {
25
25
  createHistoryEntry,
26
26
  listAllFrontMatterLight,
27
27
  readLocatedItem
28
- } from "./chunk-OHDQNKJB.js";
29
- import "./chunk-B74BP6IS.js";
30
- import "./chunk-C4C3EJCJ.js";
31
- import {
32
- resolveItemTypeRegistry
33
- } from "./chunk-ZV7IQ23N.js";
28
+ } from "./chunk-LBH7UYKY.js";
29
+ import "./chunk-ZFIEEDTJ.js";
34
30
  import {
35
31
  nowIso
36
- } from "./chunk-I6QMJ2XT.js";
32
+ } from "./chunk-MLHX6DN5.js";
37
33
  import {
38
34
  EXIT_CODE,
39
35
  PmCliError,
@@ -42,12 +38,13 @@ import {
42
38
  pathExists,
43
39
  readFileIfExists,
44
40
  readSettings,
41
+ resolveItemTypeRegistry,
45
42
  resolvePmRoot,
46
43
  resolveRuntimeStatusRegistry,
47
44
  runActiveOnReadHooks,
48
45
  runActiveOnWriteHooks,
49
46
  writeFileAtomic
50
- } from "./chunk-EYPINTFR.js";
47
+ } from "./chunk-SNUK7H5J.js";
51
48
 
52
49
  // dist/cli/commands/history-compact.js
53
50
  import fs from "node:fs/promises";
@@ -490,4 +487,4 @@ export {
490
487
  runHistoryCompact,
491
488
  runHistoryCompactBulk
492
489
  };
493
- //# sourceMappingURL=history-compact-NQ7VPRVT.js.map
490
+ //# sourceMappingURL=history-compact-WLCQEKXS.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/history-compact.ts", "../../../../../../../../core/history/history-compact-bulk.ts"],
4
4
  "sourcesContent": ["/**\n * @module cli/commands/history-compact\n *\n * Implements the pm history compact command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n selectHistoryCompactBulkTargets,\n type HistoryCompactBulkCandidate,\n type HistoryCompactBulkSkipReason,\n type HistoryCompactScope,\n} from \"../../core/history/history-compact-bulk.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n cloneEmptyReplayDocument,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n toReplayDocument,\n tryApplyReplayPatch,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { lifecycleClassifierFromStatusRegistry } from \"../../core/governance/metadata-coverage.js\";\nimport { resolveRuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.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 {\n getActiveExtensionRegistrations,\n runActiveOnReadHooks,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\n/**\n * Documents the history compact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactCommandOptions {\n before?: string;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\ntype HistoryCompactBoundaryKind = \"default\" | \"version\" | \"timestamp\";\n\ninterface HistoryCompactBoundary {\n kind: HistoryCompactBoundaryKind;\n raw: string | null;\n compactCount: number;\n retainedCount: number;\n}\n\n/**\n * Documents the history compact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n compact_boundary: {\n kind: HistoryCompactBoundaryKind;\n before: string | null;\n entries_compacted: number;\n entries_retained: number;\n first_retained_entry: number | null;\n };\n history: {\n path: string;\n entries_scanned: number;\n entries_after: number;\n baseline_entry_added: 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\nfunction parseBeforeBoundary(before: string | undefined, entries: HistoryEntry[]): HistoryCompactBoundary {\n if (before === undefined) {\n return {\n kind: \"default\",\n raw: null,\n compactCount: entries.length,\n retainedCount: 0,\n };\n }\n\n const raw = before.trim();\n if (raw.length === 0) {\n throw new PmCliError(\"history-compact --before requires a non-empty value.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(raw)) {\n const version = Number.parseInt(raw, 10);\n if (!Number.isSafeInteger(version) || version < 1 || version > entries.length + 1) {\n throw new PmCliError(\n `history-compact --before version must be between 1 and ${entries.length + 1}.`,\n EXIT_CODE.USAGE,\n );\n }\n const compactCount = Math.max(0, Math.min(entries.length, version - 1));\n return {\n kind: \"version\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n }\n\n const beforeTs = Date.parse(raw);\n if (!Number.isFinite(beforeTs)) {\n throw new PmCliError(\n `Invalid history-compact --before value \"${before}\". Use a version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let compactCount = 0;\n for (const [index, entry] of entries.entries()) {\n const entryTs = Date.parse(entry.ts);\n if (!Number.isFinite(entryTs)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${index + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTs >= beforeTs) {\n break;\n }\n compactCount += 1;\n }\n\n return {\n kind: \"timestamp\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n}\n\nfunction applyHistoryPatch(current: ReplayDocument, entry: HistoryEntry, entryNumber: number): ReplayDocument {\n const result = tryApplyReplayPatch(current, entry.patch);\n if (!result.ok) {\n throw new PmCliError(\n `history-compact failed to apply patch at entry ${entryNumber} (op=${entry.op}): ${\n result.error instanceof Error ? result.error.message : String(result.error)\n }`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n return result.document;\n}\n\nfunction replayHistoryAndResolveCheckpoint(\n entries: HistoryEntry[],\n compactCount: number,\n): {\n checkpoint: ReplayDocument;\n finalReplay: ReplayDocument;\n} {\n let replay = cloneEmptyReplayDocument();\n let checkpoint = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n throw new PmCliError(\n `history-compact detected before-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n replay = applyHistoryPatch(replay, entry, index + 1);\n if (replayHash(replay) !== entry.after_hash) {\n throw new PmCliError(\n `history-compact detected after-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (index + 1 === compactCount) {\n checkpoint = structuredClone(replay);\n }\n }\n return {\n checkpoint,\n finalReplay: replay,\n };\n}\n\nfunction reanchorRetainedEntries(\n retainedEntries: HistoryEntry[],\n seed: ReplayDocument,\n retainedEntryOffset: number,\n): {\n entries: HistoryEntry[];\n finalReplay: ReplayDocument;\n} {\n let replay = structuredClone(seed);\n const rewritten: HistoryEntry[] = [];\n for (const [index, entry] of retainedEntries.entries()) {\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(replay, entry, retainedEntryOffset + index + 1);\n rewritten.push({\n ...entry,\n before_hash: beforeHash,\n after_hash: replayHash(replay),\n });\n }\n return {\n entries: rewritten,\n finalReplay: replay,\n };\n}\n\n/**\n * Implements run history compact for the public runtime surface of this module.\n */\nexport async function runHistoryCompact(\n id: string,\n options: HistoryCompactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactResult> {\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 const historyPath = subject.historyPath;\n const historyRawBeforeLock = await readFileIfExists(historyPath);\n if (historyRawBeforeLock === null) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyEntries = await readHistoryEntries(historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to compact.`, EXIT_CODE.USAGE);\n }\n\n const chainVerification = verifyHistoryChain(historyEntries);\n if (!chainVerification.ok) {\n throw new PmCliError(\n `history-compact requires a valid history chain (${chainVerification.errors.join(\", \")}). Run pm history-repair ${subject.id} first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n\n const boundary = parseBeforeBoundary(options.before, historyEntries);\n const changed = boundary.compactCount > 0;\n const dryRun = Boolean(options.dryRun);\n const author = resolveAuthor(options.author, settings.author_default);\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_compact_noop_before_boundary\");\n }\n\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItem?.raw ?? null;\n const matchedChainBefore =\n loadedItem === null\n ? null\n : replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash;\n if (matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n let rewrittenEntries: HistoryEntry[] = historyEntries;\n let baselineEntryAdded = false;\n let auditEntryAdded = false;\n\n if (changed) {\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(historyEntries, boundary.compactCount);\n const retained = historyEntries.slice(boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message:\n boundary.raw === null\n ? `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`\n : `history-compact baseline snapshot before ${boundary.raw}.`,\n });\n rewrittenEntries = [baselineEntry, ...reanchored.entries];\n baselineEntryAdded = true;\n const compactMessage =\n typeof options.message === \"string\" && options.message.trim().length > 0\n ? options.message\n : boundary.raw === null\n ? `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`\n : `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n if (!dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: compactMessage,\n }),\n );\n auditEntryAdded = true;\n }\n }\n\n const rewrittenVerify = verifyHistoryChain(rewrittenEntries);\n if (!rewrittenVerify.ok) {\n throw new PmCliError(\n `history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await executeHistoryRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n operation: \"history-compact\",\n author,\n force: options.force,\n itemDocument: loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) => {\n try {\n await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));\n } catch (error) {\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\n })),\n );\n }\n\n const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n compact_boundary: {\n kind: boundary.kind,\n before: boundary.raw,\n entries_compacted: boundary.compactCount,\n entries_retained: boundary.retainedCount,\n first_retained_entry: firstRetainedEntry,\n },\n history: {\n path: historyPath,\n entries_scanned: historyEntries.length,\n entries_after: rewrittenEntries.length,\n baseline_entry_added: baselineEntryAdded,\n audit_entry_added: auditEntryAdded,\n verify_ok: rewrittenVerify.ok,\n verify_errors: rewrittenVerify.errors,\n },\n item: {\n exists: subject.located !== null,\n path: subject.located?.itemPath ?? null,\n matched_chain_before: matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n\n/** Default entry floor below which a stream is treated as already compact. */\nexport const HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES = 3;\n\n/**\n * Documents the bulk history compact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactBulkCommandOptions {\n ids?: string[];\n scope?: HistoryCompactScope;\n allOver?: number;\n minEntries?: number;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/** Per-item outcome row in a bulk compaction pass. */\nexport interface HistoryCompactBulkItemResult {\n id: string;\n outcome: \"compacted\" | \"skipped\" | \"errored\";\n entries_before: number;\n entries_after: number | null;\n skip_reason: HistoryCompactBulkSkipReason | null;\n changed: boolean;\n error: string | null;\n}\n\n/**\n * Documents the bulk history compact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCompactBulkResult {\n bulk: true;\n dry_run: boolean;\n mode: \"ids\" | \"scan\";\n scope: HistoryCompactScope | null;\n criteria: {\n min_entries: number;\n all_over: number | null;\n policy_threshold_applied: boolean;\n };\n totals: {\n streams_considered: number;\n selected: number;\n items_compacted: number;\n items_skipped: number;\n items_errored: number;\n };\n results: HistoryCompactBulkItemResult[];\n generated_at: string;\n}\n\n/**\n * Enforce the `pm history-compact` target contract shared by the CLI and MCP\n * surfaces: exactly one selection mode — a single item `<id>`, an explicit\n * `--ids` list, or a scan selector (`--all-over` / `--closed` / `--all-streams`).\n */\nexport function assertHistoryCompactTarget(\n id: string | undefined,\n bulk: { ids?: string[]; allOver?: number; scope?: HistoryCompactScope },\n): void {\n const hasIds = bulk.ids !== undefined && bulk.ids.length > 0;\n const hasScan = bulk.allOver !== undefined || bulk.scope !== undefined;\n const selectorCount = (id !== undefined ? 1 : 0) + (hasIds ? 1 : 0) + (hasScan ? 1 : 0);\n if (selectorCount === 0) {\n throw new PmCliError(\n \"history-compact: provide an item <id>, or a bulk selector (--ids, --all-over <N>, --closed, or --all-streams).\",\n EXIT_CODE.USAGE,\n );\n }\n if (id !== undefined && (hasIds || hasScan)) {\n throw new PmCliError(\n \"history-compact: <id> and bulk selectors (--ids/--all-over/--closed/--all-streams) are mutually exclusive; pass one item id, or use bulk mode without a positional id.\",\n EXIT_CODE.USAGE,\n );\n }\n if (hasIds && hasScan) {\n throw new PmCliError(\n \"history-compact: --ids is mutually exclusive with --all-over/--closed/--all-streams; pass an explicit id list or a scan selector, not both.\",\n EXIT_CODE.USAGE,\n );\n }\n}\n\nfunction countHistoryStreamEntries(raw: string): number {\n let count = 0;\n for (const line of raw.split(/\\r?\\n/)) {\n if (line.trim().length > 0) {\n count += 1;\n }\n }\n return count;\n}\n\n/**\n * Bulk history compaction: compact every history stream matching the requested\n * selection (explicit `--ids`, a `--scope` lifecycle filter, and/or an\n * `--all-over <N>` entry threshold) in one audited pass. Each selected stream is\n * compacted with the same single-item logic ({@link runHistoryCompact}); one\n * failing stream never aborts the rest, and the caller decides the exit code\n * from `totals.items_errored`.\n *\n * When `history.compact_policy` is enabled and no explicit `--all-over` is\n * given, the policy's `max_entries` is used as the scan threshold so the\n * configured policy drives the sweep.\n */\nexport async function runHistoryCompactBulk(\n options: HistoryCompactBulkCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactBulkResult> {\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 statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const classifier = lifecycleClassifierFromStatusRegistry(statusRegistry);\n const items = await listAllFrontMatterLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);\n const bucketById = new Map(items.map((item) => [item.id, classifier.classify(item.status)] as const));\n\n const historyDir = path.join(pmRoot, \"history\");\n const candidates: HistoryCompactBulkCandidate[] = [];\n // A stream that cannot be read during enumeration is isolated as an errored\n // row (mirroring per-stream compaction failures) rather than aborting the pass.\n const preselectionErrors: HistoryCompactBulkItemResult[] = [];\n if (await pathExists(historyDir)) {\n const historyFiles = (await fs.readdir(historyDir))\n .filter((entry) => entry.endsWith(\".jsonl\"))\n .sort((left, right) => left.localeCompare(right));\n for (const fileName of historyFiles) {\n const historyPath = path.join(historyDir, fileName);\n const id = fileName.slice(0, -\".jsonl\".length);\n try {\n const raw = await fs.readFile(historyPath, \"utf8\");\n await runActiveOnReadHooks({ path: historyPath, scope: \"project\" });\n candidates.push({ id, entries: countHistoryStreamEntries(raw), bucket: bucketById.get(id) ?? null });\n } catch (error) {\n preselectionErrors.push({\n id,\n outcome: \"errored\",\n entries_before: 0,\n entries_after: null,\n skip_reason: null,\n changed: false,\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\n const mode: \"ids\" | \"scan\" = options.ids !== undefined && options.ids.length > 0 ? \"ids\" : \"scan\";\n const minEntries = options.minEntries ?? HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES;\n const policy = settings.history.compact_policy;\n const policyThresholdApplied = mode === \"scan\" && options.allOver === undefined && policy.enabled;\n const allOver = options.allOver ?? (policyThresholdApplied ? policy.max_entries : undefined);\n\n const selection = selectHistoryCompactBulkTargets(candidates, {\n ids: options.ids,\n scope: options.scope,\n minEntries,\n allOver,\n });\n\n const dryRun = Boolean(options.dryRun);\n const results: HistoryCompactBulkItemResult[] = [...preselectionErrors];\n const totals = {\n streams_considered: candidates.length + preselectionErrors.length,\n selected: 0,\n items_compacted: 0,\n items_skipped: 0,\n items_errored: preselectionErrors.length,\n };\n for (const row of selection) {\n if (!row.selected) {\n totals.items_skipped += 1;\n results.push({\n id: row.id,\n outcome: \"skipped\",\n entries_before: row.entries,\n entries_after: null,\n skip_reason: row.skip_reason,\n changed: false,\n error: null,\n });\n continue;\n }\n totals.selected += 1;\n try {\n const result = await runHistoryCompact(\n row.id,\n {\n dryRun,\n author: options.author,\n message: options.message,\n force: options.force,\n },\n global,\n );\n totals.items_compacted += 1;\n results.push({\n id: row.id,\n outcome: \"compacted\",\n entries_before: row.entries,\n entries_after: result.history.entries_after,\n skip_reason: null,\n changed: result.changed,\n error: null,\n });\n } catch (error) {\n totals.items_errored += 1;\n results.push({\n id: row.id,\n outcome: \"errored\",\n entries_before: row.entries,\n entries_after: null,\n skip_reason: null,\n changed: false,\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 bulk: true,\n dry_run: dryRun,\n mode,\n scope: options.scope ?? null,\n criteria: {\n min_entries: minEntries,\n all_over: allOver ?? null,\n policy_threshold_applied: policyThresholdApplied,\n },\n totals,\n results,\n generated_at: nowIso(),\n };\n}\n", "/**\n * @module core/history/history-compact-bulk\n *\n * Pure selection logic for bulk history-stream compaction. Given a set of\n * history-stream candidates (id, entry count, and lifecycle bucket of the\n * owning item) plus the requested selection criteria, this module decides which\n * streams should be compacted and which are skipped (and why).\n *\n * The module performs no filesystem access and imports no heavy runtime\n * dependencies — the command layer reads streams and item statuses, hands the\n * resolved candidates here, then executes per-item compaction on the selection\n * this module returns. Keeping selection pure makes the matrix of scope /\n * threshold / explicit-id rules trivially testable without touching disk.\n */\n\nimport type { LifecycleBucket } from \"../governance/metadata-coverage.js\";\n\n/** Bulk-compaction scope: only closed items, or every history stream. */\nexport type HistoryCompactScope = \"closed\" | \"all-streams\";\n\n/** Why a candidate stream was not selected for compaction. */\nexport type HistoryCompactBulkSkipReason = \"no_stream\" | \"already_compact\" | \"scope_mismatch\" | \"below_threshold\";\n\n/**\n * One history stream considered for bulk compaction.\n *\n * `bucket` is the lifecycle bucket of the owning item, or `null` when no item\n * matches the stream (an orphan history file). Orphan streams never satisfy a\n * `closed` scope filter but are eligible under `all-streams`.\n */\nexport interface HistoryCompactBulkCandidate {\n id: string;\n entries: number;\n bucket: LifecycleBucket | null;\n}\n\n/** Selection criteria resolved from the command flags + policy defaults. */\nexport interface HistoryCompactBulkCriteria {\n /**\n * Explicit, ordered list of item ids to compact. When non-empty the selection\n * runs in \"ids\" mode: scope/allOver are ignored and only the `minEntries`\n * floor applies. Duplicates are collapsed, preserving first-seen order.\n */\n ids?: string[];\n /** Lifecycle scope filter for scan mode (ignored in ids mode). */\n scope?: HistoryCompactScope;\n /**\n * Streams with at most this many entries are skipped as `already_compact`\n * (compaction collapses a stream to a 2-entry baseline+audit pair, so smaller\n * streams gain nothing). Applies in both modes.\n */\n minEntries: number;\n /**\n * Scan mode only: when set, only streams with strictly more entries than this\n * are selected. Streams above `minEntries` but at/below `allOver` are skipped\n * as `below_threshold`.\n */\n allOver?: number;\n}\n\n/** Per-candidate selection outcome. */\nexport interface HistoryCompactBulkSelectionRow {\n id: string;\n entries: number;\n selected: boolean;\n skip_reason: HistoryCompactBulkSkipReason | null;\n}\n\nfunction selectIdsMode(\n ids: string[],\n byId: ReadonlyMap<string, HistoryCompactBulkCandidate>,\n minEntries: number,\n): HistoryCompactBulkSelectionRow[] {\n const seen = new Set<string>();\n const rows: HistoryCompactBulkSelectionRow[] = [];\n for (const rawId of ids) {\n const id = rawId.trim();\n if (id.length === 0 || seen.has(id)) {\n continue;\n }\n seen.add(id);\n const candidate = byId.get(id);\n if (candidate === undefined) {\n rows.push({ id, entries: 0, selected: false, skip_reason: \"no_stream\" });\n continue;\n }\n if (candidate.entries <= minEntries) {\n rows.push({ id, entries: candidate.entries, selected: false, skip_reason: \"already_compact\" });\n continue;\n }\n rows.push({ id, entries: candidate.entries, selected: true, skip_reason: null });\n }\n return rows;\n}\n\nfunction selectScanMode(\n candidates: HistoryCompactBulkCandidate[],\n criteria: HistoryCompactBulkCriteria,\n): HistoryCompactBulkSelectionRow[] {\n const ordered = [...candidates].sort((a, b) => b.entries - a.entries || a.id.localeCompare(b.id));\n const rows: HistoryCompactBulkSelectionRow[] = [];\n for (const candidate of ordered) {\n if (criteria.scope === \"closed\" && candidate.bucket !== \"closed\") {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"scope_mismatch\" });\n continue;\n }\n if (candidate.entries <= criteria.minEntries) {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"already_compact\" });\n continue;\n }\n if (criteria.allOver !== undefined && candidate.entries <= criteria.allOver) {\n rows.push({ id: candidate.id, entries: candidate.entries, selected: false, skip_reason: \"below_threshold\" });\n continue;\n }\n rows.push({ id: candidate.id, entries: candidate.entries, selected: true, skip_reason: null });\n }\n return rows;\n}\n\n/**\n * Decide which history streams to compact.\n *\n * Runs in \"ids\" mode when `criteria.ids` is non-empty (exact, ordered set,\n * honouring only the `minEntries` floor) and \"scan\" mode otherwise (every\n * candidate, filtered by scope and entry thresholds, ordered deepest-first).\n */\nexport function selectHistoryCompactBulkTargets(\n candidates: HistoryCompactBulkCandidate[],\n criteria: HistoryCompactBulkCriteria,\n): HistoryCompactBulkSelectionRow[] {\n if (criteria.ids !== undefined && criteria.ids.length > 0) {\n const byId = new Map(candidates.map((candidate) => [candidate.id, candidate]));\n return selectIdsMode(criteria.ids, byId, criteria.minEntries);\n }\n return selectScanMode(candidates, criteria);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;;;;;;;;;;AC8DjB,SAAS,cACP,KACA,MACA,YAAkB;AAElB,QAAM,OAAO,oBAAI,IAAG;AACpB,QAAM,OAAyC,CAAA;AAC/C,aAAW,SAAS,KAAK;AACvB,UAAM,KAAK,MAAM,KAAI;AACrB,QAAI,GAAG,WAAW,KAAK,KAAK,IAAI,EAAE,GAAG;AACnC;IACF;AACA,SAAK,IAAI,EAAE;AACX,UAAM,YAAY,KAAK,IAAI,EAAE;AAC7B,QAAI,cAAc,QAAW;AAC3B,WAAK,KAAK,EA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C3D,UAAU;IACV,iBAAiB;IACjB,eAAe;IACf,eAAe,mBAAmB;;AAEpC,aAAW,OAAO,WAAW;AAC3B,QAAI,CAAC,IAAI,UAAU;AACjB,aAAO,iBAAiB;AACxB,cAAQ,KAAK;QACX,IAAI,IAAI;QACR,SAAS;QACT,gBAAgB,IAAI;QACpB,eAAe;QACf,aAAa,IAAI;QACjB,SAAS;QACT,OAAO;OACR;AACD;IACF;AACA,WAAO,YAAY;AACnB,QAAI;AACF,YAAM,SAAS,MAAM,kBACnB,IAAI,IACJ;QACE;QACA,QAAQ,QAAQ;QAChB,SAAS,QAAQ;QACjB,OAAO,QAAQ;SAEjBA,OAAM;AAER,aAAO,mBAAmB;AAC1B,cAAQ,KAAK;QACX,IAAI,IAAI;QACR,SAAS;QACT,gBAAgB,IAAI;QACpB,eAAe,OAAO,QAAQ;QAC9B,aAAa;QACb,SAAS,OAAO;QAChB,OAAO;OACR;IACH,SAAS,OAAO;AACd,aAAO,iBAAiB;AACxB,cAAQ,KAAK;QACX,IAAI,IAAI;QACR,SAAS;QACT,gBAAgB,IAAI;QACpB,eAAe;QACf,aAAa;QACb,SAAS;;QAET,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;OAC7D;IACH;EACF;AAEA,SAAO;IACL,MAAM;IACN,SAAS;IACT;IACA,OAAO,QAAQ,SAAS;IACxB,UAAU;MACR,aAAa;MACb,UAAU,WAAW;MACrB,0BAA0B;;IAE5B;IACA;IACA,cAAc,OAAM;;AAExB;",
6
6
  "names": ["compactCount", "global"]
7
7
  }
@@ -4,22 +4,20 @@ import {
4
4
  _testOnly,
5
5
  resolveHistorySubject,
6
6
  runHistoryRedact
7
- } from "./chunk-ALQKV6U7.js";
7
+ } from "./chunk-Z55WX4IQ.js";
8
8
  import "./chunk-T5RRNDA7.js";
9
- import "./chunk-MWMHZOZZ.js";
10
- import "./chunk-WB5BYQMF.js";
11
- import "./chunk-V4UYNSEM.js";
12
- import "./chunk-KJZOSF7J.js";
13
- import "./chunk-FBLT6WGK.js";
14
- import "./chunk-ZLWRPBOW.js";
15
- import "./chunk-TKPP4GOO.js";
16
- import "./chunk-FMWW2JDU.js";
17
- import "./chunk-VSAABFGQ.js";
9
+ import "./chunk-VMY7MZEM.js";
10
+ import "./chunk-SJZTPVFT.js";
11
+ import "./chunk-JVQ7UOYC.js";
12
+ import "./chunk-KGQ3W65B.js";
13
+ import "./chunk-V3KLX7U7.js";
14
+ import "./chunk-KRASIL6M.js";
15
+ import "./chunk-CY5IJMUM.js";
18
16
  export {
19
17
  _testOnly,
20
18
  resolveHistorySubject,
21
19
  runHistoryRedact
22
20
  };
23
- //# sourceMappingURL=history-redact-YY4XYVEP.js.map
21
+ //# sourceMappingURL=history-redact-45YW65BK.js.map
24
22
 
25
23
  //# debugId=45eac7fa-f181-5cca-93b7-cfb58909dbb3
@@ -0,0 +1,19 @@
1
+ import {
2
+ _testOnly,
3
+ resolveHistorySubject,
4
+ runHistoryRedact
5
+ } from "./chunk-AWN4PPH5.js";
6
+ import "./chunk-WW4E2DC3.js";
7
+ import "./chunk-IBU2LLWM.js";
8
+ import "./chunk-E2Q2ULMR.js";
9
+ import "./chunk-7L6TXOOC.js";
10
+ import "./chunk-LBH7UYKY.js";
11
+ import "./chunk-ZFIEEDTJ.js";
12
+ import "./chunk-MLHX6DN5.js";
13
+ import "./chunk-SNUK7H5J.js";
14
+ export {
15
+ _testOnly,
16
+ resolveHistorySubject,
17
+ runHistoryRedact
18
+ };
19
+ //# sourceMappingURL=history-redact-BVHWDXPR.js.map
@@ -1,36 +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]="05ad9755-f03f-5854-926e-dc68006c744c")}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]="3696f386-1731-5e09-adb5-74cebd450c27")}catch(e){}}();
3
3
  import {
4
4
  scanHistoryDrift
5
- } from "./chunk-KKX4Z2SE.js";
5
+ } from "./chunk-IHXXUIXS.js";
6
6
  import {
7
7
  executeHistoryRewrite,
8
8
  resolveHistorySubject
9
- } from "./chunk-ALQKV6U7.js";
9
+ } from "./chunk-Z55WX4IQ.js";
10
10
  import "./chunk-T5RRNDA7.js";
11
11
  import {
12
12
  readHistoryEntries
13
- } from "./chunk-MWMHZOZZ.js";
13
+ } from "./chunk-VMY7MZEM.js";
14
14
  import {
15
15
  historyEntriesToRaw,
16
16
  reanchorHistoryEntries,
17
17
  replayHash,
18
18
  toReplayDocument,
19
19
  verifyHistoryChain
20
- } from "./chunk-WB5BYQMF.js";
21
- import "./chunk-V4UYNSEM.js";
20
+ } from "./chunk-SJZTPVFT.js";
21
+ import "./chunk-JVQ7UOYC.js";
22
22
  import {
23
23
  listAllFrontMatterWithBody,
24
24
  readLocatedItem
25
- } from "./chunk-KJZOSF7J.js";
26
- import "./chunk-FBLT6WGK.js";
27
- import "./chunk-ZLWRPBOW.js";
28
- import {
29
- resolveItemTypeRegistry
30
- } from "./chunk-TKPP4GOO.js";
25
+ } from "./chunk-KGQ3W65B.js";
26
+ import "./chunk-V3KLX7U7.js";
31
27
  import {
32
28
  nowIso
33
- } from "./chunk-FMWW2JDU.js";
29
+ } from "./chunk-KRASIL6M.js";
34
30
  import {
35
31
  EXIT_CODE,
36
32
  PmCliError,
@@ -39,10 +35,11 @@ import {
39
35
  pathExists,
40
36
  readFileIfExists,
41
37
  readSettings,
38
+ resolveItemTypeRegistry,
42
39
  resolvePmRoot,
43
40
  runActiveOnWriteHooks,
44
41
  writeFileAtomic
45
- } from "./chunk-VSAABFGQ.js";
42
+ } from "./chunk-CY5IJMUM.js";
46
43
 
47
44
  // dist/cli/commands/history-repair.js
48
45
  import fs from "node:fs/promises";
@@ -241,6 +238,6 @@ export {
241
238
  runHistoryRepair,
242
239
  runHistoryRepairAll
243
240
  };
244
- //# sourceMappingURL=history-repair-YSQH6SY6.js.map
241
+ //# sourceMappingURL=history-repair-FY75IC26.js.map
245
242
 
246
- //# debugId=05ad9755-f03f-5854-926e-dc68006c744c
243
+ //# debugId=3696f386-1731-5e09-adb5-74cebd450c27