@unbrained/pm-cli 2026.7.3 → 2026.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (663) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CONTRIBUTING.md +36 -7
  3. package/README.md +1 -9
  4. package/dist/cli/commands/calendar.d.ts +3 -2
  5. package/dist/cli/commands/calendar.js +5 -5
  6. package/dist/cli/commands/calendar.js.map +1 -1
  7. package/dist/cli/commands/claim.js +17 -3
  8. package/dist/cli/commands/claim.js.map +1 -1
  9. package/dist/cli/commands/close.js +34 -16
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +231 -345
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/copy.js +3 -3
  14. package/dist/cli/commands/copy.js.map +1 -1
  15. package/dist/cli/commands/create.d.ts +9 -59
  16. package/dist/cli/commands/create.js +162 -132
  17. package/dist/cli/commands/create.js.map +1 -1
  18. package/dist/cli/commands/extension/bundled-catalog.d.ts +6 -0
  19. package/dist/cli/commands/extension/bundled-catalog.js +15 -2
  20. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  21. package/dist/cli/commands/extension/describe.d.ts +6 -3
  22. package/dist/cli/commands/extension/describe.js +21 -9
  23. package/dist/cli/commands/extension/describe.js.map +1 -1
  24. package/dist/cli/commands/extension/doctor.d.ts +0 -4
  25. package/dist/cli/commands/extension/doctor.js +3 -3
  26. package/dist/cli/commands/extension/doctor.js.map +1 -1
  27. package/dist/cli/commands/extension/scaffold.js +59 -133
  28. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  29. package/dist/cli/commands/extension/shared.d.ts +2 -7
  30. package/dist/cli/commands/extension/shared.js +4 -10
  31. package/dist/cli/commands/extension/shared.js.map +1 -1
  32. package/dist/cli/commands/extension.js +33 -8
  33. package/dist/cli/commands/extension.js.map +1 -1
  34. package/dist/cli/commands/files.js +3 -3
  35. package/dist/cli/commands/files.js.map +1 -1
  36. package/dist/cli/commands/history-compact.js +9 -18
  37. package/dist/cli/commands/history-compact.js.map +1 -1
  38. package/dist/cli/commands/history-repair.js +9 -19
  39. package/dist/cli/commands/history-repair.js.map +1 -1
  40. package/dist/cli/commands/init-agent-guidance.js +133 -97
  41. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  42. package/dist/cli/commands/init.js +3 -3
  43. package/dist/cli/commands/init.js.map +1 -1
  44. package/dist/cli/commands/item-filter-options.d.ts +2 -0
  45. package/dist/cli/commands/item-filter-options.js +2 -2
  46. package/dist/cli/commands/item-filter-options.js.map +1 -1
  47. package/dist/cli/commands/mutation-command-options.d.ts +78 -0
  48. package/dist/cli/commands/mutation-command-options.js +10 -0
  49. package/dist/cli/commands/mutation-command-options.js.map +1 -0
  50. package/dist/cli/commands/profile.js +3 -3
  51. package/dist/cli/commands/profile.js.map +1 -1
  52. package/dist/cli/commands/reindex.js +4 -4
  53. package/dist/cli/commands/reindex.js.map +1 -1
  54. package/dist/cli/commands/restore.js +3 -3
  55. package/dist/cli/commands/restore.js.map +1 -1
  56. package/dist/cli/commands/schema.js +10 -10
  57. package/dist/cli/commands/schema.js.map +1 -1
  58. package/dist/cli/commands/shared-unset-fields.d.ts +19 -0
  59. package/dist/cli/commands/shared-unset-fields.js +31 -2
  60. package/dist/cli/commands/shared-unset-fields.js.map +1 -1
  61. package/dist/cli/commands/update.d.ts +2 -59
  62. package/dist/cli/commands/update.js +29 -98
  63. package/dist/cli/commands/update.js.map +1 -1
  64. package/dist/cli/commands/validate.js +4 -4
  65. package/dist/cli/commands/validate.js.map +1 -1
  66. package/dist/cli/error-guidance.js +107 -7
  67. package/dist/cli/error-guidance.js.map +1 -1
  68. package/dist/cli/main.d.ts +6 -2
  69. package/dist/cli/main.js +33 -12
  70. package/dist/cli/main.js.map +1 -1
  71. package/dist/cli/register-list-query.js +4 -2
  72. package/dist/cli/register-list-query.js.map +1 -1
  73. package/dist/cli/registration-helpers.js +12 -6
  74. package/dist/cli/registration-helpers.js.map +1 -1
  75. package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +18 -0
  76. package/dist/cli-bundle/chunks/{activity-5YWLSPGE.js → activity-YKAKZTZ4.js} +11 -9
  77. package/dist/cli-bundle/chunks/{aggregate-2V2M3JZU.js → aggregate-EQX2RGB7.js} +16 -13
  78. package/dist/cli-bundle/chunks/{aggregate-2V2M3JZU.js.map → aggregate-EQX2RGB7.js.map} +1 -1
  79. package/dist/cli-bundle/chunks/{aggregate-EK7DXML7.js → aggregate-PEGZGJXD.js} +18 -15
  80. package/dist/cli-bundle/chunks/{aggregate-EK7DXML7.js.map → aggregate-PEGZGJXD.js.map} +1 -1
  81. package/dist/cli-bundle/chunks/{append-EZESUVJT.js → append-CZGUZ45Q.js} +11 -8
  82. package/dist/cli-bundle/chunks/{append-EZESUVJT.js.map → append-CZGUZ45Q.js.map} +1 -1
  83. package/dist/cli-bundle/chunks/{append-JFG4WQMG.js → append-NSQBCXZJ.js} +13 -10
  84. package/dist/cli-bundle/chunks/{append-JFG4WQMG.js.map → append-NSQBCXZJ.js.map} +1 -1
  85. package/dist/cli-bundle/chunks/chunk-3JZNEQBA.js +1413 -0
  86. package/dist/cli-bundle/chunks/chunk-3JZNEQBA.js.map +1 -0
  87. package/dist/cli-bundle/chunks/{chunk-NOIEVOK5.js → chunk-3PL6LEKP.js} +16 -14
  88. package/dist/cli-bundle/chunks/{chunk-NOIEVOK5.js.map → chunk-3PL6LEKP.js.map} +1 -1
  89. package/dist/cli-bundle/chunks/{chunk-6KRFL33E.js → chunk-3U3VEWK6.js} +277 -119
  90. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +7 -0
  91. package/dist/cli-bundle/chunks/{chunk-Z5F6XZXE.js → chunk-3Y4OESPP.js} +14 -12
  92. package/dist/cli-bundle/chunks/{chunk-Z5F6XZXE.js.map → chunk-3Y4OESPP.js.map} +1 -1
  93. package/dist/cli-bundle/chunks/{chunk-HB4FAT3O.js → chunk-4LRVSBO6.js} +21 -15
  94. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js.map +7 -0
  95. package/dist/cli-bundle/chunks/{chunk-T3P7PMZP.js → chunk-4OFLJHX6.js} +7 -5
  96. package/dist/cli-bundle/chunks/{chunk-T3P7PMZP.js.map → chunk-4OFLJHX6.js.map} +1 -1
  97. package/dist/cli-bundle/chunks/{chunk-JPATY4SE.js → chunk-4QQ6PM7M.js} +45 -557
  98. package/dist/cli-bundle/chunks/chunk-4QQ6PM7M.js.map +7 -0
  99. package/dist/cli-bundle/chunks/{chunk-6CDCWKSX.js → chunk-53BTLLAF.js} +68 -331
  100. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +1 -0
  101. package/dist/cli-bundle/chunks/{chunk-4WB6S4YX.js → chunk-57C2RLW5.js} +277 -112
  102. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +1 -0
  103. package/dist/cli-bundle/chunks/{chunk-PULUSQAV.js → chunk-5B3X4Y22.js} +52 -63
  104. package/dist/cli-bundle/chunks/{chunk-PULUSQAV.js.map → chunk-5B3X4Y22.js.map} +3 -3
  105. package/dist/cli-bundle/chunks/{chunk-7LYO6S5A.js → chunk-5J2XPTAD.js} +10 -8
  106. package/dist/cli-bundle/chunks/{chunk-7LYO6S5A.js.map → chunk-5J2XPTAD.js.map} +1 -1
  107. package/dist/cli-bundle/chunks/{chunk-QCDTQCMW.js → chunk-5JE6SMYS.js} +2 -2
  108. package/dist/cli-bundle/chunks/{chunk-MHRS5FUX.js → chunk-5JZ7APJU.js} +153 -108
  109. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-KHVGM5CS.js → chunk-5VVUKE3U.js} +544 -2368
  111. package/dist/cli-bundle/chunks/chunk-5VVUKE3U.js.map +7 -0
  112. package/dist/cli-bundle/chunks/{chunk-RJH5VQHW.js → chunk-75U6M5ZD.js} +22 -16
  113. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js.map +1 -0
  114. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +23 -0
  115. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-ZFTKYWIF.js → chunk-7EQNAZX2.js} +14 -12
  117. package/dist/cli-bundle/chunks/{chunk-ZFTKYWIF.js.map → chunk-7EQNAZX2.js.map} +1 -1
  118. package/dist/cli-bundle/chunks/{chunk-Z4DGFQDH.js → chunk-7LQKVMPA.js} +14 -4
  119. package/dist/cli-bundle/chunks/chunk-7LQKVMPA.js.map +1 -0
  120. package/dist/cli-bundle/chunks/{chunk-ERG65A2L.js → chunk-7MDXZAZS.js} +29 -7
  121. package/dist/cli-bundle/chunks/chunk-7MDXZAZS.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-OGLGI22K.js → chunk-7QH7DHUB.js} +74 -8
  123. package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +1 -0
  124. package/dist/cli-bundle/chunks/{chunk-JBZ2NTKX.js → chunk-7WYXBPYQ.js} +7 -5
  125. package/dist/cli-bundle/chunks/{chunk-JBZ2NTKX.js.map → chunk-7WYXBPYQ.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/chunk-AAEQMOC6.js +150 -0
  127. package/dist/cli-bundle/chunks/chunk-AAEQMOC6.js.map +1 -0
  128. package/dist/cli-bundle/chunks/{chunk-K5DT2YKM.js → chunk-ABRA3BHY.js} +18 -16
  129. package/dist/cli-bundle/chunks/{chunk-K5DT2YKM.js.map → chunk-ABRA3BHY.js.map} +2 -2
  130. package/dist/cli-bundle/chunks/chunk-B5KXLBSJ.js +47 -0
  131. package/dist/cli-bundle/chunks/chunk-B5KXLBSJ.js.map +7 -0
  132. package/dist/cli-bundle/chunks/{chunk-7CLLC75T.js → chunk-BFVHCAOO.js} +9 -7
  133. package/dist/cli-bundle/chunks/{chunk-7CLLC75T.js.map → chunk-BFVHCAOO.js.map} +1 -1
  134. package/dist/cli-bundle/chunks/{chunk-MDHWWBNZ.js → chunk-BVEUCSH2.js} +6 -4
  135. package/dist/cli-bundle/chunks/{chunk-MDHWWBNZ.js.map → chunk-BVEUCSH2.js.map} +1 -1
  136. package/dist/cli-bundle/chunks/chunk-C3PMDWGX.js +160 -0
  137. package/dist/cli-bundle/chunks/chunk-C3PMDWGX.js.map +7 -0
  138. package/dist/cli-bundle/chunks/{chunk-T4XBKJ3F.js → chunk-D3UCE7RW.js} +7 -5
  139. package/dist/cli-bundle/chunks/{chunk-T4XBKJ3F.js.map → chunk-D3UCE7RW.js.map} +1 -1
  140. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +275 -0
  141. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +7 -0
  142. package/dist/cli-bundle/chunks/chunk-DLQ4ZTCU.js +634 -0
  143. package/dist/cli-bundle/chunks/chunk-DLQ4ZTCU.js.map +7 -0
  144. package/dist/cli-bundle/chunks/{chunk-AJHYQCBJ.js → chunk-DRBV5UC2.js} +8 -23
  145. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +7 -0
  146. package/dist/cli-bundle/chunks/{chunk-NZ7QIUP5.js → chunk-E2FUG6GD.js} +67 -351
  147. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js.map +7 -0
  148. package/dist/cli-bundle/chunks/{chunk-4PFVUUYV.js → chunk-EEY54JMF.js} +5 -3
  149. package/dist/cli-bundle/chunks/{chunk-4PFVUUYV.js.map → chunk-EEY54JMF.js.map} +1 -1
  150. package/dist/cli-bundle/chunks/{chunk-3W2HJKJX.js → chunk-EZFKWSC7.js} +94 -16
  151. package/dist/cli-bundle/chunks/{chunk-3W2HJKJX.js.map → chunk-EZFKWSC7.js.map} +4 -4
  152. package/dist/cli-bundle/chunks/{chunk-F6WNBITZ.js → chunk-FDBARR33.js} +40 -19
  153. package/dist/cli-bundle/chunks/{chunk-F6WNBITZ.js.map → chunk-FDBARR33.js.map} +3 -3
  154. package/dist/cli-bundle/chunks/{chunk-WRYERRZX.js → chunk-FGQKEDE4.js} +36 -12
  155. package/dist/cli-bundle/chunks/chunk-FGQKEDE4.js.map +7 -0
  156. package/dist/cli-bundle/chunks/{chunk-CXR3CMBQ.js → chunk-FJRKQREY.js} +10 -18
  157. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +1 -0
  158. package/dist/cli-bundle/chunks/{chunk-QNNQAAZ5.js → chunk-FUM6UMY4.js} +10 -11
  159. package/dist/cli-bundle/chunks/{chunk-QNNQAAZ5.js.map → chunk-FUM6UMY4.js.map} +1 -1
  160. package/dist/cli-bundle/chunks/{chunk-TQ6AX5SQ.js → chunk-GIWXVMZ3.js} +140 -334
  161. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +7 -0
  162. package/dist/cli-bundle/chunks/{chunk-FZJM2TXF.js → chunk-HBYZDSK5.js} +19 -17
  163. package/dist/cli-bundle/chunks/{chunk-FZJM2TXF.js.map → chunk-HBYZDSK5.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{chunk-5IZUBZBR.js → chunk-HJE4JTKQ.js} +6 -4
  165. package/dist/cli-bundle/chunks/{chunk-5IZUBZBR.js.map → chunk-HJE4JTKQ.js.map} +1 -1
  166. package/dist/cli-bundle/chunks/{chunk-YSDFIY7N.js → chunk-HK72NWAD.js} +89 -18
  167. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +1 -0
  168. package/dist/cli-bundle/chunks/{chunk-LBE5QFMZ.js → chunk-IJ6CO3JV.js} +41 -20
  169. package/dist/cli-bundle/chunks/{chunk-LBE5QFMZ.js.map → chunk-IJ6CO3JV.js.map} +1 -1
  170. package/dist/cli-bundle/chunks/{chunk-YF746GTH.js → chunk-JFCVQXZX.js} +139 -326
  171. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +1 -0
  172. package/dist/cli-bundle/chunks/{chunk-A3OQ7TFW.js → chunk-JLA7EVYV.js} +12 -10
  173. package/dist/cli-bundle/chunks/{chunk-A3OQ7TFW.js.map → chunk-JLA7EVYV.js.map} +1 -1
  174. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +76 -0
  175. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +1 -0
  176. package/dist/cli-bundle/chunks/{chunk-32IUNTG4.js → chunk-K3AGVXSF.js} +37 -13
  177. package/dist/cli-bundle/chunks/chunk-K3AGVXSF.js.map +1 -0
  178. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +79 -0
  179. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +7 -0
  180. package/dist/cli-bundle/chunks/chunk-KGHH652T.js +44 -0
  181. package/dist/cli-bundle/chunks/chunk-KGHH652T.js.map +1 -0
  182. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +915 -0
  183. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +1 -0
  184. package/dist/cli-bundle/chunks/{chunk-BI4R7HI2.js → chunk-KLG4ZULO.js} +12 -10
  185. package/dist/cli-bundle/chunks/{chunk-BI4R7HI2.js.map → chunk-KLG4ZULO.js.map} +1 -1
  186. package/dist/cli-bundle/chunks/{chunk-XRYSCRZR.js → chunk-LEKT4K7I.js} +74 -8
  187. package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +7 -0
  188. package/dist/cli-bundle/chunks/{contracts-X74F2GSM.js → chunk-MNZ7DRNC.js} +13 -10
  189. package/dist/cli-bundle/chunks/{contracts-X74F2GSM.js.map → chunk-MNZ7DRNC.js.map} +1 -1
  190. package/dist/cli-bundle/chunks/{chunk-4EXFFP7T.js → chunk-MTTXDAK4.js} +206 -147
  191. package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +7 -0
  192. package/dist/cli-bundle/chunks/{chunk-KEZOIPCR.js → chunk-MZ7VNEVY.js} +8 -6
  193. package/dist/cli-bundle/chunks/{chunk-KEZOIPCR.js.map → chunk-MZ7VNEVY.js.map} +1 -1
  194. package/dist/cli-bundle/chunks/{chunk-5JIWFWOZ.js → chunk-N6DNM2FA.js} +2 -2
  195. package/dist/cli-bundle/chunks/{test-runs-QIR5MJPL.js → chunk-N7X4WP6L.js} +11 -8
  196. package/dist/cli-bundle/chunks/{test-runs-QIR5MJPL.js.map → chunk-N7X4WP6L.js.map} +1 -1
  197. package/dist/cli-bundle/chunks/{chunk-U3S2B7TA.js → chunk-NBFCNJ7Q.js} +206 -147
  198. package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +1 -0
  199. package/dist/cli-bundle/chunks/{chunk-GVJE5T7Q.js → chunk-NER3KUUS.js} +2 -2
  200. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +20 -0
  201. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +1 -0
  202. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +918 -0
  203. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +7 -0
  204. package/dist/cli-bundle/chunks/{chunk-YPWUSH72.js → chunk-OESSOFJ4.js} +14 -12
  205. package/dist/cli-bundle/chunks/{chunk-YPWUSH72.js.map → chunk-OESSOFJ4.js.map} +1 -1
  206. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +238 -0
  207. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +1 -0
  208. package/dist/cli-bundle/chunks/{chunk-FUFFPIYA.js → chunk-OWTIRHX4.js} +28 -6
  209. package/dist/cli-bundle/chunks/chunk-OWTIRHX4.js.map +7 -0
  210. package/dist/cli-bundle/chunks/{chunk-Z7RPDF2Y.js → chunk-P3VRG72Q.js} +10 -8
  211. package/dist/cli-bundle/chunks/{chunk-Z7RPDF2Y.js.map → chunk-P3VRG72Q.js.map} +1 -1
  212. package/dist/cli-bundle/chunks/chunk-P5TFTLWW.js +1423 -0
  213. package/dist/cli-bundle/chunks/chunk-P5TFTLWW.js.map +7 -0
  214. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +1977 -0
  215. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +7 -0
  216. package/dist/cli-bundle/chunks/{chunk-MEZZZBYX.js → chunk-PDXT6Q55.js} +2 -2
  217. package/dist/cli-bundle/chunks/{chunk-EJ2OCBHF.js → chunk-PJ3A56YF.js} +46 -537
  218. package/dist/cli-bundle/chunks/chunk-PJ3A56YF.js.map +1 -0
  219. package/dist/cli-bundle/chunks/{test-runs-MG5VIGSK.js → chunk-PPAJG4GB.js} +13 -10
  220. package/dist/cli-bundle/chunks/{test-runs-MG5VIGSK.js.map → chunk-PPAJG4GB.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/{chunk-572FKBRL.js → chunk-PPE4YUQM.js} +1725 -1663
  222. package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +1 -0
  223. package/dist/cli-bundle/chunks/{chunk-ER4ME5U2.js → chunk-QHZO65XW.js} +8 -6
  224. package/dist/cli-bundle/chunks/{chunk-ER4ME5U2.js.map → chunk-QHZO65XW.js.map} +1 -1
  225. package/dist/cli-bundle/chunks/{chunk-T6AXEBOP.js → chunk-R3ZBLGTC.js} +9 -10
  226. package/dist/cli-bundle/chunks/{chunk-T6AXEBOP.js.map → chunk-R3ZBLGTC.js.map} +2 -2
  227. package/dist/cli-bundle/chunks/chunk-RCT3YJOK.js +624 -0
  228. package/dist/cli-bundle/chunks/chunk-RCT3YJOK.js.map +1 -0
  229. package/dist/cli-bundle/chunks/{chunk-YVKZ3ANP.js → chunk-RX3HQSYG.js} +2 -2
  230. package/dist/cli-bundle/chunks/{chunk-LOWVNZBZ.js → chunk-S4APD35C.js} +4 -4
  231. package/dist/cli-bundle/chunks/{chunk-FH2H3CBD.js → chunk-S5AYOUT5.js} +8 -6
  232. package/dist/cli-bundle/chunks/{chunk-FH2H3CBD.js.map → chunk-S5AYOUT5.js.map} +1 -1
  233. package/dist/cli-bundle/chunks/{chunk-SYE6WMV6.js → chunk-STPSZ2XY.js} +19 -744
  234. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +1 -0
  235. package/dist/cli-bundle/chunks/{chunk-6NYJGMTY.js → chunk-T35XLYZF.js} +2 -2
  236. package/dist/cli-bundle/chunks/{chunk-P5L7Z2O6.js → chunk-T3ABIMGW.js} +5 -3
  237. package/dist/cli-bundle/chunks/{chunk-P5L7Z2O6.js.map → chunk-T3ABIMGW.js.map} +1 -1
  238. package/dist/cli-bundle/chunks/{chunk-SU2E4AWU.js → chunk-T3F4DF23.js} +16 -14
  239. package/dist/cli-bundle/chunks/{chunk-SU2E4AWU.js.map → chunk-T3F4DF23.js.map} +1 -1
  240. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +272 -0
  241. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +1 -0
  242. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js +5354 -0
  243. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{chunk-ECU6MMTQ.js → chunk-TSPKZRRW.js} +50 -116
  245. package/dist/cli-bundle/chunks/chunk-TSPKZRRW.js.map +1 -0
  246. package/dist/cli-bundle/chunks/{chunk-BE2SR6QL.js → chunk-TT42JUMF.js} +4 -4
  247. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +165 -0
  248. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +1 -0
  249. package/dist/cli-bundle/chunks/{chunk-RAHINBVP.js → chunk-UI5BJ6DO.js} +1339 -1277
  250. package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +7 -0
  251. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +1932 -0
  252. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +1 -0
  253. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +175 -0
  254. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +7 -0
  255. package/dist/cli-bundle/chunks/{chunk-B4O5S7I3.js → chunk-VUHVWI4C.js} +13 -3
  256. package/dist/cli-bundle/chunks/chunk-VUHVWI4C.js.map +7 -0
  257. package/dist/cli-bundle/chunks/{contracts-L6ODXNUM.js → chunk-VZIYHZDX.js} +11 -8
  258. package/dist/cli-bundle/chunks/{contracts-L6ODXNUM.js.map → chunk-VZIYHZDX.js.map} +1 -1
  259. package/dist/cli-bundle/chunks/{chunk-U5TR4N7J.js → chunk-WISPVC2E.js} +9 -7
  260. package/dist/cli-bundle/chunks/{chunk-U5TR4N7J.js.map → chunk-WISPVC2E.js.map} +1 -1
  261. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js +5434 -0
  262. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +7 -0
  263. package/dist/cli-bundle/chunks/{chunk-HQAF23Q2.js → chunk-XQCG2JGW.js} +17 -749
  264. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +7 -0
  265. package/dist/cli-bundle/chunks/chunk-Y76TWC45.js +550 -0
  266. package/dist/cli-bundle/chunks/chunk-Y76TWC45.js.map +7 -0
  267. package/dist/cli-bundle/chunks/{chunk-L4SLHV6G.js → chunk-YD5FML7K.js} +464 -2239
  268. package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +1 -0
  269. package/dist/cli-bundle/chunks/{chunk-YSGTMDWC.js → chunk-YFIE7YK6.js} +7 -5
  270. package/dist/cli-bundle/chunks/{chunk-YSGTMDWC.js.map → chunk-YFIE7YK6.js.map} +1 -1
  271. package/dist/cli-bundle/chunks/{chunk-WYOIIFSE.js → chunk-YMABYTNG.js} +49 -115
  272. package/dist/cli-bundle/chunks/chunk-YMABYTNG.js.map +7 -0
  273. package/dist/cli-bundle/chunks/{chunk-SU3TB4NS.js → chunk-YOF5VPKM.js} +2 -2
  274. package/dist/cli-bundle/chunks/{chunk-WJA3PXW7.js → chunk-YPPVU5GX.js} +11 -9
  275. package/dist/cli-bundle/chunks/{chunk-WJA3PXW7.js.map → chunk-YPPVU5GX.js.map} +1 -1
  276. package/dist/cli-bundle/chunks/{chunk-GUYNUXQT.js → chunk-YQMMMONE.js} +6 -4
  277. package/dist/cli-bundle/chunks/{chunk-GUYNUXQT.js.map → chunk-YQMMMONE.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{chunk-AIKU3IIL.js → chunk-YSAH5FY5.js} +16 -14
  279. package/dist/cli-bundle/chunks/{chunk-AIKU3IIL.js.map → chunk-YSAH5FY5.js.map} +1 -1
  280. package/dist/cli-bundle/chunks/{chunk-KS6ATO47.js → chunk-YZIR4R3U.js} +153 -108
  281. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js.map +7 -0
  282. package/dist/cli-bundle/chunks/{chunk-LCWQP6NM.js → chunk-Z2CRRZYF.js} +14 -12
  283. package/dist/cli-bundle/chunks/{chunk-LCWQP6NM.js.map → chunk-Z2CRRZYF.js.map} +1 -1
  284. package/dist/cli-bundle/chunks/chunk-ZAHXPXVY.js +533 -0
  285. package/dist/cli-bundle/chunks/chunk-ZAHXPXVY.js.map +1 -0
  286. package/dist/cli-bundle/chunks/{chunk-UMNQZS4H.js → chunk-ZCJAA3JK.js} +8 -6
  287. package/dist/cli-bundle/chunks/{chunk-UMNQZS4H.js.map → chunk-ZCJAA3JK.js.map} +1 -1
  288. package/dist/cli-bundle/chunks/{chunk-EQURFOMH.js → chunk-ZD34OFFQ.js} +5 -3
  289. package/dist/cli-bundle/chunks/{chunk-EQURFOMH.js.map → chunk-ZD34OFFQ.js.map} +1 -1
  290. package/dist/cli-bundle/chunks/{chunk-67LARBDL.js → chunk-ZJB3UV5U.js} +54 -58
  291. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +1 -0
  292. package/dist/cli-bundle/chunks/{chunk-5E7N4T2Z.js → chunk-ZMD35NYG.js} +2 -2
  293. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +241 -0
  294. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +7 -0
  295. package/dist/cli-bundle/chunks/{claim-5GU7OE67.js → claim-4DROPSIS.js} +30 -13
  296. package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +1 -0
  297. package/dist/cli-bundle/chunks/{claim-2BGBGSVI.js → claim-VX54TV5U.js} +29 -12
  298. package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +7 -0
  299. package/dist/cli-bundle/chunks/{close-AFVKPR57.js → close-3YRR3XY6.js} +9 -7
  300. package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +16 -0
  301. package/dist/cli-bundle/chunks/{close-many-JKUJMHLG.js → close-many-AP4MWU36.js} +21 -18
  302. package/dist/cli-bundle/chunks/{close-many-JKUJMHLG.js.map → close-many-AP4MWU36.js.map} +1 -1
  303. package/dist/cli-bundle/chunks/{close-many-7KLOSYLP.js → close-many-OMZIGZB4.js} +19 -16
  304. package/dist/cli-bundle/chunks/{close-many-7KLOSYLP.js.map → close-many-OMZIGZB4.js.map} +1 -1
  305. package/dist/cli-bundle/chunks/{comments-DNWHEBOS.js → comments-MIW5MZOX.js} +12 -9
  306. package/dist/cli-bundle/chunks/{comments-DNWHEBOS.js.map → comments-MIW5MZOX.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/{comments-RW23R3VE.js → comments-SAG5LSKL.js} +14 -11
  308. package/dist/cli-bundle/chunks/{comments-RW23R3VE.js.map → comments-SAG5LSKL.js.map} +1 -1
  309. package/dist/cli-bundle/chunks/{config-AUM5WBYA.js → config-DJJKZB5R.js} +20 -17
  310. package/dist/cli-bundle/chunks/{config-AUM5WBYA.js.map → config-DJJKZB5R.js.map} +1 -1
  311. package/dist/cli-bundle/chunks/{config-OZWSA2NP.js → config-V57QD47V.js} +22 -19
  312. package/dist/cli-bundle/chunks/{config-OZWSA2NP.js.map → config-V57QD47V.js.map} +1 -1
  313. package/dist/cli-bundle/chunks/{context-PKCEHQY3.js → context-4OQGIPSO.js} +15 -12
  314. package/dist/cli-bundle/chunks/{context-OYXRGY7S.js → context-WLA6IAWE.js} +15 -12
  315. package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +12 -0
  316. package/dist/cli-bundle/chunks/contracts-OJEXMKVW.js +16 -0
  317. package/dist/cli-bundle/chunks/{copy-I4NCLBR4.js → copy-LEE6P6EM.js} +17 -14
  318. package/dist/cli-bundle/chunks/{copy-I4NCLBR4.js.map → copy-LEE6P6EM.js.map} +2 -2
  319. package/dist/cli-bundle/chunks/{copy-6XOR3HKN.js → copy-OTJOWFL6.js} +18 -15
  320. package/dist/cli-bundle/chunks/{copy-6XOR3HKN.js.map → copy-OTJOWFL6.js.map} +1 -1
  321. package/dist/cli-bundle/chunks/create-WKOZKPQR.js +30 -0
  322. package/dist/cli-bundle/chunks/{create-PM45M6PE.js → create-XWWQFQ6S.js} +14 -12
  323. package/dist/cli-bundle/chunks/{delete-7YXHYG67.js → delete-62JQTYT4.js} +10 -7
  324. package/dist/cli-bundle/chunks/{delete-7YXHYG67.js.map → delete-62JQTYT4.js.map} +1 -1
  325. package/dist/cli-bundle/chunks/{delete-LPISP43T.js → delete-HQKGRNRZ.js} +12 -9
  326. package/dist/cli-bundle/chunks/{delete-LPISP43T.js.map → delete-HQKGRNRZ.js.map} +1 -1
  327. package/dist/cli-bundle/chunks/{deps-WATKQDE3.js → deps-55FTG6Z5.js} +12 -9
  328. package/dist/cli-bundle/chunks/{deps-WATKQDE3.js.map → deps-55FTG6Z5.js.map} +1 -1
  329. package/dist/cli-bundle/chunks/{deps-N2T26FME.js → deps-L2FPIAD3.js} +10 -7
  330. package/dist/cli-bundle/chunks/{deps-N2T26FME.js.map → deps-L2FPIAD3.js.map} +1 -1
  331. package/dist/cli-bundle/chunks/{docs-6LQ3GLM7.js → docs-6CRCSVKK.js} +11 -9
  332. package/dist/cli-bundle/chunks/{docs-6LQ3GLM7.js.map → docs-6CRCSVKK.js.map} +1 -1
  333. package/dist/cli-bundle/chunks/{docs-Z3X6JZLT.js → docs-S6UTOTO5.js} +9 -7
  334. package/dist/cli-bundle/chunks/{docs-Z3X6JZLT.js.map → docs-S6UTOTO5.js.map} +1 -1
  335. package/dist/cli-bundle/chunks/{eval-6DCLG52D.js → eval-N6UHFWVO.js} +15 -11
  336. package/dist/cli-bundle/chunks/{eval-6DCLG52D.js.map → eval-N6UHFWVO.js.map} +1 -1
  337. package/dist/cli-bundle/chunks/{eval-Y3ZCUTHK.js → eval-PHOTWYHI.js} +17 -13
  338. package/dist/cli-bundle/chunks/{eval-Y3ZCUTHK.js.map → eval-PHOTWYHI.js.map} +1 -1
  339. package/dist/cli-bundle/chunks/{extension-BNINIMT7.js → extension-NBAH62ML.js} +17 -11
  340. package/dist/cli-bundle/chunks/{extension-QWE4YYK5.js → extension-ZF6ZZPOU.js} +17 -11
  341. package/dist/cli-bundle/chunks/{files-FUYPSOFJ.js → files-6P57MRKL.js} +14 -11
  342. package/dist/cli-bundle/chunks/files-6P57MRKL.js.map +7 -0
  343. package/dist/cli-bundle/chunks/{files-6SGKHS6O.js → files-JPU3FNJ7.js} +15 -12
  344. package/dist/cli-bundle/chunks/files-JPU3FNJ7.js.map +1 -0
  345. package/dist/cli-bundle/chunks/{focus-2Q3K76G2.js → focus-LFZ6IDBR.js} +15 -11
  346. package/dist/cli-bundle/chunks/{focus-2Q3K76G2.js.map → focus-LFZ6IDBR.js.map} +1 -1
  347. package/dist/cli-bundle/chunks/{focus-ATLBWXXD.js → focus-WNMYCVYA.js} +13 -9
  348. package/dist/cli-bundle/chunks/{focus-ATLBWXXD.js.map → focus-WNMYCVYA.js.map} +1 -1
  349. package/dist/cli-bundle/chunks/{gc-RUYEMNRF.js → gc-AETFKZ44.js} +10 -7
  350. package/dist/cli-bundle/chunks/{gc-RUYEMNRF.js.map → gc-AETFKZ44.js.map} +1 -1
  351. package/dist/cli-bundle/chunks/{gc-TDWSDR66.js → gc-RLBP4QVN.js} +12 -9
  352. package/dist/cli-bundle/chunks/{gc-TDWSDR66.js.map → gc-RLBP4QVN.js.map} +1 -1
  353. package/dist/cli-bundle/chunks/{get-LY6M2JIM.js → get-NH2MPBCI.js} +18 -15
  354. package/dist/cli-bundle/chunks/{get-LY6M2JIM.js.map → get-NH2MPBCI.js.map} +1 -1
  355. package/dist/cli-bundle/chunks/{get-2WGLX74N.js → get-P4ZQXCPZ.js} +16 -13
  356. package/dist/cli-bundle/chunks/{get-2WGLX74N.js.map → get-P4ZQXCPZ.js.map} +1 -1
  357. package/dist/cli-bundle/chunks/{health-4RKHYS3T.js → health-3GVPMQBL.js} +36 -29
  358. package/dist/cli-bundle/chunks/{health-4RKHYS3T.js.map → health-3GVPMQBL.js.map} +1 -1
  359. package/dist/cli-bundle/chunks/{health-TMFVNYRA.js → health-DNTM72GJ.js} +34 -27
  360. package/dist/cli-bundle/chunks/{health-TMFVNYRA.js.map → health-DNTM72GJ.js.map} +1 -1
  361. package/dist/cli-bundle/chunks/history-RYKLC72X.js +20 -0
  362. package/dist/cli-bundle/chunks/{history-SGRRS72R.js → history-SGPYRAFT.js} +10 -8
  363. package/dist/cli-bundle/chunks/{history-compact-LOED43R3.js → history-compact-3F6VELO7.js} +26 -30
  364. package/dist/cli-bundle/chunks/history-compact-3F6VELO7.js.map +7 -0
  365. package/dist/cli-bundle/chunks/{history-compact-V5DNAQHH.js → history-compact-656Y2TN4.js} +27 -31
  366. package/dist/cli-bundle/chunks/history-compact-656Y2TN4.js.map +1 -0
  367. package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +21 -0
  368. package/dist/cli-bundle/chunks/{history-redact-IRL7WJ3E.js → history-redact-54ICFKXM.js} +11 -9
  369. package/dist/cli-bundle/chunks/{history-repair-PGYQJMGD.js → history-repair-4N6SDVHK.js} +25 -30
  370. package/dist/cli-bundle/chunks/history-repair-4N6SDVHK.js.map +7 -0
  371. package/dist/cli-bundle/chunks/{history-repair-4WVBVHFR.js → history-repair-EVTO6LIH.js} +26 -31
  372. package/dist/cli-bundle/chunks/history-repair-EVTO6LIH.js.map +1 -0
  373. package/dist/cli-bundle/chunks/init-RPIPQUNV.js +32 -0
  374. package/dist/cli-bundle/chunks/init-SKQAESQS.js +28 -0
  375. package/dist/cli-bundle/chunks/{learnings-4FJY7WIW.js → learnings-2HTPZNGZ.js} +10 -8
  376. package/dist/cli-bundle/chunks/{learnings-4FJY7WIW.js.map → learnings-2HTPZNGZ.js.map} +1 -1
  377. package/dist/cli-bundle/chunks/{learnings-4BHWFFUV.js → learnings-YBIHY3D6.js} +12 -10
  378. package/dist/cli-bundle/chunks/{learnings-4BHWFFUV.js.map → learnings-YBIHY3D6.js.map} +1 -1
  379. package/dist/cli-bundle/chunks/{list-472TIOVK.js → list-64LHZ3HM.js} +10 -8
  380. package/dist/cli-bundle/chunks/{list-D7BF5CL2.js → list-7LXBTEKI.js} +10 -8
  381. package/dist/cli-bundle/chunks/{next-SFQZVX2B.js → next-7ODPAQ4U.js} +22 -18
  382. package/dist/cli-bundle/chunks/{next-SFQZVX2B.js.map → next-7ODPAQ4U.js.map} +1 -1
  383. package/dist/cli-bundle/chunks/{next-D5STGWI2.js → next-ODJUM4ZM.js} +24 -20
  384. package/dist/cli-bundle/chunks/{next-D5STGWI2.js.map → next-ODJUM4ZM.js.map} +1 -1
  385. package/dist/cli-bundle/chunks/{notes-6KNOSLIT.js → notes-72YXN5JX.js} +10 -8
  386. package/dist/cli-bundle/chunks/{notes-6KNOSLIT.js.map → notes-72YXN5JX.js.map} +1 -1
  387. package/dist/cli-bundle/chunks/{notes-W4UEICGF.js → notes-NJ7IQJX4.js} +12 -10
  388. package/dist/cli-bundle/chunks/{notes-W4UEICGF.js.map → notes-NJ7IQJX4.js.map} +1 -1
  389. package/dist/cli-bundle/chunks/{plan-MJQW5XK3.js → plan-R4NDQ27E.js} +18 -15
  390. package/dist/cli-bundle/chunks/{plan-MJQW5XK3.js.map → plan-R4NDQ27E.js.map} +1 -1
  391. package/dist/cli-bundle/chunks/{plan-JO6V7BXO.js → plan-XWY5T67S.js} +20 -17
  392. package/dist/cli-bundle/chunks/{plan-JO6V7BXO.js.map → plan-XWY5T67S.js.map} +1 -1
  393. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +397 -0
  394. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +1 -0
  395. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +400 -0
  396. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +7 -0
  397. package/dist/cli-bundle/chunks/{register-list-query-ELBHCCFI.js → register-list-query-5H66WFYF.js} +24 -21
  398. package/dist/cli-bundle/chunks/register-list-query-5H66WFYF.js.map +7 -0
  399. package/dist/cli-bundle/chunks/{register-list-query-GAPQ6DM3.js → register-list-query-FB3FNDLZ.js} +25 -22
  400. package/dist/cli-bundle/chunks/{register-list-query-ELBHCCFI.js.map → register-list-query-FB3FNDLZ.js.map} +1 -7
  401. package/dist/cli-bundle/chunks/{register-mutation-SJWMVIJ2.js → register-mutation-UJO23C7R.js} +42 -39
  402. package/dist/cli-bundle/chunks/{register-mutation-SJWMVIJ2.js.map → register-mutation-UJO23C7R.js.map} +1 -1
  403. package/dist/cli-bundle/chunks/{register-mutation-ROFE2YPC.js → register-mutation-Z2ETYHKS.js} +40 -37
  404. package/dist/cli-bundle/chunks/{register-mutation-ROFE2YPC.js.map → register-mutation-Z2ETYHKS.js.map} +1 -1
  405. package/dist/cli-bundle/chunks/{register-operations-MEKU3AKC.js → register-operations-A3XAM5J7.js} +39 -36
  406. package/dist/cli-bundle/chunks/{register-operations-MEKU3AKC.js.map → register-operations-A3XAM5J7.js.map} +1 -1
  407. package/dist/cli-bundle/chunks/{register-operations-IADFVH53.js → register-operations-SG7HBSUP.js} +37 -34
  408. package/dist/cli-bundle/chunks/{register-operations-IADFVH53.js.map → register-operations-SG7HBSUP.js.map} +1 -1
  409. package/dist/cli-bundle/chunks/{register-setup-AJWUSSQX.js → register-setup-I45OGJUV.js} +25 -19
  410. package/dist/cli-bundle/chunks/{register-setup-AJWUSSQX.js.map → register-setup-I45OGJUV.js.map} +1 -1
  411. package/dist/cli-bundle/chunks/{register-setup-3QJY43CY.js → register-setup-K6U3NVY5.js} +23 -17
  412. package/dist/cli-bundle/chunks/{register-setup-3QJY43CY.js.map → register-setup-K6U3NVY5.js.map} +1 -1
  413. package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +19 -0
  414. package/dist/cli-bundle/chunks/{restore-44IHMMZZ.js → restore-YJ2ET6AT.js} +11 -9
  415. package/dist/cli-bundle/chunks/{scheduling-shortcuts-TSBK4AY5.js → scheduling-shortcuts-SSC4MYWQ.js} +14 -12
  416. package/dist/cli-bundle/chunks/{scheduling-shortcuts-TSBK4AY5.js.map → scheduling-shortcuts-SSC4MYWQ.js.map} +1 -1
  417. package/dist/cli-bundle/chunks/{scheduling-shortcuts-OLHNLAZY.js → scheduling-shortcuts-ULRG7MNP.js} +16 -14
  418. package/dist/cli-bundle/chunks/{scheduling-shortcuts-OLHNLAZY.js.map → scheduling-shortcuts-ULRG7MNP.js.map} +1 -1
  419. package/dist/cli-bundle/chunks/{schema-VBCELP5G.js → schema-2PUXCZ25.js} +10 -7
  420. package/dist/cli-bundle/chunks/{schema-IB2NZZWD.js → schema-Y6DXXK2F.js} +10 -7
  421. package/dist/cli-bundle/chunks/{search-7UBETML4.js → search-3S72CTD6.js} +13 -10
  422. package/dist/cli-bundle/chunks/{search-R227JOL6.js → search-WNUNBQXO.js} +13 -10
  423. package/dist/cli-bundle/chunks/{stats-FAG7COEH.js → stats-IJYTRQGV.js} +13 -10
  424. package/dist/cli-bundle/chunks/{stats-FAG7COEH.js.map → stats-IJYTRQGV.js.map} +1 -1
  425. package/dist/cli-bundle/chunks/{stats-MCK7PLYS.js → stats-L2D5Y2O5.js} +15 -12
  426. package/dist/cli-bundle/chunks/{stats-MCK7PLYS.js.map → stats-L2D5Y2O5.js.map} +1 -1
  427. package/dist/cli-bundle/chunks/{telemetry-DRPDZMAO.js → telemetry-L2CVOKVN.js} +11 -8
  428. package/dist/cli-bundle/chunks/{telemetry-DRPDZMAO.js.map → telemetry-L2CVOKVN.js.map} +1 -1
  429. package/dist/cli-bundle/chunks/{telemetry-GVVUQSJQ.js → telemetry-QBYWQA76.js} +13 -10
  430. package/dist/cli-bundle/chunks/{telemetry-GVVUQSJQ.js.map → telemetry-QBYWQA76.js.map} +1 -1
  431. package/dist/cli-bundle/chunks/{test-QY44WAMR.js → test-DQ2QFJ7W.js} +21 -15
  432. package/dist/cli-bundle/chunks/test-W7QBLVJS.js +41 -0
  433. package/dist/cli-bundle/chunks/{test-all-USPJHXFR.js → test-all-636NTRTT.js} +26 -19
  434. package/dist/cli-bundle/chunks/{test-all-USPJHXFR.js.map → test-all-636NTRTT.js.map} +1 -1
  435. package/dist/cli-bundle/chunks/{test-all-QD6QAEG7.js → test-all-DWYK3RG6.js} +24 -17
  436. package/dist/cli-bundle/chunks/{test-all-QD6QAEG7.js.map → test-all-DWYK3RG6.js.map} +1 -1
  437. package/dist/cli-bundle/chunks/test-runs-245OINZR.js +28 -0
  438. package/dist/cli-bundle/chunks/test-runs-245OINZR.js.map +1 -0
  439. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +24 -0
  440. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js.map +7 -0
  441. package/dist/cli-bundle/chunks/update-SFLZPJXX.js +30 -0
  442. package/dist/cli-bundle/chunks/update-SFLZPJXX.js.map +1 -0
  443. package/dist/cli-bundle/chunks/update-SJZ6S77U.js +26 -0
  444. package/dist/cli-bundle/chunks/update-SJZ6S77U.js.map +7 -0
  445. package/dist/cli-bundle/chunks/{update-many-RATAARHU.js → update-many-DC7X3EWM.js} +32 -29
  446. package/dist/cli-bundle/chunks/{update-many-RATAARHU.js.map → update-many-DC7X3EWM.js.map} +1 -1
  447. package/dist/cli-bundle/chunks/{update-many-BEMTDA2X.js → update-many-SLLAMHT7.js} +34 -31
  448. package/dist/cli-bundle/chunks/{update-many-BEMTDA2X.js.map → update-many-SLLAMHT7.js.map} +1 -1
  449. package/dist/cli-bundle/chunks/{upgrade-VU46BLJZ.js → upgrade-HFFXLZJA.js} +19 -12
  450. package/dist/cli-bundle/chunks/{upgrade-VU46BLJZ.js.map → upgrade-HFFXLZJA.js.map} +1 -1
  451. package/dist/cli-bundle/chunks/{upgrade-NWMR3VQL.js → upgrade-UYQKM7RF.js} +21 -14
  452. package/dist/cli-bundle/chunks/{upgrade-NWMR3VQL.js.map → upgrade-UYQKM7RF.js.map} +1 -1
  453. package/dist/cli-bundle/chunks/{validate-NRY6MFXN.js → validate-PA4FDTOV.js} +35 -28
  454. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js.map +7 -0
  455. package/dist/cli-bundle/chunks/{validate-GAJ6FUSI.js → validate-Z7L75YEJ.js} +35 -28
  456. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js.map +1 -0
  457. package/dist/cli-bundle/main.js +173 -57
  458. package/dist/cli-bundle/main.js.map +2 -2
  459. package/dist/cli-bundle/sdk-runtime.js +247 -0
  460. package/dist/cli-bundle/sdk-runtime.js.map +7 -0
  461. package/dist/cli-bundle/sdk-testing.js +101 -0
  462. package/dist/cli-bundle/sdk-testing.js.map +7 -0
  463. package/dist/cli-bundle/sdk.js +787 -0
  464. package/dist/cli-bundle/sdk.js.map +7 -0
  465. package/dist/core/config/nested-settings.d.ts +4 -3
  466. package/dist/core/config/nested-settings.js +17 -6
  467. package/dist/core/config/nested-settings.js.map +1 -1
  468. package/dist/core/extensions/activation-summary.d.ts +6 -0
  469. package/dist/core/extensions/activation-summary.js +10 -4
  470. package/dist/core/extensions/activation-summary.js.map +1 -1
  471. package/dist/core/extensions/capability-usage.d.ts +6 -0
  472. package/dist/core/extensions/capability-usage.js +10 -4
  473. package/dist/core/extensions/capability-usage.js.map +1 -1
  474. package/dist/core/extensions/extension-types.d.ts +6 -2
  475. package/dist/core/extensions/extension-types.js +2 -2
  476. package/dist/core/extensions/extension-types.js.map +1 -1
  477. package/dist/core/extensions/loader.d.ts +3 -0
  478. package/dist/core/extensions/loader.js +11 -19
  479. package/dist/core/extensions/loader.js.map +1 -1
  480. package/dist/core/history/history-rewrite.d.ts +10 -0
  481. package/dist/core/history/history-rewrite.js +28 -4
  482. package/dist/core/history/history-rewrite.js.map +1 -1
  483. package/dist/core/item/parent-reference-policy.d.ts +9 -1
  484. package/dist/core/item/parent-reference-policy.js +28 -4
  485. package/dist/core/item/parent-reference-policy.js.map +1 -1
  486. package/dist/core/item/type-registry.d.ts +1 -0
  487. package/dist/core/item/type-registry.js +153 -177
  488. package/dist/core/item/type-registry.js.map +1 -1
  489. package/dist/core/lock/lock.d.ts +28 -1
  490. package/dist/core/lock/lock.js +254 -20
  491. package/dist/core/lock/lock.js.map +1 -1
  492. package/dist/core/search/background-refresh.js +7 -19
  493. package/dist/core/search/background-refresh.js.map +1 -1
  494. package/dist/core/search/http-client.d.ts +0 -1
  495. package/dist/core/search/http-client.js +3 -3
  496. package/dist/core/search/http-client.js.map +1 -1
  497. package/dist/core/shared/constants.js +3 -2
  498. package/dist/core/shared/constants.js.map +1 -1
  499. package/dist/core/shared/errors.d.ts +1 -0
  500. package/dist/core/shared/errors.js +2 -2
  501. package/dist/core/shared/errors.js.map +1 -1
  502. package/dist/core/shared/primitives.d.ts +12 -0
  503. package/dist/core/shared/primitives.js +29 -2
  504. package/dist/core/shared/primitives.js.map +1 -1
  505. package/dist/core/store/item-store.js +3 -3
  506. package/dist/core/store/item-store.js.map +1 -1
  507. package/dist/core/store/settings-validator.d.ts +1 -0
  508. package/dist/core/store/settings-validator.js +6 -3
  509. package/dist/core/store/settings-validator.js.map +1 -1
  510. package/dist/core/store/settings.js +3 -3
  511. package/dist/core/store/settings.js.map +1 -1
  512. package/dist/core/validate/fix-planning.d.ts +0 -2
  513. package/dist/core/validate/fix-planning.js +3 -3
  514. package/dist/core/validate/fix-planning.js.map +1 -1
  515. package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -2
  516. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  517. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  518. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  519. package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
  520. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  521. package/dist/sdk/cli-contracts/tool-schema.js +55 -94
  522. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  523. package/dist/sdk/errors.d.ts +21 -2
  524. package/dist/sdk/errors.js +8 -2
  525. package/dist/sdk/errors.js.map +1 -1
  526. package/dist/sdk/package-import-adapters.d.ts +90 -2
  527. package/dist/sdk/package-import-adapters.js +275 -3
  528. package/dist/sdk/package-import-adapters.js.map +1 -1
  529. package/dist/sdk/runtime.d.ts +1 -1
  530. package/dist/sdk/runtime.js +3 -3
  531. package/dist/sdk/runtime.js.map +1 -1
  532. package/dist/sdk/testing.js +41 -19
  533. package/dist/sdk/testing.js.map +1 -1
  534. package/dist/types.d.ts +6 -0
  535. package/dist/types.js +2 -2
  536. package/dist/types.js.map +1 -1
  537. package/docs/ARCHITECTURE.md +27 -0
  538. package/docs/CONFIGURATION.md +3 -0
  539. package/docs/README.md +1 -0
  540. package/docs/SDK_PRIMITIVE_INVENTORY.md +55 -0
  541. package/docs/TESTING.md +5 -1
  542. package/docs/examples/ci/github-actions-pm-extension-gate.yml +5 -5
  543. package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +1 -1
  544. package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +1 -1
  545. package/package.json +14 -26
  546. package/packages/pm-beads/extensions/beads/package.json +3 -0
  547. package/packages/pm-beads/extensions/beads/runtime-loader.ts +50 -41
  548. package/packages/pm-beads/extensions/beads/runtime.ts +106 -223
  549. package/packages/pm-calendar/extensions/calendar/package.json +3 -0
  550. package/packages/pm-calendar/extensions/calendar/runtime.ts +21 -18
  551. package/packages/pm-command-kit/extensions/command-kit/package.json +3 -0
  552. package/packages/pm-governance-audit/extensions/governance-audit/package.json +3 -0
  553. package/packages/pm-guide-shell/extensions/guide-shell/package.json +3 -0
  554. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +9 -11
  555. package/packages/pm-kanban/extensions/kanban/package.json +3 -0
  556. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/package.json +3 -0
  557. package/packages/pm-search-advanced/extensions/search-advanced/package.json +3 -0
  558. package/packages/pm-templates/extensions/templates/package.json +3 -0
  559. package/packages/pm-todos/extensions/todos/package.json +3 -0
  560. package/packages/pm-todos/extensions/todos/runtime-loader.ts +62 -72
  561. package/packages/pm-todos/extensions/todos/runtime.ts +61 -257
  562. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +73 -31
  563. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +80 -34
  564. package/scripts/bundle-cli.mjs +12 -2
  565. package/scripts/install.ps1 +7 -7
  566. package/dist/cli-bundle/chunks/activity-BIML7K2D.js +0 -16
  567. package/dist/cli-bundle/chunks/chunk-32IUNTG4.js.map +0 -1
  568. package/dist/cli-bundle/chunks/chunk-4EXFFP7T.js.map +0 -7
  569. package/dist/cli-bundle/chunks/chunk-4WB6S4YX.js.map +0 -1
  570. package/dist/cli-bundle/chunks/chunk-572FKBRL.js.map +0 -1
  571. package/dist/cli-bundle/chunks/chunk-67LARBDL.js.map +0 -1
  572. package/dist/cli-bundle/chunks/chunk-6CDCWKSX.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-6KRFL33E.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-AJHYQCBJ.js.map +0 -7
  575. package/dist/cli-bundle/chunks/chunk-B4O5S7I3.js.map +0 -7
  576. package/dist/cli-bundle/chunks/chunk-CXR3CMBQ.js.map +0 -1
  577. package/dist/cli-bundle/chunks/chunk-ECU6MMTQ.js.map +0 -1
  578. package/dist/cli-bundle/chunks/chunk-EJ2OCBHF.js.map +0 -1
  579. package/dist/cli-bundle/chunks/chunk-ERG65A2L.js.map +0 -1
  580. package/dist/cli-bundle/chunks/chunk-FUFFPIYA.js.map +0 -7
  581. package/dist/cli-bundle/chunks/chunk-HB4FAT3O.js.map +0 -7
  582. package/dist/cli-bundle/chunks/chunk-HQAF23Q2.js.map +0 -7
  583. package/dist/cli-bundle/chunks/chunk-JPATY4SE.js.map +0 -7
  584. package/dist/cli-bundle/chunks/chunk-KHVGM5CS.js.map +0 -7
  585. package/dist/cli-bundle/chunks/chunk-KS6ATO47.js.map +0 -7
  586. package/dist/cli-bundle/chunks/chunk-L4SLHV6G.js.map +0 -1
  587. package/dist/cli-bundle/chunks/chunk-MHRS5FUX.js.map +0 -1
  588. package/dist/cli-bundle/chunks/chunk-NZ7QIUP5.js.map +0 -7
  589. package/dist/cli-bundle/chunks/chunk-OGLGI22K.js.map +0 -1
  590. package/dist/cli-bundle/chunks/chunk-RAHINBVP.js.map +0 -7
  591. package/dist/cli-bundle/chunks/chunk-RJH5VQHW.js.map +0 -1
  592. package/dist/cli-bundle/chunks/chunk-SYE6WMV6.js.map +0 -1
  593. package/dist/cli-bundle/chunks/chunk-TQ6AX5SQ.js.map +0 -7
  594. package/dist/cli-bundle/chunks/chunk-U3S2B7TA.js.map +0 -1
  595. package/dist/cli-bundle/chunks/chunk-WRYERRZX.js.map +0 -7
  596. package/dist/cli-bundle/chunks/chunk-WYOIIFSE.js.map +0 -7
  597. package/dist/cli-bundle/chunks/chunk-XRYSCRZR.js.map +0 -7
  598. package/dist/cli-bundle/chunks/chunk-YF746GTH.js.map +0 -1
  599. package/dist/cli-bundle/chunks/chunk-YSDFIY7N.js.map +0 -1
  600. package/dist/cli-bundle/chunks/chunk-Z4DGFQDH.js.map +0 -1
  601. package/dist/cli-bundle/chunks/claim-2BGBGSVI.js.map +0 -7
  602. package/dist/cli-bundle/chunks/claim-5GU7OE67.js.map +0 -1
  603. package/dist/cli-bundle/chunks/close-6YODBUIV.js +0 -14
  604. package/dist/cli-bundle/chunks/create-Z7YCH3BE.js +0 -28
  605. package/dist/cli-bundle/chunks/files-6SGKHS6O.js.map +0 -1
  606. package/dist/cli-bundle/chunks/files-FUYPSOFJ.js.map +0 -7
  607. package/dist/cli-bundle/chunks/history-CGNQJXFE.js +0 -18
  608. package/dist/cli-bundle/chunks/history-compact-LOED43R3.js.map +0 -7
  609. package/dist/cli-bundle/chunks/history-compact-V5DNAQHH.js.map +0 -1
  610. package/dist/cli-bundle/chunks/history-redact-N3JK7VBW.js +0 -19
  611. package/dist/cli-bundle/chunks/history-repair-4WVBVHFR.js.map +0 -1
  612. package/dist/cli-bundle/chunks/history-repair-PGYQJMGD.js.map +0 -7
  613. package/dist/cli-bundle/chunks/init-4GESW7RM.js +0 -26
  614. package/dist/cli-bundle/chunks/init-XIDPABA4.js +0 -22
  615. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js +0 -1243
  616. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js.map +0 -7
  617. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js +0 -1205
  618. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js.map +0 -1
  619. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js.map +0 -1
  620. package/dist/cli-bundle/chunks/restore-EXHU34EU.js +0 -17
  621. package/dist/cli-bundle/chunks/test-SY76DZTO.js +0 -35
  622. package/dist/cli-bundle/chunks/update-A7EICML6.js +0 -24
  623. package/dist/cli-bundle/chunks/update-IKJZWLQC.js +0 -28
  624. package/dist/cli-bundle/chunks/validate-GAJ6FUSI.js.map +0 -1
  625. package/dist/cli-bundle/chunks/validate-NRY6MFXN.js.map +0 -7
  626. /package/dist/cli-bundle/chunks/{activity-BIML7K2D.js.map → activity-4XQIDNM5.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{activity-5YWLSPGE.js.map → activity-YKAKZTZ4.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{chunk-QCDTQCMW.js.map → chunk-5JE6SMYS.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{chunk-5JIWFWOZ.js.map → chunk-N6DNM2FA.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{chunk-GVJE5T7Q.js.map → chunk-NER3KUUS.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{chunk-MEZZZBYX.js.map → chunk-PDXT6Q55.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{chunk-YVKZ3ANP.js.map → chunk-RX3HQSYG.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{chunk-LOWVNZBZ.js.map → chunk-S4APD35C.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{chunk-6NYJGMTY.js.map → chunk-T35XLYZF.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{chunk-BE2SR6QL.js.map → chunk-TT42JUMF.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{chunk-SU3TB4NS.js.map → chunk-YOF5VPKM.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{chunk-5E7N4T2Z.js.map → chunk-ZMD35NYG.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{close-AFVKPR57.js.map → close-3YRR3XY6.js.map} +0 -0
  639. /package/dist/cli-bundle/chunks/{close-6YODBUIV.js.map → close-OB2Y4QP5.js.map} +0 -0
  640. /package/dist/cli-bundle/chunks/{context-PKCEHQY3.js.map → context-4OQGIPSO.js.map} +0 -0
  641. /package/dist/cli-bundle/chunks/{context-OYXRGY7S.js.map → context-WLA6IAWE.js.map} +0 -0
  642. /package/dist/cli-bundle/chunks/{create-Z7YCH3BE.js.map → contracts-HXJLKCRI.js.map} +0 -0
  643. /package/dist/cli-bundle/chunks/{create-PM45M6PE.js.map → contracts-OJEXMKVW.js.map} +0 -0
  644. /package/dist/cli-bundle/chunks/{extension-BNINIMT7.js.map → create-WKOZKPQR.js.map} +0 -0
  645. /package/dist/cli-bundle/chunks/{extension-QWE4YYK5.js.map → create-XWWQFQ6S.js.map} +0 -0
  646. /package/dist/cli-bundle/chunks/{history-CGNQJXFE.js.map → extension-NBAH62ML.js.map} +0 -0
  647. /package/dist/cli-bundle/chunks/{history-SGRRS72R.js.map → extension-ZF6ZZPOU.js.map} +0 -0
  648. /package/dist/cli-bundle/chunks/{history-redact-N3JK7VBW.js.map → history-RYKLC72X.js.map} +0 -0
  649. /package/dist/cli-bundle/chunks/{history-redact-IRL7WJ3E.js.map → history-SGPYRAFT.js.map} +0 -0
  650. /package/dist/cli-bundle/chunks/{init-XIDPABA4.js.map → history-redact-4H3FCKF3.js.map} +0 -0
  651. /package/dist/cli-bundle/chunks/{init-4GESW7RM.js.map → history-redact-54ICFKXM.js.map} +0 -0
  652. /package/dist/cli-bundle/chunks/{list-D7BF5CL2.js.map → init-RPIPQUNV.js.map} +0 -0
  653. /package/dist/cli-bundle/chunks/{list-472TIOVK.js.map → init-SKQAESQS.js.map} +0 -0
  654. /package/dist/cli-bundle/chunks/{restore-EXHU34EU.js.map → list-64LHZ3HM.js.map} +0 -0
  655. /package/dist/cli-bundle/chunks/{restore-44IHMMZZ.js.map → list-7LXBTEKI.js.map} +0 -0
  656. /package/dist/cli-bundle/chunks/{schema-VBCELP5G.js.map → restore-PXOFL6AM.js.map} +0 -0
  657. /package/dist/cli-bundle/chunks/{schema-IB2NZZWD.js.map → restore-YJ2ET6AT.js.map} +0 -0
  658. /package/dist/cli-bundle/chunks/{search-R227JOL6.js.map → schema-2PUXCZ25.js.map} +0 -0
  659. /package/dist/cli-bundle/chunks/{search-7UBETML4.js.map → schema-Y6DXXK2F.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{test-QY44WAMR.js.map → search-3S72CTD6.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{test-SY76DZTO.js.map → search-WNUNBQXO.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{update-IKJZWLQC.js.map → test-DQ2QFJ7W.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{update-A7EICML6.js.map → test-W7QBLVJS.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WW4E2DC3.js";
4
4
  import {
5
5
  readHistoryEntries
6
- } from "./chunk-Z5F6XZXE.js";
6
+ } from "./chunk-3Y4OESPP.js";
7
7
  import {
8
8
  EMPTY_REPLAY_DOCUMENT,
9
9
  historyEntriesToRaw,
@@ -11,47 +11,50 @@ import {
11
11
  replayToItemDocument,
12
12
  tryApplyReplayPatch,
13
13
  verifyHistoryChain
14
- } from "./chunk-T4XBKJ3F.js";
14
+ } from "./chunk-D3UCE7RW.js";
15
15
  import {
16
16
  acquireLock,
17
17
  createHistoryEntry,
18
18
  locateItem,
19
- normalizeItemId,
20
- normalizeRawItemId,
21
19
  readLocatedItem
22
- } from "./chunk-6KRFL33E.js";
20
+ } from "./chunk-3U3VEWK6.js";
23
21
  import {
24
22
  canonicalDocument,
23
+ normalizeItemId,
24
+ normalizeRawItemId,
25
25
  serializeItemDocument
26
- } from "./chunk-3W2HJKJX.js";
26
+ } from "./chunk-EZFKWSC7.js";
27
27
  import {
28
28
  nowIso
29
- } from "./chunk-AJHYQCBJ.js";
29
+ } from "./chunk-DRBV5UC2.js";
30
30
  import {
31
- EXIT_CODE,
32
31
  PmCliError,
33
32
  getActiveExtensionRegistrations,
33
+ readSettings,
34
+ resolveGovernanceKnobs,
35
+ runActiveOnWriteHooks
36
+ } from "./chunk-P5YORJRH.js";
37
+ import {
38
+ EXIT_CODE,
34
39
  getHistoryPath,
35
40
  getItemPath,
36
41
  getSettingsPath,
37
42
  pathExists,
38
43
  readFileIfExists,
39
- readSettings,
40
- resolveGovernanceKnobs,
41
44
  resolveItemTypeRegistry,
42
45
  resolvePmRoot,
43
- runActiveOnWriteHooks,
44
46
  writeFileAtomic
45
- } from "./chunk-KHVGM5CS.js";
47
+ } from "./chunk-5VVUKE3U.js";
46
48
 
47
49
  // dist/cli/commands/history-redact.js
48
- import fs from "node:fs/promises";
50
+ import fs2 from "node:fs/promises";
49
51
 
50
52
  // dist/core/history/history-rewrite.js
53
+ import fs from "node:fs/promises";
51
54
  !(function() {
52
55
  try {
53
56
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
54
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "665cdb28-cf61-56a3-a037-708d2445359d");
57
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b9f14848-6edc-507a-a543-7bf01d91db50");
55
58
  } catch (e2) {
56
59
  }
57
60
  })();
@@ -82,6 +85,23 @@ async function verifyHistoryRewriteNoDrift(params) {
82
85
  }
83
86
  return { historyRawUnderLock, locatedUnderLock, loadedItemUnderLock };
84
87
  }
88
+ async function writeHistoryRawWithRollback(params) {
89
+ const writeHistoryRaw = params.writeHistoryRaw ?? writeFileAtomic;
90
+ try {
91
+ await writeHistoryRaw(params.historyPath, params.nextHistoryRaw);
92
+ } catch (error) {
93
+ try {
94
+ if (params.historyRawUnderLock === null) {
95
+ await fs.rm(params.historyPath, { force: true });
96
+ } else {
97
+ await writeHistoryRaw(params.historyPath, params.historyRawUnderLock);
98
+ }
99
+ } catch (rollbackError) {
100
+ throw new AggregateError([error, rollbackError], `History rewrite failed and rollback also failed: ${String(error)}`);
101
+ }
102
+ throw error;
103
+ }
104
+ }
85
105
  async function executeHistoryRewrite(params) {
86
106
  const warnings = [...checkHistoryRewriteOwnership({
87
107
  itemDocument: params.itemDocument,
@@ -90,7 +110,7 @@ async function executeHistoryRewrite(params) {
90
110
  force: params.force,
91
111
  settings: params.settings
92
112
  })];
93
- const releaseLock = await acquireLock(params.pmRoot, params.subject.id, params.settings.locks.ttl_seconds, params.author, Boolean(params.force), params.settings.governance.force_required_for_stale_lock);
113
+ const releaseLock = await acquireLock(params.pmRoot, params.subject.id, params.settings.locks.ttl_seconds, params.author, Boolean(params.force), params.settings.governance.force_required_for_stale_lock, params.settings.locks.wait_ms);
94
114
  try {
95
115
  const verified = await verifyHistoryRewriteNoDrift({
96
116
  pmRoot: params.pmRoot,
@@ -439,7 +459,7 @@ async function applyHistoryRedactRewrite(params) {
439
459
  await writeFileAtomic(params.nextItem.path, params.nextItem.raw);
440
460
  }
441
461
  if (params.currentItem.path && (!params.nextItem.path || params.nextItem.path !== params.currentItem.path)) {
442
- await fs.rm(params.currentItem.path, { force: true });
462
+ await fs2.rm(params.currentItem.path, { force: true });
443
463
  }
444
464
  await writeFileAtomic(params.subject.historyPath, historyEntriesToRaw(params.rewrittenEntries));
445
465
  } catch (error) {
@@ -455,14 +475,14 @@ async function applyHistoryRedactRewrite(params) {
455
475
  }
456
476
  async function rollbackHistoryRedactRewrite(historyPath, historyRawUnderLock, affectedItemPaths, itemSnapshots) {
457
477
  if (historyRawUnderLock === null) {
458
- await fs.rm(historyPath, { force: true });
478
+ await fs2.rm(historyPath, { force: true });
459
479
  } else {
460
480
  await writeFileAtomic(historyPath, historyRawUnderLock);
461
481
  }
462
482
  for (const itemPath of affectedItemPaths) {
463
483
  const snapshot = itemSnapshots.get(itemPath);
464
484
  if (snapshot === void 0) {
465
- await fs.rm(itemPath, { force: true });
485
+ await fs2.rm(itemPath, { force: true });
466
486
  } else {
467
487
  await writeFileAtomic(itemPath, snapshot);
468
488
  }
@@ -626,9 +646,10 @@ var _testOnly = {
626
646
  };
627
647
 
628
648
  export {
649
+ writeHistoryRawWithRollback,
629
650
  executeHistoryRewrite,
630
651
  resolveHistorySubject,
631
652
  runHistoryRedact,
632
653
  _testOnly
633
654
  };
634
- //# sourceMappingURL=chunk-F6WNBITZ.js.map
655
+ //# sourceMappingURL=chunk-FDBARR33.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/history-redact.ts", "../../../../../../../../core/history/history-rewrite.ts"],
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 { readFileIfExists } 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>>;\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 * 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 );\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,OAAO,QAAQ;;;;;;;;;;ACmCT,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,CAAA;AACT;AA8BA,eAAsB,4BACpB,QAAuC;AAEvC,QAAM,sBAAsB,MAAM,iBAAiB,OAAO,QAAQ,WAAW;AAC7E,MAAI,wBAAwB,OAAO,sBAAsB;AACvD,UAAM,IAAI,WACR,eAAe,OAAO,QAAQ,EAAE,0CAA0C,OAAO,SAAS,KAC1F,UAAU,QAAQ;EAEtB;AACA,QAAM,mBAAmB,MAAM,WAC7B,OAA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EzD,MAAI,CAAC,cAAc,IAAI;AACrB,UAAM,IAAI,WACR,uDAAuD,cAAc,OAAO,KAAK,IAAI,CAAC,MACtF,UAAU,eAAe;EAE7B;AAGA,MAAI,CAAC,UAAU,SAAS;AACtB,aAAS,KACP,GAAI,MAAM,0BAA0B;MAClC;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,OAAO,QAAQ;MACf;KACD,CAAE;EAEP;AAEA,SAAO;IACL,IAAI,QAAQ;IACZ,SAAS;IACT;IACA,UAAU;MACR,UAAU,MAAM,OAAO,CAAC,SAA8B,KAAK,SAAS,SAAS,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK;MACvG,OAAO,MAAM,OAAO,CAAC,SAA4B,KAAK,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK,EAAE;MACrH;;IAEF,SAAS;MACP,MAAM,QAAQ;MACd,iBAAiB,eAAe;MAChC,iBAAiB,UAAU;MAC3B,cAAc,UAAU;MACxB,wBAAwB,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
- "names": ["global"]
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,QAA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ACR,uDAAuD,cAAc,OAAO,KAAK,IAAI,CAAC,MACtF,UAAU,eAAe;EAE7B;AAGA,MAAI,CAAC,UAAU,SAAS;AACtB,aAAS,KACP,GAAI,MAAM,0BAA0B;MAClC;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,OAAO,QAAQ;MACf;KACD,CAAE;EAEP;AAEA,SAAO;IACL,IAAI,QAAQ;IACZ,SAAS;IACT;IACA,UAAU;MACR,UAAU,MAAM,OAAO,CAAC,SAA8B,KAAK,SAAS,SAAS,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK;MACvG,OAAO,MAAM,OAAO,CAAC,SAA4B,KAAK,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK,EAAE;MACrH;;IAEF,SAAS;MACP,MAAM,QAAQ;MACd,iBAAiB,eAAe;MAChC,iBAAiB,UAAU;MAC3B,cAAc,UAAU;MACxB,wBAAwB,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
+ "names": ["fs", "fs", "global"]
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  collectBlockedByIds
3
- } from "./chunk-SU3TB4NS.js";
3
+ } from "./chunk-YOF5VPKM.js";
4
4
  import {
5
5
  buildItemNotFoundError,
6
6
  listAllFrontMatterLight,
@@ -8,26 +8,28 @@ import {
8
8
  mutateItem,
9
9
  readLocatedItem,
10
10
  toItemRecord
11
- } from "./chunk-6KRFL33E.js";
11
+ } from "./chunk-3U3VEWK6.js";
12
12
  import {
13
13
  isTerminalStatus
14
- } from "./chunk-3W2HJKJX.js";
14
+ } from "./chunk-EZFKWSC7.js";
15
15
  import {
16
- EXIT_CODE,
17
16
  PmCliError,
17
+ readSettings
18
+ } from "./chunk-P5YORJRH.js";
19
+ import {
20
+ EXIT_CODE,
18
21
  getSettingsPath,
19
22
  pathExists,
20
- readSettings,
21
23
  resolveItemTypeRegistry,
22
24
  resolvePmRoot,
23
25
  resolveRuntimeStatusRegistry
24
- } from "./chunk-KHVGM5CS.js";
26
+ } from "./chunk-5VVUKE3U.js";
25
27
 
26
28
  // dist/cli/commands/close.js
27
29
  !(function() {
28
30
  try {
29
31
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
30
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b66319bc-0c15-5e2a-9400-f38fe46b9b58");
32
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "19dbc992-675b-554c-83bd-4aa14b766810");
31
33
  } catch (e2) {
32
34
  }
33
35
  })();
@@ -44,11 +46,12 @@ function normalizeCloseReason(reasonText, required) {
44
46
  if (required) {
45
47
  throw new PmCliError("Close reason text is required because governance.require_close_reason is enabled", EXIT_CODE.USAGE, {
46
48
  code: "close_reason_required",
47
- required: "Provide a one-line closing summary as the positional text or via --reason.",
49
+ required: "Provide a one-line closing summary as the positional text, --reason, or --message.",
48
50
  why: "governance.require_close_reason is enabled, so every close must record why the item is done.",
49
51
  examples: [
50
52
  'pm close <id> "Done: <what changed and why>"',
51
53
  'pm close <id> --reason "<closing summary>"',
54
+ 'pm close <id> -m "<closing summary>"',
52
55
  "pm close <id> --duplicate-of <canonical-id>"
53
56
  ],
54
57
  nextSteps: [
@@ -60,6 +63,23 @@ function normalizeCloseReason(reasonText, required) {
60
63
  }
61
64
  return void 0;
62
65
  }
66
+ function resolveEffectiveCloseReasonText(input) {
67
+ if ((input.closeReasonText ?? "").trim().length > 0) {
68
+ return input.closeReasonText;
69
+ }
70
+ if (input.duplicateOf !== void 0) {
71
+ return `Duplicate of ${input.duplicateOf}`;
72
+ }
73
+ const trimmedResolution = typeof input.resolution === "string" ? input.resolution.trim() : "";
74
+ if (trimmedResolution.length > 0) {
75
+ return trimmedResolution;
76
+ }
77
+ const trimmedMessage = typeof input.message === "string" ? input.message.trim() : "";
78
+ if (input.requireCloseReason && trimmedMessage.length > 0) {
79
+ return trimmedMessage;
80
+ }
81
+ return input.closeReasonText;
82
+ }
63
83
  var CLOSE_VALIDATION_FIELDS = [
64
84
  { key: "resolution", label: "resolution" },
65
85
  { key: "expected_result", label: "expected_result" },
@@ -380,9 +400,13 @@ async function runClose(id, closeReasonText, options, global2) {
380
400
  throw await buildItemNotFoundError(pmRoot, id, settings.id_prefix, typeToFolder);
381
401
  }
382
402
  const duplicateOf = await assertDuplicateTargetExists(pmRoot, settings, options.duplicateOf, id);
383
- const hasExplicitReason = (closeReasonText ?? "").trim().length > 0;
384
- const trimmedResolution = typeof options.resolution === "string" ? options.resolution.trim() : "";
385
- const effectiveCloseReasonText = hasExplicitReason ? closeReasonText : duplicateOf !== void 0 ? `Duplicate of ${duplicateOf}` : trimmedResolution.length > 0 ? trimmedResolution : closeReasonText;
403
+ const effectiveCloseReasonText = resolveEffectiveCloseReasonText({
404
+ closeReasonText,
405
+ duplicateOf,
406
+ resolution: options.resolution,
407
+ message: options.message,
408
+ requireCloseReason: settings.governance.require_close_reason
409
+ });
386
410
  const closeReason = normalizeCloseReason(effectiveCloseReasonText, settings.governance.require_close_reason);
387
411
  const validateCloseMode = parseValidateCloseMode(options.validateClose) ?? settings.governance.close_validation_default;
388
412
  const activeChildIds = await findActiveChildIds(pmRoot, settings, id, statusRegistry);
@@ -420,4 +444,4 @@ export {
420
444
  _testOnlyCloseCommand,
421
445
  runClose
422
446
  };
423
- //# sourceMappingURL=chunk-WRYERRZX.js.map
447
+ //# sourceMappingURL=chunk-FGQKEDE4.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../cli/commands/close.ts"],
4
+ "sourcesContent": ["/**\n * @module cli/commands/close\n *\n * Implements the pm close command surface and its agent-facing runtime behavior.\n */\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { collectBlockedByIds } from \"../../core/item/actionability.js\";\nimport { toItemRecord } from \"../../core/item/item-record.js\";\nimport { isTerminalStatus } from \"../../core/item/status.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { resolveRuntimeStatusRegistry, type RuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport {\n buildItemNotFoundError,\n listAllFrontMatterLight,\n locateItem,\n mutateItem,\n readLocatedItem,\n} from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type { ItemFrontMatter } from \"../../types/index.js\";\n\n/**\n * Documents the close command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseCommandOptions {\n author?: string;\n message?: string;\n validateClose?: string;\n force?: boolean;\n // pm-fl0c #11 (2026-05-28): allow setting the three closure validation\n // fields inline on `pm close` so agents do not have to issue a prior\n // `pm update` just to satisfy --validate-close warn|strict. These map 1:1\n // to ItemFrontMatter.{resolution,expected_result,actual_result}.\n resolution?: string;\n expectedResult?: string;\n actualResult?: string;\n duplicateOf?: string;\n}\n\n/**\n * Documents the close result payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseResult {\n item: Record<string, unknown>;\n changed_fields: string[];\n warnings: string[];\n}\n\ninterface AutoUnblockCandidate {\n id: string;\n blocker_ids: string[];\n}\n\ntype CloseInlineFieldKey = \"resolution\" | \"expected_result\" | \"actual_result\";\n\ninterface CloseMutationContext {\n statusRegistry: RuntimeStatusRegistry;\n force: boolean | undefined;\n options: CloseCommandOptions;\n duplicateOf: string | undefined;\n validateCloseMode: ValidateCloseMode;\n activeChildIds: string[];\n closeReason: string | undefined;\n}\n\nfunction toAuthor(candidate: string | undefined, defaultAuthor: string): string {\n const resolved = candidate ?? process.env.PM_AUTHOR ?? defaultAuthor;\n const trimmed = resolved.trim();\n return trimmed || \"unknown\";\n}\n\nfunction normalizeCloseReason(reasonText: string | undefined, required: boolean): string | undefined {\n const reason = (reasonText ?? \"\").trim();\n if (reason.length > 0) {\n return reason;\n }\n if (required) {\n throw new PmCliError(\n \"Close reason text is required because governance.require_close_reason is enabled\",\n EXIT_CODE.USAGE,\n {\n code: \"close_reason_required\",\n required: \"Provide a one-line closing summary as the positional text, --reason, or --message.\",\n why: \"governance.require_close_reason is enabled, so every close must record why the item is done.\",\n examples: [\n 'pm close <id> \"Done: <what changed and why>\"',\n 'pm close <id> --reason \"<closing summary>\"',\n 'pm close <id> -m \"<closing summary>\"',\n \"pm close <id> --duplicate-of <canonical-id>\",\n ],\n nextSteps: [\n \"Re-run the close with a closing summary.\",\n 'When closing as a duplicate, --duplicate-of <id> auto-fills the close reason as \"Duplicate of <id>\".',\n \"To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled\",\n ],\n },\n );\n }\n return undefined;\n}\n\ntype ValidateCloseMode = \"off\" | \"warn\" | \"strict\";\n\ninterface CloseReasonFallbackInput {\n closeReasonText: string | undefined;\n duplicateOf: string | undefined;\n resolution: string | undefined;\n message: string | undefined;\n requireCloseReason: boolean;\n}\n\nfunction resolveEffectiveCloseReasonText(input: CloseReasonFallbackInput): string | undefined {\n if ((input.closeReasonText ?? \"\").trim().length > 0) {\n return input.closeReasonText;\n }\n if (input.duplicateOf !== undefined) {\n return `Duplicate of ${input.duplicateOf}`;\n }\n const trimmedResolution = typeof input.resolution === \"string\" ? input.resolution.trim() : \"\";\n if (trimmedResolution.length > 0) {\n return trimmedResolution;\n }\n const trimmedMessage = typeof input.message === \"string\" ? input.message.trim() : \"\";\n if (input.requireCloseReason && trimmedMessage.length > 0) {\n return trimmedMessage;\n }\n return input.closeReasonText;\n}\n\nconst CLOSE_VALIDATION_FIELDS: Array<{ key: keyof Pick<ItemFrontMatter, \"resolution\" | \"expected_result\" | \"actual_result\">; label: string }> = [\n { key: \"resolution\", label: \"resolution\" },\n { key: \"expected_result\", label: \"expected_result\" },\n { key: \"actual_result\", label: \"actual_result\" },\n];\n\nfunction parseValidateCloseMode(raw: string | undefined): ValidateCloseMode | undefined {\n if (raw === undefined) {\n return undefined;\n }\n const normalized = raw.trim().toLowerCase();\n if (normalized.length === 0 || normalized === \"warn\") {\n return \"warn\";\n }\n if (normalized === \"off\" || normalized === \"none\" || normalized === \"disabled\") {\n return \"off\";\n }\n if (normalized === \"strict\") {\n return \"strict\";\n }\n throw new PmCliError(`Invalid --validate-close mode \"${raw}\" (expected \"off\", \"warn\", or \"strict\")`, EXIT_CODE.USAGE);\n}\n\nfunction findMissingCloseValidationFields(frontMatter: ItemFrontMatter): string[] {\n const missing: string[] = [];\n for (const field of CLOSE_VALIDATION_FIELDS) {\n const rawValue = frontMatter[field.key];\n if (typeof rawValue !== \"string\" || rawValue.trim().length === 0) {\n missing.push(field.label);\n }\n }\n return missing;\n}\n\nasync function duplicateChainReferencesClosingItem(\n loadItemById: (id: string) => Promise<ItemFrontMatter | null>,\n initialDuplicateOf: unknown,\n closingId: string,\n): Promise<boolean> {\n const visited = new Set<string>();\n let current = initialDuplicateOf;\n while (typeof current === \"string\" && current.trim().length > 0) {\n const currentId = current.trim();\n if (currentId === closingId) {\n return true;\n }\n if (visited.has(currentId)) {\n return false;\n }\n visited.add(currentId);\n current = (await loadItemById(currentId))?.duplicate_of;\n }\n return false;\n}\n\nfunction shouldApplyDuplicateFallback(value: unknown): boolean {\n return typeof value !== \"string\" || value.trim().length === 0;\n}\n\nasync function assertDuplicateTargetExists(\n pmRoot: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n duplicateOf: string | undefined,\n closingId: string,\n): Promise<string | undefined> {\n const rawTarget = duplicateOf?.trim();\n if (!rawTarget) {\n return undefined;\n }\n if (rawTarget === closingId) {\n throw new PmCliError(\"An item cannot be closed as a duplicate of itself.\", EXIT_CODE.USAGE, {\n code: \"duplicate_target_self\",\n why: \"--duplicate-of must identify the canonical item that should remain open or already represent the work.\",\n });\n }\n const typeRegistry = resolveItemTypeRegistry(settings);\n const itemCache = new Map<string, ItemFrontMatter | null>();\n const loadItemById = async (id: string): Promise<ItemFrontMatter | null> => {\n if (itemCache.has(id)) {\n return itemCache.get(id) ?? null;\n }\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);\n if (!located) {\n itemCache.set(id, null);\n return null;\n }\n const { document } = await readLocatedItem(located, { schema: settings.schema });\n itemCache.set(id, document.metadata);\n return document.metadata;\n };\n const target = await loadItemById(rawTarget);\n if (!target) {\n throw new PmCliError(`Duplicate target \"${rawTarget}\" was not found. Create or locate the canonical item first.`, EXIT_CODE.USAGE, {\n code: \"duplicate_target_missing\",\n why: \"Duplicate closure should point at a real canonical pm item so future dedupe and changelog tooling can trace the relationship.\",\n examples: [`pm close ${closingId} \"Duplicate of ${rawTarget}\" --duplicate-of ${rawTarget}`],\n nextSteps: [\"Run pm search/list to find the canonical item, then retry with --duplicate-of <id>.\"],\n });\n }\n if (await duplicateChainReferencesClosingItem(loadItemById, target.duplicate_of, closingId)) {\n throw new PmCliError(`Circular duplicate reference detected. Target \"${rawTarget}\" points back to \"${closingId}\".`, EXIT_CODE.USAGE, {\n code: \"duplicate_target_circular\",\n why: \"Circular duplicate relationships create loops for dedupe and status propagation tooling.\",\n nextSteps: [\"Choose the existing canonical item, or clear the target duplicate_of metadata before closing this item as a duplicate.\"],\n });\n }\n if (typeof target.duplicate_of === \"string\" && target.duplicate_of.trim().length > 0) {\n throw new PmCliError(`Duplicate target \"${rawTarget}\" is already marked as a duplicate of \"${target.duplicate_of.trim()}\".`, EXIT_CODE.USAGE, {\n code: \"duplicate_target_is_duplicate\",\n why: \"Duplicate closure should point directly at the canonical item, not another duplicate.\",\n examples: [`pm close ${closingId} \"Duplicate of ${target.duplicate_of.trim()}\" --duplicate-of ${target.duplicate_of.trim()}`],\n nextSteps: [\"Use the canonical item referenced by duplicate_of as the --duplicate-of target.\"],\n });\n }\n return target.id;\n}\n\nasync function findActiveChildIds(\n pmRoot: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n parentId: string,\n statusRegistry: RuntimeStatusRegistry,\n): Promise<string[]> {\n const typeRegistry = resolveItemTypeRegistry(settings);\n const items = await listAllFrontMatterLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n settings.schema,\n );\n return items\n .filter((item) => item.parent === parentId && !isTerminalStatus(item.status, statusRegistry))\n .map((item) => item.id)\n .sort((left, right) => left.localeCompare(right));\n}\n\nasync function findAutoUnblockCandidates(\n pmRoot: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n closedId: string,\n statusRegistry: RuntimeStatusRegistry,\n): Promise<AutoUnblockCandidate[]> {\n const typeRegistry = resolveItemTypeRegistry(settings);\n const items = await listAllFrontMatterLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n settings.schema,\n );\n const itemsById = new Map(items.map((item) => [item.id, item]));\n const blockedStatuses = statusRegistry.blocked_statuses;\n return items\n .filter((item) => blockedStatuses.has(item.status))\n .map((item) => ({ item, blockerIds: collectBlockedByIds(item) }))\n .filter(({ blockerIds }) => blockerIds.includes(closedId))\n .filter(({ blockerIds }) =>\n blockerIds.every((blockerId) => {\n const blocker = itemsById.get(blockerId);\n return blocker !== undefined && isTerminalStatus(blocker.status, statusRegistry);\n }),\n )\n .map(({ item, blockerIds }) => ({ id: item.id, blocker_ids: blockerIds }))\n .sort((left, right) => left.id.localeCompare(right.id));\n}\n\nasync function autoUnblockResolvedDependents(\n pmRoot: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n closedId: string,\n author: string,\n statusRegistry: RuntimeStatusRegistry,\n): Promise<string[]> {\n const candidates = await findAutoUnblockCandidates(pmRoot, settings, closedId, statusRegistry);\n const warnings: string[] = [];\n for (const candidate of candidates) {\n try {\n const unblocked = await mutateItem({\n pmRoot,\n settings,\n id: candidate.id,\n op: \"update\",\n author,\n message: `Auto-unblocked after blocker ${closedId} closed`,\n mutate(document) {\n /* c8 ignore start -- normal auto-unblock candidates carry dependency metadata; fallback preserves hand-edited scalar-only blockers. */\n const dependencies = document.metadata.dependencies ?? [];\n /* c8 ignore stop */\n const remainingDependencies = dependencies.filter((dependency) => {\n const dependencyId = dependency.id.trim();\n return dependency.kind !== \"blocked_by\" || !candidate.blocker_ids.includes(dependencyId);\n });\n document.metadata.status = statusRegistry.open_status;\n delete document.metadata.blocked_by;\n delete document.metadata.blocked_reason;\n document.metadata.unblock_note = `Auto-unblocked after blocker ${closedId} closed; all blockers resolved (${candidate.blocker_ids.join(\", \")}).`;\n if (remainingDependencies.length > 0) {\n document.metadata.dependencies = remainingDependencies;\n } else {\n delete document.metadata.dependencies;\n }\n const changedFields = [\"status\", \"blocked_by\", \"blocked_reason\", \"unblock_note\"];\n if (remainingDependencies.length !== dependencies.length) {\n changedFields.push(\"dependencies\");\n }\n return {\n changedFields,\n };\n },\n });\n warnings.push(`auto_unblocked:${unblocked.item.id}:resolved_blockers=${candidate.blocker_ids.join(\",\")}`);\n /* c8 ignore start -- defensive fan-out failure path; normal lock/claim state is auditable and still unblocks. */\n } catch (error) {\n const reason = error instanceof Error ? error.message.replace(/\\s+/g, \" \").trim() : \"unknown\";\n warnings.push(`auto_unblock_failed:${candidate.id}:${reason}`);\n }\n /* c8 ignore stop */\n }\n return warnings;\n}\n\nfunction applyInlineCloseFields(metadata: ItemFrontMatter, options: CloseCommandOptions): CloseInlineFieldKey[] {\n const changedFields: CloseInlineFieldKey[] = [];\n const inlineCloseFields: Array<{ option: string | undefined; key: CloseInlineFieldKey }> = [\n { option: options.resolution, key: \"resolution\" },\n { option: options.expectedResult, key: \"expected_result\" },\n { option: options.actualResult, key: \"actual_result\" },\n ];\n for (const { option, key } of inlineCloseFields) {\n if (typeof option !== \"string\") {\n continue;\n }\n const trimmed = option.trim();\n if (trimmed.length === 0) {\n continue;\n }\n metadata[key] = trimmed;\n changedFields.push(key);\n }\n return changedFields;\n}\n\nfunction applyDuplicateCloseMetadata(metadata: ItemFrontMatter, duplicateOf: string | undefined): CloseInlineFieldKey[] {\n if (duplicateOf === undefined) {\n return [];\n }\n metadata.duplicate_of = duplicateOf;\n const duplicateFallbackFields: CloseInlineFieldKey[] = [];\n const fallbackValues: Array<{ key: CloseInlineFieldKey; value: string }> = [\n { key: \"resolution\", value: `Duplicate of ${duplicateOf}` },\n { key: \"expected_result\", value: `Canonical item ${duplicateOf} tracks the work.` },\n { key: \"actual_result\", value: `Closed as duplicate of ${duplicateOf}.` },\n ];\n for (const { key, value } of fallbackValues) {\n if (shouldApplyDuplicateFallback(metadata[key])) {\n metadata[key] = value;\n duplicateFallbackFields.push(key);\n }\n }\n return duplicateFallbackFields;\n}\n\nfunction collectCloseValidationWarnings(\n metadata: ItemFrontMatter,\n validateCloseMode: ValidateCloseMode,\n activeChildIds: string[],\n): string[] {\n const warnings: string[] = [];\n if (validateCloseMode !== \"off\") {\n const missingFields = findMissingCloseValidationFields(metadata);\n if (missingFields.length > 0) {\n if (validateCloseMode === \"strict\") {\n throw new PmCliError(\n `Cannot close item ${metadata.id}: missing ${missingFields.join(\", \")}. Populate fields or use --validate-close warn.`,\n EXIT_CODE.USAGE,\n );\n }\n warnings.push(`close_validation_missing_fields:${metadata.id}:${missingFields.join(\",\")}`);\n }\n if (activeChildIds.length > 0) {\n if (validateCloseMode === \"strict\") {\n throw new PmCliError(\n `Cannot close item ${metadata.id}: active child items remain open (${activeChildIds.join(\", \")}). Close, cancel, or re-parent them first, or use --validate-close warn.`,\n EXIT_CODE.USAGE,\n );\n }\n warnings.push(`close_validation_active_children:${metadata.id}:${activeChildIds.join(\",\")}`);\n }\n return warnings;\n }\n if (activeChildIds.length > 0) {\n warnings.push(`closed_with_active_children:${metadata.id}:${activeChildIds.join(\",\")}`);\n }\n return warnings;\n}\n\nfunction applyCloseReason(metadata: ItemFrontMatter, closeReason: string | undefined): string[] {\n if (closeReason !== undefined) {\n metadata.close_reason = closeReason;\n return [\"close_reason\"];\n }\n if (metadata.close_reason !== undefined) {\n delete metadata.close_reason;\n return [\"close_reason\"];\n }\n return [];\n}\n\nfunction clearCloseAssignee(metadata: ItemFrontMatter): string[] {\n if (metadata.assignee === undefined) {\n return [];\n }\n delete metadata.assignee;\n return [\"assignee\"];\n}\n\nfunction clearClosedBlockerSignals(metadata: ItemFrontMatter): { changedFields: string[]; warnings: string[] } {\n const previousBlockedBy = typeof metadata.blocked_by === \"string\" ? metadata.blocked_by.trim() : \"\";\n const existingDeps = metadata.dependencies ?? [];\n const blockedByEdge = existingDeps.find((dep) => dep.kind === \"blocked_by\");\n const hadBlockedReason = metadata.blocked_reason !== undefined;\n if (previousBlockedBy.length === 0 && blockedByEdge === undefined && !hadBlockedReason) {\n return { changedFields: [], warnings: [] };\n }\n const changedFields: string[] = [];\n if (previousBlockedBy.length > 0) {\n delete metadata.blocked_by;\n changedFields.push(\"blocked_by\");\n }\n if (hadBlockedReason) {\n delete metadata.blocked_reason;\n changedFields.push(\"blocked_reason\");\n }\n if (blockedByEdge !== undefined) {\n const remainingDeps = existingDeps.filter((dep) => dep.kind !== \"blocked_by\");\n if (remainingDeps.length > 0) {\n metadata.dependencies = remainingDeps;\n } else {\n delete metadata.dependencies;\n }\n changedFields.push(\"dependencies\");\n }\n // A stale reason-only close has no blocker identity; omit the blocker-clear warning instead of inventing one.\n const reportedBlocker = previousBlockedBy || blockedByEdge?.id;\n return {\n changedFields,\n warnings: reportedBlocker ? [`closed_cleared_blocked_by:${metadata.id}:${reportedBlocker}`] : [],\n };\n}\n\nfunction mutateCloseMetadata(metadata: ItemFrontMatter, context: CloseMutationContext): { changedFields: string[]; warnings?: string[] } {\n if (isTerminalStatus(metadata.status, context.statusRegistry) && !context.force) {\n throw new PmCliError(`Item ${metadata.id} is already terminal; use --force to close again.`, EXIT_CODE.CONFLICT);\n }\n const inlineChangedFields = applyInlineCloseFields(metadata, context.options);\n const duplicateFallbackFields = applyDuplicateCloseMetadata(metadata, context.duplicateOf);\n const mutationWarnings = collectCloseValidationWarnings(metadata, context.validateCloseMode, context.activeChildIds);\n metadata.status = context.statusRegistry.close_status;\n const changedFields = [\n \"status\",\n ...applyCloseReason(metadata, context.closeReason),\n ...inlineChangedFields,\n ];\n if (context.duplicateOf !== undefined) {\n changedFields.push(\"duplicate_of\");\n for (const key of duplicateFallbackFields) {\n /* v8 ignore start -- duplicate fallback keys are already pre-deduped by applyDuplicateCloseMetadata in covered close paths */\n if (!changedFields.includes(key)) {\n changedFields.push(key);\n }\n /* v8 ignore stop */\n }\n }\n changedFields.push(...clearCloseAssignee(metadata));\n const blockerCleanup = clearClosedBlockerSignals(metadata);\n changedFields.push(...blockerCleanup.changedFields);\n mutationWarnings.push(...blockerCleanup.warnings);\n return {\n changedFields,\n ...(mutationWarnings.length > 0 ? { warnings: mutationWarnings } : {}),\n };\n}\n\nexport const _testOnlyCloseCommand = {\n blockedByIds: collectBlockedByIds,\n};\n\n/**\n * Implements run close for the public runtime surface of this module.\n */\nexport async function runClose(\n id: string,\n closeReasonText: string | undefined,\n options: CloseCommandOptions,\n global: GlobalOptions,\n): Promise<CloseResult> {\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 statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const author = toAuthor(options.author, settings.author_default);\n // GH-250: verify the target item EXISTS before the governance close-reason\n // gate fires. Otherwise closing a typo'd id with no reason reports\n // \"Close reason text is required\" and hides the real cause (bad id) until a\n // reason is supplied. Existence is the more fundamental precondition, so it\n // is validated first regardless of whether a reason was provided.\n const typeToFolder = resolveItemTypeRegistry(settings).type_to_folder;\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);\n if (!located) {\n throw await buildItemNotFoundError(pmRoot, id, settings.id_prefix, typeToFolder);\n }\n // GH-204: resolve the duplicate target BEFORE reason validation so\n // `pm close <id> --duplicate-of <canonical>` succeeds under\n // governance.require_close_reason without a manual reason — when no\n // positional/--reason text is provided the reason defaults to\n // \"Duplicate of <id>\" (mirroring the auto-filled closure metadata).\n // Explicit reason text still wins.\n const duplicateOf = await assertDuplicateTargetExists(pmRoot, settings, options.duplicateOf, id);\n // pm-7x8d / pm-9hry / GH-204: when no explicit positional/--reason text is given, derive\n // the close reason from the next-best closure signal instead of hard-blocking\n // under governance.require_close_reason. Precedence: explicit reason text >\n // --duplicate-of (\"Duplicate of <id>\") > --resolution summary > --message.\n // Resolution still writes metadata.resolution below; message still writes the\n // history entry through mutateItem. Reusing either as the close reason just lets\n // a single agent-authored close command succeed when it already supplied a\n // closure summary through another structured option.\n const effectiveCloseReasonText = resolveEffectiveCloseReasonText({\n closeReasonText,\n duplicateOf,\n resolution: options.resolution,\n message: options.message,\n requireCloseReason: settings.governance.require_close_reason,\n });\n const closeReason = normalizeCloseReason(effectiveCloseReasonText, settings.governance.require_close_reason);\n const validateCloseMode = parseValidateCloseMode(options.validateClose) ?? settings.governance.close_validation_default;\n // C3 (pm-fu5d): scan for active children even under minimal governance so\n // closing a parent is never silently orphaning — off mode emits an\n // informational note instead of the warn/strict validation warning.\n const activeChildIds = await findActiveChildIds(pmRoot, settings, id, statusRegistry);\n\n const result = await mutateItem({\n pmRoot,\n settings,\n id,\n op: \"close\",\n author,\n message: options.message,\n force: options.force,\n mutate(document) {\n return mutateCloseMetadata(document.metadata, {\n statusRegistry,\n force: options.force,\n options,\n duplicateOf,\n validateCloseMode,\n activeChildIds,\n closeReason,\n });\n },\n });\n\n return {\n item: toItemRecord(result.item),\n changed_fields: result.changedFields,\n warnings: [\n ...result.warnings,\n ...(await autoUnblockResolvedDependents(pmRoot, settings, located.id, author, statusRegistry)),\n ],\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,SAAS,SAAS,WAA+B,eAAqB;AACpE,QAAM,WAAW,aAAa,QAAQ,IAAI,aAAa;AACvD,QAAM,UAAU,SAAS,KAAI;AAC7B,SAAO,WAAW;AACpB;AAEA,SAAS,qBAAqB,YAAgC,UAAiB;AAC7E,QAAM,UAAU,cAAc,IAAI,KAAI;AACtC,MAAI,OAAO,SAAS,GAAG;AACrB,WAAO;EACT;AACA,MAAI,UAAU;AACZ,UAAM,IAAI,WACR,oFACA,UAAU,OACV;MACE,MAAM;MACN,UAAU;MACV,KAAK;MACL,UAAU;QACR;QACA;QACA;QACA;;MAEF,WAAW;QACT;QACA;QACA;;KAEH;EAEL;AACA,SAAO;AACT;AAYA,SAAS,gCAAgC,OAA+B;AACtE,OAAK,MAAM,mBAAmB,IAAI,KAAI,EAAG,SAAS,GAAG;AACnD,WAAO,MAAM;EACf;AACA,MAAI,MAAM,gBAAgB,QAAW;AACnC,WAAO,gBAAgB,MAAM,WAAW;EAC1C;AACA,QAAM,oBAAoB,OAAO,MAAM,eAAe,WAAW,MAAM,WAAW,KAAI,IAAK;AAC3F,MAAI,kBAAkB,SAAS,GAAG;AAChC,WAAO;EACT;AACA,QAAM,iBAAiB,OAAO,MAAM,YAAY,WAAW,MAAM,QAAQ,KAAI,IAAK;AAClF,MAAI,MAAM,sBAAsB,eAAe,SAAS,GAAG;AACzD,WAAO;EACT;AACA,SAAO,MAAM;AACf;AAEA,IAAM,0BAA0I;EAC9I,EAAE,KAAK,cAAc,OAAO,aA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aAAa,OAAO,IAAI;IAC9B,gBAAgB,OAAO;IACvB,UAAU;MACR,GAAG,OAAO;MACV,GAAI,MAAM,8BAA8B,QAAQ,UAAU,QAAQ,IAAI,QAAQ,cAAc;;;AAGlG;",
6
+ "names": ["global"]
7
+ }
@@ -1,21 +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]="8b8a7dc0-b7eb-5093-a13c-9d1adf4f3023")}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]="6beae0c5-95ce-5ca2-9c64-67075f518c1a")}catch(e){}}();
3
3
  import {
4
- EXIT_CODE,
5
4
  PmCliError
6
- } from "./chunk-L4SLHV6G.js";
7
-
8
- // dist/core/shared/memo.js
9
- function evictOldestMemoEntries(memo) {
10
- let remaining = Math.ceil(memo.size / 2);
11
- for (const key of memo.keys()) {
12
- if (remaining === 0) {
13
- return;
14
- }
15
- memo.delete(key);
16
- remaining -= 1;
17
- }
18
- }
5
+ } from "./chunk-US3T3W5J.js";
6
+ import {
7
+ evictOldestMemoEntries
8
+ } from "./chunk-NNHHXJB2.js";
9
+ import {
10
+ EXIT_CODE
11
+ } from "./chunk-YD5FML7K.js";
19
12
 
20
13
  // dist/core/shared/time.js
21
14
  var RELATIVE_DEADLINE = /^([+-]?)(\d+)([hdwm])$/i;
@@ -225,12 +218,11 @@ function resolveIsoOrRelative(input, now = /* @__PURE__ */ new Date(), fieldLabe
225
218
  }
226
219
 
227
220
  export {
228
- evictOldestMemoEntries,
229
221
  nowIso,
230
222
  isTimestampLiteral,
231
223
  compareTimestampStrings,
232
224
  resolveIsoOrRelative
233
225
  };
234
- //# sourceMappingURL=chunk-CXR3CMBQ.js.map
226
+ //# sourceMappingURL=chunk-FJRKQREY.js.map
235
227
 
236
- //# debugId=8b8a7dc0-b7eb-5093-a13c-9d1adf4f3023
228
+ //# debugId=6beae0c5-95ce-5ca2-9c64-67075f518c1a