@unbrained/pm-cli 2026.7.3 → 2026.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (663) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CONTRIBUTING.md +36 -7
  3. package/README.md +1 -9
  4. package/dist/cli/commands/calendar.d.ts +3 -2
  5. package/dist/cli/commands/calendar.js +5 -5
  6. package/dist/cli/commands/calendar.js.map +1 -1
  7. package/dist/cli/commands/claim.js +17 -3
  8. package/dist/cli/commands/claim.js.map +1 -1
  9. package/dist/cli/commands/close.js +34 -16
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +231 -345
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/copy.js +3 -3
  14. package/dist/cli/commands/copy.js.map +1 -1
  15. package/dist/cli/commands/create.d.ts +9 -59
  16. package/dist/cli/commands/create.js +162 -132
  17. package/dist/cli/commands/create.js.map +1 -1
  18. package/dist/cli/commands/extension/bundled-catalog.d.ts +6 -0
  19. package/dist/cli/commands/extension/bundled-catalog.js +15 -2
  20. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  21. package/dist/cli/commands/extension/describe.d.ts +6 -3
  22. package/dist/cli/commands/extension/describe.js +21 -9
  23. package/dist/cli/commands/extension/describe.js.map +1 -1
  24. package/dist/cli/commands/extension/doctor.d.ts +0 -4
  25. package/dist/cli/commands/extension/doctor.js +3 -3
  26. package/dist/cli/commands/extension/doctor.js.map +1 -1
  27. package/dist/cli/commands/extension/scaffold.js +59 -133
  28. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  29. package/dist/cli/commands/extension/shared.d.ts +2 -7
  30. package/dist/cli/commands/extension/shared.js +4 -10
  31. package/dist/cli/commands/extension/shared.js.map +1 -1
  32. package/dist/cli/commands/extension.js +33 -8
  33. package/dist/cli/commands/extension.js.map +1 -1
  34. package/dist/cli/commands/files.js +3 -3
  35. package/dist/cli/commands/files.js.map +1 -1
  36. package/dist/cli/commands/history-compact.js +9 -18
  37. package/dist/cli/commands/history-compact.js.map +1 -1
  38. package/dist/cli/commands/history-repair.js +9 -19
  39. package/dist/cli/commands/history-repair.js.map +1 -1
  40. package/dist/cli/commands/init-agent-guidance.js +133 -97
  41. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  42. package/dist/cli/commands/init.js +3 -3
  43. package/dist/cli/commands/init.js.map +1 -1
  44. package/dist/cli/commands/item-filter-options.d.ts +2 -0
  45. package/dist/cli/commands/item-filter-options.js +2 -2
  46. package/dist/cli/commands/item-filter-options.js.map +1 -1
  47. package/dist/cli/commands/mutation-command-options.d.ts +78 -0
  48. package/dist/cli/commands/mutation-command-options.js +10 -0
  49. package/dist/cli/commands/mutation-command-options.js.map +1 -0
  50. package/dist/cli/commands/profile.js +3 -3
  51. package/dist/cli/commands/profile.js.map +1 -1
  52. package/dist/cli/commands/reindex.js +4 -4
  53. package/dist/cli/commands/reindex.js.map +1 -1
  54. package/dist/cli/commands/restore.js +3 -3
  55. package/dist/cli/commands/restore.js.map +1 -1
  56. package/dist/cli/commands/schema.js +10 -10
  57. package/dist/cli/commands/schema.js.map +1 -1
  58. package/dist/cli/commands/shared-unset-fields.d.ts +19 -0
  59. package/dist/cli/commands/shared-unset-fields.js +31 -2
  60. package/dist/cli/commands/shared-unset-fields.js.map +1 -1
  61. package/dist/cli/commands/update.d.ts +2 -59
  62. package/dist/cli/commands/update.js +29 -98
  63. package/dist/cli/commands/update.js.map +1 -1
  64. package/dist/cli/commands/validate.js +4 -4
  65. package/dist/cli/commands/validate.js.map +1 -1
  66. package/dist/cli/error-guidance.js +107 -7
  67. package/dist/cli/error-guidance.js.map +1 -1
  68. package/dist/cli/main.d.ts +6 -2
  69. package/dist/cli/main.js +33 -12
  70. package/dist/cli/main.js.map +1 -1
  71. package/dist/cli/register-list-query.js +4 -2
  72. package/dist/cli/register-list-query.js.map +1 -1
  73. package/dist/cli/registration-helpers.js +12 -6
  74. package/dist/cli/registration-helpers.js.map +1 -1
  75. package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +18 -0
  76. package/dist/cli-bundle/chunks/{activity-5YWLSPGE.js → activity-YKAKZTZ4.js} +11 -9
  77. package/dist/cli-bundle/chunks/{aggregate-2V2M3JZU.js → aggregate-EQX2RGB7.js} +16 -13
  78. package/dist/cli-bundle/chunks/{aggregate-2V2M3JZU.js.map → aggregate-EQX2RGB7.js.map} +1 -1
  79. package/dist/cli-bundle/chunks/{aggregate-EK7DXML7.js → aggregate-PEGZGJXD.js} +18 -15
  80. package/dist/cli-bundle/chunks/{aggregate-EK7DXML7.js.map → aggregate-PEGZGJXD.js.map} +1 -1
  81. package/dist/cli-bundle/chunks/{append-EZESUVJT.js → append-CZGUZ45Q.js} +11 -8
  82. package/dist/cli-bundle/chunks/{append-EZESUVJT.js.map → append-CZGUZ45Q.js.map} +1 -1
  83. package/dist/cli-bundle/chunks/{append-JFG4WQMG.js → append-NSQBCXZJ.js} +13 -10
  84. package/dist/cli-bundle/chunks/{append-JFG4WQMG.js.map → append-NSQBCXZJ.js.map} +1 -1
  85. package/dist/cli-bundle/chunks/chunk-3JZNEQBA.js +1413 -0
  86. package/dist/cli-bundle/chunks/chunk-3JZNEQBA.js.map +1 -0
  87. package/dist/cli-bundle/chunks/{chunk-NOIEVOK5.js → chunk-3PL6LEKP.js} +16 -14
  88. package/dist/cli-bundle/chunks/{chunk-NOIEVOK5.js.map → chunk-3PL6LEKP.js.map} +1 -1
  89. package/dist/cli-bundle/chunks/{chunk-6KRFL33E.js → chunk-3U3VEWK6.js} +277 -119
  90. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +7 -0
  91. package/dist/cli-bundle/chunks/{chunk-Z5F6XZXE.js → chunk-3Y4OESPP.js} +14 -12
  92. package/dist/cli-bundle/chunks/{chunk-Z5F6XZXE.js.map → chunk-3Y4OESPP.js.map} +1 -1
  93. package/dist/cli-bundle/chunks/{chunk-HB4FAT3O.js → chunk-4LRVSBO6.js} +21 -15
  94. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js.map +7 -0
  95. package/dist/cli-bundle/chunks/{chunk-T3P7PMZP.js → chunk-4OFLJHX6.js} +7 -5
  96. package/dist/cli-bundle/chunks/{chunk-T3P7PMZP.js.map → chunk-4OFLJHX6.js.map} +1 -1
  97. package/dist/cli-bundle/chunks/{chunk-JPATY4SE.js → chunk-4QQ6PM7M.js} +45 -557
  98. package/dist/cli-bundle/chunks/chunk-4QQ6PM7M.js.map +7 -0
  99. package/dist/cli-bundle/chunks/{chunk-6CDCWKSX.js → chunk-53BTLLAF.js} +68 -331
  100. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +1 -0
  101. package/dist/cli-bundle/chunks/{chunk-4WB6S4YX.js → chunk-57C2RLW5.js} +277 -112
  102. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +1 -0
  103. package/dist/cli-bundle/chunks/{chunk-PULUSQAV.js → chunk-5B3X4Y22.js} +52 -63
  104. package/dist/cli-bundle/chunks/{chunk-PULUSQAV.js.map → chunk-5B3X4Y22.js.map} +3 -3
  105. package/dist/cli-bundle/chunks/{chunk-7LYO6S5A.js → chunk-5J2XPTAD.js} +10 -8
  106. package/dist/cli-bundle/chunks/{chunk-7LYO6S5A.js.map → chunk-5J2XPTAD.js.map} +1 -1
  107. package/dist/cli-bundle/chunks/{chunk-QCDTQCMW.js → chunk-5JE6SMYS.js} +2 -2
  108. package/dist/cli-bundle/chunks/{chunk-MHRS5FUX.js → chunk-5JZ7APJU.js} +153 -108
  109. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-KHVGM5CS.js → chunk-5VVUKE3U.js} +544 -2368
  111. package/dist/cli-bundle/chunks/chunk-5VVUKE3U.js.map +7 -0
  112. package/dist/cli-bundle/chunks/{chunk-RJH5VQHW.js → chunk-75U6M5ZD.js} +22 -16
  113. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js.map +1 -0
  114. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +23 -0
  115. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-ZFTKYWIF.js → chunk-7EQNAZX2.js} +14 -12
  117. package/dist/cli-bundle/chunks/{chunk-ZFTKYWIF.js.map → chunk-7EQNAZX2.js.map} +1 -1
  118. package/dist/cli-bundle/chunks/{chunk-Z4DGFQDH.js → chunk-7LQKVMPA.js} +14 -4
  119. package/dist/cli-bundle/chunks/chunk-7LQKVMPA.js.map +1 -0
  120. package/dist/cli-bundle/chunks/{chunk-ERG65A2L.js → chunk-7MDXZAZS.js} +29 -7
  121. package/dist/cli-bundle/chunks/chunk-7MDXZAZS.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-OGLGI22K.js → chunk-7QH7DHUB.js} +74 -8
  123. package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +1 -0
  124. package/dist/cli-bundle/chunks/{chunk-JBZ2NTKX.js → chunk-7WYXBPYQ.js} +7 -5
  125. package/dist/cli-bundle/chunks/{chunk-JBZ2NTKX.js.map → chunk-7WYXBPYQ.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/chunk-AAEQMOC6.js +150 -0
  127. package/dist/cli-bundle/chunks/chunk-AAEQMOC6.js.map +1 -0
  128. package/dist/cli-bundle/chunks/{chunk-K5DT2YKM.js → chunk-ABRA3BHY.js} +18 -16
  129. package/dist/cli-bundle/chunks/{chunk-K5DT2YKM.js.map → chunk-ABRA3BHY.js.map} +2 -2
  130. package/dist/cli-bundle/chunks/chunk-B5KXLBSJ.js +47 -0
  131. package/dist/cli-bundle/chunks/chunk-B5KXLBSJ.js.map +7 -0
  132. package/dist/cli-bundle/chunks/{chunk-7CLLC75T.js → chunk-BFVHCAOO.js} +9 -7
  133. package/dist/cli-bundle/chunks/{chunk-7CLLC75T.js.map → chunk-BFVHCAOO.js.map} +1 -1
  134. package/dist/cli-bundle/chunks/{chunk-MDHWWBNZ.js → chunk-BVEUCSH2.js} +6 -4
  135. package/dist/cli-bundle/chunks/{chunk-MDHWWBNZ.js.map → chunk-BVEUCSH2.js.map} +1 -1
  136. package/dist/cli-bundle/chunks/chunk-C3PMDWGX.js +160 -0
  137. package/dist/cli-bundle/chunks/chunk-C3PMDWGX.js.map +7 -0
  138. package/dist/cli-bundle/chunks/{chunk-T4XBKJ3F.js → chunk-D3UCE7RW.js} +7 -5
  139. package/dist/cli-bundle/chunks/{chunk-T4XBKJ3F.js.map → chunk-D3UCE7RW.js.map} +1 -1
  140. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +275 -0
  141. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +7 -0
  142. package/dist/cli-bundle/chunks/chunk-DLQ4ZTCU.js +634 -0
  143. package/dist/cli-bundle/chunks/chunk-DLQ4ZTCU.js.map +7 -0
  144. package/dist/cli-bundle/chunks/{chunk-AJHYQCBJ.js → chunk-DRBV5UC2.js} +8 -23
  145. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +7 -0
  146. package/dist/cli-bundle/chunks/{chunk-NZ7QIUP5.js → chunk-E2FUG6GD.js} +67 -351
  147. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js.map +7 -0
  148. package/dist/cli-bundle/chunks/{chunk-4PFVUUYV.js → chunk-EEY54JMF.js} +5 -3
  149. package/dist/cli-bundle/chunks/{chunk-4PFVUUYV.js.map → chunk-EEY54JMF.js.map} +1 -1
  150. package/dist/cli-bundle/chunks/{chunk-3W2HJKJX.js → chunk-EZFKWSC7.js} +94 -16
  151. package/dist/cli-bundle/chunks/{chunk-3W2HJKJX.js.map → chunk-EZFKWSC7.js.map} +4 -4
  152. package/dist/cli-bundle/chunks/{chunk-F6WNBITZ.js → chunk-FDBARR33.js} +40 -19
  153. package/dist/cli-bundle/chunks/{chunk-F6WNBITZ.js.map → chunk-FDBARR33.js.map} +3 -3
  154. package/dist/cli-bundle/chunks/{chunk-WRYERRZX.js → chunk-FGQKEDE4.js} +36 -12
  155. package/dist/cli-bundle/chunks/chunk-FGQKEDE4.js.map +7 -0
  156. package/dist/cli-bundle/chunks/{chunk-CXR3CMBQ.js → chunk-FJRKQREY.js} +10 -18
  157. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +1 -0
  158. package/dist/cli-bundle/chunks/{chunk-QNNQAAZ5.js → chunk-FUM6UMY4.js} +10 -11
  159. package/dist/cli-bundle/chunks/{chunk-QNNQAAZ5.js.map → chunk-FUM6UMY4.js.map} +1 -1
  160. package/dist/cli-bundle/chunks/{chunk-TQ6AX5SQ.js → chunk-GIWXVMZ3.js} +140 -334
  161. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +7 -0
  162. package/dist/cli-bundle/chunks/{chunk-FZJM2TXF.js → chunk-HBYZDSK5.js} +19 -17
  163. package/dist/cli-bundle/chunks/{chunk-FZJM2TXF.js.map → chunk-HBYZDSK5.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{chunk-5IZUBZBR.js → chunk-HJE4JTKQ.js} +6 -4
  165. package/dist/cli-bundle/chunks/{chunk-5IZUBZBR.js.map → chunk-HJE4JTKQ.js.map} +1 -1
  166. package/dist/cli-bundle/chunks/{chunk-YSDFIY7N.js → chunk-HK72NWAD.js} +89 -18
  167. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +1 -0
  168. package/dist/cli-bundle/chunks/{chunk-LBE5QFMZ.js → chunk-IJ6CO3JV.js} +41 -20
  169. package/dist/cli-bundle/chunks/{chunk-LBE5QFMZ.js.map → chunk-IJ6CO3JV.js.map} +1 -1
  170. package/dist/cli-bundle/chunks/{chunk-YF746GTH.js → chunk-JFCVQXZX.js} +139 -326
  171. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +1 -0
  172. package/dist/cli-bundle/chunks/{chunk-A3OQ7TFW.js → chunk-JLA7EVYV.js} +12 -10
  173. package/dist/cli-bundle/chunks/{chunk-A3OQ7TFW.js.map → chunk-JLA7EVYV.js.map} +1 -1
  174. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +76 -0
  175. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +1 -0
  176. package/dist/cli-bundle/chunks/{chunk-32IUNTG4.js → chunk-K3AGVXSF.js} +37 -13
  177. package/dist/cli-bundle/chunks/chunk-K3AGVXSF.js.map +1 -0
  178. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +79 -0
  179. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +7 -0
  180. package/dist/cli-bundle/chunks/chunk-KGHH652T.js +44 -0
  181. package/dist/cli-bundle/chunks/chunk-KGHH652T.js.map +1 -0
  182. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +915 -0
  183. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +1 -0
  184. package/dist/cli-bundle/chunks/{chunk-BI4R7HI2.js → chunk-KLG4ZULO.js} +12 -10
  185. package/dist/cli-bundle/chunks/{chunk-BI4R7HI2.js.map → chunk-KLG4ZULO.js.map} +1 -1
  186. package/dist/cli-bundle/chunks/{chunk-XRYSCRZR.js → chunk-LEKT4K7I.js} +74 -8
  187. package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +7 -0
  188. package/dist/cli-bundle/chunks/{contracts-X74F2GSM.js → chunk-MNZ7DRNC.js} +13 -10
  189. package/dist/cli-bundle/chunks/{contracts-X74F2GSM.js.map → chunk-MNZ7DRNC.js.map} +1 -1
  190. package/dist/cli-bundle/chunks/{chunk-4EXFFP7T.js → chunk-MTTXDAK4.js} +206 -147
  191. package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +7 -0
  192. package/dist/cli-bundle/chunks/{chunk-KEZOIPCR.js → chunk-MZ7VNEVY.js} +8 -6
  193. package/dist/cli-bundle/chunks/{chunk-KEZOIPCR.js.map → chunk-MZ7VNEVY.js.map} +1 -1
  194. package/dist/cli-bundle/chunks/{chunk-5JIWFWOZ.js → chunk-N6DNM2FA.js} +2 -2
  195. package/dist/cli-bundle/chunks/{test-runs-QIR5MJPL.js → chunk-N7X4WP6L.js} +11 -8
  196. package/dist/cli-bundle/chunks/{test-runs-QIR5MJPL.js.map → chunk-N7X4WP6L.js.map} +1 -1
  197. package/dist/cli-bundle/chunks/{chunk-U3S2B7TA.js → chunk-NBFCNJ7Q.js} +206 -147
  198. package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +1 -0
  199. package/dist/cli-bundle/chunks/{chunk-GVJE5T7Q.js → chunk-NER3KUUS.js} +2 -2
  200. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +20 -0
  201. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +1 -0
  202. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +918 -0
  203. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +7 -0
  204. package/dist/cli-bundle/chunks/{chunk-YPWUSH72.js → chunk-OESSOFJ4.js} +14 -12
  205. package/dist/cli-bundle/chunks/{chunk-YPWUSH72.js.map → chunk-OESSOFJ4.js.map} +1 -1
  206. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +238 -0
  207. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +1 -0
  208. package/dist/cli-bundle/chunks/{chunk-FUFFPIYA.js → chunk-OWTIRHX4.js} +28 -6
  209. package/dist/cli-bundle/chunks/chunk-OWTIRHX4.js.map +7 -0
  210. package/dist/cli-bundle/chunks/{chunk-Z7RPDF2Y.js → chunk-P3VRG72Q.js} +10 -8
  211. package/dist/cli-bundle/chunks/{chunk-Z7RPDF2Y.js.map → chunk-P3VRG72Q.js.map} +1 -1
  212. package/dist/cli-bundle/chunks/chunk-P5TFTLWW.js +1423 -0
  213. package/dist/cli-bundle/chunks/chunk-P5TFTLWW.js.map +7 -0
  214. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +1977 -0
  215. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +7 -0
  216. package/dist/cli-bundle/chunks/{chunk-MEZZZBYX.js → chunk-PDXT6Q55.js} +2 -2
  217. package/dist/cli-bundle/chunks/{chunk-EJ2OCBHF.js → chunk-PJ3A56YF.js} +46 -537
  218. package/dist/cli-bundle/chunks/chunk-PJ3A56YF.js.map +1 -0
  219. package/dist/cli-bundle/chunks/{test-runs-MG5VIGSK.js → chunk-PPAJG4GB.js} +13 -10
  220. package/dist/cli-bundle/chunks/{test-runs-MG5VIGSK.js.map → chunk-PPAJG4GB.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/{chunk-572FKBRL.js → chunk-PPE4YUQM.js} +1725 -1663
  222. package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +1 -0
  223. package/dist/cli-bundle/chunks/{chunk-ER4ME5U2.js → chunk-QHZO65XW.js} +8 -6
  224. package/dist/cli-bundle/chunks/{chunk-ER4ME5U2.js.map → chunk-QHZO65XW.js.map} +1 -1
  225. package/dist/cli-bundle/chunks/{chunk-T6AXEBOP.js → chunk-R3ZBLGTC.js} +9 -10
  226. package/dist/cli-bundle/chunks/{chunk-T6AXEBOP.js.map → chunk-R3ZBLGTC.js.map} +2 -2
  227. package/dist/cli-bundle/chunks/chunk-RCT3YJOK.js +624 -0
  228. package/dist/cli-bundle/chunks/chunk-RCT3YJOK.js.map +1 -0
  229. package/dist/cli-bundle/chunks/{chunk-YVKZ3ANP.js → chunk-RX3HQSYG.js} +2 -2
  230. package/dist/cli-bundle/chunks/{chunk-LOWVNZBZ.js → chunk-S4APD35C.js} +4 -4
  231. package/dist/cli-bundle/chunks/{chunk-FH2H3CBD.js → chunk-S5AYOUT5.js} +8 -6
  232. package/dist/cli-bundle/chunks/{chunk-FH2H3CBD.js.map → chunk-S5AYOUT5.js.map} +1 -1
  233. package/dist/cli-bundle/chunks/{chunk-SYE6WMV6.js → chunk-STPSZ2XY.js} +19 -744
  234. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +1 -0
  235. package/dist/cli-bundle/chunks/{chunk-6NYJGMTY.js → chunk-T35XLYZF.js} +2 -2
  236. package/dist/cli-bundle/chunks/{chunk-P5L7Z2O6.js → chunk-T3ABIMGW.js} +5 -3
  237. package/dist/cli-bundle/chunks/{chunk-P5L7Z2O6.js.map → chunk-T3ABIMGW.js.map} +1 -1
  238. package/dist/cli-bundle/chunks/{chunk-SU2E4AWU.js → chunk-T3F4DF23.js} +16 -14
  239. package/dist/cli-bundle/chunks/{chunk-SU2E4AWU.js.map → chunk-T3F4DF23.js.map} +1 -1
  240. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +272 -0
  241. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +1 -0
  242. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js +5354 -0
  243. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{chunk-ECU6MMTQ.js → chunk-TSPKZRRW.js} +50 -116
  245. package/dist/cli-bundle/chunks/chunk-TSPKZRRW.js.map +1 -0
  246. package/dist/cli-bundle/chunks/{chunk-BE2SR6QL.js → chunk-TT42JUMF.js} +4 -4
  247. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +165 -0
  248. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +1 -0
  249. package/dist/cli-bundle/chunks/{chunk-RAHINBVP.js → chunk-UI5BJ6DO.js} +1339 -1277
  250. package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +7 -0
  251. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +1932 -0
  252. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +1 -0
  253. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +175 -0
  254. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +7 -0
  255. package/dist/cli-bundle/chunks/{chunk-B4O5S7I3.js → chunk-VUHVWI4C.js} +13 -3
  256. package/dist/cli-bundle/chunks/chunk-VUHVWI4C.js.map +7 -0
  257. package/dist/cli-bundle/chunks/{contracts-L6ODXNUM.js → chunk-VZIYHZDX.js} +11 -8
  258. package/dist/cli-bundle/chunks/{contracts-L6ODXNUM.js.map → chunk-VZIYHZDX.js.map} +1 -1
  259. package/dist/cli-bundle/chunks/{chunk-U5TR4N7J.js → chunk-WISPVC2E.js} +9 -7
  260. package/dist/cli-bundle/chunks/{chunk-U5TR4N7J.js.map → chunk-WISPVC2E.js.map} +1 -1
  261. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js +5434 -0
  262. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +7 -0
  263. package/dist/cli-bundle/chunks/{chunk-HQAF23Q2.js → chunk-XQCG2JGW.js} +17 -749
  264. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +7 -0
  265. package/dist/cli-bundle/chunks/chunk-Y76TWC45.js +550 -0
  266. package/dist/cli-bundle/chunks/chunk-Y76TWC45.js.map +7 -0
  267. package/dist/cli-bundle/chunks/{chunk-L4SLHV6G.js → chunk-YD5FML7K.js} +464 -2239
  268. package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +1 -0
  269. package/dist/cli-bundle/chunks/{chunk-YSGTMDWC.js → chunk-YFIE7YK6.js} +7 -5
  270. package/dist/cli-bundle/chunks/{chunk-YSGTMDWC.js.map → chunk-YFIE7YK6.js.map} +1 -1
  271. package/dist/cli-bundle/chunks/{chunk-WYOIIFSE.js → chunk-YMABYTNG.js} +49 -115
  272. package/dist/cli-bundle/chunks/chunk-YMABYTNG.js.map +7 -0
  273. package/dist/cli-bundle/chunks/{chunk-SU3TB4NS.js → chunk-YOF5VPKM.js} +2 -2
  274. package/dist/cli-bundle/chunks/{chunk-WJA3PXW7.js → chunk-YPPVU5GX.js} +11 -9
  275. package/dist/cli-bundle/chunks/{chunk-WJA3PXW7.js.map → chunk-YPPVU5GX.js.map} +1 -1
  276. package/dist/cli-bundle/chunks/{chunk-GUYNUXQT.js → chunk-YQMMMONE.js} +6 -4
  277. package/dist/cli-bundle/chunks/{chunk-GUYNUXQT.js.map → chunk-YQMMMONE.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{chunk-AIKU3IIL.js → chunk-YSAH5FY5.js} +16 -14
  279. package/dist/cli-bundle/chunks/{chunk-AIKU3IIL.js.map → chunk-YSAH5FY5.js.map} +1 -1
  280. package/dist/cli-bundle/chunks/{chunk-KS6ATO47.js → chunk-YZIR4R3U.js} +153 -108
  281. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js.map +7 -0
  282. package/dist/cli-bundle/chunks/{chunk-LCWQP6NM.js → chunk-Z2CRRZYF.js} +14 -12
  283. package/dist/cli-bundle/chunks/{chunk-LCWQP6NM.js.map → chunk-Z2CRRZYF.js.map} +1 -1
  284. package/dist/cli-bundle/chunks/chunk-ZAHXPXVY.js +533 -0
  285. package/dist/cli-bundle/chunks/chunk-ZAHXPXVY.js.map +1 -0
  286. package/dist/cli-bundle/chunks/{chunk-UMNQZS4H.js → chunk-ZCJAA3JK.js} +8 -6
  287. package/dist/cli-bundle/chunks/{chunk-UMNQZS4H.js.map → chunk-ZCJAA3JK.js.map} +1 -1
  288. package/dist/cli-bundle/chunks/{chunk-EQURFOMH.js → chunk-ZD34OFFQ.js} +5 -3
  289. package/dist/cli-bundle/chunks/{chunk-EQURFOMH.js.map → chunk-ZD34OFFQ.js.map} +1 -1
  290. package/dist/cli-bundle/chunks/{chunk-67LARBDL.js → chunk-ZJB3UV5U.js} +54 -58
  291. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +1 -0
  292. package/dist/cli-bundle/chunks/{chunk-5E7N4T2Z.js → chunk-ZMD35NYG.js} +2 -2
  293. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +241 -0
  294. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +7 -0
  295. package/dist/cli-bundle/chunks/{claim-5GU7OE67.js → claim-4DROPSIS.js} +30 -13
  296. package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +1 -0
  297. package/dist/cli-bundle/chunks/{claim-2BGBGSVI.js → claim-VX54TV5U.js} +29 -12
  298. package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +7 -0
  299. package/dist/cli-bundle/chunks/{close-AFVKPR57.js → close-3YRR3XY6.js} +9 -7
  300. package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +16 -0
  301. package/dist/cli-bundle/chunks/{close-many-JKUJMHLG.js → close-many-AP4MWU36.js} +21 -18
  302. package/dist/cli-bundle/chunks/{close-many-JKUJMHLG.js.map → close-many-AP4MWU36.js.map} +1 -1
  303. package/dist/cli-bundle/chunks/{close-many-7KLOSYLP.js → close-many-OMZIGZB4.js} +19 -16
  304. package/dist/cli-bundle/chunks/{close-many-7KLOSYLP.js.map → close-many-OMZIGZB4.js.map} +1 -1
  305. package/dist/cli-bundle/chunks/{comments-DNWHEBOS.js → comments-MIW5MZOX.js} +12 -9
  306. package/dist/cli-bundle/chunks/{comments-DNWHEBOS.js.map → comments-MIW5MZOX.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/{comments-RW23R3VE.js → comments-SAG5LSKL.js} +14 -11
  308. package/dist/cli-bundle/chunks/{comments-RW23R3VE.js.map → comments-SAG5LSKL.js.map} +1 -1
  309. package/dist/cli-bundle/chunks/{config-AUM5WBYA.js → config-DJJKZB5R.js} +20 -17
  310. package/dist/cli-bundle/chunks/{config-AUM5WBYA.js.map → config-DJJKZB5R.js.map} +1 -1
  311. package/dist/cli-bundle/chunks/{config-OZWSA2NP.js → config-V57QD47V.js} +22 -19
  312. package/dist/cli-bundle/chunks/{config-OZWSA2NP.js.map → config-V57QD47V.js.map} +1 -1
  313. package/dist/cli-bundle/chunks/{context-PKCEHQY3.js → context-4OQGIPSO.js} +15 -12
  314. package/dist/cli-bundle/chunks/{context-OYXRGY7S.js → context-WLA6IAWE.js} +15 -12
  315. package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +12 -0
  316. package/dist/cli-bundle/chunks/contracts-OJEXMKVW.js +16 -0
  317. package/dist/cli-bundle/chunks/{copy-I4NCLBR4.js → copy-LEE6P6EM.js} +17 -14
  318. package/dist/cli-bundle/chunks/{copy-I4NCLBR4.js.map → copy-LEE6P6EM.js.map} +2 -2
  319. package/dist/cli-bundle/chunks/{copy-6XOR3HKN.js → copy-OTJOWFL6.js} +18 -15
  320. package/dist/cli-bundle/chunks/{copy-6XOR3HKN.js.map → copy-OTJOWFL6.js.map} +1 -1
  321. package/dist/cli-bundle/chunks/create-WKOZKPQR.js +30 -0
  322. package/dist/cli-bundle/chunks/{create-PM45M6PE.js → create-XWWQFQ6S.js} +14 -12
  323. package/dist/cli-bundle/chunks/{delete-7YXHYG67.js → delete-62JQTYT4.js} +10 -7
  324. package/dist/cli-bundle/chunks/{delete-7YXHYG67.js.map → delete-62JQTYT4.js.map} +1 -1
  325. package/dist/cli-bundle/chunks/{delete-LPISP43T.js → delete-HQKGRNRZ.js} +12 -9
  326. package/dist/cli-bundle/chunks/{delete-LPISP43T.js.map → delete-HQKGRNRZ.js.map} +1 -1
  327. package/dist/cli-bundle/chunks/{deps-WATKQDE3.js → deps-55FTG6Z5.js} +12 -9
  328. package/dist/cli-bundle/chunks/{deps-WATKQDE3.js.map → deps-55FTG6Z5.js.map} +1 -1
  329. package/dist/cli-bundle/chunks/{deps-N2T26FME.js → deps-L2FPIAD3.js} +10 -7
  330. package/dist/cli-bundle/chunks/{deps-N2T26FME.js.map → deps-L2FPIAD3.js.map} +1 -1
  331. package/dist/cli-bundle/chunks/{docs-6LQ3GLM7.js → docs-6CRCSVKK.js} +11 -9
  332. package/dist/cli-bundle/chunks/{docs-6LQ3GLM7.js.map → docs-6CRCSVKK.js.map} +1 -1
  333. package/dist/cli-bundle/chunks/{docs-Z3X6JZLT.js → docs-S6UTOTO5.js} +9 -7
  334. package/dist/cli-bundle/chunks/{docs-Z3X6JZLT.js.map → docs-S6UTOTO5.js.map} +1 -1
  335. package/dist/cli-bundle/chunks/{eval-6DCLG52D.js → eval-N6UHFWVO.js} +15 -11
  336. package/dist/cli-bundle/chunks/{eval-6DCLG52D.js.map → eval-N6UHFWVO.js.map} +1 -1
  337. package/dist/cli-bundle/chunks/{eval-Y3ZCUTHK.js → eval-PHOTWYHI.js} +17 -13
  338. package/dist/cli-bundle/chunks/{eval-Y3ZCUTHK.js.map → eval-PHOTWYHI.js.map} +1 -1
  339. package/dist/cli-bundle/chunks/{extension-BNINIMT7.js → extension-NBAH62ML.js} +17 -11
  340. package/dist/cli-bundle/chunks/{extension-QWE4YYK5.js → extension-ZF6ZZPOU.js} +17 -11
  341. package/dist/cli-bundle/chunks/{files-FUYPSOFJ.js → files-6P57MRKL.js} +14 -11
  342. package/dist/cli-bundle/chunks/files-6P57MRKL.js.map +7 -0
  343. package/dist/cli-bundle/chunks/{files-6SGKHS6O.js → files-JPU3FNJ7.js} +15 -12
  344. package/dist/cli-bundle/chunks/files-JPU3FNJ7.js.map +1 -0
  345. package/dist/cli-bundle/chunks/{focus-2Q3K76G2.js → focus-LFZ6IDBR.js} +15 -11
  346. package/dist/cli-bundle/chunks/{focus-2Q3K76G2.js.map → focus-LFZ6IDBR.js.map} +1 -1
  347. package/dist/cli-bundle/chunks/{focus-ATLBWXXD.js → focus-WNMYCVYA.js} +13 -9
  348. package/dist/cli-bundle/chunks/{focus-ATLBWXXD.js.map → focus-WNMYCVYA.js.map} +1 -1
  349. package/dist/cli-bundle/chunks/{gc-RUYEMNRF.js → gc-AETFKZ44.js} +10 -7
  350. package/dist/cli-bundle/chunks/{gc-RUYEMNRF.js.map → gc-AETFKZ44.js.map} +1 -1
  351. package/dist/cli-bundle/chunks/{gc-TDWSDR66.js → gc-RLBP4QVN.js} +12 -9
  352. package/dist/cli-bundle/chunks/{gc-TDWSDR66.js.map → gc-RLBP4QVN.js.map} +1 -1
  353. package/dist/cli-bundle/chunks/{get-LY6M2JIM.js → get-NH2MPBCI.js} +18 -15
  354. package/dist/cli-bundle/chunks/{get-LY6M2JIM.js.map → get-NH2MPBCI.js.map} +1 -1
  355. package/dist/cli-bundle/chunks/{get-2WGLX74N.js → get-P4ZQXCPZ.js} +16 -13
  356. package/dist/cli-bundle/chunks/{get-2WGLX74N.js.map → get-P4ZQXCPZ.js.map} +1 -1
  357. package/dist/cli-bundle/chunks/{health-4RKHYS3T.js → health-3GVPMQBL.js} +36 -29
  358. package/dist/cli-bundle/chunks/{health-4RKHYS3T.js.map → health-3GVPMQBL.js.map} +1 -1
  359. package/dist/cli-bundle/chunks/{health-TMFVNYRA.js → health-DNTM72GJ.js} +34 -27
  360. package/dist/cli-bundle/chunks/{health-TMFVNYRA.js.map → health-DNTM72GJ.js.map} +1 -1
  361. package/dist/cli-bundle/chunks/history-RYKLC72X.js +20 -0
  362. package/dist/cli-bundle/chunks/{history-SGRRS72R.js → history-SGPYRAFT.js} +10 -8
  363. package/dist/cli-bundle/chunks/{history-compact-LOED43R3.js → history-compact-3F6VELO7.js} +26 -30
  364. package/dist/cli-bundle/chunks/history-compact-3F6VELO7.js.map +7 -0
  365. package/dist/cli-bundle/chunks/{history-compact-V5DNAQHH.js → history-compact-656Y2TN4.js} +27 -31
  366. package/dist/cli-bundle/chunks/history-compact-656Y2TN4.js.map +1 -0
  367. package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +21 -0
  368. package/dist/cli-bundle/chunks/{history-redact-IRL7WJ3E.js → history-redact-54ICFKXM.js} +11 -9
  369. package/dist/cli-bundle/chunks/{history-repair-PGYQJMGD.js → history-repair-4N6SDVHK.js} +25 -30
  370. package/dist/cli-bundle/chunks/history-repair-4N6SDVHK.js.map +7 -0
  371. package/dist/cli-bundle/chunks/{history-repair-4WVBVHFR.js → history-repair-EVTO6LIH.js} +26 -31
  372. package/dist/cli-bundle/chunks/history-repair-EVTO6LIH.js.map +1 -0
  373. package/dist/cli-bundle/chunks/init-RPIPQUNV.js +32 -0
  374. package/dist/cli-bundle/chunks/init-SKQAESQS.js +28 -0
  375. package/dist/cli-bundle/chunks/{learnings-4FJY7WIW.js → learnings-2HTPZNGZ.js} +10 -8
  376. package/dist/cli-bundle/chunks/{learnings-4FJY7WIW.js.map → learnings-2HTPZNGZ.js.map} +1 -1
  377. package/dist/cli-bundle/chunks/{learnings-4BHWFFUV.js → learnings-YBIHY3D6.js} +12 -10
  378. package/dist/cli-bundle/chunks/{learnings-4BHWFFUV.js.map → learnings-YBIHY3D6.js.map} +1 -1
  379. package/dist/cli-bundle/chunks/{list-472TIOVK.js → list-64LHZ3HM.js} +10 -8
  380. package/dist/cli-bundle/chunks/{list-D7BF5CL2.js → list-7LXBTEKI.js} +10 -8
  381. package/dist/cli-bundle/chunks/{next-SFQZVX2B.js → next-7ODPAQ4U.js} +22 -18
  382. package/dist/cli-bundle/chunks/{next-SFQZVX2B.js.map → next-7ODPAQ4U.js.map} +1 -1
  383. package/dist/cli-bundle/chunks/{next-D5STGWI2.js → next-ODJUM4ZM.js} +24 -20
  384. package/dist/cli-bundle/chunks/{next-D5STGWI2.js.map → next-ODJUM4ZM.js.map} +1 -1
  385. package/dist/cli-bundle/chunks/{notes-6KNOSLIT.js → notes-72YXN5JX.js} +10 -8
  386. package/dist/cli-bundle/chunks/{notes-6KNOSLIT.js.map → notes-72YXN5JX.js.map} +1 -1
  387. package/dist/cli-bundle/chunks/{notes-W4UEICGF.js → notes-NJ7IQJX4.js} +12 -10
  388. package/dist/cli-bundle/chunks/{notes-W4UEICGF.js.map → notes-NJ7IQJX4.js.map} +1 -1
  389. package/dist/cli-bundle/chunks/{plan-MJQW5XK3.js → plan-R4NDQ27E.js} +18 -15
  390. package/dist/cli-bundle/chunks/{plan-MJQW5XK3.js.map → plan-R4NDQ27E.js.map} +1 -1
  391. package/dist/cli-bundle/chunks/{plan-JO6V7BXO.js → plan-XWY5T67S.js} +20 -17
  392. package/dist/cli-bundle/chunks/{plan-JO6V7BXO.js.map → plan-XWY5T67S.js.map} +1 -1
  393. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +397 -0
  394. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +1 -0
  395. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +400 -0
  396. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +7 -0
  397. package/dist/cli-bundle/chunks/{register-list-query-ELBHCCFI.js → register-list-query-5H66WFYF.js} +24 -21
  398. package/dist/cli-bundle/chunks/register-list-query-5H66WFYF.js.map +7 -0
  399. package/dist/cli-bundle/chunks/{register-list-query-GAPQ6DM3.js → register-list-query-FB3FNDLZ.js} +25 -22
  400. package/dist/cli-bundle/chunks/{register-list-query-ELBHCCFI.js.map → register-list-query-FB3FNDLZ.js.map} +1 -7
  401. package/dist/cli-bundle/chunks/{register-mutation-SJWMVIJ2.js → register-mutation-UJO23C7R.js} +42 -39
  402. package/dist/cli-bundle/chunks/{register-mutation-SJWMVIJ2.js.map → register-mutation-UJO23C7R.js.map} +1 -1
  403. package/dist/cli-bundle/chunks/{register-mutation-ROFE2YPC.js → register-mutation-Z2ETYHKS.js} +40 -37
  404. package/dist/cli-bundle/chunks/{register-mutation-ROFE2YPC.js.map → register-mutation-Z2ETYHKS.js.map} +1 -1
  405. package/dist/cli-bundle/chunks/{register-operations-MEKU3AKC.js → register-operations-A3XAM5J7.js} +39 -36
  406. package/dist/cli-bundle/chunks/{register-operations-MEKU3AKC.js.map → register-operations-A3XAM5J7.js.map} +1 -1
  407. package/dist/cli-bundle/chunks/{register-operations-IADFVH53.js → register-operations-SG7HBSUP.js} +37 -34
  408. package/dist/cli-bundle/chunks/{register-operations-IADFVH53.js.map → register-operations-SG7HBSUP.js.map} +1 -1
  409. package/dist/cli-bundle/chunks/{register-setup-AJWUSSQX.js → register-setup-I45OGJUV.js} +25 -19
  410. package/dist/cli-bundle/chunks/{register-setup-AJWUSSQX.js.map → register-setup-I45OGJUV.js.map} +1 -1
  411. package/dist/cli-bundle/chunks/{register-setup-3QJY43CY.js → register-setup-K6U3NVY5.js} +23 -17
  412. package/dist/cli-bundle/chunks/{register-setup-3QJY43CY.js.map → register-setup-K6U3NVY5.js.map} +1 -1
  413. package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +19 -0
  414. package/dist/cli-bundle/chunks/{restore-44IHMMZZ.js → restore-YJ2ET6AT.js} +11 -9
  415. package/dist/cli-bundle/chunks/{scheduling-shortcuts-TSBK4AY5.js → scheduling-shortcuts-SSC4MYWQ.js} +14 -12
  416. package/dist/cli-bundle/chunks/{scheduling-shortcuts-TSBK4AY5.js.map → scheduling-shortcuts-SSC4MYWQ.js.map} +1 -1
  417. package/dist/cli-bundle/chunks/{scheduling-shortcuts-OLHNLAZY.js → scheduling-shortcuts-ULRG7MNP.js} +16 -14
  418. package/dist/cli-bundle/chunks/{scheduling-shortcuts-OLHNLAZY.js.map → scheduling-shortcuts-ULRG7MNP.js.map} +1 -1
  419. package/dist/cli-bundle/chunks/{schema-VBCELP5G.js → schema-2PUXCZ25.js} +10 -7
  420. package/dist/cli-bundle/chunks/{schema-IB2NZZWD.js → schema-Y6DXXK2F.js} +10 -7
  421. package/dist/cli-bundle/chunks/{search-7UBETML4.js → search-3S72CTD6.js} +13 -10
  422. package/dist/cli-bundle/chunks/{search-R227JOL6.js → search-WNUNBQXO.js} +13 -10
  423. package/dist/cli-bundle/chunks/{stats-FAG7COEH.js → stats-IJYTRQGV.js} +13 -10
  424. package/dist/cli-bundle/chunks/{stats-FAG7COEH.js.map → stats-IJYTRQGV.js.map} +1 -1
  425. package/dist/cli-bundle/chunks/{stats-MCK7PLYS.js → stats-L2D5Y2O5.js} +15 -12
  426. package/dist/cli-bundle/chunks/{stats-MCK7PLYS.js.map → stats-L2D5Y2O5.js.map} +1 -1
  427. package/dist/cli-bundle/chunks/{telemetry-DRPDZMAO.js → telemetry-L2CVOKVN.js} +11 -8
  428. package/dist/cli-bundle/chunks/{telemetry-DRPDZMAO.js.map → telemetry-L2CVOKVN.js.map} +1 -1
  429. package/dist/cli-bundle/chunks/{telemetry-GVVUQSJQ.js → telemetry-QBYWQA76.js} +13 -10
  430. package/dist/cli-bundle/chunks/{telemetry-GVVUQSJQ.js.map → telemetry-QBYWQA76.js.map} +1 -1
  431. package/dist/cli-bundle/chunks/{test-QY44WAMR.js → test-DQ2QFJ7W.js} +21 -15
  432. package/dist/cli-bundle/chunks/test-W7QBLVJS.js +41 -0
  433. package/dist/cli-bundle/chunks/{test-all-USPJHXFR.js → test-all-636NTRTT.js} +26 -19
  434. package/dist/cli-bundle/chunks/{test-all-USPJHXFR.js.map → test-all-636NTRTT.js.map} +1 -1
  435. package/dist/cli-bundle/chunks/{test-all-QD6QAEG7.js → test-all-DWYK3RG6.js} +24 -17
  436. package/dist/cli-bundle/chunks/{test-all-QD6QAEG7.js.map → test-all-DWYK3RG6.js.map} +1 -1
  437. package/dist/cli-bundle/chunks/test-runs-245OINZR.js +28 -0
  438. package/dist/cli-bundle/chunks/test-runs-245OINZR.js.map +1 -0
  439. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +24 -0
  440. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js.map +7 -0
  441. package/dist/cli-bundle/chunks/update-SFLZPJXX.js +30 -0
  442. package/dist/cli-bundle/chunks/update-SFLZPJXX.js.map +1 -0
  443. package/dist/cli-bundle/chunks/update-SJZ6S77U.js +26 -0
  444. package/dist/cli-bundle/chunks/update-SJZ6S77U.js.map +7 -0
  445. package/dist/cli-bundle/chunks/{update-many-RATAARHU.js → update-many-DC7X3EWM.js} +32 -29
  446. package/dist/cli-bundle/chunks/{update-many-RATAARHU.js.map → update-many-DC7X3EWM.js.map} +1 -1
  447. package/dist/cli-bundle/chunks/{update-many-BEMTDA2X.js → update-many-SLLAMHT7.js} +34 -31
  448. package/dist/cli-bundle/chunks/{update-many-BEMTDA2X.js.map → update-many-SLLAMHT7.js.map} +1 -1
  449. package/dist/cli-bundle/chunks/{upgrade-VU46BLJZ.js → upgrade-HFFXLZJA.js} +19 -12
  450. package/dist/cli-bundle/chunks/{upgrade-VU46BLJZ.js.map → upgrade-HFFXLZJA.js.map} +1 -1
  451. package/dist/cli-bundle/chunks/{upgrade-NWMR3VQL.js → upgrade-UYQKM7RF.js} +21 -14
  452. package/dist/cli-bundle/chunks/{upgrade-NWMR3VQL.js.map → upgrade-UYQKM7RF.js.map} +1 -1
  453. package/dist/cli-bundle/chunks/{validate-NRY6MFXN.js → validate-PA4FDTOV.js} +35 -28
  454. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js.map +7 -0
  455. package/dist/cli-bundle/chunks/{validate-GAJ6FUSI.js → validate-Z7L75YEJ.js} +35 -28
  456. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js.map +1 -0
  457. package/dist/cli-bundle/main.js +173 -57
  458. package/dist/cli-bundle/main.js.map +2 -2
  459. package/dist/cli-bundle/sdk-runtime.js +247 -0
  460. package/dist/cli-bundle/sdk-runtime.js.map +7 -0
  461. package/dist/cli-bundle/sdk-testing.js +101 -0
  462. package/dist/cli-bundle/sdk-testing.js.map +7 -0
  463. package/dist/cli-bundle/sdk.js +787 -0
  464. package/dist/cli-bundle/sdk.js.map +7 -0
  465. package/dist/core/config/nested-settings.d.ts +4 -3
  466. package/dist/core/config/nested-settings.js +17 -6
  467. package/dist/core/config/nested-settings.js.map +1 -1
  468. package/dist/core/extensions/activation-summary.d.ts +6 -0
  469. package/dist/core/extensions/activation-summary.js +10 -4
  470. package/dist/core/extensions/activation-summary.js.map +1 -1
  471. package/dist/core/extensions/capability-usage.d.ts +6 -0
  472. package/dist/core/extensions/capability-usage.js +10 -4
  473. package/dist/core/extensions/capability-usage.js.map +1 -1
  474. package/dist/core/extensions/extension-types.d.ts +6 -2
  475. package/dist/core/extensions/extension-types.js +2 -2
  476. package/dist/core/extensions/extension-types.js.map +1 -1
  477. package/dist/core/extensions/loader.d.ts +3 -0
  478. package/dist/core/extensions/loader.js +11 -19
  479. package/dist/core/extensions/loader.js.map +1 -1
  480. package/dist/core/history/history-rewrite.d.ts +10 -0
  481. package/dist/core/history/history-rewrite.js +28 -4
  482. package/dist/core/history/history-rewrite.js.map +1 -1
  483. package/dist/core/item/parent-reference-policy.d.ts +9 -1
  484. package/dist/core/item/parent-reference-policy.js +28 -4
  485. package/dist/core/item/parent-reference-policy.js.map +1 -1
  486. package/dist/core/item/type-registry.d.ts +1 -0
  487. package/dist/core/item/type-registry.js +153 -177
  488. package/dist/core/item/type-registry.js.map +1 -1
  489. package/dist/core/lock/lock.d.ts +28 -1
  490. package/dist/core/lock/lock.js +254 -20
  491. package/dist/core/lock/lock.js.map +1 -1
  492. package/dist/core/search/background-refresh.js +7 -19
  493. package/dist/core/search/background-refresh.js.map +1 -1
  494. package/dist/core/search/http-client.d.ts +0 -1
  495. package/dist/core/search/http-client.js +3 -3
  496. package/dist/core/search/http-client.js.map +1 -1
  497. package/dist/core/shared/constants.js +3 -2
  498. package/dist/core/shared/constants.js.map +1 -1
  499. package/dist/core/shared/errors.d.ts +1 -0
  500. package/dist/core/shared/errors.js +2 -2
  501. package/dist/core/shared/errors.js.map +1 -1
  502. package/dist/core/shared/primitives.d.ts +12 -0
  503. package/dist/core/shared/primitives.js +29 -2
  504. package/dist/core/shared/primitives.js.map +1 -1
  505. package/dist/core/store/item-store.js +3 -3
  506. package/dist/core/store/item-store.js.map +1 -1
  507. package/dist/core/store/settings-validator.d.ts +1 -0
  508. package/dist/core/store/settings-validator.js +6 -3
  509. package/dist/core/store/settings-validator.js.map +1 -1
  510. package/dist/core/store/settings.js +3 -3
  511. package/dist/core/store/settings.js.map +1 -1
  512. package/dist/core/validate/fix-planning.d.ts +0 -2
  513. package/dist/core/validate/fix-planning.js +3 -3
  514. package/dist/core/validate/fix-planning.js.map +1 -1
  515. package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -2
  516. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  517. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  518. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  519. package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
  520. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  521. package/dist/sdk/cli-contracts/tool-schema.js +55 -94
  522. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  523. package/dist/sdk/errors.d.ts +21 -2
  524. package/dist/sdk/errors.js +8 -2
  525. package/dist/sdk/errors.js.map +1 -1
  526. package/dist/sdk/package-import-adapters.d.ts +90 -2
  527. package/dist/sdk/package-import-adapters.js +275 -3
  528. package/dist/sdk/package-import-adapters.js.map +1 -1
  529. package/dist/sdk/runtime.d.ts +1 -1
  530. package/dist/sdk/runtime.js +3 -3
  531. package/dist/sdk/runtime.js.map +1 -1
  532. package/dist/sdk/testing.js +41 -19
  533. package/dist/sdk/testing.js.map +1 -1
  534. package/dist/types.d.ts +6 -0
  535. package/dist/types.js +2 -2
  536. package/dist/types.js.map +1 -1
  537. package/docs/ARCHITECTURE.md +27 -0
  538. package/docs/CONFIGURATION.md +3 -0
  539. package/docs/README.md +1 -0
  540. package/docs/SDK_PRIMITIVE_INVENTORY.md +55 -0
  541. package/docs/TESTING.md +5 -1
  542. package/docs/examples/ci/github-actions-pm-extension-gate.yml +5 -5
  543. package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +1 -1
  544. package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +1 -1
  545. package/package.json +14 -26
  546. package/packages/pm-beads/extensions/beads/package.json +3 -0
  547. package/packages/pm-beads/extensions/beads/runtime-loader.ts +50 -41
  548. package/packages/pm-beads/extensions/beads/runtime.ts +106 -223
  549. package/packages/pm-calendar/extensions/calendar/package.json +3 -0
  550. package/packages/pm-calendar/extensions/calendar/runtime.ts +21 -18
  551. package/packages/pm-command-kit/extensions/command-kit/package.json +3 -0
  552. package/packages/pm-governance-audit/extensions/governance-audit/package.json +3 -0
  553. package/packages/pm-guide-shell/extensions/guide-shell/package.json +3 -0
  554. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +9 -11
  555. package/packages/pm-kanban/extensions/kanban/package.json +3 -0
  556. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/package.json +3 -0
  557. package/packages/pm-search-advanced/extensions/search-advanced/package.json +3 -0
  558. package/packages/pm-templates/extensions/templates/package.json +3 -0
  559. package/packages/pm-todos/extensions/todos/package.json +3 -0
  560. package/packages/pm-todos/extensions/todos/runtime-loader.ts +62 -72
  561. package/packages/pm-todos/extensions/todos/runtime.ts +61 -257
  562. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +73 -31
  563. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +80 -34
  564. package/scripts/bundle-cli.mjs +12 -2
  565. package/scripts/install.ps1 +7 -7
  566. package/dist/cli-bundle/chunks/activity-BIML7K2D.js +0 -16
  567. package/dist/cli-bundle/chunks/chunk-32IUNTG4.js.map +0 -1
  568. package/dist/cli-bundle/chunks/chunk-4EXFFP7T.js.map +0 -7
  569. package/dist/cli-bundle/chunks/chunk-4WB6S4YX.js.map +0 -1
  570. package/dist/cli-bundle/chunks/chunk-572FKBRL.js.map +0 -1
  571. package/dist/cli-bundle/chunks/chunk-67LARBDL.js.map +0 -1
  572. package/dist/cli-bundle/chunks/chunk-6CDCWKSX.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-6KRFL33E.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-AJHYQCBJ.js.map +0 -7
  575. package/dist/cli-bundle/chunks/chunk-B4O5S7I3.js.map +0 -7
  576. package/dist/cli-bundle/chunks/chunk-CXR3CMBQ.js.map +0 -1
  577. package/dist/cli-bundle/chunks/chunk-ECU6MMTQ.js.map +0 -1
  578. package/dist/cli-bundle/chunks/chunk-EJ2OCBHF.js.map +0 -1
  579. package/dist/cli-bundle/chunks/chunk-ERG65A2L.js.map +0 -1
  580. package/dist/cli-bundle/chunks/chunk-FUFFPIYA.js.map +0 -7
  581. package/dist/cli-bundle/chunks/chunk-HB4FAT3O.js.map +0 -7
  582. package/dist/cli-bundle/chunks/chunk-HQAF23Q2.js.map +0 -7
  583. package/dist/cli-bundle/chunks/chunk-JPATY4SE.js.map +0 -7
  584. package/dist/cli-bundle/chunks/chunk-KHVGM5CS.js.map +0 -7
  585. package/dist/cli-bundle/chunks/chunk-KS6ATO47.js.map +0 -7
  586. package/dist/cli-bundle/chunks/chunk-L4SLHV6G.js.map +0 -1
  587. package/dist/cli-bundle/chunks/chunk-MHRS5FUX.js.map +0 -1
  588. package/dist/cli-bundle/chunks/chunk-NZ7QIUP5.js.map +0 -7
  589. package/dist/cli-bundle/chunks/chunk-OGLGI22K.js.map +0 -1
  590. package/dist/cli-bundle/chunks/chunk-RAHINBVP.js.map +0 -7
  591. package/dist/cli-bundle/chunks/chunk-RJH5VQHW.js.map +0 -1
  592. package/dist/cli-bundle/chunks/chunk-SYE6WMV6.js.map +0 -1
  593. package/dist/cli-bundle/chunks/chunk-TQ6AX5SQ.js.map +0 -7
  594. package/dist/cli-bundle/chunks/chunk-U3S2B7TA.js.map +0 -1
  595. package/dist/cli-bundle/chunks/chunk-WRYERRZX.js.map +0 -7
  596. package/dist/cli-bundle/chunks/chunk-WYOIIFSE.js.map +0 -7
  597. package/dist/cli-bundle/chunks/chunk-XRYSCRZR.js.map +0 -7
  598. package/dist/cli-bundle/chunks/chunk-YF746GTH.js.map +0 -1
  599. package/dist/cli-bundle/chunks/chunk-YSDFIY7N.js.map +0 -1
  600. package/dist/cli-bundle/chunks/chunk-Z4DGFQDH.js.map +0 -1
  601. package/dist/cli-bundle/chunks/claim-2BGBGSVI.js.map +0 -7
  602. package/dist/cli-bundle/chunks/claim-5GU7OE67.js.map +0 -1
  603. package/dist/cli-bundle/chunks/close-6YODBUIV.js +0 -14
  604. package/dist/cli-bundle/chunks/create-Z7YCH3BE.js +0 -28
  605. package/dist/cli-bundle/chunks/files-6SGKHS6O.js.map +0 -1
  606. package/dist/cli-bundle/chunks/files-FUYPSOFJ.js.map +0 -7
  607. package/dist/cli-bundle/chunks/history-CGNQJXFE.js +0 -18
  608. package/dist/cli-bundle/chunks/history-compact-LOED43R3.js.map +0 -7
  609. package/dist/cli-bundle/chunks/history-compact-V5DNAQHH.js.map +0 -1
  610. package/dist/cli-bundle/chunks/history-redact-N3JK7VBW.js +0 -19
  611. package/dist/cli-bundle/chunks/history-repair-4WVBVHFR.js.map +0 -1
  612. package/dist/cli-bundle/chunks/history-repair-PGYQJMGD.js.map +0 -7
  613. package/dist/cli-bundle/chunks/init-4GESW7RM.js +0 -26
  614. package/dist/cli-bundle/chunks/init-XIDPABA4.js +0 -22
  615. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js +0 -1243
  616. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js.map +0 -7
  617. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js +0 -1205
  618. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js.map +0 -1
  619. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js.map +0 -1
  620. package/dist/cli-bundle/chunks/restore-EXHU34EU.js +0 -17
  621. package/dist/cli-bundle/chunks/test-SY76DZTO.js +0 -35
  622. package/dist/cli-bundle/chunks/update-A7EICML6.js +0 -24
  623. package/dist/cli-bundle/chunks/update-IKJZWLQC.js +0 -28
  624. package/dist/cli-bundle/chunks/validate-GAJ6FUSI.js.map +0 -1
  625. package/dist/cli-bundle/chunks/validate-NRY6MFXN.js.map +0 -7
  626. /package/dist/cli-bundle/chunks/{activity-BIML7K2D.js.map → activity-4XQIDNM5.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{activity-5YWLSPGE.js.map → activity-YKAKZTZ4.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{chunk-QCDTQCMW.js.map → chunk-5JE6SMYS.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{chunk-5JIWFWOZ.js.map → chunk-N6DNM2FA.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{chunk-GVJE5T7Q.js.map → chunk-NER3KUUS.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{chunk-MEZZZBYX.js.map → chunk-PDXT6Q55.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{chunk-YVKZ3ANP.js.map → chunk-RX3HQSYG.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{chunk-LOWVNZBZ.js.map → chunk-S4APD35C.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{chunk-6NYJGMTY.js.map → chunk-T35XLYZF.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{chunk-BE2SR6QL.js.map → chunk-TT42JUMF.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{chunk-SU3TB4NS.js.map → chunk-YOF5VPKM.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{chunk-5E7N4T2Z.js.map → chunk-ZMD35NYG.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{close-AFVKPR57.js.map → close-3YRR3XY6.js.map} +0 -0
  639. /package/dist/cli-bundle/chunks/{close-6YODBUIV.js.map → close-OB2Y4QP5.js.map} +0 -0
  640. /package/dist/cli-bundle/chunks/{context-PKCEHQY3.js.map → context-4OQGIPSO.js.map} +0 -0
  641. /package/dist/cli-bundle/chunks/{context-OYXRGY7S.js.map → context-WLA6IAWE.js.map} +0 -0
  642. /package/dist/cli-bundle/chunks/{create-Z7YCH3BE.js.map → contracts-HXJLKCRI.js.map} +0 -0
  643. /package/dist/cli-bundle/chunks/{create-PM45M6PE.js.map → contracts-OJEXMKVW.js.map} +0 -0
  644. /package/dist/cli-bundle/chunks/{extension-BNINIMT7.js.map → create-WKOZKPQR.js.map} +0 -0
  645. /package/dist/cli-bundle/chunks/{extension-QWE4YYK5.js.map → create-XWWQFQ6S.js.map} +0 -0
  646. /package/dist/cli-bundle/chunks/{history-CGNQJXFE.js.map → extension-NBAH62ML.js.map} +0 -0
  647. /package/dist/cli-bundle/chunks/{history-SGRRS72R.js.map → extension-ZF6ZZPOU.js.map} +0 -0
  648. /package/dist/cli-bundle/chunks/{history-redact-N3JK7VBW.js.map → history-RYKLC72X.js.map} +0 -0
  649. /package/dist/cli-bundle/chunks/{history-redact-IRL7WJ3E.js.map → history-SGPYRAFT.js.map} +0 -0
  650. /package/dist/cli-bundle/chunks/{init-XIDPABA4.js.map → history-redact-4H3FCKF3.js.map} +0 -0
  651. /package/dist/cli-bundle/chunks/{init-4GESW7RM.js.map → history-redact-54ICFKXM.js.map} +0 -0
  652. /package/dist/cli-bundle/chunks/{list-D7BF5CL2.js.map → init-RPIPQUNV.js.map} +0 -0
  653. /package/dist/cli-bundle/chunks/{list-472TIOVK.js.map → init-SKQAESQS.js.map} +0 -0
  654. /package/dist/cli-bundle/chunks/{restore-EXHU34EU.js.map → list-64LHZ3HM.js.map} +0 -0
  655. /package/dist/cli-bundle/chunks/{restore-44IHMMZZ.js.map → list-7LXBTEKI.js.map} +0 -0
  656. /package/dist/cli-bundle/chunks/{schema-VBCELP5G.js.map → restore-PXOFL6AM.js.map} +0 -0
  657. /package/dist/cli-bundle/chunks/{schema-IB2NZZWD.js.map → restore-YJ2ET6AT.js.map} +0 -0
  658. /package/dist/cli-bundle/chunks/{search-R227JOL6.js.map → schema-2PUXCZ25.js.map} +0 -0
  659. /package/dist/cli-bundle/chunks/{search-7UBETML4.js.map → schema-Y6DXXK2F.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{test-QY44WAMR.js.map → search-3S72CTD6.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{test-SY76DZTO.js.map → search-WNUNBQXO.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{update-IKJZWLQC.js.map → test-DQ2QFJ7W.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{update-A7EICML6.js.map → test-W7QBLVJS.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../core/history/replay.ts"],"sourcesContent":["/**\n * @module core/history/replay\n *\n * Implements append-only history and replay behavior for Replay.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { FRONT_MATTER_KEY_ORDER } from \"../shared/constants.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport { orderObject, sha256Hex, stableStringify } from \"../shared/serialization.js\";\nimport { hashDocument } from \"./history.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\n\n/**\n * Shared history replay/patch mechanics single-sourced for the history, restore,\n * history-redact, and history-repair commands plus the health/validate drift checks.\n *\n * Each command keeps its own thin error-formatting wrapper so the exact CLI error\n * contracts (restore's rich patch-failure context, redact's op tag, history's\n * generic message) are preserved; only the underlying replay/patch logic is shared.\n */\n\nexport interface ReplayDocument {\n metadata: Record<string, unknown>;\n body: string;\n}\n\nexport const EMPTY_REPLAY_DOCUMENT: ReplayDocument = {\n metadata: {},\n body: \"\",\n};\n\n/**\n * Implements clone empty replay document for the public runtime surface of this module.\n */\nexport function cloneEmptyReplayDocument(): ReplayDocument {\n return structuredClone(EMPTY_REPLAY_DOCUMENT);\n}\n\n/**\n * Implements replay hash for the public runtime surface of this module.\n */\nexport function replayHash(document: ReplayDocument): string {\n try {\n return hashDocument(replayToItemDocument(document));\n } catch {\n // Legacy/malformed replay states (for example a stream whose first entry never\n // established a full `create` document, so the canonicalizer cannot normalize it)\n // cannot be canonically hashed. Fall back to a deterministic structural hash so\n // re-anchor and verification stay internally consistent for these streams. Fully\n // formed documents always take the canonical path above, so valid streams are\n // unaffected.\n return sha256Hex(stableStringify({ replay_fallback: true, metadata: document.metadata, body: document.body }));\n }\n}\n\n/**\n * Implements replay to item document for the public runtime surface of this module.\n */\nexport function replayToItemDocument(document: ReplayDocument): ItemDocument {\n return {\n metadata: document.metadata as ItemMetadata,\n body: document.body,\n };\n}\n\n/**\n * Converts a materialized replay document into a canonical item document. Use\n * this when callers have already rejected the empty/deleted replay state and\n * need restored metadata validated through the normal front-matter rules.\n */\nexport function replayToCanonicalItemDocument(\n document: ReplayDocument,\n options: Parameters<typeof canonicalDocument>[1] = {},\n): ItemDocument {\n return canonicalDocument(replayToItemDocument(document), options);\n}\n\n/**\n * Canonicalize an item document into the ordered replay form used when comparing\n * a replayed chain against the on-disk item (restore + history-repair reconciliation).\n */\nexport function toReplayDocument(document: ItemDocument): ReplayDocument {\n if (!document.metadata || Object.keys(document.metadata).length === 0) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n return {\n metadata: orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER),\n body: canonical.body,\n };\n}\n\n/**\n * Implements normalize replay patch path for the public runtime surface of this module.\n */\nexport function normalizeReplayPatchPath(path: string): string {\n if (path === \"/front_matter\") {\n return \"/metadata\";\n }\n if (path.startsWith(\"/front_matter/\")) {\n return `/metadata/${path.slice(\"/front_matter/\".length)}`;\n }\n return path;\n}\n\nfunction isHistoryPatchOp(value: unknown): value is HistoryPatchOp {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { op?: unknown }).op === \"string\" &&\n typeof (value as { path?: unknown }).path === \"string\"\n );\n}\n\n/**\n * Implements normalize replay patch ops for the public runtime surface of this module.\n */\nexport function normalizeReplayPatchOps(patch: HistoryPatchOp[] | unknown): HistoryPatchOp[] {\n if (!Array.isArray(patch)) {\n return [];\n }\n return patch.filter(isHistoryPatchOp).map((operation) => ({\n ...operation,\n path: normalizeReplayPatchPath(operation.path),\n from: typeof operation.from === \"string\" ? normalizeReplayPatchPath(operation.from) : undefined,\n }));\n}\n\nfunction isReplayDocumentShape(value: unknown): value is { metadata: Record<string, unknown>; body: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"metadata\" in value &&\n \"body\" in value &&\n typeof (value as { body: unknown }).body === \"string\" &&\n typeof (value as { metadata: unknown }).metadata === \"object\" &&\n (value as { metadata: unknown }).metadata !== null\n );\n}\n\n/**\n * Restricts replay apply result values accepted by command, SDK, and storage contracts.\n */\nexport type ReplayApplyResult =\n | { ok: true; document: ReplayDocument }\n | { ok: false; error: unknown };\n\n/**\n * Strictly apply a history patch (front_matter->metadata normalized) to a replay\n * document. Returns a result envelope rather than throwing so each caller can\n * format its own error contract.\n */\nexport function tryApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): ReplayApplyResult {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (!isReplayDocumentShape(applied)) {\n return { ok: false, error: new Error(\"history_replay_invalid_document_shape\") };\n }\n return { ok: true, document: { metadata: applied.metadata, body: applied.body } };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/**\n * Deterministically verify a history chain: each entry's before_hash must equal\n * the prior replayed after_hash, the patch must strictly apply, and the recorded\n * after_hash must equal the replayed result.\n */\nexport function verifyHistoryChain(entries: HistoryEntry[]): { ok: boolean; errors: string[] } {\n let replay = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n return {\n ok: false,\n errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],\n };\n }\n const applied = tryApplyReplayPatch(replay, entry.patch);\n if (!applied.ok) {\n return {\n ok: false,\n errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],\n };\n }\n replay = applied.document;\n if (replayHash(replay) !== entry.after_hash) {\n return {\n ok: false,\n errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],\n };\n }\n }\n return { ok: true, errors: [] };\n}\n\n/**\n * Documents the lenient apply result payload exchanged by command, SDK, and package integrations.\n */\nexport interface LenientApplyResult {\n document: ReplayDocument;\n convertedReplaceToAdd: number;\n skippedOps: number;\n}\n\nfunction tryApplySingleOp(document: unknown, op: HistoryPatchOp): { ok: true; document: unknown } | { ok: false } {\n try {\n const applied = jsonPatch.applyPatch(\n structuredClone(document),\n [op as jsonPatch.Operation],\n true,\n false,\n ).newDocument as unknown;\n return { ok: true, document: applied };\n } catch {\n return { ok: false };\n }\n}\n\n/**\n * Apply a legacy patch op-by-op, recovering from drift that strict replay rejects:\n * a `replace` whose path no longer exists is retried as `add`, and any op that\n * still cannot apply against the current replay state is skipped. The resulting\n * document is what the repaired entry's recomputed patch should target.\n */\nexport function lenientApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): LenientApplyResult {\n let working: unknown = structuredClone(current);\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (const op of normalizeReplayPatchOps(patch)) {\n const direct = tryApplySingleOp(working, op);\n if (direct.ok) {\n working = direct.document;\n continue;\n }\n if (op.op === \"replace\") {\n const asAdd = tryApplySingleOp(working, { ...op, op: \"add\" });\n if (asAdd.ok) {\n working = asAdd.document;\n convertedReplaceToAdd += 1;\n continue;\n }\n }\n skippedOps += 1;\n }\n\n const candidate = working as { metadata?: unknown; body?: unknown };\n const document: ReplayDocument = {\n metadata:\n typeof candidate.metadata === \"object\" && candidate.metadata !== null\n ? (candidate.metadata as Record<string, unknown>)\n : {},\n body: typeof candidate.body === \"string\" ? candidate.body : current.body,\n };\n return { document, convertedReplaceToAdd, skippedOps };\n}\n\n/**\n * Documents the reanchor entry detail payload exchanged by command, SDK, and package integrations.\n */\nexport interface ReanchorEntryDetail {\n index: number;\n rehashed: boolean;\n patch_repaired: boolean;\n converted_replace_to_add: number;\n skipped_ops: number;\n}\n\n/**\n * Documents the reanchor result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ReanchorResult {\n entries: HistoryEntry[];\n finalDocument: ReplayDocument;\n entriesRehashed: number;\n entriesPatchRepaired: number;\n convertedReplaceToAdd: number;\n skippedOps: number;\n details: ReanchorEntryDetail[];\n}\n\n/**\n * Re-anchor a drifted history chain: replay every entry from empty, recompute the\n * before/after hashes, and only rewrite a patch when the original op set no longer\n * strictly applies (legacy drift). Clean entries keep their patch verbatim so the\n * on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain.\n */\nexport function reanchorHistoryEntries(entries: HistoryEntry[]): ReanchorResult {\n let replay = cloneEmptyReplayDocument();\n const rewritten: HistoryEntry[] = [];\n const details: ReanchorEntryDetail[] = [];\n let entriesRehashed = 0;\n let entriesPatchRepaired = 0;\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n const beforeHash = replayHash(replay);\n const strict = tryApplyReplayPatch(replay, entry.patch);\n\n let next: ReplayDocument;\n let outPatch: HistoryPatchOp[];\n let patchRepaired = false;\n let entryConverted = 0;\n let entrySkipped = 0;\n\n if (strict.ok) {\n next = strict.document;\n outPatch = entry.patch;\n } else {\n const lenient = lenientApplyReplayPatch(replay, entry.patch);\n next = lenient.document;\n outPatch = jsonPatch.compare(replay, next) as HistoryPatchOp[];\n patchRepaired = true;\n entryConverted = lenient.convertedReplaceToAdd;\n entrySkipped = lenient.skippedOps;\n convertedReplaceToAdd += entryConverted;\n skippedOps += entrySkipped;\n entriesPatchRepaired += 1;\n }\n\n const afterHash = replayHash(next);\n const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;\n if (rehashed) {\n entriesRehashed += 1;\n }\n\n rewritten.push({\n ...entry,\n patch: outPatch,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n details.push({\n index: index + 1,\n rehashed,\n patch_repaired: patchRepaired,\n converted_replace_to_add: entryConverted,\n skipped_ops: entrySkipped,\n });\n replay = next;\n }\n\n return {\n entries: rewritten,\n finalDocument: replay,\n entriesRehashed,\n entriesPatchRepaired,\n convertedReplaceToAdd,\n skippedOps,\n details,\n };\n}\n\n/**\n * Implements history entries to raw for the public runtime surface of this module.\n */\nexport function historyEntriesToRaw(entries: HistoryEntry[]): string {\n if (entries.length === 0) {\n return \"\";\n }\n return `${entries.map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAKA,OAAO,eAAe;AAsBf,IAAM,wBAAwC;EACnD,UAAU,CAAA;EACV,MAAM;;AAMF,SAAU,2BAAwB;AACtC,SAAO,gBAAgB,qBAAqB;AAC9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BAAgB;AACpB,QAAI,iBAAiB;AACrB,QAAI,eAAe;AAEnB,QAAI,OAAO,IAAI;AACb,aAAO,OAAO;AACd,iBAAW,MAAM;IACnB,OAAO;AACL,YAAM,UAAU,wBAAwB,QAAQ,MAAM,KAAK;AAC3D,aAAO,QAAQ;AACf,iBAAW,UAAU,QAAQ,QAAQ,IAAI;AACzC,sBAAgB;AAChB,uBAAiB,QAAQ;AACzB,qBAAe,QAAQ;AACvB,+BAAyB;AACzB,oBAAc;AACd,8BAAwB;IAC1B;AAEA,UAAM,YAAY,WAAW,IAAI;AACjC,UAAM,WAAW,eAAe,MAAM,eAAe,cAAc,MAAM;AACzE,QAAI,UAAU;AACZ,yBAAmB;IACrB;AAEA,cAAU,KAAK;MACb,GAAG;MACH,OAAO;MACP,aAAa;MACb,YAAY;KACb;AACD,YAAQ,KAAK;MACX,OAAO,QAAQ;MACf;MACA,gBAAgB;MAChB,0BAA0B;MAC1B,aAAa;KACd;AACD,aAAS;EACX;AAEA,SAAO;IACL,SAAS;IACT,eAAe;IACf;IACA;IACA;IACA;IACA;;AAEJ;AAKM,SAAU,oBAAoB,SAAuB;AACzD,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;EACT;AACA,SAAO,GAAG,QAAQ,IAAI,CAAC,UAAU,KAAK,UAAU,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC;;AACpE","debugId":"be42ed54-a5b3-5603-ac08-e05799a50836"}
1
+ {"version":3,"sources":["../../../../../../../../core/history/replay.ts"],"sourcesContent":["/**\n * @module core/history/replay\n *\n * Implements append-only history and replay behavior for Replay.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { FRONT_MATTER_KEY_ORDER } from \"../shared/constants.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport { orderObject, sha256Hex, stableStringify } from \"../shared/serialization.js\";\nimport { hashDocument } from \"./history.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\n\n/**\n * Shared history replay/patch mechanics single-sourced for the history, restore,\n * history-redact, and history-repair commands plus the health/validate drift checks.\n *\n * Each command keeps its own thin error-formatting wrapper so the exact CLI error\n * contracts (restore's rich patch-failure context, redact's op tag, history's\n * generic message) are preserved; only the underlying replay/patch logic is shared.\n */\n\nexport interface ReplayDocument {\n metadata: Record<string, unknown>;\n body: string;\n}\n\nexport const EMPTY_REPLAY_DOCUMENT: ReplayDocument = {\n metadata: {},\n body: \"\",\n};\n\n/**\n * Implements clone empty replay document for the public runtime surface of this module.\n */\nexport function cloneEmptyReplayDocument(): ReplayDocument {\n return structuredClone(EMPTY_REPLAY_DOCUMENT);\n}\n\n/**\n * Implements replay hash for the public runtime surface of this module.\n */\nexport function replayHash(document: ReplayDocument): string {\n try {\n return hashDocument(replayToItemDocument(document));\n } catch {\n // Legacy/malformed replay states (for example a stream whose first entry never\n // established a full `create` document, so the canonicalizer cannot normalize it)\n // cannot be canonically hashed. Fall back to a deterministic structural hash so\n // re-anchor and verification stay internally consistent for these streams. Fully\n // formed documents always take the canonical path above, so valid streams are\n // unaffected.\n return sha256Hex(stableStringify({ replay_fallback: true, metadata: document.metadata, body: document.body }));\n }\n}\n\n/**\n * Implements replay to item document for the public runtime surface of this module.\n */\nexport function replayToItemDocument(document: ReplayDocument): ItemDocument {\n return {\n metadata: document.metadata as ItemMetadata,\n body: document.body,\n };\n}\n\n/**\n * Converts a materialized replay document into a canonical item document. Use\n * this when callers have already rejected the empty/deleted replay state and\n * need restored metadata validated through the normal front-matter rules.\n */\nexport function replayToCanonicalItemDocument(\n document: ReplayDocument,\n options: Parameters<typeof canonicalDocument>[1] = {},\n): ItemDocument {\n return canonicalDocument(replayToItemDocument(document), options);\n}\n\n/**\n * Canonicalize an item document into the ordered replay form used when comparing\n * a replayed chain against the on-disk item (restore + history-repair reconciliation).\n */\nexport function toReplayDocument(document: ItemDocument): ReplayDocument {\n if (!document.metadata || Object.keys(document.metadata).length === 0) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n return {\n metadata: orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER),\n body: canonical.body,\n };\n}\n\n/**\n * Implements normalize replay patch path for the public runtime surface of this module.\n */\nexport function normalizeReplayPatchPath(path: string): string {\n if (path === \"/front_matter\") {\n return \"/metadata\";\n }\n if (path.startsWith(\"/front_matter/\")) {\n return `/metadata/${path.slice(\"/front_matter/\".length)}`;\n }\n return path;\n}\n\nfunction isHistoryPatchOp(value: unknown): value is HistoryPatchOp {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { op?: unknown }).op === \"string\" &&\n typeof (value as { path?: unknown }).path === \"string\"\n );\n}\n\n/**\n * Implements normalize replay patch ops for the public runtime surface of this module.\n */\nexport function normalizeReplayPatchOps(patch: HistoryPatchOp[] | unknown): HistoryPatchOp[] {\n if (!Array.isArray(patch)) {\n return [];\n }\n return patch.filter(isHistoryPatchOp).map((operation) => ({\n ...operation,\n path: normalizeReplayPatchPath(operation.path),\n from: typeof operation.from === \"string\" ? normalizeReplayPatchPath(operation.from) : undefined,\n }));\n}\n\nfunction isReplayDocumentShape(value: unknown): value is { metadata: Record<string, unknown>; body: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"metadata\" in value &&\n \"body\" in value &&\n typeof (value as { body: unknown }).body === \"string\" &&\n typeof (value as { metadata: unknown }).metadata === \"object\" &&\n (value as { metadata: unknown }).metadata !== null\n );\n}\n\n/**\n * Restricts replay apply result values accepted by command, SDK, and storage contracts.\n */\nexport type ReplayApplyResult =\n | { ok: true; document: ReplayDocument }\n | { ok: false; error: unknown };\n\n/**\n * Strictly apply a history patch (front_matter->metadata normalized) to a replay\n * document. Returns a result envelope rather than throwing so each caller can\n * format its own error contract.\n */\nexport function tryApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): ReplayApplyResult {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (!isReplayDocumentShape(applied)) {\n return { ok: false, error: new Error(\"history_replay_invalid_document_shape\") };\n }\n return { ok: true, document: { metadata: applied.metadata, body: applied.body } };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/**\n * Deterministically verify a history chain: each entry's before_hash must equal\n * the prior replayed after_hash, the patch must strictly apply, and the recorded\n * after_hash must equal the replayed result.\n */\nexport function verifyHistoryChain(entries: HistoryEntry[]): { ok: boolean; errors: string[] } {\n let replay = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n return {\n ok: false,\n errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],\n };\n }\n const applied = tryApplyReplayPatch(replay, entry.patch);\n if (!applied.ok) {\n return {\n ok: false,\n errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],\n };\n }\n replay = applied.document;\n if (replayHash(replay) !== entry.after_hash) {\n return {\n ok: false,\n errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],\n };\n }\n }\n return { ok: true, errors: [] };\n}\n\n/**\n * Documents the lenient apply result payload exchanged by command, SDK, and package integrations.\n */\nexport interface LenientApplyResult {\n document: ReplayDocument;\n convertedReplaceToAdd: number;\n skippedOps: number;\n}\n\nfunction tryApplySingleOp(document: unknown, op: HistoryPatchOp): { ok: true; document: unknown } | { ok: false } {\n try {\n const applied = jsonPatch.applyPatch(\n structuredClone(document),\n [op as jsonPatch.Operation],\n true,\n false,\n ).newDocument as unknown;\n return { ok: true, document: applied };\n } catch {\n return { ok: false };\n }\n}\n\n/**\n * Apply a legacy patch op-by-op, recovering from drift that strict replay rejects:\n * a `replace` whose path no longer exists is retried as `add`, and any op that\n * still cannot apply against the current replay state is skipped. The resulting\n * document is what the repaired entry's recomputed patch should target.\n */\nexport function lenientApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): LenientApplyResult {\n let working: unknown = structuredClone(current);\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (const op of normalizeReplayPatchOps(patch)) {\n const direct = tryApplySingleOp(working, op);\n if (direct.ok) {\n working = direct.document;\n continue;\n }\n if (op.op === \"replace\") {\n const asAdd = tryApplySingleOp(working, { ...op, op: \"add\" });\n if (asAdd.ok) {\n working = asAdd.document;\n convertedReplaceToAdd += 1;\n continue;\n }\n }\n skippedOps += 1;\n }\n\n const candidate = working as { metadata?: unknown; body?: unknown };\n const document: ReplayDocument = {\n metadata:\n typeof candidate.metadata === \"object\" && candidate.metadata !== null\n ? (candidate.metadata as Record<string, unknown>)\n : {},\n body: typeof candidate.body === \"string\" ? candidate.body : current.body,\n };\n return { document, convertedReplaceToAdd, skippedOps };\n}\n\n/**\n * Documents the reanchor entry detail payload exchanged by command, SDK, and package integrations.\n */\nexport interface ReanchorEntryDetail {\n index: number;\n rehashed: boolean;\n patch_repaired: boolean;\n converted_replace_to_add: number;\n skipped_ops: number;\n}\n\n/**\n * Documents the reanchor result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ReanchorResult {\n entries: HistoryEntry[];\n finalDocument: ReplayDocument;\n entriesRehashed: number;\n entriesPatchRepaired: number;\n convertedReplaceToAdd: number;\n skippedOps: number;\n details: ReanchorEntryDetail[];\n}\n\n/**\n * Re-anchor a drifted history chain: replay every entry from empty, recompute the\n * before/after hashes, and only rewrite a patch when the original op set no longer\n * strictly applies (legacy drift). Clean entries keep their patch verbatim so the\n * on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain.\n */\nexport function reanchorHistoryEntries(entries: HistoryEntry[]): ReanchorResult {\n let replay = cloneEmptyReplayDocument();\n const rewritten: HistoryEntry[] = [];\n const details: ReanchorEntryDetail[] = [];\n let entriesRehashed = 0;\n let entriesPatchRepaired = 0;\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n const beforeHash = replayHash(replay);\n const strict = tryApplyReplayPatch(replay, entry.patch);\n\n let next: ReplayDocument;\n let outPatch: HistoryPatchOp[];\n let patchRepaired = false;\n let entryConverted = 0;\n let entrySkipped = 0;\n\n if (strict.ok) {\n next = strict.document;\n outPatch = entry.patch;\n } else {\n const lenient = lenientApplyReplayPatch(replay, entry.patch);\n next = lenient.document;\n outPatch = jsonPatch.compare(replay, next) as HistoryPatchOp[];\n patchRepaired = true;\n entryConverted = lenient.convertedReplaceToAdd;\n entrySkipped = lenient.skippedOps;\n convertedReplaceToAdd += entryConverted;\n skippedOps += entrySkipped;\n entriesPatchRepaired += 1;\n }\n\n const afterHash = replayHash(next);\n const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;\n if (rehashed) {\n entriesRehashed += 1;\n }\n\n rewritten.push({\n ...entry,\n patch: outPatch,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n details.push({\n index: index + 1,\n rehashed,\n patch_repaired: patchRepaired,\n converted_replace_to_add: entryConverted,\n skipped_ops: entrySkipped,\n });\n replay = next;\n }\n\n return {\n entries: rewritten,\n finalDocument: replay,\n entriesRehashed,\n entriesPatchRepaired,\n convertedReplaceToAdd,\n skippedOps,\n details,\n };\n}\n\n/**\n * Implements history entries to raw for the public runtime surface of this module.\n */\nexport function historyEntriesToRaw(entries: HistoryEntry[]): string {\n if (entries.length === 0) {\n return \"\";\n }\n return `${entries.map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,OAAO,eAAe;AAsBf,IAAM,wBAAwC;EACnD,UAAU,CAAA;EACV,MAAM;;AAMF,SAAU,2BAAwB;AACtC,SAAO,gBAAgB,qBAAqB;AAC9C;AAKM,SAAU,WAAW,UAAwB;AACjD,MAAI;AACF,WAAO,aAAa,qBAAqB,QAAQ,CAAC;EACpD,QAAQ;AAON,WAAO,UAAU,gBAAgB,EAAE,iBAAi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UAAU,wBAAwB,QAAQ,MAAM,KAAK;AAC3D,aAAO,QAAQ;AACf,iBAAW,UAAU,QAAQ,QAAQ,IAAI;AACzC,sBAAgB;AAChB,uBAAiB,QAAQ;AACzB,qBAAe,QAAQ;AACvB,+BAAyB;AACzB,oBAAc;AACd,8BAAwB;IAC1B;AAEA,UAAM,YAAY,WAAW,IAAI;AACjC,UAAM,WAAW,eAAe,MAAM,eAAe,cAAc,MAAM;AACzE,QAAI,UAAU;AACZ,yBAAmB;IACrB;AAEA,cAAU,KAAK;MACb,GAAG;MACH,OAAO;MACP,aAAa;MACb,YAAY;KACb;AACD,YAAQ,KAAK;MACX,OAAO,QAAQ;MACf;MACA,gBAAgB;MAChB,0BAA0B;MAC1B,aAAa;KACd;AACD,aAAS;EACX;AAEA,SAAO;IACL,SAAS;IACT,eAAe;IACf;IACA;IACA;IACA;IACA;;AAEJ;AAKM,SAAU,oBAAoB,SAAuB;AACzD,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;EACT;AACA,SAAO,GAAG,QAAQ,IAAI,CAAC,UAAU,KAAK,UAAU,KAAK,CAAC,EAAE,KAAK,IAAI,CAAC;;AACpE","debugId":"60ce5760-cb2c-5450-b92b-48275942b6ad"}
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  parseOptionalNumber
3
- } from "./chunk-P5L7Z2O6.js";
3
+ } from "./chunk-T3ABIMGW.js";
4
4
  import {
5
5
  splitCommaList
6
6
  } from "./chunk-5HIZDR5A.js";
7
+ import {
8
+ PmCliError
9
+ } from "./chunk-P5YORJRH.js";
7
10
  import {
8
11
  EXIT_CODE,
9
- PmCliError,
10
12
  SCOPE_VALUES
11
- } from "./chunk-KHVGM5CS.js";
13
+ } from "./chunk-5VVUKE3U.js";
12
14
 
13
15
  // dist/cli/commands/linked-test-entry.js
14
16
  !(function() {
@@ -525,4 +527,4 @@ export {
525
527
  parseLinkedTestAssertionGteMap,
526
528
  parseLinkedTestJsonEntries
527
529
  };
528
- //# sourceMappingURL=chunk-MDHWWBNZ.js.map
530
+ //# sourceMappingURL=chunk-BVEUCSH2.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/linked-test-entry.ts", "../../../../../../../../cli/commands/linked-test-parsers.ts"],
4
4
  "sourcesContent": ["/**\n * @module cli/commands/linked-test-entry\n *\n * Implements the pm linked test entry command surface and its agent-facing runtime behavior.\n */\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\n\n// Keys accepted inside a structured linked-test entry. `cmd` is an alias for\n// `command`; everything else maps 1:1 to a LinkedTest field.\nexport const STRUCTURED_LINKED_TEST_KEYS = [\n \"command\",\n \"cmd\",\n \"path\",\n \"scope\",\n \"timeout\",\n \"timeout_seconds\",\n \"pm_context_mode\",\n \"env_set\",\n \"env_clear\",\n \"shared_host_safe\",\n \"assert_stdout_contains\",\n \"assert_stdout_regex\",\n \"assert_stderr_contains\",\n \"assert_stderr_regex\",\n \"assert_stdout_min_lines\",\n \"assert_json_field_equals\",\n \"assert_json_field_gte\",\n \"note\",\n] as const;\n\nconst STRUCTURED_LINKED_TEST_KEY_SET = new Set<string>(STRUCTURED_LINKED_TEST_KEYS);\nconst STRUCTURED_LINKED_TEST_KEY_PATTERN = STRUCTURED_LINKED_TEST_KEYS.map((key) =>\n key.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"),\n).join(\"|\");\nconst STRUCTURED_LINKED_TEST_ENTRY_PATTERN = new RegExp(\n `^(?:[-*+]\\\\s+)?(?:${STRUCTURED_LINKED_TEST_KEY_PATTERN})\\\\s*[:=]`,\n \"i\",\n);\n\n/**\n * Implements looks like structured linked test entry for the public runtime surface of this module.\n */\nexport function looksLikeStructuredLinkedTestEntry(raw: string): boolean {\n if (raw.startsWith(\"```\") || raw.includes(\"\\n\")) {\n return true;\n }\n return STRUCTURED_LINKED_TEST_ENTRY_PATTERN.test(raw);\n}\n\n/**\n * Implements normalize structured linked test entry for the public runtime surface of this module.\n */\nexport function normalizeStructuredLinkedTestEntry(\n kv: Record<string, string>,\n optionName: \"--add\" | \"--test\",\n): Record<string, string> {\n const normalizedKv: Record<string, string> = {};\n const unknownKeys: string[] = [];\n for (const [key, value] of Object.entries(kv)) {\n const normalizedKey = key.toLowerCase();\n if (!STRUCTURED_LINKED_TEST_KEY_SET.has(normalizedKey)) {\n unknownKeys.push(key);\n continue;\n }\n normalizedKv[normalizedKey] = value;\n }\n if (unknownKeys.length > 0) {\n throw new PmCliError(\n `${optionName} does not recognize key${unknownKeys.length > 1 ? \"s\" : \"\"} ${unknownKeys\n .map((key) => `\"${key}\"`)\n .join(\", \")}. Allowed keys: ${STRUCTURED_LINKED_TEST_KEYS.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n }\n if (normalizedKv.cmd !== undefined) {\n if (normalizedKv.command !== undefined && normalizedKv.command.trim() !== normalizedKv.cmd.trim()) {\n throw new PmCliError(`${optionName} command and cmd must match when both are provided`, EXIT_CODE.USAGE);\n }\n const { cmd, ...rest } = normalizedKv;\n return { ...rest, command: rest.command ?? cmd };\n }\n return normalizedKv;\n}\n", "/**\n * @module cli/commands/linked-test-parsers\n *\n * Implements the pm linked test parsers command surface and its agent-facing runtime behavior.\n */\nimport { parseOptionalNumber } from \"../../core/item/parse.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { splitCommaList } from \"../../core/shared/split-comma-list.js\";\nimport { STRUCTURED_LINKED_TEST_KEYS } from \"./linked-test-entry.js\";\nimport { SCOPE_VALUES } from \"../../types/index.js\";\nimport type { LinkedTest, LinkScope } from \"../../types/index.js\";\n\n/**\n * Shared linked-test field parsers used by the `create` and `test` commands.\n *\n * Extracted verbatim from create.ts and test.ts (pm-why9). The two copies were\n * byte-identical apart from their empty-input guard: create called these with\n * raw (untrimmed) values and used `if (!normalized)`; test called them with\n * pre-`.trim()`-ed values and used `if (!raw || raw.trim().length === 0)`.\n *\n * Both reduce to the same observable behaviour when the guard is the plain\n * falsy check used here: create's call sites still pass untrimmed values\n * (behaviour preserved exactly), and test's call sites pre-trim so a\n * whitespace-only value collapses to \"\" and is rejected by `!raw` exactly as\n * before. Error strings and parsing semantics are identical to both originals.\n */\n\nexport const LINKED_TEST_PROTECTED_ENV_KEYS = new Set([\"PM_PATH\", \"PM_GLOBAL_PATH\", \"FORCE_COLOR\"]);\nexport const LINKED_TEST_ENV_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;\nexport const LINKED_TEST_PM_CONTEXT_MODE_VALUES = [\"schema\", \"tracker\", \"auto\"] as const;\n/**\n * Restricts linked test pm context mode values accepted by command, SDK, and storage contracts.\n */\nexport type LinkedTestPmContextMode = (typeof LINKED_TEST_PM_CONTEXT_MODE_VALUES)[number];\n\n/**\n * Implements parse linked test env set for the public runtime surface of this module.\n */\nexport function parseLinkedTestEnvSet(raw: string | undefined, optionName: string): Record<string, string> | undefined {\n if (!raw) {\n return undefined;\n }\n const assignments = raw\n .split(/[;\\n]/)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n if (assignments.length === 0) {\n throw new PmCliError(`${optionName} env_set must include at least one KEY=VALUE assignment`, EXIT_CODE.USAGE);\n }\n const envSet: Record<string, string> = {};\n for (const assignment of assignments) {\n const separatorIndex = assignment.indexOf(\"=\");\n if (separatorIndex <= 0) {\n throw new PmCliError(\n `${optionName} env_set entries must use KEY=VALUE and be separated by semicolons. Example: env_set=PORT=0;PLAYWRIGHT_BASE_URL=http://127.0.0.1:4173`,\n EXIT_CODE.USAGE,\n );\n }\n const key = assignment.slice(0, separatorIndex).trim();\n const value = assignment.slice(separatorIndex + 1);\n if (!LINKED_TEST_ENV_NAME_PATTERN.test(key)) {\n throw new PmCliError(`${optionName} env_set key \"${key}\" is invalid`, EXIT_CODE.USAGE);\n }\n if (LINKED_TEST_PROTECTED_ENV_KEYS.has(key.toUpperCase())) {\n throw new PmCliError(`${optionName} env_set key \"${key}\" is reserved for sandbox safety`, EXIT_CODE.USAGE);\n }\n envSet[key] = value;\n }\n /* c8 ignore start -- envSet always has >=1 key here (assignments is non-empty and each adds one); the undefined branch is defensive. */\n return Object.keys(envSet).length > 0 ? envSet : undefined;\n /* c8 ignore stop */\n}\n\n/**\n * Implements parse linked test env clear for the public runtime surface of this module.\n */\nexport function parseLinkedTestEnvClear(raw: string | undefined, optionName: string): string[] | undefined {\n if (!raw) {\n return undefined;\n }\n const keys = splitCommaList(raw, { separators: /[;,\\n]/ });\n if (keys.length === 0) {\n throw new PmCliError(`${optionName} env_clear must include at least one environment variable name`, EXIT_CODE.USAGE);\n }\n for (const key of keys) {\n if (!LINKED_TEST_ENV_NAME_PATTERN.test(key)) {\n throw new PmCliError(`${optionName} env_clear key \"${key}\" is invalid`, EXIT_CODE.USAGE);\n }\n if (LINKED_TEST_PROTECTED_ENV_KEYS.has(key.toUpperCase())) {\n throw new PmCliError(`${optionName} env_clear key \"${key}\" is reserved for sandbox safety`, EXIT_CODE.USAGE);\n }\n }\n return keys;\n}\n\n/**\n * Implements parse linked test boolean for the public runtime surface of this module.\n */\nexport function parseLinkedTestBoolean(raw: string | undefined, optionName: string, fieldLabel: string): boolean | undefined {\n if (!raw) {\n return undefined;\n }\n const value = raw.trim().toLowerCase();\n if (value === \"true\" || value === \"1\" || value === \"yes\") {\n return true;\n }\n if (value === \"false\" || value === \"0\" || value === \"no\") {\n return false;\n }\n throw new PmCliError(`${optionName} ${fieldLabel} must be one of true|false|1|0|yes|no`, EXIT_CODE.USAGE);\n}\n\n/**\n * Implements parse linked test context mode for the public runtime surface of this module.\n */\nexport function parseLinkedTestContextMode(\n raw: string | undefined,\n optionName: string,\n): LinkedTest[\"pm_context_mode\"] | undefined {\n if (!raw) {\n return undefined;\n }\n const value = raw.trim().toLowerCase();\n if ((LINKED_TEST_PM_CONTEXT_MODE_VALUES as readonly string[]).includes(value)) {\n return value as LinkedTest[\"pm_context_mode\"];\n }\n throw new PmCliError(\n `${optionName} pm_context_mode must be one of: ${LINKED_TEST_PM_CONTEXT_MODE_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n}\n\n/**\n * Implements parse linked test string list for the public runtime surface of this module.\n */\nexport function parseLinkedTestStringList(raw: string | undefined): string[] | undefined {\n if (!raw) {\n return undefined;\n }\n const values = splitCommaList(raw, { separators: /[;\\n]/ });\n return values.length > 0 ? values : undefined;\n}\n\n/**\n * Implements parse linked test regex list for the public runtime surface of this module.\n */\nexport function parseLinkedTestRegexList(raw: string | undefined, optionName: string, fieldLabel: string): string[] | undefined {\n const values = parseLinkedTestStringList(raw);\n if (!values || values.length === 0) {\n return undefined;\n }\n for (const pattern of values) {\n try {\n // Validate regex syntax early so malformed assertions fail at parse time.\n // User-provided, per-item patterns only run during local CLI validation.\n new RegExp(pattern, \"m\");\n } catch (error: unknown) {\n throw new PmCliError(\n /* c8 ignore next -- RegExp only throws SyntaxError (an Error); String(error) fallback is defensive. */\n `${optionName} ${fieldLabel} includes invalid regex \"${pattern}\": ${error instanceof Error ? error.message : String(error)}`,\n EXIT_CODE.USAGE,\n );\n }\n }\n return values;\n}\n\n/**\n * Implements parse linked test min lines for the public runtime surface of this module.\n */\nexport function parseLinkedTestMinLines(raw: string | undefined, optionName: string): number | undefined {\n if (!raw) {\n return undefined;\n }\n const parsed = parseOptionalNumber(raw, \"assert_stdout_min_lines\");\n if (!Number.isInteger(parsed) || parsed < 0) {\n throw new PmCliError(`${optionName} assert_stdout_min_lines must be an integer >= 0`, EXIT_CODE.USAGE);\n }\n return parsed;\n}\n\n/**\n * Implements parse linked test assertion equals map for the public runtime surface of this module.\n */\nexport function parseLinkedTestAssertionEqualsMap(raw: string | undefined, optionName: string): Record<string, string> | undefined {\n if (!raw) {\n return undefined;\n }\n const assignments = raw\n .split(/[;\\n]/)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n if (assignments.length === 0) {\n throw new PmCliError(`${optionName} assert_json_field_equals must include at least one path=value assignment`, EXIT_CODE.USAGE);\n }\n const values: Record<string, string> = {};\n for (const assignment of assignments) {\n const separatorIndex = assignment.indexOf(\"=\");\n if (separatorIndex <= 0) {\n throw new PmCliError(\n `${optionName} assert_json_field_equals entries must use path=value and be separated by semicolons`,\n EXIT_CODE.USAGE,\n );\n }\n const key = assignment.slice(0, separatorIndex).trim();\n const value = assignment.slice(separatorIndex + 1).trim();\n if (key.length === 0 || value.length === 0) {\n throw new PmCliError(`${optionName} assert_json_field_equals entries must include non-empty path and value`, EXIT_CODE.USAGE);\n }\n values[key] = value;\n }\n /* c8 ignore start -- values always has >=1 key here (assignments is non-empty and each adds one); the undefined branch is defensive. */\n return Object.keys(values).length > 0 ? values : undefined;\n /* c8 ignore stop */\n}\n\n/**\n * Implements parse linked test assertion gte map for the public runtime surface of this module.\n */\nexport function parseLinkedTestAssertionGteMap(raw: string | undefined, optionName: string): Record<string, number> | undefined {\n if (!raw) {\n return undefined;\n }\n const assignments = raw\n .split(/[;\\n]/)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n if (assignments.length === 0) {\n throw new PmCliError(`${optionName} assert_json_field_gte must include at least one path=value assignment`, EXIT_CODE.USAGE);\n }\n const values: Record<string, number> = {};\n for (const assignment of assignments) {\n const separatorIndex = assignment.indexOf(\"=\");\n if (separatorIndex <= 0) {\n throw new PmCliError(\n `${optionName} assert_json_field_gte entries must use path=value and be separated by semicolons`,\n EXIT_CODE.USAGE,\n );\n }\n const key = assignment.slice(0, separatorIndex).trim();\n const valueRaw = assignment.slice(separatorIndex + 1).trim();\n if (key.length === 0 || valueRaw.length === 0) {\n throw new PmCliError(`${optionName} assert_json_field_gte entries must include non-empty path and value`, EXIT_CODE.USAGE);\n }\n const value = Number.parseFloat(valueRaw);\n if (!Number.isFinite(value)) {\n throw new PmCliError(`${optionName} assert_json_field_gte value for \"${key}\" must be numeric`, EXIT_CODE.USAGE);\n }\n values[key] = value;\n }\n /* c8 ignore start -- values always has >=1 key here (assignments is non-empty and each adds one); the undefined branch is defensive. */\n return Object.keys(values).length > 0 ? values : undefined;\n /* c8 ignore stop */\n}\n\n/**\n * Strict JSON linked-test entry parsing for `pm test --add-json` (pm-vcr2).\n *\n * Accepts a JSON object or array of objects whose keys match the structured\n * linked-test fields. Unlike `--add` CSV parsing, command strings are stored\n * verbatim: commas, nested quotes, `--` separators, and shell variables like\n * `$tmp` survive byte-identically.\n */\n\nconst LINKED_TEST_JSON_KEY_SET = new Set<string>(STRUCTURED_LINKED_TEST_KEYS);\n\ntype JsonRecord = Record<string, unknown>;\n\nfunction isPlainObject(value: unknown): value is JsonRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction normalizeJsonEntryKeys(entry: JsonRecord, fail: (message: string) => PmCliError): JsonRecord {\n const normalized: JsonRecord = {};\n const unknownKeys: string[] = [];\n for (const [key, value] of Object.entries(entry)) {\n const normalizedKey = key.toLowerCase();\n if (!LINKED_TEST_JSON_KEY_SET.has(normalizedKey)) {\n unknownKeys.push(key);\n continue;\n }\n if (Object.hasOwn(normalized, normalizedKey)) {\n throw fail(`provides key \"${key}\" more than once after case normalization`);\n }\n normalized[normalizedKey] = value;\n }\n if (unknownKeys.length > 0) {\n throw fail(\n `does not recognize key${unknownKeys.length > 1 ? \"s\" : \"\"} ${unknownKeys.map((key) => `\"${key}\"`).join(\", \")}. Allowed keys: ${STRUCTURED_LINKED_TEST_KEYS.join(\", \")}.`,\n );\n }\n return normalized;\n}\n\nfunction readJsonEntryString(entry: JsonRecord, key: string, fail: (message: string) => PmCliError): string | undefined {\n if (!Object.hasOwn(entry, key)) {\n return undefined;\n }\n const value = entry[key];\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== \"string\") {\n throw fail(`field \"${key}\" must be a JSON string`);\n }\n return value;\n}\n\nfunction readJsonEntryStringList(entry: JsonRecord, key: string, fail: (message: string) => PmCliError): string[] | undefined {\n if (!Object.hasOwn(entry, key)) {\n return undefined;\n }\n const value = entry[key];\n if (value === undefined) {\n return undefined;\n }\n const list = typeof value === \"string\" ? [value] : value;\n if (!Array.isArray(list) || list.some((item) => typeof item !== \"string\")) {\n throw fail(`field \"${key}\" must be a string or an array of strings`);\n }\n const values = (list as string[]).filter((item) => item.length > 0);\n return values.length > 0 ? values : undefined;\n}\n\nfunction readJsonEntryRegexList(entry: JsonRecord, key: string, fail: (message: string) => PmCliError): string[] | undefined {\n const values = readJsonEntryStringList(entry, key, fail);\n if (!values) {\n return undefined;\n }\n for (const pattern of values) {\n try {\n new RegExp(pattern, \"m\");\n } catch (error: unknown) {\n throw fail(\n /* c8 ignore next -- RegExp only throws SyntaxError (an Error); String(error) fallback is defensive. */\n `field \"${key}\" includes invalid regex \"${pattern}\": ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n return values;\n}\n\nfunction readJsonEntryNumber(value: unknown, key: string, fail: (message: string) => PmCliError): number {\n const parsed =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\" && value.trim().length > 0\n ? Number(value.trim())\n : Number.NaN;\n if (typeof value === \"boolean\" || !Number.isFinite(parsed)) {\n throw fail(`field \"${key}\" must be a finite number (or numeric string)`);\n }\n return parsed;\n}\n\nfunction readJsonEntryTimeoutSeconds(entry: JsonRecord, fail: (message: string) => PmCliError): number | undefined {\n const timeoutSecondsRaw = entry.timeout_seconds;\n const timeoutAliasRaw = entry.timeout;\n if (timeoutSecondsRaw === undefined && timeoutAliasRaw === undefined) {\n return undefined;\n }\n const timeoutSeconds = timeoutSecondsRaw === undefined ? undefined : readJsonEntryNumber(timeoutSecondsRaw, \"timeout_seconds\", fail);\n const timeoutAlias = timeoutAliasRaw === undefined ? undefined : readJsonEntryNumber(timeoutAliasRaw, \"timeout\", fail);\n if (timeoutSeconds !== undefined && timeoutAlias !== undefined && timeoutSeconds !== timeoutAlias) {\n throw fail(\"timeout and timeout_seconds must match when both are provided\");\n }\n const timeout = timeoutSeconds ?? (timeoutAlias as number);\n if (!Number.isInteger(timeout) || timeout <= 0) {\n throw fail(\"timeout_seconds must be a positive integer\");\n }\n return timeout;\n}\n\nfunction readJsonEntryScope(entry: JsonRecord, fail: (message: string) => PmCliError): LinkScope {\n const value = readJsonEntryString(entry, \"scope\", fail);\n if (value === undefined) {\n return \"project\";\n }\n if (!(SCOPE_VALUES as readonly string[]).includes(value)) {\n throw fail(`field \"scope\" must be one of: ${SCOPE_VALUES.join(\", \")}`);\n }\n return value as LinkScope;\n}\n\nfunction readJsonEntryEnvSet(entry: JsonRecord, fail: (message: string) => PmCliError): Record<string, string> | undefined {\n if (!Object.hasOwn(entry, \"env_set\")) {\n return undefined;\n }\n const value = entry.env_set;\n if (value === undefined) {\n return undefined;\n }\n if (!isPlainObject(value)) {\n throw fail('field \"env_set\" must be a JSON object mapping environment names to string values');\n }\n const envSet: Record<string, string> = {};\n for (const [key, entryValue] of Object.entries(value)) {\n if (typeof entryValue !== \"string\") {\n throw fail(`field \"env_set\" value for \"${key}\" must be a string`);\n }\n if (!LINKED_TEST_ENV_NAME_PATTERN.test(key)) {\n throw fail(`field \"env_set\" key \"${key}\" is invalid`);\n }\n if (LINKED_TEST_PROTECTED_ENV_KEYS.has(key.toUpperCase())) {\n throw fail(`field \"env_set\" key \"${key}\" is reserved for sandbox safety`);\n }\n envSet[key] = entryValue;\n }\n return Object.keys(envSet).length > 0 ? envSet : undefined;\n}\n\nfunction readJsonEntryEnvClear(entry: JsonRecord, fail: (message: string) => PmCliError): string[] | undefined {\n const keys = readJsonEntryStringList(entry, \"env_clear\", fail);\n if (!keys) {\n return undefined;\n }\n for (const key of keys) {\n if (!LINKED_TEST_ENV_NAME_PATTERN.test(key)) {\n throw fail(`field \"env_clear\" key \"${key}\" is invalid`);\n }\n if (LINKED_TEST_PROTECTED_ENV_KEYS.has(key.toUpperCase())) {\n throw fail(`field \"env_clear\" key \"${key}\" is reserved for sandbox safety`);\n }\n }\n return keys;\n}\n\nfunction readJsonEntryBoolean(entry: JsonRecord, key: string, fail: (message: string) => PmCliError): boolean | undefined {\n if (!Object.hasOwn(entry, key)) {\n return undefined;\n }\n const value = entry[key];\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== \"boolean\") {\n throw fail(`field \"${key}\" must be a JSON boolean (true or false)`);\n }\n return value;\n}\n\nfunction readJsonEntryMinLines(entry: JsonRecord, fail: (message: string) => PmCliError): number | undefined {\n if (!Object.hasOwn(entry, \"assert_stdout_min_lines\")) {\n return undefined;\n }\n const value = entry.assert_stdout_min_lines;\n if (value === undefined) {\n return undefined;\n }\n const parsed = readJsonEntryNumber(value, \"assert_stdout_min_lines\", fail);\n if (!Number.isInteger(parsed) || parsed < 0) {\n throw fail('field \"assert_stdout_min_lines\" must be an integer >= 0');\n }\n return parsed;\n}\n\nfunction readJsonEntryEqualsMap(entry: JsonRecord, fail: (message: string) => PmCliError): Record<string, string> | undefined {\n if (!Object.hasOwn(entry, \"assert_json_field_equals\")) {\n return undefined;\n }\n const value = entry.assert_json_field_equals;\n if (value === undefined) {\n return undefined;\n }\n if (!isPlainObject(value)) {\n throw fail('field \"assert_json_field_equals\" must be a JSON object mapping field paths to expected values');\n }\n const values: Record<string, string> = {};\n for (const [key, entryValue] of Object.entries(value)) {\n if (key.trim().length === 0) {\n throw fail('field \"assert_json_field_equals\" keys must be non-empty field paths');\n }\n if (typeof entryValue !== \"string\" && typeof entryValue !== \"number\" && typeof entryValue !== \"boolean\") {\n throw fail(`field \"assert_json_field_equals\" value for \"${key}\" must be a string, number, or boolean`);\n }\n values[key] = String(entryValue);\n }\n return Object.keys(values).length > 0 ? values : undefined;\n}\n\nfunction readJsonEntryGteMap(entry: JsonRecord, fail: (message: string) => PmCliError): Record<string, number> | undefined {\n if (!Object.hasOwn(entry, \"assert_json_field_gte\")) {\n return undefined;\n }\n const value = entry.assert_json_field_gte;\n if (value === undefined) {\n return undefined;\n }\n if (!isPlainObject(value)) {\n throw fail('field \"assert_json_field_gte\" must be a JSON object mapping field paths to numeric minimums');\n }\n const values: Record<string, number> = {};\n for (const [key, entryValue] of Object.entries(value)) {\n if (key.trim().length === 0) {\n throw fail('field \"assert_json_field_gte\" keys must be non-empty field paths');\n }\n values[key] = readJsonEntryNumber(entryValue, `assert_json_field_gte.${key}`, fail);\n }\n return Object.keys(values).length > 0 ? values : undefined;\n}\n\nfunction parseLinkedTestJsonEntry(rawEntry: unknown, label: string, optionName: string): LinkedTest {\n const fail = (message: string): PmCliError => new PmCliError(`${optionName} ${label} ${message}`, EXIT_CODE.USAGE);\n if (!isPlainObject(rawEntry)) {\n throw fail(`must be a JSON object with linked-test fields. Allowed keys: ${STRUCTURED_LINKED_TEST_KEYS.join(\", \")}.`);\n }\n const entry = normalizeJsonEntryKeys(rawEntry, fail);\n const commandValue = readJsonEntryString(entry, \"command\", fail);\n const cmdAlias = readJsonEntryString(entry, \"cmd\", fail);\n if (commandValue !== undefined && cmdAlias !== undefined && commandValue !== cmdAlias) {\n throw fail(\"command and cmd must match when both are provided\");\n }\n const command = commandValue ?? cmdAlias;\n if (command === undefined || command.trim().length === 0) {\n throw fail('requires a non-empty \"command\" string');\n }\n const pathValue = readJsonEntryString(entry, \"path\", fail);\n const pmContextModeValue = readJsonEntryString(entry, \"pm_context_mode\", fail);\n if (pmContextModeValue !== undefined && !(LINKED_TEST_PM_CONTEXT_MODE_VALUES as readonly string[]).includes(pmContextModeValue)) {\n throw fail(`field \"pm_context_mode\" must be one of: ${LINKED_TEST_PM_CONTEXT_MODE_VALUES.join(\", \")}`);\n }\n const noteValue = readJsonEntryString(entry, \"note\", fail);\n return {\n command,\n path: pathValue !== undefined && pathValue.length > 0 ? pathValue : undefined,\n scope: readJsonEntryScope(entry, fail),\n timeout_seconds: readJsonEntryTimeoutSeconds(entry, fail),\n pm_context_mode: pmContextModeValue as LinkedTest[\"pm_context_mode\"],\n env_set: readJsonEntryEnvSet(entry, fail),\n env_clear: readJsonEntryEnvClear(entry, fail),\n shared_host_safe: readJsonEntryBoolean(entry, \"shared_host_safe\", fail),\n assert_stdout_contains: readJsonEntryStringList(entry, \"assert_stdout_contains\", fail),\n assert_stdout_regex: readJsonEntryRegexList(entry, \"assert_stdout_regex\", fail),\n assert_stderr_contains: readJsonEntryStringList(entry, \"assert_stderr_contains\", fail),\n assert_stderr_regex: readJsonEntryRegexList(entry, \"assert_stderr_regex\", fail),\n assert_stdout_min_lines: readJsonEntryMinLines(entry, fail),\n assert_json_field_equals: readJsonEntryEqualsMap(entry, fail),\n assert_json_field_gte: readJsonEntryGteMap(entry, fail),\n note: noteValue !== undefined && noteValue.trim().length > 0 ? noteValue.trim() : undefined,\n };\n}\n\n/**\n * Implements parse linked test json entries for the public runtime surface of this module.\n */\nexport function parseLinkedTestJsonEntries(raw: string, optionName: string): LinkedTest[] {\n const trimmed = raw.trim();\n if (trimmed.length === 0) {\n throw new PmCliError(\n `${optionName} requires a JSON object or array of objects describing linked-test entries`,\n EXIT_CODE.USAGE,\n );\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed) as unknown;\n } catch (error: unknown) {\n throw new PmCliError(\n /* c8 ignore next -- JSON.parse only throws SyntaxError (an Error); String(error) fallback is defensive. */\n `${optionName} value is not valid JSON: ${error instanceof Error ? error.message : String(error)}. Provide a JSON object or array of objects, e.g. '{\"command\":\"node scripts/check.js --flag value, with commas\",\"timeout_seconds\":120}'.`,\n EXIT_CODE.USAGE,\n );\n }\n const entries = Array.isArray(parsed) ? parsed : [parsed];\n if (entries.length === 0) {\n throw new PmCliError(`${optionName} array must include at least one linked-test entry object`, EXIT_CODE.USAGE);\n }\n return entries.map((entry, index) =>\n parseLinkedTestJsonEntry(entry, entries.length > 1 ? `entry ${index + 1}` : \"entry\", optionName),\n );\n}\n\nexport const _testOnlyLinkedTestParsers = {\n parseLinkedTestJsonEntry,\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAUO,IAAM,8BAA8B;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF,IAA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IAAI,SAAS,QAAQ,CAAC,KAAK,SAAS,UAAU,CAAC;AAEpG;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,160 @@
1
+ import {
2
+ collectUsedExtensionCapabilities,
3
+ normalizeExtensionName
4
+ } from "./chunk-5VVUKE3U.js";
5
+
6
+ // dist/core/extensions/activation-summary.js
7
+ !(function() {
8
+ try {
9
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
10
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "1c4b6114-ebdc-5cd5-8d51-5992b820af47");
11
+ } catch (e2) {
12
+ }
13
+ })();
14
+ var HOOK_REGISTRY_FIELD_TO_KIND = [
15
+ ["beforeCommand", "before_command"],
16
+ ["afterCommand", "after_command"],
17
+ ["onWrite", "on_write"],
18
+ ["onRead", "on_read"],
19
+ ["onIndex", "on_index"]
20
+ ];
21
+ function describeExtensionActivation(activation, options = {}) {
22
+ const filters = /* @__PURE__ */ new Set();
23
+ if (options.extensionName !== void 0) {
24
+ filters.add(normalizeExtensionName(options.extensionName));
25
+ }
26
+ for (const name of options.extensionNames ?? []) {
27
+ filters.add(normalizeExtensionName(name));
28
+ }
29
+ const matches = (name) => filters.size === 0 || filters.has(normalizeExtensionName(name));
30
+ const collect = (entries, identify) => sortUnique(entries.filter((entry) => matches(entry.name)).map(identify));
31
+ const collectFlat = (entries, expand) => sortUnique(entries.filter((entry) => matches(entry.name)).flatMap(expand));
32
+ const { registrations, commands, parsers, preflight, services, renderers, hooks } = activation;
33
+ return {
34
+ capabilities: collectUsedExtensionCapabilities(activation, options),
35
+ commands: collect(registrations.commands, (entry) => entry.command),
36
+ command_overrides: collect(commands.overrides, (entry) => entry.command),
37
+ command_handlers: collect(commands.handlers, (entry) => entry.command),
38
+ hooks: HOOK_REGISTRY_FIELD_TO_KIND.filter(([field]) => hooks[field].some((entry) => matches(entry.name))).map(([, kind]) => kind),
39
+ flag_commands: collect(registrations.flags, (entry) => entry.target_command),
40
+ item_types: collectFlat(registrations.item_types, (entry) => entry.types.map((type) => type.name)),
41
+ item_fields: collectFlat(registrations.item_fields, (entry) => entry.fields.map((field) => field.name)),
42
+ migrations: collectFlat(registrations.migrations, (entry) => typeof entry.definition.id === "string" ? [entry.definition.id] : []),
43
+ profiles: collect(registrations.profiles, (entry) => entry.profile.name),
44
+ importers: collect(registrations.importers, (entry) => entry.importer),
45
+ exporters: collect(registrations.exporters, (entry) => entry.exporter),
46
+ search_providers: collect(registrations.search_providers, (entry) => entry.definition.name),
47
+ vector_store_adapters: collect(registrations.vector_store_adapters, (entry) => entry.definition.name),
48
+ parser_overrides: collect(parsers.overrides, (entry) => entry.command),
49
+ service_overrides: collect(services.overrides, (entry) => entry.service),
50
+ renderer_overrides: collect(renderers.overrides, (entry) => entry.format),
51
+ preflight_overrides: preflight.overrides.filter((entry) => matches(entry.name)).length
52
+ };
53
+ }
54
+ function sortUnique(values) {
55
+ return [...new Set(values)].sort((left, right) => left.localeCompare(right));
56
+ }
57
+
58
+ // dist/core/extensions/activation-summary-markdown.js
59
+ !(function() {
60
+ try {
61
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
62
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b179b4ec-bec8-5761-b7d2-db8f7c8ed54a");
63
+ } catch (e2) {
64
+ }
65
+ })();
66
+ var MIN_HEADING_LEVEL = 1;
67
+ var MAX_HEADING_LEVEL = 6;
68
+ var SURFACE_SECTIONS = [
69
+ ["commands", "Commands"],
70
+ ["command_overrides", "Command overrides"],
71
+ ["flag_commands", "Flag commands"],
72
+ ["item_types", "Item types"],
73
+ ["item_fields", "Item fields"],
74
+ ["migrations", "Migrations"],
75
+ ["profiles", "Profiles"],
76
+ ["importers", "Importers"],
77
+ ["exporters", "Exporters"],
78
+ ["search_providers", "Search providers"],
79
+ ["vector_store_adapters", "Vector store adapters"],
80
+ ["hooks", "Lifecycle hooks"],
81
+ ["parser_overrides", "Parser overrides"],
82
+ ["service_overrides", "Service overrides"],
83
+ ["renderer_overrides", "Renderer overrides"]
84
+ ];
85
+ function headingPrefix(level) {
86
+ return "#".repeat(level);
87
+ }
88
+ function code(value) {
89
+ if (!value.includes("`")) {
90
+ return `\`${value}\``;
91
+ }
92
+ let longestRun = 0;
93
+ let currentRun = 0;
94
+ for (const char of value) {
95
+ currentRun = char === "`" ? currentRun + 1 : 0;
96
+ longestRun = Math.max(longestRun, currentRun);
97
+ }
98
+ const fence = "`".repeat(longestRun + 1);
99
+ const pad = value.startsWith("`") || value.endsWith("`") ? " " : "";
100
+ return `${fence}${pad}${value}${pad}${fence}`;
101
+ }
102
+ function renderCapabilitiesLine(capabilities) {
103
+ if (capabilities.length === 0) {
104
+ return "Capabilities: _none registered_";
105
+ }
106
+ return `Capabilities: ${capabilities.map(code).join(", ")}`;
107
+ }
108
+ function renderSection(heading, level, entries) {
109
+ const lines = [`${headingPrefix(level)} ${heading}`, ""];
110
+ if (entries.length === 0) {
111
+ lines.push("_None._", "");
112
+ return lines;
113
+ }
114
+ lines.push(...entries.map((entry) => `- ${code(entry)}`), "");
115
+ return lines;
116
+ }
117
+ function renderPreflightSection(count, level, includeEmpty) {
118
+ if (count === 0 && !includeEmpty) {
119
+ return [];
120
+ }
121
+ return [
122
+ `${headingPrefix(level)} Preflight overrides`,
123
+ "",
124
+ count > 0 ? `- ${count} registered (this surface carries no per-entry identifier)` : "_None._",
125
+ ""
126
+ ];
127
+ }
128
+ function renderExtensionSurfaceMarkdown(summary, options = {}) {
129
+ const titleLevel = options.headingLevel ?? 2;
130
+ if (!Number.isInteger(titleLevel) || titleLevel < MIN_HEADING_LEVEL || titleLevel > MAX_HEADING_LEVEL) {
131
+ throw new RangeError(`headingLevel must be an integer in [${MIN_HEADING_LEVEL}, ${MAX_HEADING_LEVEL}], received ${String(options.headingLevel)}`);
132
+ }
133
+ const sectionLevel = Math.min(titleLevel + 1, MAX_HEADING_LEVEL);
134
+ const includeEmpty = options.includeEmpty === true;
135
+ const title = options.title ?? "Extension surfaces";
136
+ const lines = [`${headingPrefix(titleLevel)} ${title}`, ""];
137
+ if (includeEmpty || summary.capabilities.length > 0) {
138
+ lines.push(renderCapabilitiesLine(summary.capabilities), "");
139
+ }
140
+ for (const [field, heading] of SURFACE_SECTIONS) {
141
+ const entries = summary[field];
142
+ if (entries.length === 0 && !includeEmpty) {
143
+ continue;
144
+ }
145
+ lines.push(...renderSection(heading, sectionLevel, entries));
146
+ }
147
+ lines.push(...renderPreflightSection(summary.preflight_overrides, sectionLevel, includeEmpty));
148
+ const hasAnySurface = summary.preflight_overrides > 0 || SURFACE_SECTIONS.some(([field]) => summary[field].length > 0);
149
+ if (!hasAnySurface && !includeEmpty) {
150
+ lines.push("_This extension registers no surfaces._", "");
151
+ }
152
+ return `${lines.join("\n").trimEnd()}
153
+ `;
154
+ }
155
+
156
+ export {
157
+ describeExtensionActivation,
158
+ renderExtensionSurfaceMarkdown
159
+ };
160
+ //# sourceMappingURL=chunk-C3PMDWGX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../core/extensions/activation-summary.ts", "../../../../../../../../core/extensions/activation-summary-markdown.ts"],
4
+ "sourcesContent": ["/**\n * @module core/extensions/activation-summary\n *\n * Enumerates *what* an extension activation registered, by name, in one pass.\n *\n * {@link ./extension-types.js#ExtensionActivationResult | `ExtensionActivationResult`}\n * already carries per-surface *counts* (`hook_counts`, `registration_counts`,\n * the various `*_count` fields), but answering \"what does this extension\n * register?\" otherwise means walking fifteen-plus sub-registries by hand\n * (`registrations.commands`/`flags`/`item_types`/`item_fields`/`migrations`/\n * `importers`/`exporters`/`search_providers`/`vector_store_adapters`,\n * `commands.overrides`/`handlers`, the `parsers`/`preflight`/`services`/\n * `renderers` override registries, and the five `hooks.*` arrays).\n *\n * {@link describeExtensionActivation} flattens all of them into one sorted,\n * deterministic {@link ExtensionActivationSummary} of identifiers — the\n * `describe` (enumerate-all) verb that complements the SDK's `assert*`\n * (verify-one) and `run*` (invoke-one) testing helpers. It serves two callers:\n *\n * - **Agents** get a single token-efficient view of an activation instead of\n * traversing every registry (\"project management = context management\").\n * - **Package authors** can assert their *entire* registration surface in one\n * `deepEqual` — a least-privilege \"I register exactly these surfaces and\n * nothing more\" check, the positive counterpart to\n * {@link ./capability-usage.js#reconcileExtensionCapabilityUsage}.\n */\nimport type {\n ExtensionActivationResult,\n ExtensionCapability,\n ExtensionHookRegistry,\n ExtensionServiceName,\n OutputRendererFormat,\n} from \"./extension-types.js\";\nimport { collectUsedExtensionCapabilities, normalizeExtensionName } from \"./capability-usage.js\";\n\n/**\n * Canonical lifecycle hook kinds paired with their {@link ExtensionHookRegistry}\n * field, ordered to match `ExtensionActivationResult.hook_counts` so a summary's\n * `hooks` list reads in the same stable order the runtime reports counts in.\n */\nconst HOOK_REGISTRY_FIELD_TO_KIND = [\n [\"beforeCommand\", \"before_command\"],\n [\"afterCommand\", \"after_command\"],\n [\"onWrite\", \"on_write\"],\n [\"onRead\", \"on_read\"],\n [\"onIndex\", \"on_index\"],\n] as const satisfies ReadonlyArray<readonly [keyof ExtensionHookRegistry, string]>;\n\n/**\n * Flat, name-level enumeration of every surface an activation registered.\n *\n * Arrays are de-duplicated for deterministic equality. Most are locale-sorted;\n * {@link ExtensionActivationSummary.hooks} is the exception — it is emitted in\n * canonical lifecycle order to mirror `ExtensionActivationResult.hook_counts`,\n * not alphabetically. The three command fields capture distinct dimensions and\n * can overlap: a command\n * registered via `api.registerCommand(definition)` appears in both\n * {@link ExtensionActivationSummary.commands} (its declared definition) and\n * {@link ExtensionActivationSummary.command_handlers} (its executable handler),\n * whereas a built-in command replaced via `api.registerCommand(name, override)`\n * appears only in {@link ExtensionActivationSummary.command_overrides}.\n */\nexport interface ExtensionActivationSummary {\n /** Known capabilities the registered surfaces exercise (sorted, de-duplicated). */\n capabilities: ExtensionCapability[];\n /** Full command paths declared via `registerCommand`'s definition form. */\n commands: string[];\n /** Built-in command paths replaced by an `registerCommand(name, override)` handler. */\n command_overrides: string[];\n /**\n * Full command paths backed by an extension-provided handler. A superset of\n * {@link ExtensionActivationSummary.commands} that also includes the\n * `<name> import`/`<name> export` paths synthesized for importers/exporters.\n */\n command_handlers: string[];\n /** Lifecycle hook kinds with at least one registered hook (canonical order). */\n hooks: string[];\n /** Command paths that received extension-registered flags. */\n flag_commands: string[];\n /** Custom item-type names registered via `registerItemTypes`. */\n item_types: string[];\n /** Custom front-matter field names registered via `registerItemFields`. */\n item_fields: string[];\n /** Schema migration ids registered via `registerMigration` (id-less migrations are omitted — they carry no identifier). */\n migrations: string[];\n /** Project profile names registered via `registerProfile`. */\n profiles: string[];\n /** Importer names registered via `registerImporter`. */\n importers: string[];\n /** Exporter names registered via `registerExporter`. */\n exporters: string[];\n /** Search-provider names registered via `registerSearchProvider`. */\n search_providers: string[];\n /** Vector-store adapter names registered via `registerVectorStoreAdapter`. */\n vector_store_adapters: string[];\n /** Command paths with a parser override registered via `registerParser`. */\n parser_overrides: string[];\n /** Built-in service names overridden via `registerService`. */\n service_overrides: ExtensionServiceName[];\n /** Output formats with a renderer override registered via `registerRenderer`. */\n renderer_overrides: OutputRendererFormat[];\n /**\n * Count of registered preflight overrides. The surface carries no per-entry\n * identifier, so this is a `number` rather than `string[]` — the only numeric\n * field in the summary.\n */\n preflight_overrides: number;\n}\n\n/**\n * Options for {@link describeExtensionActivation}.\n */\nexport interface DescribeExtensionActivationOptions {\n /**\n * Restrict the summary to a single extension by name. Names are matched\n * case-insensitively after trimming, mirroring\n * {@link ./capability-usage.js#collectUsedExtensionCapabilities}. Omit to\n * union across every extension in the activation result.\n */\n extensionName?: string;\n /**\n * Restrict the summary to a set of extension names. This supports package\n * aliases that resolve to multiple extensions while keeping the historical\n * single-name option intact.\n */\n extensionNames?: readonly string[];\n}\n\n/**\n * Summarize, by name, every registration surface an activation exercised.\n *\n * Walks the same sub-registries the loader populates and the capability\n * reconciler attributes, returning a flat {@link ExtensionActivationSummary}\n * whose arrays are sorted and de-duplicated. With\n * {@link DescribeExtensionActivationOptions.extensionName} only the matching\n * extension's registrations contribute (across both layers); without it the\n * summary unions every extension in the activation. Failed activations register\n * nothing, so they contribute only an empty summary.\n */\nexport function describeExtensionActivation(\n activation: ExtensionActivationResult,\n options: DescribeExtensionActivationOptions = {},\n): ExtensionActivationSummary {\n // Match both sides with the same normalizer collectUsedExtensionCapabilities\n // uses for the `capabilities` field below, so a filtered summary's named\n // surfaces and capabilities never disagree for a stored name with whitespace.\n const filters = new Set<string>();\n if (options.extensionName !== undefined) {\n filters.add(normalizeExtensionName(options.extensionName));\n }\n for (const name of options.extensionNames ?? []) {\n filters.add(normalizeExtensionName(name));\n }\n const matches = (name: string): boolean => filters.size === 0 || filters.has(normalizeExtensionName(name));\n const collect = <TEntry extends { name: string }, TValue extends string>(\n entries: readonly TEntry[],\n identify: (entry: TEntry) => TValue,\n ): TValue[] => sortUnique(entries.filter((entry) => matches(entry.name)).map(identify));\n const collectFlat = <TEntry extends { name: string }>(\n entries: readonly TEntry[],\n expand: (entry: TEntry) => readonly string[],\n ): string[] => sortUnique(entries.filter((entry) => matches(entry.name)).flatMap(expand));\n const { registrations, commands, parsers, preflight, services, renderers, hooks } = activation;\n return {\n capabilities: collectUsedExtensionCapabilities(activation, options),\n commands: collect(registrations.commands, (entry) => entry.command),\n command_overrides: collect(commands.overrides, (entry) => entry.command),\n command_handlers: collect(commands.handlers, (entry) => entry.command),\n hooks: HOOK_REGISTRY_FIELD_TO_KIND.filter(([field]) => hooks[field].some((entry) => matches(entry.name))).map(\n ([, kind]) => kind,\n ),\n flag_commands: collect(registrations.flags, (entry) => entry.target_command),\n item_types: collectFlat(registrations.item_types, (entry) => entry.types.map((type) => type.name)),\n item_fields: collectFlat(registrations.item_fields, (entry) => entry.fields.map((field) => field.name)),\n migrations: collectFlat(registrations.migrations, (entry) =>\n typeof entry.definition.id === \"string\" ? [entry.definition.id] : [],\n ),\n profiles: collect(registrations.profiles, (entry) => entry.profile.name),\n importers: collect(registrations.importers, (entry) => entry.importer),\n exporters: collect(registrations.exporters, (entry) => entry.exporter),\n search_providers: collect(registrations.search_providers, (entry) => entry.definition.name),\n vector_store_adapters: collect(registrations.vector_store_adapters, (entry) => entry.definition.name),\n parser_overrides: collect(parsers.overrides, (entry) => entry.command),\n service_overrides: collect(services.overrides, (entry) => entry.service),\n renderer_overrides: collect(renderers.overrides, (entry) => entry.format),\n preflight_overrides: preflight.overrides.filter((entry) => matches(entry.name)).length,\n };\n}\n\nfunction sortUnique<TValue extends string>(values: readonly TValue[]): TValue[] {\n return [...new Set(values)].sort((left, right) => left.localeCompare(right));\n}\n", "/**\n * @module core/extensions/activation-summary-markdown\n *\n * Renders an {@link ExtensionActivationSummary} to a deterministic Markdown\n * reference document — the *render* leg that completes the `describe`\n * (enumerate-all) verb.\n *\n * {@link ./activation-summary.js#describeExtensionActivation | `describeExtensionActivation`}\n * (and its author-time twin\n * {@link ../../sdk/compose.js#describeExtensionBlueprint | `describeExtensionBlueprint`})\n * already answer \"what does this package register?\" as a structured summary, and\n * the `assert*`/`run*` testing helpers verify and invoke each surface. What was\n * missing is a way to turn that summary into human-readable docs: package\n * authors hand-wrote the README \"commands & capabilities\" reference, which\n * silently drifted from the surface the loader actually registers.\n *\n * {@link renderExtensionSurfaceMarkdown} closes that gap. It is a pure,\n * dependency-free projection of the summary, so an author can pipe\n * `describeExtensionBlueprint(blueprint)` straight into it during their build or\n * test step and embed the result in their README — a reference that can never\n * drift from the registered surface (\"project management = context management\").\n * The CLI's `pm extension|package describe --markdown` composes the same\n * primitive across every loaded extension.\n */\nimport type { ExtensionActivationSummary } from \"./activation-summary.js\";\n\n/**\n * The lowest and highest ATX heading levels Markdown supports, used to validate\n * {@link ExtensionSurfaceMarkdownOptions.headingLevel} and to clamp nested\n * section headings so a deep title never emits an invalid `#######` run.\n */\nconst MIN_HEADING_LEVEL = 1;\nconst MAX_HEADING_LEVEL = 6;\n\n/**\n * Options for {@link renderExtensionSurfaceMarkdown}.\n */\nexport interface ExtensionSurfaceMarkdownOptions {\n /**\n * Heading text for the document title. Defaults to `\"Extension surfaces\"`.\n * The title always renders as an ATX heading at\n * {@link ExtensionSurfaceMarkdownOptions.headingLevel}; per-surface sections\n * render one level deeper.\n */\n title?: string;\n /**\n * ATX heading level for the title, an integer in `[1, 6]` (default `2`, i.e.\n * `##`, so the document embeds cleanly under a `# Package` README heading).\n * Section headings render at `headingLevel + 1`, clamped to `6`. Values\n * outside `[1, 6]` throw a {@link RangeError}.\n */\n headingLevel?: number;\n /**\n * When `true`, render every surface section even when it has no entries\n * (emitting `_None._` under the heading) and always emit the capabilities\n * line. Defaults to `false`, which omits empty sections so the reference lists\n * only what the package actually contributes.\n */\n includeEmpty?: boolean;\n}\n\n/**\n * A surface section paired with the {@link ExtensionActivationSummary} field\n * whose identifiers populate it. Ordered for an author-facing reference:\n * commands first, then schema, then importers/exporters, retrieval, lifecycle\n * hooks, and finally the override surfaces. {@link ExtensionActivationSummary.command_handlers}\n * is intentionally omitted — it is a documented superset of `commands` plus the\n * synthesized `<name> import`/`<name> export` paths already covered by the\n * Importers and Exporters sections, so rendering it would duplicate information.\n */\nconst SURFACE_SECTIONS = [\n [\"commands\", \"Commands\"],\n [\"command_overrides\", \"Command overrides\"],\n [\"flag_commands\", \"Flag commands\"],\n [\"item_types\", \"Item types\"],\n [\"item_fields\", \"Item fields\"],\n [\"migrations\", \"Migrations\"],\n [\"profiles\", \"Profiles\"],\n [\"importers\", \"Importers\"],\n [\"exporters\", \"Exporters\"],\n [\"search_providers\", \"Search providers\"],\n [\"vector_store_adapters\", \"Vector store adapters\"],\n [\"hooks\", \"Lifecycle hooks\"],\n [\"parser_overrides\", \"Parser overrides\"],\n [\"service_overrides\", \"Service overrides\"],\n [\"renderer_overrides\", \"Renderer overrides\"],\n] as const satisfies ReadonlyArray<\n readonly [\n {\n [K in keyof ExtensionActivationSummary]: ExtensionActivationSummary[K] extends readonly string[] ? K : never;\n }[keyof ExtensionActivationSummary],\n string,\n ]\n>;\n\n/**\n * Repeat `#` `level` times to form an ATX heading prefix.\n */\nfunction headingPrefix(level: number): string {\n return \"#\".repeat(level);\n}\n\n/**\n * Render `value` as an inline Markdown code span. Backslash escapes do not work\n * inside CommonMark code spans, so when `value` contains backticks the span is\n * delimited by a run of backticks one longer than the longest internal run, and\n * padded with a space when the value borders a backtick — the CommonMark rule\n * for embedding literal backticks in a code span.\n */\nfunction code(value: string): string {\n if (!value.includes(\"`\")) {\n return `\\`${value}\\``;\n }\n let longestRun = 0;\n let currentRun = 0;\n for (const char of value) {\n currentRun = char === \"`\" ? currentRun + 1 : 0;\n longestRun = Math.max(longestRun, currentRun);\n }\n const fence = \"`\".repeat(longestRun + 1);\n const pad = value.startsWith(\"`\") || value.endsWith(\"`\") ? \" \" : \"\";\n return `${fence}${pad}${value}${pad}${fence}`;\n}\n\n/**\n * Render the comma-separated capabilities summary line (or `_none registered_`\n * when the activation exercised no known capability).\n */\nfunction renderCapabilitiesLine(capabilities: readonly string[]): string {\n if (capabilities.length === 0) {\n return \"Capabilities: _none registered_\";\n }\n return `Capabilities: ${capabilities.map(code).join(\", \")}`;\n}\n\n/**\n * Render one surface section as `heading` + a bullet per identifier, or, when\n * `entries` is empty, `heading` + `_None._`. Callers decide whether an empty\n * section is rendered at all via {@link ExtensionSurfaceMarkdownOptions.includeEmpty}.\n */\nfunction renderSection(heading: string, level: number, entries: readonly string[]): string[] {\n const lines = [`${headingPrefix(level)} ${heading}`, \"\"];\n if (entries.length === 0) {\n lines.push(\"_None._\", \"\");\n return lines;\n }\n lines.push(...entries.map((entry) => `- ${code(entry)}`), \"\");\n return lines;\n}\n\n/**\n * Render the preflight-overrides section: a count line when any are registered,\n * `_None._` when {@link ExtensionSurfaceMarkdownOptions.includeEmpty} forces the\n * empty section, or no lines at all otherwise. Preflight overrides carry no\n * per-entry identifier, so they have a bespoke renderer rather than reusing\n * {@link renderSection}.\n */\nfunction renderPreflightSection(count: number, level: number, includeEmpty: boolean): string[] {\n if (count === 0 && !includeEmpty) {\n return [];\n }\n return [\n `${headingPrefix(level)} Preflight overrides`,\n \"\",\n count > 0 ? `- ${count} registered (this surface carries no per-entry identifier)` : \"_None._\",\n \"\",\n ];\n}\n\n/**\n * Render an {@link ExtensionActivationSummary} as a deterministic Markdown\n * reference document.\n *\n * The output is a title heading, a one-line capabilities summary, and a section\n * per registered surface (commands, overrides, flags, item types/fields,\n * migrations, importers/exporters, search providers, vector adapters, lifecycle\n * hooks, and the parser/service/renderer override surfaces), followed by a\n * preflight-override count line when any are registered. Section order and\n * within-section identifier order both come straight from the summary, so the\n * same summary always renders byte-for-byte the same document.\n *\n * By default empty sections are omitted so the reference lists only what the\n * package contributes; set {@link ExtensionSurfaceMarkdownOptions.includeEmpty}\n * to render every section. A summary with no surfaces at all renders the title,\n * the capabilities line, and a `_This extension registers no surfaces._` note.\n *\n * @throws {RangeError} when `options.headingLevel` is not an integer in `[1, 6]`.\n */\nexport function renderExtensionSurfaceMarkdown(\n summary: ExtensionActivationSummary,\n options: ExtensionSurfaceMarkdownOptions = {},\n): string {\n const titleLevel = options.headingLevel ?? 2;\n if (!Number.isInteger(titleLevel) || titleLevel < MIN_HEADING_LEVEL || titleLevel > MAX_HEADING_LEVEL) {\n throw new RangeError(\n `headingLevel must be an integer in [${MIN_HEADING_LEVEL}, ${MAX_HEADING_LEVEL}], received ${String(options.headingLevel)}`,\n );\n }\n const sectionLevel = Math.min(titleLevel + 1, MAX_HEADING_LEVEL);\n const includeEmpty = options.includeEmpty === true;\n const title = options.title ?? \"Extension surfaces\";\n\n const lines = [`${headingPrefix(titleLevel)} ${title}`, \"\"];\n if (includeEmpty || summary.capabilities.length > 0) {\n lines.push(renderCapabilitiesLine(summary.capabilities), \"\");\n }\n\n for (const [field, heading] of SURFACE_SECTIONS) {\n const entries = summary[field];\n if (entries.length === 0 && !includeEmpty) {\n continue;\n }\n lines.push(...renderSection(heading, sectionLevel, entries));\n }\n\n lines.push(...renderPreflightSection(summary.preflight_overrides, sectionLevel, includeEmpty));\n\n const hasAnySurface =\n summary.preflight_overrides > 0 || SURFACE_SECTIONS.some(([field]) => summary[field].length > 0);\n if (!hasAnySurface && !includeEmpty) {\n lines.push(\"_This extension registers no surfaces._\", \"\");\n }\n\n return `${lines.join(\"\\n\").trimEnd()}\\n`;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;AAwCA,IAAM,8BAA8B;EAClC,CAAC,iBAAiB,gBAAgB;EAClC,CAAC,gBAAgB,eAAe;EAChC,CAAC,WAAW,UAAU;EACtB,CAAC,UAAU,SAAS;EACpB,CAAC,WAAW,UAAU;;AA8FlB,SAAU,4BACd,YACA,UAA8C,CAAA,GAAE;AAKhD,QAAM,UAAU,oBAAI,IAAG;AACvB,MAAI,QAAQ,kBAAkB,QAAW;AACvC,YAAQ,IAAI,uBAAuB,QAAQ,aAAa,CAAC;EAC3D;AACA,aAAW,QAAQ,QAAQ,kBAAkB,CAAA,GAAI;AAC/C,YAAQ,IAAI,uBAAuB,IAAI,CAAC;EAC1C;AACA,QAAM,UAAU,CAAC,SAA0B,QAAQ,SAAS,KAAK,QAAQ,IAAI,uBAAuB,IAAI,CAAC;AACzG,QAAM,UAAU,CACd,SACA,aACa,WAAW,QAAQ,OAAO,CAAC,UAAU,QAAQ,MAAM,IAAI,CAAC,EAAE,IAAI,QAAQ,CAAC;AACtF,QAAM,cAAc,CAClB,SACA,WACa,WAAW,QAAQ,OAAO,CAAC,UAAU,QAAQ,MAAM,IAAI,CAAC,EAAE,QAAQ,MAAM,CAAC;AACxF,QAAM,EAAE,eAAe,UAAU,SAAS,WAAW,UAAU,WAAW,MAAK,IAAK;AACpF,SAAO;IACL,cAAc,iCAAiC,YAAY,OAAO;IAClE,UAAU,QAAQ,cAAc,UAAU,CAAC,UAAU,MAAM,OAAO;IAClE,m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AAK,GAAG,uBAAuB,QAAQ,qBAAqB,cAAc,YAAY,CAAC;AAE7F,QAAM,gBACJ,QAAQ,sBAAsB,KAAK,iBAAiB,KAAK,CAAC,CAAC,KAAK,MAAM,QAAQ,KAAK,EAAE,SAAS,CAAC;AACjG,MAAI,CAAC,iBAAiB,CAAC,cAAc;AACnC,UAAM,KAAK,2CAA2C,EAAE;EAC1D;AAEA,SAAO,GAAG,MAAM,KAAK,IAAI,EAAE,QAAO,CAAE;;AACtC;",
6
+ "names": []
7
+ }
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  hashDocument,
3
3
  toItemRecord
4
- } from "./chunk-6KRFL33E.js";
4
+ } from "./chunk-3U3VEWK6.js";
5
5
  import {
6
6
  canonicalDocument
7
- } from "./chunk-3W2HJKJX.js";
7
+ } from "./chunk-EZFKWSC7.js";
8
8
  import {
9
- FRONT_MATTER_KEY_ORDER,
10
9
  orderObject,
11
10
  sha256Hex,
12
11
  stableStringify
13
- } from "./chunk-KHVGM5CS.js";
12
+ } from "./chunk-P5YORJRH.js";
13
+ import {
14
+ FRONT_MATTER_KEY_ORDER
15
+ } from "./chunk-5VVUKE3U.js";
14
16
 
15
17
  // dist/core/history/replay.js
16
18
  import jsonPatch from "fast-json-patch";
@@ -238,4 +240,4 @@ export {
238
240
  reanchorHistoryEntries,
239
241
  historyEntriesToRaw
240
242
  };
241
- //# sourceMappingURL=chunk-T4XBKJ3F.js.map
243
+ //# sourceMappingURL=chunk-D3UCE7RW.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../core/history/replay.ts"],
4
4
  "sourcesContent": ["/**\n * @module core/history/replay\n *\n * Implements append-only history and replay behavior for Replay.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { FRONT_MATTER_KEY_ORDER } from \"../shared/constants.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport { orderObject, sha256Hex, stableStringify } from \"../shared/serialization.js\";\nimport { hashDocument } from \"./history.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\n\n/**\n * Shared history replay/patch mechanics single-sourced for the history, restore,\n * history-redact, and history-repair commands plus the health/validate drift checks.\n *\n * Each command keeps its own thin error-formatting wrapper so the exact CLI error\n * contracts (restore's rich patch-failure context, redact's op tag, history's\n * generic message) are preserved; only the underlying replay/patch logic is shared.\n */\n\nexport interface ReplayDocument {\n metadata: Record<string, unknown>;\n body: string;\n}\n\nexport const EMPTY_REPLAY_DOCUMENT: ReplayDocument = {\n metadata: {},\n body: \"\",\n};\n\n/**\n * Implements clone empty replay document for the public runtime surface of this module.\n */\nexport function cloneEmptyReplayDocument(): ReplayDocument {\n return structuredClone(EMPTY_REPLAY_DOCUMENT);\n}\n\n/**\n * Implements replay hash for the public runtime surface of this module.\n */\nexport function replayHash(document: ReplayDocument): string {\n try {\n return hashDocument(replayToItemDocument(document));\n } catch {\n // Legacy/malformed replay states (for example a stream whose first entry never\n // established a full `create` document, so the canonicalizer cannot normalize it)\n // cannot be canonically hashed. Fall back to a deterministic structural hash so\n // re-anchor and verification stay internally consistent for these streams. Fully\n // formed documents always take the canonical path above, so valid streams are\n // unaffected.\n return sha256Hex(stableStringify({ replay_fallback: true, metadata: document.metadata, body: document.body }));\n }\n}\n\n/**\n * Implements replay to item document for the public runtime surface of this module.\n */\nexport function replayToItemDocument(document: ReplayDocument): ItemDocument {\n return {\n metadata: document.metadata as ItemMetadata,\n body: document.body,\n };\n}\n\n/**\n * Converts a materialized replay document into a canonical item document. Use\n * this when callers have already rejected the empty/deleted replay state and\n * need restored metadata validated through the normal front-matter rules.\n */\nexport function replayToCanonicalItemDocument(\n document: ReplayDocument,\n options: Parameters<typeof canonicalDocument>[1] = {},\n): ItemDocument {\n return canonicalDocument(replayToItemDocument(document), options);\n}\n\n/**\n * Canonicalize an item document into the ordered replay form used when comparing\n * a replayed chain against the on-disk item (restore + history-repair reconciliation).\n */\nexport function toReplayDocument(document: ItemDocument): ReplayDocument {\n if (!document.metadata || Object.keys(document.metadata).length === 0) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n return {\n metadata: orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER),\n body: canonical.body,\n };\n}\n\n/**\n * Implements normalize replay patch path for the public runtime surface of this module.\n */\nexport function normalizeReplayPatchPath(path: string): string {\n if (path === \"/front_matter\") {\n return \"/metadata\";\n }\n if (path.startsWith(\"/front_matter/\")) {\n return `/metadata/${path.slice(\"/front_matter/\".length)}`;\n }\n return path;\n}\n\nfunction isHistoryPatchOp(value: unknown): value is HistoryPatchOp {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { op?: unknown }).op === \"string\" &&\n typeof (value as { path?: unknown }).path === \"string\"\n );\n}\n\n/**\n * Implements normalize replay patch ops for the public runtime surface of this module.\n */\nexport function normalizeReplayPatchOps(patch: HistoryPatchOp[] | unknown): HistoryPatchOp[] {\n if (!Array.isArray(patch)) {\n return [];\n }\n return patch.filter(isHistoryPatchOp).map((operation) => ({\n ...operation,\n path: normalizeReplayPatchPath(operation.path),\n from: typeof operation.from === \"string\" ? normalizeReplayPatchPath(operation.from) : undefined,\n }));\n}\n\nfunction isReplayDocumentShape(value: unknown): value is { metadata: Record<string, unknown>; body: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"metadata\" in value &&\n \"body\" in value &&\n typeof (value as { body: unknown }).body === \"string\" &&\n typeof (value as { metadata: unknown }).metadata === \"object\" &&\n (value as { metadata: unknown }).metadata !== null\n );\n}\n\n/**\n * Restricts replay apply result values accepted by command, SDK, and storage contracts.\n */\nexport type ReplayApplyResult =\n | { ok: true; document: ReplayDocument }\n | { ok: false; error: unknown };\n\n/**\n * Strictly apply a history patch (front_matter->metadata normalized) to a replay\n * document. Returns a result envelope rather than throwing so each caller can\n * format its own error contract.\n */\nexport function tryApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): ReplayApplyResult {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (!isReplayDocumentShape(applied)) {\n return { ok: false, error: new Error(\"history_replay_invalid_document_shape\") };\n }\n return { ok: true, document: { metadata: applied.metadata, body: applied.body } };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/**\n * Deterministically verify a history chain: each entry's before_hash must equal\n * the prior replayed after_hash, the patch must strictly apply, and the recorded\n * after_hash must equal the replayed result.\n */\nexport function verifyHistoryChain(entries: HistoryEntry[]): { ok: boolean; errors: string[] } {\n let replay = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n return {\n ok: false,\n errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],\n };\n }\n const applied = tryApplyReplayPatch(replay, entry.patch);\n if (!applied.ok) {\n return {\n ok: false,\n errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],\n };\n }\n replay = applied.document;\n if (replayHash(replay) !== entry.after_hash) {\n return {\n ok: false,\n errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],\n };\n }\n }\n return { ok: true, errors: [] };\n}\n\n/**\n * Documents the lenient apply result payload exchanged by command, SDK, and package integrations.\n */\nexport interface LenientApplyResult {\n document: ReplayDocument;\n convertedReplaceToAdd: number;\n skippedOps: number;\n}\n\nfunction tryApplySingleOp(document: unknown, op: HistoryPatchOp): { ok: true; document: unknown } | { ok: false } {\n try {\n const applied = jsonPatch.applyPatch(\n structuredClone(document),\n [op as jsonPatch.Operation],\n true,\n false,\n ).newDocument as unknown;\n return { ok: true, document: applied };\n } catch {\n return { ok: false };\n }\n}\n\n/**\n * Apply a legacy patch op-by-op, recovering from drift that strict replay rejects:\n * a `replace` whose path no longer exists is retried as `add`, and any op that\n * still cannot apply against the current replay state is skipped. The resulting\n * document is what the repaired entry's recomputed patch should target.\n */\nexport function lenientApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): LenientApplyResult {\n let working: unknown = structuredClone(current);\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (const op of normalizeReplayPatchOps(patch)) {\n const direct = tryApplySingleOp(working, op);\n if (direct.ok) {\n working = direct.document;\n continue;\n }\n if (op.op === \"replace\") {\n const asAdd = tryApplySingleOp(working, { ...op, op: \"add\" });\n if (asAdd.ok) {\n working = asAdd.document;\n convertedReplaceToAdd += 1;\n continue;\n }\n }\n skippedOps += 1;\n }\n\n const candidate = working as { metadata?: unknown; body?: unknown };\n const document: ReplayDocument = {\n metadata:\n typeof candidate.metadata === \"object\" && candidate.metadata !== null\n ? (candidate.metadata as Record<string, unknown>)\n : {},\n body: typeof candidate.body === \"string\" ? candidate.body : current.body,\n };\n return { document, convertedReplaceToAdd, skippedOps };\n}\n\n/**\n * Documents the reanchor entry detail payload exchanged by command, SDK, and package integrations.\n */\nexport interface ReanchorEntryDetail {\n index: number;\n rehashed: boolean;\n patch_repaired: boolean;\n converted_replace_to_add: number;\n skipped_ops: number;\n}\n\n/**\n * Documents the reanchor result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ReanchorResult {\n entries: HistoryEntry[];\n finalDocument: ReplayDocument;\n entriesRehashed: number;\n entriesPatchRepaired: number;\n convertedReplaceToAdd: number;\n skippedOps: number;\n details: ReanchorEntryDetail[];\n}\n\n/**\n * Re-anchor a drifted history chain: replay every entry from empty, recompute the\n * before/after hashes, and only rewrite a patch when the original op set no longer\n * strictly applies (legacy drift). Clean entries keep their patch verbatim so the\n * on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain.\n */\nexport function reanchorHistoryEntries(entries: HistoryEntry[]): ReanchorResult {\n let replay = cloneEmptyReplayDocument();\n const rewritten: HistoryEntry[] = [];\n const details: ReanchorEntryDetail[] = [];\n let entriesRehashed = 0;\n let entriesPatchRepaired = 0;\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n const beforeHash = replayHash(replay);\n const strict = tryApplyReplayPatch(replay, entry.patch);\n\n let next: ReplayDocument;\n let outPatch: HistoryPatchOp[];\n let patchRepaired = false;\n let entryConverted = 0;\n let entrySkipped = 0;\n\n if (strict.ok) {\n next = strict.document;\n outPatch = entry.patch;\n } else {\n const lenient = lenientApplyReplayPatch(replay, entry.patch);\n next = lenient.document;\n outPatch = jsonPatch.compare(replay, next) as HistoryPatchOp[];\n patchRepaired = true;\n entryConverted = lenient.convertedReplaceToAdd;\n entrySkipped = lenient.skippedOps;\n convertedReplaceToAdd += entryConverted;\n skippedOps += entrySkipped;\n entriesPatchRepaired += 1;\n }\n\n const afterHash = replayHash(next);\n const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;\n if (rehashed) {\n entriesRehashed += 1;\n }\n\n rewritten.push({\n ...entry,\n patch: outPatch,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n details.push({\n index: index + 1,\n rehashed,\n patch_repaired: patchRepaired,\n converted_replace_to_add: entryConverted,\n skipped_ops: entrySkipped,\n });\n replay = next;\n }\n\n return {\n entries: rewritten,\n finalDocument: replay,\n entriesRehashed,\n entriesPatchRepaired,\n convertedReplaceToAdd,\n skippedOps,\n details,\n };\n}\n\n/**\n * Implements history entries to raw for the public runtime surface of this module.\n */\nexport function historyEntriesToRaw(entries: HistoryEntry[]): string {\n if (entries.length === 0) {\n return \"\";\n }\n return `${entries.map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;AAKA,OAAO,eAAe;;;;;;;;AAsBf,IAAM,wBAAwC;EACnD,UAAU,CAAA;EACV,MAAM;;AAMF,SAAU,2BAAwB;AACtC,SAAO,gBAAgB,qBAAqB;AAC9C;AAKM,SAAU,WAAW,UAAwB;AACjD,MAAI;AACF,WAAO,a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