@unbrained/pm-cli 2026.5.31 → 2026.6.6

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 (638) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/README.md +12 -4
  4. package/dist/cli/argv-utils.js +7 -3
  5. package/dist/cli/argv-utils.js.map +1 -1
  6. package/dist/cli/bootstrap-args.d.ts +1 -0
  7. package/dist/cli/bootstrap-args.js +23 -3
  8. package/dist/cli/bootstrap-args.js.map +1 -1
  9. package/dist/cli/commands/calendar.js +17 -3
  10. package/dist/cli/commands/calendar.js.map +1 -1
  11. package/dist/cli/commands/close-many.d.ts +63 -0
  12. package/dist/cli/commands/close-many.js +302 -0
  13. package/dist/cli/commands/close-many.js.map +1 -0
  14. package/dist/cli/commands/completion.d.ts +1 -0
  15. package/dist/cli/commands/completion.js +260 -32
  16. package/dist/cli/commands/completion.js.map +1 -1
  17. package/dist/cli/commands/config.d.ts +4 -4
  18. package/dist/cli/commands/config.js +115 -3
  19. package/dist/cli/commands/config.js.map +1 -1
  20. package/dist/cli/commands/contracts.js +193 -162
  21. package/dist/cli/commands/contracts.js.map +1 -1
  22. package/dist/cli/commands/create.d.ts +1 -0
  23. package/dist/cli/commands/create.js +77 -114
  24. package/dist/cli/commands/create.js.map +1 -1
  25. package/dist/cli/commands/extension/doctor.d.ts +12 -0
  26. package/dist/cli/commands/extension/doctor.js +97 -2
  27. package/dist/cli/commands/extension/doctor.js.map +1 -1
  28. package/dist/cli/commands/extension/scaffold.js +49 -48
  29. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  30. package/dist/cli/commands/extension.js +51 -23
  31. package/dist/cli/commands/extension.js.map +1 -1
  32. package/dist/cli/commands/gc.d.ts +8 -1
  33. package/dist/cli/commands/gc.js +26 -3
  34. package/dist/cli/commands/gc.js.map +1 -1
  35. package/dist/cli/commands/get.js +7 -7
  36. package/dist/cli/commands/get.js.map +1 -1
  37. package/dist/cli/commands/health.js +51 -3
  38. package/dist/cli/commands/health.js.map +1 -1
  39. package/dist/cli/commands/history.d.ts +4 -1
  40. package/dist/cli/commands/history.js +12 -24
  41. package/dist/cli/commands/history.js.map +1 -1
  42. package/dist/cli/commands/index.d.ts +3 -1
  43. package/dist/cli/commands/index.js +5 -3
  44. package/dist/cli/commands/index.js.map +1 -1
  45. package/dist/cli/commands/init.d.ts +10 -0
  46. package/dist/cli/commands/init.js +107 -4
  47. package/dist/cli/commands/init.js.map +1 -1
  48. package/dist/cli/commands/list.d.ts +5 -0
  49. package/dist/cli/commands/list.js +58 -26
  50. package/dist/cli/commands/list.js.map +1 -1
  51. package/dist/cli/commands/reindex.js +163 -47
  52. package/dist/cli/commands/reindex.js.map +1 -1
  53. package/dist/cli/commands/repeatable-metadata-parsers.d.ts +15 -0
  54. package/dist/cli/commands/repeatable-metadata-parsers.js +120 -0
  55. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -0
  56. package/dist/cli/commands/restore.js +25 -4
  57. package/dist/cli/commands/restore.js.map +1 -1
  58. package/dist/cli/commands/schema.d.ts +122 -1
  59. package/dist/cli/commands/schema.js +536 -6
  60. package/dist/cli/commands/schema.js.map +1 -1
  61. package/dist/cli/commands/search.d.ts +1 -0
  62. package/dist/cli/commands/search.js +18 -4
  63. package/dist/cli/commands/search.js.map +1 -1
  64. package/dist/cli/commands/stats.d.ts +8 -1
  65. package/dist/cli/commands/stats.js +18 -17
  66. package/dist/cli/commands/stats.js.map +1 -1
  67. package/dist/cli/commands/telemetry.d.ts +8 -0
  68. package/dist/cli/commands/telemetry.js +253 -0
  69. package/dist/cli/commands/telemetry.js.map +1 -0
  70. package/dist/cli/commands/test.js +4 -3
  71. package/dist/cli/commands/test.js.map +1 -1
  72. package/dist/cli/commands/update-many.js +69 -140
  73. package/dist/cli/commands/update-many.js.map +1 -1
  74. package/dist/cli/commands/update.d.ts +2 -0
  75. package/dist/cli/commands/update.js +138 -119
  76. package/dist/cli/commands/update.js.map +1 -1
  77. package/dist/cli/commands/validate.d.ts +1 -0
  78. package/dist/cli/commands/validate.js +63 -33
  79. package/dist/cli/commands/validate.js.map +1 -1
  80. package/dist/cli/error-guidance.js +26 -3
  81. package/dist/cli/error-guidance.js.map +1 -1
  82. package/dist/cli/help-content.js +91 -3
  83. package/dist/cli/help-content.js.map +1 -1
  84. package/dist/cli/main.js +377 -23
  85. package/dist/cli/main.js.map +1 -1
  86. package/dist/cli/register-list-query.js +14 -5
  87. package/dist/cli/register-list-query.js.map +1 -1
  88. package/dist/cli/register-mutation.js +200 -28
  89. package/dist/cli/register-mutation.js.map +1 -1
  90. package/dist/cli/register-operations.js +31 -6
  91. package/dist/cli/register-operations.js.map +1 -1
  92. package/dist/cli/register-setup.js +4 -2
  93. package/dist/cli/register-setup.js.map +1 -1
  94. package/dist/cli/registration-helpers.js +31 -4
  95. package/dist/cli/registration-helpers.js.map +1 -1
  96. package/dist/cli-bundle/chunks/activity-CVXTCHYY.js +16 -0
  97. package/dist/cli-bundle/chunks/activity-JM6DTDND.js +20 -0
  98. package/dist/cli-bundle/chunks/activity-JM6DTDND.js.map +1 -0
  99. package/dist/cli-bundle/chunks/aggregate-GI7WSZPH.js +206 -0
  100. package/dist/cli-bundle/chunks/aggregate-GI7WSZPH.js.map +1 -0
  101. package/dist/cli-bundle/chunks/{aggregate-ADUOSFRO.js → aggregate-VNAHUNNF.js} +11 -11
  102. package/dist/cli-bundle/chunks/{append-JD2DETU7.js → append-7H5N64R2.js} +8 -9
  103. package/dist/cli-bundle/chunks/{append-JD2DETU7.js.map → append-7H5N64R2.js.map} +1 -1
  104. package/dist/cli-bundle/chunks/append-WMKRXKCE.js +69 -0
  105. package/dist/cli-bundle/chunks/append-WMKRXKCE.js.map +1 -0
  106. package/dist/cli-bundle/chunks/{chunk-3M73P3G6.js → chunk-23YFZ3IG.js} +210 -132
  107. package/dist/cli-bundle/chunks/chunk-23YFZ3IG.js.map +7 -0
  108. package/dist/cli-bundle/chunks/chunk-2HVRUSQA.js +128 -0
  109. package/dist/cli-bundle/chunks/chunk-2HVRUSQA.js.map +1 -0
  110. package/dist/cli-bundle/chunks/chunk-2RSPZI5H.js +266 -0
  111. package/dist/cli-bundle/chunks/chunk-2RSPZI5H.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-2VBQ6ZXS.js +631 -0
  113. package/dist/cli-bundle/chunks/chunk-2VBQ6ZXS.js.map +1 -0
  114. package/dist/cli-bundle/chunks/chunk-2VVCGBNV.js +380 -0
  115. package/dist/cli-bundle/chunks/chunk-2VVCGBNV.js.map +1 -0
  116. package/dist/cli-bundle/chunks/chunk-3BWOVLTH.js +1664 -0
  117. package/dist/cli-bundle/chunks/chunk-3BWOVLTH.js.map +1 -0
  118. package/dist/cli-bundle/chunks/{chunk-6HT2F4TK.js → chunk-3FI4SEFT.js} +175 -54
  119. package/dist/cli-bundle/chunks/chunk-3FI4SEFT.js.map +7 -0
  120. package/dist/cli-bundle/chunks/{chunk-JULRTHJQ.js → chunk-3LB74A67.js} +119 -6
  121. package/dist/cli-bundle/chunks/chunk-3LB74A67.js.map +7 -0
  122. package/dist/cli-bundle/chunks/chunk-3VAM3NNM.js +57 -0
  123. package/dist/cli-bundle/chunks/chunk-3VAM3NNM.js.map +1 -0
  124. package/dist/cli-bundle/chunks/chunk-4LL6TK5B.js +1832 -0
  125. package/dist/cli-bundle/chunks/chunk-4LL6TK5B.js.map +1 -0
  126. package/dist/cli-bundle/chunks/chunk-52MAOQ6J.js +422 -0
  127. package/dist/cli-bundle/chunks/chunk-52MAOQ6J.js.map +7 -0
  128. package/dist/cli-bundle/chunks/chunk-5FDATVEZ.js +412 -0
  129. package/dist/cli-bundle/chunks/chunk-5FDATVEZ.js.map +1 -0
  130. package/dist/cli-bundle/chunks/chunk-5SFCOO6B.js +5622 -0
  131. package/dist/cli-bundle/chunks/chunk-5SFCOO6B.js.map +1 -0
  132. package/dist/cli-bundle/chunks/{chunk-U7FMKRXH.js → chunk-6ER6DXH5.js} +37 -16
  133. package/dist/cli-bundle/chunks/chunk-6ER6DXH5.js.map +7 -0
  134. package/dist/cli-bundle/chunks/chunk-6P6GGMOG.js +218 -0
  135. package/dist/cli-bundle/chunks/chunk-6P6GGMOG.js.map +1 -0
  136. package/dist/cli-bundle/chunks/chunk-77GFDHGF.js +80 -0
  137. package/dist/cli-bundle/chunks/chunk-77GFDHGF.js.map +1 -0
  138. package/dist/cli-bundle/chunks/{chunk-MD7K4JYF.js → chunk-AO442XLN.js} +26 -15
  139. package/dist/cli-bundle/chunks/chunk-AO442XLN.js.map +7 -0
  140. package/dist/cli-bundle/chunks/chunk-AY43SBIN.js +751 -0
  141. package/dist/cli-bundle/chunks/chunk-AY43SBIN.js.map +1 -0
  142. package/dist/cli-bundle/chunks/{chunk-D7AOMPRH.js → chunk-BQHUILZS.js} +5 -5
  143. package/dist/cli-bundle/chunks/chunk-E5FJNAZA.js +242 -0
  144. package/dist/cli-bundle/chunks/chunk-E5FJNAZA.js.map +1 -0
  145. package/dist/cli-bundle/chunks/{chunk-OGZEG5TT.js → chunk-ECCMVXGM.js} +164 -53
  146. package/dist/cli-bundle/chunks/chunk-ECCMVXGM.js.map +7 -0
  147. package/dist/cli-bundle/chunks/chunk-FRAUKRU2.js +182 -0
  148. package/dist/cli-bundle/chunks/chunk-FRAUKRU2.js.map +1 -0
  149. package/dist/cli-bundle/chunks/chunk-GCOQW437.js +130 -0
  150. package/dist/cli-bundle/chunks/chunk-GCOQW437.js.map +1 -0
  151. package/dist/cli-bundle/chunks/chunk-GGYWB3Y2.js +1340 -0
  152. package/dist/cli-bundle/chunks/chunk-GGYWB3Y2.js.map +1 -0
  153. package/dist/cli-bundle/chunks/{chunk-G57E5D7T.js → chunk-GU2ZJ2VV.js} +5 -5
  154. package/dist/cli-bundle/chunks/chunk-GXSUPCBV.js +231 -0
  155. package/dist/cli-bundle/chunks/chunk-GXSUPCBV.js.map +1 -0
  156. package/dist/cli-bundle/chunks/chunk-HZGUAH22.js +76 -0
  157. package/dist/cli-bundle/chunks/chunk-HZGUAH22.js.map +1 -0
  158. package/dist/cli-bundle/chunks/chunk-I2HSTRJF.js +346 -0
  159. package/dist/cli-bundle/chunks/chunk-I2HSTRJF.js.map +1 -0
  160. package/dist/cli-bundle/chunks/chunk-I6BNFU5X.js +140 -0
  161. package/dist/cli-bundle/chunks/chunk-I6BNFU5X.js.map +7 -0
  162. package/dist/cli-bundle/chunks/{chunk-JTWRXG4B.js → chunk-IJGCZSIQ.js} +251 -251
  163. package/dist/cli-bundle/chunks/chunk-IJGCZSIQ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/chunk-IOR7LGF4.js +1491 -0
  165. package/dist/cli-bundle/chunks/chunk-IOR7LGF4.js.map +1 -0
  166. package/dist/cli-bundle/chunks/chunk-IUV734HF.js +17 -0
  167. package/dist/cli-bundle/chunks/chunk-IUV734HF.js.map +1 -0
  168. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js +15 -0
  169. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js.map +1 -0
  170. package/dist/cli-bundle/chunks/{chunk-AKOOMO3T.js → chunk-KAG77BY3.js} +2 -2
  171. package/dist/cli-bundle/chunks/{chunk-KBQY3YG5.js → chunk-KJ33AOCY.js} +3 -3
  172. package/dist/cli-bundle/chunks/{chunk-WDPXDQFG.js → chunk-KJE2FOS4.js} +6 -4
  173. package/dist/cli-bundle/chunks/chunk-KJE2FOS4.js.map +7 -0
  174. package/dist/cli-bundle/chunks/chunk-KWU6HG75.js +3883 -0
  175. package/dist/cli-bundle/chunks/chunk-KWU6HG75.js.map +1 -0
  176. package/dist/cli-bundle/chunks/chunk-LB3RUL2N.js +1325 -0
  177. package/dist/cli-bundle/chunks/chunk-LB3RUL2N.js.map +1 -0
  178. package/dist/cli-bundle/chunks/{chunk-5HSEP75M.js → chunk-LCM63IXU.js} +18 -6
  179. package/dist/cli-bundle/chunks/chunk-LCM63IXU.js.map +7 -0
  180. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js +24 -0
  181. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js.map +1 -0
  182. package/dist/cli-bundle/chunks/chunk-ME2YH6FN.js +182 -0
  183. package/dist/cli-bundle/chunks/chunk-ME2YH6FN.js.map +1 -0
  184. package/dist/cli-bundle/chunks/chunk-MITFDD35.js +1809 -0
  185. package/dist/cli-bundle/chunks/chunk-MITFDD35.js.map +1 -0
  186. package/dist/cli-bundle/chunks/{chunk-WJ2NAC37.js → chunk-N7ACFE26.js} +3 -3
  187. package/dist/cli-bundle/chunks/chunk-NUZ5HKR4.js +332 -0
  188. package/dist/cli-bundle/chunks/chunk-NUZ5HKR4.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-7Y53ZJIQ.js → chunk-OVQCEJPG.js} +22 -3
  190. package/dist/cli-bundle/chunks/chunk-OVQCEJPG.js.map +7 -0
  191. package/dist/cli-bundle/chunks/{chunk-PXUAZUUY.js → chunk-OZ7NSQHL.js} +12 -11
  192. package/dist/cli-bundle/chunks/chunk-OZ7NSQHL.js.map +7 -0
  193. package/dist/cli-bundle/chunks/{chunk-P53TN6IA.js → chunk-PDDFYW4X.js} +35 -8
  194. package/dist/cli-bundle/chunks/chunk-PDDFYW4X.js.map +7 -0
  195. package/dist/cli-bundle/chunks/{chunk-6YCV7WSL.js → chunk-PIU6RSL3.js} +10 -12
  196. package/dist/cli-bundle/chunks/{chunk-6YCV7WSL.js.map → chunk-PIU6RSL3.js.map} +1 -1
  197. package/dist/cli-bundle/chunks/chunk-PO3GSVFV.js +338 -0
  198. package/dist/cli-bundle/chunks/chunk-PO3GSVFV.js.map +1 -0
  199. package/dist/cli-bundle/chunks/{chunk-LRBOHPUE.js → chunk-PRJCELV4.js} +108 -21
  200. package/dist/cli-bundle/chunks/chunk-PRJCELV4.js.map +7 -0
  201. package/dist/cli-bundle/chunks/{chunk-GN7IJPCD.js → chunk-PROOHX4K.js} +332 -32
  202. package/dist/cli-bundle/chunks/chunk-PROOHX4K.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-FQE6XZDB.js → chunk-Q7SPNHLW.js} +54 -32
  204. package/dist/cli-bundle/chunks/chunk-Q7SPNHLW.js.map +7 -0
  205. package/dist/cli-bundle/chunks/{chunk-PVNQLCIS.js → chunk-QO7EBBOM.js} +2 -2
  206. package/dist/cli-bundle/chunks/{chunk-A7E7PUVX.js → chunk-R6UFP2GE.js} +7 -7
  207. package/dist/cli-bundle/chunks/chunk-RWPSOIEE.js +154 -0
  208. package/dist/cli-bundle/chunks/chunk-RWPSOIEE.js.map +1 -0
  209. package/dist/cli-bundle/chunks/chunk-RZN6VURO.js +119 -0
  210. package/dist/cli-bundle/chunks/chunk-RZN6VURO.js.map +1 -0
  211. package/dist/cli-bundle/chunks/chunk-SKJWX3QB.js +1501 -0
  212. package/dist/cli-bundle/chunks/chunk-SKJWX3QB.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{chunk-CEFIVZPG.js → chunk-T3LC5LKB.js} +2 -2
  214. package/dist/cli-bundle/chunks/chunk-TCD3R2PF.js +173 -0
  215. package/dist/cli-bundle/chunks/chunk-TCD3R2PF.js.map +1 -0
  216. package/dist/cli-bundle/chunks/chunk-TPH5XEVD.js +2988 -0
  217. package/dist/cli-bundle/chunks/chunk-TPH5XEVD.js.map +1 -0
  218. package/dist/cli-bundle/chunks/{chunk-LSXGH6NE.js → chunk-U5SXYXSY.js} +821 -200
  219. package/dist/cli-bundle/chunks/chunk-U5SXYXSY.js.map +7 -0
  220. package/dist/cli-bundle/chunks/chunk-UBOPJT3S.js +540 -0
  221. package/dist/cli-bundle/chunks/chunk-UBOPJT3S.js.map +1 -0
  222. package/dist/cli-bundle/chunks/{chunk-JFWUHHS2.js → chunk-UM2GBHS4.js} +5 -4
  223. package/dist/cli-bundle/chunks/chunk-W7XABV4H.js +454 -0
  224. package/dist/cli-bundle/chunks/chunk-W7XABV4H.js.map +1 -0
  225. package/dist/cli-bundle/chunks/{chunk-SEXQN4KL.js → chunk-WKY2IBOQ.js} +3 -3
  226. package/dist/cli-bundle/chunks/chunk-WOPXVEZP.js +698 -0
  227. package/dist/cli-bundle/chunks/chunk-WOPXVEZP.js.map +1 -0
  228. package/dist/cli-bundle/chunks/chunk-WSMOSYRD.js +1704 -0
  229. package/dist/cli-bundle/chunks/chunk-WSMOSYRD.js.map +1 -0
  230. package/dist/cli-bundle/chunks/{chunk-NGN7UV5K.js → chunk-XLTD2HN3.js} +2 -2
  231. package/dist/cli-bundle/chunks/chunk-XSJCLN2R.js +131 -0
  232. package/dist/cli-bundle/chunks/chunk-XSJCLN2R.js.map +7 -0
  233. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js +53 -0
  234. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js.map +1 -0
  235. package/dist/cli-bundle/chunks/{chunk-BUPWJ3IJ.js → chunk-XTGLRY2Y.js} +484 -49
  236. package/dist/cli-bundle/chunks/chunk-XTGLRY2Y.js.map +7 -0
  237. package/dist/cli-bundle/chunks/{chunk-L2FXEKDB.js → chunk-YL2DJGYS.js} +7 -7
  238. package/dist/cli-bundle/chunks/{claim-EE4TKKCV.js → claim-4DBF6RVG.js} +10 -11
  239. package/dist/cli-bundle/chunks/{claim-EE4TKKCV.js.map → claim-4DBF6RVG.js.map} +1 -1
  240. package/dist/cli-bundle/chunks/claim-X2P4IB7J.js +129 -0
  241. package/dist/cli-bundle/chunks/claim-X2P4IB7J.js.map +1 -0
  242. package/dist/cli-bundle/chunks/close-3HDWDA3L.js +13 -0
  243. package/dist/cli-bundle/chunks/close-PTYFA45H.js +17 -0
  244. package/dist/cli-bundle/chunks/close-PTYFA45H.js.map +1 -0
  245. package/dist/cli-bundle/chunks/close-many-7CGIDPTJ.js +314 -0
  246. package/dist/cli-bundle/chunks/close-many-7CGIDPTJ.js.map +7 -0
  247. package/dist/cli-bundle/chunks/close-many-ERFO6LHR.js +311 -0
  248. package/dist/cli-bundle/chunks/close-many-ERFO6LHR.js.map +1 -0
  249. package/dist/cli-bundle/chunks/comments-OONGABK5.js +100 -0
  250. package/dist/cli-bundle/chunks/comments-OONGABK5.js.map +1 -0
  251. package/dist/cli-bundle/chunks/{comments-AAKJQ6LW.js → comments-QKBYCWKD.js} +10 -11
  252. package/dist/cli-bundle/chunks/{comments-AAKJQ6LW.js.map → comments-QKBYCWKD.js.map} +1 -1
  253. package/dist/cli-bundle/chunks/config-6FXCQKIF.js +1671 -0
  254. package/dist/cli-bundle/chunks/config-6FXCQKIF.js.map +1 -0
  255. package/dist/cli-bundle/chunks/{config-V3FZOKLI.js → config-U4RZ4CQB.js} +121 -10
  256. package/dist/cli-bundle/chunks/config-U4RZ4CQB.js.map +7 -0
  257. package/dist/cli-bundle/chunks/{context-RZ5QPNJB.js → context-FYYJGFWS.js} +32 -19
  258. package/dist/cli-bundle/chunks/{context-RZ5QPNJB.js.map → context-FYYJGFWS.js.map} +2 -2
  259. package/dist/cli-bundle/chunks/context-YMJ3Z2HQ.js +1461 -0
  260. package/dist/cli-bundle/chunks/context-YMJ3Z2HQ.js.map +1 -0
  261. package/dist/cli-bundle/chunks/contracts-QDB6OMLQ.js +1278 -0
  262. package/dist/cli-bundle/chunks/contracts-QDB6OMLQ.js.map +1 -0
  263. package/dist/cli-bundle/chunks/{contracts-YLMH33VU.js → contracts-RFSPGVVJ.js} +198 -162
  264. package/dist/cli-bundle/chunks/contracts-RFSPGVVJ.js.map +7 -0
  265. package/dist/cli-bundle/chunks/create-I5L4EYYZ.js +31 -0
  266. package/dist/cli-bundle/chunks/create-I5L4EYYZ.js.map +1 -0
  267. package/dist/cli-bundle/chunks/create-JTZNCTQC.js +27 -0
  268. package/dist/cli-bundle/chunks/delete-7HPGI4GZ.js +55 -0
  269. package/dist/cli-bundle/chunks/delete-7HPGI4GZ.js.map +1 -0
  270. package/dist/cli-bundle/chunks/{delete-RHCTEORS.js → delete-VXUPH5RS.js} +7 -8
  271. package/dist/cli-bundle/chunks/{delete-RHCTEORS.js.map → delete-VXUPH5RS.js.map} +1 -1
  272. package/dist/cli-bundle/chunks/{deps-MZYCMLAO.js → deps-JSRRWC3Z.js} +7 -8
  273. package/dist/cli-bundle/chunks/{deps-MZYCMLAO.js.map → deps-JSRRWC3Z.js.map} +1 -1
  274. package/dist/cli-bundle/chunks/deps-SCZIFK2Z.js +225 -0
  275. package/dist/cli-bundle/chunks/deps-SCZIFK2Z.js.map +1 -0
  276. package/dist/cli-bundle/chunks/docs-GJK6K4VP.js +31 -0
  277. package/dist/cli-bundle/chunks/docs-GJK6K4VP.js.map +1 -0
  278. package/dist/cli-bundle/chunks/{docs-FXXUCZYU.js → docs-WW4N3MBM.js} +9 -10
  279. package/dist/cli-bundle/chunks/{docs-FXXUCZYU.js.map → docs-WW4N3MBM.js.map} +1 -1
  280. package/dist/cli-bundle/chunks/{extension-B4WL7BQU.js → extension-J7IBMFTD.js} +4 -5
  281. package/dist/cli-bundle/chunks/extension-VDY2U33M.js +28 -0
  282. package/dist/cli-bundle/chunks/extension-VDY2U33M.js.map +1 -0
  283. package/dist/cli-bundle/chunks/files-ISZJGILQ.js +282 -0
  284. package/dist/cli-bundle/chunks/files-ISZJGILQ.js.map +1 -0
  285. package/dist/cli-bundle/chunks/{files-WVOX67PE.js → files-WKOD326U.js} +9 -10
  286. package/dist/cli-bundle/chunks/{files-WVOX67PE.js.map → files-WKOD326U.js.map} +1 -1
  287. package/dist/cli-bundle/chunks/gc-JDVJ6OQ2.js +362 -0
  288. package/dist/cli-bundle/chunks/gc-JDVJ6OQ2.js.map +1 -0
  289. package/dist/cli-bundle/chunks/gc-ULPVWMTN.js +372 -0
  290. package/dist/cli-bundle/chunks/gc-ULPVWMTN.js.map +7 -0
  291. package/dist/cli-bundle/chunks/get-RV37HT3G.js +194 -0
  292. package/dist/cli-bundle/chunks/get-RV37HT3G.js.map +1 -0
  293. package/dist/cli-bundle/chunks/{get-LTK3HOCQ.js → get-WXU6WI5P.js} +16 -17
  294. package/dist/cli-bundle/chunks/get-WXU6WI5P.js.map +7 -0
  295. package/dist/cli-bundle/chunks/{health-TCWL55KM.js → health-6L6EH4WR.js} +57 -16
  296. package/dist/cli-bundle/chunks/health-6L6EH4WR.js.map +7 -0
  297. package/dist/cli-bundle/chunks/health-LOI2HHKB.js +1271 -0
  298. package/dist/cli-bundle/chunks/health-LOI2HHKB.js.map +1 -0
  299. package/dist/cli-bundle/chunks/history-2BA3T5AE.js +20 -0
  300. package/dist/cli-bundle/chunks/history-PKN67D5O.js +24 -0
  301. package/dist/cli-bundle/chunks/history-PKN67D5O.js.map +1 -0
  302. package/dist/cli-bundle/chunks/history-redact-JBZNXHGR.js +19 -0
  303. package/dist/cli-bundle/chunks/history-redact-V4FOJGS7.js +23 -0
  304. package/dist/cli-bundle/chunks/history-redact-V4FOJGS7.js.map +1 -0
  305. package/dist/cli-bundle/chunks/{history-repair-ZWSTDRH2.js → history-repair-HIBCBIKK.js} +12 -14
  306. package/dist/cli-bundle/chunks/{history-repair-ZWSTDRH2.js.map → history-repair-HIBCBIKK.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/history-repair-SDMHR7JT.js +193 -0
  308. package/dist/cli-bundle/chunks/history-repair-SDMHR7JT.js.map +1 -0
  309. package/dist/cli-bundle/chunks/init-HIVSNX3O.js +16 -0
  310. package/dist/cli-bundle/chunks/init-P56QYWJF.js +20 -0
  311. package/dist/cli-bundle/chunks/init-P56QYWJF.js.map +1 -0
  312. package/dist/cli-bundle/chunks/learnings-GDFRG5J7.js +44 -0
  313. package/dist/cli-bundle/chunks/learnings-GDFRG5J7.js.map +1 -0
  314. package/dist/cli-bundle/chunks/{learnings-NXTWE3FR.js → learnings-MIXSESLK.js} +10 -11
  315. package/dist/cli-bundle/chunks/{learnings-NXTWE3FR.js.map → learnings-MIXSESLK.js.map} +1 -1
  316. package/dist/cli-bundle/chunks/list-FGOWQMSM.js +24 -0
  317. package/dist/cli-bundle/chunks/list-FGOWQMSM.js.map +1 -0
  318. package/dist/cli-bundle/chunks/list-MUSQNMTD.js +20 -0
  319. package/dist/cli-bundle/chunks/{notes-DFS5ZGOO.js → notes-4XVSH2AZ.js} +10 -11
  320. package/dist/cli-bundle/chunks/{notes-DFS5ZGOO.js.map → notes-4XVSH2AZ.js.map} +1 -1
  321. package/dist/cli-bundle/chunks/notes-5UK3GEH2.js +44 -0
  322. package/dist/cli-bundle/chunks/notes-5UK3GEH2.js.map +1 -0
  323. package/dist/cli-bundle/chunks/plan-DUMBV3QB.js +1171 -0
  324. package/dist/cli-bundle/chunks/plan-DUMBV3QB.js.map +1 -0
  325. package/dist/cli-bundle/chunks/{plan-67AB2PLM.js → plan-SLMODHWX.js} +13 -14
  326. package/dist/cli-bundle/chunks/{plan-67AB2PLM.js.map → plan-SLMODHWX.js.map} +1 -1
  327. package/dist/cli-bundle/chunks/register-list-query-POCFZ5JW.js +229 -0
  328. package/dist/cli-bundle/chunks/register-list-query-POCFZ5JW.js.map +1 -0
  329. package/dist/cli-bundle/chunks/{register-list-query-UP3VRUFS.js → register-list-query-WST76HSQ.js} +26 -26
  330. package/dist/cli-bundle/chunks/register-list-query-WST76HSQ.js.map +7 -0
  331. package/dist/cli-bundle/chunks/register-mutation-N5GSUZJV.js +813 -0
  332. package/dist/cli-bundle/chunks/register-mutation-N5GSUZJV.js.map +1 -0
  333. package/dist/cli-bundle/chunks/{register-mutation-YWSBF545.js → register-mutation-OA675SOU.js} +154 -43
  334. package/dist/cli-bundle/chunks/register-mutation-OA675SOU.js.map +7 -0
  335. package/dist/cli-bundle/chunks/register-operations-GNHBE5I3.js +383 -0
  336. package/dist/cli-bundle/chunks/register-operations-GNHBE5I3.js.map +1 -0
  337. package/dist/cli-bundle/chunks/{register-operations-3BDTGSDH.js → register-operations-N3PMHXH5.js} +49 -37
  338. package/dist/cli-bundle/chunks/register-operations-N3PMHXH5.js.map +7 -0
  339. package/dist/cli-bundle/chunks/register-setup-JIMPKJKV.js +242 -0
  340. package/dist/cli-bundle/chunks/register-setup-JIMPKJKV.js.map +1 -0
  341. package/dist/cli-bundle/chunks/{register-setup-V56GDRUS.js → register-setup-ZHJI2DI3.js} +18 -19
  342. package/dist/cli-bundle/chunks/{register-setup-V56GDRUS.js.map → register-setup-ZHJI2DI3.js.map} +2 -2
  343. package/dist/cli-bundle/chunks/restore-D4RGNX33.js +17 -0
  344. package/dist/cli-bundle/chunks/restore-PBL6T5TW.js +21 -0
  345. package/dist/cli-bundle/chunks/restore-PBL6T5TW.js.map +1 -0
  346. package/dist/cli-bundle/chunks/schema-2NOO6NGB.js +780 -0
  347. package/dist/cli-bundle/chunks/schema-2NOO6NGB.js.map +7 -0
  348. package/dist/cli-bundle/chunks/schema-EBI4NLUO.js +770 -0
  349. package/dist/cli-bundle/chunks/schema-EBI4NLUO.js.map +1 -0
  350. package/dist/cli-bundle/chunks/search-JPUQTVCY.js +1127 -0
  351. package/dist/cli-bundle/chunks/search-JPUQTVCY.js.map +1 -0
  352. package/dist/cli-bundle/chunks/{search-HENBL456.js → search-OA6JX27A.js} +25 -16
  353. package/dist/cli-bundle/chunks/search-OA6JX27A.js.map +7 -0
  354. package/dist/cli-bundle/chunks/stats-CV54BAWY.js +202 -0
  355. package/dist/cli-bundle/chunks/stats-CV54BAWY.js.map +1 -0
  356. package/dist/cli-bundle/chunks/stats-XYB6KTFG.js +212 -0
  357. package/dist/cli-bundle/chunks/stats-XYB6KTFG.js.map +7 -0
  358. package/dist/cli-bundle/chunks/telemetry-LMJ7PFUO.js +251 -0
  359. package/dist/cli-bundle/chunks/telemetry-LMJ7PFUO.js.map +7 -0
  360. package/dist/cli-bundle/chunks/telemetry-NCMEPJNR.js +248 -0
  361. package/dist/cli-bundle/chunks/telemetry-NCMEPJNR.js.map +1 -0
  362. package/dist/cli-bundle/chunks/test-MXX3E5JL.js +31 -0
  363. package/dist/cli-bundle/chunks/test-WBROAJIE.js +35 -0
  364. package/dist/cli-bundle/chunks/test-WBROAJIE.js.map +1 -0
  365. package/dist/cli-bundle/chunks/test-all-N6NSRDTV.js +328 -0
  366. package/dist/cli-bundle/chunks/test-all-N6NSRDTV.js.map +1 -0
  367. package/dist/cli-bundle/chunks/{test-all-G2AZOHXI.js → test-all-NTOZ7C3M.js} +13 -14
  368. package/dist/cli-bundle/chunks/{test-all-G2AZOHXI.js.map → test-all-NTOZ7C3M.js.map} +1 -1
  369. package/dist/cli-bundle/chunks/test-runs-V6A7LPWZ.js +929 -0
  370. package/dist/cli-bundle/chunks/test-runs-V6A7LPWZ.js.map +1 -0
  371. package/dist/cli-bundle/chunks/{test-runs-GX5HTPSF.js → test-runs-WMVTQU3Y.js} +5 -5
  372. package/dist/cli-bundle/chunks/update-OSV3NAQB.js +25 -0
  373. package/dist/cli-bundle/chunks/update-OSV3NAQB.js.map +1 -0
  374. package/dist/cli-bundle/chunks/update-YRXSUGYQ.js +21 -0
  375. package/dist/cli-bundle/chunks/update-many-EM6OXYGO.js +605 -0
  376. package/dist/cli-bundle/chunks/update-many-EM6OXYGO.js.map +1 -0
  377. package/dist/cli-bundle/chunks/{update-many-46HRSP2Q.js → update-many-KGGEYABR.js} +78 -146
  378. package/dist/cli-bundle/chunks/update-many-KGGEYABR.js.map +7 -0
  379. package/dist/cli-bundle/chunks/{upgrade-H5HHM5UV.js → upgrade-BLI7XBAJ.js} +5 -7
  380. package/dist/cli-bundle/chunks/{upgrade-H5HHM5UV.js.map → upgrade-BLI7XBAJ.js.map} +1 -1
  381. package/dist/cli-bundle/chunks/upgrade-LXPOQKFV.js +266 -0
  382. package/dist/cli-bundle/chunks/upgrade-LXPOQKFV.js.map +1 -0
  383. package/dist/cli-bundle/chunks/{validate-TMCVKIGZ.js → validate-AGOAUOVW.js} +61 -48
  384. package/dist/cli-bundle/chunks/validate-AGOAUOVW.js.map +7 -0
  385. package/dist/cli-bundle/chunks/validate-L5J6A7YO.js +1120 -0
  386. package/dist/cli-bundle/chunks/validate-L5J6A7YO.js.map +1 -0
  387. package/dist/cli-bundle/main.js +534 -1505
  388. package/dist/cli-bundle/main.js.map +4 -4
  389. package/dist/core/checkpoint/mutation-checkpoint.d.ts +44 -0
  390. package/dist/core/checkpoint/mutation-checkpoint.js +119 -0
  391. package/dist/core/checkpoint/mutation-checkpoint.js.map +1 -0
  392. package/dist/core/config/positional-value.js +4 -2
  393. package/dist/core/config/positional-value.js.map +1 -1
  394. package/dist/core/diagnostics/remediation.d.ts +73 -0
  395. package/dist/core/diagnostics/remediation.js +328 -0
  396. package/dist/core/diagnostics/remediation.js.map +1 -0
  397. package/dist/core/extensions/extension-hook-runtime.js +9 -2
  398. package/dist/core/extensions/extension-hook-runtime.js.map +1 -1
  399. package/dist/core/extensions/extension-types.d.ts +60 -4
  400. package/dist/core/extensions/extension-types.js +2 -2
  401. package/dist/core/extensions/extension-types.js.map +1 -1
  402. package/dist/core/extensions/index.d.ts +5 -1
  403. package/dist/core/extensions/index.js +61 -2
  404. package/dist/core/extensions/index.js.map +1 -1
  405. package/dist/core/extensions/item-fields.d.ts +5 -1
  406. package/dist/core/extensions/item-fields.js +126 -4
  407. package/dist/core/extensions/item-fields.js.map +1 -1
  408. package/dist/core/extensions/loader.js +283 -8
  409. package/dist/core/extensions/loader.js.map +1 -1
  410. package/dist/core/history/history-diff.d.ts +47 -0
  411. package/dist/core/history/history-diff.js +152 -0
  412. package/dist/core/history/history-diff.js.map +1 -0
  413. package/dist/core/history/history-storage-stats.d.ts +31 -0
  414. package/dist/core/history/history-storage-stats.js +101 -0
  415. package/dist/core/history/history-storage-stats.js.map +1 -0
  416. package/dist/core/item/item-format.d.ts +3 -2
  417. package/dist/core/item/item-format.js +15 -10
  418. package/dist/core/item/item-format.js.map +1 -1
  419. package/dist/core/item/status-filter.d.ts +29 -0
  420. package/dist/core/item/status-filter.js +97 -0
  421. package/dist/core/item/status-filter.js.map +1 -0
  422. package/dist/core/item/type-registry.js +4 -2
  423. package/dist/core/item/type-registry.js.map +1 -1
  424. package/dist/core/lock/lock-gc.d.ts +46 -0
  425. package/dist/core/lock/lock-gc.js +194 -0
  426. package/dist/core/lock/lock-gc.js.map +1 -0
  427. package/dist/core/output/output.js +17 -5
  428. package/dist/core/output/output.js.map +1 -1
  429. package/dist/core/schema/item-types-file.d.ts +15 -0
  430. package/dist/core/schema/item-types-file.js +27 -2
  431. package/dist/core/schema/item-types-file.js.map +1 -1
  432. package/dist/core/schema/runtime-field-filters.js +4 -3
  433. package/dist/core/schema/runtime-field-filters.js.map +1 -1
  434. package/dist/core/schema/runtime-field-values.d.ts +1 -1
  435. package/dist/core/schema/runtime-field-values.js +10 -4
  436. package/dist/core/schema/runtime-field-values.js.map +1 -1
  437. package/dist/core/schema/runtime-schema.js +75 -2
  438. package/dist/core/schema/runtime-schema.js.map +1 -1
  439. package/dist/core/schema/status-defs-file.d.ts +113 -0
  440. package/dist/core/schema/status-defs-file.js +260 -0
  441. package/dist/core/schema/status-defs-file.js.map +1 -0
  442. package/dist/core/schema/type-workflows.d.ts +64 -0
  443. package/dist/core/schema/type-workflows.js +98 -0
  444. package/dist/core/schema/type-workflows.js.map +1 -0
  445. package/dist/core/search/cache.d.ts +3 -1
  446. package/dist/core/search/cache.js +104 -28
  447. package/dist/core/search/cache.js.map +1 -1
  448. package/dist/core/search/http-client.d.ts +2 -2
  449. package/dist/core/search/http-client.js +2 -2
  450. package/dist/core/search/http-client.js.map +1 -1
  451. package/dist/core/search/vector-stores.d.ts +1 -0
  452. package/dist/core/search/vector-stores.js +64 -14
  453. package/dist/core/search/vector-stores.js.map +1 -1
  454. package/dist/core/search/vectorization-metadata.d.ts +13 -0
  455. package/dist/core/search/vectorization-metadata.js +65 -0
  456. package/dist/core/search/vectorization-metadata.js.map +1 -0
  457. package/dist/core/shared/serial-queue.d.ts +12 -0
  458. package/dist/core/shared/serial-queue.js +43 -0
  459. package/dist/core/shared/serial-queue.js.map +1 -0
  460. package/dist/core/shared/serialization.d.ts +1 -0
  461. package/dist/core/shared/serialization.js +86 -2
  462. package/dist/core/shared/serialization.js.map +1 -1
  463. package/dist/core/store/front-matter-cache.js +14 -5
  464. package/dist/core/store/front-matter-cache.js.map +1 -1
  465. package/dist/core/store/item-store.d.ts +2 -0
  466. package/dist/core/store/item-store.js +61 -6
  467. package/dist/core/store/item-store.js.map +1 -1
  468. package/dist/core/store/settings-validator.js +18 -2
  469. package/dist/core/store/settings-validator.js.map +1 -1
  470. package/dist/core/store/settings.d.ts +19 -1
  471. package/dist/core/store/settings.js +130 -10
  472. package/dist/core/store/settings.js.map +1 -1
  473. package/dist/core/telemetry/consent.js +3 -3
  474. package/dist/core/telemetry/consent.js.map +1 -1
  475. package/dist/core/telemetry/observability.js +5 -4
  476. package/dist/core/telemetry/observability.js.map +1 -1
  477. package/dist/core/telemetry/runtime.js +16 -4
  478. package/dist/core/telemetry/runtime.js.map +1 -1
  479. package/dist/mcp/server.d.ts +1 -0
  480. package/dist/mcp/server.js +372 -45
  481. package/dist/mcp/server.js.map +1 -1
  482. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -2
  483. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  484. package/dist/sdk/cli-contracts/commander-types.js +7 -2
  485. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  486. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  487. package/dist/sdk/cli-contracts/enum-contracts.js +6 -2
  488. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  489. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -0
  490. package/dist/sdk/cli-contracts/tool-option-contracts.js +53 -3
  491. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  492. package/dist/sdk/cli-contracts/tool-parameter-tables.js +42 -10
  493. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  494. package/dist/sdk/cli-contracts.d.ts +42 -1
  495. package/dist/sdk/cli-contracts.js +225 -19
  496. package/dist/sdk/cli-contracts.js.map +1 -1
  497. package/dist/sdk/errors.d.ts +22 -0
  498. package/dist/sdk/errors.js +46 -0
  499. package/dist/sdk/errors.js.map +1 -0
  500. package/dist/sdk/index.d.ts +2 -1
  501. package/dist/sdk/index.js +3 -2
  502. package/dist/sdk/index.js.map +1 -1
  503. package/dist/sdk/package-import-adapters.js +14 -3
  504. package/dist/sdk/package-import-adapters.js.map +1 -1
  505. package/dist/sdk/runtime.d.ts +1 -0
  506. package/dist/sdk/runtime.js +3 -2
  507. package/dist/sdk/runtime.js.map +1 -1
  508. package/dist/sdk/testing.d.ts +77 -0
  509. package/dist/sdk/testing.js +239 -0
  510. package/dist/sdk/testing.js.map +1 -0
  511. package/dist/types.d.ts +19 -0
  512. package/dist/types.js +3 -2
  513. package/dist/types.js.map +1 -1
  514. package/docs/AGENT_GUIDE.md +22 -3
  515. package/docs/ARCHITECTURE.md +11 -1
  516. package/docs/CLAUDE_CODE_PLUGIN.md +2 -2
  517. package/docs/COMMANDS.md +118 -7
  518. package/docs/CONFIGURATION.md +57 -2
  519. package/docs/EXTENSIONS.md +125 -6
  520. package/docs/EXTENSION_AUTHOR_CONTRACTS.md +73 -0
  521. package/docs/ONBOARDING.md +165 -0
  522. package/docs/QUICKSTART.md +3 -1
  523. package/docs/README.md +12 -4
  524. package/docs/RELEASING.md +38 -3
  525. package/docs/SDK.md +273 -1
  526. package/docs/TESTING.md +36 -1
  527. package/docs/examples/policy-restricted-extension/manifest.json +1 -0
  528. package/docs/examples/starter-extension/index.js +9 -1
  529. package/docs/examples/starter-extension/manifest.json +1 -0
  530. package/package.json +16 -7
  531. package/packages/pm-beads/extensions/beads/index.js +2 -4
  532. package/packages/pm-beads/extensions/beads/index.ts +43 -33
  533. package/packages/pm-beads/extensions/beads/manifest.json +12 -1
  534. package/packages/pm-calendar/README.md +6 -0
  535. package/packages/pm-calendar/extensions/calendar/index.js +6 -1
  536. package/packages/pm-calendar/extensions/calendar/index.ts +6 -1
  537. package/packages/pm-calendar/extensions/calendar/manifest.json +6 -1
  538. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +6 -1
  539. package/packages/pm-guide-shell/README.md +4 -0
  540. package/packages/pm-guide-shell/extensions/guide-shell/index.js +22 -0
  541. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +22 -0
  542. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +6 -1
  543. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +74 -3
  544. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +84 -4
  545. package/packages/pm-lifecycle-hooks/README.md +29 -0
  546. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +18 -0
  547. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +20 -0
  548. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +9 -0
  549. package/packages/pm-lifecycle-hooks/package.json +52 -0
  550. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +13 -1
  551. package/packages/pm-search-advanced/extensions/search-advanced/index.js +69 -1
  552. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +91 -2
  553. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +13 -1
  554. package/packages/pm-templates/extensions/templates/manifest.json +6 -1
  555. package/packages/pm-todos/extensions/todos/index.js +3 -7
  556. package/packages/pm-todos/extensions/todos/index.ts +55 -42
  557. package/packages/pm-todos/extensions/todos/manifest.json +13 -1
  558. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  559. package/plugins/pm-claude/README.md +7 -4
  560. package/plugins/pm-claude/agents/pm-coordinator.md +1 -1
  561. package/plugins/pm-claude/commands/pm-init.md +1 -1
  562. package/scripts/bundle-cli.mjs +121 -17
  563. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +0 -17
  564. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +0 -7
  565. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +0 -189
  566. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +0 -7
  567. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +0 -7
  568. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +0 -7
  569. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +0 -7
  570. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +0 -7
  571. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +0 -47
  572. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +0 -7
  573. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +0 -56
  574. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +0 -7
  575. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +0 -7
  576. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +0 -7
  577. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +0 -7
  578. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +0 -7
  579. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +0 -7
  580. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +0 -7
  581. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +0 -7
  582. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +0 -7
  583. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +0 -7
  584. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +0 -7
  585. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +0 -7
  586. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +0 -141
  587. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +0 -7
  588. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +0 -7
  589. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +0 -14
  590. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +0 -7
  591. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +0 -7
  592. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +0 -28
  593. package/dist/cli-bundle/chunks/gc-JWNF66EC.js +0 -181
  594. package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +0 -7
  595. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +0 -7
  596. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +0 -7
  597. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +0 -21
  598. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +0 -20
  599. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +0 -16
  600. package/dist/cli-bundle/chunks/list-OGWQPC26.js +0 -20
  601. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +0 -7
  602. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +0 -7
  603. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +0 -7
  604. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +0 -18
  605. package/dist/cli-bundle/chunks/schema-Q622KC46.js +0 -119
  606. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +0 -7
  607. package/dist/cli-bundle/chunks/search-HENBL456.js.map +0 -7
  608. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +0 -124
  609. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +0 -7
  610. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +0 -32
  611. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +0 -22
  612. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +0 -7
  613. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +0 -7
  614. /package/dist/cli-bundle/chunks/{activity-OWYSUZOY.js.map → activity-CVXTCHYY.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{aggregate-ADUOSFRO.js.map → aggregate-VNAHUNNF.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{chunk-D7AOMPRH.js.map → chunk-BQHUILZS.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{chunk-G57E5D7T.js.map → chunk-GU2ZJ2VV.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{chunk-AKOOMO3T.js.map → chunk-KAG77BY3.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{chunk-KBQY3YG5.js.map → chunk-KJ33AOCY.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{chunk-WJ2NAC37.js.map → chunk-N7ACFE26.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{chunk-PVNQLCIS.js.map → chunk-QO7EBBOM.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{chunk-A7E7PUVX.js.map → chunk-R6UFP2GE.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{chunk-CEFIVZPG.js.map → chunk-T3LC5LKB.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{chunk-JFWUHHS2.js.map → chunk-UM2GBHS4.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{chunk-SEXQN4KL.js.map → chunk-WKY2IBOQ.js.map} +0 -0
  626. /package/dist/cli-bundle/chunks/{chunk-NGN7UV5K.js.map → chunk-XLTD2HN3.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{chunk-L2FXEKDB.js.map → chunk-YL2DJGYS.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{close-XY4CSAYF.js.map → close-3HDWDA3L.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{create-PZVHRIZQ.js.map → create-JTZNCTQC.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{extension-B4WL7BQU.js.map → extension-J7IBMFTD.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{history-A2JUDXUE.js.map → history-2BA3T5AE.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{history-redact-ED6RFCPL.js.map → history-redact-JBZNXHGR.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{init-M2WUB4YH.js.map → init-HIVSNX3O.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{list-OGWQPC26.js.map → list-MUSQNMTD.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{restore-MB2ISME7.js.map → restore-D4RGNX33.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{test-VNBDRJ4Z.js.map → test-MXX3E5JL.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{test-runs-GX5HTPSF.js.map → test-runs-WMVTQU3Y.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{update-H6SCWNMA.js.map → update-YRXSUGYQ.js.map} +0 -0
@@ -0,0 +1,1340 @@
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]="83aa0c1e-d8e6-5e3e-ac80-b84dd7ee7bce")}catch(e){}}();
3
+ import {
4
+ normalizeItemId,
5
+ normalizeRawItemId
6
+ } from "./chunk-HZGUAH22.js";
7
+ import {
8
+ canonicalDocument,
9
+ parseItemDocument,
10
+ serializeItemDocument
11
+ } from "./chunk-LB3RUL2N.js";
12
+ import {
13
+ resolveItemTypeRegistry
14
+ } from "./chunk-2VBQ6ZXS.js";
15
+ import {
16
+ nowIso
17
+ } from "./chunk-TCD3R2PF.js";
18
+ import {
19
+ EMPTY_CANONICAL_DOCUMENT,
20
+ EXIT_CODE,
21
+ FRONT_MATTER_KEY_ORDER,
22
+ ITEM_FILE_EXTENSIONS,
23
+ PmCliError,
24
+ TYPE_TO_FOLDER,
25
+ appendLineAtomic,
26
+ ensureDir,
27
+ getActiveExtensionRegistrations,
28
+ getHistoryPath,
29
+ getItemFormatFromPath,
30
+ getItemPath,
31
+ getLockPath,
32
+ hasActiveOnReadHooks,
33
+ orderObject,
34
+ pathExists,
35
+ projectAfterCommandItemSnapshot,
36
+ recordAfterCommandAffectedItem,
37
+ resolveGovernanceKnobs,
38
+ runActiveOnReadHooks,
39
+ runActiveOnWriteHooks,
40
+ runActiveServiceOverride,
41
+ sha256Hex,
42
+ stableStringify,
43
+ toErrorMessage,
44
+ writeFileAtomic
45
+ } from "./chunk-5SFCOO6B.js";
46
+
47
+ // dist/core/extensions/item-fields.js
48
+ var RESERVED_ITEM_FIELD_NAMES = new Set(FRONT_MATTER_KEY_ORDER);
49
+ function normalizeFieldName(value) {
50
+ if (typeof value !== "string") {
51
+ return null;
52
+ }
53
+ const normalized = value.trim();
54
+ return normalized.length > 0 ? normalized : null;
55
+ }
56
+ function normalizeFieldType(value) {
57
+ if (typeof value !== "string") {
58
+ return null;
59
+ }
60
+ const normalized = value.trim().toLowerCase();
61
+ if (normalized === "string" || normalized === "number" || normalized === "boolean" || normalized === "array" || normalized === "object") {
62
+ return normalized;
63
+ }
64
+ return null;
65
+ }
66
+ function cloneFieldValue(value) {
67
+ try {
68
+ return structuredClone(value);
69
+ } catch {
70
+ return value;
71
+ }
72
+ }
73
+ function parseFieldAssignment(raw) {
74
+ const trimmed = raw.trim();
75
+ const separatorIndex = trimmed.indexOf("=");
76
+ if (separatorIndex <= 0) {
77
+ throw new PmCliError(`--field entries must use name=value syntax, received: ${raw}`, EXIT_CODE.USAGE);
78
+ }
79
+ const key = trimmed.slice(0, separatorIndex).trim();
80
+ const value = trimmed.slice(separatorIndex + 1);
81
+ if (key.length === 0) {
82
+ throw new PmCliError("--field entries require a non-empty field name", EXIT_CODE.USAGE);
83
+ }
84
+ return { key, value };
85
+ }
86
+ function parseJsonFieldValue(raw, fieldName, expectedType) {
87
+ try {
88
+ const parsed = JSON.parse(raw);
89
+ if (expectedType === "array" && Array.isArray(parsed)) {
90
+ return parsed;
91
+ }
92
+ if (expectedType === "object" && typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
93
+ return parsed;
94
+ }
95
+ } catch {
96
+ }
97
+ throw new PmCliError(`--field ${fieldName}=... must be valid JSON ${expectedType}`, EXIT_CODE.USAGE);
98
+ }
99
+ function coerceRegisteredFieldValue(fieldName, fieldType, raw) {
100
+ if (fieldType === "string") {
101
+ return raw;
102
+ }
103
+ if (fieldType === "number") {
104
+ const trimmed = raw.trim();
105
+ if (trimmed.length === 0) {
106
+ throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);
107
+ }
108
+ const parsed = Number(trimmed);
109
+ if (!Number.isFinite(parsed)) {
110
+ throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);
111
+ }
112
+ return parsed;
113
+ }
114
+ if (fieldType === "boolean") {
115
+ const normalized = raw.trim().toLowerCase();
116
+ if (normalized === "true" || normalized === "1" || normalized === "yes") {
117
+ return true;
118
+ }
119
+ if (normalized === "false" || normalized === "0" || normalized === "no") {
120
+ return false;
121
+ }
122
+ throw new PmCliError(`--field ${fieldName}=... must be one of true|false|1|0|yes|no`, EXIT_CODE.USAGE);
123
+ }
124
+ return parseJsonFieldValue(raw, fieldName, fieldType);
125
+ }
126
+ function collectRegisteredFieldDefinitions(registrations) {
127
+ const definitions = /* @__PURE__ */ new Map();
128
+ if (!registrations) {
129
+ return definitions;
130
+ }
131
+ for (const registration of registrations.item_fields) {
132
+ for (const definition of registration.fields) {
133
+ const fieldName = normalizeFieldName(definition.name);
134
+ const fieldType = normalizeFieldType(definition.type);
135
+ if (!fieldName || !fieldType) {
136
+ continue;
137
+ }
138
+ const existing = definitions.get(fieldName);
139
+ if (existing && existing.type !== fieldType) {
140
+ throw new PmCliError(`Extension item field "${fieldName}" is declared with conflicting types: ${existing.type}, ${fieldType}`, EXIT_CODE.USAGE, {
141
+ code: "extension_item_field_type_conflict",
142
+ nextSteps: ["Make every active extension declaration for this field use the same type."]
143
+ });
144
+ }
145
+ definitions.set(fieldName, { name: fieldName, type: fieldType });
146
+ }
147
+ }
148
+ return definitions;
149
+ }
150
+ function assertNotReservedItemFieldName(fieldName) {
151
+ if (!RESERVED_ITEM_FIELD_NAMES.has(fieldName)) {
152
+ return;
153
+ }
154
+ throw new PmCliError(`Extension item field "${fieldName}" collides with reserved item metadata`, EXIT_CODE.USAGE, {
155
+ code: "extension_item_field_reserved",
156
+ nextSteps: ["Rename the extension item field, preferably with an extension-specific prefix."]
157
+ });
158
+ }
159
+ function collectRegisteredItemFieldNames(registrations) {
160
+ return [...collectRegisteredFieldDefinitions(registrations).keys()].sort((left, right) => left.localeCompare(right));
161
+ }
162
+ function parseRegisteredItemFieldAssignments(rawFields, registrations) {
163
+ if (!rawFields || rawFields.length === 0) {
164
+ return {};
165
+ }
166
+ const definitions = collectRegisteredFieldDefinitions(registrations);
167
+ const values = {};
168
+ for (const raw of rawFields) {
169
+ const { key, value } = parseFieldAssignment(raw);
170
+ const definition = definitions.get(key);
171
+ if (!definition) {
172
+ const known = [...definitions.keys()].sort((left, right) => left.localeCompare(right));
173
+ throw new PmCliError(`--field ${key} is not declared by an active extension item-field registration`, EXIT_CODE.USAGE, {
174
+ code: "extension_item_field_unknown",
175
+ recovery: { provided_fields: known },
176
+ nextSteps: known.length > 0 ? [`Use one of the declared fields: ${known.join(", ")}`] : ["Activate an extension that calls registerItemFields before setting extension fields."]
177
+ });
178
+ }
179
+ assertNotReservedItemFieldName(definition.name);
180
+ values[definition.name] = coerceRegisteredFieldValue(definition.name, definition.type, value);
181
+ }
182
+ return values;
183
+ }
184
+ function isValidFieldType(value, expectedType) {
185
+ if (expectedType === "string") {
186
+ return typeof value === "string";
187
+ }
188
+ if (expectedType === "number") {
189
+ return typeof value === "number" && Number.isFinite(value);
190
+ }
191
+ if (expectedType === "boolean") {
192
+ return typeof value === "boolean";
193
+ }
194
+ if (expectedType === "array") {
195
+ return Array.isArray(value);
196
+ }
197
+ return typeof value === "object" && value !== null && !Array.isArray(value);
198
+ }
199
+ function isAllowedFieldValue(value, allowed) {
200
+ if (!allowed || allowed.length === 0) {
201
+ return true;
202
+ }
203
+ return allowed.some((candidate) => Object.is(candidate, value));
204
+ }
205
+ function applyRegisteredItemFieldDefaultsAndValidation(frontMatter, registrations, options = {}) {
206
+ if (!registrations) {
207
+ return;
208
+ }
209
+ collectRegisteredFieldDefinitions(registrations);
210
+ for (const registration of registrations.item_fields) {
211
+ for (const definition of registration.fields) {
212
+ const fieldName = normalizeFieldName(definition.name);
213
+ if (!fieldName) {
214
+ continue;
215
+ }
216
+ assertNotReservedItemFieldName(fieldName);
217
+ if (!(fieldName in frontMatter) && !options.skipDefaultFields?.has(fieldName) && Object.prototype.hasOwnProperty.call(definition, "default")) {
218
+ frontMatter[fieldName] = cloneFieldValue(definition.default);
219
+ }
220
+ const currentValue = frontMatter[fieldName];
221
+ if (currentValue === void 0) {
222
+ continue;
223
+ }
224
+ const expectedType = normalizeFieldType(definition.type);
225
+ if (expectedType && !isValidFieldType(currentValue, expectedType)) {
226
+ throw new TypeError(`Item field "${fieldName}" must be of type ${expectedType}`);
227
+ }
228
+ const allowedValues = Array.isArray(definition.values) ? definition.values : void 0;
229
+ if (!isAllowedFieldValue(currentValue, allowedValues)) {
230
+ throw new TypeError(`Item field "${fieldName}" must match one of the configured allowed values`);
231
+ }
232
+ }
233
+ }
234
+ }
235
+
236
+ // dist/core/item/item-record.js
237
+ function toItemRecord(item) {
238
+ return item;
239
+ }
240
+
241
+ // dist/core/history/history.js
242
+ import jsonPatch from "fast-json-patch";
243
+ var EMPTY_LEGACY_HASH_DOCUMENT = {
244
+ front_matter: {},
245
+ body: ""
246
+ };
247
+ function decodeJsonPointer(path5) {
248
+ if (!path5 || path5 === "/") {
249
+ return [];
250
+ }
251
+ if (!path5.startsWith("/")) {
252
+ return [];
253
+ }
254
+ return path5.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
255
+ }
256
+ function isDefinedPointerPath(document, path5) {
257
+ const segments = decodeJsonPointer(path5);
258
+ if (segments.length === 0) {
259
+ return true;
260
+ }
261
+ let cursor = document;
262
+ for (const segment of segments) {
263
+ if (Array.isArray(cursor)) {
264
+ if (segment === "-" || !/^(0|[1-9]\d*)$/.test(segment)) {
265
+ return false;
266
+ }
267
+ const index = Number(segment);
268
+ if (!Number.isInteger(index) || index < 0 || index >= cursor.length) {
269
+ return false;
270
+ }
271
+ const next2 = cursor[index];
272
+ if (next2 === void 0) {
273
+ return false;
274
+ }
275
+ cursor = next2;
276
+ continue;
277
+ }
278
+ if (typeof cursor !== "object" || cursor === null) {
279
+ return false;
280
+ }
281
+ if (!Object.prototype.hasOwnProperty.call(cursor, segment)) {
282
+ return false;
283
+ }
284
+ const next = cursor[segment];
285
+ if (next === void 0) {
286
+ return false;
287
+ }
288
+ cursor = next;
289
+ }
290
+ return true;
291
+ }
292
+ function normalizeHistoryPatchOps(beforeDocument, patch) {
293
+ const normalized = [];
294
+ let replayCursor = structuredClone(beforeDocument);
295
+ for (const operation of patch) {
296
+ const normalizedOperation = operation.op === "replace" && !isDefinedPointerPath(replayCursor, operation.path) ? { ...operation, op: "add" } : operation;
297
+ normalized.push(normalizedOperation);
298
+ replayCursor = jsonPatch.applyPatch(replayCursor, [normalizedOperation], true, true).newDocument;
299
+ }
300
+ return normalized;
301
+ }
302
+ function canonicalHashDocument(document) {
303
+ const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;
304
+ if (!hasMetadata) {
305
+ return {
306
+ front_matter: {},
307
+ body: document.body ?? ""
308
+ };
309
+ }
310
+ const canonical = canonicalDocument(document);
311
+ const orderedFrontMatter = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);
312
+ return {
313
+ front_matter: orderedFrontMatter,
314
+ body: canonical.body
315
+ };
316
+ }
317
+ function canonicalPatchDocument(document) {
318
+ const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;
319
+ if (!hasMetadata) {
320
+ return {
321
+ metadata: {},
322
+ body: document.body ?? ""
323
+ };
324
+ }
325
+ const canonical = canonicalDocument(document);
326
+ const orderedMetadata = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);
327
+ return {
328
+ metadata: orderedMetadata,
329
+ body: canonical.body
330
+ };
331
+ }
332
+ function hashDocument(document) {
333
+ return sha256Hex(stableStringify(canonicalHashDocument(document)));
334
+ }
335
+ function hashEmptyDocument() {
336
+ return sha256Hex(stableStringify(EMPTY_LEGACY_HASH_DOCUMENT));
337
+ }
338
+ function createHistoryEntry(params) {
339
+ const beforeHashCanonical = canonicalHashDocument(params.before);
340
+ const afterHashCanonical = canonicalHashDocument(params.after);
341
+ const beforePatchCanonical = canonicalPatchDocument(params.before);
342
+ const afterPatchCanonical = canonicalPatchDocument(params.after);
343
+ const rawPatch = jsonPatch.compare(beforePatchCanonical, afterPatchCanonical);
344
+ const patch = normalizeHistoryPatchOps(beforePatchCanonical, rawPatch);
345
+ return {
346
+ ts: params.nowIso,
347
+ author: params.author,
348
+ op: params.op,
349
+ patch,
350
+ before_hash: sha256Hex(stableStringify(beforeHashCanonical)),
351
+ after_hash: sha256Hex(stableStringify(afterHashCanonical)),
352
+ message: params.message === void 0 ? void 0 : params.message
353
+ };
354
+ }
355
+ async function appendHistoryEntry(historyPath, entry) {
356
+ const override = await runActiveServiceOverride("history_append", {
357
+ history_path: historyPath,
358
+ entry
359
+ });
360
+ if (override.handled) {
361
+ if (override.result === false) {
362
+ return;
363
+ }
364
+ if (typeof override.result === "string") {
365
+ await appendLineAtomic(historyPath, override.result);
366
+ return;
367
+ }
368
+ if (typeof override.result === "object" && override.result !== null) {
369
+ const record = override.result;
370
+ if (record.skip === true) {
371
+ return;
372
+ }
373
+ const nextHistoryPath = typeof record.history_path === "string" ? record.history_path : historyPath;
374
+ if (typeof record.line === "string") {
375
+ await appendLineAtomic(nextHistoryPath, record.line);
376
+ return;
377
+ }
378
+ const nextEntry = record.entry ?? entry;
379
+ await appendLineAtomic(nextHistoryPath, JSON.stringify(nextEntry));
380
+ return;
381
+ }
382
+ }
383
+ await appendLineAtomic(historyPath, JSON.stringify(entry));
384
+ }
385
+
386
+ // dist/core/history/history-stream-policy.js
387
+ import fs from "node:fs/promises";
388
+ import path from "node:path";
389
+ function toSortedUniqueItemIds(itemIds) {
390
+ return [...new Set(itemIds.filter((value) => value.trim().length > 0))].sort((left, right) => left.localeCompare(right));
391
+ }
392
+ function strictMissingStreamError(itemId, commandLabel) {
393
+ return new PmCliError(`Missing history stream for ${itemId}. ${commandLabel} requires history streams when settings.history.missing_stream is strict_error.`, EXIT_CODE.NOT_FOUND);
394
+ }
395
+ async function createStream(historyPath, commandLabel) {
396
+ await ensureDir(path.dirname(historyPath));
397
+ const handle = await fs.open(historyPath, "a");
398
+ await handle.close();
399
+ return runActiveOnWriteHooks({
400
+ path: historyPath,
401
+ scope: "project",
402
+ op: `${commandLabel}:history:auto_create`
403
+ });
404
+ }
405
+ async function enforceHistoryStreamPolicyForItem(params) {
406
+ return enforceHistoryStreamPolicyForItems({
407
+ pmRoot: params.pmRoot,
408
+ settings: params.settings,
409
+ itemIds: [params.itemId],
410
+ commandLabel: params.commandLabel
411
+ });
412
+ }
413
+ async function enforceHistoryStreamPolicyForItems(params) {
414
+ const ids = toSortedUniqueItemIds(params.itemIds);
415
+ const autoCreated = [];
416
+ const warnings = [];
417
+ for (const itemId of ids) {
418
+ const historyPath = getHistoryPath(params.pmRoot, itemId);
419
+ if (await pathExists(historyPath)) {
420
+ continue;
421
+ }
422
+ if (params.settings.history.missing_stream === "strict_error") {
423
+ throw strictMissingStreamError(itemId, params.commandLabel);
424
+ }
425
+ warnings.push(...await createStream(historyPath, params.commandLabel));
426
+ warnings.push(`history_stream_auto_created:${itemId}`);
427
+ autoCreated.push(itemId);
428
+ }
429
+ return {
430
+ auto_created_ids: autoCreated,
431
+ warnings
432
+ };
433
+ }
434
+
435
+ // dist/core/lock/lock.js
436
+ import fs2 from "node:fs/promises";
437
+ import path2 from "node:path";
438
+ function parseLockInfo(raw) {
439
+ let parsed;
440
+ try {
441
+ parsed = JSON.parse(raw);
442
+ } catch {
443
+ return {
444
+ info: null,
445
+ warnings: ["lock_info_invalid_json"]
446
+ };
447
+ }
448
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
449
+ return {
450
+ info: null,
451
+ warnings: ["lock_info_invalid_shape"]
452
+ };
453
+ }
454
+ const candidate = parsed;
455
+ const id = candidate.id;
456
+ const pid = candidate.pid;
457
+ const owner = candidate.owner;
458
+ const createdAt = candidate.created_at;
459
+ const ttlSeconds = candidate.ttl_seconds;
460
+ if (typeof id !== "string" || typeof pid !== "number" || !Number.isFinite(pid) || typeof owner !== "string" || typeof createdAt !== "string" || typeof ttlSeconds !== "number" || !Number.isFinite(ttlSeconds)) {
461
+ return {
462
+ info: null,
463
+ warnings: ["lock_info_invalid_shape"]
464
+ };
465
+ }
466
+ return {
467
+ info: {
468
+ id,
469
+ pid,
470
+ owner,
471
+ created_at: createdAt,
472
+ ttl_seconds: ttlSeconds
473
+ },
474
+ warnings: []
475
+ };
476
+ }
477
+ async function readLockInfo(lockPath) {
478
+ try {
479
+ const raw = await fs2.readFile(lockPath, "utf8");
480
+ await runActiveOnReadHooks({
481
+ path: lockPath,
482
+ scope: "project"
483
+ });
484
+ return parseLockInfo(raw);
485
+ } catch (error) {
486
+ if (isErrno(error, "ENOENT")) {
487
+ return {
488
+ info: null,
489
+ warnings: []
490
+ };
491
+ }
492
+ return {
493
+ info: null,
494
+ warnings: ["lock_info_read_failed"]
495
+ };
496
+ }
497
+ }
498
+ function isErrno(error, code) {
499
+ return typeof error === "object" && error !== null && "code" in error && error.code === code;
500
+ }
501
+ async function emitLockWriteHook(lockPath, op) {
502
+ await runActiveOnWriteHooks({
503
+ path: lockPath,
504
+ scope: "project",
505
+ op
506
+ });
507
+ }
508
+ function buildLockPayload(id, owner, ttlSeconds) {
509
+ return {
510
+ id,
511
+ pid: process.pid,
512
+ owner,
513
+ created_at: nowIso(),
514
+ ttl_seconds: ttlSeconds
515
+ };
516
+ }
517
+ async function createLockFile(lockPath, id, owner, ttlSeconds) {
518
+ await fs2.mkdir(path2.dirname(lockPath), { recursive: true });
519
+ const handle = await fs2.open(lockPath, "wx");
520
+ try {
521
+ await handle.writeFile(`${JSON.stringify(buildLockPayload(id, owner, ttlSeconds), null, 2)}
522
+ `, "utf8");
523
+ } finally {
524
+ await handle.close();
525
+ }
526
+ await emitLockWriteHook(lockPath, "lock:create");
527
+ }
528
+ async function unlinkLockWithHook(lockPath, op) {
529
+ try {
530
+ await fs2.unlink(lockPath);
531
+ await emitLockWriteHook(lockPath, op);
532
+ } catch {
533
+ }
534
+ }
535
+ function isStaleLock(info, ttlSeconds) {
536
+ const createdAtMs = info?.created_at ? Date.parse(info.created_at) : Number.NaN;
537
+ const ageMs = Number.isFinite(createdAtMs) ? Date.now() - createdAtMs : Number.POSITIVE_INFINITY;
538
+ return ageMs > ttlSeconds * 1e3;
539
+ }
540
+ function lockOwnerSuffix(info) {
541
+ return info?.owner ? ` (owner ${info.owner})` : "";
542
+ }
543
+ async function handleExistingLock(lockPath, id, ttlSeconds, force, forceRequiredForStaleLock) {
544
+ const lockInfo = await readLockInfo(lockPath);
545
+ if (!isStaleLock(lockInfo.info, ttlSeconds)) {
546
+ throw new PmCliError(`Item ${id} is locked${lockOwnerSuffix(lockInfo.info)}`, EXIT_CODE.CONFLICT);
547
+ }
548
+ if (!force && forceRequiredForStaleLock) {
549
+ const warningSuffix = lockInfo.warnings.length > 0 ? ` (${lockInfo.warnings.join(",")})` : "";
550
+ throw new PmCliError(`Item ${id} lock is stale${warningSuffix}; rerun with --force when supported for this command`, EXIT_CODE.CONFLICT);
551
+ }
552
+ await unlinkLockWithHook(lockPath, "lock:stale_remove");
553
+ }
554
+ async function acquireLock(pmRoot, id, ttlSeconds, owner, force = false, forceRequiredForStaleLock = true) {
555
+ const lockOverride = await runActiveServiceOverride("lock_acquire", {
556
+ pm_root: pmRoot,
557
+ id,
558
+ ttl_seconds: ttlSeconds,
559
+ owner,
560
+ force,
561
+ force_required_for_stale_lock: forceRequiredForStaleLock
562
+ });
563
+ if (lockOverride.handled) {
564
+ const releaseFromFunction = typeof lockOverride.result === "function" ? lockOverride.result : null;
565
+ const releaseFromObject = typeof lockOverride.result === "object" && lockOverride.result !== null && "release" in lockOverride.result && typeof lockOverride.result.release === "function" ? lockOverride.result.release : null;
566
+ const release = releaseFromFunction ?? releaseFromObject;
567
+ if (release) {
568
+ return async () => {
569
+ await Promise.resolve(release());
570
+ await runActiveServiceOverride("lock_release", {
571
+ pm_root: pmRoot,
572
+ id,
573
+ owner
574
+ });
575
+ };
576
+ }
577
+ }
578
+ const lockPath = getLockPath(pmRoot, id);
579
+ for (let attempt = 0; attempt < 3; attempt += 1) {
580
+ try {
581
+ await createLockFile(lockPath, id, owner, ttlSeconds);
582
+ return async () => {
583
+ await unlinkLockWithHook(lockPath, "lock:release");
584
+ await runActiveServiceOverride("lock_release", {
585
+ pm_root: pmRoot,
586
+ id,
587
+ owner
588
+ });
589
+ };
590
+ } catch (error) {
591
+ if (!isErrno(error, "EEXIST")) {
592
+ throw new PmCliError(`Failed to acquire lock for ${id}: ${toErrorMessage(error)}`, EXIT_CODE.GENERIC_FAILURE);
593
+ }
594
+ await handleExistingLock(lockPath, id, ttlSeconds, force, forceRequiredForStaleLock);
595
+ }
596
+ }
597
+ throw new PmCliError(`Failed to acquire lock for ${id}`, EXIT_CODE.CONFLICT);
598
+ }
599
+
600
+ // dist/core/store/front-matter-cache.js
601
+ import fs3 from "node:fs/promises";
602
+ import path3 from "node:path";
603
+ import { createHash } from "node:crypto";
604
+ var CACHE_VERSION = 6;
605
+ var CACHE_FILENAME = "metadata-cache.json";
606
+ var BODY_CACHE_FILENAME = "metadata-cache-bodies.json";
607
+ var COLLECTIONS_CACHE_FILENAME = "metadata-cache-collections.json";
608
+ var HEAVY_METADATA_KEYS = [
609
+ "comments",
610
+ "notes",
611
+ "learnings",
612
+ "files",
613
+ "tests",
614
+ "test_runs",
615
+ "docs"
616
+ ];
617
+ function resolveActiveExtensionFieldNames() {
618
+ return collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
619
+ }
620
+ function splitHeavyMetadata(metadata) {
621
+ const light = { ...metadata };
622
+ const heavy = {};
623
+ for (const key of HEAVY_METADATA_KEYS) {
624
+ if (key in light) {
625
+ heavy[key] = light[key];
626
+ delete light[key];
627
+ }
628
+ }
629
+ return { light, heavy };
630
+ }
631
+ function mergeHeavyMetadata(light, heavy) {
632
+ if (!heavy || Object.keys(heavy).length === 0) {
633
+ return light;
634
+ }
635
+ return { ...light, ...heavy };
636
+ }
637
+ function computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames) {
638
+ const hash = createHash("sha256");
639
+ hash.update(`format:${preferredFormat ?? "default"}`);
640
+ const sortedTypes = Object.entries(typeToFolder).sort(([a], [b]) => a.localeCompare(b)).map(([type, folder]) => `${type}=${folder}`).join(",");
641
+ hash.update(`|types:${sortedTypes}`);
642
+ if (schema) {
643
+ hash.update(`|schema:${JSON.stringify(schema)}`);
644
+ }
645
+ if (extensionFieldNames.length > 0) {
646
+ hash.update(`|extension_fields:${extensionFieldNames.join(",")}`);
647
+ }
648
+ return hash.digest("hex").slice(0, 16);
649
+ }
650
+ function getCachePath(pmRoot) {
651
+ return path3.join(pmRoot, "runtime", CACHE_FILENAME);
652
+ }
653
+ function getBodyCachePath(pmRoot) {
654
+ return path3.join(pmRoot, "runtime", BODY_CACHE_FILENAME);
655
+ }
656
+ function getCollectionsCachePath(pmRoot) {
657
+ return path3.join(pmRoot, "runtime", COLLECTIONS_CACHE_FILENAME);
658
+ }
659
+ async function loadCache(pmRoot) {
660
+ try {
661
+ const raw = await fs3.readFile(getCachePath(pmRoot), "utf8");
662
+ const parsed = JSON.parse(raw);
663
+ if (parsed.version !== CACHE_VERSION || typeof parsed.entries !== "object" || parsed.entries === null) {
664
+ return null;
665
+ }
666
+ return parsed;
667
+ } catch {
668
+ return null;
669
+ }
670
+ }
671
+ async function loadBodyCache(pmRoot) {
672
+ try {
673
+ const raw = await fs3.readFile(getBodyCachePath(pmRoot), "utf8");
674
+ const parsed = JSON.parse(raw);
675
+ if (parsed.version !== CACHE_VERSION || typeof parsed.bodies !== "object" || parsed.bodies === null) {
676
+ return null;
677
+ }
678
+ return parsed;
679
+ } catch {
680
+ return null;
681
+ }
682
+ }
683
+ async function loadCollectionsCache(pmRoot) {
684
+ try {
685
+ const raw = await fs3.readFile(getCollectionsCachePath(pmRoot), "utf8");
686
+ const parsed = JSON.parse(raw);
687
+ if (parsed.version !== CACHE_VERSION || typeof parsed.collections !== "object" || parsed.collections === null) {
688
+ return null;
689
+ }
690
+ return parsed;
691
+ } catch {
692
+ return null;
693
+ }
694
+ }
695
+ async function persistCache(cachePath, envelope) {
696
+ await fs3.mkdir(path3.dirname(cachePath), { recursive: true });
697
+ await writeFileAtomic(cachePath, JSON.stringify(envelope));
698
+ }
699
+ function appendWarning(warnings, warning) {
700
+ if (warnings && !warnings.includes(warning)) {
701
+ warnings.push(warning);
702
+ }
703
+ }
704
+ function statMatches(signature, mtimeMs, ctimeMs, size) {
705
+ return signature.mtime_ms === mtimeMs && signature.ctime_ms === ctimeMs && signature.size === size;
706
+ }
707
+ async function listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, options = {}) {
708
+ const includeBody = options.includeBody !== false;
709
+ const includeCollections = options.includeCollections !== false;
710
+ const extensionFieldNames = resolveActiveExtensionFieldNames();
711
+ const contextFingerprint = computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames);
712
+ const existingCache = await loadCache(pmRoot);
713
+ const previousEntries = existingCache && existingCache.context_fingerprint === contextFingerprint ? existingCache.entries : {};
714
+ const existingBodyCache = includeBody ? await loadBodyCache(pmRoot) : null;
715
+ const previousBodies = existingBodyCache && existingBodyCache.context_fingerprint === contextFingerprint ? existingBodyCache.bodies : {};
716
+ const existingCollectionsCache = includeCollections ? await loadCollectionsCache(pmRoot) : null;
717
+ const previousCollections = existingCollectionsCache && existingCollectionsCache.context_fingerprint === contextFingerprint ? existingCollectionsCache.collections : {};
718
+ const entries = Object.entries(typeToFolder);
719
+ const dirResults = await Promise.all(entries.map(async ([, folder]) => {
720
+ const dirPath = path3.join(pmRoot, folder);
721
+ try {
722
+ const files = await fs3.readdir(dirPath);
723
+ return { folder, dirPath, files };
724
+ } catch (error) {
725
+ if (typeof error === "object" && error !== null && "code" in error && error.code !== "ENOENT") {
726
+ appendWarning(warnings, `item_list_directory_read_failed:${folder}`);
727
+ }
728
+ return { folder, dirPath, files: [] };
729
+ }
730
+ }));
731
+ const dispatchReadHooks = hasActiveOnReadHooks();
732
+ const newEntries = {};
733
+ const newBodies = {};
734
+ const newCollections = {};
735
+ const documentsById = /* @__PURE__ */ new Map();
736
+ let metadataMiss = false;
737
+ let bodyMiss = false;
738
+ let collectionsMiss = false;
739
+ const parseTasks = [];
740
+ for (const { folder, dirPath, files } of dirResults) {
741
+ for (const file of files) {
742
+ if (!ITEM_FILE_EXTENSIONS.some((ext) => file.toLowerCase().endsWith(ext))) {
743
+ continue;
744
+ }
745
+ const filePath = path3.join(dirPath, file);
746
+ const relativePath = path3.relative(pmRoot, filePath);
747
+ parseTasks.push((async () => {
748
+ try {
749
+ const stat = await fs3.stat(filePath);
750
+ const mtimeMs = stat.mtimeMs;
751
+ const ctimeMs = stat.ctimeMs;
752
+ const { size } = stat;
753
+ const itemFormat = getItemFormatFromPath(filePath);
754
+ if (dispatchReadHooks) {
755
+ for (const warning of await runActiveOnReadHooks({ path: filePath, scope: "project" })) {
756
+ appendWarning(warnings, warning);
757
+ }
758
+ }
759
+ const cachedEntry = previousEntries[relativePath];
760
+ const metadataCached = cachedEntry !== void 0 && statMatches(cachedEntry, mtimeMs, ctimeMs, size);
761
+ const cachedBody = previousBodies[relativePath];
762
+ const bodyCached = cachedBody !== void 0 && statMatches(cachedBody, mtimeMs, ctimeMs, size);
763
+ const cachedCollections = previousCollections[relativePath];
764
+ const collectionsCached = cachedCollections !== void 0 && statMatches(cachedCollections, mtimeMs, ctimeMs, size);
765
+ const needRead = !metadataCached || includeBody && !bodyCached || includeCollections && !collectionsCached;
766
+ let lightMetadata;
767
+ let heavyMetadata;
768
+ let bodyLength;
769
+ let body;
770
+ if (needRead) {
771
+ const raw = await fs3.readFile(filePath, "utf8");
772
+ const parsed = parseItemDocument(raw, {
773
+ format: itemFormat,
774
+ schema,
775
+ extensionFieldNames,
776
+ onWarning: (w) => appendWarning(warnings, w)
777
+ });
778
+ const split = splitHeavyMetadata(parsed.metadata);
779
+ lightMetadata = metadataCached ? cachedEntry.metadata : split.light;
780
+ bodyLength = metadataCached ? cachedEntry.body_length : parsed.body.length;
781
+ body = includeBody ? parsed.body : void 0;
782
+ if (includeCollections) {
783
+ heavyMetadata = collectionsCached ? cachedCollections.collections : split.heavy;
784
+ }
785
+ if (!metadataCached) {
786
+ metadataMiss = true;
787
+ }
788
+ if (includeBody && !bodyCached) {
789
+ bodyMiss = true;
790
+ }
791
+ if (includeCollections && !collectionsCached) {
792
+ collectionsMiss = true;
793
+ }
794
+ } else {
795
+ lightMetadata = cachedEntry.metadata;
796
+ bodyLength = cachedEntry.body_length;
797
+ body = includeBody ? cachedBody.body : void 0;
798
+ heavyMetadata = includeCollections && cachedCollections ? cachedCollections.collections : void 0;
799
+ }
800
+ newEntries[relativePath] = {
801
+ mtime_ms: mtimeMs,
802
+ ctime_ms: ctimeMs,
803
+ size,
804
+ metadata: lightMetadata,
805
+ body_length: bodyLength
806
+ };
807
+ if (includeBody && body !== void 0) {
808
+ newBodies[relativePath] = { mtime_ms: mtimeMs, ctime_ms: ctimeMs, size, body };
809
+ }
810
+ if (includeCollections && heavyMetadata !== void 0) {
811
+ newCollections[relativePath] = { mtime_ms: mtimeMs, ctime_ms: ctimeMs, size, collections: heavyMetadata };
812
+ }
813
+ const metadata = includeCollections ? mergeHeavyMetadata(lightMetadata, heavyMetadata) : lightMetadata;
814
+ const existing = documentsById.get(metadata.id);
815
+ const candidate = {
816
+ metadata,
817
+ body,
818
+ item_format: itemFormat,
819
+ item_path: filePath
820
+ };
821
+ if (!existing) {
822
+ documentsById.set(metadata.id, { candidate, itemFormat });
823
+ } else {
824
+ const shouldReplace = preferredFormat ? itemFormat === preferredFormat && existing.itemFormat !== preferredFormat : itemFormat === "toon" && existing.itemFormat !== "toon";
825
+ if (shouldReplace) {
826
+ documentsById.set(metadata.id, { candidate, itemFormat });
827
+ }
828
+ }
829
+ } catch {
830
+ appendWarning(warnings, `item_list_item_read_failed:${folder}/${file}`);
831
+ }
832
+ })());
833
+ }
834
+ }
835
+ await Promise.all(parseTasks);
836
+ const metadataDirty = metadataMiss || Object.keys(previousEntries).length !== Object.keys(newEntries).length;
837
+ if (metadataDirty || existingCache === null || existingCache.context_fingerprint !== contextFingerprint) {
838
+ await persistCache(getCachePath(pmRoot), {
839
+ version: CACHE_VERSION,
840
+ context_fingerprint: contextFingerprint,
841
+ entries: newEntries
842
+ }).catch(() => {
843
+ });
844
+ }
845
+ if (includeBody) {
846
+ const bodyDirty = bodyMiss || Object.keys(previousBodies).length !== Object.keys(newBodies).length;
847
+ if (bodyDirty || existingBodyCache === null || existingBodyCache.context_fingerprint !== contextFingerprint) {
848
+ await persistCache(getBodyCachePath(pmRoot), {
849
+ version: CACHE_VERSION,
850
+ context_fingerprint: contextFingerprint,
851
+ bodies: newBodies
852
+ }).catch(() => {
853
+ });
854
+ }
855
+ }
856
+ if (includeCollections) {
857
+ const collectionsDirty = collectionsMiss || Object.keys(previousCollections).length !== Object.keys(newCollections).length;
858
+ if (collectionsDirty || existingCollectionsCache === null || existingCollectionsCache.context_fingerprint !== contextFingerprint) {
859
+ await persistCache(getCollectionsCachePath(pmRoot), {
860
+ version: CACHE_VERSION,
861
+ context_fingerprint: contextFingerprint,
862
+ collections: newCollections
863
+ }).catch(() => {
864
+ });
865
+ }
866
+ }
867
+ return [...documentsById.values()].sort((left, right) => left.candidate.metadata.id.localeCompare(right.candidate.metadata.id)).map((entry) => entry.candidate);
868
+ }
869
+ async function listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema) {
870
+ const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
871
+ includeBody: false
872
+ });
873
+ return candidates.map((candidate) => ({
874
+ metadata: candidate.metadata,
875
+ body: candidate.body ?? ""
876
+ }));
877
+ }
878
+ async function listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema) {
879
+ const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
880
+ includeBody: false,
881
+ includeCollections: false
882
+ });
883
+ return candidates.map((candidate) => ({
884
+ metadata: candidate.metadata,
885
+ body: candidate.body ?? ""
886
+ }));
887
+ }
888
+
889
+ // dist/core/store/item-store.js
890
+ import fs4 from "node:fs/promises";
891
+ import path4 from "node:path";
892
+ async function fileExists(targetPath) {
893
+ try {
894
+ await fs4.access(targetPath);
895
+ return true;
896
+ } catch {
897
+ return false;
898
+ }
899
+ }
900
+ function appendWarning2(warnings, warning) {
901
+ if (!warnings) {
902
+ return;
903
+ }
904
+ if (!warnings.includes(warning)) {
905
+ warnings.push(warning);
906
+ }
907
+ }
908
+ function resolveActiveExtensionFieldNames2(explicit) {
909
+ return explicit ?? collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
910
+ }
911
+ function resolveItemFormatSearchOrder(preferredFormat) {
912
+ if (preferredFormat === "toon") {
913
+ return ["toon", "json_markdown"];
914
+ }
915
+ if (preferredFormat === "json_markdown") {
916
+ return ["json_markdown", "toon"];
917
+ }
918
+ return ["toon", "json_markdown"];
919
+ }
920
+ async function locateItem(pmRoot, rawId, idPrefix, preferredFormat, typeToFolder = TYPE_TO_FOLDER) {
921
+ const normalizedId = normalizeItemId(rawId, idPrefix);
922
+ const rawNormalizedId = normalizeRawItemId(rawId);
923
+ const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];
924
+ const entries = Object.entries(typeToFolder);
925
+ const searchOrder = resolveItemFormatSearchOrder(preferredFormat);
926
+ for (const candidateId of candidateIds) {
927
+ for (const [type] of entries) {
928
+ for (const itemFormat of searchOrder) {
929
+ const itemPath = getItemPath(pmRoot, type, candidateId, itemFormat, typeToFolder);
930
+ if (await fileExists(itemPath)) {
931
+ return {
932
+ id: candidateId,
933
+ type,
934
+ itemPath,
935
+ item_format: itemFormat
936
+ };
937
+ }
938
+ }
939
+ }
940
+ }
941
+ return null;
942
+ }
943
+ async function readLocatedItem(item, options = {}) {
944
+ const raw = await fs4.readFile(item.itemPath, "utf8");
945
+ await runActiveOnReadHooks({
946
+ path: item.itemPath,
947
+ scope: "project"
948
+ });
949
+ const document = parseItemDocument(raw, {
950
+ format: item.item_format,
951
+ schema: options.schema,
952
+ extensionFieldNames: resolveActiveExtensionFieldNames2(options.extensionFieldNames),
953
+ onWarning: (warning) => appendWarning2(options.warnings, warning)
954
+ });
955
+ return { raw, document };
956
+ }
957
+ async function listAllFrontMatter(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
958
+ const documents = await listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema);
959
+ return documents.map((document) => document.metadata);
960
+ }
961
+ async function listAllFrontMatterLight(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
962
+ const documents = await listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema);
963
+ return documents.map((document) => document.metadata);
964
+ }
965
+ async function listAllFrontMatterWithBody(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
966
+ const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, { includeBody: true });
967
+ return candidates.map((candidate) => ({
968
+ ...candidate.metadata,
969
+ body: candidate.body ?? ""
970
+ }));
971
+ }
972
+ async function listKnownItemIds(pmRoot, typeToFolder) {
973
+ const folders = new Set(Object.values(typeToFolder));
974
+ const allIds = [];
975
+ await Promise.all([...folders].map(async (folder) => {
976
+ try {
977
+ const entries = await fs4.readdir(path4.join(pmRoot, folder));
978
+ for (const entry of entries) {
979
+ for (const ext of ITEM_FILE_EXTENSIONS) {
980
+ if (entry.toLowerCase().endsWith(ext)) {
981
+ allIds.push(entry.slice(0, -ext.length));
982
+ break;
983
+ }
984
+ }
985
+ }
986
+ } catch {
987
+ }
988
+ }));
989
+ return allIds;
990
+ }
991
+ function levenshtein(a, b) {
992
+ if (a === b)
993
+ return 0;
994
+ if (a.length === 0)
995
+ return b.length;
996
+ if (b.length === 0)
997
+ return a.length;
998
+ let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
999
+ for (let i = 1; i <= a.length; i++) {
1000
+ const curr = [i];
1001
+ for (let j = 1; j <= b.length; j++) {
1002
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
1003
+ curr.push(Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost));
1004
+ }
1005
+ prev = curr;
1006
+ }
1007
+ return prev[b.length];
1008
+ }
1009
+ async function buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder) {
1010
+ const normalized = normalizeItemId(badId, idPrefix);
1011
+ const ids = await listKnownItemIds(pmRoot, typeToFolder);
1012
+ if (ids.length === 0)
1013
+ return [];
1014
+ const scored = ids.map((id) => ({ id, distance: levenshtein(id, normalized) })).filter((entry) => entry.distance <= Math.max(3, Math.floor(normalized.length / 2))).sort((left, right) => left.distance - right.distance).slice(0, 3).map((entry) => entry.id);
1015
+ return scored;
1016
+ }
1017
+ async function buildItemNotFoundError(pmRoot, badId, idPrefix, typeToFolder) {
1018
+ const suggestions = await buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder);
1019
+ const nextSteps = ["Confirm the active --path/PM_PATH scope, then retry with a valid id."];
1020
+ if (suggestions.length > 0) {
1021
+ nextSteps.unshift(`Did you mean one of: ${suggestions.join(", ")}?`);
1022
+ }
1023
+ return new PmCliError(`Item ${badId} not found`, EXIT_CODE.NOT_FOUND, { nextSteps });
1024
+ }
1025
+ function bypassesAssigneeConflict(op, bypassAssigneeConflict) {
1026
+ return op === "claim" || bypassAssigneeConflict === true && (op === "comment_add" || op === "note_add" || op === "learning_add" || op === "release" || op === "update" || op === "update_audit");
1027
+ }
1028
+ async function prepareLockedItem(params) {
1029
+ const typeToFolder = params.typeToFolder ?? resolveItemTypeRegistry(params.settings, getActiveExtensionRegistrations()).type_to_folder;
1030
+ const located = await locateItem(params.pmRoot, params.id, params.settings.id_prefix, params.settings.item_format, typeToFolder);
1031
+ if (!located) {
1032
+ throw await buildItemNotFoundError(params.pmRoot, params.id, params.settings.id_prefix, typeToFolder);
1033
+ }
1034
+ const releaseLock = await acquireLock(params.pmRoot, located.id, params.settings.locks.ttl_seconds, params.author, Boolean(params.force), params.settings.governance.force_required_for_stale_lock);
1035
+ try {
1036
+ const warnings = [];
1037
+ const { raw: originalRaw, document } = await readLocatedItem(located, {
1038
+ schema: params.settings.schema,
1039
+ extensionFieldNames: params.extensionFieldNames,
1040
+ warnings
1041
+ });
1042
+ const assigned = document.metadata.assignee?.trim();
1043
+ const governance = resolveGovernanceKnobs(params.settings);
1044
+ const hasOwnershipConflict = assigned && assigned !== params.author && !params.force && !bypassesAssigneeConflict(params.op, params.bypassAssigneeConflict);
1045
+ if (hasOwnershipConflict) {
1046
+ if (governance.ownership_enforcement === "strict") {
1047
+ throw new PmCliError(`Item ${located.id} is assigned to ${assigned}. Use --force to override.`, EXIT_CODE.CONFLICT);
1048
+ }
1049
+ if (governance.ownership_enforcement === "warn") {
1050
+ warnings.push(`ownership_warning:assignee_conflict:${located.id}:${assigned}`);
1051
+ }
1052
+ }
1053
+ return {
1054
+ typeToFolder,
1055
+ located,
1056
+ originalRaw,
1057
+ document,
1058
+ warnings,
1059
+ releaseLock
1060
+ };
1061
+ } catch (error) {
1062
+ await releaseLock();
1063
+ throw error;
1064
+ }
1065
+ }
1066
+ async function mutateItem(params) {
1067
+ const prepared = await prepareLockedItem({
1068
+ pmRoot: params.pmRoot,
1069
+ settings: params.settings,
1070
+ id: params.id,
1071
+ op: params.op,
1072
+ author: params.author,
1073
+ force: params.force,
1074
+ bypassAssigneeConflict: params.bypassAssigneeConflict,
1075
+ extensionFieldNames: params.extensionFieldNames,
1076
+ typeToFolder: params.typeToFolder
1077
+ });
1078
+ const { typeToFolder, located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;
1079
+ try {
1080
+ const historyPolicy = await enforceHistoryStreamPolicyForItem({
1081
+ pmRoot: params.pmRoot,
1082
+ settings: params.settings,
1083
+ itemId: located.id,
1084
+ commandLabel: params.op
1085
+ });
1086
+ const beforeDocument = canonicalDocument(document, {
1087
+ schema: params.settings.schema,
1088
+ extensionFieldNames: params.extensionFieldNames
1089
+ });
1090
+ const mutableDocument = canonicalDocument(structuredClone(document), {
1091
+ schema: params.settings.schema,
1092
+ extensionFieldNames: params.extensionFieldNames
1093
+ });
1094
+ const mutation = params.mutate(mutableDocument);
1095
+ mutableDocument.metadata.updated_at = nowIso();
1096
+ const afterDocument = canonicalDocument(mutableDocument, {
1097
+ schema: params.settings.schema,
1098
+ extensionFieldNames: params.extensionFieldNames
1099
+ });
1100
+ const targetItemFormat = "toon";
1101
+ const serializedAfter = serializeItemDocument(afterDocument, {
1102
+ format: targetItemFormat,
1103
+ schema: params.settings.schema,
1104
+ extensionFieldNames: params.extensionFieldNames
1105
+ });
1106
+ const targetItemPath = getItemPath(params.pmRoot, afterDocument.metadata.type, located.id, targetItemFormat, typeToFolder);
1107
+ const historyPath = getHistoryPath(params.pmRoot, located.id);
1108
+ const serviceWriteOverride = await runActiveServiceOverride("item_store_write", {
1109
+ op: params.op,
1110
+ pm_root: params.pmRoot,
1111
+ item_id: located.id,
1112
+ source_item_path: located.itemPath,
1113
+ target_item_path: targetItemPath,
1114
+ history_path: historyPath,
1115
+ item_format: targetItemFormat,
1116
+ before: beforeDocument,
1117
+ after: afterDocument,
1118
+ contents: serializedAfter
1119
+ });
1120
+ let effectiveTargetItemPath = targetItemPath;
1121
+ let effectiveSerializedAfter = serializedAfter;
1122
+ let skipItemWrite = false;
1123
+ if (serviceWriteOverride.handled && typeof serviceWriteOverride.result === "object" && serviceWriteOverride.result !== null) {
1124
+ const overrideRecord = serviceWriteOverride.result;
1125
+ if (typeof overrideRecord.target_item_path === "string" && overrideRecord.target_item_path.trim().length > 0) {
1126
+ effectiveTargetItemPath = overrideRecord.target_item_path;
1127
+ }
1128
+ if (typeof overrideRecord.contents === "string") {
1129
+ effectiveSerializedAfter = overrideRecord.contents;
1130
+ }
1131
+ if (overrideRecord.skip_write === true) {
1132
+ skipItemWrite = true;
1133
+ }
1134
+ }
1135
+ if (!skipItemWrite) {
1136
+ await writeFileAtomic(effectiveTargetItemPath, effectiveSerializedAfter);
1137
+ }
1138
+ if (!skipItemWrite && effectiveTargetItemPath !== located.itemPath) {
1139
+ await fs4.rm(located.itemPath);
1140
+ }
1141
+ const entry = createHistoryEntry({
1142
+ nowIso: afterDocument.metadata.updated_at,
1143
+ author: params.author,
1144
+ op: params.op,
1145
+ before: beforeDocument,
1146
+ after: afterDocument,
1147
+ message: params.message
1148
+ });
1149
+ try {
1150
+ await appendHistoryEntry(historyPath, entry);
1151
+ } catch (error) {
1152
+ if (!skipItemWrite && effectiveTargetItemPath !== located.itemPath) {
1153
+ await writeFileAtomic(located.itemPath, originalRaw);
1154
+ await fs4.rm(effectiveTargetItemPath, { force: true });
1155
+ } else if (!skipItemWrite) {
1156
+ await writeFileAtomic(located.itemPath, originalRaw);
1157
+ }
1158
+ throw error;
1159
+ }
1160
+ const hookWarnings = [
1161
+ ...await runActiveOnWriteHooks({
1162
+ path: effectiveTargetItemPath,
1163
+ scope: "project",
1164
+ op: params.op,
1165
+ item_id: afterDocument.metadata.id,
1166
+ item_type: afterDocument.metadata.type,
1167
+ before: beforeDocument,
1168
+ after: afterDocument,
1169
+ changed_fields: mutation.changedFields
1170
+ }),
1171
+ ...await runActiveOnWriteHooks({
1172
+ path: historyPath,
1173
+ scope: "project",
1174
+ op: `${params.op}:history`,
1175
+ item_id: afterDocument.metadata.id,
1176
+ item_type: afterDocument.metadata.type,
1177
+ before: beforeDocument,
1178
+ after: afterDocument,
1179
+ changed_fields: mutation.changedFields
1180
+ })
1181
+ ];
1182
+ recordAfterCommandAffectedItem({
1183
+ id: afterDocument.metadata.id,
1184
+ op: params.op,
1185
+ item_type: afterDocument.metadata.type,
1186
+ previous_status: beforeDocument.metadata.status,
1187
+ status: afterDocument.metadata.status,
1188
+ previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, mutation.changedFields),
1189
+ current: projectAfterCommandItemSnapshot(afterDocument.metadata, mutation.changedFields),
1190
+ changed_fields: mutation.changedFields
1191
+ });
1192
+ return {
1193
+ item: afterDocument.metadata,
1194
+ body: afterDocument.body,
1195
+ changedFields: mutation.changedFields,
1196
+ warnings: [
1197
+ ...parseWarnings,
1198
+ ...mutation.warnings ?? [],
1199
+ ...historyPolicy.warnings,
1200
+ ...serviceWriteOverride.warnings,
1201
+ ...hookWarnings
1202
+ ]
1203
+ };
1204
+ } finally {
1205
+ await releaseLock();
1206
+ }
1207
+ }
1208
+ async function deleteItem(params) {
1209
+ const prepared = await prepareLockedItem({
1210
+ pmRoot: params.pmRoot,
1211
+ settings: params.settings,
1212
+ id: params.id,
1213
+ op: "delete",
1214
+ author: params.author,
1215
+ force: params.force
1216
+ });
1217
+ const { located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;
1218
+ try {
1219
+ const historyPolicy = await enforceHistoryStreamPolicyForItem({
1220
+ pmRoot: params.pmRoot,
1221
+ settings: params.settings,
1222
+ itemId: located.id,
1223
+ commandLabel: "delete"
1224
+ });
1225
+ const beforeDocument = canonicalDocument(document, { schema: params.settings.schema });
1226
+ const deletionTimestamp = nowIso();
1227
+ const tombstoneDocument = EMPTY_CANONICAL_DOCUMENT;
1228
+ const historyEntry = createHistoryEntry({
1229
+ nowIso: deletionTimestamp,
1230
+ author: params.author,
1231
+ op: "delete",
1232
+ before: beforeDocument,
1233
+ after: tombstoneDocument,
1234
+ message: params.message
1235
+ });
1236
+ const historyPath = getHistoryPath(params.pmRoot, located.id);
1237
+ const serviceDeleteOverride = await runActiveServiceOverride("item_store_delete", {
1238
+ op: "delete",
1239
+ pm_root: params.pmRoot,
1240
+ item_id: located.id,
1241
+ item_path: located.itemPath,
1242
+ history_path: historyPath,
1243
+ before: beforeDocument
1244
+ });
1245
+ let effectiveItemPath = located.itemPath;
1246
+ let skipDelete = false;
1247
+ if (serviceDeleteOverride.handled && typeof serviceDeleteOverride.result === "object" && serviceDeleteOverride.result !== null) {
1248
+ const overrideRecord = serviceDeleteOverride.result;
1249
+ if (typeof overrideRecord.item_path === "string" && overrideRecord.item_path.trim().length > 0) {
1250
+ effectiveItemPath = overrideRecord.item_path;
1251
+ }
1252
+ if (overrideRecord.skip_delete === true) {
1253
+ skipDelete = true;
1254
+ }
1255
+ }
1256
+ if (params.dryRun === true) {
1257
+ return {
1258
+ item: beforeDocument.metadata,
1259
+ changedFields: ["deleted"],
1260
+ targetPath: effectiveItemPath,
1261
+ warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings]
1262
+ };
1263
+ }
1264
+ if (!skipDelete) {
1265
+ await fs4.rm(effectiveItemPath);
1266
+ }
1267
+ try {
1268
+ await appendHistoryEntry(historyPath, historyEntry);
1269
+ } catch (error) {
1270
+ if (!skipDelete) {
1271
+ await writeFileAtomic(effectiveItemPath, originalRaw);
1272
+ }
1273
+ throw error;
1274
+ }
1275
+ const hookWarnings = [
1276
+ ...await runActiveOnWriteHooks({
1277
+ path: effectiveItemPath,
1278
+ scope: "project",
1279
+ op: "delete",
1280
+ item_id: beforeDocument.metadata.id,
1281
+ item_type: beforeDocument.metadata.type,
1282
+ before: beforeDocument,
1283
+ after: tombstoneDocument,
1284
+ changed_fields: ["deleted"]
1285
+ }),
1286
+ ...await runActiveOnWriteHooks({
1287
+ path: historyPath,
1288
+ scope: "project",
1289
+ op: "delete:history",
1290
+ item_id: beforeDocument.metadata.id,
1291
+ item_type: beforeDocument.metadata.type,
1292
+ before: beforeDocument,
1293
+ after: tombstoneDocument,
1294
+ changed_fields: ["deleted"]
1295
+ })
1296
+ ];
1297
+ recordAfterCommandAffectedItem({
1298
+ id: beforeDocument.metadata.id,
1299
+ op: "delete",
1300
+ item_type: beforeDocument.metadata.type,
1301
+ previous_status: beforeDocument.metadata.status,
1302
+ previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, Object.keys(beforeDocument.metadata)),
1303
+ changed_fields: ["deleted"]
1304
+ });
1305
+ return {
1306
+ item: beforeDocument.metadata,
1307
+ changedFields: ["deleted"],
1308
+ warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings, ...hookWarnings]
1309
+ };
1310
+ } finally {
1311
+ await releaseLock();
1312
+ }
1313
+ }
1314
+
1315
+ export {
1316
+ collectRegisteredItemFieldNames,
1317
+ parseRegisteredItemFieldAssignments,
1318
+ applyRegisteredItemFieldDefaultsAndValidation,
1319
+ toItemRecord,
1320
+ hashDocument,
1321
+ hashEmptyDocument,
1322
+ createHistoryEntry,
1323
+ appendHistoryEntry,
1324
+ enforceHistoryStreamPolicyForItem,
1325
+ enforceHistoryStreamPolicyForItems,
1326
+ acquireLock,
1327
+ HEAVY_METADATA_KEYS,
1328
+ listAllDocumentCandidatesCached,
1329
+ locateItem,
1330
+ readLocatedItem,
1331
+ listAllFrontMatter,
1332
+ listAllFrontMatterLight,
1333
+ listAllFrontMatterWithBody,
1334
+ buildItemNotFoundError,
1335
+ mutateItem,
1336
+ deleteItem
1337
+ };
1338
+ //# sourceMappingURL=chunk-GGYWB3Y2.js.map
1339
+
1340
+ //# debugId=83aa0c1e-d8e6-5e3e-ac80-b84dd7ee7bce