@unbrained/pm-cli 2026.7.6 → 2026.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (666) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cli/commands/annotation-command.d.ts +1 -0
  3. package/dist/cli/commands/annotation-command.js +29 -2
  4. package/dist/cli/commands/annotation-command.js.map +1 -1
  5. package/dist/cli/commands/comments.js +3 -4
  6. package/dist/cli/commands/comments.js.map +1 -1
  7. package/dist/cli/commands/extension/bundled-catalog.d.ts +3 -0
  8. package/dist/cli/commands/extension/bundled-catalog.js +38 -28
  9. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  10. package/dist/cli/commands/extension/install-sources.js +81 -18
  11. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  12. package/dist/cli/commands/health.js +9 -5
  13. package/dist/cli/commands/health.js.map +1 -1
  14. package/dist/cli/commands/learnings.js +5 -3
  15. package/dist/cli/commands/learnings.js.map +1 -1
  16. package/dist/cli/commands/notes.js +5 -3
  17. package/dist/cli/commands/notes.js.map +1 -1
  18. package/dist/cli/commands/reindex.js +4 -3
  19. package/dist/cli/commands/reindex.js.map +1 -1
  20. package/dist/cli/commands/search.js +3 -3
  21. package/dist/cli/commands/search.js.map +1 -1
  22. package/dist/cli/commands/test.d.ts +9 -0
  23. package/dist/cli/commands/test.js +144 -105
  24. package/dist/cli/commands/test.js.map +1 -1
  25. package/dist/cli/extension-command-help.js +10 -2
  26. package/dist/cli/extension-command-help.js.map +1 -1
  27. package/dist/cli/register-list-query.d.ts +1 -1
  28. package/dist/cli/register-list-query.js +18 -27
  29. package/dist/cli/register-list-query.js.map +1 -1
  30. package/dist/cli/register-operations.d.ts +0 -8
  31. package/dist/cli/register-operations.js +41 -46
  32. package/dist/cli/register-operations.js.map +1 -1
  33. package/dist/cli/register-setup.js +113 -13
  34. package/dist/cli/register-setup.js.map +1 -1
  35. package/dist/cli/registration-helpers.d.ts +5 -1
  36. package/dist/cli/registration-helpers.js +14 -2
  37. package/dist/cli/registration-helpers.js.map +1 -1
  38. package/dist/cli-bundle/chunks/append-F7WPGIQL.js +11 -0
  39. package/dist/cli-bundle/chunks/{gc-2DNMPXMC.js → append-PVCTBVJG.js} +8 -9
  40. package/dist/cli-bundle/chunks/{chunk-EGAP5OWD.js → chunk-2APXX4TZ.js} +16 -14
  41. package/dist/cli-bundle/chunks/chunk-2APXX4TZ.js.map +1 -0
  42. package/dist/cli-bundle/chunks/{chunk-R5BMJX33.js → chunk-2LEJGRQ7.js} +2 -2
  43. package/dist/cli-bundle/chunks/{chunk-AZYGZGGI.js → chunk-2TILG6F2.js} +3 -3
  44. package/dist/cli-bundle/chunks/{chunk-SMB7RV23.js → chunk-3G6UMXT3.js} +6 -8
  45. package/dist/cli-bundle/chunks/{chunk-SMB7RV23.js.map → chunk-3G6UMXT3.js.map} +1 -1
  46. package/dist/cli-bundle/chunks/{chunk-GJ7QC5DJ.js → chunk-3TYOW6RR.js} +8 -8
  47. package/dist/cli-bundle/chunks/{chunk-B6DUFX6H.js → chunk-3X542TEY.js} +7 -7
  48. package/dist/cli-bundle/chunks/{chunk-B6XS3R3O.js → chunk-42LXP4VO.js} +12 -16
  49. package/dist/cli-bundle/chunks/{chunk-B6XS3R3O.js.map → chunk-42LXP4VO.js.map} +1 -1
  50. package/dist/cli-bundle/chunks/{chunk-CL36D4PC.js → chunk-43SIHQND.js} +36 -15
  51. package/dist/cli-bundle/chunks/chunk-43SIHQND.js.map +7 -0
  52. package/dist/cli-bundle/chunks/{chunk-7D7OOEYG.js → chunk-43UQN754.js} +10 -14
  53. package/dist/cli-bundle/chunks/{chunk-7D7OOEYG.js.map → chunk-43UQN754.js.map} +1 -1
  54. package/dist/cli-bundle/chunks/{chunk-ALFPSEWO.js → chunk-43YSKY75.js} +4 -6
  55. package/dist/cli-bundle/chunks/{chunk-ALFPSEWO.js.map → chunk-43YSKY75.js.map} +1 -1
  56. package/dist/cli-bundle/chunks/{chunk-NO442GWJ.js → chunk-4BKDAEDF.js} +5 -5
  57. package/dist/cli-bundle/chunks/{chunk-NO442GWJ.js.map → chunk-4BKDAEDF.js.map} +2 -2
  58. package/dist/cli-bundle/chunks/{chunk-4LELACOL.js → chunk-4IQKDKGE.js} +15 -23
  59. package/dist/cli-bundle/chunks/{chunk-4LELACOL.js.map → chunk-4IQKDKGE.js.map} +1 -1
  60. package/dist/cli-bundle/chunks/{chunk-F3K4JGFD.js → chunk-4MZOKTI2.js} +6 -8
  61. package/dist/cli-bundle/chunks/{chunk-F3K4JGFD.js.map → chunk-4MZOKTI2.js.map} +1 -1
  62. package/dist/cli-bundle/chunks/{chunk-D2XRLB55.js → chunk-52NS7JDP.js} +14 -20
  63. package/dist/cli-bundle/chunks/{chunk-D2XRLB55.js.map → chunk-52NS7JDP.js.map} +1 -1
  64. package/dist/cli-bundle/chunks/{chunk-IX5BXEMX.js → chunk-565WYS5W.js} +12 -16
  65. package/dist/cli-bundle/chunks/{chunk-IX5BXEMX.js.map → chunk-565WYS5W.js.map} +1 -1
  66. package/dist/cli-bundle/chunks/{chunk-UH7T2DAX.js → chunk-5FIQ4EX3.js} +12 -18
  67. package/dist/cli-bundle/chunks/{chunk-UH7T2DAX.js.map → chunk-5FIQ4EX3.js.map} +1 -1
  68. package/dist/cli-bundle/chunks/{chunk-DMRNBQOI.js → chunk-6G6O3OPQ.js} +256 -36
  69. package/dist/cli-bundle/chunks/chunk-6G6O3OPQ.js.map +1 -0
  70. package/dist/cli-bundle/chunks/{chunk-G64OCSKU.js → chunk-6LCJRGPD.js} +9 -13
  71. package/dist/cli-bundle/chunks/{chunk-G64OCSKU.js.map → chunk-6LCJRGPD.js.map} +1 -1
  72. package/dist/cli-bundle/chunks/{chunk-7WBAJSS6.js → chunk-6UQCNWFV.js} +6 -8
  73. package/dist/cli-bundle/chunks/{chunk-7WBAJSS6.js.map → chunk-6UQCNWFV.js.map} +1 -1
  74. package/dist/cli-bundle/chunks/{chunk-ZSUS2OD3.js → chunk-6XTSYPPO.js} +1216 -387
  75. package/dist/cli-bundle/chunks/chunk-6XTSYPPO.js.map +7 -0
  76. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js +5434 -0
  77. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js.map +1 -0
  78. package/dist/cli-bundle/chunks/{chunk-ZZD4J5XY.js → chunk-7PNQA24K.js} +30 -36
  79. package/dist/cli-bundle/chunks/{chunk-ZZD4J5XY.js.map → chunk-7PNQA24K.js.map} +1 -1
  80. package/dist/cli-bundle/chunks/{chunk-JJP45OEI.js → chunk-7VQ3JJN5.js} +2 -2
  81. package/dist/cli-bundle/chunks/{chunk-OGWQ2IEP.js → chunk-7Y5N34HX.js} +8 -12
  82. package/dist/cli-bundle/chunks/{chunk-OGWQ2IEP.js.map → chunk-7Y5N34HX.js.map} +1 -1
  83. package/dist/cli-bundle/chunks/{chunk-MWMVPCIE.js → chunk-AGAVEDIE.js} +7 -7
  84. package/dist/cli-bundle/chunks/{chunk-22KBU3MW.js → chunk-AJUON7E6.js} +3 -3
  85. package/dist/cli-bundle/chunks/{chunk-ZJ262CED.js → chunk-ARKHKYYS.js} +13 -21
  86. package/dist/cli-bundle/chunks/{chunk-ZJ262CED.js.map → chunk-ARKHKYYS.js.map} +1 -1
  87. package/dist/cli-bundle/chunks/{chunk-46CUF5L6.js → chunk-C5ACVMOI.js} +99 -51
  88. package/dist/cli-bundle/chunks/chunk-C5ACVMOI.js.map +7 -0
  89. package/dist/cli-bundle/chunks/{chunk-LPSSSDJR.js → chunk-CJQM7O7R.js} +16 -20
  90. package/dist/cli-bundle/chunks/{chunk-LPSSSDJR.js.map → chunk-CJQM7O7R.js.map} +1 -1
  91. package/dist/cli-bundle/chunks/{chunk-GBAX2ZAQ.js → chunk-D2DCTFTL.js} +10 -12
  92. package/dist/cli-bundle/chunks/{chunk-GBAX2ZAQ.js.map → chunk-D2DCTFTL.js.map} +1 -1
  93. package/dist/cli-bundle/chunks/{chunk-XHET7YUZ.js → chunk-DDDWVPID.js} +8 -10
  94. package/dist/cli-bundle/chunks/{chunk-XHET7YUZ.js.map → chunk-DDDWVPID.js.map} +1 -1
  95. package/dist/cli-bundle/chunks/{chunk-HIHMT6WS.js → chunk-DG6BSXZ7.js} +5 -5
  96. package/dist/cli-bundle/chunks/{chunk-HIHMT6WS.js.map → chunk-DG6BSXZ7.js.map} +2 -2
  97. package/dist/cli-bundle/chunks/{chunk-IWVU4C2F.js → chunk-DR2V5OIV.js} +3 -3
  98. package/dist/cli-bundle/chunks/{chunk-ZGK4L4JM.js → chunk-E3LWJUGF.js} +4 -6
  99. package/dist/cli-bundle/chunks/{chunk-ZGK4L4JM.js.map → chunk-E3LWJUGF.js.map} +1 -1
  100. package/dist/cli-bundle/chunks/{chunk-XUC7PI2H.js → chunk-E3YQFSFE.js} +6 -10
  101. package/dist/cli-bundle/chunks/{chunk-XUC7PI2H.js.map → chunk-E3YQFSFE.js.map} +1 -1
  102. package/dist/cli-bundle/chunks/{chunk-XG625QP4.js → chunk-EDO7VXSO.js} +2 -2
  103. package/dist/cli-bundle/chunks/{chunk-MA4SM3QZ.js → chunk-EIUBK2LT.js} +12 -18
  104. package/dist/cli-bundle/chunks/{chunk-MA4SM3QZ.js.map → chunk-EIUBK2LT.js.map} +1 -1
  105. package/dist/cli-bundle/chunks/{chunk-YN7Y6DQZ.js → chunk-EMXPI36L.js} +14 -20
  106. package/dist/cli-bundle/chunks/{chunk-YN7Y6DQZ.js.map → chunk-EMXPI36L.js.map} +1 -1
  107. package/dist/cli-bundle/chunks/{chunk-MLIYFOE7.js → chunk-EOUVR7JN.js} +12 -8
  108. package/dist/cli-bundle/chunks/chunk-EOUVR7JN.js.map +1 -0
  109. package/dist/cli-bundle/chunks/{chunk-Y4M7CPQP.js → chunk-EVEPHNXJ.js} +4 -4
  110. package/dist/cli-bundle/chunks/{chunk-M7JNBQAD.js → chunk-F6MT7KKE.js} +4 -6
  111. package/dist/cli-bundle/chunks/{chunk-M7JNBQAD.js.map → chunk-F6MT7KKE.js.map} +1 -1
  112. package/dist/cli-bundle/chunks/{chunk-W3DSJQIO.js → chunk-F6YC2A6X.js} +7 -11
  113. package/dist/cli-bundle/chunks/{chunk-W3DSJQIO.js.map → chunk-F6YC2A6X.js.map} +1 -1
  114. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js +5514 -0
  115. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-JDDLOQAE.js → chunk-FN6SB4HU.js} +2 -2
  117. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js +5359 -0
  118. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js.map +1 -0
  119. package/dist/cli-bundle/chunks/{chunk-EKFNL33R.js → chunk-GLS6VMWI.js} +37 -16
  120. package/dist/cli-bundle/chunks/chunk-GLS6VMWI.js.map +1 -0
  121. package/dist/cli-bundle/chunks/{chunk-HOVCGJSD.js → chunk-GPIDUMMN.js} +9 -11
  122. package/dist/cli-bundle/chunks/{chunk-HOVCGJSD.js.map → chunk-GPIDUMMN.js.map} +1 -1
  123. package/dist/cli-bundle/chunks/{chunk-SQOIV3OQ.js → chunk-GTM5HQL4.js} +11 -15
  124. package/dist/cli-bundle/chunks/{chunk-SQOIV3OQ.js.map → chunk-GTM5HQL4.js.map} +1 -1
  125. package/dist/cli-bundle/chunks/{chunk-24YG75HI.js → chunk-H2SMKL2N.js} +8 -8
  126. package/dist/cli-bundle/chunks/{chunk-QLMX7SRD.js → chunk-HHEWQXPD.js} +6 -6
  127. package/dist/cli-bundle/chunks/chunk-HHEWQXPD.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-EGY6JBQ3.js → chunk-HX6QXV5P.js} +2 -2
  129. package/dist/cli-bundle/chunks/{chunk-4ZBE5GUN.js → chunk-I74FMIWA.js} +10 -16
  130. package/dist/cli-bundle/chunks/{chunk-4ZBE5GUN.js.map → chunk-I74FMIWA.js.map} +1 -1
  131. package/dist/cli-bundle/chunks/{chunk-3N6RRO2Q.js → chunk-IDIBF4E2.js} +20 -24
  132. package/dist/cli-bundle/chunks/{chunk-3N6RRO2Q.js.map → chunk-IDIBF4E2.js.map} +1 -1
  133. package/dist/cli-bundle/chunks/{chunk-6QBJLYBP.js → chunk-II7R6KD4.js} +8 -7
  134. package/dist/cli-bundle/chunks/{chunk-6QBJLYBP.js.map → chunk-II7R6KD4.js.map} +1 -1
  135. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js +10320 -0
  136. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js.map +1 -0
  137. package/dist/cli-bundle/chunks/{chunk-FT3QTERD.js → chunk-J7BOLHAV.js} +5 -7
  138. package/dist/cli-bundle/chunks/{chunk-FT3QTERD.js.map → chunk-J7BOLHAV.js.map} +1 -1
  139. package/dist/cli-bundle/chunks/{chunk-GANUTS7W.js → chunk-KTGJ2CBU.js} +4 -6
  140. package/dist/cli-bundle/chunks/{chunk-GANUTS7W.js.map → chunk-KTGJ2CBU.js.map} +1 -1
  141. package/dist/cli-bundle/chunks/{chunk-LK6XLOGP.js → chunk-LCFJ7XAM.js} +22 -2
  142. package/dist/cli-bundle/chunks/{chunk-LK6XLOGP.js.map → chunk-LCFJ7XAM.js.map} +3 -3
  143. package/dist/cli-bundle/chunks/{chunk-3UJRFJ5R.js → chunk-LZQU6XJG.js} +28 -34
  144. package/dist/cli-bundle/chunks/{chunk-3UJRFJ5R.js.map → chunk-LZQU6XJG.js.map} +1 -1
  145. package/dist/cli-bundle/chunks/{chunk-L5PSPMZ4.js → chunk-M62RO3XK.js} +10 -14
  146. package/dist/cli-bundle/chunks/{chunk-L5PSPMZ4.js.map → chunk-M62RO3XK.js.map} +1 -1
  147. package/dist/cli-bundle/chunks/{chunk-CFB33L7W.js → chunk-MCEUKJKW.js} +12 -14
  148. package/dist/cli-bundle/chunks/{chunk-CFB33L7W.js.map → chunk-MCEUKJKW.js.map} +1 -1
  149. package/dist/cli-bundle/chunks/{chunk-TKD5VCTD.js → chunk-MHNMCDWR.js} +343 -195
  150. package/dist/cli-bundle/chunks/chunk-MHNMCDWR.js.map +1 -0
  151. package/dist/cli-bundle/chunks/{chunk-O6AWCQRQ.js → chunk-MRFWUSVA.js} +4 -6
  152. package/dist/cli-bundle/chunks/{chunk-O6AWCQRQ.js.map → chunk-MRFWUSVA.js.map} +1 -1
  153. package/dist/cli-bundle/chunks/{chunk-SQYJ4HF2.js → chunk-N6ZHDLUY.js} +6 -8
  154. package/dist/cli-bundle/chunks/{chunk-SQYJ4HF2.js.map → chunk-N6ZHDLUY.js.map} +1 -1
  155. package/dist/cli-bundle/chunks/{chunk-ZWBEPGD7.js → chunk-NWWL22C7.js} +7 -9
  156. package/dist/cli-bundle/chunks/{chunk-ZWBEPGD7.js.map → chunk-NWWL22C7.js.map} +1 -1
  157. package/dist/cli-bundle/chunks/{chunk-Y46GD4IX.js → chunk-P3MJJW7P.js} +2 -2
  158. package/dist/cli-bundle/chunks/{chunk-MVYWGY2A.js → chunk-PDXJXEZJ.js} +2 -2
  159. package/dist/cli-bundle/chunks/{chunk-SGMFPXKR.js → chunk-Q64AYQYW.js} +10 -12
  160. package/dist/cli-bundle/chunks/{chunk-SGMFPXKR.js.map → chunk-Q64AYQYW.js.map} +1 -1
  161. package/dist/cli-bundle/chunks/{chunk-EBRZZ54H.js → chunk-QDABF2RB.js} +26 -34
  162. package/dist/cli-bundle/chunks/{chunk-EBRZZ54H.js.map → chunk-QDABF2RB.js.map} +1 -1
  163. package/dist/cli-bundle/chunks/{chunk-TULGS6X6.js → chunk-QFBSP3NI.js} +529 -46
  164. package/dist/cli-bundle/chunks/chunk-QFBSP3NI.js.map +1 -0
  165. package/dist/cli-bundle/chunks/{chunk-GDDAGPWJ.js → chunk-RB3KLPAH.js} +10 -14
  166. package/dist/cli-bundle/chunks/{chunk-GDDAGPWJ.js.map → chunk-RB3KLPAH.js.map} +1 -1
  167. package/dist/cli-bundle/chunks/{chunk-3VHSI5FL.js → chunk-RY7PTTUB.js} +94 -53
  168. package/dist/cli-bundle/chunks/chunk-RY7PTTUB.js.map +1 -0
  169. package/dist/cli-bundle/chunks/{chunk-COSPOP7H.js → chunk-S547WBYG.js} +343 -195
  170. package/dist/cli-bundle/chunks/chunk-S547WBYG.js.map +7 -0
  171. package/dist/cli-bundle/chunks/{chunk-NZEHECMW.js → chunk-S5BNGFN5.js} +24 -32
  172. package/dist/cli-bundle/chunks/{chunk-NZEHECMW.js.map → chunk-S5BNGFN5.js.map} +1 -1
  173. package/dist/cli-bundle/chunks/{chunk-MVSP7WGJ.js → chunk-S6VC2A2K.js} +8 -12
  174. package/dist/cli-bundle/chunks/{chunk-MVSP7WGJ.js.map → chunk-S6VC2A2K.js.map} +1 -1
  175. package/dist/cli-bundle/chunks/{chunk-45FYNUFJ.js → chunk-SIM5JDON.js} +6 -6
  176. package/dist/cli-bundle/chunks/{chunk-45FYNUFJ.js.map → chunk-SIM5JDON.js.map} +1 -1
  177. package/dist/cli-bundle/chunks/{chunk-VPIM42PC.js → chunk-SY75LYXR.js} +11 -7
  178. package/dist/cli-bundle/chunks/chunk-SY75LYXR.js.map +7 -0
  179. package/dist/cli-bundle/chunks/{chunk-K46RF36U.js → chunk-TEISGNSH.js} +7 -7
  180. package/dist/cli-bundle/chunks/chunk-TEISGNSH.js.map +1 -0
  181. package/dist/cli-bundle/chunks/{chunk-AGHMOTGM.js → chunk-TEKZOS7M.js} +2 -2
  182. package/dist/cli-bundle/chunks/{chunk-W572BIEB.js → chunk-TGUK6XN6.js} +14 -18
  183. package/dist/cli-bundle/chunks/{chunk-W572BIEB.js.map → chunk-TGUK6XN6.js.map} +1 -1
  184. package/dist/cli-bundle/chunks/{chunk-E42XTBSP.js → chunk-TNC6MZUD.js} +8 -12
  185. package/dist/cli-bundle/chunks/{chunk-E42XTBSP.js.map → chunk-TNC6MZUD.js.map} +1 -1
  186. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js +10498 -0
  187. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js.map +7 -0
  188. package/dist/cli-bundle/chunks/{chunk-57NWPFF2.js → chunk-UO7XAZK6.js} +17 -4
  189. package/dist/cli-bundle/chunks/chunk-UO7XAZK6.js.map +1 -0
  190. package/dist/cli-bundle/chunks/{chunk-JVH7QBVV.js → chunk-V5ZWKJNY.js} +2 -2
  191. package/dist/cli-bundle/chunks/{chunk-I36Y7PCE.js → chunk-VGO73OCK.js} +6 -6
  192. package/dist/cli-bundle/chunks/{chunk-I36Y7PCE.js.map → chunk-VGO73OCK.js.map} +1 -1
  193. package/dist/cli-bundle/chunks/{chunk-KUOOJR35.js → chunk-VLEA2UTQ.js} +2 -2
  194. package/dist/cli-bundle/chunks/{chunk-RCQZK2GO.js → chunk-W5HXHC7C.js} +7 -9
  195. package/dist/cli-bundle/chunks/{chunk-RCQZK2GO.js.map → chunk-W5HXHC7C.js.map} +1 -1
  196. package/dist/cli-bundle/chunks/{chunk-MUH7A3FD.js → chunk-WCWVEXGA.js} +2 -2
  197. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js +6690 -0
  198. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js.map +7 -0
  199. package/dist/cli-bundle/chunks/{chunk-NB7RLQFW.js → chunk-XBX5CBRQ.js} +5 -7
  200. package/dist/cli-bundle/chunks/{chunk-NB7RLQFW.js.map → chunk-XBX5CBRQ.js.map} +1 -1
  201. package/dist/cli-bundle/chunks/{chunk-SCUR7K7N.js → chunk-XC3X7BQR.js} +541 -44
  202. package/dist/cli-bundle/chunks/chunk-XC3X7BQR.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-CRVYGJUI.js → chunk-XHCVAZGM.js} +13 -17
  204. package/dist/cli-bundle/chunks/{chunk-CRVYGJUI.js.map → chunk-XHCVAZGM.js.map} +1 -1
  205. package/dist/cli-bundle/chunks/{chunk-XB7KFVFI.js → chunk-XPMXPR7K.js} +7 -9
  206. package/dist/cli-bundle/chunks/{chunk-XB7KFVFI.js.map → chunk-XPMXPR7K.js.map} +1 -1
  207. package/dist/cli-bundle/chunks/{chunk-4CJFCTLM.js → chunk-XS2TMNXR.js} +6 -8
  208. package/dist/cli-bundle/chunks/{chunk-4CJFCTLM.js.map → chunk-XS2TMNXR.js.map} +1 -1
  209. package/dist/cli-bundle/chunks/{chunk-HFDADVJZ.js → chunk-XXIYUTLK.js} +10 -14
  210. package/dist/cli-bundle/chunks/{chunk-HFDADVJZ.js.map → chunk-XXIYUTLK.js.map} +1 -1
  211. package/dist/cli-bundle/chunks/{chunk-EOKXK3R3.js → chunk-XZWL7VNE.js} +1220 -398
  212. package/dist/cli-bundle/chunks/chunk-XZWL7VNE.js.map +1 -0
  213. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js +6624 -0
  214. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js.map +1 -0
  215. package/dist/cli-bundle/chunks/{chunk-6LLVNJXT.js → chunk-Y7KYVCZM.js} +12 -18
  216. package/dist/cli-bundle/chunks/{chunk-6LLVNJXT.js.map → chunk-Y7KYVCZM.js.map} +1 -1
  217. package/dist/cli-bundle/chunks/{chunk-VIIUS6N6.js → chunk-YCVWWIKY.js} +16 -14
  218. package/dist/cli-bundle/chunks/chunk-YCVWWIKY.js.map +7 -0
  219. package/dist/cli-bundle/chunks/{chunk-CFNGIXZP.js → chunk-YH5NBDFA.js} +22 -26
  220. package/dist/cli-bundle/chunks/{chunk-CFNGIXZP.js.map → chunk-YH5NBDFA.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js +5509 -0
  222. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js.map +7 -0
  223. package/dist/cli-bundle/chunks/{chunk-NC33K5ZS.js → chunk-YPD7SQ5P.js} +7 -6
  224. package/dist/cli-bundle/chunks/{chunk-NC33K5ZS.js.map → chunk-YPD7SQ5P.js.map} +2 -2
  225. package/dist/cli-bundle/chunks/{chunk-NGXQ3PFT.js → chunk-YPMZMKN7.js} +2 -2
  226. package/dist/cli-bundle/chunks/{chunk-KGFUY7WN.js → chunk-YTD5GICJ.js} +4 -4
  227. package/dist/cli-bundle/chunks/{chunk-W6DYWXPQ.js → chunk-ZNEG2UDO.js} +261 -34
  228. package/dist/cli-bundle/chunks/{chunk-W6DYWXPQ.js.map → chunk-ZNEG2UDO.js.map} +4 -4
  229. package/dist/cli-bundle/chunks/{chunk-7DT4WSH2.js → chunk-ZO7CLOY2.js} +3 -3
  230. package/dist/cli-bundle/chunks/{close-2SSSHHUZ.js → close-3YYQ5OG2.js} +5 -9
  231. package/dist/cli-bundle/chunks/close-Z3Q4U7TS.js +12 -0
  232. package/dist/cli-bundle/chunks/close-many-3L2RXH3M.js +22 -0
  233. package/dist/cli-bundle/chunks/close-many-D366FTIG.js +26 -0
  234. package/dist/cli-bundle/chunks/comments-54XDJNFE.js +17 -0
  235. package/dist/cli-bundle/chunks/comments-HGHC2PN6.js +13 -0
  236. package/dist/cli-bundle/chunks/{copy-32ROBIDL.js → copy-44RT5GDW.js} +4 -8
  237. package/dist/cli-bundle/chunks/copy-UGMUGHZA.js +9 -0
  238. package/dist/cli-bundle/chunks/{create-E77SDCUP.js → create-4GWJWPXG.js} +9 -14
  239. package/dist/cli-bundle/chunks/create-AZXCUYKP.js +25 -0
  240. package/dist/cli-bundle/chunks/delete-Y6SXIQ4X.js +10 -0
  241. package/dist/cli-bundle/chunks/{delete-RA5KTCLB.js → delete-YQ2VPXNF.js} +4 -8
  242. package/dist/cli-bundle/chunks/{deps-32SU7HO5.js → deps-BU5EBJDU.js} +4 -8
  243. package/dist/cli-bundle/chunks/deps-FMANWFRP.js +13 -0
  244. package/dist/cli-bundle/chunks/{docs-RRUPT7O2.js → docs-OQBSJNIA.js} +6 -10
  245. package/dist/cli-bundle/chunks/docs-VNPBZXEL.js +14 -0
  246. package/dist/cli-bundle/chunks/files-72HZEBOE.js +18 -0
  247. package/dist/cli-bundle/chunks/{files-PYKR2UUG.js → files-HTSB2KJG.js} +6 -10
  248. package/dist/cli-bundle/chunks/{contracts-NYPEW2G4.js → focus-FOG4ALC2.js} +7 -9
  249. package/dist/cli-bundle/chunks/focus-SUTMKXGX.js +10 -0
  250. package/dist/cli-bundle/chunks/{history-compact-3MNXLKAT.js → history-compact-M6IFAMBP.js} +9 -13
  251. package/dist/cli-bundle/chunks/history-compact-NEXRPP2O.js +21 -0
  252. package/dist/cli-bundle/chunks/{history-redact-P6DYF55G.js → history-redact-NQX3OGZP.js} +7 -11
  253. package/dist/cli-bundle/chunks/history-redact-WQJBZ3PX.js +17 -0
  254. package/dist/cli-bundle/chunks/history-repair-CBHMHAJO.js +19 -0
  255. package/dist/cli-bundle/chunks/{history-repair-ZJQFMWPD.js → history-repair-NHOJG7WO.js} +9 -13
  256. package/dist/cli-bundle/chunks/learnings-M64NTSOR.js +13 -0
  257. package/dist/cli-bundle/chunks/{append-BGML6VLD.js → learnings-T63JGKKN.js} +9 -11
  258. package/dist/cli-bundle/chunks/notes-73WE2UV2.js +13 -0
  259. package/dist/cli-bundle/chunks/notes-U7L6HQQ2.js +17 -0
  260. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js +24 -0
  261. package/dist/cli-bundle/chunks/{plan-CHVE7PBR.js → plan-TN537L24.js} +10 -15
  262. package/dist/cli-bundle/chunks/{profile-ZXGSKBJD.js → profile-MHAMXMHQ.js} +9 -13
  263. package/dist/cli-bundle/chunks/{profile-LD23PSI6.js → profile-TIGLAKJ7.js} +9 -13
  264. package/dist/cli-bundle/chunks/{register-list-query-OEYQHFXO.js → register-list-query-OHXD7G5N.js} +41 -33
  265. package/dist/cli-bundle/chunks/register-list-query-OHXD7G5N.js.map +7 -0
  266. package/dist/cli-bundle/chunks/{register-list-query-B42JCCOI.js → register-list-query-ZCRABAPN.js} +42 -34
  267. package/dist/cli-bundle/chunks/register-list-query-ZCRABAPN.js.map +1 -0
  268. package/dist/cli-bundle/chunks/{register-mutation-IAEST26S.js → register-mutation-P3G4XP6Q.js} +36 -41
  269. package/dist/cli-bundle/chunks/{register-mutation-IAEST26S.js.map → register-mutation-P3G4XP6Q.js.map} +1 -1
  270. package/dist/cli-bundle/chunks/{register-mutation-3QXIHCQG.js → register-mutation-XX4H56PE.js} +34 -39
  271. package/dist/cli-bundle/chunks/{register-mutation-3QXIHCQG.js.map → register-mutation-XX4H56PE.js.map} +1 -1
  272. package/dist/cli-bundle/chunks/{chunk-5BMM6XQY.js → register-operations-V6PIYEDU.js} +79 -46
  273. package/dist/cli-bundle/chunks/register-operations-V6PIYEDU.js.map +1 -0
  274. package/dist/cli-bundle/chunks/{chunk-Z3U3U5KD.js → register-operations-V6VKTG54.js} +78 -45
  275. package/dist/cli-bundle/chunks/register-operations-V6VKTG54.js.map +7 -0
  276. package/dist/cli-bundle/chunks/{register-setup-3ZVVX2VN.js → register-setup-6RVAWT6W.js} +129 -29
  277. package/dist/cli-bundle/chunks/register-setup-6RVAWT6W.js.map +7 -0
  278. package/dist/cli-bundle/chunks/{register-setup-Q6KFNIOZ.js → register-setup-6YVUSQYD.js} +130 -30
  279. package/dist/cli-bundle/chunks/register-setup-6YVUSQYD.js.map +1 -0
  280. package/dist/cli-bundle/chunks/{restore-5RQHAPMA.js → restore-HC3YSWF7.js} +7 -11
  281. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js +15 -0
  282. package/dist/cli-bundle/chunks/{schema-HBORFC6B.js → schema-DAGSYO6E.js} +6 -10
  283. package/dist/cli-bundle/chunks/{schema-245WW4G2.js → schema-UBXJCQAC.js} +6 -10
  284. package/dist/cli-bundle/chunks/update-CJGG5WMV.js +21 -0
  285. package/dist/cli-bundle/chunks/update-LKD64AFP.js +25 -0
  286. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js +31 -0
  287. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js +35 -0
  288. package/dist/cli-bundle/main.js +29 -31
  289. package/dist/cli-bundle/main.js.map +2 -2
  290. package/dist/cli-bundle/sdk-runtime.js +129 -107
  291. package/dist/cli-bundle/sdk-testing.js +7 -8
  292. package/dist/cli-bundle/sdk.js +122 -117
  293. package/dist/cli-bundle/sdk.js.map +2 -2
  294. package/dist/core/history/drift-scan.js +3 -8
  295. package/dist/core/history/drift-scan.js.map +1 -1
  296. package/dist/core/output/mutation-projection.js +11 -5
  297. package/dist/core/output/mutation-projection.js.map +1 -1
  298. package/dist/core/search/cache.js +3 -3
  299. package/dist/core/search/cache.js.map +1 -1
  300. package/dist/core/search/semantic-defaults.d.ts +2 -0
  301. package/dist/core/search/semantic-defaults.js +11 -4
  302. package/dist/core/search/semantic-defaults.js.map +1 -1
  303. package/dist/core/search/vector-stores.d.ts +1 -1
  304. package/dist/core/search/vector-stores.js +33 -7
  305. package/dist/core/search/vector-stores.js.map +1 -1
  306. package/dist/mcp/server.d.ts +1 -1
  307. package/dist/sdk/cli-contracts/flag-contracts.js +7 -7
  308. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  309. package/dist/sdk/cli-contracts/tool-schema.js +9 -7
  310. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  311. package/dist/sdk/index.d.ts +1 -1
  312. package/dist/sdk/index.js +3 -3
  313. package/dist/sdk/index.js.map +1 -1
  314. package/dist/sdk/runtime.d.ts +151 -8
  315. package/dist/sdk/runtime.js +255 -14
  316. package/dist/sdk/runtime.js.map +1 -1
  317. package/dist/sdk/start-task-status.d.ts +13 -0
  318. package/dist/sdk/start-task-status.js +19 -0
  319. package/dist/sdk/start-task-status.js.map +1 -0
  320. package/docs/COMMANDS.md +10 -1
  321. package/docs/SDK.md +35 -0
  322. package/docs/TESTING.md +3 -0
  323. package/package.json +1 -1
  324. package/dist/cli-bundle/chunks/activity-WJCGCYPU.js +0 -18
  325. package/dist/cli-bundle/chunks/activity-Z6QUAUSG.js +0 -22
  326. package/dist/cli-bundle/chunks/aggregate-BDM6EIAR.js +0 -25
  327. package/dist/cli-bundle/chunks/aggregate-VQ2DHU3S.js +0 -21
  328. package/dist/cli-bundle/chunks/append-RKJYPU74.js +0 -15
  329. package/dist/cli-bundle/chunks/chunk-2XG4IZON.js +0 -218
  330. package/dist/cli-bundle/chunks/chunk-2XG4IZON.js.map +0 -7
  331. package/dist/cli-bundle/chunks/chunk-37E72CNS.js +0 -217
  332. package/dist/cli-bundle/chunks/chunk-37E72CNS.js.map +0 -1
  333. package/dist/cli-bundle/chunks/chunk-3GCS5SKL.js +0 -228
  334. package/dist/cli-bundle/chunks/chunk-3GCS5SKL.js.map +0 -1
  335. package/dist/cli-bundle/chunks/chunk-3KTN6IBA.js +0 -2330
  336. package/dist/cli-bundle/chunks/chunk-3KTN6IBA.js.map +0 -7
  337. package/dist/cli-bundle/chunks/chunk-3VHSI5FL.js.map +0 -1
  338. package/dist/cli-bundle/chunks/chunk-425E4QL5.js +0 -278
  339. package/dist/cli-bundle/chunks/chunk-425E4QL5.js.map +0 -7
  340. package/dist/cli-bundle/chunks/chunk-46CUF5L6.js.map +0 -7
  341. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js +0 -87
  342. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js.map +0 -7
  343. package/dist/cli-bundle/chunks/chunk-4HIFVN7N.js +0 -249
  344. package/dist/cli-bundle/chunks/chunk-4HIFVN7N.js.map +0 -7
  345. package/dist/cli-bundle/chunks/chunk-4IWYTWGF.js +0 -819
  346. package/dist/cli-bundle/chunks/chunk-4IWYTWGF.js.map +0 -1
  347. package/dist/cli-bundle/chunks/chunk-4MZVRJOE.js +0 -279
  348. package/dist/cli-bundle/chunks/chunk-4MZVRJOE.js.map +0 -1
  349. package/dist/cli-bundle/chunks/chunk-57NWPFF2.js.map +0 -1
  350. package/dist/cli-bundle/chunks/chunk-5AJXHQM7.js +0 -268
  351. package/dist/cli-bundle/chunks/chunk-5AJXHQM7.js.map +0 -1
  352. package/dist/cli-bundle/chunks/chunk-5BMM6XQY.js.map +0 -1
  353. package/dist/cli-bundle/chunks/chunk-5GZ7TDD6.js +0 -1868
  354. package/dist/cli-bundle/chunks/chunk-5GZ7TDD6.js.map +0 -7
  355. package/dist/cli-bundle/chunks/chunk-5VAA4YHR.js +0 -1749
  356. package/dist/cli-bundle/chunks/chunk-5VAA4YHR.js.map +0 -7
  357. package/dist/cli-bundle/chunks/chunk-64YKRTSV.js +0 -1961
  358. package/dist/cli-bundle/chunks/chunk-64YKRTSV.js.map +0 -1
  359. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +0 -23
  360. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +0 -7
  361. package/dist/cli-bundle/chunks/chunk-B7FRNMYN.js +0 -421
  362. package/dist/cli-bundle/chunks/chunk-B7FRNMYN.js.map +0 -1
  363. package/dist/cli-bundle/chunks/chunk-C5JBZRPU.js +0 -1985
  364. package/dist/cli-bundle/chunks/chunk-C5JBZRPU.js.map +0 -7
  365. package/dist/cli-bundle/chunks/chunk-CL36D4PC.js.map +0 -7
  366. package/dist/cli-bundle/chunks/chunk-COSPOP7H.js.map +0 -7
  367. package/dist/cli-bundle/chunks/chunk-COWTDV6B.js +0 -3461
  368. package/dist/cli-bundle/chunks/chunk-COWTDV6B.js.map +0 -7
  369. package/dist/cli-bundle/chunks/chunk-DEWEK6AN.js +0 -1858
  370. package/dist/cli-bundle/chunks/chunk-DEWEK6AN.js.map +0 -1
  371. package/dist/cli-bundle/chunks/chunk-DMRNBQOI.js.map +0 -1
  372. package/dist/cli-bundle/chunks/chunk-E3SZTQ4K.js +0 -1932
  373. package/dist/cli-bundle/chunks/chunk-E3SZTQ4K.js.map +0 -1
  374. package/dist/cli-bundle/chunks/chunk-EGAP5OWD.js.map +0 -1
  375. package/dist/cli-bundle/chunks/chunk-EKFNL33R.js.map +0 -1
  376. package/dist/cli-bundle/chunks/chunk-ENGQOEUY.js +0 -1704
  377. package/dist/cli-bundle/chunks/chunk-ENGQOEUY.js.map +0 -1
  378. package/dist/cli-bundle/chunks/chunk-EOKXK3R3.js.map +0 -1
  379. package/dist/cli-bundle/chunks/chunk-FLZSGSQR.js +0 -231
  380. package/dist/cli-bundle/chunks/chunk-FLZSGSQR.js.map +0 -7
  381. package/dist/cli-bundle/chunks/chunk-FOUYJE4A.js +0 -2090
  382. package/dist/cli-bundle/chunks/chunk-FOUYJE4A.js.map +0 -1
  383. package/dist/cli-bundle/chunks/chunk-G24G7ZAV.js +0 -1570
  384. package/dist/cli-bundle/chunks/chunk-G24G7ZAV.js.map +0 -1
  385. package/dist/cli-bundle/chunks/chunk-GEYZ4G4O.js +0 -239
  386. package/dist/cli-bundle/chunks/chunk-GEYZ4G4O.js.map +0 -1
  387. package/dist/cli-bundle/chunks/chunk-GPLPTGOV.js +0 -530
  388. package/dist/cli-bundle/chunks/chunk-GPLPTGOV.js.map +0 -7
  389. package/dist/cli-bundle/chunks/chunk-GZRDYONU.js +0 -1005
  390. package/dist/cli-bundle/chunks/chunk-GZRDYONU.js.map +0 -7
  391. package/dist/cli-bundle/chunks/chunk-HN6NSXNW.js +0 -277
  392. package/dist/cli-bundle/chunks/chunk-HN6NSXNW.js.map +0 -7
  393. package/dist/cli-bundle/chunks/chunk-IQNVQHOP.js +0 -309
  394. package/dist/cli-bundle/chunks/chunk-IQNVQHOP.js.map +0 -7
  395. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js +0 -371
  396. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js.map +0 -7
  397. package/dist/cli-bundle/chunks/chunk-JQXPY7DN.js +0 -2257
  398. package/dist/cli-bundle/chunks/chunk-JQXPY7DN.js.map +0 -7
  399. package/dist/cli-bundle/chunks/chunk-K46RF36U.js.map +0 -1
  400. package/dist/cli-bundle/chunks/chunk-KERMZVY5.js +0 -371
  401. package/dist/cli-bundle/chunks/chunk-KERMZVY5.js.map +0 -7
  402. package/dist/cli-bundle/chunks/chunk-KSRUHV2H.js +0 -76
  403. package/dist/cli-bundle/chunks/chunk-KSRUHV2H.js.map +0 -1
  404. package/dist/cli-bundle/chunks/chunk-LP3HSFZ2.js +0 -140
  405. package/dist/cli-bundle/chunks/chunk-LP3HSFZ2.js.map +0 -1
  406. package/dist/cli-bundle/chunks/chunk-MAWDPCJW.js +0 -1601
  407. package/dist/cli-bundle/chunks/chunk-MAWDPCJW.js.map +0 -1
  408. package/dist/cli-bundle/chunks/chunk-MFAZSEM5.js +0 -1031
  409. package/dist/cli-bundle/chunks/chunk-MFAZSEM5.js.map +0 -1
  410. package/dist/cli-bundle/chunks/chunk-MFSCBT5Q.js +0 -995
  411. package/dist/cli-bundle/chunks/chunk-MFSCBT5Q.js.map +0 -1
  412. package/dist/cli-bundle/chunks/chunk-ML5X7DP2.js +0 -296
  413. package/dist/cli-bundle/chunks/chunk-ML5X7DP2.js.map +0 -1
  414. package/dist/cli-bundle/chunks/chunk-MLIYFOE7.js.map +0 -1
  415. package/dist/cli-bundle/chunks/chunk-MR6FJ7LL.js +0 -2043
  416. package/dist/cli-bundle/chunks/chunk-MR6FJ7LL.js.map +0 -7
  417. package/dist/cli-bundle/chunks/chunk-MXYA5SAJ.js +0 -2033
  418. package/dist/cli-bundle/chunks/chunk-MXYA5SAJ.js.map +0 -1
  419. package/dist/cli-bundle/chunks/chunk-N745W3B3.js +0 -1604
  420. package/dist/cli-bundle/chunks/chunk-N745W3B3.js.map +0 -7
  421. package/dist/cli-bundle/chunks/chunk-NMP5I3I5.js +0 -1615
  422. package/dist/cli-bundle/chunks/chunk-NMP5I3I5.js.map +0 -7
  423. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +0 -20
  424. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +0 -1
  425. package/dist/cli-bundle/chunks/chunk-PZUGEOPS.js +0 -143
  426. package/dist/cli-bundle/chunks/chunk-PZUGEOPS.js.map +0 -7
  427. package/dist/cli-bundle/chunks/chunk-QLMX7SRD.js.map +0 -7
  428. package/dist/cli-bundle/chunks/chunk-QX6HM775.js +0 -398
  429. package/dist/cli-bundle/chunks/chunk-QX6HM775.js.map +0 -7
  430. package/dist/cli-bundle/chunks/chunk-QZ342C63.js +0 -220
  431. package/dist/cli-bundle/chunks/chunk-QZ342C63.js.map +0 -7
  432. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js +0 -368
  433. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js.map +0 -1
  434. package/dist/cli-bundle/chunks/chunk-RFNYTESG.js +0 -520
  435. package/dist/cli-bundle/chunks/chunk-RFNYTESG.js.map +0 -1
  436. package/dist/cli-bundle/chunks/chunk-RKQOO2UM.js +0 -79
  437. package/dist/cli-bundle/chunks/chunk-RKQOO2UM.js.map +0 -7
  438. package/dist/cli-bundle/chunks/chunk-RQLT6ZWB.js +0 -282
  439. package/dist/cli-bundle/chunks/chunk-RQLT6ZWB.js.map +0 -7
  440. package/dist/cli-bundle/chunks/chunk-S3JS6YVZ.js +0 -274
  441. package/dist/cli-bundle/chunks/chunk-S3JS6YVZ.js.map +0 -1
  442. package/dist/cli-bundle/chunks/chunk-SCUR7K7N.js.map +0 -7
  443. package/dist/cli-bundle/chunks/chunk-SHQY2IDC.js +0 -1977
  444. package/dist/cli-bundle/chunks/chunk-SHQY2IDC.js.map +0 -7
  445. package/dist/cli-bundle/chunks/chunk-SPZ6DOGY.js +0 -1041
  446. package/dist/cli-bundle/chunks/chunk-SPZ6DOGY.js.map +0 -7
  447. package/dist/cli-bundle/chunks/chunk-T42JWV3F.js +0 -822
  448. package/dist/cli-bundle/chunks/chunk-T42JWV3F.js.map +0 -7
  449. package/dist/cli-bundle/chunks/chunk-TKD5VCTD.js.map +0 -1
  450. package/dist/cli-bundle/chunks/chunk-TULGS6X6.js.map +0 -1
  451. package/dist/cli-bundle/chunks/chunk-TZXRBVAM.js +0 -2306
  452. package/dist/cli-bundle/chunks/chunk-TZXRBVAM.js.map +0 -1
  453. package/dist/cli-bundle/chunks/chunk-VIIUS6N6.js.map +0 -7
  454. package/dist/cli-bundle/chunks/chunk-VPIM42PC.js.map +0 -7
  455. package/dist/cli-bundle/chunks/chunk-VQRSPVME.js +0 -368
  456. package/dist/cli-bundle/chunks/chunk-VQRSPVME.js.map +0 -1
  457. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js +0 -84
  458. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js.map +0 -1
  459. package/dist/cli-bundle/chunks/chunk-WG34ZNQQ.js +0 -3423
  460. package/dist/cli-bundle/chunks/chunk-WG34ZNQQ.js.map +0 -1
  461. package/dist/cli-bundle/chunks/chunk-WLSM645P.js +0 -2247
  462. package/dist/cli-bundle/chunks/chunk-WLSM645P.js.map +0 -1
  463. package/dist/cli-bundle/chunks/chunk-WRTENIX3.js +0 -215
  464. package/dist/cli-bundle/chunks/chunk-WRTENIX3.js.map +0 -1
  465. package/dist/cli-bundle/chunks/chunk-WSBLYDWV.js +0 -388
  466. package/dist/cli-bundle/chunks/chunk-WSBLYDWV.js.map +0 -1
  467. package/dist/cli-bundle/chunks/chunk-XC5BURG2.js +0 -306
  468. package/dist/cli-bundle/chunks/chunk-XC5BURG2.js.map +0 -1
  469. package/dist/cli-bundle/chunks/chunk-XDB7RWQT.js +0 -424
  470. package/dist/cli-bundle/chunks/chunk-XDB7RWQT.js.map +0 -7
  471. package/dist/cli-bundle/chunks/chunk-Y6BK55A3.js +0 -2128
  472. package/dist/cli-bundle/chunks/chunk-Y6BK55A3.js.map +0 -7
  473. package/dist/cli-bundle/chunks/chunk-Z3U3U5KD.js.map +0 -7
  474. package/dist/cli-bundle/chunks/chunk-ZO3XKAOP.js +0 -299
  475. package/dist/cli-bundle/chunks/chunk-ZO3XKAOP.js.map +0 -7
  476. package/dist/cli-bundle/chunks/chunk-ZSUS2OD3.js.map +0 -7
  477. package/dist/cli-bundle/chunks/claim-RFS7BROJ.js +0 -19
  478. package/dist/cli-bundle/chunks/claim-XP5AWZ5H.js +0 -23
  479. package/dist/cli-bundle/chunks/close-GEANHQ2J.js +0 -16
  480. package/dist/cli-bundle/chunks/close-many-CMZW7ITN.js +0 -31
  481. package/dist/cli-bundle/chunks/close-many-ZFDIG6M7.js +0 -27
  482. package/dist/cli-bundle/chunks/comments-MFSYVNNU.js +0 -21
  483. package/dist/cli-bundle/chunks/comments-XUBPXDYX.js +0 -17
  484. package/dist/cli-bundle/chunks/config-D7XQMONX.js +0 -18
  485. package/dist/cli-bundle/chunks/config-T4FHBSYN.js +0 -22
  486. package/dist/cli-bundle/chunks/context-DIU275XI.js +0 -48
  487. package/dist/cli-bundle/chunks/context-JCOYB4LZ.js +0 -44
  488. package/dist/cli-bundle/chunks/contracts-BVO7CSLK.js +0 -12
  489. package/dist/cli-bundle/chunks/copy-NAGLGMHZ.js +0 -13
  490. package/dist/cli-bundle/chunks/create-4V7SWNBB.js +0 -30
  491. package/dist/cli-bundle/chunks/delete-NQI5OSKN.js +0 -14
  492. package/dist/cli-bundle/chunks/deps-T7SCWXEX.js +0 -17
  493. package/dist/cli-bundle/chunks/docs-WL2IWGWV.js +0 -18
  494. package/dist/cli-bundle/chunks/eval-NF2J5SHR.js +0 -23
  495. package/dist/cli-bundle/chunks/eval-SKDT3MZU.js +0 -27
  496. package/dist/cli-bundle/chunks/extension-LAXKCAYE.js +0 -42
  497. package/dist/cli-bundle/chunks/extension-ZISPBRBC.js +0 -38
  498. package/dist/cli-bundle/chunks/files-EWRQHGIS.js +0 -22
  499. package/dist/cli-bundle/chunks/focus-4T7TM4MT.js +0 -18
  500. package/dist/cli-bundle/chunks/focus-L3YUASOD.js +0 -14
  501. package/dist/cli-bundle/chunks/gc-2PCTYYRI.js +0 -12
  502. package/dist/cli-bundle/chunks/get-7DMITJ3G.js +0 -23
  503. package/dist/cli-bundle/chunks/get-VKQXCXLL.js +0 -19
  504. package/dist/cli-bundle/chunks/health-CVSTAR2F.js +0 -31
  505. package/dist/cli-bundle/chunks/health-TV3GKTFN.js +0 -35
  506. package/dist/cli-bundle/chunks/history-D4JUX5XV.js +0 -20
  507. package/dist/cli-bundle/chunks/history-D4JUX5XV.js.map +0 -7
  508. package/dist/cli-bundle/chunks/history-LQ2UWZTE.js +0 -24
  509. package/dist/cli-bundle/chunks/history-LQ2UWZTE.js.map +0 -1
  510. package/dist/cli-bundle/chunks/history-compact-3MNXLKAT.js.map +0 -1
  511. package/dist/cli-bundle/chunks/history-compact-QWEO32FP.js +0 -25
  512. package/dist/cli-bundle/chunks/history-compact-QWEO32FP.js.map +0 -7
  513. package/dist/cli-bundle/chunks/history-redact-3OIVBVIY.js +0 -21
  514. package/dist/cli-bundle/chunks/history-redact-3OIVBVIY.js.map +0 -7
  515. package/dist/cli-bundle/chunks/history-redact-P6DYF55G.js.map +0 -1
  516. package/dist/cli-bundle/chunks/history-repair-I3E73UGQ.js +0 -23
  517. package/dist/cli-bundle/chunks/history-repair-I3E73UGQ.js.map +0 -7
  518. package/dist/cli-bundle/chunks/history-repair-ZJQFMWPD.js.map +0 -1
  519. package/dist/cli-bundle/chunks/init-C3LJPWQZ.js +0 -30
  520. package/dist/cli-bundle/chunks/init-C3LJPWQZ.js.map +0 -1
  521. package/dist/cli-bundle/chunks/init-J3DPGWQI.js +0 -26
  522. package/dist/cli-bundle/chunks/init-J3DPGWQI.js.map +0 -7
  523. package/dist/cli-bundle/chunks/learnings-5BO2SNDW.js +0 -21
  524. package/dist/cli-bundle/chunks/learnings-5BO2SNDW.js.map +0 -1
  525. package/dist/cli-bundle/chunks/learnings-OGP4JB4I.js +0 -17
  526. package/dist/cli-bundle/chunks/learnings-OGP4JB4I.js.map +0 -7
  527. package/dist/cli-bundle/chunks/list-O5NZVSPN.js +0 -36
  528. package/dist/cli-bundle/chunks/list-O5NZVSPN.js.map +0 -1
  529. package/dist/cli-bundle/chunks/list-Z55YCNTC.js +0 -32
  530. package/dist/cli-bundle/chunks/list-Z55YCNTC.js.map +0 -7
  531. package/dist/cli-bundle/chunks/next-GBNTGXFC.js +0 -28
  532. package/dist/cli-bundle/chunks/next-GBNTGXFC.js.map +0 -7
  533. package/dist/cli-bundle/chunks/next-QKW7PTKE.js +0 -32
  534. package/dist/cli-bundle/chunks/next-QKW7PTKE.js.map +0 -1
  535. package/dist/cli-bundle/chunks/notes-R5FZTKWF.js +0 -17
  536. package/dist/cli-bundle/chunks/notes-R5FZTKWF.js.map +0 -7
  537. package/dist/cli-bundle/chunks/notes-WCGIULVG.js +0 -21
  538. package/dist/cli-bundle/chunks/notes-WCGIULVG.js.map +0 -1
  539. package/dist/cli-bundle/chunks/plan-ADISFYH4.js +0 -29
  540. package/dist/cli-bundle/chunks/plan-ADISFYH4.js.map +0 -7
  541. package/dist/cli-bundle/chunks/plan-CHVE7PBR.js.map +0 -1
  542. package/dist/cli-bundle/chunks/profile-LD23PSI6.js.map +0 -7
  543. package/dist/cli-bundle/chunks/profile-ZXGSKBJD.js.map +0 -1
  544. package/dist/cli-bundle/chunks/register-list-query-B42JCCOI.js.map +0 -1
  545. package/dist/cli-bundle/chunks/register-list-query-OEYQHFXO.js.map +0 -7
  546. package/dist/cli-bundle/chunks/register-operations-I3M3U7DS.js +0 -19
  547. package/dist/cli-bundle/chunks/register-operations-I3M3U7DS.js.map +0 -7
  548. package/dist/cli-bundle/chunks/register-operations-UHKENLZV.js +0 -23
  549. package/dist/cli-bundle/chunks/register-operations-UHKENLZV.js.map +0 -1
  550. package/dist/cli-bundle/chunks/register-setup-3ZVVX2VN.js.map +0 -7
  551. package/dist/cli-bundle/chunks/register-setup-Q6KFNIOZ.js.map +0 -1
  552. package/dist/cli-bundle/chunks/restore-5RQHAPMA.js.map +0 -1
  553. package/dist/cli-bundle/chunks/restore-PNEIBBLW.js +0 -19
  554. package/dist/cli-bundle/chunks/restore-PNEIBBLW.js.map +0 -7
  555. package/dist/cli-bundle/chunks/scheduling-shortcuts-4G56YHVQ.js +0 -29
  556. package/dist/cli-bundle/chunks/scheduling-shortcuts-4G56YHVQ.js.map +0 -1
  557. package/dist/cli-bundle/chunks/scheduling-shortcuts-75DULBYP.js +0 -25
  558. package/dist/cli-bundle/chunks/scheduling-shortcuts-75DULBYP.js.map +0 -7
  559. package/dist/cli-bundle/chunks/schema-245WW4G2.js.map +0 -1
  560. package/dist/cli-bundle/chunks/schema-HBORFC6B.js.map +0 -7
  561. package/dist/cli-bundle/chunks/search-AOZC5SIK.js +0 -34
  562. package/dist/cli-bundle/chunks/search-AOZC5SIK.js.map +0 -7
  563. package/dist/cli-bundle/chunks/search-DRXPGHD7.js +0 -38
  564. package/dist/cli-bundle/chunks/search-DRXPGHD7.js.map +0 -1
  565. package/dist/cli-bundle/chunks/stats-NJG4NLHG.js +0 -21
  566. package/dist/cli-bundle/chunks/stats-NJG4NLHG.js.map +0 -1
  567. package/dist/cli-bundle/chunks/stats-RG6AG4N2.js +0 -17
  568. package/dist/cli-bundle/chunks/stats-RG6AG4N2.js.map +0 -7
  569. package/dist/cli-bundle/chunks/telemetry-HQC2JJIF.js +0 -14
  570. package/dist/cli-bundle/chunks/telemetry-HQC2JJIF.js.map +0 -7
  571. package/dist/cli-bundle/chunks/telemetry-MPNL3HHY.js +0 -18
  572. package/dist/cli-bundle/chunks/telemetry-MPNL3HHY.js.map +0 -1
  573. package/dist/cli-bundle/chunks/test-6CMOCWUC.js +0 -39
  574. package/dist/cli-bundle/chunks/test-6CMOCWUC.js.map +0 -7
  575. package/dist/cli-bundle/chunks/test-RI7XHBZL.js +0 -43
  576. package/dist/cli-bundle/chunks/test-RI7XHBZL.js.map +0 -1
  577. package/dist/cli-bundle/chunks/test-all-7R7YRZIA.js +0 -29
  578. package/dist/cli-bundle/chunks/test-all-7R7YRZIA.js.map +0 -7
  579. package/dist/cli-bundle/chunks/test-all-QEIORFYW.js +0 -33
  580. package/dist/cli-bundle/chunks/test-all-QEIORFYW.js.map +0 -1
  581. package/dist/cli-bundle/chunks/test-runs-5Y2BOU2S.js +0 -28
  582. package/dist/cli-bundle/chunks/test-runs-5Y2BOU2S.js.map +0 -1
  583. package/dist/cli-bundle/chunks/test-runs-PVGC3GRZ.js +0 -24
  584. package/dist/cli-bundle/chunks/test-runs-PVGC3GRZ.js.map +0 -7
  585. package/dist/cli-bundle/chunks/update-QVJDFEAP.js +0 -30
  586. package/dist/cli-bundle/chunks/update-QVJDFEAP.js.map +0 -1
  587. package/dist/cli-bundle/chunks/update-VQVHAY6X.js +0 -26
  588. package/dist/cli-bundle/chunks/update-VQVHAY6X.js.map +0 -7
  589. package/dist/cli-bundle/chunks/update-many-S7XWBSB3.js +0 -37
  590. package/dist/cli-bundle/chunks/update-many-S7XWBSB3.js.map +0 -7
  591. package/dist/cli-bundle/chunks/update-many-YIYW6XQ6.js +0 -41
  592. package/dist/cli-bundle/chunks/update-many-YIYW6XQ6.js.map +0 -1
  593. package/dist/cli-bundle/chunks/upgrade-OPRXA56R.js +0 -24
  594. package/dist/cli-bundle/chunks/upgrade-OPRXA56R.js.map +0 -7
  595. package/dist/cli-bundle/chunks/upgrade-WH4BTQLX.js +0 -28
  596. package/dist/cli-bundle/chunks/upgrade-WH4BTQLX.js.map +0 -1
  597. package/dist/cli-bundle/chunks/validate-4NTXSB62.js +0 -36
  598. package/dist/cli-bundle/chunks/validate-4NTXSB62.js.map +0 -1
  599. package/dist/cli-bundle/chunks/validate-MUFXQZMI.js +0 -32
  600. package/dist/cli-bundle/chunks/validate-MUFXQZMI.js.map +0 -7
  601. /package/dist/cli-bundle/chunks/{activity-WJCGCYPU.js.map → append-F7WPGIQL.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{activity-Z6QUAUSG.js.map → append-PVCTBVJG.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{chunk-R5BMJX33.js.map → chunk-2LEJGRQ7.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{chunk-AZYGZGGI.js.map → chunk-2TILG6F2.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{chunk-GJ7QC5DJ.js.map → chunk-3TYOW6RR.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{chunk-B6DUFX6H.js.map → chunk-3X542TEY.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{chunk-JJP45OEI.js.map → chunk-7VQ3JJN5.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{chunk-MWMVPCIE.js.map → chunk-AGAVEDIE.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{chunk-22KBU3MW.js.map → chunk-AJUON7E6.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{chunk-IWVU4C2F.js.map → chunk-DR2V5OIV.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{chunk-XG625QP4.js.map → chunk-EDO7VXSO.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{chunk-Y4M7CPQP.js.map → chunk-EVEPHNXJ.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{chunk-JDDLOQAE.js.map → chunk-FN6SB4HU.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{chunk-24YG75HI.js.map → chunk-H2SMKL2N.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{chunk-EGY6JBQ3.js.map → chunk-HX6QXV5P.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{chunk-Y46GD4IX.js.map → chunk-P3MJJW7P.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{chunk-MVYWGY2A.js.map → chunk-PDXJXEZJ.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{chunk-AGHMOTGM.js.map → chunk-TEKZOS7M.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{chunk-JVH7QBVV.js.map → chunk-V5ZWKJNY.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{chunk-KUOOJR35.js.map → chunk-VLEA2UTQ.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{chunk-MUH7A3FD.js.map → chunk-WCWVEXGA.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{chunk-NGXQ3PFT.js.map → chunk-YPMZMKN7.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{chunk-KGFUY7WN.js.map → chunk-YTD5GICJ.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{chunk-7DT4WSH2.js.map → chunk-ZO7CLOY2.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{aggregate-BDM6EIAR.js.map → close-3YYQ5OG2.js.map} +0 -0
  626. /package/dist/cli-bundle/chunks/{aggregate-VQ2DHU3S.js.map → close-Z3Q4U7TS.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{append-RKJYPU74.js.map → close-many-3L2RXH3M.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{append-BGML6VLD.js.map → close-many-D366FTIG.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{claim-XP5AWZ5H.js.map → comments-54XDJNFE.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{claim-RFS7BROJ.js.map → comments-HGHC2PN6.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{close-2SSSHHUZ.js.map → copy-44RT5GDW.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{close-GEANHQ2J.js.map → copy-UGMUGHZA.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{close-many-CMZW7ITN.js.map → create-4GWJWPXG.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{close-many-ZFDIG6M7.js.map → create-AZXCUYKP.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{comments-XUBPXDYX.js.map → delete-Y6SXIQ4X.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{comments-MFSYVNNU.js.map → delete-YQ2VPXNF.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{config-T4FHBSYN.js.map → deps-BU5EBJDU.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{config-D7XQMONX.js.map → deps-FMANWFRP.js.map} +0 -0
  639. /package/dist/cli-bundle/chunks/{context-DIU275XI.js.map → docs-OQBSJNIA.js.map} +0 -0
  640. /package/dist/cli-bundle/chunks/{context-JCOYB4LZ.js.map → docs-VNPBZXEL.js.map} +0 -0
  641. /package/dist/cli-bundle/chunks/{contracts-BVO7CSLK.js.map → files-72HZEBOE.js.map} +0 -0
  642. /package/dist/cli-bundle/chunks/{contracts-NYPEW2G4.js.map → files-HTSB2KJG.js.map} +0 -0
  643. /package/dist/cli-bundle/chunks/{copy-32ROBIDL.js.map → focus-FOG4ALC2.js.map} +0 -0
  644. /package/dist/cli-bundle/chunks/{copy-NAGLGMHZ.js.map → focus-SUTMKXGX.js.map} +0 -0
  645. /package/dist/cli-bundle/chunks/{create-E77SDCUP.js.map → history-compact-M6IFAMBP.js.map} +0 -0
  646. /package/dist/cli-bundle/chunks/{create-4V7SWNBB.js.map → history-compact-NEXRPP2O.js.map} +0 -0
  647. /package/dist/cli-bundle/chunks/{delete-RA5KTCLB.js.map → history-redact-NQX3OGZP.js.map} +0 -0
  648. /package/dist/cli-bundle/chunks/{delete-NQI5OSKN.js.map → history-redact-WQJBZ3PX.js.map} +0 -0
  649. /package/dist/cli-bundle/chunks/{deps-T7SCWXEX.js.map → history-repair-CBHMHAJO.js.map} +0 -0
  650. /package/dist/cli-bundle/chunks/{deps-32SU7HO5.js.map → history-repair-NHOJG7WO.js.map} +0 -0
  651. /package/dist/cli-bundle/chunks/{docs-WL2IWGWV.js.map → learnings-M64NTSOR.js.map} +0 -0
  652. /package/dist/cli-bundle/chunks/{docs-RRUPT7O2.js.map → learnings-T63JGKKN.js.map} +0 -0
  653. /package/dist/cli-bundle/chunks/{eval-NF2J5SHR.js.map → notes-73WE2UV2.js.map} +0 -0
  654. /package/dist/cli-bundle/chunks/{eval-SKDT3MZU.js.map → notes-U7L6HQQ2.js.map} +0 -0
  655. /package/dist/cli-bundle/chunks/{extension-ZISPBRBC.js.map → plan-OSCNYFGC.js.map} +0 -0
  656. /package/dist/cli-bundle/chunks/{extension-LAXKCAYE.js.map → plan-TN537L24.js.map} +0 -0
  657. /package/dist/cli-bundle/chunks/{files-PYKR2UUG.js.map → profile-MHAMXMHQ.js.map} +0 -0
  658. /package/dist/cli-bundle/chunks/{files-EWRQHGIS.js.map → profile-TIGLAKJ7.js.map} +0 -0
  659. /package/dist/cli-bundle/chunks/{focus-4T7TM4MT.js.map → restore-HC3YSWF7.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{focus-L3YUASOD.js.map → restore-LFAMMRYZ.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{gc-2PCTYYRI.js.map → schema-DAGSYO6E.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{gc-2DNMPXMC.js.map → schema-UBXJCQAC.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{get-VKQXCXLL.js.map → update-CJGG5WMV.js.map} +0 -0
  664. /package/dist/cli-bundle/chunks/{get-7DMITJ3G.js.map → update-LKD64AFP.js.map} +0 -0
  665. /package/dist/cli-bundle/chunks/{health-CVSTAR2F.js.map → update-many-G4SM7BHC.js.map} +0 -0
  666. /package/dist/cli-bundle/chunks/{health-TV3GKTFN.js.map → update-many-VLIV3D7R.js.map} +0 -0
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/history-redact.ts", "../../../../../../../../core/history/history-rewrite.ts"],
4
4
  "sourcesContent": ["/**\n * @module cli/commands/history-redact\n *\n * Implements the pm history redact command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { createHistoryEntry } from \"../../core/history/history.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n tryApplyReplayPatch,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../../core/item/id.js\";\nimport { canonicalDocument, serializeItemDocument } from \"../../core/item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { getActiveExtensionRegistrations, runActiveOnWriteHooks } from \"../../core/extensions/index.js\";\nimport { locateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\n\n/**\n * Documents the history redact command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRedactCommandOptions {\n literal?: string[] | string;\n regex?: string[] | string;\n replacement?: string;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\ninterface RegexRule {\n kind: \"regex\";\n source: string;\n flags: string;\n label: string;\n}\n\ninterface LiteralRule {\n kind: \"literal\";\n value: string;\n label: string;\n}\n\ntype RedactionRule = RegexRule | LiteralRule;\n\ninterface RedactionRewriteResult {\n entries: HistoryEntry[];\n finalDocument: ReplayDocument;\n entriesChanged: number;\n replacements: number;\n}\n\ninterface HistoryIntegritySnapshot {\n hashMismatchesBefore: number;\n hashMismatchesAfter: number;\n finalDocument: ReplayDocument;\n}\n\ninterface HistoryRedactCurrentItem {\n raw: string | null;\n path: string | null;\n document: ItemDocument | null;\n}\n\ninterface HistoryRedactNextItem {\n raw: string | null;\n path: string | null;\n document: ItemDocument | null;\n}\n\n/**\n * Documents the history subject payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistorySubject {\n id: string;\n historyPath: string;\n located: Awaited<ReturnType<typeof locateItem>>;\n}\n\n/**\n * Documents the history redact result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRedactResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n patterns: {\n literals: string[];\n regex: string[];\n replacement: string;\n };\n history: {\n path: string;\n entries_scanned: number;\n entries_changed: number;\n replacements: number;\n hash_mismatches_before: number;\n hash_mismatches_after: number;\n preexisting_hash_mismatches: number;\n audit_entry_added: boolean;\n verify_ok: boolean;\n verify_errors: string[];\n };\n item: {\n existed_before: boolean;\n exists_after: boolean;\n path_before: string | null;\n path_after: string | null;\n changed: boolean;\n };\n warnings: string[];\n generated_at: string;\n}\n\nfunction normalizeStringArrayInput(value: string[] | string | undefined): string[] {\n if (Array.isArray(value)) {\n return value;\n }\n if (typeof value === \"string\") {\n return [value];\n }\n return [];\n}\n\nfunction normalizeRegexFlags(flags: string): string {\n const unique: string[] = [];\n for (const token of flags) {\n if (!unique.includes(token)) {\n unique.push(token);\n }\n }\n if (!unique.includes(\"g\")) {\n unique.push(\"g\");\n }\n return unique.join(\"\");\n}\n\nfunction parseRegexRule(spec: string): RegexRule {\n const trimmed = spec.trim();\n if (trimmed.length === 0) {\n throw new PmCliError(\"history-redact --regex requires a non-empty pattern.\", EXIT_CODE.USAGE);\n }\n\n let source = trimmed;\n let flags = \"g\";\n if (trimmed.startsWith(\"/\") && trimmed.length > 1) {\n /* c8 ignore start -- bare-slash regex literals are rejected earlier in argument validation. */\n const slashIndex = trimmed.lastIndexOf(\"/\");\n if (slashIndex > 0) {\n source = trimmed.slice(1, slashIndex);\n flags = normalizeRegexFlags(trimmed.slice(slashIndex + 1));\n }\n /* c8 ignore stop */\n }\n if (source.length === 0) {\n throw new PmCliError(\"history-redact --regex cannot use an empty pattern.\", EXIT_CODE.USAGE);\n }\n try {\n new RegExp(source, flags);\n } catch (error) {\n /* c8 ignore start -- RegExp constructor failures are normalized in higher-level parser tests. */\n throw new PmCliError(\n `Invalid --regex value \"${spec}\": ${error instanceof Error ? error.message : String(error)}`,\n EXIT_CODE.USAGE,\n );\n /* c8 ignore stop */\n }\n\n return {\n kind: \"regex\",\n source,\n flags,\n label: `/${source}/${flags}`,\n };\n}\n\nfunction buildRedactionRules(\n literalInput: string[] | string | undefined,\n regexInput: string[] | string | undefined,\n): RedactionRule[] {\n const literalRules = [...new Set(normalizeStringArrayInput(literalInput).map((entry) => entry.trim()))]\n .filter((entry) => entry.length > 0)\n .map<LiteralRule>((entry) => ({\n kind: \"literal\",\n value: entry,\n label: entry,\n }));\n const regexRules = [...new Set(normalizeStringArrayInput(regexInput).map((entry) => entry.trim()))]\n .filter((entry) => entry.length > 0)\n .map(parseRegexRule);\n\n const rules = [...literalRules, ...regexRules];\n if (rules.length === 0) {\n throw new PmCliError(\n \"history-redact requires at least one matcher via --literal or --regex.\",\n EXIT_CODE.USAGE,\n {\n code: \"missing_required_argument\",\n required: \"Provide --literal <value> and/or --regex <pattern>.\",\n examples: [\n 'pm history-redact pm-a1b2 --literal \"[redacted_path_prefix]/private\"',\n 'pm history-redact pm-a1b2 --regex \"/192\\\\\\\\.168\\\\\\\\.[0-9.]+/g\" --replacement \"[scrubbed_ip]\"',\n ],\n },\n );\n }\n return rules;\n}\n\nfunction applyLiteralRule(value: string, literal: string, replacement: string): { value: string; replacements: number } {\n if (literal.length === 0) {\n return { value, replacements: 0 };\n }\n let cursor = 0;\n let replacements = 0;\n while (cursor <= value.length) {\n const index = value.indexOf(literal, cursor);\n if (index === -1) {\n break;\n }\n replacements += 1;\n cursor = index + Math.max(1, literal.length);\n }\n if (replacements === 0) {\n return { value, replacements: 0 };\n }\n return {\n value: value.split(literal).join(replacement),\n replacements,\n };\n}\n\nfunction applyRegexRule(value: string, rule: RegexRule, replacement: string): { value: string; replacements: number } {\n const regex = new RegExp(rule.source, rule.flags);\n const matches = [...value.matchAll(regex)];\n if (matches.length === 0) {\n return { value, replacements: 0 };\n }\n return {\n value: value.replace(regex, replacement),\n replacements: matches.length,\n };\n}\n\nfunction redactStringValue(value: string, rules: RedactionRule[], replacement: string): { value: string; replacements: number } {\n let next = value;\n let replacements = 0;\n for (const rule of rules) {\n const result =\n rule.kind === \"literal\"\n ? applyLiteralRule(next, rule.value, replacement)\n : applyRegexRule(next, rule, replacement);\n next = result.value;\n replacements += result.replacements;\n }\n return {\n value: next,\n replacements,\n };\n}\n\nfunction redactUnknownValue(value: unknown, rules: RedactionRule[], replacement: string): { value: unknown; replacements: number } {\n if (typeof value === \"string\") {\n return redactStringValue(value, rules, replacement);\n }\n if (Array.isArray(value)) {\n let replacements = 0;\n const nextValues = value.map((entry) => {\n const redacted = redactUnknownValue(entry, rules, replacement);\n replacements += redacted.replacements;\n return redacted.value;\n });\n return {\n value: nextValues,\n replacements,\n };\n }\n if (typeof value === \"object\" && value !== null) {\n let replacements = 0;\n const nextRecord: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const redacted = redactUnknownValue(entry, rules, replacement);\n replacements += redacted.replacements;\n nextRecord[key] = redacted.value;\n }\n return {\n value: nextRecord,\n replacements,\n };\n }\n return {\n value,\n replacements: 0,\n };\n}\n\nfunction applyHistoryPatch(current: ReplayDocument, patch: HistoryPatchOp[], entryNumber: number, op: string): ReplayDocument {\n const result = tryApplyReplayPatch(current, patch);\n /* c8 ignore start -- invalid patch replay paths are covered by replay helper tests. */\n if (!result.ok) {\n throw new PmCliError(\n `history-redact failed to apply patch at entry ${entryNumber} (op=${op}): ${\n result.error instanceof Error ? result.error.message : String(result.error)\n }`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n /* c8 ignore stop */\n return result.document;\n}\n\nfunction inspectHistoryIntegrity(entries: HistoryEntry[]): HistoryIntegritySnapshot {\n let replay = structuredClone(EMPTY_REPLAY_DOCUMENT);\n let hashMismatchesBefore = 0;\n let hashMismatchesAfter = 0;\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n hashMismatchesBefore += 1;\n }\n replay = applyHistoryPatch(replay, entry.patch, index + 1, entry.op);\n /* c8 ignore start -- after-hash mismatch branch is exercised in dedicated history integrity tests. */\n if (replayHash(replay) !== entry.after_hash) {\n hashMismatchesAfter += 1;\n }\n /* c8 ignore stop */\n }\n return {\n hashMismatchesBefore,\n hashMismatchesAfter,\n finalDocument: replay,\n };\n}\n\nfunction redactHistoryEntry(entry: HistoryEntry, rules: RedactionRule[], replacement: string): {\n entry: HistoryEntry;\n replacements: number;\n changed: boolean;\n} {\n let replacements = 0;\n let changed = false;\n let nextMessage = entry.message;\n\n if (typeof entry.message === \"string\") {\n const redactedMessage = redactStringValue(entry.message, rules, replacement);\n nextMessage = redactedMessage.value;\n replacements += redactedMessage.replacements;\n if (redactedMessage.replacements > 0) {\n changed = true;\n }\n }\n\n const nextPatch = entry.patch.map((operation) => {\n /* c8 ignore start -- patch operations without `value` are covered in lower-level patch adapters. */\n if (!Object.prototype.hasOwnProperty.call(operation, \"value\")) {\n return operation;\n }\n /* c8 ignore stop */\n const redactedValue = redactUnknownValue(operation.value, rules, replacement);\n replacements += redactedValue.replacements;\n if (redactedValue.replacements > 0) {\n changed = true;\n return {\n ...operation,\n value: redactedValue.value,\n };\n }\n return operation;\n });\n\n return {\n entry: {\n ...entry,\n message: nextMessage,\n patch: nextPatch,\n },\n replacements,\n changed,\n };\n}\n\nfunction rewriteHistoryEntries(entries: HistoryEntry[], rules: RedactionRule[], replacement: string): RedactionRewriteResult {\n let replay = structuredClone(EMPTY_REPLAY_DOCUMENT);\n let entriesChanged = 0;\n let replacements = 0;\n const rewrittenEntries: HistoryEntry[] = [];\n\n for (let index = 0; index < entries.length; index += 1) {\n const redacted = redactHistoryEntry(entries[index], rules, replacement);\n replacements += redacted.replacements;\n if (redacted.changed) {\n entriesChanged += 1;\n }\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(replay, redacted.entry.patch, index + 1, redacted.entry.op);\n const afterHash = replayHash(replay);\n rewrittenEntries.push({\n ...redacted.entry,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n }\n\n return {\n entries: rewrittenEntries,\n finalDocument: replay,\n entriesChanged,\n replacements,\n };\n}\n\nfunction hasItemMetadata(replay: ReplayDocument): boolean {\n return Object.keys(replay.metadata).length > 0;\n}\n\nasync function loadHistoryRedactCurrentItem(\n subject: HistorySubject,\n settings: Awaited<ReturnType<typeof readSettings>>,\n): Promise<HistoryRedactCurrentItem> {\n const currentItemPath = subject.located?.itemPath ?? null;\n if (!subject.located) {\n return { raw: null, path: currentItemPath, document: null };\n }\n const loaded = await readLocatedItem(subject.located, { schema: settings.schema });\n return { raw: loaded.raw, path: currentItemPath, document: loaded.document };\n}\n\nfunction resolveHistoryRedactNextItem(params: {\n pmRoot: string;\n subject: HistorySubject;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeToFolder: Record<string, string>;\n finalDocument: ReplayDocument;\n}): HistoryRedactNextItem {\n if (!hasItemMetadata(params.finalDocument)) {\n return { raw: null, path: null, document: null };\n }\n const canonical = canonicalDocument(replayToItemDocument(params.finalDocument), { schema: params.settings.schema });\n if (canonical.metadata.id !== params.subject.id) {\n throw new PmCliError(\n `history-redact would change item id from ${params.subject.id} to ${canonical.metadata.id}; narrow your patterns.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n document: canonical,\n path: getItemPath(params.pmRoot, canonical.metadata.type, params.subject.id, \"toon\", params.typeToFolder),\n raw: serializeItemDocument(canonical, {\n format: \"toon\",\n schema: params.settings.schema,\n }),\n };\n}\n\n/* v8 ignore start -- message passthrough/plural formatting is deterministic around covered redaction outcomes */\nfunction buildHistoryRedactMessage(options: HistoryRedactCommandOptions, rewritten: RedactionRewriteResult): string {\n if (typeof options.message === \"string\" && options.message.trim().length > 0) {\n return options.message;\n }\n return `history-redact replaced ${rewritten.replacements} match(es) across ${rewritten.entriesChanged} entr${\n rewritten.entriesChanged === 1 ? \"y\" : \"ies\"\n }.`;\n}\n/* v8 ignore stop */\n\nfunction buildHistoryRedactEntries(params: {\n rewritten: RedactionRewriteResult;\n dryRun: boolean;\n changed: boolean;\n nextItemDocument: ItemDocument | null;\n author: string;\n message: string;\n}): { rewrittenEntries: HistoryEntry[]; auditEntryAdded: boolean } {\n const rewrittenEntries = [...params.rewritten.entries];\n if (params.dryRun || !params.changed) {\n return { rewrittenEntries, auditEntryAdded: false };\n }\n /* c8 ignore next -- fallback replay-to-item conversion runs only when rewritten final metadata is absent. */\n const finalDocument = params.nextItemDocument ?? replayToItemDocument(params.rewritten.finalDocument);\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author: params.author,\n op: \"history_redact\",\n before: finalDocument,\n after: finalDocument,\n message: params.message,\n }),\n );\n return { rewrittenEntries, auditEntryAdded: true };\n}\n\nasync function applyHistoryRedactRewrite(params: {\n pmRoot: string;\n subject: HistorySubject;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>;\n historyRawBeforeLock: string | null;\n currentItem: HistoryRedactCurrentItem;\n nextItem: HistoryRedactNextItem;\n author: string;\n force: boolean | undefined;\n rewrittenEntries: HistoryEntry[];\n}): Promise<string[]> {\n return executeHistoryRewrite({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItem.raw,\n operation: \"history-redact\",\n author: params.author,\n force: params.force,\n itemDocument: params.currentItem.document,\n applyRewrite: async ({ historyRawUnderLock }) => {\n const affectedItemPaths = new Set<string>();\n if (params.currentItem.path) {\n affectedItemPaths.add(params.currentItem.path);\n }\n if (params.nextItem.path) {\n affectedItemPaths.add(params.nextItem.path);\n }\n const itemSnapshots = new Map<string, string>();\n if (params.currentItem.path && params.currentItem.raw !== null) {\n itemSnapshots.set(params.currentItem.path, params.currentItem.raw);\n }\n try {\n /* c8 ignore next -- item-write diff branch requires path and content divergence under lock races. */\n if (params.nextItem.path && params.nextItem.raw !== null && params.nextItem.raw !== params.currentItem.raw) {\n await writeFileAtomic(params.nextItem.path, params.nextItem.raw);\n }\n if (params.currentItem.path && (!params.nextItem.path || params.nextItem.path !== params.currentItem.path)) {\n await fs.rm(params.currentItem.path, { force: true });\n }\n await writeFileAtomic(params.subject.historyPath, historyEntriesToRaw(params.rewrittenEntries));\n } catch (error) {\n await rollbackHistoryRedactRewrite(params.subject.historyPath, historyRawUnderLock, affectedItemPaths, itemSnapshots);\n throw error;\n }\n },\n applyPostRewrite: async () => runHistoryRedactWriteHooks(params.subject.historyPath, [\n params.nextItem.path,\n params.currentItem.path,\n ]),\n });\n}\n\nasync function rollbackHistoryRedactRewrite(\n historyPath: string,\n historyRawUnderLock: string | null,\n affectedItemPaths: Set<string>,\n itemSnapshots: Map<string, string>,\n): Promise<void> {\n /* c8 ignore start -- no-history-under-lock rollback path is exercised in lock-race integration tests. */\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n /* c8 ignore stop */\n for (const itemPath of affectedItemPaths) {\n const snapshot = itemSnapshots.get(itemPath);\n /* c8 ignore start -- missing snapshot rollback occurs only for create/delete race permutations. */\n if (snapshot === undefined) {\n await fs.rm(itemPath, { force: true });\n } else {\n await writeFileAtomic(itemPath, snapshot);\n }\n /* c8 ignore stop */\n }\n}\n\nasync function runHistoryRedactWriteHooks(historyPath: string, itemHookPaths: Array<string | null>): Promise<string[]> {\n const hookWarnings: string[] = [];\n const uniqueItemHookPaths = new Set(itemHookPaths.filter((itemPath): itemPath is string => itemPath !== null));\n for (const itemHookPath of uniqueItemHookPaths) {\n hookWarnings.push(\n ...(await runActiveOnWriteHooks({\n path: itemHookPath,\n scope: \"project\",\n op: \"history_redact\",\n })),\n );\n }\n hookWarnings.push(\n ...(await runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_redact:history\",\n })),\n );\n return hookWarnings;\n}\n\n/**\n * Implements resolve history subject for the public runtime surface of this module.\n */\nexport async function resolveHistorySubject(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<HistorySubject> {\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);\n if (located) {\n return {\n id: located.id,\n historyPath: getHistoryPath(pmRoot, located.id),\n located,\n };\n }\n\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const rawNormalizedId = normalizeRawItemId(id);\n const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];\n for (const candidateId of candidateIds) {\n const historyPath = getHistoryPath(pmRoot, candidateId);\n if (await pathExists(historyPath)) {\n return {\n id: candidateId,\n historyPath,\n located: null,\n };\n }\n }\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n}\n\n/**\n * Implements run history redact for the public runtime surface of this module.\n */\nexport async function runHistoryRedact(\n id: string,\n options: HistoryRedactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryRedactResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const replacement = typeof options.replacement === \"string\" && options.replacement.length > 0 ? options.replacement : \"[redacted]\";\n const rules = buildRedactionRules(options.literal, options.regex);\n const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n\n if (!(await pathExists(subject.historyPath))) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const historyEntries = await readHistoryEntries(subject.historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to redact.`, EXIT_CODE.USAGE);\n }\n\n const integritySnapshot = inspectHistoryIntegrity(historyEntries);\n const rewritten = rewriteHistoryEntries(historyEntries, rules, replacement);\n const preexistingHashMismatches = integritySnapshot.hashMismatchesBefore + integritySnapshot.hashMismatchesAfter;\n const dryRun = Boolean(options.dryRun);\n const changed = rewritten.replacements > 0;\n const warnings: string[] = [];\n if (preexistingHashMismatches > 0) {\n warnings.push(`history_redact_preexisting_hash_mismatches:${preexistingHashMismatches}`);\n }\n if (!changed) {\n warnings.push(\"history_redact_no_matches\");\n }\n\n const currentItem = await loadHistoryRedactCurrentItem(subject, settings);\n const nextItem = resolveHistoryRedactNextItem({\n pmRoot,\n subject,\n settings,\n typeToFolder: typeRegistry.type_to_folder,\n finalDocument: rewritten.finalDocument,\n });\n\n const itemChanged =\n /* c8 ignore next -- null-coalescing item-path comparison branch is exercised in broader command integration coverage. */\n (currentItem.path ?? null) !== (nextItem.path ?? null) ||\n /* c8 ignore next -- null-coalescing item-content comparison branch is exercised in broader command integration coverage. */\n (currentItem.raw ?? null) !== (nextItem.raw ?? null);\n\n const author = resolveAuthor(options.author, settings.author_default);\n const redactionMessage = buildHistoryRedactMessage(options, rewritten);\n const { rewrittenEntries, auditEntryAdded } = buildHistoryRedactEntries({\n rewritten,\n dryRun,\n changed,\n nextItemDocument: nextItem.document,\n author,\n message: redactionMessage,\n });\n const historyVerify = verifyHistoryChain(rewrittenEntries);\n /* c8 ignore start -- invalid rewritten chains are covered by history verification unit tests. */\n if (!historyVerify.ok) {\n throw new PmCliError(\n `history-redact produced an invalid rewritten chain (${historyVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n /* c8 ignore stop */\n\n if (!dryRun && changed) {\n warnings.push(\n ...(await applyHistoryRedactRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItem,\n nextItem,\n author,\n force: options.force,\n rewrittenEntries,\n })),\n );\n }\n\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n patterns: {\n literals: rules.filter((rule): rule is LiteralRule => rule.kind === \"literal\").map((rule) => rule.value),\n regex: rules.filter((rule): rule is RegexRule => rule.kind === \"regex\").map((rule) => `/${rule.source}/${rule.flags}`),\n replacement,\n },\n history: {\n path: subject.historyPath,\n entries_scanned: historyEntries.length,\n entries_changed: rewritten.entriesChanged,\n replacements: rewritten.replacements,\n hash_mismatches_before: integritySnapshot.hashMismatchesBefore,\n hash_mismatches_after: integritySnapshot.hashMismatchesAfter,\n preexisting_hash_mismatches: preexistingHashMismatches,\n audit_entry_added: auditEntryAdded,\n verify_ok: historyVerify.ok,\n verify_errors: historyVerify.errors,\n },\n item: {\n existed_before: currentItem.path !== null,\n exists_after: nextItem.path !== null,\n path_before: currentItem.path,\n path_after: nextItem.path,\n changed: itemChanged,\n },\n /* c8 ignore next -- warning dedupe ordering is covered indirectly by command-level smoke tests. */\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n\nexport const _testOnly = {\n applyLiteralRule,\n applyRegexRule,\n buildRedactionRules,\n hasItemMetadata,\n normalizeRegexFlags,\n normalizeStringArrayInput,\n parseRegexRule,\n redactStringValue,\n redactUnknownValue,\n};\n", "/**\n * @module core/history/history-rewrite\n *\n * Implements append-only history and replay behavior for History Rewrite.\n */\nimport fs from \"node:fs/promises\";\nimport { readFileIfExists, writeFileAtomic } from \"../fs/fs-utils.js\";\nimport type { ItemTypeRegistry } from \"../item/type-registry.js\";\nimport { acquireLock } from \"../lock/lock.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { locateItem, readLocatedItem } from \"../store/item-store.js\";\nimport { resolveGovernanceKnobs } from \"../store/settings.js\";\nimport type { ItemDocument, PmSettings } from \"../../types/index.js\";\n\ntype LoadedItem = Awaited<ReturnType<typeof readLocatedItem>>;\ntype HistoryRawWriter = (filePath: string, content: string) => Promise<void>;\n\n/**\n * Documents the history rewrite subject payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRewriteSubject {\n id: string;\n historyPath: string;\n}\n\n/**\n * Documents the history rewrite ownership params payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryRewriteOwnershipParams {\n itemDocument: ItemDocument | null;\n subjectId: string;\n author: string;\n force: boolean | undefined;\n settings: PmSettings;\n}\n\n/**\n * Apply ownership_enforcement governance to a history-rewriting operation.\n * Returns the warning(s) the caller should append (empty when no conflict or strict-throws).\n * Throws PmCliError(CONFLICT) in strict mode when the assignee conflicts and --force is not set.\n */\nexport function checkHistoryRewriteOwnership(params: HistoryRewriteOwnershipParams): string[] {\n if (!params.itemDocument) return [];\n const assigned = params.itemDocument.metadata?.assignee?.trim();\n if (!assigned || assigned === params.author || params.force) return [];\n\n const governance = resolveGovernanceKnobs(params.settings);\n if (governance.ownership_enforcement === \"strict\") {\n throw new PmCliError(\n `Item ${params.subjectId} is assigned to ${assigned}. Use --force to override.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (governance.ownership_enforcement === \"warn\") {\n return [`ownership_warning:assignee_conflict:${params.subjectId}:${assigned}`];\n }\n return [];\n}\n\n/**\n * Documents the verify history rewrite drift params payload exchanged by command, SDK, and package integrations.\n */\nexport interface VerifyHistoryRewriteDriftParams {\n pmRoot: string;\n subject: HistoryRewriteSubject;\n settings: PmSettings;\n typeRegistry: ItemTypeRegistry;\n historyRawBeforeLock: string | null;\n currentItemRawBeforeLock: string | null;\n /** Short operation name used in the conflict message (e.g. \"history-redact\"). */\n operation: string;\n}\n\n/**\n * Documents the verified history rewrite state payload exchanged by command, SDK, and package integrations.\n */\nexport interface VerifiedHistoryRewriteState {\n historyRawUnderLock: string | null;\n locatedUnderLock: Awaited<ReturnType<typeof locateItem>>;\n loadedItemUnderLock: LoadedItem | null;\n}\n\n/**\n * Re-read the history stream and the located item document under the acquired lock and\n * compare both with the pre-lock raw snapshots. Throws PmCliError(CONFLICT) if either\n * diverged while waiting for the lock so the caller surfaces an actionable retry.\n */\nexport async function verifyHistoryRewriteNoDrift(\n params: VerifyHistoryRewriteDriftParams,\n): Promise<VerifiedHistoryRewriteState> {\n const historyRawUnderLock = await readFileIfExists(params.subject.historyPath);\n if (historyRawUnderLock !== params.historyRawBeforeLock) {\n throw new PmCliError(\n `History for ${params.subject.id} changed while waiting for lock; retry ${params.operation}.`,\n EXIT_CODE.CONFLICT,\n );\n }\n const locatedUnderLock = await locateItem(\n params.pmRoot,\n params.subject.id,\n params.settings.id_prefix,\n params.settings.item_format,\n params.typeRegistry.type_to_folder,\n );\n const loadedItemUnderLock = locatedUnderLock\n ? await readLocatedItem(locatedUnderLock, { schema: params.settings.schema })\n : null;\n if ((loadedItemUnderLock?.raw ?? null) !== (params.currentItemRawBeforeLock ?? null)) {\n throw new PmCliError(\n `Item ${params.subject.id} changed while waiting for lock; retry ${params.operation}.`,\n EXIT_CODE.CONFLICT,\n );\n }\n return { historyRawUnderLock, locatedUnderLock, loadedItemUnderLock };\n}\n\n/**\n * Documents the execute history rewrite params payload exchanged by command, SDK, and package integrations.\n */\nexport interface ExecuteHistoryRewriteParams {\n pmRoot: string;\n subject: HistoryRewriteSubject;\n settings: PmSettings;\n typeRegistry: ItemTypeRegistry;\n historyRawBeforeLock: string | null;\n currentItemRawBeforeLock: string | null;\n /** Short operation name used in conflict guidance (e.g. \"history-redact\"). */\n operation: string;\n author: string;\n force: boolean | undefined;\n itemDocument: ItemDocument | null;\n applyRewrite: (verified: VerifiedHistoryRewriteState) => Promise<void>;\n applyPostRewrite?: (verified: VerifiedHistoryRewriteState) => Promise<string[]>;\n}\n\n/**\n * Writes the rewritten history stream and restores the under-lock snapshot on failure.\n */\nexport async function writeHistoryRawWithRollback(params: {\n historyPath: string;\n nextHistoryRaw: string;\n historyRawUnderLock: string | null;\n writeHistoryRaw?: HistoryRawWriter;\n}): Promise<void> {\n const writeHistoryRaw = params.writeHistoryRaw ?? writeFileAtomic;\n try {\n await writeHistoryRaw(params.historyPath, params.nextHistoryRaw);\n } catch (error) {\n try {\n if (params.historyRawUnderLock === null) {\n await fs.rm(params.historyPath, { force: true });\n } else {\n await writeHistoryRaw(params.historyPath, params.historyRawUnderLock);\n }\n } catch (rollbackError) {\n throw new AggregateError(\n [error, rollbackError],\n `History rewrite failed and rollback also failed: ${String(error)}`,\n );\n }\n throw error;\n }\n}\n\n/**\n * Shared lock/verify/ownership orchestration for history-rewrite commands.\n * Callers provide the operation-specific write/rollback logic and optional\n * post-write hook execution while this helper enforces the common governance +\n * lock sequencing contract.\n */\nexport async function executeHistoryRewrite(params: ExecuteHistoryRewriteParams): Promise<string[]> {\n const warnings = [...checkHistoryRewriteOwnership({\n itemDocument: params.itemDocument,\n subjectId: params.subject.id,\n author: params.author,\n force: params.force,\n settings: params.settings,\n })];\n const releaseLock = await acquireLock(\n params.pmRoot,\n params.subject.id,\n params.settings.locks.ttl_seconds,\n params.author,\n Boolean(params.force),\n params.settings.governance.force_required_for_stale_lock,\n params.settings.locks.wait_ms,\n );\n try {\n const verified = await verifyHistoryRewriteNoDrift({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItemRawBeforeLock,\n operation: params.operation,\n });\n await params.applyRewrite(verified);\n if (params.applyPostRewrite) {\n warnings.push(...(await params.applyPostRewrite(verified)));\n }\n return warnings;\n } finally {\n await releaseLock();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAOA,SAAQ;;;ACAf,OAAO,QAAQ;;;;;;;;AAqCT,SAAU,6BAA6B,QAAqC;AAChF,MAAI,CAAC,OAAO;AAAc,WAAO,CAAA;AACjC,QAAM,WAAW,OAAO,aAAa,UAAU,UAAU,KAAI;AAC7D,MAAI,CAAC,YAAY,aAAa,OAAO,UAAU,OAAO;AAAO,WAAO,CAAA;AAEpE,QAAM,aAAa,uBAAuB,OAAO,QAAQ;AACzD,MAAI,WAAW,0BAA0B,UAAU;AACjD,UAAM,IAAI,WACR,QAAQ,OAAO,SAAS,mBAAmB,QAAQ,8BACnD,UAAU,QAAQ;EAEtB;AACA,MAAI,WAAW,0BAA0B,QAAQ;AAC/C,WAAO,CAAC,uCAAuC,OAAO,SAAS,IAAI,QAAQ,EAAE;EAC/E;AACA,SAAO,C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kBAAkB;MAC1C,uBAAuB,kBAAkB;MACzC,6BAA6B;MAC7B,mBAAmB;MACnB,WAAW,cAAc;MACzB,eAAe,cAAc;;IAE/B,MAAM;MACJ,gBAAgB,YAAY,SAAS;MACrC,cAAc,SAAS,SAAS;MAChC,aAAa,YAAY;MACzB,YAAY,SAAS;MACrB,SAAS;;;IAGX,UAAU,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAChF,cAAc,OAAM;;AAExB;AAEO,IAAM,YAAY;EACvB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;",
6
6
  "names": ["fs", "fs", "global"]
7
7
  }
@@ -1,11 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="652b0f45-5bb7-52ea-967d-44b4e556bc1b")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="80e4cdd6-dd3f-5ce4-9549-330a2bc292cd")}catch(e){}}();
3
3
  import {
4
4
  resolveAuthor
5
5
  } from "./chunk-T5RRNDA7.js";
6
6
  import {
7
7
  readHistoryEntries
8
- } from "./chunk-IX5BXEMX.js";
8
+ } from "./chunk-565WYS5W.js";
9
9
  import {
10
10
  EMPTY_REPLAY_DOCUMENT,
11
11
  normalizeReplayPatchOps,
@@ -13,32 +13,26 @@ import {
13
13
  replayToCanonicalItemDocument,
14
14
  replayToItemDocument,
15
15
  toReplayDocument
16
- } from "./chunk-OGWQ2IEP.js";
16
+ } from "./chunk-7Y5N34HX.js";
17
17
  import {
18
+ PmCliError,
18
19
  acquireLock,
19
20
  appendHistoryEntry,
21
+ canonicalDocument,
20
22
  createHistoryEntry,
21
23
  enforceHistoryStreamPolicyForItem,
24
+ getActiveExtensionRegistrations,
22
25
  locateItem,
23
- readLocatedItem
24
- } from "./chunk-ENGQOEUY.js";
25
- import {
26
- canonicalDocument,
27
26
  normalizeItemId,
28
27
  normalizeRawItemId,
29
- serializeItemDocument
30
- } from "./chunk-G24G7ZAV.js";
31
- import {
32
- nowIso
33
- } from "./chunk-3GCS5SKL.js";
34
- import {
35
- PmCliError,
36
- getActiveExtensionRegistrations,
28
+ nowIso,
37
29
  projectAfterCommandItemSnapshot,
30
+ readLocatedItem,
38
31
  readSettings,
39
32
  recordAfterCommandAffectedItem,
40
- runActiveOnWriteHooks
41
- } from "./chunk-E3SZTQ4K.js";
33
+ runActiveOnWriteHooks,
34
+ serializeItemDocument
35
+ } from "./chunk-GH73UOSJ.js";
42
36
  import {
43
37
  EXIT_CODE,
44
38
  getHistoryPath,
@@ -49,7 +43,7 @@ import {
49
43
  resolveItemTypeRegistry,
50
44
  resolvePmRoot,
51
45
  writeFileAtomic
52
- } from "./chunk-57NWPFF2.js";
46
+ } from "./chunk-UO7XAZK6.js";
53
47
 
54
48
  // dist/cli/commands/restore.js
55
49
  import jsonPatch from "fast-json-patch";
@@ -421,6 +415,6 @@ export {
421
415
  runRestore,
422
416
  _testOnlyRestoreCommand
423
417
  };
424
- //# sourceMappingURL=chunk-YN7Y6DQZ.js.map
418
+ //# sourceMappingURL=chunk-EMXPI36L.js.map
425
419
 
426
- //# debugId=652b0f45-5bb7-52ea-967d-44b4e556bc1b
420
+ //# debugId=80e4cdd6-dd3f-5ce4-9549-330a2bc292cd
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../cli/commands/restore.ts"],"sourcesContent":["/**\n * @module cli/commands/restore\n *\n * Implements the pm restore command surface and its agent-facing runtime behavior.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport fs from \"node:fs/promises\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { appendHistoryEntry, createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n normalizeReplayPatchOps,\n replayHash,\n replayToCanonicalItemDocument,\n replayToItemDocument,\n toReplayDocument,\n type ReplayDocument as CanonicalReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { enforceHistoryStreamPolicyForItem } from \"../../core/history/history-stream-policy.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../../core/item/id.js\";\nimport { canonicalDocument, serializeItemDocument } from \"../../core/item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { acquireLock } from \"../../core/lock/lock.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport {\n getActiveExtensionRegistrations,\n projectAfterCommandItemSnapshot,\n recordAfterCommandAffectedItem,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { locateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\n\ninterface ResolvedRestoreTarget {\n kind: \"version\" | \"timestamp\";\n raw: string;\n historyIndex: number;\n}\n\ninterface ResolvedRestoreSubject {\n id: string;\n historyPath: string;\n located: Awaited<ReturnType<typeof locateItem>>;\n historyPolicyWarnings: string[];\n}\n\ninterface RestoreCurrentState {\n document: ItemDocument;\n originalRaw: string | null;\n}\n\ninterface PatchFailureContext {\n patchIndex?: number;\n op?: string;\n path?: string;\n from?: string;\n reason?: string;\n}\n\n/**\n * Documents the restore command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreCommandOptions {\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/**\n * Documents the restore result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreResult {\n item: ItemMetadata;\n restored_from: {\n kind: \"version\" | \"timestamp\";\n target: string;\n history_index: number;\n entry_ts: string;\n entry_op: string;\n };\n changed_fields: string[];\n warnings: string[];\n}\n\nfunction ensureReplayTarget(target: string, history: HistoryEntry[]): ResolvedRestoreTarget {\n const trimmed = target.trim();\n if (!trimmed) {\n throw new PmCliError(\"Missing restore target. Use a timestamp or version number.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(trimmed)) {\n const version = Number(trimmed);\n if (!Number.isSafeInteger(version) || version < 1 || version > history.length) {\n throw new PmCliError(\n `Restore version must be between 1 and ${history.length} for this item.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n kind: \"version\",\n raw: trimmed,\n historyIndex: version - 1,\n };\n }\n\n const parsedTarget = Date.parse(trimmed);\n if (!Number.isFinite(parsedTarget)) {\n throw new PmCliError(\n `Invalid restore target \"${target}\". Use a positive version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let index = -1;\n for (let i = 0; i < history.length; i += 1) {\n const entryTimestamp = Date.parse(history[i].ts);\n if (!Number.isFinite(entryTimestamp)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTimestamp <= parsedTarget) {\n index = i;\n }\n }\n\n if (index < 0) {\n throw new PmCliError(`No history entries exist at or before timestamp ${trimmed}.`, EXIT_CODE.USAGE);\n }\n\n return {\n kind: \"timestamp\",\n raw: trimmed,\n historyIndex: index,\n };\n}\n\nfunction extractPatchFailureContext(\n patch: HistoryPatchOp[],\n error: unknown,\n): PatchFailureContext {\n const context: PatchFailureContext = {};\n if (error instanceof Error && error.message.trim().length > 0) {\n context.reason = error.message.trim();\n }\n if (typeof error !== \"object\" || error === null) {\n return context;\n }\n const candidate = error as {\n index?: unknown;\n operation?: unknown;\n };\n /* c8 ignore start -- parser-generated patch errors may omit index metadata in current fixtures. */\n if (typeof candidate.index === \"number\" && Number.isInteger(candidate.index) && candidate.index >= 0) {\n context.patchIndex = candidate.index;\n }\n /* c8 ignore stop */\n /* c8 ignore start -- operation payload metadata is optional in upstream json-patch failures. */\n const operationRecord =\n typeof candidate.operation === \"object\" && candidate.operation !== null\n ? (candidate.operation as { op?: unknown; path?: unknown; from?: unknown })\n : null;\n /* c8 ignore stop */\n enrichPatchFailureContext(context, operationRecord, patch);\n return context;\n}\n\nfunction enrichPatchFailureContext(\n context: PatchFailureContext,\n operationRecord: { op?: unknown; path?: unknown; from?: unknown } | null,\n patch: HistoryPatchOp[],\n): void {\n /* v8 ignore start -- operation replay records always carry a string op when present; this preserves context for malformed future rows */\n if (operationRecord && typeof operationRecord.op === \"string\") {\n context.op = operationRecord.op;\n }\n /* v8 ignore stop */\n if (operationRecord && typeof operationRecord.path === \"string\") {\n context.path = operationRecord.path;\n }\n if (operationRecord && typeof operationRecord.from === \"string\") {\n context.from = operationRecord.from;\n }\n if ((context.op === undefined || context.path === undefined) && context.patchIndex !== undefined) {\n const fallback = patch[context.patchIndex];\n /* c8 ignore start -- fallback enrichment paths are only exercised by malformed patch telemetry payloads. */\n if (fallback) {\n context.op = context.op ?? fallback.op;\n context.path = context.path ?? fallback.path;\n context.from = context.from ?? fallback.from;\n }\n /* c8 ignore stop */\n }\n}\n\nfunction applyHistoryPatch(\n current: CanonicalReplayDocument,\n patch: HistoryPatchOp[],\n entryNumber: number,\n entryOp: string,\n): CanonicalReplayDocument {\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 (\n typeof applied !== \"object\" ||\n applied === null ||\n !(\"metadata\" in applied) ||\n !(\"body\" in applied) ||\n typeof (applied as { body: unknown }).body !== \"string\" ||\n typeof (applied as { metadata: unknown }).metadata !== \"object\" ||\n (applied as { metadata: unknown }).metadata === null\n ) {\n throw new PmCliError(\n `History replay produced an invalid document shape at entry ${entryNumber}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const replay = applied as { metadata: Record<string, unknown>; body: string };\n return {\n metadata: replay.metadata,\n body: replay.body,\n };\n } catch (error: unknown) {\n if (error instanceof PmCliError) {\n throw error;\n }\n const failureContext = extractPatchFailureContext(patch, error);\n const contextTokens = [\n `history_op=${entryOp}`,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.patchIndex !== undefined ? `patch_index=${failureContext.patchIndex}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.op ? `op=${failureContext.op}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.path ? `path=${failureContext.path}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.from ? `from=${failureContext.from}` : null,\n ].filter((token): token is string => token !== null);\n /* c8 ignore start -- jsonPatch/structuredClone/normalizeReplayPatchOps always throw Error instances with non-empty messages here, so extractPatchFailureContext always sets reason; the empty-suffix fallback is unreachable through applyHistoryPatch. */\n const reasonSuffix = failureContext.reason ? ` ${failureContext.reason}` : \"\";\n /* c8 ignore stop */\n throw new PmCliError(\n `Failed to apply history patch at entry ${entryNumber} (${contextTokens.join(\", \")}).${reasonSuffix}`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n}\n\nfunction replayToTarget(history: HistoryEntry[], targetIndex: number): CanonicalReplayDocument {\n let document: CanonicalReplayDocument = structuredClone(EMPTY_REPLAY_DOCUMENT);\n\n for (let i = 0; i <= targetIndex; i += 1) {\n const entry = history[i];\n const beforeHash = replayHash(document);\n if (beforeHash !== entry.before_hash) {\n throw new PmCliError(\n `History hash mismatch before replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n document = applyHistoryPatch(document, entry.patch, i + 1, entry.op);\n\n const afterHash = replayHash(document);\n if (afterHash !== entry.after_hash) {\n throw new PmCliError(\n `History hash mismatch after replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n\n return document;\n}\n\nfunction ensureMaterializedRestoreTarget(\n replayDocument: CanonicalReplayDocument,\n target: ResolvedRestoreTarget,\n): CanonicalReplayDocument {\n if (Object.keys(replayDocument.metadata).length > 0) {\n return replayDocument;\n }\n throw new PmCliError(\n `Restore target ${target.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction replayCurrentDocument(history: HistoryEntry[]): ItemDocument {\n const currentReplay = replayToTarget(history, history.length - 1);\n if (Object.keys(currentReplay.metadata).length === 0) {\n return {\n metadata: {} as ItemMetadata,\n body: currentReplay.body,\n };\n }\n return canonicalDocument(replayToItemDocument(currentReplay));\n}\n\nasync function resolveRestoreSubject(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<ResolvedRestoreSubject> {\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);\n if (located) {\n const historyPath = getHistoryPath(pmRoot, located.id);\n const historyPolicy = await enforceHistoryStreamPolicyForItem({\n pmRoot,\n settings,\n itemId: located.id,\n commandLabel: \"restore\",\n });\n return {\n id: located.id,\n historyPath,\n located,\n historyPolicyWarnings: historyPolicy.warnings,\n };\n }\n\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const rawNormalizedId = normalizeRawItemId(id);\n /* c8 ignore start -- raw-id fallback is covered by normalize-item-id utility tests. */\n const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];\n /* c8 ignore stop */\n for (const candidateId of candidateIds) {\n const historyPath = getHistoryPath(pmRoot, candidateId);\n if (await pathExists(historyPath)) {\n return {\n id: candidateId,\n historyPath,\n located: null,\n historyPolicyWarnings: [],\n };\n }\n }\n\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n}\n\nfunction changedFields(beforeDocument: ItemDocument, afterDocument: ItemDocument): string[] {\n const beforeReplay = toReplayDocument(beforeDocument);\n const afterReplay = toReplayDocument(afterDocument);\n const patch = jsonPatch.compare(beforeReplay, afterReplay) as HistoryPatchOp[];\n const fields = new Set<string>();\n\n for (const op of patch) {\n if (op.path === \"/body\" || op.path.startsWith(\"/body/\")) {\n fields.add(\"body\");\n continue;\n }\n const segment = op.path.replace(/^\\/(?:metadata|front_matter)\\/?/, \"\").split(\"/\")[0];\n fields.add(segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n }\n\n return Array.from(fields).sort((a, b) => a.localeCompare(b));\n}\n\nasync function loadRestoreStateUnderLock(params: {\n pmRoot: string;\n resolvedId: string;\n subject: ResolvedRestoreSubject;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeToFolder: Record<string, string>;\n historyRawBeforeLock: string | null;\n currentItemRawBeforeLock: string | null;\n}): Promise<{ loadedItemUnderLock: Awaited<ReturnType<typeof readLocatedItem>> | null; existingItemPath: string | null }> {\n const historyRawUnderLock = await readFileIfExists(params.subject.historyPath);\n if (historyRawUnderLock !== params.historyRawBeforeLock) {\n throw new PmCliError(`History for ${params.resolvedId} changed while waiting for lock; retry restore.`, EXIT_CODE.CONFLICT);\n }\n const locatedUnderLock = await locateItem(\n params.pmRoot,\n params.resolvedId,\n params.settings.id_prefix,\n params.settings.item_format,\n params.typeToFolder,\n );\n const loadedItemUnderLock = locatedUnderLock ? await readLocatedItem(locatedUnderLock, { schema: params.settings.schema }) : null;\n if ((loadedItemUnderLock?.raw ?? null) !== params.currentItemRawBeforeLock) {\n throw new PmCliError(`Item ${params.resolvedId} changed while waiting for lock; retry restore.`, EXIT_CODE.CONFLICT);\n }\n return { loadedItemUnderLock, existingItemPath: locatedUnderLock?.itemPath ?? null };\n}\n\nfunction resolveRestoreCurrentState(\n loadedItemUnderLock: Awaited<ReturnType<typeof readLocatedItem>> | null,\n history: HistoryEntry[],\n): RestoreCurrentState {\n if (loadedItemUnderLock) {\n return { document: loadedItemUnderLock.document, originalRaw: loadedItemUnderLock.raw };\n }\n return { document: replayCurrentDocument(history), originalRaw: null };\n}\n\nfunction collectRestoreOwnershipWarnings(params: {\n document: ItemDocument;\n author: string;\n force: boolean | undefined;\n enforcement: \"strict\" | \"warn\" | \"none\";\n resolvedId: string;\n}): string[] {\n const assigned = params.document.metadata.assignee?.trim();\n const hasOwnershipConflict = assigned && assigned !== params.author && !params.force;\n if (!hasOwnershipConflict) {\n return [];\n }\n if (params.enforcement === \"strict\") {\n throw new PmCliError(`Item ${params.resolvedId} is assigned to ${assigned}. Use --force to override.`, EXIT_CODE.CONFLICT);\n }\n return params.enforcement === \"warn\" ? [`ownership_warning:assignee_conflict:${params.resolvedId}:${assigned}`] : [];\n}\n\nasync function restorePreviousItemAfterHistoryFailure(params: {\n existingItemPath: string | null;\n resolvedOriginalRaw: string | null;\n restoredItemPath: string;\n}): Promise<void> {\n if (params.existingItemPath && params.resolvedOriginalRaw !== null && params.restoredItemPath !== params.existingItemPath) {\n await writeFileAtomic(params.existingItemPath, params.resolvedOriginalRaw);\n await fs.rm(params.restoredItemPath, { force: true });\n return;\n }\n if (params.existingItemPath && params.resolvedOriginalRaw !== null) {\n await writeFileAtomic(params.existingItemPath, params.resolvedOriginalRaw);\n return;\n }\n await fs.rm(params.restoredItemPath, { force: true });\n}\n\nasync function runRestoreWriteHooks(params: {\n restoredItemPath: string;\n historyPath: string;\n before: ItemDocument;\n after: ItemDocument;\n}): Promise<string[]> {\n return [\n ...(await runActiveOnWriteHooks({\n path: params.restoredItemPath,\n scope: \"project\",\n op: \"restore\",\n item_id: params.after.metadata.id,\n item_type: params.after.metadata.type,\n before: params.before,\n after: params.after,\n changed_fields: [\"restored\"],\n })),\n ...(await runActiveOnWriteHooks({\n path: params.historyPath,\n scope: \"project\",\n op: \"restore:history\",\n item_id: params.after.metadata.id,\n item_type: params.after.metadata.type,\n before: params.before,\n after: params.after,\n changed_fields: [\"restored\"],\n })),\n ];\n}\n\n/**\n * Implements run restore for the public runtime surface of this module.\n */\nexport async function runRestore(\n id: string,\n target: string,\n options: RestoreCommandOptions,\n global: GlobalOptions,\n): Promise<RestoreResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveRestoreSubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n const resolvedId = subject.id;\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const history = await readHistoryEntries(subject.historyPath, resolvedId);\n if (history.length === 0) {\n throw new PmCliError(`No history exists for ${resolvedId}; restore is unavailable.`, EXIT_CODE.NOT_FOUND);\n }\n\n const resolvedTarget = ensureReplayTarget(target, history);\n const replayDocument = ensureMaterializedRestoreTarget(replayToTarget(history, resolvedTarget.historyIndex), resolvedTarget);\n const restoredDocument = replayToCanonicalItemDocument(replayDocument, { schema: settings.schema });\n\n if (restoredDocument.metadata.id !== resolvedId) {\n throw new PmCliError(\n `Restore target resolved to item ${restoredDocument.metadata.id}, expected ${resolvedId}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const loadedItemBeforeLock = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItemBeforeLock?.raw ?? null;\n\n const author = resolveAuthor(options.author, settings.author_default);\n const releaseLock = await acquireLock(\n pmRoot,\n resolvedId,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n settings.governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n\n try {\n const { loadedItemUnderLock, existingItemPath } = await loadRestoreStateUnderLock({\n pmRoot,\n resolvedId,\n subject,\n settings,\n typeToFolder: typeRegistry.type_to_folder,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n });\n const itemFormat = \"toon\";\n const currentState = resolveRestoreCurrentState(loadedItemUnderLock, history);\n const ownershipWarnings = collectRestoreOwnershipWarnings({\n document: currentState.document,\n author,\n force: options.force,\n enforcement: settings.governance.ownership_enforcement,\n resolvedId,\n });\n\n const serializedRestore = serializeItemDocument(restoredDocument, { format: itemFormat, schema: settings.schema });\n /* c8 ignore next -- restored item path typing is exercised in restore integration workflows. */\n const restoredItemPath = getItemPath(\n pmRoot,\n restoredDocument.metadata.type,\n resolvedId,\n itemFormat,\n typeRegistry.type_to_folder,\n );\n await writeFileAtomic(restoredItemPath, serializedRestore);\n if (existingItemPath && restoredItemPath !== existingItemPath) {\n await fs.rm(existingItemPath);\n }\n\n const historyEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"restore\",\n before: currentState.document,\n after: restoredDocument,\n message: options.message,\n });\n\n try {\n await appendHistoryEntry(subject.historyPath, historyEntry);\n } catch (error: unknown) {\n await restorePreviousItemAfterHistoryFailure({\n existingItemPath,\n resolvedOriginalRaw: currentState.originalRaw,\n restoredItemPath,\n });\n throw error;\n }\n const restoreChangedFields = changedFields(currentState.document, restoredDocument);\n const hookWarnings = await runRestoreWriteHooks({\n restoredItemPath,\n historyPath: subject.historyPath,\n before: currentState.document,\n after: restoredDocument,\n });\n recordAfterCommandAffectedItem({\n id: restoredDocument.metadata.id,\n op: \"restore\",\n item_type: restoredDocument.metadata.type,\n previous_status: currentState.document.metadata.status,\n status: restoredDocument.metadata.status,\n previous: projectAfterCommandItemSnapshot(currentState.document.metadata, restoreChangedFields),\n current: projectAfterCommandItemSnapshot(restoredDocument.metadata, restoreChangedFields),\n changed_fields: restoreChangedFields,\n });\n\n const targetEntry = history[resolvedTarget.historyIndex];\n return {\n item: restoredDocument.metadata,\n restored_from: {\n kind: resolvedTarget.kind,\n target: resolvedTarget.raw,\n history_index: resolvedTarget.historyIndex + 1,\n entry_ts: targetEntry.ts,\n entry_op: targetEntry.op,\n },\n changed_fields: restoreChangedFields,\n warnings: [...subject.historyPolicyWarnings, ...ownershipWarnings, ...hookWarnings],\n };\n } finally {\n await releaseLock();\n }\n}\n\nexport const _testOnlyRestoreCommand = {\n applyHistoryPatch,\n changedFields,\n ensureMaterializedRestoreTarget,\n ensureReplayTarget,\n extractPatchFailureContext,\n replayCurrentDocument,\n replayToTarget,\n resolveRestoreSubject,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,eAAe;AACtB,OAAO,QAAQ;AAqFf,SAAS,mBAAmB,QAAgB,SAAuB;AACjE,QAAM,UAAU,OAAO,KAAI;AAC3B,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,WAAW,8DAA8D,UAAU,KAAK;EACpG;AAEA,MAAI,QAAQ,KAAK,OAAO,GAAG;AACzB,UAAM,UAAU,OAAO,OAAO;AAC9B,QAAI,CAAC,OAAO,cAAc,OAAO,KAAK,UAAU,KAAK,UAAU,QAAQ,QAAQ;AAC7E,YAAM,IAAI,WACR,yCAAyC,QAAQ,MAAM,mBACvD,UAAU,KAAK;IAEnB;AACA,WAAO;MACL,MAAM;MACN,KAAK;MACL,cAAc,UAAU;;EAE5B;AAEA,QAAM,eAAe,KAAK,MAAM,OAAO;AACvC,MAAI,CAAC,OAAO,SAAS,YAAY,GAAG;AAClC,UAAM,IAAI,WACR,2BAA2B,MAAM,sDACjC,UAAU,KAAK;EAEnB;AAEA,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK,GAAG;AAC1C,UAAM,iBAAiB,KAAK,MAAM,QAAQ,CAAC,EAAE,EAAE;AAC/C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AS;MAC9B,IAAI;MACJ,WAAW,iBAAiB,SAAS;MACrC,iBAAiB,aAAa,SAAS,SAAS;MAChD,QAAQ,iBAAiB,SAAS;MAClC,UAAU,gCAAgC,aAAa,SAAS,UAAU,oBAAoB;MAC9F,SAAS,gCAAgC,iBAAiB,UAAU,oBAAoB;MACxF,gBAAgB;KACjB;AAED,UAAM,cAAc,QAAQ,eAAe,YAAY;AACvD,WAAO;MACL,MAAM,iBAAiB;MACvB,eAAe;QACb,MAAM,eAAe;QACrB,QAAQ,eAAe;QACvB,eAAe,eAAe,eAAe;QAC7C,UAAU,YAAY;QACtB,UAAU,YAAY;;MAExB,gBAAgB;MAChB,UAAU,CAAC,GAAG,QAAQ,uBAAuB,GAAG,mBAAmB,GAAG,YAAY;;EAEtF;AACE,UAAM,YAAW;EACnB;AACF;AAEO,IAAM,0BAA0B;EACrC;EACA;EACA;EACA;EACA;EACA;EACA;EACA","debugId":"652b0f45-5bb7-52ea-967d-44b4e556bc1b"}
1
+ {"version":3,"sources":["../../../../../../../../cli/commands/restore.ts"],"sourcesContent":["/**\n * @module cli/commands/restore\n *\n * Implements the pm restore command surface and its agent-facing runtime behavior.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport fs from \"node:fs/promises\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { appendHistoryEntry, createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n normalizeReplayPatchOps,\n replayHash,\n replayToCanonicalItemDocument,\n replayToItemDocument,\n toReplayDocument,\n type ReplayDocument as CanonicalReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { enforceHistoryStreamPolicyForItem } from \"../../core/history/history-stream-policy.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../../core/item/id.js\";\nimport { canonicalDocument, serializeItemDocument } from \"../../core/item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { acquireLock } from \"../../core/lock/lock.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport {\n getActiveExtensionRegistrations,\n projectAfterCommandItemSnapshot,\n recordAfterCommandAffectedItem,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { locateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\n\ninterface ResolvedRestoreTarget {\n kind: \"version\" | \"timestamp\";\n raw: string;\n historyIndex: number;\n}\n\ninterface ResolvedRestoreSubject {\n id: string;\n historyPath: string;\n located: Awaited<ReturnType<typeof locateItem>>;\n historyPolicyWarnings: string[];\n}\n\ninterface RestoreCurrentState {\n document: ItemDocument;\n originalRaw: string | null;\n}\n\ninterface PatchFailureContext {\n patchIndex?: number;\n op?: string;\n path?: string;\n from?: string;\n reason?: string;\n}\n\n/**\n * Documents the restore command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreCommandOptions {\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/**\n * Documents the restore result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreResult {\n item: ItemMetadata;\n restored_from: {\n kind: \"version\" | \"timestamp\";\n target: string;\n history_index: number;\n entry_ts: string;\n entry_op: string;\n };\n changed_fields: string[];\n warnings: string[];\n}\n\nfunction ensureReplayTarget(target: string, history: HistoryEntry[]): ResolvedRestoreTarget {\n const trimmed = target.trim();\n if (!trimmed) {\n throw new PmCliError(\"Missing restore target. Use a timestamp or version number.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(trimmed)) {\n const version = Number(trimmed);\n if (!Number.isSafeInteger(version) || version < 1 || version > history.length) {\n throw new PmCliError(\n `Restore version must be between 1 and ${history.length} for this item.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n kind: \"version\",\n raw: trimmed,\n historyIndex: version - 1,\n };\n }\n\n const parsedTarget = Date.parse(trimmed);\n if (!Number.isFinite(parsedTarget)) {\n throw new PmCliError(\n `Invalid restore target \"${target}\". Use a positive version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let index = -1;\n for (let i = 0; i < history.length; i += 1) {\n const entryTimestamp = Date.parse(history[i].ts);\n if (!Number.isFinite(entryTimestamp)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTimestamp <= parsedTarget) {\n index = i;\n }\n }\n\n if (index < 0) {\n throw new PmCliError(`No history entries exist at or before timestamp ${trimmed}.`, EXIT_CODE.USAGE);\n }\n\n return {\n kind: \"timestamp\",\n raw: trimmed,\n historyIndex: index,\n };\n}\n\nfunction extractPatchFailureContext(\n patch: HistoryPatchOp[],\n error: unknown,\n): PatchFailureContext {\n const context: PatchFailureContext = {};\n if (error instanceof Error && error.message.trim().length > 0) {\n context.reason = error.message.trim();\n }\n if (typeof error !== \"object\" || error === null) {\n return context;\n }\n const candidate = error as {\n index?: unknown;\n operation?: unknown;\n };\n /* c8 ignore start -- parser-generated patch errors may omit index metadata in current fixtures. */\n if (typeof candidate.index === \"number\" && Number.isInteger(candidate.index) && candidate.index >= 0) {\n context.patchIndex = candidate.index;\n }\n /* c8 ignore stop */\n /* c8 ignore start -- operation payload metadata is optional in upstream json-patch failures. */\n const operationRecord =\n typeof candidate.operation === \"object\" && candidate.operation !== null\n ? (candidate.operation as { op?: unknown; path?: unknown; from?: unknown })\n : null;\n /* c8 ignore stop */\n enrichPatchFailureContext(context, operationRecord, patch);\n return context;\n}\n\nfunction enrichPatchFailureContext(\n context: PatchFailureContext,\n operationRecord: { op?: unknown; path?: unknown; from?: unknown } | null,\n patch: HistoryPatchOp[],\n): void {\n /* v8 ignore start -- operation replay records always carry a string op when present; this preserves context for malformed future rows */\n if (operationRecord && typeof operationRecord.op === \"string\") {\n context.op = operationRecord.op;\n }\n /* v8 ignore stop */\n if (operationRecord && typeof operationRecord.path === \"string\") {\n context.path = operationRecord.path;\n }\n if (operationRecord && typeof operationRecord.from === \"string\") {\n context.from = operationRecord.from;\n }\n if ((context.op === undefined || context.path === undefined) && context.patchIndex !== undefined) {\n const fallback = patch[context.patchIndex];\n /* c8 ignore start -- fallback enrichment paths are only exercised by malformed patch telemetry payloads. */\n if (fallback) {\n context.op = context.op ?? fallback.op;\n context.path = context.path ?? fallback.path;\n context.from = context.from ?? fallback.from;\n }\n /* c8 ignore stop */\n }\n}\n\nfunction applyHistoryPatch(\n current: CanonicalReplayDocument,\n patch: HistoryPatchOp[],\n entryNumber: number,\n entryOp: string,\n): CanonicalReplayDocument {\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 (\n typeof applied !== \"object\" ||\n applied === null ||\n !(\"metadata\" in applied) ||\n !(\"body\" in applied) ||\n typeof (applied as { body: unknown }).body !== \"string\" ||\n typeof (applied as { metadata: unknown }).metadata !== \"object\" ||\n (applied as { metadata: unknown }).metadata === null\n ) {\n throw new PmCliError(\n `History replay produced an invalid document shape at entry ${entryNumber}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const replay = applied as { metadata: Record<string, unknown>; body: string };\n return {\n metadata: replay.metadata,\n body: replay.body,\n };\n } catch (error: unknown) {\n if (error instanceof PmCliError) {\n throw error;\n }\n const failureContext = extractPatchFailureContext(patch, error);\n const contextTokens = [\n `history_op=${entryOp}`,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.patchIndex !== undefined ? `patch_index=${failureContext.patchIndex}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.op ? `op=${failureContext.op}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.path ? `path=${failureContext.path}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.from ? `from=${failureContext.from}` : null,\n ].filter((token): token is string => token !== null);\n /* c8 ignore start -- jsonPatch/structuredClone/normalizeReplayPatchOps always throw Error instances with non-empty messages here, so extractPatchFailureContext always sets reason; the empty-suffix fallback is unreachable through applyHistoryPatch. */\n const reasonSuffix = failureContext.reason ? ` ${failureContext.reason}` : \"\";\n /* c8 ignore stop */\n throw new PmCliError(\n `Failed to apply history patch at entry ${entryNumber} (${contextTokens.join(\", \")}).${reasonSuffix}`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n}\n\nfunction replayToTarget(history: HistoryEntry[], targetIndex: number): CanonicalReplayDocument {\n let document: CanonicalReplayDocument = structuredClone(EMPTY_REPLAY_DOCUMENT);\n\n for (let i = 0; i <= targetIndex; i += 1) {\n const entry = history[i];\n const beforeHash = replayHash(document);\n if (beforeHash !== entry.before_hash) {\n throw new PmCliError(\n `History hash mismatch before replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n document = applyHistoryPatch(document, entry.patch, i + 1, entry.op);\n\n const afterHash = replayHash(document);\n if (afterHash !== entry.after_hash) {\n throw new PmCliError(\n `History hash mismatch after replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n\n return document;\n}\n\nfunction ensureMaterializedRestoreTarget(\n replayDocument: CanonicalReplayDocument,\n target: ResolvedRestoreTarget,\n): CanonicalReplayDocument {\n if (Object.keys(replayDocument.metadata).length > 0) {\n return replayDocument;\n }\n throw new PmCliError(\n `Restore target ${target.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction replayCurrentDocument(history: HistoryEntry[]): ItemDocument {\n const currentReplay = replayToTarget(history, history.length - 1);\n if (Object.keys(currentReplay.metadata).length === 0) {\n return {\n metadata: {} as ItemMetadata,\n body: currentReplay.body,\n };\n }\n return canonicalDocument(replayToItemDocument(currentReplay));\n}\n\nasync function resolveRestoreSubject(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<ResolvedRestoreSubject> {\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);\n if (located) {\n const historyPath = getHistoryPath(pmRoot, located.id);\n const historyPolicy = await enforceHistoryStreamPolicyForItem({\n pmRoot,\n settings,\n itemId: located.id,\n commandLabel: \"restore\",\n });\n return {\n id: located.id,\n historyPath,\n located,\n historyPolicyWarnings: historyPolicy.warnings,\n };\n }\n\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const rawNormalizedId = normalizeRawItemId(id);\n /* c8 ignore start -- raw-id fallback is covered by normalize-item-id utility tests. */\n const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];\n /* c8 ignore stop */\n for (const candidateId of candidateIds) {\n const historyPath = getHistoryPath(pmRoot, candidateId);\n if (await pathExists(historyPath)) {\n return {\n id: candidateId,\n historyPath,\n located: null,\n historyPolicyWarnings: [],\n };\n }\n }\n\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n}\n\nfunction changedFields(beforeDocument: ItemDocument, afterDocument: ItemDocument): string[] {\n const beforeReplay = toReplayDocument(beforeDocument);\n const afterReplay = toReplayDocument(afterDocument);\n const patch = jsonPatch.compare(beforeReplay, afterReplay) as HistoryPatchOp[];\n const fields = new Set<string>();\n\n for (const op of patch) {\n if (op.path === \"/body\" || op.path.startsWith(\"/body/\")) {\n fields.add(\"body\");\n continue;\n }\n const segment = op.path.replace(/^\\/(?:metadata|front_matter)\\/?/, \"\").split(\"/\")[0];\n fields.add(segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n }\n\n return Array.from(fields).sort((a, b) => a.localeCompare(b));\n}\n\nasync function loadRestoreStateUnderLock(params: {\n pmRoot: string;\n resolvedId: string;\n subject: ResolvedRestoreSubject;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeToFolder: Record<string, string>;\n historyRawBeforeLock: string | null;\n currentItemRawBeforeLock: string | null;\n}): Promise<{ loadedItemUnderLock: Awaited<ReturnType<typeof readLocatedItem>> | null; existingItemPath: string | null }> {\n const historyRawUnderLock = await readFileIfExists(params.subject.historyPath);\n if (historyRawUnderLock !== params.historyRawBeforeLock) {\n throw new PmCliError(`History for ${params.resolvedId} changed while waiting for lock; retry restore.`, EXIT_CODE.CONFLICT);\n }\n const locatedUnderLock = await locateItem(\n params.pmRoot,\n params.resolvedId,\n params.settings.id_prefix,\n params.settings.item_format,\n params.typeToFolder,\n );\n const loadedItemUnderLock = locatedUnderLock ? await readLocatedItem(locatedUnderLock, { schema: params.settings.schema }) : null;\n if ((loadedItemUnderLock?.raw ?? null) !== params.currentItemRawBeforeLock) {\n throw new PmCliError(`Item ${params.resolvedId} changed while waiting for lock; retry restore.`, EXIT_CODE.CONFLICT);\n }\n return { loadedItemUnderLock, existingItemPath: locatedUnderLock?.itemPath ?? null };\n}\n\nfunction resolveRestoreCurrentState(\n loadedItemUnderLock: Awaited<ReturnType<typeof readLocatedItem>> | null,\n history: HistoryEntry[],\n): RestoreCurrentState {\n if (loadedItemUnderLock) {\n return { document: loadedItemUnderLock.document, originalRaw: loadedItemUnderLock.raw };\n }\n return { document: replayCurrentDocument(history), originalRaw: null };\n}\n\nfunction collectRestoreOwnershipWarnings(params: {\n document: ItemDocument;\n author: string;\n force: boolean | undefined;\n enforcement: \"strict\" | \"warn\" | \"none\";\n resolvedId: string;\n}): string[] {\n const assigned = params.document.metadata.assignee?.trim();\n const hasOwnershipConflict = assigned && assigned !== params.author && !params.force;\n if (!hasOwnershipConflict) {\n return [];\n }\n if (params.enforcement === \"strict\") {\n throw new PmCliError(`Item ${params.resolvedId} is assigned to ${assigned}. Use --force to override.`, EXIT_CODE.CONFLICT);\n }\n return params.enforcement === \"warn\" ? [`ownership_warning:assignee_conflict:${params.resolvedId}:${assigned}`] : [];\n}\n\nasync function restorePreviousItemAfterHistoryFailure(params: {\n existingItemPath: string | null;\n resolvedOriginalRaw: string | null;\n restoredItemPath: string;\n}): Promise<void> {\n if (params.existingItemPath && params.resolvedOriginalRaw !== null && params.restoredItemPath !== params.existingItemPath) {\n await writeFileAtomic(params.existingItemPath, params.resolvedOriginalRaw);\n await fs.rm(params.restoredItemPath, { force: true });\n return;\n }\n if (params.existingItemPath && params.resolvedOriginalRaw !== null) {\n await writeFileAtomic(params.existingItemPath, params.resolvedOriginalRaw);\n return;\n }\n await fs.rm(params.restoredItemPath, { force: true });\n}\n\nasync function runRestoreWriteHooks(params: {\n restoredItemPath: string;\n historyPath: string;\n before: ItemDocument;\n after: ItemDocument;\n}): Promise<string[]> {\n return [\n ...(await runActiveOnWriteHooks({\n path: params.restoredItemPath,\n scope: \"project\",\n op: \"restore\",\n item_id: params.after.metadata.id,\n item_type: params.after.metadata.type,\n before: params.before,\n after: params.after,\n changed_fields: [\"restored\"],\n })),\n ...(await runActiveOnWriteHooks({\n path: params.historyPath,\n scope: \"project\",\n op: \"restore:history\",\n item_id: params.after.metadata.id,\n item_type: params.after.metadata.type,\n before: params.before,\n after: params.after,\n changed_fields: [\"restored\"],\n })),\n ];\n}\n\n/**\n * Implements run restore for the public runtime surface of this module.\n */\nexport async function runRestore(\n id: string,\n target: string,\n options: RestoreCommandOptions,\n global: GlobalOptions,\n): Promise<RestoreResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveRestoreSubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n const resolvedId = subject.id;\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const history = await readHistoryEntries(subject.historyPath, resolvedId);\n if (history.length === 0) {\n throw new PmCliError(`No history exists for ${resolvedId}; restore is unavailable.`, EXIT_CODE.NOT_FOUND);\n }\n\n const resolvedTarget = ensureReplayTarget(target, history);\n const replayDocument = ensureMaterializedRestoreTarget(replayToTarget(history, resolvedTarget.historyIndex), resolvedTarget);\n const restoredDocument = replayToCanonicalItemDocument(replayDocument, { schema: settings.schema });\n\n if (restoredDocument.metadata.id !== resolvedId) {\n throw new PmCliError(\n `Restore target resolved to item ${restoredDocument.metadata.id}, expected ${resolvedId}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const loadedItemBeforeLock = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItemBeforeLock?.raw ?? null;\n\n const author = resolveAuthor(options.author, settings.author_default);\n const releaseLock = await acquireLock(\n pmRoot,\n resolvedId,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n settings.governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n\n try {\n const { loadedItemUnderLock, existingItemPath } = await loadRestoreStateUnderLock({\n pmRoot,\n resolvedId,\n subject,\n settings,\n typeToFolder: typeRegistry.type_to_folder,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n });\n const itemFormat = \"toon\";\n const currentState = resolveRestoreCurrentState(loadedItemUnderLock, history);\n const ownershipWarnings = collectRestoreOwnershipWarnings({\n document: currentState.document,\n author,\n force: options.force,\n enforcement: settings.governance.ownership_enforcement,\n resolvedId,\n });\n\n const serializedRestore = serializeItemDocument(restoredDocument, { format: itemFormat, schema: settings.schema });\n /* c8 ignore next -- restored item path typing is exercised in restore integration workflows. */\n const restoredItemPath = getItemPath(\n pmRoot,\n restoredDocument.metadata.type,\n resolvedId,\n itemFormat,\n typeRegistry.type_to_folder,\n );\n await writeFileAtomic(restoredItemPath, serializedRestore);\n if (existingItemPath && restoredItemPath !== existingItemPath) {\n await fs.rm(existingItemPath);\n }\n\n const historyEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"restore\",\n before: currentState.document,\n after: restoredDocument,\n message: options.message,\n });\n\n try {\n await appendHistoryEntry(subject.historyPath, historyEntry);\n } catch (error: unknown) {\n await restorePreviousItemAfterHistoryFailure({\n existingItemPath,\n resolvedOriginalRaw: currentState.originalRaw,\n restoredItemPath,\n });\n throw error;\n }\n const restoreChangedFields = changedFields(currentState.document, restoredDocument);\n const hookWarnings = await runRestoreWriteHooks({\n restoredItemPath,\n historyPath: subject.historyPath,\n before: currentState.document,\n after: restoredDocument,\n });\n recordAfterCommandAffectedItem({\n id: restoredDocument.metadata.id,\n op: \"restore\",\n item_type: restoredDocument.metadata.type,\n previous_status: currentState.document.metadata.status,\n status: restoredDocument.metadata.status,\n previous: projectAfterCommandItemSnapshot(currentState.document.metadata, restoreChangedFields),\n current: projectAfterCommandItemSnapshot(restoredDocument.metadata, restoreChangedFields),\n changed_fields: restoreChangedFields,\n });\n\n const targetEntry = history[resolvedTarget.historyIndex];\n return {\n item: restoredDocument.metadata,\n restored_from: {\n kind: resolvedTarget.kind,\n target: resolvedTarget.raw,\n history_index: resolvedTarget.historyIndex + 1,\n entry_ts: targetEntry.ts,\n entry_op: targetEntry.op,\n },\n changed_fields: restoreChangedFields,\n warnings: [...subject.historyPolicyWarnings, ...ownershipWarnings, ...hookWarnings],\n };\n } finally {\n await releaseLock();\n }\n}\n\nexport const _testOnlyRestoreCommand = {\n applyHistoryPatch,\n changedFields,\n ensureMaterializedRestoreTarget,\n ensureReplayTarget,\n extractPatchFailureContext,\n replayCurrentDocument,\n replayToTarget,\n resolveRestoreSubject,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;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GAAG,YAAY;;EAEtF;AACE,UAAM,YAAW;EACnB;AACF;AAEO,IAAM,0BAA0B;EACrC;EACA;EACA;EACA;EACA;EACA;EACA;EACA","debugId":"80e4cdd6-dd3f-5ce4-9549-330a2bc292cd"}
@@ -1,14 +1,14 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="03f31b47-8941-5834-b40b-21ce8c7cc862")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c8b9d222-9c7e-5077-a38a-d9da73f14a67")}catch(e){}}();
3
3
  import {
4
4
  runActiveCommandOverride,
5
5
  runActiveRendererOverride,
6
6
  runActiveServiceOverrideSync,
7
7
  setActiveCommandResult
8
- } from "./chunk-E3SZTQ4K.js";
8
+ } from "./chunk-GH73UOSJ.js";
9
9
  import {
10
10
  EXIT_CODE
11
- } from "./chunk-57NWPFF2.js";
11
+ } from "./chunk-UO7XAZK6.js";
12
12
 
13
13
  // dist/core/output/mutation-projection.js
14
14
  var CHANGED_FIELDS_KEY = "changed_fields";
@@ -49,11 +49,15 @@ function replaceRows(envelope, rows) {
49
49
  return projected;
50
50
  }
51
51
  function projectIdOnlyResult(result) {
52
- if (!isPlainObject(result) || !isPlainObject(result.item)) {
52
+ if (!isPlainObject(result)) {
53
53
  return null;
54
54
  }
55
- const id = typeof result.item.id === "string" ? result.item.id : void 0;
56
- const status = typeof result.item.status === "string" ? result.item.status : void 0;
55
+ const subject = isPlainObject(result.item) ? result.item : isPlainObject(result.plan) ? result.plan : null;
56
+ if (subject === null) {
57
+ return null;
58
+ }
59
+ const id = typeof subject.id === "string" ? subject.id : void 0;
60
+ const status = typeof subject.status === "string" ? subject.status : void 0;
57
61
  if (!id) {
58
62
  return null;
59
63
  }
@@ -352,6 +356,6 @@ export {
352
356
  printResult,
353
357
  printError
354
358
  };
355
- //# sourceMappingURL=chunk-MLIYFOE7.js.map
359
+ //# sourceMappingURL=chunk-EOUVR7JN.js.map
356
360
 
357
- //# debugId=03f31b47-8941-5834-b40b-21ce8c7cc862
361
+ //# debugId=c8b9d222-9c7e-5077-a38a-d9da73f14a67
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../core/output/mutation-projection.ts","../../../../../../../../core/output/output.ts"],"sourcesContent":["/**\n * Shared projection helper for mutation command results.\n *\n * Mutation commands (create/update/close/append/update-many) return a result\n * envelope that carries a `changed_fields` string array. On create this array simply\n * re-lists every field the command just set, which the item echo above it already\n * shows, so for high-volume agent loops it is ~50% redundant payload. This helper\n * lets the CLI (`--no-changed-fields`) and the MCP agent path trim that array down\n * to a deterministic `changed_field_count` without losing mutation evidence.\n *\n * Compaction is deliberately scoped to the mutation envelope only:\n * - the envelope's own top-level `changed_fields` (create/update/close/append), and\n * - `rows[*].changed_fields` (update-many reports its delta per row).\n * It does NOT recurse into arbitrary nested objects, so unrelated payloads that\n * legitimately carry `changed_fields` (for example `pm history --diff` entries, or a\n * custom runtime metadata field) are left untouched.\n *\n * The helper is pure and side-effect free, reused by both the output layer and the\n * MCP server, and returns the original reference unchanged when nothing is compacted.\n */\n\n/** Controls whether mutation output keeps full changed fields or compact counts. */\nexport type ChangedFieldsMode = \"full\" | \"compact\";\n\n/**\n * Documents the mutation projection options payload exchanged by command, SDK, and package integrations.\n */\nexport interface MutationProjectionOptions {\n /** Defaults to \"full\" (unchanged output). \"compact\" drops the array, keeping a count. */\n changedFields?: ChangedFieldsMode;\n /** Return only id/status for single-item mutation envelopes. */\n idOnly?: boolean;\n}\n\nconst CHANGED_FIELDS_KEY = \"changed_fields\";\nconst CHANGED_FIELD_COUNT_KEY = \"changed_field_count\";\nconst ROWS_KEY = \"rows\";\nconst UPDATE_MANY_MUTATION_MODES = new Set([\"apply\", \"rollback\"]);\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n}\n\n/** Replace a single envelope's own top-level `changed_fields` array with a count. */\nfunction compactOwnChangedFields(envelope: Record<string, unknown>): Record<string, unknown> | null {\n const changedFields = envelope[CHANGED_FIELDS_KEY];\n if (!Array.isArray(changedFields)) {\n return null;\n }\n const projected: Record<string, unknown> =\n Object.getPrototypeOf(envelope) === null ? Object.create(null) : {};\n for (const [key, value] of Object.entries(envelope)) {\n if (key !== CHANGED_FIELDS_KEY) {\n projected[key] = value;\n }\n }\n projected[CHANGED_FIELD_COUNT_KEY] = changedFields.length;\n return projected;\n}\n\nfunction isMutationEnvelope(value: Record<string, unknown>): boolean {\n return \"item\" in value && Array.isArray(value[CHANGED_FIELDS_KEY]);\n}\n\nfunction isUpdateManyMutationEnvelope(value: Record<string, unknown>): boolean {\n return (\n typeof value.mode === \"string\" &&\n UPDATE_MANY_MUTATION_MODES.has(value.mode) &&\n Array.isArray(value[ROWS_KEY])\n );\n}\n\nfunction replaceRows(envelope: Record<string, unknown>, rows: unknown[]): Record<string, unknown> {\n const projected: Record<string, unknown> =\n Object.getPrototypeOf(envelope) === null ? Object.create(null) : {};\n Object.assign(projected, envelope);\n projected[ROWS_KEY] = rows;\n return projected;\n}\n\nfunction projectIdOnlyResult(result: unknown): unknown | null {\n if (!isPlainObject(result)) {\n return null;\n }\n // Plan mutations wrap the mutated subject under \"plan\" instead of \"item\";\n // both shapes honor the root --id-only contract (id + status).\n const subject = isPlainObject(result.item) ? result.item : isPlainObject(result.plan) ? result.plan : null;\n if (subject === null) {\n return null;\n }\n const id = typeof subject.id === \"string\" ? subject.id : undefined;\n const status = typeof subject.status === \"string\" ? subject.status : undefined;\n if (!id) {\n return null;\n }\n return status ? { id, status } : { id };\n}\n\nfunction compactUpdateManyRows(envelope: Record<string, unknown>): { projected: Record<string, unknown>; changed: boolean } {\n const rows = isUpdateManyMutationEnvelope(envelope) ? envelope[ROWS_KEY] : undefined;\n if (!Array.isArray(rows)) {\n return { projected: envelope, changed: false };\n }\n let rowsChanged = false;\n const nextRows = rows.map((row) => {\n if (!isPlainObject(row)) {\n return row;\n }\n const compactedRow = compactOwnChangedFields(row);\n if (compactedRow) {\n rowsChanged = true;\n return compactedRow;\n }\n return row;\n });\n return rowsChanged\n ? { projected: replaceRows(envelope, nextRows), changed: true }\n : { projected: envelope, changed: false };\n}\n\n/**\n * Returns a copy of a mutation result with the envelope `changed_fields` arrays\n * replaced by `changed_field_count` when compact mode is requested. Inputs that are\n * not a mutation envelope (or full mode) are returned unchanged (same reference).\n */\nexport function projectMutationResult(result: unknown, options: MutationProjectionOptions = {}): unknown {\n if (options.idOnly === true) {\n const idOnly = projectIdOnlyResult(result);\n if (idOnly !== null) {\n return idOnly;\n }\n }\n\n const mode = options.changedFields ?? \"full\";\n if (mode === \"full\" || !isPlainObject(result)) {\n return result;\n }\n\n let changed = false;\n let projected: Record<string, unknown> = result;\n\n const compactedTop = isMutationEnvelope(result) ? compactOwnChangedFields(result) : null;\n if (compactedTop !== null) {\n projected = compactedTop;\n changed = true;\n }\n\n const rowProjection = compactUpdateManyRows(projected);\n if (rowProjection.changed) {\n projected = rowProjection.projected;\n changed = true;\n }\n\n return changed ? projected : result;\n}\n","/**\n * @module core/output/output\n *\n * Formats compact human and machine output for Output.\n */\nimport {\n runActiveCommandOverride,\n runActiveRendererOverride,\n runActiveServiceOverrideSync,\n setActiveCommandResult,\n} from \"../extensions/index.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { projectMutationResult } from \"./mutation-projection.js\";\n\n/**\n * Documents the output options payload exchanged by command, SDK, and package integrations.\n */\nexport interface OutputOptions {\n json?: boolean;\n quiet?: boolean;\n /** When true, mutation results drop the verbose changed_fields array (keeps changed_field_count). */\n noChangedFields?: boolean;\n /** When true, single-item mutation results print only id and status. */\n idOnly?: boolean;\n defaultOutputFormat?: \"toon\" | \"json\";\n command?: string;\n commandArgs?: string[];\n commandOptions?: Record<string, unknown>;\n pmRoot?: string;\n}\n\ninterface NodeLikeError {\n code?: string;\n}\n\nconst NATIVE_OUTPUT_MARKER = \"__pm_native_output\";\n\nlet streamErrorHandlersInstalled = false;\ntype OutputStreamTarget = \"stdout\" | \"stderr\";\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction shouldUseNativeOutput(result: unknown): boolean {\n return isPlainObject(result) && result[NATIVE_OUTPUT_MARKER] === true;\n}\n\nfunction stripNativeOutputMarker<T>(result: T): T {\n if (!isPlainObject(result) || result[NATIVE_OUTPUT_MARKER] !== true) {\n return result;\n }\n const { [NATIVE_OUTPUT_MARKER]: _marker, ...rest } = result;\n return rest as T;\n}\n\nfunction isBrokenPipeError(error: unknown): boolean {\n return typeof error === \"object\" && error !== null && (error as NodeLikeError).code === \"EPIPE\";\n}\n\nfunction markStdoutBrokenPipeExitCode(): void {\n if (process.exitCode === undefined || process.exitCode === EXIT_CODE.SUCCESS) {\n process.exitCode = EXIT_CODE.SUCCESS;\n }\n}\n\nfunction markStderrBrokenPipeExitCode(): void {\n if (process.exitCode === undefined || process.exitCode === EXIT_CODE.SUCCESS) {\n process.exitCode = EXIT_CODE.GENERIC_FAILURE;\n }\n}\n\nfunction markBrokenPipeExitCode(target: OutputStreamTarget): void {\n if (target === \"stdout\") {\n markStdoutBrokenPipeExitCode();\n return;\n }\n markStderrBrokenPipeExitCode();\n}\n\nfunction handleUnhandledStreamError(error: unknown): void {\n const unhandled = error instanceof Error ? error : new Error(String(error));\n setImmediate(() => {\n throw unhandled;\n });\n}\n\nfunction installStreamErrorHandlers(): void {\n if (streamErrorHandlersInstalled) {\n return;\n }\n streamErrorHandlersInstalled = true;\n process.stdout.on(\"error\", (error: unknown) => {\n if (isBrokenPipeError(error)) {\n markBrokenPipeExitCode(\"stdout\");\n return;\n }\n handleUnhandledStreamError(error);\n });\n process.stderr.on(\"error\", (error: unknown) => {\n if (isBrokenPipeError(error)) {\n markBrokenPipeExitCode(\"stderr\");\n return;\n }\n handleUnhandledStreamError(error);\n });\n}\n\nfunction writeToStream(target: OutputStreamTarget, text: string): boolean {\n installStreamErrorHandlers();\n try {\n if (target === \"stdout\") {\n process.stdout.write(text);\n } else {\n process.stderr.write(text);\n }\n return true;\n } catch (error: unknown) {\n if (isBrokenPipeError(error)) {\n markBrokenPipeExitCode(target);\n return false;\n }\n throw error;\n }\n}\n\n/**\n * Implements write stdout for the public runtime surface of this module.\n */\nexport function writeStdout(text: string): boolean {\n return writeToStream(\"stdout\", text);\n}\n\n/**\n * Implements write stderr for the public runtime surface of this module.\n */\nexport function writeStderr(text: string): boolean {\n return writeToStream(\"stderr\", text);\n}\n\nfunction renderScalar(value: unknown): string {\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (value === null) return \"null\";\n return JSON.stringify(value);\n}\n\nfunction compactToonValue(value: unknown): unknown | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n const compactedEntries = value\n .map((entry) => compactToonValue(entry))\n .filter((entry): entry is unknown => entry !== undefined);\n return compactedEntries.length > 0 ? compactedEntries : undefined;\n }\n\n if (isPlainObject(value)) {\n const compacted: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const compactedEntry = compactToonValue(entry);\n if (compactedEntry !== undefined) {\n compacted[key] = compactedEntry;\n }\n }\n return Object.keys(compacted).length > 0 ? compacted : undefined;\n }\n\n return value;\n}\n\nfunction renderToonValue(value: unknown, depth: number): string {\n const indent = \" \".repeat(depth);\n\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n return value\n .map((entry) => {\n if (!isPlainObject(entry) && !Array.isArray(entry)) {\n return `${indent}- ${renderScalar(entry)}`;\n }\n const rendered = renderToonValue(entry, depth + 1);\n const lines = rendered.split(\"\\n\");\n const [firstLine, ...rest] = lines;\n if (rest.length === 0) {\n return `${indent}- ${firstLine.trimStart()}`;\n }\n return `${indent}- ${firstLine.trimStart()}\\n${rest.join(\"\\n\")}`;\n })\n .join(\"\\n\");\n }\n\n if (isPlainObject(value)) {\n const entries = Object.entries(value);\n if (entries.length === 0) return \"{}\";\n return entries\n .map(([key, entry]) => {\n if (!isPlainObject(entry) && !Array.isArray(entry)) {\n return `${indent}${key}: ${renderScalar(entry)}`;\n }\n if (Array.isArray(entry) && entry.length === 0) {\n return `${indent}${key}: []`;\n }\n if (isPlainObject(entry) && Object.keys(entry).length === 0) {\n return `${indent}${key}: {}`;\n }\n return `${indent}${key}:\\n${renderToonValue(entry, depth + 1)}`;\n })\n .join(\"\\n\");\n }\n\n return `${indent}${renderScalar(value)}`;\n}\n\nfunction renderDefaultMarkdownResult(value: unknown): string | null {\n if (!isPlainObject(value) || value.output_default !== \"markdown\") {\n return null;\n }\n if (typeof value.view !== \"string\" || !Array.isArray(value.events) || !Array.isArray(value.days)) {\n return null;\n }\n const lines = [`# pm calendar (${value.view})`, \"\"];\n const summary = isPlainObject(value.summary) ? value.summary : {};\n lines.push(`- events: ${String(summary.events ?? 0)}`);\n lines.push(\"\");\n if (value.events.length === 0) {\n lines.push(\"No calendar events matched the selected filters.\");\n return `${lines.join(\"\\n\")}\\n`;\n }\n for (const event of value.events) {\n if (!isPlainObject(event)) {\n continue;\n }\n const kind = typeof event.kind === \"string\" ? event.kind : \"event\";\n const title = typeof event.item_title === \"string\" ? event.item_title : \"\";\n const itemId = typeof event.item_id === \"string\" ? event.item_id : \"\";\n const reminderText = typeof event.reminder_text === \"string\" && event.reminder_text.length > 0 ? ` ${event.reminder_text}` : \"\";\n lines.push(`- [${kind}] ${itemId} ${title}${reminderText}`.trim());\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n\n/**\n * Implements format output for the public runtime surface of this module.\n */\nexport function formatOutput(result: unknown, options: OutputOptions): string {\n const commandOverride = runActiveCommandOverride(result);\n const nativeOutput = shouldUseNativeOutput(commandOverride.result);\n const effectiveResult = stripNativeOutputMarker(commandOverride.result);\n setActiveCommandResult(effectiveResult);\n const format =\n options.json === true\n ? \"json\"\n : options.json === false\n ? \"toon\"\n : options.defaultOutputFormat === \"json\"\n ? \"json\"\n : \"toon\";\n const serviceOverride = nativeOutput ? { handled: false, result: effectiveResult } : runActiveServiceOverrideSync(\"output_format\", {\n command: options.command,\n args: options.commandArgs,\n command_options: options.commandOptions,\n global: { ...options },\n pm_root: options.pmRoot,\n format,\n options: { ...options },\n result: effectiveResult,\n });\n if (serviceOverride.handled && typeof serviceOverride.result === \"string\") {\n return serviceOverride.result.endsWith(\"\\n\") ? serviceOverride.result : `${serviceOverride.result}\\n`;\n }\n const outputResult = serviceOverride.handled ? serviceOverride.result : effectiveResult;\n if (format === \"toon\") {\n const markdownDefault = renderDefaultMarkdownResult(outputResult);\n if (markdownDefault !== null) {\n return markdownDefault;\n }\n }\n const rendererOverride = nativeOutput ? { rendered: null } : runActiveRendererOverride(format, outputResult);\n if (rendererOverride.rendered !== null) {\n return rendererOverride.rendered.endsWith(\"\\n\") ? rendererOverride.rendered : `${rendererOverride.rendered}\\n`;\n }\n if (format === \"json\") {\n return `${JSON.stringify(outputResult, null, 2)}\\n`;\n }\n const compactedToon = compactToonValue(outputResult);\n if (compactedToon === undefined) {\n return \"{}\\n\";\n }\n return `${renderToonValue(compactedToon, 0)}\\n`;\n}\n\n/**\n * Implements print result for the public runtime surface of this module.\n */\nexport function printResult(result: unknown, options: OutputOptions): void {\n const projected = options.idOnly\n ? projectMutationResult(result, { idOnly: true })\n : options.noChangedFields\n ? projectMutationResult(result, { changedFields: \"compact\" })\n : result;\n const rendered = formatOutput(projected, options);\n if (options.quiet) {\n return;\n }\n writeStdout(rendered);\n}\n\n/**\n * Implements print error for the public runtime surface of this module.\n */\nexport function printError(message: string): void {\n const override = runActiveServiceOverrideSync(\"error_format\", {\n message,\n });\n const rendered = override.handled && typeof override.result === \"string\" ? override.result : message;\n writeStderr(rendered.endsWith(\"\\n\") ? rendered : `${rendered}\\n`);\n}\n\nexport const outputTestOnly = {\n compactToonValue,\n renderToonValue,\n};\n"],"names":["isPlainObject"],"mappings":";;;;;;;;;;;;;AAkCA,IAAM,qBAAqB;AAC3B,IAAM,0BAA0B;AAChC,IAAM,WAAW;AACjB,IAAM,6BAA6B,oBAAI,IAAI,CAAC,SAAS,UAAU,CAAC;AAEhE,SAAS,cAAc,OAAc;AACnC,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG;AACvE,WAAO;EACT;AACA,QAAM,QAAQ,OAAO,eAAe,KAAK;AACzC,SAAO,UAAU,QAAQ,UAAU,OAAO;AAC5C;AAGA,SAAS,wBAAwB,UAAiC;AAChE,QAAM,gBAAgB,SAAS,kBAAkB;AACjD,MAAI,CAAC,MAAM,QAAQ,aAAa,GAAG;AACjC,WAAO;EACT;AACA,QAAM,YACJ,OAAO,eAAe,QAAQ,MAAM,OAAO,uBAAO,OAAO,IAAI,IAAI,CAAA;AACnE,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,QAAI,QAAQ,oBAAoB;AAC9B,gBAAU,GAAG,IAAI;IACnB;EACF;AACA,YAAU,uBAAuB,IAAI,cAAc;AACnD,SAAO;AACT;AAEA,SAAS,mBAAmB,OAA8B;AACxD,SAAO,UAAU,SAAS,MAAM,QAAQ,MAAM,kBAAkB,CAAC;AACnE;AAEA,SAAS,6BAA6B,OAA8B;AAClE,SACE,OAAO,MAAM,SAAS,YACtB,2BAA2B,IAAI,MAAM,IAAI,KACzC,MAAM,QAAQ,MAAM,QAAQ,CAAC;AAEjC;AAEA,SAAS,YAAY,UAAmC,MAAe;AACrE,QAAM,YACJ,OAAO,eAAe,QAAQ,MAAM,OAAO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C5G;AACA,MAAI,WAAW,QAAQ;AACrB,WAAO,GAAG,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;;EACjD;AACA,QAAM,gBAAgB,iBAAiB,YAAY;AACnD,MAAI,kBAAkB,QAAW;AAC/B,WAAO;EACT;AACA,SAAO,GAAG,gBAAgB,eAAe,CAAC,CAAC;;AAC7C;AAKM,SAAU,YAAY,QAAiB,SAAsB;AACjE,QAAM,YAAY,QAAQ,SACtB,sBAAsB,QAAQ,EAAE,QAAQ,KAAI,CAAE,IAC9C,QAAQ,kBACN,sBAAsB,QAAQ,EAAE,eAAe,UAAS,CAAE,IAC1D;AACN,QAAM,WAAW,aAAa,WAAW,OAAO;AAChD,MAAI,QAAQ,OAAO;AACjB;EACF;AACA,cAAY,QAAQ;AACtB;AAKM,SAAU,WAAW,SAAe;AACxC,QAAM,WAAW,6BAA6B,gBAAgB;IAC5D;GACD;AACD,QAAM,WAAW,SAAS,WAAW,OAAO,SAAS,WAAW,WAAW,SAAS,SAAS;AAC7F,cAAY,SAAS,SAAS,IAAI,IAAI,WAAW,GAAG,QAAQ;CAAI;AAClE","debugId":"c8b9d222-9c7e-5077-a38a-d9da73f14a67"}
@@ -2,10 +2,10 @@
2
2
  !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c4de3378-47cb-508f-a6a6-8635b65148e0")}catch(e){}}();
3
3
  import {
4
4
  resolveSubcommandFlagContractsForCommand
5
- } from "./chunk-EGAP5OWD.js";
5
+ } from "./chunk-2APXX4TZ.js";
6
6
  import {
7
7
  PmCliError
8
- } from "./chunk-E3SZTQ4K.js";
8
+ } from "./chunk-GH73UOSJ.js";
9
9
  import {
10
10
  DEFAULT_EXTENSION_PRIORITY,
11
11
  EXIT_CODE,
@@ -13,7 +13,7 @@ import {
13
13
  isPathWithinDirectory,
14
14
  levenshteinDistanceWithinLimit,
15
15
  pathExists
16
- } from "./chunk-57NWPFF2.js";
16
+ } from "./chunk-UO7XAZK6.js";
17
17
 
18
18
  // dist/cli/bootstrap-args.js
19
19
  function parseBootstrapPathToken(token, next) {
@@ -799,6 +799,6 @@ export {
799
799
  parseExtensionManifest,
800
800
  validateExtensionDirectory
801
801
  };
802
- //# sourceMappingURL=chunk-Y4M7CPQP.js.map
802
+ //# sourceMappingURL=chunk-EVEPHNXJ.js.map
803
803
 
804
804
  //# debugId=c4de3378-47cb-508f-a6a6-8635b65148e0
@@ -1,18 +1,16 @@
1
- import {
2
- listAllFrontMatterLight
3
- } from "./chunk-5VAA4YHR.js";
4
1
  import {
5
2
  PmCliError,
6
3
  getActiveExtensionRegistrations,
4
+ listAllFrontMatterLight,
7
5
  readSettings
8
- } from "./chunk-SHQY2IDC.js";
6
+ } from "./chunk-YNCFP5AR.js";
9
7
  import {
10
8
  EXIT_CODE,
11
9
  getSettingsPath,
12
10
  pathExists,
13
11
  resolveItemTypeRegistry,
14
12
  resolvePmRoot
15
- } from "./chunk-LK6XLOGP.js";
13
+ } from "./chunk-LCFJ7XAM.js";
16
14
 
17
15
  // dist/cli/commands/deps.js
18
16
  !(function() {
@@ -222,4 +220,4 @@ export {
222
220
  DEPS_COLLAPSE_VALUES,
223
221
  runDeps
224
222
  };
225
- //# sourceMappingURL=chunk-M7JNBQAD.js.map
223
+ //# sourceMappingURL=chunk-F6MT7KKE.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/deps.ts"],
4
4
  "sourcesContent": ["/**\n * @module cli/commands/deps\n *\n * Implements the pm deps command surface and its agent-facing runtime behavior.\n */\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type { Dependency, ItemFrontMatter, ItemStatus, ItemType } from \"../../types/index.js\";\n\nexport const DEPS_FORMAT_VALUES = [\"tree\", \"graph\"] as const;\n/**\n * Restricts deps format values accepted by command, SDK, and storage contracts.\n */\nexport type DepsFormat = (typeof DEPS_FORMAT_VALUES)[number];\nexport const DEPS_COLLAPSE_VALUES = [\"none\", \"repeated\"] as const;\n/**\n * Restricts deps collapse mode values accepted by command, SDK, and storage contracts.\n */\nexport type DepsCollapseMode = (typeof DEPS_COLLAPSE_VALUES)[number];\n\n/**\n * Documents the deps command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface DepsCommandOptions {\n format?: string;\n maxDepth?: string | number;\n collapse?: string;\n summary?: boolean;\n}\n\ninterface IndexedItem {\n id: string;\n title: string;\n type: ItemType;\n status: ItemStatus;\n dependencies: Dependency[];\n}\n\n/**\n * Documents the deps tree node payload exchanged by command, SDK, and package integrations.\n */\nexport interface DepsTreeNode {\n id: string;\n title?: string;\n type?: ItemType;\n status?: ItemStatus;\n via?: string;\n missing: boolean;\n cycle: boolean;\n truncated?: boolean;\n collapsed?: boolean;\n dependencies: DepsTreeNode[];\n}\n\n/**\n * Documents the deps graph node payload exchanged by command, SDK, and package integrations.\n */\nexport interface DepsGraphNode {\n id: string;\n title?: string;\n type?: ItemType;\n status?: ItemStatus;\n missing: boolean;\n}\n\n/**\n * Documents the deps graph edge payload exchanged by command, SDK, and package integrations.\n */\nexport interface DepsGraphEdge {\n from: string;\n to: string;\n kind: string;\n}\n\n/**\n * Documents the deps graph result payload exchanged by command, SDK, and package integrations.\n */\nexport interface DepsGraphResult {\n root_id: string;\n nodes: DepsGraphNode[];\n edges: DepsGraphEdge[];\n missing_ids: string[];\n}\n\n/**\n * Documents the deps result payload exchanged by command, SDK, and package integrations.\n */\nexport interface DepsResult {\n id: string;\n format: DepsFormat;\n node_count: number;\n edge_count: number;\n missing_count: number;\n tree?: DepsTreeNode;\n graph?: DepsGraphResult;\n}\n\nfunction parseFormat(raw: string | undefined): DepsFormat {\n const candidate = raw?.trim().toLowerCase() ?? \"tree\";\n if ((DEPS_FORMAT_VALUES as readonly string[]).includes(candidate)) {\n return candidate as DepsFormat;\n }\n throw new PmCliError(`Invalid --format value \"${raw}\". Use \"tree\" or \"graph\".`, EXIT_CODE.USAGE);\n}\n\nfunction parseMaxDepth(raw: string | number | undefined): number | undefined {\n if (raw === undefined) {\n return undefined;\n }\n const normalized = typeof raw === \"number\" ? raw : Number(raw.trim());\n if (!Number.isInteger(normalized) || normalized < 0) {\n throw new PmCliError(`Invalid --max-depth value \"${raw}\". Use a non-negative integer.`, EXIT_CODE.USAGE);\n }\n return normalized;\n}\n\nfunction parseCollapse(raw: string | undefined): DepsCollapseMode {\n const candidate = raw?.trim().toLowerCase() ?? \"none\";\n if ((DEPS_COLLAPSE_VALUES as readonly string[]).includes(candidate)) {\n return candidate as DepsCollapseMode;\n }\n throw new PmCliError(`Invalid --collapse value \"${raw}\". Use \"none\" or \"repeated\".`, EXIT_CODE.USAGE);\n}\n\nfunction normalizeDependencies(dependencies: Dependency[] | undefined): Dependency[] {\n if (!dependencies || dependencies.length === 0) {\n return [];\n }\n const sorted = [...dependencies].sort((left, right) => {\n const byKind = left.kind.localeCompare(right.kind);\n if (byKind !== 0) return byKind;\n const byId = left.id.localeCompare(right.id);\n if (byId !== 0) return byId;\n return left.created_at.localeCompare(right.created_at);\n });\n const deduped = new Map<string, Dependency>();\n for (const dependency of sorted) {\n const key = `${dependency.kind}::${dependency.id}`;\n if (!deduped.has(key)) {\n deduped.set(key, dependency);\n }\n }\n return [...deduped.values()];\n}\n\nfunction toIndexedItem(item: ItemFrontMatter): IndexedItem {\n return {\n id: item.id,\n title: item.title,\n type: item.type,\n status: item.status,\n dependencies: normalizeDependencies(item.dependencies),\n };\n}\n\nfunction toTreeNode(\n id: string,\n index: Map<string, IndexedItem>,\n lineage: Set<string>,\n maxDepth: number | undefined,\n collapse: DepsCollapseMode,\n expanded: Set<string>,\n depth = 0,\n via?: string,\n): DepsTreeNode {\n const item = index.get(id);\n const baseNode: DepsTreeNode = {\n id,\n title: item?.title,\n type: item?.type,\n status: item?.status,\n via,\n missing: !item,\n cycle: lineage.has(id),\n dependencies: [],\n };\n if (!item || baseNode.cycle) {\n return baseNode;\n }\n if (maxDepth !== undefined && depth >= maxDepth) {\n if (item.dependencies.length > 0) {\n baseNode.truncated = true;\n }\n return baseNode;\n }\n if (collapse === \"repeated\" && expanded.has(id)) {\n baseNode.collapsed = true;\n return baseNode;\n }\n if (collapse === \"repeated\") {\n expanded.add(id);\n }\n const nextLineage = new Set(lineage);\n nextLineage.add(id);\n baseNode.dependencies = item.dependencies.map((dependency) =>\n toTreeNode(dependency.id, index, nextLineage, maxDepth, collapse, expanded, depth + 1, dependency.kind),\n );\n return baseNode;\n}\n\nfunction mergeGraphNode(existing: DepsGraphNode | undefined, candidate: DepsGraphNode): DepsGraphNode {\n if (!existing) {\n return candidate;\n }\n /* c8 ignore start -- defensive: mixed missing/non-missing duplicates only occur in malformed synthetic trees. */\n if (existing.missing && !candidate.missing) return candidate;\n /* c8 ignore stop */\n return {\n ...existing,\n title: existing.title ?? candidate.title,\n type: existing.type ?? candidate.type,\n status: existing.status ?? candidate.status,\n };\n}\n\nfunction toGraph(root: DepsTreeNode): DepsGraphResult {\n const nodesById = new Map<string, DepsGraphNode>();\n const edgesByKey = new Map<string, DepsGraphEdge>();\n\n const visit = (node: DepsTreeNode): void => {\n nodesById.set(\n node.id,\n mergeGraphNode(nodesById.get(node.id), {\n id: node.id,\n title: node.title,\n type: node.type,\n status: node.status,\n missing: node.missing,\n }),\n );\n for (const child of node.dependencies) {\n nodesById.set(\n child.id,\n mergeGraphNode(nodesById.get(child.id), {\n id: child.id,\n title: child.title,\n type: child.type,\n status: child.status,\n missing: child.missing,\n }),\n );\n /* c8 ignore start -- legacy malformed dependency payloads may omit kind/via. */\n const relationKind = child.via ?? \"related\";\n const edgeKey = `${node.id}::${child.id}::${relationKind}`;\n if (!edgesByKey.has(edgeKey)) {\n edgesByKey.set(edgeKey, {\n from: node.id,\n to: child.id,\n kind: relationKind,\n });\n }\n /* c8 ignore stop */\n if (!child.cycle) {\n visit(child);\n }\n }\n };\n\n visit(root);\n\n const nodes = [...nodesById.values()].sort((left, right) => left.id.localeCompare(right.id));\n const edges = [...edgesByKey.values()].sort((left, right) => {\n const byFrom = left.from.localeCompare(right.from);\n if (byFrom !== 0) return byFrom;\n const byTo = left.to.localeCompare(right.to);\n if (byTo !== 0) return byTo;\n return left.kind.localeCompare(right.kind);\n });\n const missingIds = nodes.filter((node) => node.missing).map((node) => node.id);\n return {\n root_id: root.id,\n nodes,\n edges,\n missing_ids: missingIds,\n };\n}\n\n/**\n * Implements run deps for the public runtime surface of this module.\n */\nexport async function runDeps(id: string, options: DepsCommandOptions, global: GlobalOptions): Promise<DepsResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n const format = parseFormat(options.format);\n const maxDepth = parseMaxDepth(options.maxDepth);\n const collapse = parseCollapse(options.collapse);\n const summaryOnly = options.summary === true;\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const items = await listAllFrontMatterLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);\n const index = new Map(items.map((item) => [item.id, toIndexedItem(item)]));\n if (!index.has(id)) {\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n }\n\n const tree = toTreeNode(id, index, new Set<string>(), maxDepth, collapse, new Set<string>());\n const graph = toGraph(tree);\n const baseResult = {\n id,\n format,\n node_count: graph.nodes.length,\n edge_count: graph.edges.length,\n missing_count: graph.missing_ids.length,\n };\n if (summaryOnly) {\n return baseResult;\n }\n if (format === \"tree\") {\n return {\n ...baseResult,\n tree,\n };\n }\n return {\n ...baseResult,\n graph,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,qBAAqB,CAAC,QAAQ,OAAO;AAK3C,IAAM,uBAAuB,CAAC,QAAQ,UAAU;AAmFvD,SAAS,YAAY,KAAuB;AAC1C,QAAM,YAAY,KAAK,KAAI,EAAG,YAAW,KAAM;AAC/C,MAAK,mBAAyC,SAAS,SAAS,GAAG;AACjE,WAAO;EACT;AACA,QAAM,IAAI,WAAW,2BAA2B,GAAG,6BAA6B,UAAU,KAAK;AACjG;AAEA,SAAS,cAAc,KAAgC;AACrD,MAAI,QAAQ,QAAW;AACrB,WAAO;EACT;AACA,QAAM,aAAa,OAAO,QAAQ,WAAW,MAAM,OAAO,IAAI,KAAI,CAAE;AACpE,MAAI,CAAC,OAAO,UAAU,UAAU,KAAK,aAAa,GAAG;AACnD,UAAM,IAAI,WAAW,8BAA8B,GAAG,kCAAkC,UAAU,KAAK;EACzG;AACA,SAAO;AACT;AAEA,SAAS,cAAc,KAAuB;AAC5C,QAAM,YAAY,KAAK,KAAI,EAAG,YAAW,KAAM;AAC/C,MAAK,qBAA2C,SAAS,SAAS,GAAG;AACnE,WAAO;EACT;AACA,QAAM,IAAI,WAAW,6BAA6B,GAAG,gCAAgC,UAAU,KAAK;AACtG;AAEA,SAAS,sBAAsB,cAAsC;AACnE,MAAI,CAAC,gBAAgB,aAAa,WAAW,GAAG;AAC9C,WAAO,CAAA;EACT;AACA,QAAM,SAAS,CAAC,GAAG,YAAY,EAAE,KAAK,CAAC,MAAM,UAAS;AACpD,UAAM,SAAS,KAAK,KAAK,cAAc,MAAM,IAAI;AACjD,QAAI,WAAW;AAAG,aAAO;AACzB,UAAM,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