@unbrained/pm-cli 2026.7.5 → 2026.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/cli/commands/annotation-command.d.ts +1 -0
  3. package/dist/cli/commands/annotation-command.js +29 -2
  4. package/dist/cli/commands/annotation-command.js.map +1 -1
  5. package/dist/cli/commands/comments.js +3 -4
  6. package/dist/cli/commands/comments.js.map +1 -1
  7. package/dist/cli/commands/extension/bundled-catalog.d.ts +3 -0
  8. package/dist/cli/commands/extension/bundled-catalog.js +38 -28
  9. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  10. package/dist/cli/commands/extension/install-sources.js +81 -18
  11. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  12. package/dist/cli/commands/health.js +9 -5
  13. package/dist/cli/commands/health.js.map +1 -1
  14. package/dist/cli/commands/learnings.js +5 -3
  15. package/dist/cli/commands/learnings.js.map +1 -1
  16. package/dist/cli/commands/notes.js +5 -3
  17. package/dist/cli/commands/notes.js.map +1 -1
  18. package/dist/cli/commands/reindex.js +4 -3
  19. package/dist/cli/commands/reindex.js.map +1 -1
  20. package/dist/cli/commands/search.js +3 -3
  21. package/dist/cli/commands/search.js.map +1 -1
  22. package/dist/cli/commands/test.d.ts +9 -0
  23. package/dist/cli/commands/test.js +144 -105
  24. package/dist/cli/commands/test.js.map +1 -1
  25. package/dist/cli/extension-command-help.js +10 -2
  26. package/dist/cli/extension-command-help.js.map +1 -1
  27. package/dist/cli/register-list-query.d.ts +1 -1
  28. package/dist/cli/register-list-query.js +18 -27
  29. package/dist/cli/register-list-query.js.map +1 -1
  30. package/dist/cli/register-operations.d.ts +0 -8
  31. package/dist/cli/register-operations.js +41 -46
  32. package/dist/cli/register-operations.js.map +1 -1
  33. package/dist/cli/register-setup.js +113 -13
  34. package/dist/cli/register-setup.js.map +1 -1
  35. package/dist/cli/registration-helpers.d.ts +5 -1
  36. package/dist/cli/registration-helpers.js +14 -2
  37. package/dist/cli/registration-helpers.js.map +1 -1
  38. package/dist/cli-bundle/chunks/append-F7WPGIQL.js +11 -0
  39. package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js → append-PVCTBVJG.js} +8 -9
  40. package/dist/cli-bundle/chunks/{chunk-PPE4YUQM.js → chunk-2APXX4TZ.js} +17 -28
  41. package/dist/cli-bundle/chunks/chunk-2APXX4TZ.js.map +1 -0
  42. package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js → chunk-2LEJGRQ7.js} +3 -12
  43. package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js.map → chunk-2LEJGRQ7.js.map} +1 -1
  44. package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js → chunk-2TILG6F2.js} +3 -3
  45. package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js → chunk-3G6UMXT3.js} +6 -8
  46. package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js.map → chunk-3G6UMXT3.js.map} +1 -1
  47. package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js → chunk-3TYOW6RR.js} +8 -8
  48. package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js → chunk-3X542TEY.js} +7 -7
  49. package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js → chunk-42LXP4VO.js} +14 -21
  50. package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js.map → chunk-42LXP4VO.js.map} +1 -1
  51. package/dist/cli-bundle/chunks/{chunk-5J2XPTAD.js → chunk-43SIHQND.js} +36 -15
  52. package/dist/cli-bundle/chunks/chunk-43SIHQND.js.map +7 -0
  53. package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js → chunk-43UQN754.js} +12 -19
  54. package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js.map → chunk-43UQN754.js.map} +1 -1
  55. package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js → chunk-43YSKY75.js} +4 -6
  56. package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js.map → chunk-43YSKY75.js.map} +1 -1
  57. package/dist/cli-bundle/chunks/{notes-72YXN5JX.js → chunk-4BKDAEDF.js} +6 -13
  58. package/dist/cli-bundle/chunks/{notes-72YXN5JX.js.map → chunk-4BKDAEDF.js.map} +2 -2
  59. package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js → chunk-4IQKDKGE.js} +18 -32
  60. package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js.map → chunk-4IQKDKGE.js.map} +1 -1
  61. package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js → chunk-4MZOKTI2.js} +6 -8
  62. package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js.map → chunk-4MZOKTI2.js.map} +1 -1
  63. package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js → chunk-52NS7JDP.js} +14 -20
  64. package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js.map → chunk-52NS7JDP.js.map} +1 -1
  65. package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js → chunk-565WYS5W.js} +12 -16
  66. package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js.map → chunk-565WYS5W.js.map} +1 -1
  67. package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js → chunk-5FIQ4EX3.js} +13 -19
  68. package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js.map → chunk-5FIQ4EX3.js.map} +1 -1
  69. package/dist/cli-bundle/chunks/{config-V57QD47V.js → chunk-6G6O3OPQ.js} +259 -41
  70. package/dist/cli-bundle/chunks/chunk-6G6O3OPQ.js.map +1 -0
  71. package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js → chunk-6LCJRGPD.js} +9 -13
  72. package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js.map → chunk-6LCJRGPD.js.map} +1 -1
  73. package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js → chunk-6UQCNWFV.js} +6 -8
  74. package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js.map → chunk-6UQCNWFV.js.map} +1 -1
  75. package/dist/cli-bundle/chunks/{chunk-LEKT4K7I.js → chunk-6XTSYPPO.js} +1216 -387
  76. package/dist/cli-bundle/chunks/chunk-6XTSYPPO.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js +5434 -0
  78. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js.map +1 -0
  79. package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js → chunk-7PNQA24K.js} +30 -36
  80. package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js.map → chunk-7PNQA24K.js.map} +1 -1
  81. package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js → chunk-7VQ3JJN5.js} +2 -2
  82. package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js → chunk-7Y5N34HX.js} +8 -12
  83. package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js.map → chunk-7Y5N34HX.js.map} +1 -1
  84. package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js → chunk-AGAVEDIE.js} +7 -7
  85. package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js → chunk-AJUON7E6.js} +3 -3
  86. package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js → chunk-ARKHKYYS.js} +16 -30
  87. package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js.map → chunk-ARKHKYYS.js.map} +1 -1
  88. package/dist/cli-bundle/chunks/{chunk-7EQNAZX2.js → chunk-C5ACVMOI.js} +99 -51
  89. package/dist/cli-bundle/chunks/chunk-C5ACVMOI.js.map +7 -0
  90. package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js → chunk-CJQM7O7R.js} +16 -20
  91. package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js.map → chunk-CJQM7O7R.js.map} +1 -1
  92. package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js → chunk-D2DCTFTL.js} +7 -9
  93. package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js.map → chunk-D2DCTFTL.js.map} +1 -1
  94. package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js → chunk-DDDWVPID.js} +7 -11
  95. package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js.map → chunk-DDDWVPID.js.map} +1 -1
  96. package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js → chunk-DG6BSXZ7.js} +6 -13
  97. package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js.map → chunk-DG6BSXZ7.js.map} +2 -2
  98. package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js → chunk-DR2V5OIV.js} +3 -3
  99. package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js → chunk-E3LWJUGF.js} +4 -6
  100. package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js.map → chunk-E3LWJUGF.js.map} +1 -1
  101. package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js → chunk-E3YQFSFE.js} +6 -10
  102. package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js.map → chunk-E3YQFSFE.js.map} +1 -1
  103. package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js → chunk-EDO7VXSO.js} +2 -2
  104. package/dist/cli-bundle/chunks/{chunk-FDBARR33.js → chunk-EIUBK2LT.js} +12 -18
  105. package/dist/cli-bundle/chunks/{chunk-FDBARR33.js.map → chunk-EIUBK2LT.js.map} +1 -1
  106. package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js → chunk-EMXPI36L.js} +14 -20
  107. package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js.map → chunk-EMXPI36L.js.map} +1 -1
  108. package/dist/cli-bundle/chunks/{chunk-4OFLJHX6.js → chunk-EOUVR7JN.js} +13 -8
  109. package/dist/cli-bundle/chunks/chunk-EOUVR7JN.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js → chunk-EVEPHNXJ.js} +4 -4
  111. package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js → chunk-F6MT7KKE.js} +6 -10
  112. package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js.map → chunk-F6MT7KKE.js.map} +1 -1
  113. package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js → chunk-F6YC2A6X.js} +7 -11
  114. package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js.map → chunk-F6YC2A6X.js.map} +1 -1
  115. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js +5514 -0
  116. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js → chunk-FN6SB4HU.js} +2 -2
  118. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js +5359 -0
  119. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js.map +1 -0
  120. package/dist/cli-bundle/chunks/{chunk-JLA7EVYV.js → chunk-GLS6VMWI.js} +37 -16
  121. package/dist/cli-bundle/chunks/chunk-GLS6VMWI.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js → chunk-GPIDUMMN.js} +10 -17
  123. package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js.map → chunk-GPIDUMMN.js.map} +1 -1
  124. package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js → chunk-GTM5HQL4.js} +15 -21
  125. package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js.map → chunk-GTM5HQL4.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js → chunk-H2SMKL2N.js} +8 -8
  127. package/dist/cli-bundle/chunks/{chunk-S4APD35C.js → chunk-HHEWQXPD.js} +6 -6
  128. package/dist/cli-bundle/chunks/chunk-HHEWQXPD.js.map +7 -0
  129. package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js → chunk-HX6QXV5P.js} +2 -2
  130. package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js → chunk-I74FMIWA.js} +11 -17
  131. package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js.map → chunk-I74FMIWA.js.map} +1 -1
  132. package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js +804 -0
  133. package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js.map +7 -0
  134. package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js → chunk-II7R6KD4.js} +9 -13
  135. package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js.map → chunk-II7R6KD4.js.map} +1 -1
  136. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js +10320 -0
  137. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js.map +1 -0
  138. package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js → chunk-J7BOLHAV.js} +5 -7
  139. package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js.map → chunk-J7BOLHAV.js.map} +1 -1
  140. package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js → chunk-KTGJ2CBU.js} +4 -6
  141. package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js.map → chunk-KTGJ2CBU.js.map} +1 -1
  142. package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js → chunk-LCFJ7XAM.js} +32 -2
  143. package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js.map → chunk-LCFJ7XAM.js.map} +3 -3
  144. package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js → chunk-LZQU6XJG.js} +28 -34
  145. package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js.map → chunk-LZQU6XJG.js.map} +1 -1
  146. package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js → chunk-M62RO3XK.js} +10 -14
  147. package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js.map → chunk-M62RO3XK.js.map} +1 -1
  148. package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js → chunk-MCEUKJKW.js} +9 -11
  149. package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js.map → chunk-MCEUKJKW.js.map} +1 -1
  150. package/dist/cli-bundle/chunks/{chunk-T5Y3QSNF.js → chunk-MHNMCDWR.js} +1447 -86
  151. package/dist/cli-bundle/chunks/chunk-MHNMCDWR.js.map +1 -0
  152. package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js → chunk-MRFWUSVA.js} +4 -6
  153. package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js.map → chunk-MRFWUSVA.js.map} +1 -1
  154. package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js → chunk-N6ZHDLUY.js} +6 -8
  155. package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js.map → chunk-N6ZHDLUY.js.map} +1 -1
  156. package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js → chunk-NWWL22C7.js} +8 -12
  157. package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js.map → chunk-NWWL22C7.js.map} +1 -1
  158. package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js → chunk-P3MJJW7P.js} +2 -2
  159. package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js → chunk-PDXJXEZJ.js} +2 -2
  160. package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js → chunk-Q64AYQYW.js} +9 -13
  161. package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js.map → chunk-Q64AYQYW.js.map} +1 -1
  162. package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js → chunk-QDABF2RB.js} +26 -47
  163. package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js.map → chunk-QDABF2RB.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{chunk-NBFCNJ7Q.js → chunk-QFBSP3NI.js} +529 -46
  165. package/dist/cli-bundle/chunks/chunk-QFBSP3NI.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js → chunk-RB3KLPAH.js} +11 -16
  167. package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js.map → chunk-RB3KLPAH.js.map} +1 -1
  168. package/dist/cli-bundle/chunks/{chunk-YSAH5FY5.js → chunk-RY7PTTUB.js} +94 -53
  169. package/dist/cli-bundle/chunks/chunk-RY7PTTUB.js.map +1 -0
  170. package/dist/cli-bundle/chunks/{chunk-WVSGSZ6J.js → chunk-S547WBYG.js} +1477 -86
  171. package/dist/cli-bundle/chunks/chunk-S547WBYG.js.map +7 -0
  172. package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js → chunk-S5BNGFN5.js} +24 -45
  173. package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js.map → chunk-S5BNGFN5.js.map} +1 -1
  174. package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js → chunk-S6VC2A2K.js} +9 -14
  175. package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js.map → chunk-S6VC2A2K.js.map} +1 -1
  176. package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js → chunk-SIM5JDON.js} +7 -14
  177. package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js.map → chunk-SIM5JDON.js.map} +1 -1
  178. package/dist/cli-bundle/chunks/{chunk-ZD34OFFQ.js → chunk-SY75LYXR.js} +12 -7
  179. package/dist/cli-bundle/chunks/chunk-SY75LYXR.js.map +7 -0
  180. package/dist/cli-bundle/chunks/{chunk-TT42JUMF.js → chunk-TEISGNSH.js} +7 -7
  181. package/dist/cli-bundle/chunks/chunk-TEISGNSH.js.map +1 -0
  182. package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js → chunk-TEKZOS7M.js} +2 -2
  183. package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js → chunk-TGUK6XN6.js} +14 -18
  184. package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js.map → chunk-TGUK6XN6.js.map} +1 -1
  185. package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js → chunk-TNC6MZUD.js} +10 -21
  186. package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js.map → chunk-TNC6MZUD.js.map} +1 -1
  187. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js +10498 -0
  188. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js.map +7 -0
  189. package/dist/cli-bundle/chunks/{chunk-YD5FML7K.js → chunk-UO7XAZK6.js} +27 -4
  190. package/dist/cli-bundle/chunks/chunk-UO7XAZK6.js.map +1 -0
  191. package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js → chunk-V5ZWKJNY.js} +5 -14
  192. package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js.map → chunk-V5ZWKJNY.js.map} +1 -1
  193. package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js → chunk-VGO73OCK.js} +7 -14
  194. package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js.map → chunk-VGO73OCK.js.map} +1 -1
  195. package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js → chunk-VLEA2UTQ.js} +2 -2
  196. package/dist/cli-bundle/chunks/{files-6P57MRKL.js → chunk-W5HXHC7C.js} +8 -15
  197. package/dist/cli-bundle/chunks/{files-6P57MRKL.js.map → chunk-W5HXHC7C.js.map} +1 -1
  198. package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js → chunk-WCWVEXGA.js} +2 -2
  199. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js +6690 -0
  200. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js.map +7 -0
  201. package/dist/cli-bundle/chunks/{delete-62JQTYT4.js → chunk-XBX5CBRQ.js} +6 -10
  202. package/dist/cli-bundle/chunks/{delete-62JQTYT4.js.map → chunk-XBX5CBRQ.js.map} +1 -1
  203. package/dist/cli-bundle/chunks/{chunk-MTTXDAK4.js → chunk-XC3X7BQR.js} +541 -44
  204. package/dist/cli-bundle/chunks/chunk-XC3X7BQR.js.map +7 -0
  205. package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js → chunk-XHCVAZGM.js} +17 -23
  206. package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js.map → chunk-XHCVAZGM.js.map} +1 -1
  207. package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js → chunk-XPMXPR7K.js} +7 -9
  208. package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js.map → chunk-XPMXPR7K.js.map} +1 -1
  209. package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js → chunk-XS2TMNXR.js} +8 -12
  210. package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js.map → chunk-XS2TMNXR.js.map} +1 -1
  211. package/dist/cli-bundle/chunks/{plan-XWY5T67S.js → chunk-XXIYUTLK.js} +12 -23
  212. package/dist/cli-bundle/chunks/{plan-XWY5T67S.js.map → chunk-XXIYUTLK.js.map} +1 -1
  213. package/dist/cli-bundle/chunks/{chunk-7QH7DHUB.js → chunk-XZWL7VNE.js} +1220 -398
  214. package/dist/cli-bundle/chunks/chunk-XZWL7VNE.js.map +1 -0
  215. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js +6624 -0
  216. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js → chunk-Y7KYVCZM.js} +12 -18
  218. package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js.map → chunk-Y7KYVCZM.js.map} +1 -1
  219. package/dist/cli-bundle/chunks/{chunk-UI5BJ6DO.js → chunk-YCVWWIKY.js} +17 -28
  220. package/dist/cli-bundle/chunks/chunk-YCVWWIKY.js.map +7 -0
  221. package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js +780 -0
  222. package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js.map +1 -0
  223. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js +5509 -0
  224. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js.map +7 -0
  225. package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js → chunk-YPD7SQ5P.js} +8 -12
  226. package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js.map → chunk-YPD7SQ5P.js.map} +2 -2
  227. package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js → chunk-YPMZMKN7.js} +2 -2
  228. package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js → chunk-YTD5GICJ.js} +4 -4
  229. package/dist/cli-bundle/chunks/{config-DJJKZB5R.js → chunk-ZNEG2UDO.js} +264 -39
  230. package/dist/cli-bundle/chunks/{config-DJJKZB5R.js.map → chunk-ZNEG2UDO.js.map} +4 -4
  231. package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js → chunk-ZO7CLOY2.js} +3 -3
  232. package/dist/cli-bundle/chunks/{close-3YRR3XY6.js → close-3YYQ5OG2.js} +5 -9
  233. package/dist/cli-bundle/chunks/close-Z3Q4U7TS.js +12 -0
  234. package/dist/cli-bundle/chunks/close-many-3L2RXH3M.js +22 -0
  235. package/dist/cli-bundle/chunks/close-many-D366FTIG.js +26 -0
  236. package/dist/cli-bundle/chunks/comments-54XDJNFE.js +17 -0
  237. package/dist/cli-bundle/chunks/comments-HGHC2PN6.js +13 -0
  238. package/dist/cli-bundle/chunks/copy-44RT5GDW.js +13 -0
  239. package/dist/cli-bundle/chunks/copy-UGMUGHZA.js +9 -0
  240. package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js → create-4GWJWPXG.js} +9 -14
  241. package/dist/cli-bundle/chunks/create-AZXCUYKP.js +25 -0
  242. package/dist/cli-bundle/chunks/delete-Y6SXIQ4X.js +10 -0
  243. package/dist/cli-bundle/chunks/delete-YQ2VPXNF.js +14 -0
  244. package/dist/cli-bundle/chunks/deps-BU5EBJDU.js +17 -0
  245. package/dist/cli-bundle/chunks/deps-FMANWFRP.js +13 -0
  246. package/dist/cli-bundle/chunks/docs-OQBSJNIA.js +18 -0
  247. package/dist/cli-bundle/chunks/docs-VNPBZXEL.js +14 -0
  248. package/dist/cli-bundle/chunks/files-72HZEBOE.js +18 -0
  249. package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js → files-HTSB2KJG.js} +13 -13
  250. package/dist/cli-bundle/chunks/focus-FOG4ALC2.js +14 -0
  251. package/dist/cli-bundle/chunks/focus-SUTMKXGX.js +10 -0
  252. package/dist/cli-bundle/chunks/history-compact-M6IFAMBP.js +25 -0
  253. package/dist/cli-bundle/chunks/history-compact-NEXRPP2O.js +21 -0
  254. package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js → history-redact-NQX3OGZP.js} +7 -11
  255. package/dist/cli-bundle/chunks/history-redact-WQJBZ3PX.js +17 -0
  256. package/dist/cli-bundle/chunks/history-repair-CBHMHAJO.js +19 -0
  257. package/dist/cli-bundle/chunks/history-repair-NHOJG7WO.js +23 -0
  258. package/dist/cli-bundle/chunks/learnings-M64NTSOR.js +13 -0
  259. package/dist/cli-bundle/chunks/learnings-T63JGKKN.js +17 -0
  260. package/dist/cli-bundle/chunks/notes-73WE2UV2.js +13 -0
  261. package/dist/cli-bundle/chunks/notes-U7L6HQQ2.js +17 -0
  262. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js +24 -0
  263. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js.map +7 -0
  264. package/dist/cli-bundle/chunks/plan-TN537L24.js +28 -0
  265. package/dist/cli-bundle/chunks/plan-TN537L24.js.map +1 -0
  266. package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js +37 -0
  267. package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js.map +1 -0
  268. package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js +33 -0
  269. package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js.map +7 -0
  270. package/dist/cli-bundle/chunks/{register-list-query-5H66WFYF.js → register-list-query-OHXD7G5N.js} +41 -33
  271. package/dist/cli-bundle/chunks/register-list-query-OHXD7G5N.js.map +7 -0
  272. package/dist/cli-bundle/chunks/{register-list-query-FB3FNDLZ.js → register-list-query-ZCRABAPN.js} +42 -34
  273. package/dist/cli-bundle/chunks/register-list-query-ZCRABAPN.js.map +1 -0
  274. package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js → register-mutation-P3G4XP6Q.js} +36 -41
  275. package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js.map → register-mutation-P3G4XP6Q.js.map} +1 -1
  276. package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js → register-mutation-XX4H56PE.js} +34 -39
  277. package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js.map → register-mutation-XX4H56PE.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{register-operations-A3XAM5J7.js → register-operations-V6PIYEDU.js} +80 -52
  279. package/dist/cli-bundle/chunks/register-operations-V6PIYEDU.js.map +1 -0
  280. package/dist/cli-bundle/chunks/{register-operations-SG7HBSUP.js → register-operations-V6VKTG54.js} +79 -51
  281. package/dist/cli-bundle/chunks/register-operations-V6VKTG54.js.map +7 -0
  282. package/dist/cli-bundle/chunks/{register-setup-K6U3NVY5.js → register-setup-6RVAWT6W.js} +129 -31
  283. package/dist/cli-bundle/chunks/register-setup-6RVAWT6W.js.map +7 -0
  284. package/dist/cli-bundle/chunks/{register-setup-I45OGJUV.js → register-setup-6YVUSQYD.js} +130 -32
  285. package/dist/cli-bundle/chunks/register-setup-6YVUSQYD.js.map +1 -0
  286. package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js → restore-HC3YSWF7.js} +7 -11
  287. package/dist/cli-bundle/chunks/restore-HC3YSWF7.js.map +1 -0
  288. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js +15 -0
  289. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js.map +7 -0
  290. package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js → schema-DAGSYO6E.js} +6 -10
  291. package/dist/cli-bundle/chunks/schema-DAGSYO6E.js.map +7 -0
  292. package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js → schema-UBXJCQAC.js} +6 -10
  293. package/dist/cli-bundle/chunks/schema-UBXJCQAC.js.map +1 -0
  294. package/dist/cli-bundle/chunks/update-CJGG5WMV.js +21 -0
  295. package/dist/cli-bundle/chunks/update-CJGG5WMV.js.map +7 -0
  296. package/dist/cli-bundle/chunks/update-LKD64AFP.js +25 -0
  297. package/dist/cli-bundle/chunks/update-LKD64AFP.js.map +1 -0
  298. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js +31 -0
  299. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js.map +7 -0
  300. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js +35 -0
  301. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js.map +1 -0
  302. package/dist/cli-bundle/main.js +29 -31
  303. package/dist/cli-bundle/main.js.map +2 -2
  304. package/dist/cli-bundle/sdk-runtime.js +136 -54
  305. package/dist/cli-bundle/sdk-testing.js +7 -8
  306. package/dist/cli-bundle/sdk.js +132 -84
  307. package/dist/cli-bundle/sdk.js.map +2 -2
  308. package/dist/core/history/drift-scan.js +3 -8
  309. package/dist/core/history/drift-scan.js.map +1 -1
  310. package/dist/core/output/mutation-projection.js +11 -5
  311. package/dist/core/output/mutation-projection.js.map +1 -1
  312. package/dist/core/search/cache.js +3 -3
  313. package/dist/core/search/cache.js.map +1 -1
  314. package/dist/core/search/semantic-defaults.d.ts +2 -0
  315. package/dist/core/search/semantic-defaults.js +11 -4
  316. package/dist/core/search/semantic-defaults.js.map +1 -1
  317. package/dist/core/search/vector-stores.d.ts +1 -1
  318. package/dist/core/search/vector-stores.js +33 -7
  319. package/dist/core/search/vector-stores.js.map +1 -1
  320. package/dist/mcp/server.d.ts +22 -50
  321. package/dist/mcp/server.js +62 -916
  322. package/dist/mcp/server.js.map +1 -1
  323. package/dist/sdk/cli-contracts/flag-contracts.js +7 -7
  324. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  325. package/dist/sdk/cli-contracts/tool-schema.js +9 -7
  326. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  327. package/dist/sdk/index.d.ts +4 -2
  328. package/dist/sdk/index.js +4 -4
  329. package/dist/sdk/index.js.map +1 -1
  330. package/dist/sdk/runtime.d.ts +312 -5
  331. package/dist/sdk/runtime.js +1391 -26
  332. package/dist/sdk/runtime.js.map +1 -1
  333. package/dist/sdk/start-task-status.d.ts +13 -0
  334. package/dist/sdk/start-task-status.js +19 -0
  335. package/dist/sdk/start-task-status.js.map +1 -0
  336. package/dist/sdk/workspace-contracts-cache.d.ts +17 -0
  337. package/dist/sdk/workspace-contracts-cache.js +36 -0
  338. package/dist/sdk/workspace-contracts-cache.js.map +1 -0
  339. package/docs/COMMANDS.md +10 -1
  340. package/docs/RELEASING.md +3 -1
  341. package/docs/SDK.md +81 -0
  342. package/docs/TESTING.md +3 -0
  343. package/docs/examples/sdk-app-embedding/run-embedded-pm.mjs +16 -2
  344. package/docs/examples/sdk-contract-consumer/inspect-contracts.mjs +16 -1
  345. package/package.json +1 -1
  346. package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +0 -18
  347. package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js +0 -375
  348. package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js.map +0 -7
  349. package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js +0 -372
  350. package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js.map +0 -1
  351. package/dist/cli-bundle/chunks/chunk-37E72CNS.js +0 -217
  352. package/dist/cli-bundle/chunks/chunk-37E72CNS.js.map +0 -1
  353. package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js +0 -1961
  354. package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js.map +0 -1
  355. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js +0 -1749
  356. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +0 -7
  357. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js +0 -87
  358. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js.map +0 -7
  359. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js +0 -822
  360. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js.map +0 -7
  361. package/dist/cli-bundle/chunks/chunk-4OFLJHX6.js.map +0 -1
  362. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js +0 -2181
  363. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +0 -1
  364. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js +0 -1704
  365. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +0 -1
  366. package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js +0 -2330
  367. package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js.map +0 -7
  368. package/dist/cli-bundle/chunks/chunk-5J2XPTAD.js.map +0 -7
  369. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js +0 -995
  370. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js.map +0 -1
  371. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js +0 -819
  372. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js.map +0 -1
  373. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +0 -23
  374. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +0 -7
  375. package/dist/cli-bundle/chunks/chunk-7EQNAZX2.js.map +0 -7
  376. package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +0 -1
  377. package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js +0 -530
  378. package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js.map +0 -7
  379. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +0 -275
  380. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +0 -7
  381. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js +0 -231
  382. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +0 -7
  383. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js +0 -2184
  384. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js.map +0 -7
  385. package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js +0 -1615
  386. package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js.map +0 -7
  387. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js +0 -228
  388. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +0 -1
  389. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js +0 -3237
  390. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +0 -7
  391. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js +0 -1570
  392. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +0 -1
  393. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js +0 -3206
  394. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +0 -1
  395. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js +0 -371
  396. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js.map +0 -7
  397. package/dist/cli-bundle/chunks/chunk-JLA7EVYV.js.map +0 -1
  398. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +0 -76
  399. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +0 -1
  400. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +0 -79
  401. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +0 -7
  402. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +0 -915
  403. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +0 -1
  404. package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js +0 -218
  405. package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js.map +0 -7
  406. package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +0 -7
  407. package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js +0 -1858
  408. package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js.map +0 -1
  409. package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +0 -7
  410. package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js +0 -520
  411. package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js.map +0 -1
  412. package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js +0 -1041
  413. package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js.map +0 -7
  414. package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +0 -1
  415. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +0 -20
  416. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +0 -1
  417. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +0 -918
  418. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +0 -7
  419. package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js +0 -1985
  420. package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js.map +0 -7
  421. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +0 -238
  422. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +0 -1
  423. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +0 -1977
  424. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +0 -7
  425. package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js +0 -1031
  426. package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js.map +0 -1
  427. package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +0 -1
  428. package/dist/cli-bundle/chunks/chunk-QZ342C63.js +0 -220
  429. package/dist/cli-bundle/chunks/chunk-QZ342C63.js.map +0 -7
  430. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js +0 -368
  431. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js.map +0 -1
  432. package/dist/cli-bundle/chunks/chunk-S4APD35C.js.map +0 -7
  433. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js +0 -1149
  434. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +0 -1
  435. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +0 -272
  436. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +0 -1
  437. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +0 -1
  438. package/dist/cli-bundle/chunks/chunk-TT42JUMF.js.map +0 -1
  439. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +0 -165
  440. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +0 -1
  441. package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +0 -7
  442. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +0 -1932
  443. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +0 -1
  444. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +0 -175
  445. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +0 -7
  446. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js +0 -84
  447. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js.map +0 -1
  448. package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js +0 -1868
  449. package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js.map +0 -7
  450. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +0 -7
  451. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js +0 -1152
  452. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +0 -7
  453. package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +0 -1
  454. package/dist/cli-bundle/chunks/chunk-YSAH5FY5.js.map +0 -1
  455. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js +0 -1005
  456. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js.map +0 -7
  457. package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js +0 -215
  458. package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js.map +0 -1
  459. package/dist/cli-bundle/chunks/chunk-ZD34OFFQ.js.map +0 -7
  460. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js +0 -2306
  461. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +0 -1
  462. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +0 -241
  463. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +0 -7
  464. package/dist/cli-bundle/chunks/claim-4DROPSIS.js +0 -144
  465. package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +0 -1
  466. package/dist/cli-bundle/chunks/claim-VX54TV5U.js +0 -147
  467. package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +0 -7
  468. package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +0 -16
  469. package/dist/cli-bundle/chunks/config-V57QD47V.js.map +0 -1
  470. package/dist/cli-bundle/chunks/context-4OQGIPSO.js +0 -45
  471. package/dist/cli-bundle/chunks/context-WLA6IAWE.js +0 -49
  472. package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +0 -12
  473. package/dist/cli-bundle/chunks/create-WKOZKPQR.js +0 -30
  474. package/dist/cli-bundle/chunks/eval-N6UHFWVO.js +0 -288
  475. package/dist/cli-bundle/chunks/eval-N6UHFWVO.js.map +0 -7
  476. package/dist/cli-bundle/chunks/eval-PHOTWYHI.js +0 -278
  477. package/dist/cli-bundle/chunks/eval-PHOTWYHI.js.map +0 -1
  478. package/dist/cli-bundle/chunks/extension-NBAH62ML.js +0 -40
  479. package/dist/cli-bundle/chunks/extension-ZF6ZZPOU.js +0 -44
  480. package/dist/cli-bundle/chunks/gc-AETFKZ44.js +0 -398
  481. package/dist/cli-bundle/chunks/gc-AETFKZ44.js.map +0 -7
  482. package/dist/cli-bundle/chunks/gc-RLBP4QVN.js +0 -388
  483. package/dist/cli-bundle/chunks/gc-RLBP4QVN.js.map +0 -1
  484. package/dist/cli-bundle/chunks/get-NH2MPBCI.js +0 -283
  485. package/dist/cli-bundle/chunks/get-NH2MPBCI.js.map +0 -1
  486. package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js +0 -286
  487. package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js.map +0 -7
  488. package/dist/cli-bundle/chunks/health-3GVPMQBL.js +0 -1612
  489. package/dist/cli-bundle/chunks/health-3GVPMQBL.js.map +0 -1
  490. package/dist/cli-bundle/chunks/health-DNTM72GJ.js +0 -1615
  491. package/dist/cli-bundle/chunks/health-DNTM72GJ.js.map +0 -7
  492. package/dist/cli-bundle/chunks/history-RYKLC72X.js +0 -20
  493. package/dist/cli-bundle/chunks/history-SGPYRAFT.js +0 -24
  494. package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +0 -21
  495. package/dist/cli-bundle/chunks/init-RPIPQUNV.js +0 -32
  496. package/dist/cli-bundle/chunks/init-SKQAESQS.js +0 -28
  497. package/dist/cli-bundle/chunks/list-64LHZ3HM.js +0 -32
  498. package/dist/cli-bundle/chunks/list-7LXBTEKI.js +0 -36
  499. package/dist/cli-bundle/chunks/next-7ODPAQ4U.js +0 -306
  500. package/dist/cli-bundle/chunks/next-7ODPAQ4U.js.map +0 -7
  501. package/dist/cli-bundle/chunks/next-ODJUM4ZM.js +0 -303
  502. package/dist/cli-bundle/chunks/next-ODJUM4ZM.js.map +0 -1
  503. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +0 -397
  504. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +0 -1
  505. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +0 -400
  506. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +0 -7
  507. package/dist/cli-bundle/chunks/register-list-query-5H66WFYF.js.map +0 -7
  508. package/dist/cli-bundle/chunks/register-list-query-FB3FNDLZ.js.map +0 -1
  509. package/dist/cli-bundle/chunks/register-operations-A3XAM5J7.js.map +0 -1
  510. package/dist/cli-bundle/chunks/register-operations-SG7HBSUP.js.map +0 -7
  511. package/dist/cli-bundle/chunks/register-setup-I45OGJUV.js.map +0 -1
  512. package/dist/cli-bundle/chunks/register-setup-K6U3NVY5.js.map +0 -7
  513. package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +0 -19
  514. package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js +0 -91
  515. package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js.map +0 -7
  516. package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js +0 -88
  517. package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js.map +0 -1
  518. package/dist/cli-bundle/chunks/search-3S72CTD6.js +0 -38
  519. package/dist/cli-bundle/chunks/search-WNUNBQXO.js +0 -34
  520. package/dist/cli-bundle/chunks/stats-IJYTRQGV.js +0 -250
  521. package/dist/cli-bundle/chunks/stats-IJYTRQGV.js.map +0 -7
  522. package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js +0 -240
  523. package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js.map +0 -1
  524. package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js +0 -309
  525. package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js.map +0 -7
  526. package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js +0 -306
  527. package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js.map +0 -1
  528. package/dist/cli-bundle/chunks/test-DQ2QFJ7W.js +0 -45
  529. package/dist/cli-bundle/chunks/test-W7QBLVJS.js +0 -41
  530. package/dist/cli-bundle/chunks/test-all-636NTRTT.js +0 -434
  531. package/dist/cli-bundle/chunks/test-all-636NTRTT.js.map +0 -1
  532. package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js +0 -437
  533. package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js.map +0 -7
  534. package/dist/cli-bundle/chunks/test-runs-245OINZR.js +0 -28
  535. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +0 -24
  536. package/dist/cli-bundle/chunks/update-SFLZPJXX.js +0 -30
  537. package/dist/cli-bundle/chunks/update-SJZ6S77U.js +0 -26
  538. package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js +0 -290
  539. package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js.map +0 -7
  540. package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js +0 -287
  541. package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js.map +0 -1
  542. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js +0 -2143
  543. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js.map +0 -7
  544. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js +0 -2105
  545. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js.map +0 -1
  546. /package/dist/cli-bundle/chunks/{activity-4XQIDNM5.js.map → append-F7WPGIQL.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js.map → append-PVCTBVJG.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js.map → chunk-2TILG6F2.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js.map → chunk-3TYOW6RR.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js.map → chunk-3X542TEY.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js.map → chunk-7VQ3JJN5.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js.map → chunk-AGAVEDIE.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js.map → chunk-AJUON7E6.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js.map → chunk-DR2V5OIV.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js.map → chunk-EDO7VXSO.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js.map → chunk-EVEPHNXJ.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js.map → chunk-FN6SB4HU.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js.map → chunk-H2SMKL2N.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js.map → chunk-HX6QXV5P.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js.map → chunk-P3MJJW7P.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js.map → chunk-PDXJXEZJ.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js.map → chunk-TEKZOS7M.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js.map → chunk-VLEA2UTQ.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js.map → chunk-WCWVEXGA.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js.map → chunk-YPMZMKN7.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js.map → chunk-YTD5GICJ.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js.map → chunk-ZO7CLOY2.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{close-3YRR3XY6.js.map → close-3YYQ5OG2.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{close-OB2Y4QP5.js.map → close-Z3Q4U7TS.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{context-4OQGIPSO.js.map → close-many-3L2RXH3M.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{context-WLA6IAWE.js.map → close-many-D366FTIG.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js.map → comments-54XDJNFE.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{contracts-HXJLKCRI.js.map → comments-HGHC2PN6.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js.map → copy-44RT5GDW.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{create-WKOZKPQR.js.map → copy-UGMUGHZA.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{extension-ZF6ZZPOU.js.map → create-4GWJWPXG.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{extension-NBAH62ML.js.map → create-AZXCUYKP.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{history-RYKLC72X.js.map → delete-Y6SXIQ4X.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{history-SGPYRAFT.js.map → delete-YQ2VPXNF.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js.map → deps-BU5EBJDU.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{history-redact-4H3FCKF3.js.map → deps-FMANWFRP.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{init-RPIPQUNV.js.map → docs-OQBSJNIA.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{init-SKQAESQS.js.map → docs-VNPBZXEL.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{list-64LHZ3HM.js.map → files-72HZEBOE.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{list-7LXBTEKI.js.map → files-HTSB2KJG.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js.map → focus-FOG4ALC2.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{restore-PXOFL6AM.js.map → focus-SUTMKXGX.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js.map → history-compact-M6IFAMBP.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js.map → history-compact-NEXRPP2O.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{search-3S72CTD6.js.map → history-redact-NQX3OGZP.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{search-WNUNBQXO.js.map → history-redact-WQJBZ3PX.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{test-W7QBLVJS.js.map → history-repair-CBHMHAJO.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{test-DQ2QFJ7W.js.map → history-repair-NHOJG7WO.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{test-runs-ZRD4GCTT.js.map → learnings-M64NTSOR.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{test-runs-245OINZR.js.map → learnings-T63JGKKN.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{update-SJZ6S77U.js.map → notes-73WE2UV2.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{update-SFLZPJXX.js.map → notes-U7L6HQQ2.js.map} +0 -0
@@ -1,16 +1,19 @@
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]="4b2e8821-8fef-5f8a-99a7-2b848e117ffa")}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]="066b9461-1946-5b62-8a6f-777da307c9c0")}catch(e){}}();
3
3
  import {
4
4
  executeHistoryRewrite,
5
5
  resolveHistorySubject,
6
6
  writeHistoryRawWithRollback
7
- } from "./chunk-IJ6CO3JV.js";
7
+ } from "./chunk-52NS7JDP.js";
8
8
  import {
9
9
  resolveAuthor
10
10
  } from "./chunk-T5RRNDA7.js";
11
+ import {
12
+ lifecycleClassifierFromStatusRegistry
13
+ } from "./chunk-PDXJXEZJ.js";
11
14
  import {
12
15
  readHistoryEntries
13
- } from "./chunk-T3F4DF23.js";
16
+ } from "./chunk-565WYS5W.js";
14
17
  import {
15
18
  cloneEmptyReplayDocument,
16
19
  historyEntriesToRaw,
@@ -19,28 +22,18 @@ import {
19
22
  toReplayDocument,
20
23
  tryApplyReplayPatch,
21
24
  verifyHistoryChain
22
- } from "./chunk-BFVHCAOO.js";
23
- import {
24
- lifecycleClassifierFromStatusRegistry
25
- } from "./chunk-5JE6SMYS.js";
26
- import "./chunk-YFIE7YK6.js";
27
- import {
28
- createHistoryEntry,
29
- listAllFrontMatterLight,
30
- readLocatedItem
31
- } from "./chunk-57C2RLW5.js";
32
- import "./chunk-HK72NWAD.js";
33
- import {
34
- nowIso
35
- } from "./chunk-FJRKQREY.js";
25
+ } from "./chunk-7Y5N34HX.js";
36
26
  import {
37
27
  PmCliError,
28
+ createHistoryEntry,
38
29
  getActiveExtensionRegistrations,
30
+ listAllFrontMatterLight,
31
+ nowIso,
32
+ readLocatedItem,
39
33
  readSettings,
40
34
  runActiveOnReadHooks,
41
35
  runActiveOnWriteHooks
42
- } from "./chunk-US3T3W5J.js";
43
- import "./chunk-NNHHXJB2.js";
36
+ } from "./chunk-GH73UOSJ.js";
44
37
  import {
45
38
  EXIT_CODE,
46
39
  getSettingsPath,
@@ -49,7 +42,7 @@ import {
49
42
  resolveItemTypeRegistry,
50
43
  resolvePmRoot,
51
44
  resolveRuntimeStatusRegistry
52
- } from "./chunk-YD5FML7K.js";
45
+ } from "./chunk-UO7XAZK6.js";
53
46
 
54
47
  // dist/cli/commands/history-compact.js
55
48
  import fs from "node:fs/promises";
@@ -544,12 +537,13 @@ async function runHistoryCompactBulk(options, global) {
544
537
  generated_at: nowIso()
545
538
  };
546
539
  }
540
+
547
541
  export {
542
+ runHistoryCompact,
548
543
  HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES,
549
544
  assertHistoryCompactTarget,
550
- runHistoryCompact,
551
545
  runHistoryCompactBulk
552
546
  };
553
- //# sourceMappingURL=history-compact-656Y2TN4.js.map
547
+ //# sourceMappingURL=chunk-XHCVAZGM.js.map
554
548
 
555
- //# debugId=4b2e8821-8fef-5f8a-99a7-2b848e117ffa
549
+ //# debugId=066b9461-1946-5b62-8a6f-777da307c9c0
@@ -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, writeHistoryRawWithRollback } 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 } 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\ninterface HistoryCompactCurrentItem {\n loadedItem: Awaited<ReturnType<typeof readLocatedItem>> | null;\n currentItemRawBeforeLock: string | null;\n matchedChainBefore: boolean | null;\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\nasync function loadHistoryCompactCurrentItem(\n subject: Awaited<ReturnType<typeof resolveHistorySubject>>,\n settings: Awaited<ReturnType<typeof readSettings>>,\n historyEntries: HistoryEntry[],\n): Promise<HistoryCompactCurrentItem> {\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n if (!loadedItem) {\n return { loadedItem: null, currentItemRawBeforeLock: null, matchedChainBefore: null };\n }\n return {\n loadedItem,\n currentItemRawBeforeLock: loadedItem.raw,\n matchedChainBefore: replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash,\n };\n}\n\nfunction buildHistoryCompactMessage(options: HistoryCompactCommandOptions, boundary: HistoryCompactBoundary): string {\n if (typeof options.message === \"string\" && options.message.trim().length > 0) {\n return options.message;\n }\n if (boundary.raw === null) {\n return `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`;\n }\n return `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n}\n\nfunction buildHistoryCompactBaselineMessage(boundary: HistoryCompactBoundary): string {\n if (boundary.raw === null) {\n return `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`;\n }\n return `history-compact baseline snapshot before ${boundary.raw}.`;\n}\n\nfunction buildHistoryCompactEntries(params: {\n historyEntries: HistoryEntry[];\n boundary: HistoryCompactBoundary;\n changed: boolean;\n dryRun: boolean;\n author: string;\n options: HistoryCompactCommandOptions;\n}): { rewrittenEntries: HistoryEntry[]; baselineEntryAdded: boolean; auditEntryAdded: boolean } {\n if (!params.changed) {\n return { rewrittenEntries: params.historyEntries, baselineEntryAdded: false, auditEntryAdded: false };\n }\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(params.historyEntries, params.boundary.compactCount);\n const retained = params.historyEntries.slice(params.boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, params.boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author: params.author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message: buildHistoryCompactBaselineMessage(params.boundary),\n });\n const rewrittenEntries = [baselineEntry, ...reanchored.entries];\n if (!params.dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author: params.author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: buildHistoryCompactMessage(params.options, params.boundary),\n }),\n );\n }\n return { rewrittenEntries, baselineEntryAdded: true, auditEntryAdded: !params.dryRun };\n}\n\nasync function applyHistoryCompactRewrite(params: {\n pmRoot: string;\n subject: Awaited<ReturnType<typeof resolveHistorySubject>>;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>;\n historyRawBeforeLock: string;\n currentItemRawBeforeLock: string | null;\n author: string;\n force: boolean | undefined;\n loadedItem: Awaited<ReturnType<typeof readLocatedItem>> | null;\n historyPath: string;\n rewrittenEntries: HistoryEntry[];\n}): Promise<string[]> {\n return executeHistoryRewrite({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItemRawBeforeLock,\n operation: \"history-compact\",\n author: params.author,\n force: params.force,\n itemDocument: params.loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) =>\n writeHistoryRawWithRollback({\n historyPath: params.historyPath,\n nextHistoryRaw: historyEntriesToRaw(params.rewrittenEntries),\n historyRawUnderLock,\n }),\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: params.historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\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 currentItem = await loadHistoryCompactCurrentItem(subject, settings, historyEntries);\n if (currentItem.matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n const { rewrittenEntries, baselineEntryAdded, auditEntryAdded } = buildHistoryCompactEntries({\n historyEntries,\n boundary,\n changed,\n dryRun,\n author,\n options,\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 applyHistoryCompactRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock: currentItem.currentItemRawBeforeLock,\n author,\n force: options.force,\n loadedItem: currentItem.loadedItem,\n historyPath,\n rewrittenEntries,\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: currentItem.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\nasync function collectHistoryCompactBulkCandidates(params: {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeToFolder: Record<string, string>;\n}): Promise<{ candidates: HistoryCompactBulkCandidate[]; preselectionErrors: HistoryCompactBulkItemResult[] }> {\n const statusRegistry = resolveRuntimeStatusRegistry(params.settings.schema);\n const classifier = lifecycleClassifierFromStatusRegistry(statusRegistry);\n const items = await listAllFrontMatterLight(\n params.pmRoot,\n params.settings.item_format,\n params.typeToFolder,\n undefined,\n params.settings.schema,\n );\n const bucketById = new Map(items.map((item) => [item.id, classifier.classify(item.status)] as const));\n const historyDir = path.join(params.pmRoot, \"history\");\n const candidates: HistoryCompactBulkCandidate[] = [];\n const preselectionErrors: HistoryCompactBulkItemResult[] = [];\n if (!(await pathExists(historyDir))) {\n return { candidates, preselectionErrors };\n }\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 return { candidates, preselectionErrors };\n}\n\nasync function runHistoryCompactBulkRow(params: {\n row: ReturnType<typeof selectHistoryCompactBulkTargets>[number];\n options: HistoryCompactBulkCommandOptions;\n dryRun: boolean;\n global: GlobalOptions;\n}): Promise<{ result: HistoryCompactBulkItemResult; selected: boolean; compacted: boolean; errored: boolean }> {\n if (!params.row.selected) {\n return {\n selected: false,\n compacted: false,\n errored: false,\n result: {\n id: params.row.id,\n outcome: \"skipped\",\n entries_before: params.row.entries,\n entries_after: null,\n skip_reason: params.row.skip_reason,\n changed: false,\n error: null,\n },\n };\n }\n try {\n const result = await runHistoryCompact(\n params.row.id,\n {\n dryRun: params.dryRun,\n author: params.options.author,\n message: params.options.message,\n force: params.options.force,\n },\n params.global,\n );\n return {\n selected: true,\n compacted: true,\n errored: false,\n result: {\n id: params.row.id,\n outcome: \"compacted\",\n entries_before: params.row.entries,\n entries_after: result.history.entries_after,\n skip_reason: null,\n changed: result.changed,\n error: null,\n },\n };\n } catch (error) {\n return {\n selected: true,\n compacted: false,\n errored: true,\n result: {\n id: params.row.id,\n outcome: \"errored\",\n entries_before: params.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\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 { candidates, preselectionErrors } = await collectHistoryCompactBulkCandidates({\n pmRoot,\n settings,\n typeToFolder: typeRegistry.type_to_folder,\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 const outcome = await runHistoryCompactBulkRow({ row, options, dryRun, global });\n results.push(outcome.result);\n if (!outcome.selected) {\n totals.items_skipped += 1;\n continue;\n }\n totals.selected += 1;\n if (outcome.compacted) {\n totals.items_compacted += 1;\n }\n if (outcome.errored) {\n totals.items_errored += 1;\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,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AQ,SAAS;IACxB,UAAU;MACR,aAAa;MACb,UAAU,WAAW;MACrB,0BAA0B;;IAE5B;IACA;IACA,cAAc,OAAM;;AAExB","debugId":"4b2e8821-8fef-5f8a-99a7-2b848e117ffa"}
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, writeHistoryRawWithRollback } 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 } 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\ninterface HistoryCompactCurrentItem {\n loadedItem: Awaited<ReturnType<typeof readLocatedItem>> | null;\n currentItemRawBeforeLock: string | null;\n matchedChainBefore: boolean | null;\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\nasync function loadHistoryCompactCurrentItem(\n subject: Awaited<ReturnType<typeof resolveHistorySubject>>,\n settings: Awaited<ReturnType<typeof readSettings>>,\n historyEntries: HistoryEntry[],\n): Promise<HistoryCompactCurrentItem> {\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n if (!loadedItem) {\n return { loadedItem: null, currentItemRawBeforeLock: null, matchedChainBefore: null };\n }\n return {\n loadedItem,\n currentItemRawBeforeLock: loadedItem.raw,\n matchedChainBefore: replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash,\n };\n}\n\nfunction buildHistoryCompactMessage(options: HistoryCompactCommandOptions, boundary: HistoryCompactBoundary): string {\n if (typeof options.message === \"string\" && options.message.trim().length > 0) {\n return options.message;\n }\n if (boundary.raw === null) {\n return `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`;\n }\n return `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n}\n\nfunction buildHistoryCompactBaselineMessage(boundary: HistoryCompactBoundary): string {\n if (boundary.raw === null) {\n return `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`;\n }\n return `history-compact baseline snapshot before ${boundary.raw}.`;\n}\n\nfunction buildHistoryCompactEntries(params: {\n historyEntries: HistoryEntry[];\n boundary: HistoryCompactBoundary;\n changed: boolean;\n dryRun: boolean;\n author: string;\n options: HistoryCompactCommandOptions;\n}): { rewrittenEntries: HistoryEntry[]; baselineEntryAdded: boolean; auditEntryAdded: boolean } {\n if (!params.changed) {\n return { rewrittenEntries: params.historyEntries, baselineEntryAdded: false, auditEntryAdded: false };\n }\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(params.historyEntries, params.boundary.compactCount);\n const retained = params.historyEntries.slice(params.boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, params.boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author: params.author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message: buildHistoryCompactBaselineMessage(params.boundary),\n });\n const rewrittenEntries = [baselineEntry, ...reanchored.entries];\n if (!params.dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author: params.author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: buildHistoryCompactMessage(params.options, params.boundary),\n }),\n );\n }\n return { rewrittenEntries, baselineEntryAdded: true, auditEntryAdded: !params.dryRun };\n}\n\nasync function applyHistoryCompactRewrite(params: {\n pmRoot: string;\n subject: Awaited<ReturnType<typeof resolveHistorySubject>>;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>;\n historyRawBeforeLock: string;\n currentItemRawBeforeLock: string | null;\n author: string;\n force: boolean | undefined;\n loadedItem: Awaited<ReturnType<typeof readLocatedItem>> | null;\n historyPath: string;\n rewrittenEntries: HistoryEntry[];\n}): Promise<string[]> {\n return executeHistoryRewrite({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItemRawBeforeLock,\n operation: \"history-compact\",\n author: params.author,\n force: params.force,\n itemDocument: params.loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) =>\n writeHistoryRawWithRollback({\n historyPath: params.historyPath,\n nextHistoryRaw: historyEntriesToRaw(params.rewrittenEntries),\n historyRawUnderLock,\n }),\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: params.historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\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 currentItem = await loadHistoryCompactCurrentItem(subject, settings, historyEntries);\n if (currentItem.matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n const { rewrittenEntries, baselineEntryAdded, auditEntryAdded } = buildHistoryCompactEntries({\n historyEntries,\n boundary,\n changed,\n dryRun,\n author,\n options,\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 applyHistoryCompactRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock: currentItem.currentItemRawBeforeLock,\n author,\n force: options.force,\n loadedItem: currentItem.loadedItem,\n historyPath,\n rewrittenEntries,\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: currentItem.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\nasync function collectHistoryCompactBulkCandidates(params: {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeToFolder: Record<string, string>;\n}): Promise<{ candidates: HistoryCompactBulkCandidate[]; preselectionErrors: HistoryCompactBulkItemResult[] }> {\n const statusRegistry = resolveRuntimeStatusRegistry(params.settings.schema);\n const classifier = lifecycleClassifierFromStatusRegistry(statusRegistry);\n const items = await listAllFrontMatterLight(\n params.pmRoot,\n params.settings.item_format,\n params.typeToFolder,\n undefined,\n params.settings.schema,\n );\n const bucketById = new Map(items.map((item) => [item.id, classifier.classify(item.status)] as const));\n const historyDir = path.join(params.pmRoot, \"history\");\n const candidates: HistoryCompactBulkCandidate[] = [];\n const preselectionErrors: HistoryCompactBulkItemResult[] = [];\n if (!(await pathExists(historyDir))) {\n return { candidates, preselectionErrors };\n }\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 return { candidates, preselectionErrors };\n}\n\nasync function runHistoryCompactBulkRow(params: {\n row: ReturnType<typeof selectHistoryCompactBulkTargets>[number];\n options: HistoryCompactBulkCommandOptions;\n dryRun: boolean;\n global: GlobalOptions;\n}): Promise<{ result: HistoryCompactBulkItemResult; selected: boolean; compacted: boolean; errored: boolean }> {\n if (!params.row.selected) {\n return {\n selected: false,\n compacted: false,\n errored: false,\n result: {\n id: params.row.id,\n outcome: \"skipped\",\n entries_before: params.row.entries,\n entries_after: null,\n skip_reason: params.row.skip_reason,\n changed: false,\n error: null,\n },\n };\n }\n try {\n const result = await runHistoryCompact(\n params.row.id,\n {\n dryRun: params.dryRun,\n author: params.options.author,\n message: params.options.message,\n force: params.options.force,\n },\n params.global,\n );\n return {\n selected: true,\n compacted: true,\n errored: false,\n result: {\n id: params.row.id,\n outcome: \"compacted\",\n entries_before: params.row.entries,\n entries_after: result.history.entries_after,\n skip_reason: null,\n changed: result.changed,\n error: null,\n },\n };\n } catch (error) {\n return {\n selected: true,\n compacted: false,\n errored: true,\n result: {\n id: params.row.id,\n outcome: \"errored\",\n entries_before: params.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\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 { candidates, preselectionErrors } = await collectHistoryCompactBulkCandidates({\n pmRoot,\n settings,\n typeToFolder: typeRegistry.type_to_folder,\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 const outcome = await runHistoryCompactBulkRow({ row, options, dryRun, global });\n results.push(outcome.result);\n if (!outcome.selected) {\n totals.items_skipped += 1;\n continue;\n }\n totals.selected += 1;\n if (outcome.compacted) {\n totals.items_compacted += 1;\n }\n if (outcome.errored) {\n totals.items_errored += 1;\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,SAAS,UAAU,SAAS,UAAU,OAAO,aAAa,kBAAiB,CAAE;AAC7F;IACF;AACA,SAAK,KAAK,EAAE,IAAI,SAAS,UAAU,SAAS,UAAU,MAAM,aAAa,KAAI,CAAE;EACjF;AACA,SAAO;AACT;AAEA,SAAS,eACP,YACA,UAAoC;AAEpC,QAAM,UAAU,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC;AAChG,QAAM,OAAyC,CAAA;AAC/C,aAAW,aAAa,SAAS;AAC/B,QAAI,SAAS,UAAU,YAAY,UAAU,WAAW,UAAU;AAChE,WAAK,KAAK,EAAE,IAAI,UAAU,IAAI,SAAS,UAAU,SAAS,U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AAS,QAAQ,OAAM,CAAE;AAC/E,YAAQ,KAAK,QAAQ,MAAM;AAC3B,QAAI,CAAC,QAAQ,UAAU;AACrB,aAAO,iBAAiB;AACxB;IACF;AACA,WAAO,YAAY;AACnB,QAAI,QAAQ,WAAW;AACrB,aAAO,mBAAmB;IAC5B;AACA,QAAI,QAAQ,SAAS;AACnB,aAAO,iBAAiB;IAC1B;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":"066b9461-1946-5b62-8a6f-777da307c9c0"}
@@ -1,17 +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]="b091c012-afb7-5159-95d2-527f565dc5e7")}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]="15c384ad-9069-5ef0-bf3d-94b32fd19a03")}catch(e){}}();
3
3
  import {
4
4
  normalizeAddTypeInput
5
- } from "./chunk-NER3KUUS.js";
6
- import {
7
- evictOldestMemoEntries
8
- } from "./chunk-NNHHXJB2.js";
5
+ } from "./chunk-VLEA2UTQ.js";
9
6
  import {
10
7
  DEFAULT_RUNTIME_STATUS_DEFINITIONS,
11
8
  RUNTIME_FIELD_COMMAND_VALUES,
12
9
  RUNTIME_FIELD_TYPE_VALUES,
13
- RUNTIME_STATUS_ROLE_VALUES
14
- } from "./chunk-YD5FML7K.js";
10
+ RUNTIME_STATUS_ROLE_VALUES,
11
+ evictOldestMemoEntries
12
+ } from "./chunk-UO7XAZK6.js";
15
13
 
16
14
  // dist/core/schema/status-defs-file.js
17
15
  var RUNTIME_STATUS_ROLE_SET = new Set(RUNTIME_STATUS_ROLE_VALUES);
@@ -528,6 +526,6 @@ export {
528
526
  normalizeTypePresetName,
529
527
  resolveTypePresetDefinitions
530
528
  };
531
- //# sourceMappingURL=chunk-ZAHXPXVY.js.map
529
+ //# sourceMappingURL=chunk-XPMXPR7K.js.map
532
530
 
533
- //# debugId=b091c012-afb7-5159-95d2-527f565dc5e7
531
+ //# debugId=15c384ad-9069-5ef0-bf3d-94b32fd19a03
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../core/schema/status-defs-file.ts","../../../../../../../../core/schema/fields-file.ts","../../../../../../../../core/schema/type-presets.ts"],"sourcesContent":["/**\n * @module core/schema/status-defs-file\n *\n * Resolves configurable schema, fields, statuses, and workflows for Status Defs File.\n */\nimport { RUNTIME_STATUS_ROLE_VALUES } from \"../../types/index.js\";\nimport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\nimport { DEFAULT_RUNTIME_STATUS_DEFINITIONS } from \"./runtime-schema.js\";\nimport { evictOldestMemoEntries } from \"../shared/memo.js\";\n\nexport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\n\n/**\n * Pure logic for the `pm schema add-status` / `pm schema remove-status`\n * commands. The CLI command file (schema.ts) owns IO/governance; everything\n * testable and side-effect-free lives here so it can be coverage-gated to 100%.\n *\n * Statuses persist at `.agents/pm/schema/statuses.json` under the shape\n * `{ statuses: RuntimeStatusDefinition[] }`. When the file is absent the runtime\n * merge layer (src/core/store/settings.ts) still supplies the built-in defaults\n * from DEFAULT_RUNTIME_STATUS_DEFINITIONS, so this module never duplicates them\n * into the persisted file.\n */\n\nconst RUNTIME_STATUS_ROLE_SET = new Set<string>(RUNTIME_STATUS_ROLE_VALUES);\n\n/**\n * Memo for {@link normalizeStatusToken}. Status ranking inside sort comparators\n * normalizes the same handful of status strings O(n log n) times per corpus scan, and\n * the trim/lowercase/regex pipeline shows up in list/next/context profiles. The cap\n * bounds memory in long-lived hosts against unbounded arbitrary inputs; half-eviction keeps the\n * newest-inserted half when the cap is hit. Declared before\n * BUILTIN_STATUS_IDS, whose module-level initializer already normalizes tokens.\n */\nconst STATUS_TOKEN_MEMO_MAX_ENTRIES = 2_000;\nconst statusTokenMemo = new Map<string, string>();\n\n/**\n * The 5 lifecycle status ids that ship as built-in defaults and may never be\n * removed (their normalized ids match DEFAULT_RUNTIME_STATUS_DEFINITIONS:\n * open/in_progress/blocked/closed/canceled). `draft` is also a default but the\n * acceptance criteria enumerate the 5 terminal/active ids explicitly, so the\n * guard derives the full set from the canonical defaults to stay in sync.\n */\nexport const BUILTIN_STATUS_IDS: ReadonlySet<string> = new Set(\n DEFAULT_RUNTIME_STATUS_DEFINITIONS.map((definition) => normalizeStatusToken(definition.id)).filter(\n (id) => id.length > 0,\n ),\n);\n\n/**\n * The shape persisted at `.agents/pm/schema/statuses.json`.\n */\nexport interface StatusDefsFile {\n statuses: RuntimeStatusDefinition[];\n}\n\n/**\n * Documents the raw add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface RawAddStatusInput {\n id: string | undefined;\n roles?: string[];\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the normalized add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface NormalizedAddStatusInput {\n id: string;\n /**\n * Normalized roles, or `undefined` when the raw input did not supply a roles\n * field at all. `undefined` means \"leave existing roles untouched\" on upsert;\n * an explicit empty array means \"clear roles\". This distinction is what keeps\n * `add-status review --description x` from wiping a previously-set role.\n */\n roles?: RuntimeStatusRole[];\n /** Same omitted-vs-explicit-empty semantics as `roles`. */\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the upsert status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface UpsertStatusDefResult {\n file: StatusDefsFile;\n /** The definition as stored after the upsert (existing fields preserved). */\n definition: RuntimeStatusDefinition;\n /** True when an existing definition with the same (normalized) id was replaced. */\n replaced: boolean;\n}\n\n/**\n * Documents the remove status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RemoveStatusDefResult {\n file: StatusDefsFile;\n /** True when a matching definition existed and was dropped from the file. */\n removed: boolean;\n /** The removed definition, when one matched the requested id. */\n definition?: RuntimeStatusDefinition;\n}\n\n/**\n * Normalizes a status token using the same rules as runtime-schema.ts: lowercase\n * and collapse any run of whitespace/hyphens into a single underscore.\n */\nexport function normalizeStatusToken(value: unknown): string {\n if (typeof value !== \"string\") {\n return \"\";\n }\n const memoized = statusTokenMemo.get(value);\n if (memoized !== undefined) {\n return memoized;\n }\n const normalized = value.trim().toLowerCase().replaceAll(/[\\s-]+/g, \"_\");\n if (statusTokenMemo.size >= STATUS_TOKEN_MEMO_MAX_ENTRIES) {\n evictOldestMemoEntries(statusTokenMemo);\n }\n statusTokenMemo.set(value, normalized);\n return normalized;\n}\n\nfunction dedupeTokens(values: Iterable<string>): string[] {\n const seen = new Set<string>();\n for (const value of values) {\n const token = normalizeStatusToken(value);\n if (token.length > 0) {\n seen.add(token);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Validates and normalizes raw add-status CLI input. Throws a plain Error with a\n * stable message when the id is missing/empty or a role is not one of\n * RUNTIME_STATUS_ROLE_VALUES; the CLI layer maps these to PmCliError exit codes.\n *\n * Omitted vs explicit-empty is preserved end-to-end: when `raw.roles`/`raw.aliases`\n * is `undefined` (flag not supplied) the normalized field is `undefined` so the\n * upsert leaves the existing value untouched; when supplied (even an empty array)\n * the field is normalized to an array so the upsert can apply an explicit clear.\n */\nexport function normalizeAddStatusInput(raw: RawAddStatusInput): NormalizedAddStatusInput {\n const id = normalizeStatusToken(raw.id);\n if (id.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n // Built-in lifecycle statuses are reserved and cannot be overridden: an\n // add-status override would change reserved metadata yet remove-status refuses\n // to delete a built-in id, leaving no CLI path to undo it. Reject up front,\n // symmetric with removeStatusDef.\n if (BUILTIN_STATUS_IDS.has(id)) {\n throw new Error(\n `Cannot add-status the built-in status \"${id}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n let roles: RuntimeStatusRole[] | undefined;\n if (raw.roles !== undefined) {\n roles = [];\n const seenRoles = new Set<string>();\n for (const rawRole of raw.roles) {\n const role = typeof rawRole === \"string\" ? rawRole.trim().toLowerCase() : \"\";\n if (role.length === 0) {\n continue;\n }\n if (!RUNTIME_STATUS_ROLE_SET.has(role)) {\n throw new Error(\n `Invalid status role \"${rawRole}\". Allowed roles: ${RUNTIME_STATUS_ROLE_VALUES.join(\", \")}.`,\n );\n }\n if (!seenRoles.has(role)) {\n seenRoles.add(role);\n roles.push(role as RuntimeStatusRole);\n }\n }\n }\n const aliases =\n raw.aliases === undefined ? undefined : dedupeTokens(raw.aliases).filter((alias) => alias !== id);\n const description = raw.description?.trim();\n const order =\n typeof raw.order === \"number\" && Number.isFinite(raw.order) ? Math.trunc(raw.order) : undefined;\n return {\n id,\n roles,\n aliases,\n description: description && description.length > 0 ? description : undefined,\n order,\n };\n}\n\nfunction selectStatusesArray(parsed: unknown): unknown[] | undefined {\n if (Array.isArray(parsed)) {\n return parsed;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as Record<string, unknown>;\n if (Array.isArray(record.statuses)) {\n return record.statuses;\n }\n if (Array.isArray(record.definitions)) {\n return record.definitions;\n }\n return undefined;\n}\n\nfunction extractStatusDefinitions(parsed: unknown): RuntimeStatusDefinition[] {\n const candidate = selectStatusesArray(parsed);\n if (!candidate) {\n return [];\n }\n const definitions: RuntimeStatusDefinition[] = [];\n for (const entry of candidate) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n continue;\n }\n const record = entry as Record<string, unknown>;\n if (typeof record.id !== \"string\" || record.id.trim().length === 0) {\n continue;\n }\n definitions.push(record as unknown as RuntimeStatusDefinition);\n }\n return definitions;\n}\n\n/**\n * Coerces an arbitrary parsed value from statuses.json into a StatusDefsFile.\n * Accepts the canonical `{ statuses: [...] }` shape, a bare array of\n * definitions, or a `{ definitions: [...] }` form, and tolerates a\n * missing/invalid file by returning an empty statuses list.\n */\nexport function parseStatusDefsFile(raw: string | null | undefined): StatusDefsFile {\n if (raw === null || raw === undefined || raw.trim().length === 0) {\n return { statuses: [] };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(\"schema/statuses.json contains invalid JSON.\");\n }\n return { statuses: extractStatusDefinitions(parsed) };\n}\n\n/**\n * Serializes the status definitions file with a trailing newline (matches the\n * rest of the schema scaffold files written by pm).\n */\nexport function serializeStatusDefsFile(file: StatusDefsFile): string {\n return `${JSON.stringify({ statuses: file.statuses }, null, 2)}\\n`;\n}\n\n/**\n * Idempotent UPSERT of a status definition into the parsed file. Matching is by\n * normalized id. When a definition already exists, fields supplied in `input`\n * override the previous values (roles/aliases replace when a non-empty array is\n * given, clear when an explicit empty array is given, and are left UNTOUCHED\n * when the field is `undefined` — i.e. the add-status flag was omitted);\n * description/order override when provided. Fields not addressed by add-status\n * flags are preserved untouched, so `add-status <id> --description x` keeps any\n * previously-set roles/aliases.\n */\nexport function upsertStatusDef(\n file: StatusDefsFile,\n input: NormalizedAddStatusInput,\n baseDefinition?: RuntimeStatusDefinition,\n): UpsertStatusDefResult {\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === input.id,\n );\n // A file-backed definition is the primary seed; when the status is not yet in\n // statuses.json fall back to `baseDefinition` (the resolved settings-backed\n // definition) so omitting --role/--alias preserves metadata that lives in\n // settings.schema.statuses rather than the file.\n const existing = existingIndex >= 0 ? statuses[existingIndex] : baseDefinition;\n\n const next: RuntimeStatusDefinition = {\n ...existing,\n id: input.id,\n };\n if (input.roles !== undefined) {\n if (input.roles.length > 0) {\n next.roles = [...input.roles];\n } else if (next.roles !== undefined) {\n delete next.roles;\n }\n }\n if (input.aliases !== undefined) {\n if (input.aliases.length > 0) {\n next.aliases = [...input.aliases];\n } else if (next.aliases !== undefined) {\n delete next.aliases;\n }\n }\n if (input.description !== undefined) {\n next.description = input.description;\n }\n if (input.order !== undefined) {\n next.order = input.order;\n }\n\n if (existingIndex >= 0) {\n statuses[existingIndex] = next;\n } else {\n statuses.push(next);\n }\n\n return {\n file: { statuses },\n definition: next,\n // \"replaced\" reflects whether the status already existed effectively (in the\n // file OR in resolved settings), so the CLI reports \"Updated\" vs \"Registered\"\n // correctly even when the prior definition lived only in settings.\n replaced: existing !== undefined,\n };\n}\n\n/**\n * Removes a status definition from the parsed file by id (normalized). Throws a\n * plain Error when `id` is empty or matches a reserved built-in default status\n * (those are never stored in the file and must never be deletable). Returns\n * `removed: false` when no matching definition exists so the CLI layer can treat\n * the call as an idempotent no-op.\n */\nexport function removeStatusDef(file: StatusDefsFile, id: string | undefined): RemoveStatusDefResult {\n const normalizedId = normalizeStatusToken(id);\n if (normalizedId.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n if (BUILTIN_STATUS_IDS.has(normalizedId)) {\n throw new Error(\n `Cannot remove built-in status \"${normalizedId}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === normalizedId,\n );\n if (existingIndex < 0) {\n return { file: { statuses }, removed: false };\n }\n const [definition] = statuses.splice(existingIndex, 1);\n return { file: { statuses }, removed: true, definition };\n}\n\n/**\n * Throws when the new status id or any explicitly-supplied alias collides with a\n * DIFFERENT existing status's id/alias. `resolvedAliasToId` maps a normalized\n * token to its owning status id (the runtime status registry's alias_to_id map,\n * which stores ids and aliases in one namespace). Re-adding the same status\n * (matching id) is allowed — only cross-status collisions throw. This prevents a\n * custom status from shadowing a built-in lifecycle token (for example\n * `add-status review --alias open`, or a custom id `cancelled` that aliases the\n * built-in `canceled`), which would make `pm update --status open` resolve to the\n * wrong status. The CLI layer maps the thrown Error to a USAGE exit code.\n */\nexport function assertStatusTokensAvailable(\n input: { id: string; aliases?: string[] },\n resolvedAliasToId: ReadonlyMap<string, string>,\n): void {\n const candidates = [input.id, ...(input.aliases ?? [])];\n for (const candidate of candidates) {\n const token = normalizeStatusToken(candidate);\n if (token.length === 0) {\n continue;\n }\n const owner = resolvedAliasToId.get(token);\n if (owner !== undefined && owner !== input.id) {\n throw new Error(\n `Status token \"${token}\" already belongs to status \"${owner}\". Choose a different id/alias to avoid shadowing it.`,\n );\n }\n }\n}\n","/**\n * @module core/schema/fields-file\n *\n * Resolves configurable schema, fields, statuses, and workflows for Fields File.\n */\nimport {\n RUNTIME_FIELD_COMMAND_VALUES,\n RUNTIME_FIELD_TYPE_VALUES,\n} from \"../../types/index.js\";\nimport type { RuntimeFieldCommand, RuntimeFieldDefinition, RuntimeFieldType } from \"../../types/index.js\";\n\nexport type { RuntimeFieldCommand, RuntimeFieldDefinition, RuntimeFieldType } from \"../../types/index.js\";\n\n/**\n * Pure logic for the `pm schema add-field` / `pm schema remove-field` commands\n * and the `list-fields` / `show-field` inspectors. The CLI command file\n * (schema.ts) owns IO/governance; everything testable and side-effect-free lives\n * here so it can be coverage-gated to 100%.\n *\n * Custom fields persist at `.agents/pm/schema/fields.json` under the shape\n * `{ fields: RuntimeFieldDefinition[] }`. The runtime merge layer\n * (loadRuntimeSchemaFromOptionalFiles) reads that file and dynamically registers\n * a CLI flag per field on create/update/list/search/context, so this module only\n * has to manage the persisted entries; it never duplicates the registration.\n */\n\nconst RUNTIME_FIELD_TYPE_SET = new Set<string>(RUNTIME_FIELD_TYPE_VALUES);\nconst RUNTIME_FIELD_COMMAND_SET = new Set<string>(RUNTIME_FIELD_COMMAND_VALUES);\n\n/**\n * Built-in front-matter field names a custom field key must never shadow. A\n * custom key that collides with one of these would let `pm create --<key>` write\n * over reserved metadata, so add-field rejects them up front (symmetric with the\n * built-in-type guard in item-types-file.ts).\n */\nexport const BUILTIN_FIELD_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"title\",\n \"type\",\n \"status\",\n \"priority\",\n \"tags\",\n \"assignee\",\n \"parent\",\n \"description\",\n \"body\",\n \"created_at\",\n \"updated_at\",\n \"closed_at\",\n \"author\",\n \"deadline\",\n \"estimate\",\n \"sprint\",\n \"release\",\n \"risk\",\n \"confidence\",\n \"reviewer\",\n \"resolution\",\n \"expected\",\n \"actual\",\n]);\n\n/**\n * The default commands a field is wired onto when `--commands` is omitted,\n * matching the runtime default in runtime-schema.ts (normalizeRuntimeFieldDefinition).\n */\nconst DEFAULT_FIELD_COMMANDS: RuntimeFieldCommand[] = [\"create\", \"update\"];\n\n/**\n * The shape persisted at `.agents/pm/schema/fields.json`.\n */\nexport interface FieldsFile {\n fields: RuntimeFieldDefinition[];\n}\n\n/**\n * Documents the raw add field input payload exchanged by command, SDK, and package integrations.\n */\nexport interface RawAddFieldInput {\n key: string | undefined;\n type?: string;\n commands?: string[];\n description?: string;\n cliFlag?: string;\n aliases?: string[];\n required?: boolean;\n requiredOnCreate?: boolean;\n allowUnset?: boolean;\n requiredTypes?: string[];\n}\n\n/**\n * Documents the normalized add field input payload exchanged by command, SDK, and package integrations.\n */\nexport interface NormalizedAddFieldInput {\n key: string;\n type: RuntimeFieldType;\n commands: RuntimeFieldCommand[];\n description?: string;\n cliFlag?: string;\n cliAliases: string[];\n required: boolean;\n requiredOnCreate: boolean;\n allowUnset: boolean;\n requiredTypes: string[];\n}\n\n/**\n * Documents the upsert field result payload exchanged by command, SDK, and package integrations.\n */\nexport interface UpsertFieldResult {\n file: FieldsFile;\n /** The definition as stored after the upsert. */\n definition: RuntimeFieldDefinition;\n /** True when an existing definition with the same (normalized) key was replaced. */\n replaced: boolean;\n}\n\n/**\n * Documents the remove field result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RemoveFieldResult {\n file: FieldsFile;\n /** True when a matching definition existed and was dropped from the file. */\n removed: boolean;\n /** The removed definition, when one matched the requested key. */\n definition?: RuntimeFieldDefinition;\n}\n\n/**\n * Normalizes a field key using the same rule as runtime-schema.ts: lowercase and\n * collapse any run of whitespace/hyphens into a single underscore.\n */\nexport function normalizeFieldKey(value: unknown): string {\n return typeof value === \"string\" ? value.trim().toLowerCase().replaceAll(/[\\s-]+/g, \"_\") : \"\";\n}\n\n/**\n * Normalizes a CLI flag token: strip a leading `--`, lowercase, and collapse\n * whitespace/underscore runs to a single hyphen (matches normalizeCliToken in\n * runtime-schema.ts).\n */\nfunction normalizeCliToken(value: unknown): string {\n if (typeof value !== \"string\") {\n return \"\";\n }\n const collapsed = value.trim().toLowerCase().replaceAll(/[\\s_]+/g, \"-\");\n return collapsed.startsWith(\"--\") ? collapsed.slice(2) : collapsed;\n}\n\nfunction keyToDefaultCliFlag(key: string): string {\n return key.replaceAll(\"_\", \"-\");\n}\n\nfunction dedupeCliTokens(values: Iterable<string>, exclude: string): string[] {\n const seen = new Set<string>();\n for (const value of values) {\n const token = normalizeCliToken(value);\n if (token.length > 0 && token !== exclude) {\n seen.add(token);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\nfunction dedupeStringList(values: string[] | undefined): string[] {\n const seen = new Set<string>();\n for (const value of values ?? []) {\n const trimmed = value.trim();\n if (trimmed.length > 0) {\n seen.add(trimmed);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Normalizes the command allow-list stored for a custom field definition.\n */\nfunction normalizeFieldCommands(rawCommands: string[] | undefined): RuntimeFieldCommand[] {\n const seen = new Set<string>();\n const normalized: RuntimeFieldCommand[] = [];\n for (const rawCommand of rawCommands ?? []) {\n const command = rawCommand.trim().toLowerCase();\n if (command.length === 0) {\n continue;\n }\n if (!RUNTIME_FIELD_COMMAND_SET.has(command)) {\n throw new Error(`Invalid field command \"${rawCommand}\". Allowed: ${RUNTIME_FIELD_COMMAND_VALUES.join(\", \")}.`);\n }\n if (!seen.has(command)) {\n seen.add(command);\n normalized.push(command as RuntimeFieldCommand);\n }\n }\n return rawCommands === undefined || normalized.length === 0 ? [...DEFAULT_FIELD_COMMANDS] : normalized;\n}\n\n/**\n * Validates and normalizes raw add-field CLI input. Throws a plain Error with a\n * stable message when the key is missing/empty, collides with a built-in field,\n * or carries an invalid type/command; the CLI layer maps these to PmCliError\n * exit codes. A `string_array` type implies a repeatable field downstream\n * (runtime-schema.ts derives `repeatable`), so no separate repeatable flag is\n * exposed.\n */\nexport function normalizeAddFieldInput(raw: RawAddFieldInput): NormalizedAddFieldInput {\n const key = normalizeFieldKey(raw.key);\n if (key.length === 0) {\n throw new Error(\"Field key must not be empty.\");\n }\n if (BUILTIN_FIELD_KEYS.has(key)) {\n throw new Error(\n `Cannot define custom field \"${key}\": it shadows a built-in field. Built-in fields are reserved.`,\n );\n }\n\n const typeCandidate =\n typeof raw.type === \"string\" && raw.type.trim().length > 0 ? raw.type.trim().toLowerCase() : \"string\";\n if (!RUNTIME_FIELD_TYPE_SET.has(typeCandidate)) {\n throw new Error(`Invalid field type \"${raw.type}\". Allowed: ${RUNTIME_FIELD_TYPE_VALUES.join(\", \")}.`);\n }\n const type = typeCandidate as RuntimeFieldType;\n\n const commands = normalizeFieldCommands(raw.commands);\n\n const cliFlagToken = normalizeCliToken(raw.cliFlag);\n const cliFlag = cliFlagToken.length > 0 && cliFlagToken !== keyToDefaultCliFlag(key) ? cliFlagToken : undefined;\n const effectiveFlag = cliFlag ?? keyToDefaultCliFlag(key);\n const cliAliases = dedupeCliTokens(raw.aliases ?? [], effectiveFlag);\n\n const description = raw.description?.trim();\n return {\n key,\n type,\n commands,\n description: description && description.length > 0 ? description : undefined,\n cliFlag,\n cliAliases,\n required: raw.required === true,\n requiredOnCreate: raw.requiredOnCreate === true,\n // allow_unset defaults to true (omitted) and is only persisted when an\n // operator explicitly disables it with --no-allow-unset (allowUnset === false).\n allowUnset: raw.allowUnset !== false,\n requiredTypes: dedupeStringList(raw.requiredTypes),\n };\n}\n\nfunction selectFieldsArray(parsed: unknown): unknown[] | undefined {\n if (Array.isArray(parsed)) {\n return parsed;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as Record<string, unknown>;\n if (Array.isArray(record.fields)) {\n return record.fields;\n }\n if (Array.isArray(record.definitions)) {\n return record.definitions;\n }\n return undefined;\n}\n\nfunction extractFieldDefinitions(parsed: unknown): RuntimeFieldDefinition[] {\n const candidate = selectFieldsArray(parsed);\n if (!candidate) {\n return [];\n }\n const definitions: RuntimeFieldDefinition[] = [];\n for (const entry of candidate) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n continue;\n }\n const record = entry as Record<string, unknown>;\n if (typeof record.key !== \"string\" || record.key.trim().length === 0) {\n continue;\n }\n definitions.push(record as unknown as RuntimeFieldDefinition);\n }\n return definitions;\n}\n\n/**\n * Coerces an arbitrary parsed value from fields.json into a FieldsFile. Accepts\n * the canonical `{ fields: [...] }` shape, a bare array, or a `{ definitions: [...] }`\n * form, and tolerates a missing/invalid file by returning an empty fields list.\n */\nexport function parseFieldsFile(raw: string | null | undefined): FieldsFile {\n if (raw === null || raw === undefined || raw.trim().length === 0) {\n return { fields: [] };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(\"schema/fields.json contains invalid JSON.\");\n }\n return { fields: extractFieldDefinitions(parsed) };\n}\n\n/**\n * Serializes the fields file with a trailing newline (matches the rest of the\n * schema scaffold files written by pm).\n */\nexport function serializeFieldsFile(file: FieldsFile): string {\n return `${JSON.stringify({ fields: file.fields }, null, 2)}\\n`;\n}\n\n/**\n * Idempotent UPSERT of a custom field into the parsed file. Matching is by\n * normalized key. When a definition already exists, the supplied input fully\n * replaces its add-field-managed attributes (type/commands/description/flags/\n * required flags) while preserving any unrelated keys the file may carry; any\n * `metadata_key` already stored is preserved so existing item data keeps mapping\n * to the same front-matter column.\n */\nexport function upsertField(file: FieldsFile, input: NormalizedAddFieldInput): UpsertFieldResult {\n // Match by normalized key. A hand-authored file may carry more than one entry\n // for the same key, so drop ALL matches and re-insert a single merged result\n // (collapsing duplicates) rather than only rewriting the first occurrence. The\n // first existing match seeds preserved attributes (e.g. metadata_key).\n const existing = file.fields.find((definition) => normalizeFieldKey(definition.key) === input.key);\n const replaced = existing !== undefined;\n const fields = file.fields.filter((definition) => normalizeFieldKey(definition.key) !== input.key);\n\n const next: RuntimeFieldDefinition = {\n ...existing,\n key: input.key,\n type: input.type,\n commands: [...input.commands],\n };\n applyOptionalString(next, \"description\", input.description);\n applyOptionalString(next, \"cli_flag\", input.cliFlag);\n if (input.cliAliases.length > 0) {\n next.cli_aliases = [...input.cliAliases];\n } else {\n delete next.cli_aliases;\n }\n applyBooleanFlag(next, \"required\", input.required);\n applyBooleanFlag(next, \"required_on_create\", input.requiredOnCreate);\n // allow_unset defaults true; only persist the explicit false override.\n if (input.allowUnset === false) {\n next.allow_unset = false;\n } else {\n delete next.allow_unset;\n }\n if (input.requiredTypes.length > 0) {\n next.required_types = [...input.requiredTypes];\n } else {\n delete next.required_types;\n }\n\n fields.push(next);\n fields.sort((left, right) => normalizeFieldKey(left.key).localeCompare(normalizeFieldKey(right.key)));\n\n return {\n file: { fields },\n definition: next,\n replaced,\n };\n}\n\n/**\n * Removes a custom field definition from the parsed file by key (normalized).\n * Throws a plain Error when `key` is empty. Returns `removed: false` when no\n * matching definition exists so the CLI layer can treat the call as an\n * idempotent no-op.\n */\nexport function removeField(file: FieldsFile, key: string | undefined): RemoveFieldResult {\n const normalizedKey = normalizeFieldKey(key);\n if (normalizedKey.length === 0) {\n throw new Error(\"Field key must not be empty.\");\n }\n // Remove ALL matches (a hand-authored file may carry duplicate entries for the\n // same normalized key) so no stale duplicate survives the removal.\n const removed: RuntimeFieldDefinition[] = [];\n const fields = file.fields.filter((definition) => {\n if (normalizeFieldKey(definition.key) === normalizedKey) {\n removed.push(definition);\n return false;\n }\n return true;\n });\n if (removed.length === 0) {\n return { file: { fields }, removed: false };\n }\n return { file: { fields }, removed: true, definition: removed[0] };\n}\n\nfunction applyOptionalString(definition: RuntimeFieldDefinition, key: string, value: string | undefined): void {\n const record = definition as unknown as Record<string, unknown>;\n if (value !== undefined && value.length > 0) {\n record[key] = value;\n } else {\n delete record[key];\n }\n}\n\nfunction applyBooleanFlag(definition: RuntimeFieldDefinition, key: string, value: boolean): void {\n const record = definition as unknown as Record<string, unknown>;\n if (value) {\n record[key] = true;\n } else {\n delete record[key];\n }\n}\n","/**\n * @module core/schema/type-presets\n *\n * Resolves configurable schema, fields, statuses, and workflows for Type Presets.\n */\nimport { normalizeAddTypeInput, type NormalizedAddTypeInput, type RawAddTypeInput } from \"./item-types-file.js\";\n\n/**\n * Shared domain item-type presets. These power both `pm init --type-preset`\n * (registered during initialization) and the standalone `pm schema apply-preset`\n * subcommand (adopting a preset into an already-initialized project). Keeping the\n * raw definitions and the preset-name normalizer in one place guarantees init and\n * schema register byte-identical types.\n */\n\nexport const TYPE_PRESET_NAMES = [\"agile\", \"ops\", \"research\"] as const;\n/**\n * Restricts type preset name values accepted by command, SDK, and storage contracts.\n */\nexport type TypePresetName = (typeof TYPE_PRESET_NAMES)[number];\n\n/**\n * Raw (pre-normalization) preset definitions keyed by preset name. Each entry is\n * fed through {@link normalizeAddTypeInput} before being upserted so the same\n * validation/normalization the `pm schema add-type` CLI applies governs preset\n * registration too.\n */\nexport const TYPE_PRESET_DEFINITIONS: Record<TypePresetName, RawAddTypeInput[]> = {\n agile: [\n {\n name: \"Story\",\n description: \"User-facing outcome or capability slice expressed from a stakeholder perspective.\",\n defaultStatus: \"open\",\n folder: \"stories\",\n aliases: [\"user-story\"],\n },\n {\n name: \"Spike\",\n description: \"Time-boxed investigation used to reduce uncertainty before implementation.\",\n defaultStatus: \"open\",\n folder: \"spikes\",\n aliases: [\"research-spike\"],\n },\n ],\n ops: [\n {\n name: \"Incident\",\n description: \"Operational disruption, degradation, or support escalation with recovery tracking.\",\n defaultStatus: \"open\",\n folder: \"incidents\",\n aliases: [\"outage\"],\n },\n {\n name: \"Runbook\",\n description: \"Repeatable operational procedure, diagnostic path, or response playbook.\",\n defaultStatus: \"open\",\n folder: \"runbooks\",\n aliases: [\"playbook\"],\n },\n ],\n research: [\n {\n name: \"Experiment\",\n description: \"Validated-learning activity with hypothesis, method, and outcome tracking.\",\n defaultStatus: \"open\",\n folder: \"experiments\",\n aliases: [\"study\"],\n },\n {\n name: \"Hypothesis\",\n description: \"Testable claim or assumption that should be supported, rejected, or refined.\",\n defaultStatus: \"open\",\n folder: \"hypotheses\",\n aliases: [\"assumption\"],\n },\n ],\n};\n\n/**\n * Validates and normalizes a raw preset-name CLI value. Returns `undefined` when\n * the value is omitted (no preset requested). Throws a plain Error with a stable\n * message for an empty or unknown preset; CLI layers map it to a USAGE exit code.\n * Accepts hyphen/underscore-insensitive casing for ergonomics.\n */\nexport function normalizeTypePresetName(rawValue: string | undefined): TypePresetName | undefined {\n if (rawValue === undefined) {\n return undefined;\n }\n const normalized = rawValue.trim().toLowerCase().replaceAll(\"-\", \"_\");\n if (normalized.length === 0) {\n throw new Error(\"Type preset name must not be empty.\");\n }\n if (normalized === \"agile\" || normalized === \"ops\" || normalized === \"research\") {\n return normalized;\n }\n throw new Error(`Invalid type preset \"${rawValue}\". Allowed: ${TYPE_PRESET_NAMES.join(\", \")}.`);\n}\n\n/**\n * Returns the normalized add-type inputs for a preset, in the order they should\n * be upserted. Each raw definition is run through normalizeAddTypeInput so callers\n * get the same validated shape as an individual `add-type` invocation.\n */\nexport function resolveTypePresetDefinitions(preset: TypePresetName): NormalizedAddTypeInput[] {\n return TYPE_PRESET_DEFINITIONS[preset].map((rawDefinition) => normalizeAddTypeInput(rawDefinition));\n}\n"],"names":["definition"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAM,0BAA0B,IAAI,IAAY,0BAA0B;AAU1E,IAAM,gCAAgC;AACtC,IAAM,kBAAkB,oBAAI,IAAG;AASxB,IAAM,qBAA0C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AAG;AACpE,MAAI,WAAW,WAAW,GAAG;AAC3B,UAAM,IAAI,MAAM,qCAAqC;EACvD;AACA,MAAI,eAAe,WAAW,eAAe,SAAS,eAAe,YAAY;AAC/E,WAAO;EACT;AACA,QAAM,IAAI,MAAM,wBAAwB,QAAQ,eAAe,kBAAkB,KAAK,IAAI,CAAC,GAAG;AAChG;AAOM,SAAU,6BAA6B,QAAsB;AACjE,SAAO,wBAAwB,MAAM,EAAE,IAAI,CAAC,kBAAkB,sBAAsB,aAAa,CAAC;AACpG","debugId":"b091c012-afb7-5159-95d2-527f565dc5e7"}
1
+ {"version":3,"sources":["../../../../../../../../core/schema/status-defs-file.ts","../../../../../../../../core/schema/fields-file.ts","../../../../../../../../core/schema/type-presets.ts"],"sourcesContent":["/**\n * @module core/schema/status-defs-file\n *\n * Resolves configurable schema, fields, statuses, and workflows for Status Defs File.\n */\nimport { RUNTIME_STATUS_ROLE_VALUES } from \"../../types/index.js\";\nimport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\nimport { DEFAULT_RUNTIME_STATUS_DEFINITIONS } from \"./runtime-schema.js\";\nimport { evictOldestMemoEntries } from \"../shared/memo.js\";\n\nexport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\n\n/**\n * Pure logic for the `pm schema add-status` / `pm schema remove-status`\n * commands. The CLI command file (schema.ts) owns IO/governance; everything\n * testable and side-effect-free lives here so it can be coverage-gated to 100%.\n *\n * Statuses persist at `.agents/pm/schema/statuses.json` under the shape\n * `{ statuses: RuntimeStatusDefinition[] }`. When the file is absent the runtime\n * merge layer (src/core/store/settings.ts) still supplies the built-in defaults\n * from DEFAULT_RUNTIME_STATUS_DEFINITIONS, so this module never duplicates them\n * into the persisted file.\n */\n\nconst RUNTIME_STATUS_ROLE_SET = new Set<string>(RUNTIME_STATUS_ROLE_VALUES);\n\n/**\n * Memo for {@link normalizeStatusToken}. Status ranking inside sort comparators\n * normalizes the same handful of status strings O(n log n) times per corpus scan, and\n * the trim/lowercase/regex pipeline shows up in list/next/context profiles. The cap\n * bounds memory in long-lived hosts against unbounded arbitrary inputs; half-eviction keeps the\n * newest-inserted half when the cap is hit. Declared before\n * BUILTIN_STATUS_IDS, whose module-level initializer already normalizes tokens.\n */\nconst STATUS_TOKEN_MEMO_MAX_ENTRIES = 2_000;\nconst statusTokenMemo = new Map<string, string>();\n\n/**\n * The 5 lifecycle status ids that ship as built-in defaults and may never be\n * removed (their normalized ids match DEFAULT_RUNTIME_STATUS_DEFINITIONS:\n * open/in_progress/blocked/closed/canceled). `draft` is also a default but the\n * acceptance criteria enumerate the 5 terminal/active ids explicitly, so the\n * guard derives the full set from the canonical defaults to stay in sync.\n */\nexport const BUILTIN_STATUS_IDS: ReadonlySet<string> = new Set(\n DEFAULT_RUNTIME_STATUS_DEFINITIONS.map((definition) => normalizeStatusToken(definition.id)).filter(\n (id) => id.length > 0,\n ),\n);\n\n/**\n * The shape persisted at `.agents/pm/schema/statuses.json`.\n */\nexport interface StatusDefsFile {\n statuses: RuntimeStatusDefinition[];\n}\n\n/**\n * Documents the raw add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface RawAddStatusInput {\n id: string | undefined;\n roles?: string[];\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the normalized add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface NormalizedAddStatusInput {\n id: string;\n /**\n * Normalized roles, or `undefined` when the raw input did not supply a roles\n * field at all. `undefined` means \"leave existing roles untouched\" on upsert;\n * an explicit empty array means \"clear roles\". This distinction is what keeps\n * `add-status review --description x` from wiping a previously-set role.\n */\n roles?: RuntimeStatusRole[];\n /** Same omitted-vs-explicit-empty semantics as `roles`. */\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the upsert status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface UpsertStatusDefResult {\n file: StatusDefsFile;\n /** The definition as stored after the upsert (existing fields preserved). */\n definition: RuntimeStatusDefinition;\n /** True when an existing definition with the same (normalized) id was replaced. */\n replaced: boolean;\n}\n\n/**\n * Documents the remove status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RemoveStatusDefResult {\n file: StatusDefsFile;\n /** True when a matching definition existed and was dropped from the file. */\n removed: boolean;\n /** The removed definition, when one matched the requested id. */\n definition?: RuntimeStatusDefinition;\n}\n\n/**\n * Normalizes a status token using the same rules as runtime-schema.ts: lowercase\n * and collapse any run of whitespace/hyphens into a single underscore.\n */\nexport function normalizeStatusToken(value: unknown): string {\n if (typeof value !== \"string\") {\n return \"\";\n }\n const memoized = statusTokenMemo.get(value);\n if (memoized !== undefined) {\n return memoized;\n }\n const normalized = value.trim().toLowerCase().replaceAll(/[\\s-]+/g, \"_\");\n if (statusTokenMemo.size >= STATUS_TOKEN_MEMO_MAX_ENTRIES) {\n evictOldestMemoEntries(statusTokenMemo);\n }\n statusTokenMemo.set(value, normalized);\n return normalized;\n}\n\nfunction dedupeTokens(values: Iterable<string>): string[] {\n const seen = new Set<string>();\n for (const value of values) {\n const token = normalizeStatusToken(value);\n if (token.length > 0) {\n seen.add(token);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Validates and normalizes raw add-status CLI input. Throws a plain Error with a\n * stable message when the id is missing/empty or a role is not one of\n * RUNTIME_STATUS_ROLE_VALUES; the CLI layer maps these to PmCliError exit codes.\n *\n * Omitted vs explicit-empty is preserved end-to-end: when `raw.roles`/`raw.aliases`\n * is `undefined` (flag not supplied) the normalized field is `undefined` so the\n * upsert leaves the existing value untouched; when supplied (even an empty array)\n * the field is normalized to an array so the upsert can apply an explicit clear.\n */\nexport function normalizeAddStatusInput(raw: RawAddStatusInput): NormalizedAddStatusInput {\n const id = normalizeStatusToken(raw.id);\n if (id.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n // Built-in lifecycle statuses are reserved and cannot be overridden: an\n // add-status override would change reserved metadata yet remove-status refuses\n // to delete a built-in id, leaving no CLI path to undo it. Reject up front,\n // symmetric with removeStatusDef.\n if (BUILTIN_STATUS_IDS.has(id)) {\n throw new Error(\n `Cannot add-status the built-in status \"${id}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n let roles: RuntimeStatusRole[] | undefined;\n if (raw.roles !== undefined) {\n roles = [];\n const seenRoles = new Set<string>();\n for (const rawRole of raw.roles) {\n const role = typeof rawRole === \"string\" ? rawRole.trim().toLowerCase() : \"\";\n if (role.length === 0) {\n continue;\n }\n if (!RUNTIME_STATUS_ROLE_SET.has(role)) {\n throw new Error(\n `Invalid status role \"${rawRole}\". Allowed roles: ${RUNTIME_STATUS_ROLE_VALUES.join(\", \")}.`,\n );\n }\n if (!seenRoles.has(role)) {\n seenRoles.add(role);\n roles.push(role as RuntimeStatusRole);\n }\n }\n }\n const aliases =\n raw.aliases === undefined ? undefined : dedupeTokens(raw.aliases).filter((alias) => alias !== id);\n const description = raw.description?.trim();\n const order =\n typeof raw.order === \"number\" && Number.isFinite(raw.order) ? Math.trunc(raw.order) : undefined;\n return {\n id,\n roles,\n aliases,\n description: description && description.length > 0 ? description : undefined,\n order,\n };\n}\n\nfunction selectStatusesArray(parsed: unknown): unknown[] | undefined {\n if (Array.isArray(parsed)) {\n return parsed;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as Record<string, unknown>;\n if (Array.isArray(record.statuses)) {\n return record.statuses;\n }\n if (Array.isArray(record.definitions)) {\n return record.definitions;\n }\n return undefined;\n}\n\nfunction extractStatusDefinitions(parsed: unknown): RuntimeStatusDefinition[] {\n const candidate = selectStatusesArray(parsed);\n if (!candidate) {\n return [];\n }\n const definitions: RuntimeStatusDefinition[] = [];\n for (const entry of candidate) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n continue;\n }\n const record = entry as Record<string, unknown>;\n if (typeof record.id !== \"string\" || record.id.trim().length === 0) {\n continue;\n }\n definitions.push(record as unknown as RuntimeStatusDefinition);\n }\n return definitions;\n}\n\n/**\n * Coerces an arbitrary parsed value from statuses.json into a StatusDefsFile.\n * Accepts the canonical `{ statuses: [...] }` shape, a bare array of\n * definitions, or a `{ definitions: [...] }` form, and tolerates a\n * missing/invalid file by returning an empty statuses list.\n */\nexport function parseStatusDefsFile(raw: string | null | undefined): StatusDefsFile {\n if (raw === null || raw === undefined || raw.trim().length === 0) {\n return { statuses: [] };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(\"schema/statuses.json contains invalid JSON.\");\n }\n return { statuses: extractStatusDefinitions(parsed) };\n}\n\n/**\n * Serializes the status definitions file with a trailing newline (matches the\n * rest of the schema scaffold files written by pm).\n */\nexport function serializeStatusDefsFile(file: StatusDefsFile): string {\n return `${JSON.stringify({ statuses: file.statuses }, null, 2)}\\n`;\n}\n\n/**\n * Idempotent UPSERT of a status definition into the parsed file. Matching is by\n * normalized id. When a definition already exists, fields supplied in `input`\n * override the previous values (roles/aliases replace when a non-empty array is\n * given, clear when an explicit empty array is given, and are left UNTOUCHED\n * when the field is `undefined` — i.e. the add-status flag was omitted);\n * description/order override when provided. Fields not addressed by add-status\n * flags are preserved untouched, so `add-status <id> --description x` keeps any\n * previously-set roles/aliases.\n */\nexport function upsertStatusDef(\n file: StatusDefsFile,\n input: NormalizedAddStatusInput,\n baseDefinition?: RuntimeStatusDefinition,\n): UpsertStatusDefResult {\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === input.id,\n );\n // A file-backed definition is the primary seed; when the status is not yet in\n // statuses.json fall back to `baseDefinition` (the resolved settings-backed\n // definition) so omitting --role/--alias preserves metadata that lives in\n // settings.schema.statuses rather than the file.\n const existing = existingIndex >= 0 ? statuses[existingIndex] : baseDefinition;\n\n const next: RuntimeStatusDefinition = {\n ...existing,\n id: input.id,\n };\n if (input.roles !== undefined) {\n if (input.roles.length > 0) {\n next.roles = [...input.roles];\n } else if (next.roles !== undefined) {\n delete next.roles;\n }\n }\n if (input.aliases !== undefined) {\n if (input.aliases.length > 0) {\n next.aliases = [...input.aliases];\n } else if (next.aliases !== undefined) {\n delete next.aliases;\n }\n }\n if (input.description !== undefined) {\n next.description = input.description;\n }\n if (input.order !== undefined) {\n next.order = input.order;\n }\n\n if (existingIndex >= 0) {\n statuses[existingIndex] = next;\n } else {\n statuses.push(next);\n }\n\n return {\n file: { statuses },\n definition: next,\n // \"replaced\" reflects whether the status already existed effectively (in the\n // file OR in resolved settings), so the CLI reports \"Updated\" vs \"Registered\"\n // correctly even when the prior definition lived only in settings.\n replaced: existing !== undefined,\n };\n}\n\n/**\n * Removes a status definition from the parsed file by id (normalized). Throws a\n * plain Error when `id` is empty or matches a reserved built-in default status\n * (those are never stored in the file and must never be deletable). Returns\n * `removed: false` when no matching definition exists so the CLI layer can treat\n * the call as an idempotent no-op.\n */\nexport function removeStatusDef(file: StatusDefsFile, id: string | undefined): RemoveStatusDefResult {\n const normalizedId = normalizeStatusToken(id);\n if (normalizedId.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n if (BUILTIN_STATUS_IDS.has(normalizedId)) {\n throw new Error(\n `Cannot remove built-in status \"${normalizedId}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === normalizedId,\n );\n if (existingIndex < 0) {\n return { file: { statuses }, removed: false };\n }\n const [definition] = statuses.splice(existingIndex, 1);\n return { file: { statuses }, removed: true, definition };\n}\n\n/**\n * Throws when the new status id or any explicitly-supplied alias collides with a\n * DIFFERENT existing status's id/alias. `resolvedAliasToId` maps a normalized\n * token to its owning status id (the runtime status registry's alias_to_id map,\n * which stores ids and aliases in one namespace). Re-adding the same status\n * (matching id) is allowed — only cross-status collisions throw. This prevents a\n * custom status from shadowing a built-in lifecycle token (for example\n * `add-status review --alias open`, or a custom id `cancelled` that aliases the\n * built-in `canceled`), which would make `pm update --status open` resolve to the\n * wrong status. The CLI layer maps the thrown Error to a USAGE exit code.\n */\nexport function assertStatusTokensAvailable(\n input: { id: string; aliases?: string[] },\n resolvedAliasToId: ReadonlyMap<string, string>,\n): void {\n const candidates = [input.id, ...(input.aliases ?? [])];\n for (const candidate of candidates) {\n const token = normalizeStatusToken(candidate);\n if (token.length === 0) {\n continue;\n }\n const owner = resolvedAliasToId.get(token);\n if (owner !== undefined && owner !== input.id) {\n throw new Error(\n `Status token \"${token}\" already belongs to status \"${owner}\". Choose a different id/alias to avoid shadowing it.`,\n );\n }\n }\n}\n","/**\n * @module core/schema/fields-file\n *\n * Resolves configurable schema, fields, statuses, and workflows for Fields File.\n */\nimport {\n RUNTIME_FIELD_COMMAND_VALUES,\n RUNTIME_FIELD_TYPE_VALUES,\n} from \"../../types/index.js\";\nimport type { RuntimeFieldCommand, RuntimeFieldDefinition, RuntimeFieldType } from \"../../types/index.js\";\n\nexport type { RuntimeFieldCommand, RuntimeFieldDefinition, RuntimeFieldType } from \"../../types/index.js\";\n\n/**\n * Pure logic for the `pm schema add-field` / `pm schema remove-field` commands\n * and the `list-fields` / `show-field` inspectors. The CLI command file\n * (schema.ts) owns IO/governance; everything testable and side-effect-free lives\n * here so it can be coverage-gated to 100%.\n *\n * Custom fields persist at `.agents/pm/schema/fields.json` under the shape\n * `{ fields: RuntimeFieldDefinition[] }`. The runtime merge layer\n * (loadRuntimeSchemaFromOptionalFiles) reads that file and dynamically registers\n * a CLI flag per field on create/update/list/search/context, so this module only\n * has to manage the persisted entries; it never duplicates the registration.\n */\n\nconst RUNTIME_FIELD_TYPE_SET = new Set<string>(RUNTIME_FIELD_TYPE_VALUES);\nconst RUNTIME_FIELD_COMMAND_SET = new Set<string>(RUNTIME_FIELD_COMMAND_VALUES);\n\n/**\n * Built-in front-matter field names a custom field key must never shadow. A\n * custom key that collides with one of these would let `pm create --<key>` write\n * over reserved metadata, so add-field rejects them up front (symmetric with the\n * built-in-type guard in item-types-file.ts).\n */\nexport const BUILTIN_FIELD_KEYS: ReadonlySet<string> = new Set([\n \"id\",\n \"title\",\n \"type\",\n \"status\",\n \"priority\",\n \"tags\",\n \"assignee\",\n \"parent\",\n \"description\",\n \"body\",\n \"created_at\",\n \"updated_at\",\n \"closed_at\",\n \"author\",\n \"deadline\",\n \"estimate\",\n \"sprint\",\n \"release\",\n \"risk\",\n \"confidence\",\n \"reviewer\",\n \"resolution\",\n \"expected\",\n \"actual\",\n]);\n\n/**\n * The default commands a field is wired onto when `--commands` is omitted,\n * matching the runtime default in runtime-schema.ts (normalizeRuntimeFieldDefinition).\n */\nconst DEFAULT_FIELD_COMMANDS: RuntimeFieldCommand[] = [\"create\", \"update\"];\n\n/**\n * The shape persisted at `.agents/pm/schema/fields.json`.\n */\nexport interface FieldsFile {\n fields: RuntimeFieldDefinition[];\n}\n\n/**\n * Documents the raw add field input payload exchanged by command, SDK, and package integrations.\n */\nexport interface RawAddFieldInput {\n key: string | undefined;\n type?: string;\n commands?: string[];\n description?: string;\n cliFlag?: string;\n aliases?: string[];\n required?: boolean;\n requiredOnCreate?: boolean;\n allowUnset?: boolean;\n requiredTypes?: string[];\n}\n\n/**\n * Documents the normalized add field input payload exchanged by command, SDK, and package integrations.\n */\nexport interface NormalizedAddFieldInput {\n key: string;\n type: RuntimeFieldType;\n commands: RuntimeFieldCommand[];\n description?: string;\n cliFlag?: string;\n cliAliases: string[];\n required: boolean;\n requiredOnCreate: boolean;\n allowUnset: boolean;\n requiredTypes: string[];\n}\n\n/**\n * Documents the upsert field result payload exchanged by command, SDK, and package integrations.\n */\nexport interface UpsertFieldResult {\n file: FieldsFile;\n /** The definition as stored after the upsert. */\n definition: RuntimeFieldDefinition;\n /** True when an existing definition with the same (normalized) key was replaced. */\n replaced: boolean;\n}\n\n/**\n * Documents the remove field result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RemoveFieldResult {\n file: FieldsFile;\n /** True when a matching definition existed and was dropped from the file. */\n removed: boolean;\n /** The removed definition, when one matched the requested key. */\n definition?: RuntimeFieldDefinition;\n}\n\n/**\n * Normalizes a field key using the same rule as runtime-schema.ts: lowercase and\n * collapse any run of whitespace/hyphens into a single underscore.\n */\nexport function normalizeFieldKey(value: unknown): string {\n return typeof value === \"string\" ? value.trim().toLowerCase().replaceAll(/[\\s-]+/g, \"_\") : \"\";\n}\n\n/**\n * Normalizes a CLI flag token: strip a leading `--`, lowercase, and collapse\n * whitespace/underscore runs to a single hyphen (matches normalizeCliToken in\n * runtime-schema.ts).\n */\nfunction normalizeCliToken(value: unknown): string {\n if (typeof value !== \"string\") {\n return \"\";\n }\n const collapsed = value.trim().toLowerCase().replaceAll(/[\\s_]+/g, \"-\");\n return collapsed.startsWith(\"--\") ? collapsed.slice(2) : collapsed;\n}\n\nfunction keyToDefaultCliFlag(key: string): string {\n return key.replaceAll(\"_\", \"-\");\n}\n\nfunction dedupeCliTokens(values: Iterable<string>, exclude: string): string[] {\n const seen = new Set<string>();\n for (const value of values) {\n const token = normalizeCliToken(value);\n if (token.length > 0 && token !== exclude) {\n seen.add(token);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\nfunction dedupeStringList(values: string[] | undefined): string[] {\n const seen = new Set<string>();\n for (const value of values ?? []) {\n const trimmed = value.trim();\n if (trimmed.length > 0) {\n seen.add(trimmed);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Normalizes the command allow-list stored for a custom field definition.\n */\nfunction normalizeFieldCommands(rawCommands: string[] | undefined): RuntimeFieldCommand[] {\n const seen = new Set<string>();\n const normalized: RuntimeFieldCommand[] = [];\n for (const rawCommand of rawCommands ?? []) {\n const command = rawCommand.trim().toLowerCase();\n if (command.length === 0) {\n continue;\n }\n if (!RUNTIME_FIELD_COMMAND_SET.has(command)) {\n throw new Error(`Invalid field command \"${rawCommand}\". Allowed: ${RUNTIME_FIELD_COMMAND_VALUES.join(\", \")}.`);\n }\n if (!seen.has(command)) {\n seen.add(command);\n normalized.push(command as RuntimeFieldCommand);\n }\n }\n return rawCommands === undefined || normalized.length === 0 ? [...DEFAULT_FIELD_COMMANDS] : normalized;\n}\n\n/**\n * Validates and normalizes raw add-field CLI input. Throws a plain Error with a\n * stable message when the key is missing/empty, collides with a built-in field,\n * or carries an invalid type/command; the CLI layer maps these to PmCliError\n * exit codes. A `string_array` type implies a repeatable field downstream\n * (runtime-schema.ts derives `repeatable`), so no separate repeatable flag is\n * exposed.\n */\nexport function normalizeAddFieldInput(raw: RawAddFieldInput): NormalizedAddFieldInput {\n const key = normalizeFieldKey(raw.key);\n if (key.length === 0) {\n throw new Error(\"Field key must not be empty.\");\n }\n if (BUILTIN_FIELD_KEYS.has(key)) {\n throw new Error(\n `Cannot define custom field \"${key}\": it shadows a built-in field. Built-in fields are reserved.`,\n );\n }\n\n const typeCandidate =\n typeof raw.type === \"string\" && raw.type.trim().length > 0 ? raw.type.trim().toLowerCase() : \"string\";\n if (!RUNTIME_FIELD_TYPE_SET.has(typeCandidate)) {\n throw new Error(`Invalid field type \"${raw.type}\". Allowed: ${RUNTIME_FIELD_TYPE_VALUES.join(\", \")}.`);\n }\n const type = typeCandidate as RuntimeFieldType;\n\n const commands = normalizeFieldCommands(raw.commands);\n\n const cliFlagToken = normalizeCliToken(raw.cliFlag);\n const cliFlag = cliFlagToken.length > 0 && cliFlagToken !== keyToDefaultCliFlag(key) ? cliFlagToken : undefined;\n const effectiveFlag = cliFlag ?? keyToDefaultCliFlag(key);\n const cliAliases = dedupeCliTokens(raw.aliases ?? [], effectiveFlag);\n\n const description = raw.description?.trim();\n return {\n key,\n type,\n commands,\n description: description && description.length > 0 ? description : undefined,\n cliFlag,\n cliAliases,\n required: raw.required === true,\n requiredOnCreate: raw.requiredOnCreate === true,\n // allow_unset defaults to true (omitted) and is only persisted when an\n // operator explicitly disables it with --no-allow-unset (allowUnset === false).\n allowUnset: raw.allowUnset !== false,\n requiredTypes: dedupeStringList(raw.requiredTypes),\n };\n}\n\nfunction selectFieldsArray(parsed: unknown): unknown[] | undefined {\n if (Array.isArray(parsed)) {\n return parsed;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as Record<string, unknown>;\n if (Array.isArray(record.fields)) {\n return record.fields;\n }\n if (Array.isArray(record.definitions)) {\n return record.definitions;\n }\n return undefined;\n}\n\nfunction extractFieldDefinitions(parsed: unknown): RuntimeFieldDefinition[] {\n const candidate = selectFieldsArray(parsed);\n if (!candidate) {\n return [];\n }\n const definitions: RuntimeFieldDefinition[] = [];\n for (const entry of candidate) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n continue;\n }\n const record = entry as Record<string, unknown>;\n if (typeof record.key !== \"string\" || record.key.trim().length === 0) {\n continue;\n }\n definitions.push(record as unknown as RuntimeFieldDefinition);\n }\n return definitions;\n}\n\n/**\n * Coerces an arbitrary parsed value from fields.json into a FieldsFile. Accepts\n * the canonical `{ fields: [...] }` shape, a bare array, or a `{ definitions: [...] }`\n * form, and tolerates a missing/invalid file by returning an empty fields list.\n */\nexport function parseFieldsFile(raw: string | null | undefined): FieldsFile {\n if (raw === null || raw === undefined || raw.trim().length === 0) {\n return { fields: [] };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(\"schema/fields.json contains invalid JSON.\");\n }\n return { fields: extractFieldDefinitions(parsed) };\n}\n\n/**\n * Serializes the fields file with a trailing newline (matches the rest of the\n * schema scaffold files written by pm).\n */\nexport function serializeFieldsFile(file: FieldsFile): string {\n return `${JSON.stringify({ fields: file.fields }, null, 2)}\\n`;\n}\n\n/**\n * Idempotent UPSERT of a custom field into the parsed file. Matching is by\n * normalized key. When a definition already exists, the supplied input fully\n * replaces its add-field-managed attributes (type/commands/description/flags/\n * required flags) while preserving any unrelated keys the file may carry; any\n * `metadata_key` already stored is preserved so existing item data keeps mapping\n * to the same front-matter column.\n */\nexport function upsertField(file: FieldsFile, input: NormalizedAddFieldInput): UpsertFieldResult {\n // Match by normalized key. A hand-authored file may carry more than one entry\n // for the same key, so drop ALL matches and re-insert a single merged result\n // (collapsing duplicates) rather than only rewriting the first occurrence. The\n // first existing match seeds preserved attributes (e.g. metadata_key).\n const existing = file.fields.find((definition) => normalizeFieldKey(definition.key) === input.key);\n const replaced = existing !== undefined;\n const fields = file.fields.filter((definition) => normalizeFieldKey(definition.key) !== input.key);\n\n const next: RuntimeFieldDefinition = {\n ...existing,\n key: input.key,\n type: input.type,\n commands: [...input.commands],\n };\n applyOptionalString(next, \"description\", input.description);\n applyOptionalString(next, \"cli_flag\", input.cliFlag);\n if (input.cliAliases.length > 0) {\n next.cli_aliases = [...input.cliAliases];\n } else {\n delete next.cli_aliases;\n }\n applyBooleanFlag(next, \"required\", input.required);\n applyBooleanFlag(next, \"required_on_create\", input.requiredOnCreate);\n // allow_unset defaults true; only persist the explicit false override.\n if (input.allowUnset === false) {\n next.allow_unset = false;\n } else {\n delete next.allow_unset;\n }\n if (input.requiredTypes.length > 0) {\n next.required_types = [...input.requiredTypes];\n } else {\n delete next.required_types;\n }\n\n fields.push(next);\n fields.sort((left, right) => normalizeFieldKey(left.key).localeCompare(normalizeFieldKey(right.key)));\n\n return {\n file: { fields },\n definition: next,\n replaced,\n };\n}\n\n/**\n * Removes a custom field definition from the parsed file by key (normalized).\n * Throws a plain Error when `key` is empty. Returns `removed: false` when no\n * matching definition exists so the CLI layer can treat the call as an\n * idempotent no-op.\n */\nexport function removeField(file: FieldsFile, key: string | undefined): RemoveFieldResult {\n const normalizedKey = normalizeFieldKey(key);\n if (normalizedKey.length === 0) {\n throw new Error(\"Field key must not be empty.\");\n }\n // Remove ALL matches (a hand-authored file may carry duplicate entries for the\n // same normalized key) so no stale duplicate survives the removal.\n const removed: RuntimeFieldDefinition[] = [];\n const fields = file.fields.filter((definition) => {\n if (normalizeFieldKey(definition.key) === normalizedKey) {\n removed.push(definition);\n return false;\n }\n return true;\n });\n if (removed.length === 0) {\n return { file: { fields }, removed: false };\n }\n return { file: { fields }, removed: true, definition: removed[0] };\n}\n\nfunction applyOptionalString(definition: RuntimeFieldDefinition, key: string, value: string | undefined): void {\n const record = definition as unknown as Record<string, unknown>;\n if (value !== undefined && value.length > 0) {\n record[key] = value;\n } else {\n delete record[key];\n }\n}\n\nfunction applyBooleanFlag(definition: RuntimeFieldDefinition, key: string, value: boolean): void {\n const record = definition as unknown as Record<string, unknown>;\n if (value) {\n record[key] = true;\n } else {\n delete record[key];\n }\n}\n","/**\n * @module core/schema/type-presets\n *\n * Resolves configurable schema, fields, statuses, and workflows for Type Presets.\n */\nimport { normalizeAddTypeInput, type NormalizedAddTypeInput, type RawAddTypeInput } from \"./item-types-file.js\";\n\n/**\n * Shared domain item-type presets. These power both `pm init --type-preset`\n * (registered during initialization) and the standalone `pm schema apply-preset`\n * subcommand (adopting a preset into an already-initialized project). Keeping the\n * raw definitions and the preset-name normalizer in one place guarantees init and\n * schema register byte-identical types.\n */\n\nexport const TYPE_PRESET_NAMES = [\"agile\", \"ops\", \"research\"] as const;\n/**\n * Restricts type preset name values accepted by command, SDK, and storage contracts.\n */\nexport type TypePresetName = (typeof TYPE_PRESET_NAMES)[number];\n\n/**\n * Raw (pre-normalization) preset definitions keyed by preset name. Each entry is\n * fed through {@link normalizeAddTypeInput} before being upserted so the same\n * validation/normalization the `pm schema add-type` CLI applies governs preset\n * registration too.\n */\nexport const TYPE_PRESET_DEFINITIONS: Record<TypePresetName, RawAddTypeInput[]> = {\n agile: [\n {\n name: \"Story\",\n description: \"User-facing outcome or capability slice expressed from a stakeholder perspective.\",\n defaultStatus: \"open\",\n folder: \"stories\",\n aliases: [\"user-story\"],\n },\n {\n name: \"Spike\",\n description: \"Time-boxed investigation used to reduce uncertainty before implementation.\",\n defaultStatus: \"open\",\n folder: \"spikes\",\n aliases: [\"research-spike\"],\n },\n ],\n ops: [\n {\n name: \"Incident\",\n description: \"Operational disruption, degradation, or support escalation with recovery tracking.\",\n defaultStatus: \"open\",\n folder: \"incidents\",\n aliases: [\"outage\"],\n },\n {\n name: \"Runbook\",\n description: \"Repeatable operational procedure, diagnostic path, or response playbook.\",\n defaultStatus: \"open\",\n folder: \"runbooks\",\n aliases: [\"playbook\"],\n },\n ],\n research: [\n {\n name: \"Experiment\",\n description: \"Validated-learning activity with hypothesis, method, and outcome tracking.\",\n defaultStatus: \"open\",\n folder: \"experiments\",\n aliases: [\"study\"],\n },\n {\n name: \"Hypothesis\",\n description: \"Testable claim or assumption that should be supported, rejected, or refined.\",\n defaultStatus: \"open\",\n folder: \"hypotheses\",\n aliases: [\"assumption\"],\n },\n ],\n};\n\n/**\n * Validates and normalizes a raw preset-name CLI value. Returns `undefined` when\n * the value is omitted (no preset requested). Throws a plain Error with a stable\n * message for an empty or unknown preset; CLI layers map it to a USAGE exit code.\n * Accepts hyphen/underscore-insensitive casing for ergonomics.\n */\nexport function normalizeTypePresetName(rawValue: string | undefined): TypePresetName | undefined {\n if (rawValue === undefined) {\n return undefined;\n }\n const normalized = rawValue.trim().toLowerCase().replaceAll(\"-\", \"_\");\n if (normalized.length === 0) {\n throw new Error(\"Type preset name must not be empty.\");\n }\n if (normalized === \"agile\" || normalized === \"ops\" || normalized === \"research\") {\n return normalized;\n }\n throw new Error(`Invalid type preset \"${rawValue}\". Allowed: ${TYPE_PRESET_NAMES.join(\", \")}.`);\n}\n\n/**\n * Returns the normalized add-type inputs for a preset, in the order they should\n * be upserted. Each raw definition is run through normalizeAddTypeInput so callers\n * get the same validated shape as an individual `add-type` invocation.\n */\nexport function resolveTypePresetDefinitions(preset: TypePresetName): NormalizedAddTypeInput[] {\n return TYPE_PRESET_DEFINITIONS[preset].map((rawDefinition) => normalizeAddTypeInput(rawDefinition));\n}\n"],"names":["definition"],"mappings":";;;;;;;;;;;;;;AAwBA,IAAM,0BAA0B,IAAI,IAAY,0BAA0B;AAU1E,IAAM,gCAAgC;AACtC,IAAM,kBAAkB,oBAAI,IAAG;AASxB,IAAM,qBAA0C,IAAI,IACzD,mCAAmC,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,WAAW,GAAG;AAC3B,UAAM,IAAI,MAAM,qCAAqC;EACvD;AACA,MAAI,eAAe,WAAW,eAAe,SAAS,eAAe,YAAY;AAC/E,WAAO;EACT;AACA,QAAM,IAAI,MAAM,wBAAwB,QAAQ,eAAe,kBAAkB,KAAK,IAAI,CAAC,GAAG;AAChG;AAOM,SAAU,6BAA6B,QAAsB;AACjE,SAAO,wBAAwB,MAAM,EAAE,IAAI,CAAC,kBAAkB,sBAAsB,aAAa,CAAC;AACpG","debugId":"15c384ad-9069-5ef0-bf3d-94b32fd19a03"}
@@ -1,23 +1,18 @@
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]="9f5bd1d8-0152-5389-9939-5bd3b047e020")}catch(e){}}();
3
- import {
4
- listAllFrontMatterLight
5
- } from "./chunk-57C2RLW5.js";
6
- import "./chunk-HK72NWAD.js";
7
- import "./chunk-FJRKQREY.js";
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]="7ca68c4d-ec0c-5aed-a5ff-2dd272fb85e7")}catch(e){}}();
8
3
  import {
9
4
  PmCliError,
10
5
  getActiveExtensionRegistrations,
6
+ listAllFrontMatterLight,
11
7
  readSettings
12
- } from "./chunk-US3T3W5J.js";
13
- import "./chunk-NNHHXJB2.js";
8
+ } from "./chunk-GH73UOSJ.js";
14
9
  import {
15
10
  EXIT_CODE,
16
11
  getSettingsPath,
17
12
  pathExists,
18
13
  resolveItemTypeRegistry,
19
14
  resolvePmRoot
20
- } from "./chunk-YD5FML7K.js";
15
+ } from "./chunk-UO7XAZK6.js";
21
16
 
22
17
  // dist/cli/commands/deps.js
23
18
  var DEPS_FORMAT_VALUES = ["tree", "graph"];
@@ -214,11 +209,12 @@ async function runDeps(id, options, global) {
214
209
  graph
215
210
  };
216
211
  }
212
+
217
213
  export {
218
- DEPS_COLLAPSE_VALUES,
219
214
  DEPS_FORMAT_VALUES,
215
+ DEPS_COLLAPSE_VALUES,
220
216
  runDeps
221
217
  };
222
- //# sourceMappingURL=deps-55FTG6Z5.js.map
218
+ //# sourceMappingURL=chunk-XS2TMNXR.js.map
223
219
 
224
- //# debugId=9f5bd1d8-0152-5389-9939-5bd3b047e020
220
+ //# debugId=7ca68c4d-ec0c-5aed-a5ff-2dd272fb85e7