@unbrained/pm-cli 2026.6.6 → 2026.6.8

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 (600) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +79 -0
  4. package/CONTRIBUTING.md +1 -1
  5. package/README.md +6 -2
  6. package/dist/cli/bootstrap-args.js +30 -13
  7. package/dist/cli/bootstrap-args.js.map +1 -1
  8. package/dist/cli/commander-usage.js +74 -4
  9. package/dist/cli/commander-usage.js.map +1 -1
  10. package/dist/cli/commands/aggregate.d.ts +8 -0
  11. package/dist/cli/commands/aggregate.js +84 -7
  12. package/dist/cli/commands/aggregate.js.map +1 -1
  13. package/dist/cli/commands/calendar.js +10 -3
  14. package/dist/cli/commands/calendar.js.map +1 -1
  15. package/dist/cli/commands/close-many.js +20 -11
  16. package/dist/cli/commands/close-many.js.map +1 -1
  17. package/dist/cli/commands/close.d.ts +1 -1
  18. package/dist/cli/commands/close.js +32 -10
  19. package/dist/cli/commands/close.js.map +1 -1
  20. package/dist/cli/commands/comments-audit.js +4 -3
  21. package/dist/cli/commands/comments-audit.js.map +1 -1
  22. package/dist/cli/commands/completion.js +105 -43
  23. package/dist/cli/commands/completion.js.map +1 -1
  24. package/dist/cli/commands/config.d.ts +5 -4
  25. package/dist/cli/commands/config.js +50 -2
  26. package/dist/cli/commands/config.js.map +1 -1
  27. package/dist/cli/commands/contracts.js +4 -3
  28. package/dist/cli/commands/contracts.js.map +1 -1
  29. package/dist/cli/commands/copy.d.ts +14 -0
  30. package/dist/cli/commands/copy.js +153 -0
  31. package/dist/cli/commands/copy.js.map +1 -0
  32. package/dist/cli/commands/extension/doctor.js +62 -2
  33. package/dist/cli/commands/extension/doctor.js.map +1 -1
  34. package/dist/cli/commands/extension/install-sources.d.ts +8 -0
  35. package/dist/cli/commands/extension/install-sources.js +82 -2
  36. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  37. package/dist/cli/commands/extension/scaffold.js +6 -14
  38. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  39. package/dist/cli/commands/extension.d.ts +29 -0
  40. package/dist/cli/commands/extension.js +61 -2
  41. package/dist/cli/commands/extension.js.map +1 -1
  42. package/dist/cli/commands/gc.js +10 -2
  43. package/dist/cli/commands/gc.js.map +1 -1
  44. package/dist/cli/commands/get.d.ts +9 -0
  45. package/dist/cli/commands/get.js +23 -2
  46. package/dist/cli/commands/get.js.map +1 -1
  47. package/dist/cli/commands/health.js +10 -2
  48. package/dist/cli/commands/health.js.map +1 -1
  49. package/dist/cli/commands/history-compact.d.ts +39 -0
  50. package/dist/cli/commands/history-compact.js +262 -0
  51. package/dist/cli/commands/history-compact.js.map +1 -0
  52. package/dist/cli/commands/index.d.ts +3 -1
  53. package/dist/cli/commands/index.js +5 -3
  54. package/dist/cli/commands/index.js.map +1 -1
  55. package/dist/cli/commands/init.d.ts +1 -0
  56. package/dist/cli/commands/init.js +48 -2
  57. package/dist/cli/commands/init.js.map +1 -1
  58. package/dist/cli/commands/list.d.ts +13 -2
  59. package/dist/cli/commands/list.js +189 -9
  60. package/dist/cli/commands/list.js.map +1 -1
  61. package/dist/cli/commands/normalize.js +6 -4
  62. package/dist/cli/commands/normalize.js.map +1 -1
  63. package/dist/cli/commands/reindex.js +8 -4
  64. package/dist/cli/commands/reindex.js.map +1 -1
  65. package/dist/cli/commands/schema.d.ts +13 -2
  66. package/dist/cli/commands/schema.js +66 -12
  67. package/dist/cli/commands/schema.js.map +1 -1
  68. package/dist/cli/commands/search.d.ts +11 -2
  69. package/dist/cli/commands/search.js +321 -35
  70. package/dist/cli/commands/search.js.map +1 -1
  71. package/dist/cli/commands/upgrade.js +4 -12
  72. package/dist/cli/commands/upgrade.js.map +1 -1
  73. package/dist/cli/error-guidance.js +26 -2
  74. package/dist/cli/error-guidance.js.map +1 -1
  75. package/dist/cli/extension-command-help.d.ts +1 -0
  76. package/dist/cli/extension-command-help.js +3 -2
  77. package/dist/cli/extension-command-help.js.map +1 -1
  78. package/dist/cli/help-content.js +10 -2
  79. package/dist/cli/help-content.js.map +1 -1
  80. package/dist/cli/main.d.ts +3 -0
  81. package/dist/cli/main.js +18 -37
  82. package/dist/cli/main.js.map +1 -1
  83. package/dist/cli/register-list-query.js +22 -5
  84. package/dist/cli/register-list-query.js.map +1 -1
  85. package/dist/cli/register-mutation.js +83 -39
  86. package/dist/cli/register-mutation.js.map +1 -1
  87. package/dist/cli/register-operations.js +31 -7
  88. package/dist/cli/register-operations.js.map +1 -1
  89. package/dist/cli/register-setup.js +7 -5
  90. package/dist/cli/register-setup.js.map +1 -1
  91. package/dist/cli/registration-helpers.js +26 -4
  92. package/dist/cli/registration-helpers.js.map +1 -1
  93. package/dist/cli-bundle/chunks/activity-A3QKFSSF.js +16 -0
  94. package/dist/cli-bundle/chunks/{activity-JM6DTDND.js → activity-Q7XMIZIH.js} +11 -11
  95. package/dist/cli-bundle/chunks/{aggregate-VNAHUNNF.js → aggregate-GBSHSXOB.js} +87 -17
  96. package/dist/cli-bundle/chunks/aggregate-GBSHSXOB.js.map +7 -0
  97. package/dist/cli-bundle/chunks/{aggregate-GI7WSZPH.js → aggregate-HKQJZUBG.js} +88 -18
  98. package/dist/cli-bundle/chunks/aggregate-HKQJZUBG.js.map +1 -0
  99. package/dist/cli-bundle/chunks/{append-WMKRXKCE.js → append-3RFOU7P5.js} +8 -8
  100. package/dist/cli-bundle/chunks/{append-7H5N64R2.js → append-OM74OJVT.js} +8 -8
  101. package/dist/cli-bundle/chunks/{chunk-KJE2FOS4.js → chunk-2BYKYPWY.js} +26 -4
  102. package/dist/cli-bundle/chunks/chunk-2BYKYPWY.js.map +7 -0
  103. package/dist/cli-bundle/chunks/{chunk-XTGLRY2Y.js → chunk-2HMD3JM2.js} +6 -6
  104. package/dist/cli-bundle/chunks/{chunk-PRJCELV4.js → chunk-2YPVCD7T.js} +8 -8
  105. package/dist/cli-bundle/chunks/{chunk-3FI4SEFT.js → chunk-3E3MDBTB.js} +62 -38
  106. package/dist/cli-bundle/chunks/chunk-3E3MDBTB.js.map +7 -0
  107. package/dist/cli-bundle/chunks/{chunk-U5SXYXSY.js → chunk-3TXWDGPU.js} +287 -45
  108. package/dist/cli-bundle/chunks/chunk-3TXWDGPU.js.map +7 -0
  109. package/dist/cli-bundle/chunks/{chunk-HZGUAH22.js → chunk-4TI3532H.js} +6 -7
  110. package/dist/cli-bundle/chunks/chunk-4TI3532H.js.map +1 -0
  111. package/dist/cli-bundle/chunks/{chunk-2HVRUSQA.js → chunk-4WYBLB6J.js} +3 -3
  112. package/dist/cli-bundle/chunks/{chunk-R6UFP2GE.js → chunk-5NVJA7IW.js} +7 -7
  113. package/dist/cli-bundle/chunks/{chunk-Q7SPNHLW.js → chunk-5WO2VKFA.js} +190 -16
  114. package/dist/cli-bundle/chunks/chunk-5WO2VKFA.js.map +7 -0
  115. package/dist/cli-bundle/chunks/{chunk-IOR7LGF4.js → chunk-7NQIY7Z6.js} +89 -7
  116. package/dist/cli-bundle/chunks/chunk-7NQIY7Z6.js.map +1 -0
  117. package/dist/cli-bundle/chunks/{chunk-ECCMVXGM.js → chunk-7WXGR44E.js} +305 -216
  118. package/dist/cli-bundle/chunks/chunk-7WXGR44E.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-XSJCLN2R.js → chunk-AEMKH5WQ.js} +3 -3
  120. package/dist/cli-bundle/chunks/{chunk-WOPXVEZP.js → chunk-ALSRBNYB.js} +28 -9
  121. package/dist/cli-bundle/chunks/chunk-ALSRBNYB.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-6ER6DXH5.js → chunk-AXBUHLW7.js} +9 -9
  123. package/dist/cli-bundle/chunks/{chunk-BQHUILZS.js → chunk-BFJPMUF5.js} +5 -5
  124. package/dist/cli-bundle/chunks/{chunk-I6BNFU5X.js → chunk-BKQMJXWY.js} +3 -3
  125. package/dist/cli-bundle/chunks/{chunk-XLTD2HN3.js → chunk-CBJXWXI5.js} +2 -2
  126. package/dist/cli-bundle/chunks/{chunk-FRAUKRU2.js → chunk-D7WK2PKB.js} +36 -15
  127. package/dist/cli-bundle/chunks/chunk-D7WK2PKB.js.map +1 -0
  128. package/dist/cli-bundle/chunks/{chunk-PROOHX4K.js → chunk-DV27WDA7.js} +104 -21
  129. package/dist/cli-bundle/chunks/chunk-DV27WDA7.js.map +7 -0
  130. package/dist/cli-bundle/chunks/{chunk-3BWOVLTH.js → chunk-EPWT7BEA.js} +8 -8
  131. package/dist/cli-bundle/chunks/chunk-ETZZU5QF.js +112 -0
  132. package/dist/cli-bundle/chunks/chunk-ETZZU5QF.js.map +1 -0
  133. package/dist/cli-bundle/chunks/{chunk-TPH5XEVD.js → chunk-F33AQIB4.js} +303 -207
  134. package/dist/cli-bundle/chunks/chunk-F33AQIB4.js.map +1 -0
  135. package/dist/cli-bundle/chunks/{chunk-NUZ5HKR4.js → chunk-F33VC5EX.js} +2 -2
  136. package/dist/cli-bundle/chunks/{chunk-WKY2IBOQ.js → chunk-FGRJZVXD.js} +3 -3
  137. package/dist/cli-bundle/chunks/{chunk-77GFDHGF.js → chunk-FO2TYSQZ.js} +2 -2
  138. package/dist/cli-bundle/chunks/{chunk-GXSUPCBV.js → chunk-HOA3GMB6.js} +4 -4
  139. package/dist/cli-bundle/chunks/{chunk-OVQCEJPG.js → chunk-HP35AVFS.js} +2 -2
  140. package/dist/cli-bundle/chunks/{chunk-KJ33AOCY.js → chunk-J4DKAGTM.js} +3 -3
  141. package/dist/cli-bundle/chunks/{chunk-ME2YH6FN.js → chunk-JS47EKLP.js} +7 -7
  142. package/dist/cli-bundle/chunks/{chunk-T3LC5LKB.js → chunk-K62SNVVE.js} +5 -6
  143. package/dist/cli-bundle/chunks/chunk-K62SNVVE.js.map +7 -0
  144. package/dist/cli-bundle/chunks/{chunk-GU2ZJ2VV.js → chunk-KBKJVXUS.js} +35 -14
  145. package/dist/cli-bundle/chunks/chunk-KBKJVXUS.js.map +7 -0
  146. package/dist/cli-bundle/chunks/{chunk-KWU6HG75.js → chunk-KCGMABHM.js} +101 -18
  147. package/dist/cli-bundle/chunks/chunk-KCGMABHM.js.map +1 -0
  148. package/dist/cli-bundle/chunks/{chunk-I2HSTRJF.js → chunk-KN4WSESY.js} +5 -5
  149. package/dist/cli-bundle/chunks/{chunk-RZN6VURO.js → chunk-KP4KIUQT.js} +3 -3
  150. package/dist/cli-bundle/chunks/{chunk-5FDATVEZ.js → chunk-KS2U7BZ3.js} +71 -17
  151. package/dist/cli-bundle/chunks/chunk-KS2U7BZ3.js.map +1 -0
  152. package/dist/cli-bundle/chunks/{chunk-MITFDD35.js → chunk-KVXIQDJG.js} +12 -12
  153. package/dist/cli-bundle/chunks/{chunk-IJGCZSIQ.js → chunk-L3LYL3ID.js} +12 -12
  154. package/dist/cli-bundle/chunks/{chunk-AO442XLN.js → chunk-M7UBTVFT.js} +10 -6
  155. package/dist/cli-bundle/chunks/{chunk-AO442XLN.js.map → chunk-M7UBTVFT.js.map} +2 -2
  156. package/dist/cli-bundle/chunks/{chunk-UM2GBHS4.js → chunk-MSH23UWO.js} +4 -4
  157. package/dist/cli-bundle/chunks/{chunk-LCM63IXU.js → chunk-N4SQZ7L3.js} +2 -2
  158. package/dist/cli-bundle/chunks/{chunk-3VAM3NNM.js → chunk-NDSMKB2I.js} +3 -3
  159. package/dist/cli-bundle/chunks/{chunk-6P6GGMOG.js → chunk-NGEEXR2R.js} +2 -2
  160. package/dist/cli-bundle/chunks/{chunk-PO3GSVFV.js → chunk-NLVCMVC7.js} +2 -2
  161. package/dist/cli-bundle/chunks/{chunk-N7ACFE26.js → chunk-NUKHZZNM.js} +3 -3
  162. package/dist/cli-bundle/chunks/{chunk-GGYWB3Y2.js → chunk-ODN53S6H.js} +6 -6
  163. package/dist/cli-bundle/chunks/{chunk-23YFZ3IG.js → chunk-OTY2YEH5.js} +14 -14
  164. package/dist/cli-bundle/chunks/{chunk-2RSPZI5H.js → chunk-OVSSE2JP.js} +8 -8
  165. package/dist/cli-bundle/chunks/{chunk-4LL6TK5B.js → chunk-PQDH3S54.js} +59 -35
  166. package/dist/cli-bundle/chunks/chunk-PQDH3S54.js.map +1 -0
  167. package/dist/cli-bundle/chunks/{chunk-2VVCGBNV.js → chunk-QF4OPBAG.js} +9 -9
  168. package/dist/cli-bundle/chunks/{chunk-QO7EBBOM.js → chunk-QFVASU44.js} +38 -7
  169. package/dist/cli-bundle/chunks/chunk-QFVASU44.js.map +7 -0
  170. package/dist/cli-bundle/chunks/{chunk-WSMOSYRD.js → chunk-QQPZYP73.js} +14 -14
  171. package/dist/cli-bundle/chunks/{chunk-OZ7NSQHL.js → chunk-QWNUDGFQ.js} +8 -8
  172. package/dist/cli-bundle/chunks/{chunk-AY43SBIN.js → chunk-R4XIE7NQ.js} +54 -8
  173. package/dist/cli-bundle/chunks/chunk-R4XIE7NQ.js.map +1 -0
  174. package/dist/cli-bundle/chunks/{chunk-52MAOQ6J.js → chunk-RISLL7XH.js} +71 -17
  175. package/dist/cli-bundle/chunks/chunk-RISLL7XH.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-GCOQW437.js → chunk-SDLEYY6A.js} +3 -3
  177. package/dist/cli-bundle/chunks/{chunk-W7XABV4H.js → chunk-SM3RMWGO.js} +191 -17
  178. package/dist/cli-bundle/chunks/chunk-SM3RMWGO.js.map +1 -0
  179. package/dist/cli-bundle/chunks/{chunk-PIU6RSL3.js → chunk-TBLBEOEX.js} +9 -9
  180. package/dist/cli-bundle/chunks/{chunk-SKJWX3QB.js → chunk-TXKENAQP.js} +88 -6
  181. package/dist/cli-bundle/chunks/chunk-TXKENAQP.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{chunk-YL2DJGYS.js → chunk-UEXNNF3K.js} +7 -7
  183. package/dist/cli-bundle/chunks/{chunk-UBOPJT3S.js → chunk-UMMJAJB2.js} +9 -9
  184. package/dist/cli-bundle/chunks/chunk-URJEZOLB.js +115 -0
  185. package/dist/cli-bundle/chunks/chunk-URJEZOLB.js.map +7 -0
  186. package/dist/cli-bundle/chunks/{chunk-PDDFYW4X.js → chunk-VXBUXLVD.js} +27 -8
  187. package/dist/cli-bundle/chunks/chunk-VXBUXLVD.js.map +7 -0
  188. package/dist/cli-bundle/chunks/{chunk-LB3RUL2N.js → chunk-XEKZCBCS.js} +10 -6
  189. package/dist/cli-bundle/chunks/chunk-XEKZCBCS.js.map +1 -0
  190. package/dist/cli-bundle/chunks/{chunk-KAG77BY3.js → chunk-XLSQ3QLT.js} +2 -2
  191. package/dist/cli-bundle/chunks/{chunk-E5FJNAZA.js → chunk-XNGMIVQY.js} +3 -3
  192. package/dist/cli-bundle/chunks/{chunk-TCD3R2PF.js → chunk-XZS4MV37.js} +39 -8
  193. package/dist/cli-bundle/chunks/chunk-XZS4MV37.js.map +1 -0
  194. package/dist/cli-bundle/chunks/{chunk-RWPSOIEE.js → chunk-YEFOCDIK.js} +7 -7
  195. package/dist/cli-bundle/chunks/{chunk-5SFCOO6B.js → chunk-YJAKN2N2.js} +277 -35
  196. package/dist/cli-bundle/chunks/chunk-YJAKN2N2.js.map +1 -0
  197. package/dist/cli-bundle/chunks/{chunk-2VBQ6ZXS.js → chunk-Z2HXAFFH.js} +27 -5
  198. package/dist/cli-bundle/chunks/chunk-Z2HXAFFH.js.map +1 -0
  199. package/dist/cli-bundle/chunks/{chunk-3LB74A67.js → chunk-Z55JACL2.js} +53 -7
  200. package/dist/cli-bundle/chunks/chunk-Z55JACL2.js.map +7 -0
  201. package/dist/cli-bundle/chunks/{claim-4DBF6RVG.js → claim-NHBIIBOW.js} +10 -10
  202. package/dist/cli-bundle/chunks/{claim-X2P4IB7J.js → claim-RNEBQCOO.js} +10 -10
  203. package/dist/cli-bundle/chunks/close-UNTFXVM3.js +13 -0
  204. package/dist/cli-bundle/chunks/{close-PTYFA45H.js → close-ZMXL2WDS.js} +8 -8
  205. package/dist/cli-bundle/chunks/{close-many-ERFO6LHR.js → close-many-CDPQGQUB.js} +37 -28
  206. package/dist/cli-bundle/chunks/close-many-CDPQGQUB.js.map +1 -0
  207. package/dist/cli-bundle/chunks/{close-many-7CGIDPTJ.js → close-many-IQV5C2SI.js} +36 -27
  208. package/dist/cli-bundle/chunks/close-many-IQV5C2SI.js.map +7 -0
  209. package/dist/cli-bundle/chunks/{comments-QKBYCWKD.js → comments-EFVBHWPT.js} +10 -10
  210. package/dist/cli-bundle/chunks/{comments-OONGABK5.js → comments-J5Q4IJPH.js} +10 -10
  211. package/dist/cli-bundle/chunks/{config-6FXCQKIF.js → config-72253M2O.js} +127 -12
  212. package/dist/cli-bundle/chunks/config-72253M2O.js.map +1 -0
  213. package/dist/cli-bundle/chunks/{config-U4RZ4CQB.js → config-VFYA6BMI.js} +128 -13
  214. package/dist/cli-bundle/chunks/config-VFYA6BMI.js.map +7 -0
  215. package/dist/cli-bundle/chunks/{context-FYYJGFWS.js → context-AVLO4IFH.js} +14 -14
  216. package/dist/cli-bundle/chunks/{context-FYYJGFWS.js.map → context-AVLO4IFH.js.map} +2 -2
  217. package/dist/cli-bundle/chunks/{context-YMJ3Z2HQ.js → context-WMSI2D65.js} +15 -15
  218. package/dist/cli-bundle/chunks/context-WMSI2D65.js.map +1 -0
  219. package/dist/cli-bundle/chunks/{contracts-RFSPGVVJ.js → contracts-D4BN3VSQ.js} +7 -5
  220. package/dist/cli-bundle/chunks/contracts-D4BN3VSQ.js.map +7 -0
  221. package/dist/cli-bundle/chunks/{contracts-QDB6OMLQ.js → contracts-RGPOBLPL.js} +8 -6
  222. package/dist/cli-bundle/chunks/contracts-RGPOBLPL.js.map +1 -0
  223. package/dist/cli-bundle/chunks/copy-H6TXHK7S.js +185 -0
  224. package/dist/cli-bundle/chunks/copy-H6TXHK7S.js.map +7 -0
  225. package/dist/cli-bundle/chunks/copy-WXE3OOLZ.js +182 -0
  226. package/dist/cli-bundle/chunks/copy-WXE3OOLZ.js.map +1 -0
  227. package/dist/cli-bundle/chunks/create-EZWAMUKR.js +27 -0
  228. package/dist/cli-bundle/chunks/{create-I5L4EYYZ.js → create-PUAIJEZ7.js} +13 -13
  229. package/dist/cli-bundle/chunks/{delete-7HPGI4GZ.js → delete-PKR2JHLH.js} +7 -7
  230. package/dist/cli-bundle/chunks/{delete-VXUPH5RS.js → delete-WBME6WG5.js} +7 -7
  231. package/dist/cli-bundle/chunks/{deps-JSRRWC3Z.js → deps-4BQEDV4L.js} +7 -7
  232. package/dist/cli-bundle/chunks/{deps-SCZIFK2Z.js → deps-KWHQRO75.js} +7 -7
  233. package/dist/cli-bundle/chunks/{docs-GJK6K4VP.js → docs-364GT3ZR.js} +9 -9
  234. package/dist/cli-bundle/chunks/{docs-WW4N3MBM.js → docs-SCNBUGSV.js} +9 -9
  235. package/dist/cli-bundle/chunks/{extension-VDY2U33M.js → extension-CRE7JM47.js} +8 -6
  236. package/dist/cli-bundle/chunks/{extension-J7IBMFTD.js → extension-KK2UPXJD.js} +8 -6
  237. package/dist/cli-bundle/chunks/{files-ISZJGILQ.js → files-3GESQAWL.js} +9 -9
  238. package/dist/cli-bundle/chunks/{files-WKOD326U.js → files-66EHM5ZR.js} +9 -9
  239. package/dist/cli-bundle/chunks/{gc-JDVJ6OQ2.js → gc-D5IWOKQH.js} +13 -5
  240. package/dist/cli-bundle/chunks/gc-D5IWOKQH.js.map +1 -0
  241. package/dist/cli-bundle/chunks/{gc-ULPVWMTN.js → gc-MOQDND5J.js} +12 -4
  242. package/dist/cli-bundle/chunks/gc-MOQDND5J.js.map +7 -0
  243. package/dist/cli-bundle/chunks/{get-RV37HT3G.js → get-7J2ZCBV5.js} +34 -12
  244. package/dist/cli-bundle/chunks/get-7J2ZCBV5.js.map +1 -0
  245. package/dist/cli-bundle/chunks/{get-WXU6WI5P.js → get-WXSLXV3K.js} +33 -11
  246. package/dist/cli-bundle/chunks/get-WXSLXV3K.js.map +7 -0
  247. package/dist/cli-bundle/chunks/{health-LOI2HHKB.js → health-B6AEM7BV.js} +21 -13
  248. package/dist/cli-bundle/chunks/health-B6AEM7BV.js.map +1 -0
  249. package/dist/cli-bundle/chunks/{health-6L6EH4WR.js → health-YMZGOMVX.js} +20 -12
  250. package/dist/cli-bundle/chunks/health-YMZGOMVX.js.map +7 -0
  251. package/dist/cli-bundle/chunks/{history-PKN67D5O.js → history-TJTO5GCR.js} +10 -10
  252. package/dist/cli-bundle/chunks/history-ZERISU2L.js +20 -0
  253. package/dist/cli-bundle/chunks/history-compact-CKNN6UKW.js +290 -0
  254. package/dist/cli-bundle/chunks/history-compact-CKNN6UKW.js.map +7 -0
  255. package/dist/cli-bundle/chunks/history-compact-N2Q7IR3T.js +287 -0
  256. package/dist/cli-bundle/chunks/history-compact-N2Q7IR3T.js.map +1 -0
  257. package/dist/cli-bundle/chunks/history-redact-GODBYT5A.js +19 -0
  258. package/dist/cli-bundle/chunks/{history-redact-V4FOJGS7.js → history-redact-JUXUOH54.js} +11 -11
  259. package/dist/cli-bundle/chunks/{history-repair-HIBCBIKK.js → history-repair-CCCPBNTF.js} +11 -11
  260. package/dist/cli-bundle/chunks/{history-repair-SDMHR7JT.js → history-repair-TDBBSRVK.js} +11 -11
  261. package/dist/cli-bundle/chunks/{init-P56QYWJF.js → init-6ZPKD3YN.js} +9 -8
  262. package/dist/cli-bundle/chunks/init-CBZHXBR3.js +17 -0
  263. package/dist/cli-bundle/chunks/{learnings-MIXSESLK.js → learnings-U7U2FNIO.js} +10 -10
  264. package/dist/cli-bundle/chunks/{learnings-GDFRG5J7.js → learnings-WYNTYQ5T.js} +10 -10
  265. package/dist/cli-bundle/chunks/list-7MTPPZHC.js +20 -0
  266. package/dist/cli-bundle/chunks/{list-FGOWQMSM.js → list-JGP7ODML.js} +10 -10
  267. package/dist/cli-bundle/chunks/{notes-5UK3GEH2.js → notes-P25YVTEG.js} +10 -10
  268. package/dist/cli-bundle/chunks/{notes-4XVSH2AZ.js → notes-QIF6A7XS.js} +10 -10
  269. package/dist/cli-bundle/chunks/{plan-DUMBV3QB.js → plan-RACB5PI6.js} +13 -13
  270. package/dist/cli-bundle/chunks/{plan-SLMODHWX.js → plan-SSBJFWXA.js} +13 -13
  271. package/dist/cli-bundle/chunks/{register-list-query-POCFZ5JW.js → register-list-query-5IXDPUZ6.js} +31 -25
  272. package/dist/cli-bundle/chunks/register-list-query-5IXDPUZ6.js.map +1 -0
  273. package/dist/cli-bundle/chunks/{register-list-query-WST76HSQ.js → register-list-query-GQAEIG4K.js} +30 -24
  274. package/dist/cli-bundle/chunks/register-list-query-GQAEIG4K.js.map +7 -0
  275. package/dist/cli-bundle/chunks/{register-mutation-N5GSUZJV.js → register-mutation-FAS4YG63.js} +72 -50
  276. package/dist/cli-bundle/chunks/register-mutation-FAS4YG63.js.map +1 -0
  277. package/dist/cli-bundle/chunks/{register-mutation-OA675SOU.js → register-mutation-YZCUILGO.js} +71 -49
  278. package/dist/cli-bundle/chunks/register-mutation-YZCUILGO.js.map +7 -0
  279. package/dist/cli-bundle/chunks/{register-operations-N3PMHXH5.js → register-operations-IBYWNJN5.js} +57 -34
  280. package/dist/cli-bundle/chunks/register-operations-IBYWNJN5.js.map +7 -0
  281. package/dist/cli-bundle/chunks/{register-operations-GNHBE5I3.js → register-operations-S2BOLUPF.js} +58 -35
  282. package/dist/cli-bundle/chunks/register-operations-S2BOLUPF.js.map +1 -0
  283. package/dist/cli-bundle/chunks/{register-setup-ZHJI2DI3.js → register-setup-ABA2JPWO.js} +20 -19
  284. package/dist/cli-bundle/chunks/{register-setup-ZHJI2DI3.js.map → register-setup-ABA2JPWO.js.map} +2 -2
  285. package/dist/cli-bundle/chunks/{register-setup-JIMPKJKV.js → register-setup-JRZ4UMWZ.js} +21 -20
  286. package/dist/cli-bundle/chunks/register-setup-JRZ4UMWZ.js.map +1 -0
  287. package/dist/cli-bundle/chunks/restore-3JRX27QW.js +17 -0
  288. package/dist/cli-bundle/chunks/{restore-PBL6T5TW.js → restore-K72ZNPEP.js} +11 -11
  289. package/dist/cli-bundle/chunks/{schema-2NOO6NGB.js → schema-3VKRDBLC.js} +76 -20
  290. package/dist/cli-bundle/chunks/schema-3VKRDBLC.js.map +7 -0
  291. package/dist/cli-bundle/chunks/{schema-EBI4NLUO.js → schema-UL4B2JX5.js} +77 -21
  292. package/dist/cli-bundle/chunks/schema-UL4B2JX5.js.map +1 -0
  293. package/dist/cli-bundle/chunks/{search-OA6JX27A.js → search-632WJ7GO.js} +516 -41
  294. package/dist/cli-bundle/chunks/search-632WJ7GO.js.map +7 -0
  295. package/dist/cli-bundle/chunks/{search-JPUQTVCY.js → search-EQDHSE4G.js} +510 -42
  296. package/dist/cli-bundle/chunks/search-EQDHSE4G.js.map +1 -0
  297. package/dist/cli-bundle/chunks/{stats-XYB6KTFG.js → stats-O4UTMJMC.js} +7 -7
  298. package/dist/cli-bundle/chunks/{stats-CV54BAWY.js → stats-WLJ3XBF5.js} +7 -7
  299. package/dist/cli-bundle/chunks/{telemetry-LMJ7PFUO.js → telemetry-EUVHFSQU.js} +4 -4
  300. package/dist/cli-bundle/chunks/{telemetry-NCMEPJNR.js → telemetry-NRVWX25E.js} +4 -4
  301. package/dist/cli-bundle/chunks/{test-WBROAJIE.js → test-GXUBQNUC.js} +14 -13
  302. package/dist/cli-bundle/chunks/test-XN7RJL5Z.js +32 -0
  303. package/dist/cli-bundle/chunks/{test-all-N6NSRDTV.js → test-all-UTFXC7S2.js} +16 -15
  304. package/dist/cli-bundle/chunks/{test-all-N6NSRDTV.js.map → test-all-UTFXC7S2.js.map} +1 -1
  305. package/dist/cli-bundle/chunks/{test-all-NTOZ7C3M.js → test-all-XM6OKI3L.js} +14 -13
  306. package/dist/cli-bundle/chunks/{test-all-NTOZ7C3M.js.map → test-all-XM6OKI3L.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/{test-runs-V6A7LPWZ.js → test-runs-7FHCPEA3.js} +5 -5
  308. package/dist/cli-bundle/chunks/{test-runs-WMVTQU3Y.js → test-runs-IK6E2HNX.js} +5 -5
  309. package/dist/cli-bundle/chunks/update-LFBSEW3N.js +21 -0
  310. package/dist/cli-bundle/chunks/update-U4B4OMHZ.js +25 -0
  311. package/dist/cli-bundle/chunks/{update-many-KGGEYABR.js → update-many-5KD33MKY.js} +22 -22
  312. package/dist/cli-bundle/chunks/{update-many-EM6OXYGO.js → update-many-N3YTM7K4.js} +22 -22
  313. package/dist/cli-bundle/chunks/{upgrade-BLI7XBAJ.js → upgrade-5SRFLUNW.js} +8 -14
  314. package/dist/cli-bundle/chunks/upgrade-5SRFLUNW.js.map +7 -0
  315. package/dist/cli-bundle/chunks/{upgrade-LXPOQKFV.js → upgrade-FFXGO43H.js} +9 -15
  316. package/dist/cli-bundle/chunks/upgrade-FFXGO43H.js.map +1 -0
  317. package/dist/cli-bundle/chunks/{validate-L5J6A7YO.js → validate-CRWXZILW.js} +20 -19
  318. package/dist/cli-bundle/chunks/{validate-L5J6A7YO.js.map → validate-CRWXZILW.js.map} +1 -1
  319. package/dist/cli-bundle/chunks/{validate-AGOAUOVW.js → validate-T3LPWSZG.js} +18 -17
  320. package/dist/cli-bundle/chunks/{validate-AGOAUOVW.js.map → validate-T3LPWSZG.js.map} +1 -1
  321. package/dist/cli-bundle/main.js +160 -87
  322. package/dist/cli-bundle/main.js.map +3 -3
  323. package/dist/core/config/nested-settings.d.ts +8 -8
  324. package/dist/core/config/nested-settings.js +71 -7
  325. package/dist/core/config/nested-settings.js.map +1 -1
  326. package/dist/core/config/positional-value.js +4 -2
  327. package/dist/core/config/positional-value.js.map +1 -1
  328. package/dist/core/diagnostics/remediation.js +7 -2
  329. package/dist/core/diagnostics/remediation.js.map +1 -1
  330. package/dist/core/extensions/extension-types.d.ts +36 -0
  331. package/dist/core/extensions/extension-types.js +2 -2
  332. package/dist/core/extensions/extension-types.js.map +1 -1
  333. package/dist/core/extensions/loader.js +46 -5
  334. package/dist/core/extensions/loader.js.map +1 -1
  335. package/dist/core/fs/fs-utils.js +29 -4
  336. package/dist/core/fs/fs-utils.js.map +1 -1
  337. package/dist/core/history/drift-scan.d.ts +3 -4
  338. package/dist/core/history/drift-scan.js +71 -18
  339. package/dist/core/history/drift-scan.js.map +1 -1
  340. package/dist/core/item/id.js +4 -5
  341. package/dist/core/item/id.js.map +1 -1
  342. package/dist/core/item/item-format.js +7 -3
  343. package/dist/core/item/item-format.js.map +1 -1
  344. package/dist/core/item/toon-decode.d.ts +7 -0
  345. package/dist/core/item/toon-decode.js +11 -2
  346. package/dist/core/item/toon-decode.js.map +1 -1
  347. package/dist/core/item/type-registry.js +25 -7
  348. package/dist/core/item/type-registry.js.map +1 -1
  349. package/dist/core/packages/root.d.ts +10 -0
  350. package/dist/core/packages/root.js +24 -2
  351. package/dist/core/packages/root.js.map +1 -1
  352. package/dist/core/schema/runtime-schema.js +3 -6
  353. package/dist/core/schema/runtime-schema.js.map +1 -1
  354. package/dist/core/search/background-refresh.d.ts +0 -8
  355. package/dist/core/search/background-refresh.js +2 -9
  356. package/dist/core/search/background-refresh.js.map +1 -1
  357. package/dist/core/search/cache.js +5 -3
  358. package/dist/core/search/cache.js.map +1 -1
  359. package/dist/core/search/corpus.d.ts +6 -0
  360. package/dist/core/search/corpus.js +22 -9
  361. package/dist/core/search/corpus.js.map +1 -1
  362. package/dist/core/search/embedding-batches.js +10 -7
  363. package/dist/core/search/embedding-batches.js.map +1 -1
  364. package/dist/core/search/relevance.d.ts +29 -0
  365. package/dist/core/search/relevance.js +226 -0
  366. package/dist/core/search/relevance.js.map +1 -0
  367. package/dist/core/search/vector-stores.d.ts +3 -0
  368. package/dist/core/search/vector-stores.js +27 -16
  369. package/dist/core/search/vector-stores.js.map +1 -1
  370. package/dist/core/sentry/instrument.js +4 -17
  371. package/dist/core/sentry/instrument.js.map +1 -1
  372. package/dist/core/shared/constants.js +15 -2
  373. package/dist/core/shared/constants.js.map +1 -1
  374. package/dist/core/shared/errors.d.ts +6 -0
  375. package/dist/core/shared/errors.js +2 -2
  376. package/dist/core/shared/errors.js.map +1 -1
  377. package/dist/core/shared/primitives.d.ts +8 -0
  378. package/dist/core/shared/primitives.js +29 -2
  379. package/dist/core/shared/primitives.js.map +1 -1
  380. package/dist/core/shared/time.js +42 -6
  381. package/dist/core/shared/time.js.map +1 -1
  382. package/dist/core/store/paths.js +40 -8
  383. package/dist/core/store/paths.js.map +1 -1
  384. package/dist/core/store/settings-validator.d.ts +11 -0
  385. package/dist/core/store/settings-validator.js +14 -2
  386. package/dist/core/store/settings-validator.js.map +1 -1
  387. package/dist/core/store/settings.js +109 -12
  388. package/dist/core/store/settings.js.map +1 -1
  389. package/dist/core/telemetry/runtime.d.ts +1 -0
  390. package/dist/core/telemetry/runtime.js +86 -5
  391. package/dist/core/telemetry/runtime.js.map +1 -1
  392. package/dist/mcp/server.js +109 -19
  393. package/dist/mcp/server.js.map +1 -1
  394. package/dist/sdk/cli-contracts/commander-types.d.ts +1 -0
  395. package/dist/sdk/cli-contracts/commander-types.js +15 -4
  396. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  397. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  398. package/dist/sdk/cli-contracts/enum-contracts.js +6 -2
  399. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  400. package/dist/sdk/cli-contracts/tool-option-contracts.js +7 -2
  401. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  402. package/dist/sdk/cli-contracts/tool-parameter-tables.js +32 -3
  403. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  404. package/dist/sdk/cli-contracts.d.ts +3 -1
  405. package/dist/sdk/cli-contracts.js +44 -12
  406. package/dist/sdk/cli-contracts.js.map +1 -1
  407. package/dist/sdk/index.d.ts +2 -2
  408. package/dist/sdk/index.js +3 -3
  409. package/dist/sdk/index.js.map +1 -1
  410. package/dist/sdk/testing.d.ts +51 -1
  411. package/dist/sdk/testing.js +93 -2
  412. package/dist/sdk/testing.js.map +1 -1
  413. package/dist/types.d.ts +14 -0
  414. package/dist/types.js +2 -2
  415. package/dist/types.js.map +1 -1
  416. package/docs/AGENT_GUIDE.md +3 -1
  417. package/docs/CLAUDE_CODE_PLUGIN.md +4 -4
  418. package/docs/CODEX_PLUGIN.md +1 -1
  419. package/docs/COMMANDS.md +14 -5
  420. package/docs/CONFIGURATION.md +28 -1
  421. package/docs/EXTENSIONS.md +17 -9
  422. package/docs/QUICKSTART.md +1 -1
  423. package/docs/RELEASING.md +17 -0
  424. package/docs/SDK.md +66 -0
  425. package/docs/TESTING.md +14 -0
  426. package/marketplace.json +1 -1
  427. package/package.json +2 -1
  428. package/packages/pm-governance-audit/README.md +14 -0
  429. package/packages/pm-governance-audit/extensions/governance-audit/index.js +39 -1
  430. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +40 -2
  431. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +1 -1
  432. package/packages/pm-governance-audit/package.json +4 -2
  433. package/packages/pm-lifecycle-hooks/README.md +21 -0
  434. package/packages/pm-search-advanced/README.md +38 -0
  435. package/packages/pm-search-advanced/extensions/search-advanced/index.js +17 -0
  436. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +17 -0
  437. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +216 -1
  438. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +271 -2
  439. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  440. package/plugins/pm-claude/README.md +7 -7
  441. package/plugins/pm-claude/commands/pm-init.md +1 -1
  442. package/plugins/pm-codex/README.md +1 -1
  443. package/dist/cli-bundle/chunks/activity-CVXTCHYY.js +0 -16
  444. package/dist/cli-bundle/chunks/aggregate-GI7WSZPH.js.map +0 -1
  445. package/dist/cli-bundle/chunks/aggregate-VNAHUNNF.js.map +0 -7
  446. package/dist/cli-bundle/chunks/chunk-2VBQ6ZXS.js.map +0 -1
  447. package/dist/cli-bundle/chunks/chunk-3FI4SEFT.js.map +0 -7
  448. package/dist/cli-bundle/chunks/chunk-3LB74A67.js.map +0 -7
  449. package/dist/cli-bundle/chunks/chunk-4LL6TK5B.js.map +0 -1
  450. package/dist/cli-bundle/chunks/chunk-52MAOQ6J.js.map +0 -7
  451. package/dist/cli-bundle/chunks/chunk-5FDATVEZ.js.map +0 -1
  452. package/dist/cli-bundle/chunks/chunk-5SFCOO6B.js.map +0 -1
  453. package/dist/cli-bundle/chunks/chunk-AY43SBIN.js.map +0 -1
  454. package/dist/cli-bundle/chunks/chunk-ECCMVXGM.js.map +0 -7
  455. package/dist/cli-bundle/chunks/chunk-FRAUKRU2.js.map +0 -1
  456. package/dist/cli-bundle/chunks/chunk-GU2ZJ2VV.js.map +0 -7
  457. package/dist/cli-bundle/chunks/chunk-HZGUAH22.js.map +0 -1
  458. package/dist/cli-bundle/chunks/chunk-IOR7LGF4.js.map +0 -1
  459. package/dist/cli-bundle/chunks/chunk-KJE2FOS4.js.map +0 -7
  460. package/dist/cli-bundle/chunks/chunk-KWU6HG75.js.map +0 -1
  461. package/dist/cli-bundle/chunks/chunk-LB3RUL2N.js.map +0 -1
  462. package/dist/cli-bundle/chunks/chunk-PDDFYW4X.js.map +0 -7
  463. package/dist/cli-bundle/chunks/chunk-PROOHX4K.js.map +0 -7
  464. package/dist/cli-bundle/chunks/chunk-Q7SPNHLW.js.map +0 -7
  465. package/dist/cli-bundle/chunks/chunk-QO7EBBOM.js.map +0 -7
  466. package/dist/cli-bundle/chunks/chunk-SKJWX3QB.js.map +0 -7
  467. package/dist/cli-bundle/chunks/chunk-T3LC5LKB.js.map +0 -7
  468. package/dist/cli-bundle/chunks/chunk-TCD3R2PF.js.map +0 -1
  469. package/dist/cli-bundle/chunks/chunk-TPH5XEVD.js.map +0 -1
  470. package/dist/cli-bundle/chunks/chunk-U5SXYXSY.js.map +0 -7
  471. package/dist/cli-bundle/chunks/chunk-W7XABV4H.js.map +0 -1
  472. package/dist/cli-bundle/chunks/chunk-WOPXVEZP.js.map +0 -1
  473. package/dist/cli-bundle/chunks/close-3HDWDA3L.js +0 -13
  474. package/dist/cli-bundle/chunks/close-many-7CGIDPTJ.js.map +0 -7
  475. package/dist/cli-bundle/chunks/close-many-ERFO6LHR.js.map +0 -1
  476. package/dist/cli-bundle/chunks/config-6FXCQKIF.js.map +0 -1
  477. package/dist/cli-bundle/chunks/config-U4RZ4CQB.js.map +0 -7
  478. package/dist/cli-bundle/chunks/context-YMJ3Z2HQ.js.map +0 -1
  479. package/dist/cli-bundle/chunks/contracts-QDB6OMLQ.js.map +0 -1
  480. package/dist/cli-bundle/chunks/contracts-RFSPGVVJ.js.map +0 -7
  481. package/dist/cli-bundle/chunks/create-JTZNCTQC.js +0 -27
  482. package/dist/cli-bundle/chunks/gc-JDVJ6OQ2.js.map +0 -1
  483. package/dist/cli-bundle/chunks/gc-ULPVWMTN.js.map +0 -7
  484. package/dist/cli-bundle/chunks/get-RV37HT3G.js.map +0 -1
  485. package/dist/cli-bundle/chunks/get-WXU6WI5P.js.map +0 -7
  486. package/dist/cli-bundle/chunks/health-6L6EH4WR.js.map +0 -7
  487. package/dist/cli-bundle/chunks/health-LOI2HHKB.js.map +0 -1
  488. package/dist/cli-bundle/chunks/history-2BA3T5AE.js +0 -20
  489. package/dist/cli-bundle/chunks/history-redact-JBZNXHGR.js +0 -19
  490. package/dist/cli-bundle/chunks/init-HIVSNX3O.js +0 -16
  491. package/dist/cli-bundle/chunks/list-MUSQNMTD.js +0 -20
  492. package/dist/cli-bundle/chunks/register-list-query-POCFZ5JW.js.map +0 -1
  493. package/dist/cli-bundle/chunks/register-list-query-WST76HSQ.js.map +0 -7
  494. package/dist/cli-bundle/chunks/register-mutation-N5GSUZJV.js.map +0 -1
  495. package/dist/cli-bundle/chunks/register-mutation-OA675SOU.js.map +0 -7
  496. package/dist/cli-bundle/chunks/register-operations-GNHBE5I3.js.map +0 -1
  497. package/dist/cli-bundle/chunks/register-operations-N3PMHXH5.js.map +0 -7
  498. package/dist/cli-bundle/chunks/register-setup-JIMPKJKV.js.map +0 -1
  499. package/dist/cli-bundle/chunks/restore-D4RGNX33.js +0 -17
  500. package/dist/cli-bundle/chunks/schema-2NOO6NGB.js.map +0 -7
  501. package/dist/cli-bundle/chunks/schema-EBI4NLUO.js.map +0 -1
  502. package/dist/cli-bundle/chunks/search-JPUQTVCY.js.map +0 -1
  503. package/dist/cli-bundle/chunks/search-OA6JX27A.js.map +0 -7
  504. package/dist/cli-bundle/chunks/test-MXX3E5JL.js +0 -31
  505. package/dist/cli-bundle/chunks/update-OSV3NAQB.js +0 -25
  506. package/dist/cli-bundle/chunks/update-YRXSUGYQ.js +0 -21
  507. package/dist/cli-bundle/chunks/upgrade-BLI7XBAJ.js.map +0 -7
  508. package/dist/cli-bundle/chunks/upgrade-LXPOQKFV.js.map +0 -1
  509. /package/dist/cli-bundle/chunks/{activity-CVXTCHYY.js.map → activity-A3QKFSSF.js.map} +0 -0
  510. /package/dist/cli-bundle/chunks/{activity-JM6DTDND.js.map → activity-Q7XMIZIH.js.map} +0 -0
  511. /package/dist/cli-bundle/chunks/{append-WMKRXKCE.js.map → append-3RFOU7P5.js.map} +0 -0
  512. /package/dist/cli-bundle/chunks/{append-7H5N64R2.js.map → append-OM74OJVT.js.map} +0 -0
  513. /package/dist/cli-bundle/chunks/{chunk-XTGLRY2Y.js.map → chunk-2HMD3JM2.js.map} +0 -0
  514. /package/dist/cli-bundle/chunks/{chunk-PRJCELV4.js.map → chunk-2YPVCD7T.js.map} +0 -0
  515. /package/dist/cli-bundle/chunks/{chunk-2HVRUSQA.js.map → chunk-4WYBLB6J.js.map} +0 -0
  516. /package/dist/cli-bundle/chunks/{chunk-R6UFP2GE.js.map → chunk-5NVJA7IW.js.map} +0 -0
  517. /package/dist/cli-bundle/chunks/{chunk-XSJCLN2R.js.map → chunk-AEMKH5WQ.js.map} +0 -0
  518. /package/dist/cli-bundle/chunks/{chunk-6ER6DXH5.js.map → chunk-AXBUHLW7.js.map} +0 -0
  519. /package/dist/cli-bundle/chunks/{chunk-BQHUILZS.js.map → chunk-BFJPMUF5.js.map} +0 -0
  520. /package/dist/cli-bundle/chunks/{chunk-I6BNFU5X.js.map → chunk-BKQMJXWY.js.map} +0 -0
  521. /package/dist/cli-bundle/chunks/{chunk-XLTD2HN3.js.map → chunk-CBJXWXI5.js.map} +0 -0
  522. /package/dist/cli-bundle/chunks/{chunk-3BWOVLTH.js.map → chunk-EPWT7BEA.js.map} +0 -0
  523. /package/dist/cli-bundle/chunks/{chunk-NUZ5HKR4.js.map → chunk-F33VC5EX.js.map} +0 -0
  524. /package/dist/cli-bundle/chunks/{chunk-WKY2IBOQ.js.map → chunk-FGRJZVXD.js.map} +0 -0
  525. /package/dist/cli-bundle/chunks/{chunk-77GFDHGF.js.map → chunk-FO2TYSQZ.js.map} +0 -0
  526. /package/dist/cli-bundle/chunks/{chunk-GXSUPCBV.js.map → chunk-HOA3GMB6.js.map} +0 -0
  527. /package/dist/cli-bundle/chunks/{chunk-OVQCEJPG.js.map → chunk-HP35AVFS.js.map} +0 -0
  528. /package/dist/cli-bundle/chunks/{chunk-KJ33AOCY.js.map → chunk-J4DKAGTM.js.map} +0 -0
  529. /package/dist/cli-bundle/chunks/{chunk-ME2YH6FN.js.map → chunk-JS47EKLP.js.map} +0 -0
  530. /package/dist/cli-bundle/chunks/{chunk-I2HSTRJF.js.map → chunk-KN4WSESY.js.map} +0 -0
  531. /package/dist/cli-bundle/chunks/{chunk-RZN6VURO.js.map → chunk-KP4KIUQT.js.map} +0 -0
  532. /package/dist/cli-bundle/chunks/{chunk-MITFDD35.js.map → chunk-KVXIQDJG.js.map} +0 -0
  533. /package/dist/cli-bundle/chunks/{chunk-IJGCZSIQ.js.map → chunk-L3LYL3ID.js.map} +0 -0
  534. /package/dist/cli-bundle/chunks/{chunk-UM2GBHS4.js.map → chunk-MSH23UWO.js.map} +0 -0
  535. /package/dist/cli-bundle/chunks/{chunk-LCM63IXU.js.map → chunk-N4SQZ7L3.js.map} +0 -0
  536. /package/dist/cli-bundle/chunks/{chunk-3VAM3NNM.js.map → chunk-NDSMKB2I.js.map} +0 -0
  537. /package/dist/cli-bundle/chunks/{chunk-6P6GGMOG.js.map → chunk-NGEEXR2R.js.map} +0 -0
  538. /package/dist/cli-bundle/chunks/{chunk-PO3GSVFV.js.map → chunk-NLVCMVC7.js.map} +0 -0
  539. /package/dist/cli-bundle/chunks/{chunk-N7ACFE26.js.map → chunk-NUKHZZNM.js.map} +0 -0
  540. /package/dist/cli-bundle/chunks/{chunk-GGYWB3Y2.js.map → chunk-ODN53S6H.js.map} +0 -0
  541. /package/dist/cli-bundle/chunks/{chunk-23YFZ3IG.js.map → chunk-OTY2YEH5.js.map} +0 -0
  542. /package/dist/cli-bundle/chunks/{chunk-2RSPZI5H.js.map → chunk-OVSSE2JP.js.map} +0 -0
  543. /package/dist/cli-bundle/chunks/{chunk-2VVCGBNV.js.map → chunk-QF4OPBAG.js.map} +0 -0
  544. /package/dist/cli-bundle/chunks/{chunk-WSMOSYRD.js.map → chunk-QQPZYP73.js.map} +0 -0
  545. /package/dist/cli-bundle/chunks/{chunk-OZ7NSQHL.js.map → chunk-QWNUDGFQ.js.map} +0 -0
  546. /package/dist/cli-bundle/chunks/{chunk-GCOQW437.js.map → chunk-SDLEYY6A.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{chunk-PIU6RSL3.js.map → chunk-TBLBEOEX.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-YL2DJGYS.js.map → chunk-UEXNNF3K.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-UBOPJT3S.js.map → chunk-UMMJAJB2.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-KAG77BY3.js.map → chunk-XLSQ3QLT.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-E5FJNAZA.js.map → chunk-XNGMIVQY.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-RWPSOIEE.js.map → chunk-YEFOCDIK.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{claim-4DBF6RVG.js.map → claim-NHBIIBOW.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{claim-X2P4IB7J.js.map → claim-RNEBQCOO.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{close-3HDWDA3L.js.map → close-UNTFXVM3.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{close-PTYFA45H.js.map → close-ZMXL2WDS.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{comments-QKBYCWKD.js.map → comments-EFVBHWPT.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{comments-OONGABK5.js.map → comments-J5Q4IJPH.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{create-JTZNCTQC.js.map → create-EZWAMUKR.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{create-I5L4EYYZ.js.map → create-PUAIJEZ7.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{delete-7HPGI4GZ.js.map → delete-PKR2JHLH.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{delete-VXUPH5RS.js.map → delete-WBME6WG5.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{deps-JSRRWC3Z.js.map → deps-4BQEDV4L.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{deps-SCZIFK2Z.js.map → deps-KWHQRO75.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{docs-GJK6K4VP.js.map → docs-364GT3ZR.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{docs-WW4N3MBM.js.map → docs-SCNBUGSV.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{extension-VDY2U33M.js.map → extension-CRE7JM47.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{extension-J7IBMFTD.js.map → extension-KK2UPXJD.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{files-ISZJGILQ.js.map → files-3GESQAWL.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{files-WKOD326U.js.map → files-66EHM5ZR.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{history-PKN67D5O.js.map → history-TJTO5GCR.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{history-2BA3T5AE.js.map → history-ZERISU2L.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{history-redact-JBZNXHGR.js.map → history-redact-GODBYT5A.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{history-redact-V4FOJGS7.js.map → history-redact-JUXUOH54.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{history-repair-HIBCBIKK.js.map → history-repair-CCCPBNTF.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{history-repair-SDMHR7JT.js.map → history-repair-TDBBSRVK.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{init-P56QYWJF.js.map → init-6ZPKD3YN.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{init-HIVSNX3O.js.map → init-CBZHXBR3.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{learnings-MIXSESLK.js.map → learnings-U7U2FNIO.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{learnings-GDFRG5J7.js.map → learnings-WYNTYQ5T.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{list-MUSQNMTD.js.map → list-7MTPPZHC.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{list-FGOWQMSM.js.map → list-JGP7ODML.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{notes-5UK3GEH2.js.map → notes-P25YVTEG.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{notes-4XVSH2AZ.js.map → notes-QIF6A7XS.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{plan-DUMBV3QB.js.map → plan-RACB5PI6.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{plan-SLMODHWX.js.map → plan-SSBJFWXA.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{restore-D4RGNX33.js.map → restore-3JRX27QW.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{restore-PBL6T5TW.js.map → restore-K72ZNPEP.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{stats-XYB6KTFG.js.map → stats-O4UTMJMC.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{stats-CV54BAWY.js.map → stats-WLJ3XBF5.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{telemetry-LMJ7PFUO.js.map → telemetry-EUVHFSQU.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{telemetry-NCMEPJNR.js.map → telemetry-NRVWX25E.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{test-WBROAJIE.js.map → test-GXUBQNUC.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{test-MXX3E5JL.js.map → test-XN7RJL5Z.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{test-runs-V6A7LPWZ.js.map → test-runs-7FHCPEA3.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{test-runs-WMVTQU3Y.js.map → test-runs-IK6E2HNX.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{update-YRXSUGYQ.js.map → update-LFBSEW3N.js.map} +0 -0
  598. /package/dist/cli-bundle/chunks/{update-OSV3NAQB.js.map → update-U4B4OMHZ.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{update-many-KGGEYABR.js.map → update-many-5KD33MKY.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{update-many-EM6OXYGO.js.map → update-many-N3YTM7K4.js.map} +0 -0
@@ -1,6 +1,6 @@
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]="24293159-379b-5416-a184-9ed7ef02ca92")}catch(e){}}();
3
- import fs from "node:fs/promises";
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]="8b4dd1a6-7645-5c6e-afd3-f4c23fe19182")}catch(e){}}();
3
+ import * as fs from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import crypto from "node:crypto";
6
6
  export async function ensureDir(dirPath) {
@@ -31,7 +31,32 @@ export async function writeFileAtomic(targetPath, contents) {
31
31
  await ensureDir(dirPath);
32
32
  const tempPath = path.join(dirPath, `.${path.basename(targetPath)}.${process.pid}.${Date.now()}.${crypto.randomBytes(4).toString("hex")}.tmp`);
33
33
  await fs.writeFile(tempPath, contents, "utf8");
34
- await fs.rename(tempPath, targetPath);
34
+ try {
35
+ await fs.rename(tempPath, targetPath);
36
+ }
37
+ catch (error) {
38
+ if (isErrno(error, "EXDEV")) {
39
+ try {
40
+ await fs.copyFile(tempPath, targetPath);
41
+ }
42
+ finally {
43
+ try {
44
+ await fs.unlink(tempPath);
45
+ }
46
+ catch {
47
+ // Best-effort cleanup only.
48
+ }
49
+ }
50
+ return;
51
+ }
52
+ try {
53
+ await fs.unlink(tempPath);
54
+ }
55
+ catch {
56
+ // Best-effort cleanup only.
57
+ }
58
+ throw error;
59
+ }
35
60
  }
36
61
  export async function appendLineAtomic(targetPath, line) {
37
62
  const dirPath = path.dirname(targetPath);
@@ -58,4 +83,4 @@ function isErrno(error, code) {
58
83
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
59
84
  }
60
85
  //# sourceMappingURL=fs-utils.js.map
61
- //# debugId=24293159-379b-5416-a184-9ed7ef02ca92
86
+ //# debugId=8b4dd1a6-7645-5c6e-afd3-f4c23fe19182
@@ -1 +1 @@
1
- {"version":3,"file":"fs-utils.js","sources":["core/fs/fs-utils.ts"],"sourceRoot":"/","sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\n\nexport async function ensureDir(dirPath: string): Promise<void> {\n await fs.mkdir(dirPath, { recursive: true });\n}\n\nexport async function pathExists(targetPath: string): Promise<boolean> {\n try {\n await fs.access(targetPath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readFileIfExists(targetPath: string): Promise<string | null> {\n try {\n return await fs.readFile(targetPath, \"utf8\");\n } catch (error: unknown) {\n if (isErrno(error, \"ENOENT\")) {\n return null;\n }\n throw error;\n }\n}\n\nexport async function writeFileAtomic(targetPath: string, contents: string): Promise<void> {\n const dirPath = path.dirname(targetPath);\n await ensureDir(dirPath);\n const tempPath = path.join(\n dirPath,\n `.${path.basename(targetPath)}.${process.pid}.${Date.now()}.${crypto.randomBytes(4).toString(\"hex\")}.tmp`,\n );\n await fs.writeFile(tempPath, contents, \"utf8\");\n await fs.rename(tempPath, targetPath);\n}\n\nexport async function appendLineAtomic(targetPath: string, line: string): Promise<void> {\n const dirPath = path.dirname(targetPath);\n await ensureDir(dirPath);\n const handle = await fs.open(targetPath, \"a\");\n try {\n await handle.writeFile(`${line}\\n`, \"utf8\");\n } finally {\n await handle.close();\n }\n}\n\nexport async function removeFileIfExists(targetPath: string): Promise<void> {\n try {\n await fs.unlink(targetPath);\n } catch (error: unknown) {\n if (!isErrno(error, \"ENOENT\")) {\n throw error;\n }\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAe;IAC7C,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;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AAC,GAAG,IAAI,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IACzD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,IAAY;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAK,KAA2B,CAAC,IAAI,KAAK,IAAI,CAAC;AACtH,CAAC","debugId":"24293159-379b-5416-a184-9ed7ef02ca92"}
1
+ {"version":3,"file":"fs-utils.js","sources":["core/fs/fs-utils.ts"],"sourceRoot":"/","sourcesContent":["import * as fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\n\nexport async function ensureDir(dirPath: string): Promise<void> {\n await fs.mkdir(dirPath, { recursive: true });\n}\n\nexport async function pathExists(targetPath: string): Promise<boolean> {\n try {\n await fs.access(targetPath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readFileIfExists(targetPath: string): Promise<string | null> {\n try {\n return await fs.readFile(targetPath, \"utf8\");\n } catch (error: unknown) {\n if (isErrno(error, \"ENOENT\")) {\n return null;\n }\n throw error;\n }\n}\n\nexport async function writeFileAtomic(targetPath: string, contents: string): Promise<void> {\n const dirPath = path.dirname(targetPath);\n await ensureDir(dirPath);\n const tempPath = path.join(\n dirPath,\n `.${path.basename(targetPath)}.${process.pid}.${Date.now()}.${crypto.randomBytes(4).toString(\"hex\")}.tmp`,\n );\n await fs.writeFile(tempPath, contents, \"utf8\");\n try {\n await fs.rename(tempPath, targetPath);\n } catch (error: unknown) {\n if (isErrno(error, \"EXDEV\")) {\n try {\n await fs.copyFile(tempPath, targetPath);\n } finally {\n try {\n await fs.unlink(tempPath);\n } catch {\n // Best-effort cleanup only.\n }\n }\n return;\n }\n try {\n await fs.unlink(tempPath);\n } catch {\n // Best-effort cleanup only.\n }\n throw error;\n }\n}\n\nexport async function appendLineAtomic(targetPath: string, line: string): Promise<void> {\n const dirPath = path.dirname(targetPath);\n await ensureDir(dirPath);\n const handle = await fs.open(targetPath, \"a\");\n try {\n await handle.writeFile(`${line}\\n`, \"utf8\");\n } finally {\n await handle.close();\n }\n}\n\nexport async function removeFileIfExists(targetPath: string): Promise<void> {\n try {\n await fs.unlink(targetPath);\n } catch (error: unknown) {\n if (!isErrno(error, \"ENOENT\")) {\n throw error;\n }\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAe;IAC7C,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAkB;IACvD,IAAI,CAAC;QACH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I,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,4BAA4B;QAC9B,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAkB,EAAE,IAAY;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;IACzB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IACzD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC9B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,IAAY;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAK,KAA2B,CAAC,IAAI,KAAK,IAAI,CAAC;AACtH,CAAC","debugId":"8b4dd1a6-7645-5c6e-afd3-f4c23fe19182"}
@@ -12,10 +12,9 @@ export interface DriftScanResult {
12
12
  *
13
13
  * Full chain re-verification of a 17MB+ history tree is the dominant cost of
14
14
  * `pm health`. We cache the per-stream verification keyed by the history file's
15
- * mtime/size: an unchanged file has an identical chain and latest stored hash, so
16
- * we skip re-reading and re-hashing it. Item-side changes are still caught every
17
- * run because the current document hash is recomputed and compared to the cached
18
- * `latest_after_hash`.
15
+ * mtime/ctime/size + content hash: metadata-stable replacements (same stat tuple)
16
+ * can still happen, so each metadata hit recomputes a content hash guard before
17
+ * trusting the cached chain/hash verification.
19
18
  */
20
19
  export declare function scanHistoryDrift(pmRoot: string, items: Array<ItemMetadata & {
21
20
  body: string;
@@ -1,12 +1,13 @@
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]="e8559b46-0199-506f-bf98-8f92a4474215")}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]="0dd4c4e6-9086-5afb-814b-38d0b36d4283")}catch(e){}}();
3
3
  import fs from "fs/promises";
4
+ import { createHash } from "node:crypto";
4
5
  import path from "node:path";
5
6
  import { getHistoryPath } from "../store/paths.js";
6
7
  import { writeFileAtomic } from "../fs/fs-utils.js";
7
8
  import { hashDocument } from "./history.js";
8
9
  import { verifyHistoryChain } from "./replay.js";
9
- const DRIFT_CACHE_VERSION = 1;
10
+ const DRIFT_CACHE_VERSION = 2;
10
11
  const DRIFT_CACHE_FILENAME = "history-drift-cache.json";
11
12
  function getDriftCachePath(pmRoot) {
12
13
  return path.join(pmRoot, "runtime", DRIFT_CACHE_FILENAME);
@@ -27,12 +28,20 @@ async function loadDriftCache(pmRoot) {
27
28
  function isErrno(error, code) {
28
29
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
29
30
  }
31
+ function hashContent(raw) {
32
+ return createHash("sha256").update(raw).digest("hex");
33
+ }
34
+ async function readHistoryContentHash(historyPath) {
35
+ const raw = await fs.readFile(historyPath, "utf8");
36
+ return hashContent(raw);
37
+ }
30
38
  /**
31
39
  * Read and fully verify one history stream's hash chain. Returns null for an
32
40
  * empty/missing stream (caller records it as a missing stream).
33
41
  */
34
42
  async function verifyHistoryStream(historyPath) {
35
43
  const raw = await fs.readFile(historyPath, "utf8");
44
+ const contentHash = hashContent(raw);
36
45
  if (raw.trim().length === 0) {
37
46
  return null;
38
47
  }
@@ -55,7 +64,11 @@ async function verifyHistoryStream(historyPath) {
55
64
  return null;
56
65
  }
57
66
  /* c8 ignore stop */
58
- return { latestAfterHash, chainOk: verifyHistoryChain(entries).ok };
67
+ return {
68
+ latestAfterHash,
69
+ chainOk: verifyHistoryChain(entries).ok,
70
+ contentHash,
71
+ };
59
72
  }
60
73
  /**
61
74
  * Scan every item's history stream for drift (missing/unreadable streams, broken
@@ -63,10 +76,9 @@ async function verifyHistoryStream(historyPath) {
63
76
  *
64
77
  * Full chain re-verification of a 17MB+ history tree is the dominant cost of
65
78
  * `pm health`. We cache the per-stream verification keyed by the history file's
66
- * mtime/size: an unchanged file has an identical chain and latest stored hash, so
67
- * we skip re-reading and re-hashing it. Item-side changes are still caught every
68
- * run because the current document hash is recomputed and compared to the cached
69
- * `latest_after_hash`.
79
+ * mtime/ctime/size + content hash: metadata-stable replacements (same stat tuple)
80
+ * can still happen, so each metadata hit recomputes a content hash guard before
81
+ * trusting the cached chain/hash verification.
70
82
  */
71
83
  export async function scanHistoryDrift(pmRoot, items) {
72
84
  const missingStreams = [];
@@ -92,26 +104,66 @@ export async function scanHistoryDrift(pmRoot, items) {
92
104
  }
93
105
  continue;
94
106
  }
107
+ const loadStreamVerification = async () => {
108
+ try {
109
+ return await verifyHistoryStream(historyPath);
110
+ }
111
+ catch {
112
+ return "unreadable";
113
+ }
114
+ };
115
+ const loadFreshVerification = async () => {
116
+ const loaded = await loadStreamVerification();
117
+ if (loaded === "unreadable") {
118
+ unreadableStreams.push(item.id);
119
+ return null;
120
+ }
121
+ if (!loaded) {
122
+ missingStreams.push(item.id);
123
+ return null;
124
+ }
125
+ return loaded;
126
+ };
95
127
  const cached = previousEntries[item.id];
96
128
  let verification;
97
- if (cached && cached.mtime_ms === stat.mtimeMs && cached.ctime_ms === stat.ctimeMs && cached.size === stat.size) {
98
- verification = { latestAfterHash: cached.latest_after_hash, chainOk: cached.chain_ok };
99
- }
100
- else {
101
- cacheDirty = true;
102
- let result;
129
+ const metadataMatchesCache = cached !== undefined &&
130
+ cached.mtime_ms === stat.mtimeMs &&
131
+ cached.ctime_ms === stat.ctimeMs &&
132
+ cached.size === stat.size;
133
+ const cachedContentHash = typeof cached?.content_hash === "string" && cached.content_hash.length > 0 ? cached.content_hash : undefined;
134
+ const canUseCache = metadataMatchesCache && cachedContentHash !== undefined;
135
+ if (canUseCache && cached) {
136
+ let currentContentHash;
103
137
  try {
104
- result = await verifyHistoryStream(historyPath);
138
+ currentContentHash = await readHistoryContentHash(historyPath);
105
139
  }
106
140
  catch {
107
141
  unreadableStreams.push(item.id);
108
142
  continue;
109
143
  }
110
- if (!result) {
111
- missingStreams.push(item.id);
144
+ if (currentContentHash === cachedContentHash) {
145
+ verification = {
146
+ latestAfterHash: cached.latest_after_hash,
147
+ chainOk: cached.chain_ok,
148
+ contentHash: currentContentHash,
149
+ };
150
+ }
151
+ else {
152
+ cacheDirty = true;
153
+ const refreshed = await loadFreshVerification();
154
+ if (!refreshed) {
155
+ continue;
156
+ }
157
+ verification = refreshed;
158
+ }
159
+ }
160
+ else {
161
+ cacheDirty = true;
162
+ const refreshed = await loadFreshVerification();
163
+ if (!refreshed) {
112
164
  continue;
113
165
  }
114
- verification = result;
166
+ verification = refreshed;
115
167
  }
116
168
  if (!verification.chainOk) {
117
169
  chainMismatches.push(item.id);
@@ -120,6 +172,7 @@ export async function scanHistoryDrift(pmRoot, items) {
120
172
  mtime_ms: stat.mtimeMs,
121
173
  ctime_ms: stat.ctimeMs,
122
174
  size: stat.size,
175
+ content_hash: verification.contentHash,
123
176
  latest_after_hash: verification.latestAfterHash,
124
177
  chain_ok: verification.chainOk,
125
178
  };
@@ -146,4 +199,4 @@ export async function scanHistoryDrift(pmRoot, items) {
146
199
  return { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems };
147
200
  }
148
201
  //# sourceMappingURL=drift-scan.js.map
149
- //# debugId=e8559b46-0199-506f-bf98-8f92a4474215
202
+ //# debugId=0dd4c4e6-9086-5afb-814b-38d0b36d4283
@@ -1 +1 @@
1
- {"version":3,"file":"drift-scan.js","sources":["core/history/drift-scan.ts"],"sourceRoot":"/","sourcesContent":["import fs from \"fs/promises\";\nimport path from \"node:path\";\nimport { getHistoryPath } from \"../store/paths.js\";\nimport { writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { hashDocument } from \"./history.js\";\nimport { verifyHistoryChain } from \"./replay.js\";\nimport type { HistoryEntry, ItemMetadata } from \"../../types/index.js\";\n\nexport interface DriftScanResult {\n missingStreams: string[];\n unreadableStreams: string[];\n hashMismatches: string[];\n chainMismatches: string[];\n driftedItems: string[];\n}\n\nconst DRIFT_CACHE_VERSION = 1;\nconst DRIFT_CACHE_FILENAME = \"history-drift-cache.json\";\n\ninterface DriftCacheEntry {\n mtime_ms: number;\n ctime_ms: number;\n size: number;\n latest_after_hash: string;\n chain_ok: boolean;\n}\n\ninterface DriftCacheEnvelope {\n version: number;\n entries: Record<string, DriftCacheEntry>;\n}\n\nfunction getDriftCachePath(pmRoot: string): string {\n return path.join(pmRoot, \"runtime\", DRIFT_CACHE_FILENAME);\n}\n\nasync function loadDriftCache(pmRoot: string): Promise<DriftCacheEnvelope | null> {\n try {\n const raw = await fs.readFile(getDriftCachePath(pmRoot), \"utf8\");\n const parsed = JSON.parse(raw) as DriftCacheEnvelope;\n if (parsed.version !== DRIFT_CACHE_VERSION || typeof parsed.entries !== \"object\" || parsed.entries === null) {\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n\ninterface StreamVerification {\n latestAfterHash: string;\n chainOk: boolean;\n}\n\n/**\n * Read and fully verify one history stream's hash chain. Returns null for an\n * empty/missing stream (caller records it as a missing stream).\n */\nasync function verifyHistoryStream(historyPath: string): Promise<StreamVerification | null> {\n const raw = await fs.readFile(historyPath, \"utf8\");\n if (raw.trim().length === 0) {\n return null;\n }\n const entries: HistoryEntry[] = [];\n let latestAfterHash: string | null = null;\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (trimmed.length === 0) {\n continue;\n }\n const parsed = JSON.parse(trimmed) as HistoryEntry;\n if (typeof parsed.after_hash !== \"string\" || parsed.after_hash.trim().length === 0) {\n throw new Error(\"missing after_hash\");\n }\n entries.push(parsed);\n latestAfterHash = parsed.after_hash;\n }\n /* c8 ignore start -- defensive guard for future history schema changes. */\n if (!latestAfterHash) {\n return null;\n }\n /* c8 ignore stop */\n return { latestAfterHash, chainOk: verifyHistoryChain(entries).ok };\n}\n\n/**\n * Scan every item's history stream for drift (missing/unreadable streams, broken\n * hash chains, and item/history hash mismatches).\n *\n * Full chain re-verification of a 17MB+ history tree is the dominant cost of\n * `pm health`. We cache the per-stream verification keyed by the history file's\n * mtime/size: an unchanged file has an identical chain and latest stored hash, so\n * we skip re-reading and re-hashing it. Item-side changes are still caught every\n * run because the current document hash is recomputed and compared to the cached\n * `latest_after_hash`.\n */\nexport async function scanHistoryDrift(\n pmRoot: string,\n items: Array<ItemMetadata & { body: string }>,\n): Promise<DriftScanResult> {\n const missingStreams: string[] = [];\n const unreadableStreams: string[] = [];\n const hashMismatches: string[] = [];\n const chainMismatches: string[] = [];\n\n const cache = await loadDriftCache(pmRoot);\n const previousEntries: Record<string, DriftCacheEntry> = cache?.entries ?? {};\n const nextEntries: Record<string, DriftCacheEntry> = {};\n let cacheDirty = false;\n\n for (const item of items) {\n const historyPath = getHistoryPath(pmRoot, item.id);\n\n let stat: Awaited<ReturnType<typeof fs.stat>>;\n try {\n stat = await fs.stat(historyPath);\n } catch (error: unknown) {\n if (isErrno(error, \"ENOENT\")) {\n missingStreams.push(item.id);\n } else {\n unreadableStreams.push(item.id);\n }\n continue;\n }\n\n const cached = previousEntries[item.id];\n let verification: StreamVerification;\n if (cached && cached.mtime_ms === stat.mtimeMs && cached.ctime_ms === stat.ctimeMs && cached.size === stat.size) {\n verification = { latestAfterHash: cached.latest_after_hash, chainOk: cached.chain_ok };\n } else {\n cacheDirty = true;\n let result: StreamVerification | null;\n try {\n result = await verifyHistoryStream(historyPath);\n } catch {\n unreadableStreams.push(item.id);\n continue;\n }\n if (!result) {\n missingStreams.push(item.id);\n continue;\n }\n verification = result;\n }\n\n if (!verification.chainOk) {\n chainMismatches.push(item.id);\n }\n nextEntries[item.id] = {\n mtime_ms: stat.mtimeMs,\n ctime_ms: stat.ctimeMs,\n size: stat.size,\n latest_after_hash: verification.latestAfterHash,\n chain_ok: verification.chainOk,\n };\n\n const { body, ...frontMatter } = item;\n const currentHash = hashDocument({\n metadata: frontMatter as ItemMetadata,\n body,\n });\n if (currentHash !== verification.latestAfterHash) {\n hashMismatches.push(item.id);\n }\n }\n\n if (cacheDirty || Object.keys(previousEntries).length !== Object.keys(nextEntries).length) {\n const cachePath = getDriftCachePath(pmRoot);\n try {\n await fs.mkdir(path.dirname(cachePath), { recursive: true });\n await writeFileAtomic(cachePath, JSON.stringify({ version: DRIFT_CACHE_VERSION, entries: nextEntries }));\n } catch {\n // Best-effort cache write: a failed persist must never fail a health scan.\n }\n }\n\n const driftedItems = [...new Set([...missingStreams, ...unreadableStreams, ...hashMismatches, ...chainMismatches])].sort((a, b) =>\n a.localeCompare(b),\n );\n return { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems };\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,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AI,EAAE,CAAC,CAAC;YAC7D,MAAM,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QAC3G,CAAC;QAAC,MAAM,CAAC;YACP,2EAA2E;QAC7E,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,iBAAiB,EAAE,GAAG,cAAc,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CACnB,CAAC;IACF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAC9F,CAAC","debugId":"e8559b46-0199-506f-bf98-8f92a4474215"}
1
+ {"version":3,"file":"drift-scan.js","sources":["core/history/drift-scan.ts"],"sourceRoot":"/","sourcesContent":["import fs from \"fs/promises\";\nimport { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport { getHistoryPath } from \"../store/paths.js\";\nimport { writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { hashDocument } from \"./history.js\";\nimport { verifyHistoryChain } from \"./replay.js\";\nimport type { HistoryEntry, ItemMetadata } from \"../../types/index.js\";\n\nexport interface DriftScanResult {\n missingStreams: string[];\n unreadableStreams: string[];\n hashMismatches: string[];\n chainMismatches: string[];\n driftedItems: string[];\n}\n\nconst DRIFT_CACHE_VERSION = 2;\nconst DRIFT_CACHE_FILENAME = \"history-drift-cache.json\";\n\ninterface DriftCacheEntry {\n mtime_ms: number;\n ctime_ms: number;\n size: number;\n content_hash: string;\n latest_after_hash: string;\n chain_ok: boolean;\n}\n\ninterface DriftCacheEnvelope {\n version: number;\n entries: Record<string, DriftCacheEntry>;\n}\n\nfunction getDriftCachePath(pmRoot: string): string {\n return path.join(pmRoot, \"runtime\", DRIFT_CACHE_FILENAME);\n}\n\nasync function loadDriftCache(pmRoot: string): Promise<DriftCacheEnvelope | null> {\n try {\n const raw = await fs.readFile(getDriftCachePath(pmRoot), \"utf8\");\n const parsed = JSON.parse(raw) as DriftCacheEnvelope;\n if (parsed.version !== DRIFT_CACHE_VERSION || typeof parsed.entries !== \"object\" || parsed.entries === null) {\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n\ninterface StreamVerification {\n latestAfterHash: string;\n chainOk: boolean;\n contentHash: string;\n}\n\nfunction hashContent(raw: string): string {\n return createHash(\"sha256\").update(raw).digest(\"hex\");\n}\n\nasync function readHistoryContentHash(historyPath: string): Promise<string> {\n const raw = await fs.readFile(historyPath, \"utf8\");\n return hashContent(raw);\n}\n\n/**\n * Read and fully verify one history stream's hash chain. Returns null for an\n * empty/missing stream (caller records it as a missing stream).\n */\nasync function verifyHistoryStream(historyPath: string): Promise<StreamVerification | null> {\n const raw = await fs.readFile(historyPath, \"utf8\");\n const contentHash = hashContent(raw);\n if (raw.trim().length === 0) {\n return null;\n }\n const entries: HistoryEntry[] = [];\n let latestAfterHash: string | null = null;\n for (const line of raw.split(/\\r?\\n/)) {\n const trimmed = line.trim();\n if (trimmed.length === 0) {\n continue;\n }\n const parsed = JSON.parse(trimmed) as HistoryEntry;\n if (typeof parsed.after_hash !== \"string\" || parsed.after_hash.trim().length === 0) {\n throw new Error(\"missing after_hash\");\n }\n entries.push(parsed);\n latestAfterHash = parsed.after_hash;\n }\n /* c8 ignore start -- defensive guard for future history schema changes. */\n if (!latestAfterHash) {\n return null;\n }\n /* c8 ignore stop */\n return {\n latestAfterHash,\n chainOk: verifyHistoryChain(entries).ok,\n contentHash,\n };\n}\n\n/**\n * Scan every item's history stream for drift (missing/unreadable streams, broken\n * hash chains, and item/history hash mismatches).\n *\n * Full chain re-verification of a 17MB+ history tree is the dominant cost of\n * `pm health`. We cache the per-stream verification keyed by the history file's\n * mtime/ctime/size + content hash: metadata-stable replacements (same stat tuple)\n * can still happen, so each metadata hit recomputes a content hash guard before\n * trusting the cached chain/hash verification.\n */\nexport async function scanHistoryDrift(\n pmRoot: string,\n items: Array<ItemMetadata & { body: string }>,\n): Promise<DriftScanResult> {\n const missingStreams: string[] = [];\n const unreadableStreams: string[] = [];\n const hashMismatches: string[] = [];\n const chainMismatches: string[] = [];\n\n const cache = await loadDriftCache(pmRoot);\n const previousEntries: Record<string, DriftCacheEntry> = cache?.entries ?? {};\n const nextEntries: Record<string, DriftCacheEntry> = {};\n let cacheDirty = false;\n\n for (const item of items) {\n const historyPath = getHistoryPath(pmRoot, item.id);\n\n let stat: Awaited<ReturnType<typeof fs.stat>>;\n try {\n stat = await fs.stat(historyPath);\n } catch (error: unknown) {\n if (isErrno(error, \"ENOENT\")) {\n missingStreams.push(item.id);\n } else {\n unreadableStreams.push(item.id);\n }\n continue;\n }\n\n const loadStreamVerification = async (): Promise<StreamVerification | null | \"unreadable\"> => {\n try {\n return await verifyHistoryStream(historyPath);\n } catch {\n return \"unreadable\";\n }\n };\n\n const loadFreshVerification = async (): Promise<StreamVerification | null> => {\n const loaded = await loadStreamVerification();\n if (loaded === \"unreadable\") {\n unreadableStreams.push(item.id);\n return null;\n }\n if (!loaded) {\n missingStreams.push(item.id);\n return null;\n }\n return loaded;\n };\n\n const cached = previousEntries[item.id];\n let verification: StreamVerification;\n const metadataMatchesCache =\n cached !== undefined &&\n cached.mtime_ms === stat.mtimeMs &&\n cached.ctime_ms === stat.ctimeMs &&\n cached.size === stat.size;\n const cachedContentHash =\n typeof cached?.content_hash === \"string\" && cached.content_hash.length > 0 ? cached.content_hash : undefined;\n const canUseCache = metadataMatchesCache && cachedContentHash !== undefined;\n if (canUseCache && cached) {\n let currentContentHash: string;\n try {\n currentContentHash = await readHistoryContentHash(historyPath);\n } catch {\n unreadableStreams.push(item.id);\n continue;\n }\n if (currentContentHash === cachedContentHash) {\n verification = {\n latestAfterHash: cached.latest_after_hash,\n chainOk: cached.chain_ok,\n contentHash: currentContentHash,\n };\n } else {\n cacheDirty = true;\n const refreshed = await loadFreshVerification();\n if (!refreshed) {\n continue;\n }\n verification = refreshed;\n }\n } else {\n cacheDirty = true;\n const refreshed = await loadFreshVerification();\n if (!refreshed) {\n continue;\n }\n verification = refreshed;\n }\n\n if (!verification.chainOk) {\n chainMismatches.push(item.id);\n }\n nextEntries[item.id] = {\n mtime_ms: stat.mtimeMs,\n ctime_ms: stat.ctimeMs,\n size: stat.size,\n content_hash: verification.contentHash,\n latest_after_hash: verification.latestAfterHash,\n chain_ok: verification.chainOk,\n };\n\n const { body, ...frontMatter } = item;\n const currentHash = hashDocument({\n metadata: frontMatter as ItemMetadata,\n body,\n });\n if (currentHash !== verification.latestAfterHash) {\n hashMismatches.push(item.id);\n }\n }\n\n if (cacheDirty || Object.keys(previousEntries).length !== Object.keys(nextEntries).length) {\n const cachePath = getDriftCachePath(pmRoot);\n try {\n await fs.mkdir(path.dirname(cachePath), { recursive: true });\n await writeFileAtomic(cachePath, JSON.stringify({ version: DRIFT_CACHE_VERSION, entries: nextEntries }));\n } catch {\n // Best-effort cache write: a failed persist must never fail a health scan.\n }\n }\n\n const driftedItems = [...new Set([...missingStreams, ...unreadableStreams, ...hashMismatches, ...chainMismatches])].sort((a, b) =>\n a.localeCompare(b),\n );\n return { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems };\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE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AAC,eAAe,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1F,MAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7D,MAAM,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QAC3G,CAAC;QAAC,MAAM,CAAC;YACP,2EAA2E;QAC7E,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,iBAAiB,EAAE,GAAG,cAAc,EAAE,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChI,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CACnB,CAAC;IACF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAC9F,CAAC","debugId":"0dd4c4e6-9086-5afb-814b-38d0b36d4283"}
@@ -1,5 +1,5 @@
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]="f427a735-ffab-5a1c-b4cf-7069624a58cd")}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]="681913fe-dcec-59f2-a0dc-0f3578f11e37")}catch(e){}}();
3
3
  import crypto from "node:crypto";
4
4
  import path from "node:path";
5
5
  import { TYPE_TO_FOLDER } from "../shared/constants.js";
@@ -26,10 +26,9 @@ export function normalizeItemId(input, prefix) {
26
26
  return `${canonicalPrefix}${normalized}`;
27
27
  }
28
28
  function randomToken(length) {
29
- const bytes = crypto.randomBytes(length);
30
29
  let token = "";
31
- for (const byte of bytes) {
32
- token += (byte % 36).toString(36);
30
+ for (let index = 0; index < length; index += 1) {
31
+ token += crypto.randomInt(0, 36).toString(36);
33
32
  }
34
33
  return token;
35
34
  }
@@ -61,4 +60,4 @@ export async function generateItemId(pmRoot, prefix) {
61
60
  throw new Error(`Unable to generate unique id after ${attempts} attempts`);
62
61
  }
63
62
  //# sourceMappingURL=id.js.map
64
- //# debugId=f427a735-ffab-5a1c-b4cf-7069624a58cd
63
+ //# debugId=681913fe-dcec-59f2-a0dc-0f3578f11e37
@@ -1 +1 @@
1
- {"version":3,"file":"id.js","sources":["core/item/id.ts"],"sourceRoot":"/","sourcesContent":["import crypto from \"node:crypto\";\nimport path from \"node:path\";\nimport { TYPE_TO_FOLDER } from \"../shared/constants.js\";\nimport { pathExists } from \"../fs/fs-utils.js\";\n\nexport function normalizePrefix(input: string | undefined): string {\n const normalized = (input ?? \"\").trim().toLowerCase();\n if (!normalized) return \"pm-\";\n return normalized.endsWith(\"-\") ? normalized : `${normalized}-`;\n}\n\nexport function normalizeRawItemId(input: string): string {\n let normalized = input.trim().toLowerCase();\n if (normalized.startsWith(\"#\")) {\n normalized = normalized.slice(1);\n }\n return normalized;\n}\n\nexport function normalizeItemId(input: string, prefix: string): string {\n const canonicalPrefix = normalizePrefix(prefix);\n const normalized = normalizeRawItemId(input);\n if (normalized.startsWith(canonicalPrefix)) {\n return normalized;\n }\n return `${canonicalPrefix}${normalized}`;\n}\n\nfunction randomToken(length: number): string {\n const bytes = crypto.randomBytes(length);\n let token = \"\";\n for (const byte of bytes) {\n token += (byte % 36).toString(36);\n }\n return token;\n}\n\nasync function idExists(pmRoot: string, id: string): Promise<boolean> {\n const checks = Object.values(TYPE_TO_FOLDER).flatMap((folder) => [\n path.join(pmRoot, folder, `${id}.md`),\n path.join(pmRoot, folder, `${id}.toon`),\n ]);\n for (const target of checks) {\n if (await pathExists(target)) {\n return true;\n }\n }\n return false;\n}\n\nexport async function generateItemId(pmRoot: string, prefix: string): Promise<string> {\n let tokenLength = 4;\n let attempts = 0;\n\n while (tokenLength <= 10) {\n for (let i = 0; i < 32; i += 1) {\n const id = `${normalizePrefix(prefix)}${randomToken(tokenLength)}`;\n if (!(await idExists(pmRoot, id))) {\n return id;\n }\n attempts += 1;\n }\n tokenLength += 1;\n }\n\n throw new Error(`Unable to generate unique id after ${attempts} attempts`);\n}\n"],"names":[],"mappings":";;AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,MAAM,UAAU,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9B,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,IAAI,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,UAAU,GAAG,UAAU,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AM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc,EAAE,MAAc;IACjE,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,OAAO,WAAW,IAAI,EAAE,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,EAAE,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;YACnE,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;gBAClC,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,QAAQ,IAAI,CAAC,CAAC;QAChB,CAAC;QACD,WAAW,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,WAAW,CAAC,CAAC;AAC7E,CAAC","debugId":"f427a735-ffab-5a1c-b4cf-7069624a58cd"}
1
+ {"version":3,"file":"id.js","sources":["core/item/id.ts"],"sourceRoot":"/","sourcesContent":["import crypto from \"node:crypto\";\nimport path from \"node:path\";\nimport { TYPE_TO_FOLDER } from \"../shared/constants.js\";\nimport { pathExists } from \"../fs/fs-utils.js\";\n\nexport function normalizePrefix(input: string | undefined): string {\n const normalized = (input ?? \"\").trim().toLowerCase();\n if (!normalized) return \"pm-\";\n return normalized.endsWith(\"-\") ? normalized : `${normalized}-`;\n}\n\nexport function normalizeRawItemId(input: string): string {\n let normalized = input.trim().toLowerCase();\n if (normalized.startsWith(\"#\")) {\n normalized = normalized.slice(1);\n }\n return normalized;\n}\n\nexport function normalizeItemId(input: string, prefix: string): string {\n const canonicalPrefix = normalizePrefix(prefix);\n const normalized = normalizeRawItemId(input);\n if (normalized.startsWith(canonicalPrefix)) {\n return normalized;\n }\n return `${canonicalPrefix}${normalized}`;\n}\n\nfunction randomToken(length: number): string {\n let token = \"\";\n for (let index = 0; index < length; index += 1) {\n token += crypto.randomInt(0, 36).toString(36);\n }\n return token;\n}\n\nasync function idExists(pmRoot: string, id: string): Promise<boolean> {\n const checks = Object.values(TYPE_TO_FOLDER).flatMap((folder) => [\n path.join(pmRoot, folder, `${id}.md`),\n path.join(pmRoot, folder, `${id}.toon`),\n ]);\n for (const target of checks) {\n if (await pathExists(target)) {\n return true;\n }\n }\n return false;\n}\n\nexport async function generateItemId(pmRoot: string, prefix: string): Promise<string> {\n let tokenLength = 4;\n let attempts = 0;\n\n while (tokenLength <= 10) {\n for (let i = 0; i < 32; i += 1) {\n const id = `${normalizePrefix(prefix)}${randomToken(tokenLength)}`;\n if (!(await idExists(pmRoot, id))) {\n return id;\n }\n attempts += 1;\n }\n tokenLength += 1;\n }\n\n throw new Error(`Unable to generate unique id after ${attempts} attempts`);\n}\n"],"names":[],"mappings":";;AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,MAAM,UAAU,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9B,OAAO,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,IAAI,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,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O,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc,EAAE,MAAc;IACjE,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,OAAO,WAAW,IAAI,EAAE,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,EAAE,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;YACnE,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;gBAClC,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,QAAQ,IAAI,CAAC,CAAC;QAChB,CAAC;QACD,WAAW,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,WAAW,CAAC,CAAC;AAC7E,CAAC","debugId":"681913fe-dcec-59f2-a0dc-0f3578f11e37"}
@@ -1,5 +1,5 @@
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]="375a5879-64b1-55a4-a83e-90ee50031713")}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]="ba14fa53-be28-55e9-92fb-d00e33a98480")}catch(e){}}();
3
3
  import { encode as encodeToon } from "@toon-format/toon";
4
4
  import { CONFIDENCE_TEXT_VALUES, ISSUE_SEVERITY_VALUES, RECURRENCE_FREQUENCY_VALUES, RECURRENCE_WEEKDAY_VALUES, STATUS_VALUES, weekdayOrderIndex, } from "../../types/index.js";
5
5
  import { coerceRuntimeFieldValue } from "../schema/runtime-field-values.js";
@@ -823,7 +823,11 @@ function normalizeTypeOptions(values) {
823
823
  return Object.fromEntries(normalizedEntries);
824
824
  }
825
825
  function normalizeBody(body) {
826
- return body.replace(/^\n+/, "").replace(/\s+$/, "");
826
+ let start = 0;
827
+ while (start < body.length && body[start] === "\n") {
828
+ start += 1;
829
+ }
830
+ return body.slice(start).trimEnd();
827
831
  }
828
832
  function normalizeConfidenceValue(value) {
829
833
  if (value === undefined) {
@@ -1134,4 +1138,4 @@ export function canonicalDocument(document, options = {}) {
1134
1138
  };
1135
1139
  }
1136
1140
  //# sourceMappingURL=item-format.js.map
1137
- //# debugId=375a5879-64b1-55a4-a83e-90ee50031713
1141
+ //# debugId=ba14fa53-be28-55e9-92fb-d00e33a98480