@unbrained/pm-cli 2026.7.5 → 2026.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/cli/commands/annotation-command.d.ts +1 -0
  3. package/dist/cli/commands/annotation-command.js +29 -2
  4. package/dist/cli/commands/annotation-command.js.map +1 -1
  5. package/dist/cli/commands/comments.js +3 -4
  6. package/dist/cli/commands/comments.js.map +1 -1
  7. package/dist/cli/commands/extension/bundled-catalog.d.ts +3 -0
  8. package/dist/cli/commands/extension/bundled-catalog.js +38 -28
  9. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  10. package/dist/cli/commands/extension/install-sources.js +81 -18
  11. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  12. package/dist/cli/commands/health.js +9 -5
  13. package/dist/cli/commands/health.js.map +1 -1
  14. package/dist/cli/commands/learnings.js +5 -3
  15. package/dist/cli/commands/learnings.js.map +1 -1
  16. package/dist/cli/commands/notes.js +5 -3
  17. package/dist/cli/commands/notes.js.map +1 -1
  18. package/dist/cli/commands/reindex.js +4 -3
  19. package/dist/cli/commands/reindex.js.map +1 -1
  20. package/dist/cli/commands/search.js +3 -3
  21. package/dist/cli/commands/search.js.map +1 -1
  22. package/dist/cli/commands/test.d.ts +9 -0
  23. package/dist/cli/commands/test.js +144 -105
  24. package/dist/cli/commands/test.js.map +1 -1
  25. package/dist/cli/extension-command-help.js +10 -2
  26. package/dist/cli/extension-command-help.js.map +1 -1
  27. package/dist/cli/register-list-query.d.ts +1 -1
  28. package/dist/cli/register-list-query.js +18 -27
  29. package/dist/cli/register-list-query.js.map +1 -1
  30. package/dist/cli/register-operations.d.ts +0 -8
  31. package/dist/cli/register-operations.js +41 -46
  32. package/dist/cli/register-operations.js.map +1 -1
  33. package/dist/cli/register-setup.js +113 -13
  34. package/dist/cli/register-setup.js.map +1 -1
  35. package/dist/cli/registration-helpers.d.ts +5 -1
  36. package/dist/cli/registration-helpers.js +14 -2
  37. package/dist/cli/registration-helpers.js.map +1 -1
  38. package/dist/cli-bundle/chunks/append-F7WPGIQL.js +11 -0
  39. package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js → append-PVCTBVJG.js} +8 -9
  40. package/dist/cli-bundle/chunks/{chunk-PPE4YUQM.js → chunk-2APXX4TZ.js} +17 -28
  41. package/dist/cli-bundle/chunks/chunk-2APXX4TZ.js.map +1 -0
  42. package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js → chunk-2LEJGRQ7.js} +3 -12
  43. package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js.map → chunk-2LEJGRQ7.js.map} +1 -1
  44. package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js → chunk-2TILG6F2.js} +3 -3
  45. package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js → chunk-3G6UMXT3.js} +6 -8
  46. package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js.map → chunk-3G6UMXT3.js.map} +1 -1
  47. package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js → chunk-3TYOW6RR.js} +8 -8
  48. package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js → chunk-3X542TEY.js} +7 -7
  49. package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js → chunk-42LXP4VO.js} +14 -21
  50. package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js.map → chunk-42LXP4VO.js.map} +1 -1
  51. package/dist/cli-bundle/chunks/{chunk-5J2XPTAD.js → chunk-43SIHQND.js} +36 -15
  52. package/dist/cli-bundle/chunks/chunk-43SIHQND.js.map +7 -0
  53. package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js → chunk-43UQN754.js} +12 -19
  54. package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js.map → chunk-43UQN754.js.map} +1 -1
  55. package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js → chunk-43YSKY75.js} +4 -6
  56. package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js.map → chunk-43YSKY75.js.map} +1 -1
  57. package/dist/cli-bundle/chunks/{notes-72YXN5JX.js → chunk-4BKDAEDF.js} +6 -13
  58. package/dist/cli-bundle/chunks/{notes-72YXN5JX.js.map → chunk-4BKDAEDF.js.map} +2 -2
  59. package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js → chunk-4IQKDKGE.js} +18 -32
  60. package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js.map → chunk-4IQKDKGE.js.map} +1 -1
  61. package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js → chunk-4MZOKTI2.js} +6 -8
  62. package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js.map → chunk-4MZOKTI2.js.map} +1 -1
  63. package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js → chunk-52NS7JDP.js} +14 -20
  64. package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js.map → chunk-52NS7JDP.js.map} +1 -1
  65. package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js → chunk-565WYS5W.js} +12 -16
  66. package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js.map → chunk-565WYS5W.js.map} +1 -1
  67. package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js → chunk-5FIQ4EX3.js} +13 -19
  68. package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js.map → chunk-5FIQ4EX3.js.map} +1 -1
  69. package/dist/cli-bundle/chunks/{config-V57QD47V.js → chunk-6G6O3OPQ.js} +259 -41
  70. package/dist/cli-bundle/chunks/chunk-6G6O3OPQ.js.map +1 -0
  71. package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js → chunk-6LCJRGPD.js} +9 -13
  72. package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js.map → chunk-6LCJRGPD.js.map} +1 -1
  73. package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js → chunk-6UQCNWFV.js} +6 -8
  74. package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js.map → chunk-6UQCNWFV.js.map} +1 -1
  75. package/dist/cli-bundle/chunks/{chunk-LEKT4K7I.js → chunk-6XTSYPPO.js} +1216 -387
  76. package/dist/cli-bundle/chunks/chunk-6XTSYPPO.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js +5434 -0
  78. package/dist/cli-bundle/chunks/chunk-7ML7JONU.js.map +1 -0
  79. package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js → chunk-7PNQA24K.js} +30 -36
  80. package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js.map → chunk-7PNQA24K.js.map} +1 -1
  81. package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js → chunk-7VQ3JJN5.js} +2 -2
  82. package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js → chunk-7Y5N34HX.js} +8 -12
  83. package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js.map → chunk-7Y5N34HX.js.map} +1 -1
  84. package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js → chunk-AGAVEDIE.js} +7 -7
  85. package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js → chunk-AJUON7E6.js} +3 -3
  86. package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js → chunk-ARKHKYYS.js} +16 -30
  87. package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js.map → chunk-ARKHKYYS.js.map} +1 -1
  88. package/dist/cli-bundle/chunks/{chunk-7EQNAZX2.js → chunk-C5ACVMOI.js} +99 -51
  89. package/dist/cli-bundle/chunks/chunk-C5ACVMOI.js.map +7 -0
  90. package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js → chunk-CJQM7O7R.js} +16 -20
  91. package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js.map → chunk-CJQM7O7R.js.map} +1 -1
  92. package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js → chunk-D2DCTFTL.js} +7 -9
  93. package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js.map → chunk-D2DCTFTL.js.map} +1 -1
  94. package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js → chunk-DDDWVPID.js} +7 -11
  95. package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js.map → chunk-DDDWVPID.js.map} +1 -1
  96. package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js → chunk-DG6BSXZ7.js} +6 -13
  97. package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js.map → chunk-DG6BSXZ7.js.map} +2 -2
  98. package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js → chunk-DR2V5OIV.js} +3 -3
  99. package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js → chunk-E3LWJUGF.js} +4 -6
  100. package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js.map → chunk-E3LWJUGF.js.map} +1 -1
  101. package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js → chunk-E3YQFSFE.js} +6 -10
  102. package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js.map → chunk-E3YQFSFE.js.map} +1 -1
  103. package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js → chunk-EDO7VXSO.js} +2 -2
  104. package/dist/cli-bundle/chunks/{chunk-FDBARR33.js → chunk-EIUBK2LT.js} +12 -18
  105. package/dist/cli-bundle/chunks/{chunk-FDBARR33.js.map → chunk-EIUBK2LT.js.map} +1 -1
  106. package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js → chunk-EMXPI36L.js} +14 -20
  107. package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js.map → chunk-EMXPI36L.js.map} +1 -1
  108. package/dist/cli-bundle/chunks/{chunk-4OFLJHX6.js → chunk-EOUVR7JN.js} +13 -8
  109. package/dist/cli-bundle/chunks/chunk-EOUVR7JN.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js → chunk-EVEPHNXJ.js} +4 -4
  111. package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js → chunk-F6MT7KKE.js} +6 -10
  112. package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js.map → chunk-F6MT7KKE.js.map} +1 -1
  113. package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js → chunk-F6YC2A6X.js} +7 -11
  114. package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js.map → chunk-F6YC2A6X.js.map} +1 -1
  115. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js +5514 -0
  116. package/dist/cli-bundle/chunks/chunk-FILL6BB2.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js → chunk-FN6SB4HU.js} +2 -2
  118. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js +5359 -0
  119. package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js.map +1 -0
  120. package/dist/cli-bundle/chunks/{chunk-JLA7EVYV.js → chunk-GLS6VMWI.js} +37 -16
  121. package/dist/cli-bundle/chunks/chunk-GLS6VMWI.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js → chunk-GPIDUMMN.js} +10 -17
  123. package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js.map → chunk-GPIDUMMN.js.map} +1 -1
  124. package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js → chunk-GTM5HQL4.js} +15 -21
  125. package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js.map → chunk-GTM5HQL4.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js → chunk-H2SMKL2N.js} +8 -8
  127. package/dist/cli-bundle/chunks/{chunk-S4APD35C.js → chunk-HHEWQXPD.js} +6 -6
  128. package/dist/cli-bundle/chunks/chunk-HHEWQXPD.js.map +7 -0
  129. package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js → chunk-HX6QXV5P.js} +2 -2
  130. package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js → chunk-I74FMIWA.js} +11 -17
  131. package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js.map → chunk-I74FMIWA.js.map} +1 -1
  132. package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js +804 -0
  133. package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js.map +7 -0
  134. package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js → chunk-II7R6KD4.js} +9 -13
  135. package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js.map → chunk-II7R6KD4.js.map} +1 -1
  136. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js +10320 -0
  137. package/dist/cli-bundle/chunks/chunk-J2VGADNG.js.map +1 -0
  138. package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js → chunk-J7BOLHAV.js} +5 -7
  139. package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js.map → chunk-J7BOLHAV.js.map} +1 -1
  140. package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js → chunk-KTGJ2CBU.js} +4 -6
  141. package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js.map → chunk-KTGJ2CBU.js.map} +1 -1
  142. package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js → chunk-LCFJ7XAM.js} +32 -2
  143. package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js.map → chunk-LCFJ7XAM.js.map} +3 -3
  144. package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js → chunk-LZQU6XJG.js} +28 -34
  145. package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js.map → chunk-LZQU6XJG.js.map} +1 -1
  146. package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js → chunk-M62RO3XK.js} +10 -14
  147. package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js.map → chunk-M62RO3XK.js.map} +1 -1
  148. package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js → chunk-MCEUKJKW.js} +9 -11
  149. package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js.map → chunk-MCEUKJKW.js.map} +1 -1
  150. package/dist/cli-bundle/chunks/{chunk-T5Y3QSNF.js → chunk-MHNMCDWR.js} +1447 -86
  151. package/dist/cli-bundle/chunks/chunk-MHNMCDWR.js.map +1 -0
  152. package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js → chunk-MRFWUSVA.js} +4 -6
  153. package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js.map → chunk-MRFWUSVA.js.map} +1 -1
  154. package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js → chunk-N6ZHDLUY.js} +6 -8
  155. package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js.map → chunk-N6ZHDLUY.js.map} +1 -1
  156. package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js → chunk-NWWL22C7.js} +8 -12
  157. package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js.map → chunk-NWWL22C7.js.map} +1 -1
  158. package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js → chunk-P3MJJW7P.js} +2 -2
  159. package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js → chunk-PDXJXEZJ.js} +2 -2
  160. package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js → chunk-Q64AYQYW.js} +9 -13
  161. package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js.map → chunk-Q64AYQYW.js.map} +1 -1
  162. package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js → chunk-QDABF2RB.js} +26 -47
  163. package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js.map → chunk-QDABF2RB.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{chunk-NBFCNJ7Q.js → chunk-QFBSP3NI.js} +529 -46
  165. package/dist/cli-bundle/chunks/chunk-QFBSP3NI.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js → chunk-RB3KLPAH.js} +11 -16
  167. package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js.map → chunk-RB3KLPAH.js.map} +1 -1
  168. package/dist/cli-bundle/chunks/{chunk-YSAH5FY5.js → chunk-RY7PTTUB.js} +94 -53
  169. package/dist/cli-bundle/chunks/chunk-RY7PTTUB.js.map +1 -0
  170. package/dist/cli-bundle/chunks/{chunk-WVSGSZ6J.js → chunk-S547WBYG.js} +1477 -86
  171. package/dist/cli-bundle/chunks/chunk-S547WBYG.js.map +7 -0
  172. package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js → chunk-S5BNGFN5.js} +24 -45
  173. package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js.map → chunk-S5BNGFN5.js.map} +1 -1
  174. package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js → chunk-S6VC2A2K.js} +9 -14
  175. package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js.map → chunk-S6VC2A2K.js.map} +1 -1
  176. package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js → chunk-SIM5JDON.js} +7 -14
  177. package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js.map → chunk-SIM5JDON.js.map} +1 -1
  178. package/dist/cli-bundle/chunks/{chunk-ZD34OFFQ.js → chunk-SY75LYXR.js} +12 -7
  179. package/dist/cli-bundle/chunks/chunk-SY75LYXR.js.map +7 -0
  180. package/dist/cli-bundle/chunks/{chunk-TT42JUMF.js → chunk-TEISGNSH.js} +7 -7
  181. package/dist/cli-bundle/chunks/chunk-TEISGNSH.js.map +1 -0
  182. package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js → chunk-TEKZOS7M.js} +2 -2
  183. package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js → chunk-TGUK6XN6.js} +14 -18
  184. package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js.map → chunk-TGUK6XN6.js.map} +1 -1
  185. package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js → chunk-TNC6MZUD.js} +10 -21
  186. package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js.map → chunk-TNC6MZUD.js.map} +1 -1
  187. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js +10498 -0
  188. package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js.map +7 -0
  189. package/dist/cli-bundle/chunks/{chunk-YD5FML7K.js → chunk-UO7XAZK6.js} +27 -4
  190. package/dist/cli-bundle/chunks/chunk-UO7XAZK6.js.map +1 -0
  191. package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js → chunk-V5ZWKJNY.js} +5 -14
  192. package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js.map → chunk-V5ZWKJNY.js.map} +1 -1
  193. package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js → chunk-VGO73OCK.js} +7 -14
  194. package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js.map → chunk-VGO73OCK.js.map} +1 -1
  195. package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js → chunk-VLEA2UTQ.js} +2 -2
  196. package/dist/cli-bundle/chunks/{files-6P57MRKL.js → chunk-W5HXHC7C.js} +8 -15
  197. package/dist/cli-bundle/chunks/{files-6P57MRKL.js.map → chunk-W5HXHC7C.js.map} +1 -1
  198. package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js → chunk-WCWVEXGA.js} +2 -2
  199. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js +6690 -0
  200. package/dist/cli-bundle/chunks/chunk-X47MKQXU.js.map +7 -0
  201. package/dist/cli-bundle/chunks/{delete-62JQTYT4.js → chunk-XBX5CBRQ.js} +6 -10
  202. package/dist/cli-bundle/chunks/{delete-62JQTYT4.js.map → chunk-XBX5CBRQ.js.map} +1 -1
  203. package/dist/cli-bundle/chunks/{chunk-MTTXDAK4.js → chunk-XC3X7BQR.js} +541 -44
  204. package/dist/cli-bundle/chunks/chunk-XC3X7BQR.js.map +7 -0
  205. package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js → chunk-XHCVAZGM.js} +17 -23
  206. package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js.map → chunk-XHCVAZGM.js.map} +1 -1
  207. package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js → chunk-XPMXPR7K.js} +7 -9
  208. package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js.map → chunk-XPMXPR7K.js.map} +1 -1
  209. package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js → chunk-XS2TMNXR.js} +8 -12
  210. package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js.map → chunk-XS2TMNXR.js.map} +1 -1
  211. package/dist/cli-bundle/chunks/{plan-XWY5T67S.js → chunk-XXIYUTLK.js} +12 -23
  212. package/dist/cli-bundle/chunks/{plan-XWY5T67S.js.map → chunk-XXIYUTLK.js.map} +1 -1
  213. package/dist/cli-bundle/chunks/{chunk-7QH7DHUB.js → chunk-XZWL7VNE.js} +1220 -398
  214. package/dist/cli-bundle/chunks/chunk-XZWL7VNE.js.map +1 -0
  215. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js +6624 -0
  216. package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js → chunk-Y7KYVCZM.js} +12 -18
  218. package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js.map → chunk-Y7KYVCZM.js.map} +1 -1
  219. package/dist/cli-bundle/chunks/{chunk-UI5BJ6DO.js → chunk-YCVWWIKY.js} +17 -28
  220. package/dist/cli-bundle/chunks/chunk-YCVWWIKY.js.map +7 -0
  221. package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js +780 -0
  222. package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js.map +1 -0
  223. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js +5509 -0
  224. package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js.map +7 -0
  225. package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js → chunk-YPD7SQ5P.js} +8 -12
  226. package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js.map → chunk-YPD7SQ5P.js.map} +2 -2
  227. package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js → chunk-YPMZMKN7.js} +2 -2
  228. package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js → chunk-YTD5GICJ.js} +4 -4
  229. package/dist/cli-bundle/chunks/{config-DJJKZB5R.js → chunk-ZNEG2UDO.js} +264 -39
  230. package/dist/cli-bundle/chunks/{config-DJJKZB5R.js.map → chunk-ZNEG2UDO.js.map} +4 -4
  231. package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js → chunk-ZO7CLOY2.js} +3 -3
  232. package/dist/cli-bundle/chunks/{close-3YRR3XY6.js → close-3YYQ5OG2.js} +5 -9
  233. package/dist/cli-bundle/chunks/close-Z3Q4U7TS.js +12 -0
  234. package/dist/cli-bundle/chunks/close-many-3L2RXH3M.js +22 -0
  235. package/dist/cli-bundle/chunks/close-many-D366FTIG.js +26 -0
  236. package/dist/cli-bundle/chunks/comments-54XDJNFE.js +17 -0
  237. package/dist/cli-bundle/chunks/comments-HGHC2PN6.js +13 -0
  238. package/dist/cli-bundle/chunks/copy-44RT5GDW.js +13 -0
  239. package/dist/cli-bundle/chunks/copy-UGMUGHZA.js +9 -0
  240. package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js → create-4GWJWPXG.js} +9 -14
  241. package/dist/cli-bundle/chunks/create-AZXCUYKP.js +25 -0
  242. package/dist/cli-bundle/chunks/delete-Y6SXIQ4X.js +10 -0
  243. package/dist/cli-bundle/chunks/delete-YQ2VPXNF.js +14 -0
  244. package/dist/cli-bundle/chunks/deps-BU5EBJDU.js +17 -0
  245. package/dist/cli-bundle/chunks/deps-FMANWFRP.js +13 -0
  246. package/dist/cli-bundle/chunks/docs-OQBSJNIA.js +18 -0
  247. package/dist/cli-bundle/chunks/docs-VNPBZXEL.js +14 -0
  248. package/dist/cli-bundle/chunks/files-72HZEBOE.js +18 -0
  249. package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js → files-HTSB2KJG.js} +13 -13
  250. package/dist/cli-bundle/chunks/focus-FOG4ALC2.js +14 -0
  251. package/dist/cli-bundle/chunks/focus-SUTMKXGX.js +10 -0
  252. package/dist/cli-bundle/chunks/history-compact-M6IFAMBP.js +25 -0
  253. package/dist/cli-bundle/chunks/history-compact-NEXRPP2O.js +21 -0
  254. package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js → history-redact-NQX3OGZP.js} +7 -11
  255. package/dist/cli-bundle/chunks/history-redact-WQJBZ3PX.js +17 -0
  256. package/dist/cli-bundle/chunks/history-repair-CBHMHAJO.js +19 -0
  257. package/dist/cli-bundle/chunks/history-repair-NHOJG7WO.js +23 -0
  258. package/dist/cli-bundle/chunks/learnings-M64NTSOR.js +13 -0
  259. package/dist/cli-bundle/chunks/learnings-T63JGKKN.js +17 -0
  260. package/dist/cli-bundle/chunks/notes-73WE2UV2.js +13 -0
  261. package/dist/cli-bundle/chunks/notes-U7L6HQQ2.js +17 -0
  262. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js +24 -0
  263. package/dist/cli-bundle/chunks/plan-OSCNYFGC.js.map +7 -0
  264. package/dist/cli-bundle/chunks/plan-TN537L24.js +28 -0
  265. package/dist/cli-bundle/chunks/plan-TN537L24.js.map +1 -0
  266. package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js +37 -0
  267. package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js.map +1 -0
  268. package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js +33 -0
  269. package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js.map +7 -0
  270. package/dist/cli-bundle/chunks/{register-list-query-5H66WFYF.js → register-list-query-OHXD7G5N.js} +41 -33
  271. package/dist/cli-bundle/chunks/register-list-query-OHXD7G5N.js.map +7 -0
  272. package/dist/cli-bundle/chunks/{register-list-query-FB3FNDLZ.js → register-list-query-ZCRABAPN.js} +42 -34
  273. package/dist/cli-bundle/chunks/register-list-query-ZCRABAPN.js.map +1 -0
  274. package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js → register-mutation-P3G4XP6Q.js} +36 -41
  275. package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js.map → register-mutation-P3G4XP6Q.js.map} +1 -1
  276. package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js → register-mutation-XX4H56PE.js} +34 -39
  277. package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js.map → register-mutation-XX4H56PE.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{register-operations-A3XAM5J7.js → register-operations-V6PIYEDU.js} +80 -52
  279. package/dist/cli-bundle/chunks/register-operations-V6PIYEDU.js.map +1 -0
  280. package/dist/cli-bundle/chunks/{register-operations-SG7HBSUP.js → register-operations-V6VKTG54.js} +79 -51
  281. package/dist/cli-bundle/chunks/register-operations-V6VKTG54.js.map +7 -0
  282. package/dist/cli-bundle/chunks/{register-setup-K6U3NVY5.js → register-setup-6RVAWT6W.js} +129 -31
  283. package/dist/cli-bundle/chunks/register-setup-6RVAWT6W.js.map +7 -0
  284. package/dist/cli-bundle/chunks/{register-setup-I45OGJUV.js → register-setup-6YVUSQYD.js} +130 -32
  285. package/dist/cli-bundle/chunks/register-setup-6YVUSQYD.js.map +1 -0
  286. package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js → restore-HC3YSWF7.js} +7 -11
  287. package/dist/cli-bundle/chunks/restore-HC3YSWF7.js.map +1 -0
  288. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js +15 -0
  289. package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js.map +7 -0
  290. package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js → schema-DAGSYO6E.js} +6 -10
  291. package/dist/cli-bundle/chunks/schema-DAGSYO6E.js.map +7 -0
  292. package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js → schema-UBXJCQAC.js} +6 -10
  293. package/dist/cli-bundle/chunks/schema-UBXJCQAC.js.map +1 -0
  294. package/dist/cli-bundle/chunks/update-CJGG5WMV.js +21 -0
  295. package/dist/cli-bundle/chunks/update-CJGG5WMV.js.map +7 -0
  296. package/dist/cli-bundle/chunks/update-LKD64AFP.js +25 -0
  297. package/dist/cli-bundle/chunks/update-LKD64AFP.js.map +1 -0
  298. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js +31 -0
  299. package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js.map +7 -0
  300. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js +35 -0
  301. package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js.map +1 -0
  302. package/dist/cli-bundle/main.js +29 -31
  303. package/dist/cli-bundle/main.js.map +2 -2
  304. package/dist/cli-bundle/sdk-runtime.js +136 -54
  305. package/dist/cli-bundle/sdk-testing.js +7 -8
  306. package/dist/cli-bundle/sdk.js +132 -84
  307. package/dist/cli-bundle/sdk.js.map +2 -2
  308. package/dist/core/history/drift-scan.js +3 -8
  309. package/dist/core/history/drift-scan.js.map +1 -1
  310. package/dist/core/output/mutation-projection.js +11 -5
  311. package/dist/core/output/mutation-projection.js.map +1 -1
  312. package/dist/core/search/cache.js +3 -3
  313. package/dist/core/search/cache.js.map +1 -1
  314. package/dist/core/search/semantic-defaults.d.ts +2 -0
  315. package/dist/core/search/semantic-defaults.js +11 -4
  316. package/dist/core/search/semantic-defaults.js.map +1 -1
  317. package/dist/core/search/vector-stores.d.ts +1 -1
  318. package/dist/core/search/vector-stores.js +33 -7
  319. package/dist/core/search/vector-stores.js.map +1 -1
  320. package/dist/mcp/server.d.ts +22 -50
  321. package/dist/mcp/server.js +62 -916
  322. package/dist/mcp/server.js.map +1 -1
  323. package/dist/sdk/cli-contracts/flag-contracts.js +7 -7
  324. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  325. package/dist/sdk/cli-contracts/tool-schema.js +9 -7
  326. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  327. package/dist/sdk/index.d.ts +4 -2
  328. package/dist/sdk/index.js +4 -4
  329. package/dist/sdk/index.js.map +1 -1
  330. package/dist/sdk/runtime.d.ts +312 -5
  331. package/dist/sdk/runtime.js +1391 -26
  332. package/dist/sdk/runtime.js.map +1 -1
  333. package/dist/sdk/start-task-status.d.ts +13 -0
  334. package/dist/sdk/start-task-status.js +19 -0
  335. package/dist/sdk/start-task-status.js.map +1 -0
  336. package/dist/sdk/workspace-contracts-cache.d.ts +17 -0
  337. package/dist/sdk/workspace-contracts-cache.js +36 -0
  338. package/dist/sdk/workspace-contracts-cache.js.map +1 -0
  339. package/docs/COMMANDS.md +10 -1
  340. package/docs/RELEASING.md +3 -1
  341. package/docs/SDK.md +81 -0
  342. package/docs/TESTING.md +3 -0
  343. package/docs/examples/sdk-app-embedding/run-embedded-pm.mjs +16 -2
  344. package/docs/examples/sdk-contract-consumer/inspect-contracts.mjs +16 -1
  345. package/package.json +1 -1
  346. package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +0 -18
  347. package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js +0 -375
  348. package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js.map +0 -7
  349. package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js +0 -372
  350. package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js.map +0 -1
  351. package/dist/cli-bundle/chunks/chunk-37E72CNS.js +0 -217
  352. package/dist/cli-bundle/chunks/chunk-37E72CNS.js.map +0 -1
  353. package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js +0 -1961
  354. package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js.map +0 -1
  355. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js +0 -1749
  356. package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +0 -7
  357. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js +0 -87
  358. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js.map +0 -7
  359. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js +0 -822
  360. package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js.map +0 -7
  361. package/dist/cli-bundle/chunks/chunk-4OFLJHX6.js.map +0 -1
  362. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js +0 -2181
  363. package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +0 -1
  364. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js +0 -1704
  365. package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +0 -1
  366. package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js +0 -2330
  367. package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js.map +0 -7
  368. package/dist/cli-bundle/chunks/chunk-5J2XPTAD.js.map +0 -7
  369. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js +0 -995
  370. package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js.map +0 -1
  371. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js +0 -819
  372. package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js.map +0 -1
  373. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +0 -23
  374. package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +0 -7
  375. package/dist/cli-bundle/chunks/chunk-7EQNAZX2.js.map +0 -7
  376. package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +0 -1
  377. package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js +0 -530
  378. package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js.map +0 -7
  379. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +0 -275
  380. package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +0 -7
  381. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js +0 -231
  382. package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +0 -7
  383. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js +0 -2184
  384. package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js.map +0 -7
  385. package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js +0 -1615
  386. package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js.map +0 -7
  387. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js +0 -228
  388. package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +0 -1
  389. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js +0 -3237
  390. package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +0 -7
  391. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js +0 -1570
  392. package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +0 -1
  393. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js +0 -3206
  394. package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +0 -1
  395. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js +0 -371
  396. package/dist/cli-bundle/chunks/chunk-JINYH2DB.js.map +0 -7
  397. package/dist/cli-bundle/chunks/chunk-JLA7EVYV.js.map +0 -1
  398. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +0 -76
  399. package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +0 -1
  400. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +0 -79
  401. package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +0 -7
  402. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +0 -915
  403. package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +0 -1
  404. package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js +0 -218
  405. package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js.map +0 -7
  406. package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +0 -7
  407. package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js +0 -1858
  408. package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js.map +0 -1
  409. package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +0 -7
  410. package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js +0 -520
  411. package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js.map +0 -1
  412. package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js +0 -1041
  413. package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js.map +0 -7
  414. package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +0 -1
  415. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +0 -20
  416. package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +0 -1
  417. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +0 -918
  418. package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +0 -7
  419. package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js +0 -1985
  420. package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js.map +0 -7
  421. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +0 -238
  422. package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +0 -1
  423. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +0 -1977
  424. package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +0 -7
  425. package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js +0 -1031
  426. package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js.map +0 -1
  427. package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +0 -1
  428. package/dist/cli-bundle/chunks/chunk-QZ342C63.js +0 -220
  429. package/dist/cli-bundle/chunks/chunk-QZ342C63.js.map +0 -7
  430. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js +0 -368
  431. package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js.map +0 -1
  432. package/dist/cli-bundle/chunks/chunk-S4APD35C.js.map +0 -7
  433. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js +0 -1149
  434. package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +0 -1
  435. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +0 -272
  436. package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +0 -1
  437. package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +0 -1
  438. package/dist/cli-bundle/chunks/chunk-TT42JUMF.js.map +0 -1
  439. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +0 -165
  440. package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +0 -1
  441. package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +0 -7
  442. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +0 -1932
  443. package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +0 -1
  444. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +0 -175
  445. package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +0 -7
  446. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js +0 -84
  447. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js.map +0 -1
  448. package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js +0 -1868
  449. package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js.map +0 -7
  450. package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +0 -7
  451. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js +0 -1152
  452. package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +0 -7
  453. package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +0 -1
  454. package/dist/cli-bundle/chunks/chunk-YSAH5FY5.js.map +0 -1
  455. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js +0 -1005
  456. package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js.map +0 -7
  457. package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js +0 -215
  458. package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js.map +0 -1
  459. package/dist/cli-bundle/chunks/chunk-ZD34OFFQ.js.map +0 -7
  460. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js +0 -2306
  461. package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +0 -1
  462. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +0 -241
  463. package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +0 -7
  464. package/dist/cli-bundle/chunks/claim-4DROPSIS.js +0 -144
  465. package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +0 -1
  466. package/dist/cli-bundle/chunks/claim-VX54TV5U.js +0 -147
  467. package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +0 -7
  468. package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +0 -16
  469. package/dist/cli-bundle/chunks/config-V57QD47V.js.map +0 -1
  470. package/dist/cli-bundle/chunks/context-4OQGIPSO.js +0 -45
  471. package/dist/cli-bundle/chunks/context-WLA6IAWE.js +0 -49
  472. package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +0 -12
  473. package/dist/cli-bundle/chunks/create-WKOZKPQR.js +0 -30
  474. package/dist/cli-bundle/chunks/eval-N6UHFWVO.js +0 -288
  475. package/dist/cli-bundle/chunks/eval-N6UHFWVO.js.map +0 -7
  476. package/dist/cli-bundle/chunks/eval-PHOTWYHI.js +0 -278
  477. package/dist/cli-bundle/chunks/eval-PHOTWYHI.js.map +0 -1
  478. package/dist/cli-bundle/chunks/extension-NBAH62ML.js +0 -40
  479. package/dist/cli-bundle/chunks/extension-ZF6ZZPOU.js +0 -44
  480. package/dist/cli-bundle/chunks/gc-AETFKZ44.js +0 -398
  481. package/dist/cli-bundle/chunks/gc-AETFKZ44.js.map +0 -7
  482. package/dist/cli-bundle/chunks/gc-RLBP4QVN.js +0 -388
  483. package/dist/cli-bundle/chunks/gc-RLBP4QVN.js.map +0 -1
  484. package/dist/cli-bundle/chunks/get-NH2MPBCI.js +0 -283
  485. package/dist/cli-bundle/chunks/get-NH2MPBCI.js.map +0 -1
  486. package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js +0 -286
  487. package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js.map +0 -7
  488. package/dist/cli-bundle/chunks/health-3GVPMQBL.js +0 -1612
  489. package/dist/cli-bundle/chunks/health-3GVPMQBL.js.map +0 -1
  490. package/dist/cli-bundle/chunks/health-DNTM72GJ.js +0 -1615
  491. package/dist/cli-bundle/chunks/health-DNTM72GJ.js.map +0 -7
  492. package/dist/cli-bundle/chunks/history-RYKLC72X.js +0 -20
  493. package/dist/cli-bundle/chunks/history-SGPYRAFT.js +0 -24
  494. package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +0 -21
  495. package/dist/cli-bundle/chunks/init-RPIPQUNV.js +0 -32
  496. package/dist/cli-bundle/chunks/init-SKQAESQS.js +0 -28
  497. package/dist/cli-bundle/chunks/list-64LHZ3HM.js +0 -32
  498. package/dist/cli-bundle/chunks/list-7LXBTEKI.js +0 -36
  499. package/dist/cli-bundle/chunks/next-7ODPAQ4U.js +0 -306
  500. package/dist/cli-bundle/chunks/next-7ODPAQ4U.js.map +0 -7
  501. package/dist/cli-bundle/chunks/next-ODJUM4ZM.js +0 -303
  502. package/dist/cli-bundle/chunks/next-ODJUM4ZM.js.map +0 -1
  503. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +0 -397
  504. package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +0 -1
  505. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +0 -400
  506. package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +0 -7
  507. package/dist/cli-bundle/chunks/register-list-query-5H66WFYF.js.map +0 -7
  508. package/dist/cli-bundle/chunks/register-list-query-FB3FNDLZ.js.map +0 -1
  509. package/dist/cli-bundle/chunks/register-operations-A3XAM5J7.js.map +0 -1
  510. package/dist/cli-bundle/chunks/register-operations-SG7HBSUP.js.map +0 -7
  511. package/dist/cli-bundle/chunks/register-setup-I45OGJUV.js.map +0 -1
  512. package/dist/cli-bundle/chunks/register-setup-K6U3NVY5.js.map +0 -7
  513. package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +0 -19
  514. package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js +0 -91
  515. package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js.map +0 -7
  516. package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js +0 -88
  517. package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js.map +0 -1
  518. package/dist/cli-bundle/chunks/search-3S72CTD6.js +0 -38
  519. package/dist/cli-bundle/chunks/search-WNUNBQXO.js +0 -34
  520. package/dist/cli-bundle/chunks/stats-IJYTRQGV.js +0 -250
  521. package/dist/cli-bundle/chunks/stats-IJYTRQGV.js.map +0 -7
  522. package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js +0 -240
  523. package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js.map +0 -1
  524. package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js +0 -309
  525. package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js.map +0 -7
  526. package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js +0 -306
  527. package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js.map +0 -1
  528. package/dist/cli-bundle/chunks/test-DQ2QFJ7W.js +0 -45
  529. package/dist/cli-bundle/chunks/test-W7QBLVJS.js +0 -41
  530. package/dist/cli-bundle/chunks/test-all-636NTRTT.js +0 -434
  531. package/dist/cli-bundle/chunks/test-all-636NTRTT.js.map +0 -1
  532. package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js +0 -437
  533. package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js.map +0 -7
  534. package/dist/cli-bundle/chunks/test-runs-245OINZR.js +0 -28
  535. package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +0 -24
  536. package/dist/cli-bundle/chunks/update-SFLZPJXX.js +0 -30
  537. package/dist/cli-bundle/chunks/update-SJZ6S77U.js +0 -26
  538. package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js +0 -290
  539. package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js.map +0 -7
  540. package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js +0 -287
  541. package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js.map +0 -1
  542. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js +0 -2143
  543. package/dist/cli-bundle/chunks/validate-PA4FDTOV.js.map +0 -7
  544. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js +0 -2105
  545. package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js.map +0 -1
  546. /package/dist/cli-bundle/chunks/{activity-4XQIDNM5.js.map → append-F7WPGIQL.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js.map → append-PVCTBVJG.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js.map → chunk-2TILG6F2.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js.map → chunk-3TYOW6RR.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js.map → chunk-3X542TEY.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js.map → chunk-7VQ3JJN5.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js.map → chunk-AGAVEDIE.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js.map → chunk-AJUON7E6.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js.map → chunk-DR2V5OIV.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js.map → chunk-EDO7VXSO.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js.map → chunk-EVEPHNXJ.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js.map → chunk-FN6SB4HU.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js.map → chunk-H2SMKL2N.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js.map → chunk-HX6QXV5P.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js.map → chunk-P3MJJW7P.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js.map → chunk-PDXJXEZJ.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js.map → chunk-TEKZOS7M.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js.map → chunk-VLEA2UTQ.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js.map → chunk-WCWVEXGA.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js.map → chunk-YPMZMKN7.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js.map → chunk-YTD5GICJ.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js.map → chunk-ZO7CLOY2.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{close-3YRR3XY6.js.map → close-3YYQ5OG2.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{close-OB2Y4QP5.js.map → close-Z3Q4U7TS.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{context-4OQGIPSO.js.map → close-many-3L2RXH3M.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{context-WLA6IAWE.js.map → close-many-D366FTIG.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js.map → comments-54XDJNFE.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{contracts-HXJLKCRI.js.map → comments-HGHC2PN6.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js.map → copy-44RT5GDW.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{create-WKOZKPQR.js.map → copy-UGMUGHZA.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{extension-ZF6ZZPOU.js.map → create-4GWJWPXG.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{extension-NBAH62ML.js.map → create-AZXCUYKP.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{history-RYKLC72X.js.map → delete-Y6SXIQ4X.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{history-SGPYRAFT.js.map → delete-YQ2VPXNF.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js.map → deps-BU5EBJDU.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{history-redact-4H3FCKF3.js.map → deps-FMANWFRP.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{init-RPIPQUNV.js.map → docs-OQBSJNIA.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{init-SKQAESQS.js.map → docs-VNPBZXEL.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{list-64LHZ3HM.js.map → files-72HZEBOE.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{list-7LXBTEKI.js.map → files-HTSB2KJG.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js.map → focus-FOG4ALC2.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{restore-PXOFL6AM.js.map → focus-SUTMKXGX.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js.map → history-compact-M6IFAMBP.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js.map → history-compact-NEXRPP2O.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{search-3S72CTD6.js.map → history-redact-NQX3OGZP.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{search-WNUNBQXO.js.map → history-redact-WQJBZ3PX.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{test-W7QBLVJS.js.map → history-repair-CBHMHAJO.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{test-DQ2QFJ7W.js.map → history-repair-NHOJG7WO.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{test-runs-ZRD4GCTT.js.map → learnings-M64NTSOR.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{test-runs-245OINZR.js.map → learnings-T63JGKKN.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{update-SJZ6S77U.js.map → notes-73WE2UV2.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{update-SFLZPJXX.js.map → notes-U7L6HQQ2.js.map} +0 -0
@@ -1,1749 +0,0 @@
1
- import {
2
- canonicalDocument,
3
- normalizeItemId,
4
- normalizeRawItemId,
5
- parseItemDocument,
6
- serializeItemDocument
7
- } from "./chunk-EZFKWSC7.js";
8
- import {
9
- nowIso
10
- } from "./chunk-DRBV5UC2.js";
11
- import {
12
- PmCliError,
13
- getActiveExtensionRegistrations,
14
- hasActiveOnReadHooks,
15
- orderObject,
16
- projectAfterCommandItemSnapshot,
17
- recordAfterCommandAffectedItem,
18
- resolveGovernanceKnobs,
19
- runActiveOnReadHooks,
20
- runActiveOnWriteHooks,
21
- runActiveServiceOverride,
22
- sha256Hex,
23
- stableStringify
24
- } from "./chunk-P5YORJRH.js";
25
- import {
26
- evictOldestMemoEntries
27
- } from "./chunk-7C2O74AE.js";
28
- import {
29
- EMPTY_CANONICAL_DOCUMENT,
30
- EXIT_CODE,
31
- FRONT_MATTER_KEY_ORDER,
32
- ITEM_FILE_EXTENSIONS,
33
- TYPE_TO_FOLDER,
34
- appendLineAtomic,
35
- ensureDir,
36
- getHistoryPath,
37
- getItemFormatFromPath,
38
- getItemPath,
39
- getLockPath,
40
- levenshteinDistanceWithinLimit,
41
- normalizeItemFieldType,
42
- pathExists,
43
- resolveItemTypeRegistry,
44
- toErrorMessage,
45
- writeFileAtomic
46
- } from "./chunk-5VVUKE3U.js";
47
-
48
- // dist/core/extensions/item-fields.js
49
- !(function() {
50
- try {
51
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
52
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "455e46e5-2843-5222-8d87-bc9d62238ff4");
53
- } catch (e2) {
54
- }
55
- })();
56
- var RESERVED_ITEM_FIELD_NAMES = new Set(FRONT_MATTER_KEY_ORDER);
57
- function normalizeFieldName(value) {
58
- if (typeof value !== "string") {
59
- return null;
60
- }
61
- const normalized = value.trim();
62
- return normalized.length > 0 ? normalized : null;
63
- }
64
- function normalizeFieldType(value) {
65
- if (typeof value !== "string") {
66
- return null;
67
- }
68
- return normalizeItemFieldType(value);
69
- }
70
- function cloneFieldValue(value) {
71
- try {
72
- return structuredClone(value);
73
- } catch {
74
- return value;
75
- }
76
- }
77
- function parseFieldAssignment(raw) {
78
- const trimmed = raw.trim();
79
- const separatorIndex = trimmed.indexOf("=");
80
- if (separatorIndex <= 0) {
81
- throw new PmCliError(`--field entries must use name=value syntax, received: ${raw}`, EXIT_CODE.USAGE);
82
- }
83
- const key = trimmed.slice(0, separatorIndex).trim();
84
- const value = trimmed.slice(separatorIndex + 1);
85
- return { key, value };
86
- }
87
- function parseJsonFieldValue(raw, fieldName, expectedType) {
88
- try {
89
- const parsed = JSON.parse(raw);
90
- if (expectedType === "array" && Array.isArray(parsed)) {
91
- return parsed;
92
- }
93
- if (expectedType === "object" && typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
94
- return parsed;
95
- }
96
- } catch {
97
- }
98
- throw new PmCliError(`--field ${fieldName}=... must be valid JSON ${expectedType}`, EXIT_CODE.USAGE);
99
- }
100
- function coerceRegisteredFieldValue(fieldName, fieldType, raw) {
101
- if (fieldType === "string") {
102
- return raw;
103
- }
104
- if (fieldType === "number") {
105
- const trimmed = raw.trim();
106
- if (trimmed.length === 0) {
107
- throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);
108
- }
109
- const parsed = Number(trimmed);
110
- if (!Number.isFinite(parsed)) {
111
- throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);
112
- }
113
- return parsed;
114
- }
115
- if (fieldType === "boolean") {
116
- const normalized = raw.trim().toLowerCase();
117
- if (normalized === "true" || normalized === "1" || normalized === "yes") {
118
- return true;
119
- }
120
- if (normalized === "false" || normalized === "0" || normalized === "no") {
121
- return false;
122
- }
123
- throw new PmCliError(`--field ${fieldName}=... must be one of true|false|1|0|yes|no`, EXIT_CODE.USAGE);
124
- }
125
- return parseJsonFieldValue(raw, fieldName, fieldType);
126
- }
127
- function collectRegisteredFieldDefinitions(registrations) {
128
- const definitions = /* @__PURE__ */ new Map();
129
- if (!registrations) {
130
- return definitions;
131
- }
132
- for (const registration of registrations.item_fields) {
133
- for (const definition of registration.fields) {
134
- const fieldName = normalizeFieldName(definition.name);
135
- const fieldType = normalizeFieldType(definition.type);
136
- if (!fieldName || !fieldType) {
137
- continue;
138
- }
139
- const existing = definitions.get(fieldName);
140
- if (existing && existing.type !== fieldType) {
141
- throw new PmCliError(`Extension item field "${fieldName}" is declared with conflicting types: ${existing.type}, ${fieldType}`, EXIT_CODE.USAGE, {
142
- code: "extension_item_field_type_conflict",
143
- nextSteps: ["Make every active extension declaration for this field use the same type."]
144
- });
145
- }
146
- definitions.set(fieldName, { name: fieldName, type: fieldType });
147
- }
148
- }
149
- return definitions;
150
- }
151
- function assertNotReservedItemFieldName(fieldName) {
152
- if (!RESERVED_ITEM_FIELD_NAMES.has(fieldName)) {
153
- return;
154
- }
155
- throw new PmCliError(`Extension item field "${fieldName}" collides with reserved item metadata`, EXIT_CODE.USAGE, {
156
- code: "extension_item_field_reserved",
157
- nextSteps: ["Rename the extension item field, preferably with an extension-specific prefix."]
158
- });
159
- }
160
- function collectRegisteredItemFieldNames(registrations) {
161
- return [...collectRegisteredFieldDefinitions(registrations).keys()].sort((left, right) => left.localeCompare(right));
162
- }
163
- function parseRegisteredItemFieldAssignments(rawFields, registrations) {
164
- if (!rawFields || rawFields.length === 0) {
165
- return {};
166
- }
167
- const definitions = collectRegisteredFieldDefinitions(registrations);
168
- const values = {};
169
- for (const raw of rawFields) {
170
- const { key, value } = parseFieldAssignment(raw);
171
- const definition = definitions.get(key);
172
- if (!definition) {
173
- const known = [...definitions.keys()].sort((left, right) => left.localeCompare(right));
174
- throw new PmCliError(`--field ${key} is not declared by an active extension item-field registration`, EXIT_CODE.USAGE, {
175
- code: "extension_item_field_unknown",
176
- recovery: { provided_fields: known },
177
- nextSteps: known.length > 0 ? [`Use one of the declared fields: ${known.join(", ")}`] : ["Activate an extension that calls registerItemFields before setting extension fields."]
178
- });
179
- }
180
- assertNotReservedItemFieldName(definition.name);
181
- values[definition.name] = coerceRegisteredFieldValue(definition.name, definition.type, value);
182
- }
183
- return values;
184
- }
185
- function isValidFieldType(value, expectedType) {
186
- if (expectedType === "string") {
187
- return typeof value === "string";
188
- }
189
- if (expectedType === "number") {
190
- return typeof value === "number" && Number.isFinite(value);
191
- }
192
- if (expectedType === "boolean") {
193
- return typeof value === "boolean";
194
- }
195
- if (expectedType === "array") {
196
- return Array.isArray(value);
197
- }
198
- return typeof value === "object" && value !== null && !Array.isArray(value);
199
- }
200
- function isAllowedFieldValue(value, allowed) {
201
- if (!allowed || allowed.length === 0) {
202
- return true;
203
- }
204
- return allowed.some((candidate) => Object.is(candidate, value));
205
- }
206
- function applyRegisteredItemFieldDefaultsAndValidation(frontMatter, registrations, options = {}) {
207
- if (!registrations) {
208
- return;
209
- }
210
- collectRegisteredFieldDefinitions(registrations);
211
- for (const registration of registrations.item_fields) {
212
- for (const definition of registration.fields) {
213
- const fieldName = normalizeFieldName(definition.name);
214
- if (!fieldName) {
215
- continue;
216
- }
217
- assertNotReservedItemFieldName(fieldName);
218
- if (!(fieldName in frontMatter) && !options.skipDefaultFields?.has(fieldName) && Object.prototype.hasOwnProperty.call(definition, "default")) {
219
- frontMatter[fieldName] = cloneFieldValue(definition.default);
220
- }
221
- const currentValue = frontMatter[fieldName];
222
- if (currentValue === void 0) {
223
- continue;
224
- }
225
- const expectedType = normalizeFieldType(definition.type);
226
- if (expectedType && !isValidFieldType(currentValue, expectedType)) {
227
- throw new TypeError(`Item field "${fieldName}" must be of type ${expectedType}`);
228
- }
229
- const allowedValues = Array.isArray(definition.values) ? definition.values : void 0;
230
- if (!isAllowedFieldValue(currentValue, allowedValues)) {
231
- throw new TypeError(`Item field "${fieldName}" must match one of the configured allowed values`);
232
- }
233
- }
234
- }
235
- }
236
-
237
- // dist/core/item/item-record.js
238
- !(function() {
239
- try {
240
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
241
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "15ec7791-0156-5f73-84a4-0b0b80eaa2f3");
242
- } catch (e2) {
243
- }
244
- })();
245
- function toItemRecord(item) {
246
- return item;
247
- }
248
-
249
- // dist/core/history/history.js
250
- import jsonPatch from "fast-json-patch";
251
- !(function() {
252
- try {
253
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
254
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "f19df987-de61-5a9d-8d7e-93b7d5ca162c");
255
- } catch (e2) {
256
- }
257
- })();
258
- var EMPTY_LEGACY_HASH_DOCUMENT = {
259
- front_matter: {},
260
- body: ""
261
- };
262
- function decodeJsonPointer(path5) {
263
- if (!path5 || path5 === "/") {
264
- return [];
265
- }
266
- if (!path5.startsWith("/")) {
267
- return [];
268
- }
269
- return path5.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
270
- }
271
- function isDefinedPointerPath(document, path5) {
272
- const segments = decodeJsonPointer(path5);
273
- if (segments.length === 0) {
274
- return true;
275
- }
276
- let cursor = document;
277
- for (const segment of segments) {
278
- if (Array.isArray(cursor)) {
279
- if (segment === "-" || !/^(0|[1-9]\d*)$/.test(segment)) {
280
- return false;
281
- }
282
- const index = Number(segment);
283
- if (!Number.isInteger(index) || index < 0 || index >= cursor.length) {
284
- return false;
285
- }
286
- const next2 = cursor[index];
287
- if (next2 === void 0) {
288
- return false;
289
- }
290
- cursor = next2;
291
- continue;
292
- }
293
- if (typeof cursor !== "object" || cursor === null) {
294
- return false;
295
- }
296
- if (!Object.prototype.hasOwnProperty.call(cursor, segment)) {
297
- return false;
298
- }
299
- const next = cursor[segment];
300
- if (next === void 0) {
301
- return false;
302
- }
303
- cursor = next;
304
- }
305
- return true;
306
- }
307
- function normalizeHistoryPatchOps(beforeDocument, patch) {
308
- const normalized = [];
309
- let replayCursor = structuredClone(beforeDocument);
310
- for (const operation of patch) {
311
- const normalizedOperation = operation.op === "replace" && !isDefinedPointerPath(replayCursor, operation.path) ? { ...operation, op: "add" } : operation;
312
- normalized.push(normalizedOperation);
313
- replayCursor = jsonPatch.applyPatch(replayCursor, [normalizedOperation], true, true).newDocument;
314
- }
315
- return normalized;
316
- }
317
- function canonicalHashDocument(document) {
318
- const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;
319
- if (!hasMetadata) {
320
- return {
321
- front_matter: {},
322
- body: document.body ?? ""
323
- };
324
- }
325
- const canonical = canonicalDocument(document);
326
- const orderedFrontMatter = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);
327
- return {
328
- front_matter: orderedFrontMatter,
329
- body: canonical.body
330
- };
331
- }
332
- function canonicalPatchDocument(document) {
333
- const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;
334
- if (!hasMetadata) {
335
- return {
336
- metadata: {},
337
- body: document.body ?? ""
338
- };
339
- }
340
- const canonical = canonicalDocument(document);
341
- const orderedMetadata = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);
342
- return {
343
- metadata: orderedMetadata,
344
- body: canonical.body
345
- };
346
- }
347
- function hashDocument(document) {
348
- return sha256Hex(stableStringify(canonicalHashDocument(document)));
349
- }
350
- function hashEmptyDocument() {
351
- return sha256Hex(stableStringify(EMPTY_LEGACY_HASH_DOCUMENT));
352
- }
353
- function createHistoryEntry(params) {
354
- const beforeHashCanonical = canonicalHashDocument(params.before);
355
- const afterHashCanonical = canonicalHashDocument(params.after);
356
- const beforePatchCanonical = canonicalPatchDocument(params.before);
357
- const afterPatchCanonical = canonicalPatchDocument(params.after);
358
- const rawPatch = jsonPatch.compare(beforePatchCanonical, afterPatchCanonical);
359
- const patch = normalizeHistoryPatchOps(beforePatchCanonical, rawPatch);
360
- return {
361
- ts: params.nowIso,
362
- author: params.author,
363
- op: params.op,
364
- patch,
365
- before_hash: sha256Hex(stableStringify(beforeHashCanonical)),
366
- after_hash: sha256Hex(stableStringify(afterHashCanonical)),
367
- message: params.message === void 0 ? void 0 : params.message
368
- };
369
- }
370
- function isRecord(value) {
371
- return typeof value === "object" && value !== null && !Array.isArray(value);
372
- }
373
- function fallbackHistoryTimestamp(entry) {
374
- const ts = entry.ts.trim();
375
- return ts.length > 0 ? ts : nowIso();
376
- }
377
- function withHistoryTimestamp(value, fallbackTs) {
378
- const ts = value.ts;
379
- if (typeof ts === "string" && ts.trim().length > 0) {
380
- return value;
381
- }
382
- return { ...value, ts: fallbackTs };
383
- }
384
- function serializeHistoryLine(value, fallbackEntry) {
385
- const fallbackTs = fallbackHistoryTimestamp(fallbackEntry);
386
- if (typeof value === "string") {
387
- try {
388
- const parsed = JSON.parse(value);
389
- if (isRecord(parsed)) {
390
- return JSON.stringify(withHistoryTimestamp(parsed, fallbackTs));
391
- }
392
- } catch {
393
- }
394
- return value;
395
- }
396
- if (isRecord(value)) {
397
- return JSON.stringify(withHistoryTimestamp(value, fallbackTs));
398
- }
399
- return JSON.stringify(value);
400
- }
401
- async function appendHistoryEntry(historyPath, entry) {
402
- const override = await runActiveServiceOverride("history_append", {
403
- history_path: historyPath,
404
- entry
405
- });
406
- if (override.handled) {
407
- if (override.result === false) {
408
- return;
409
- }
410
- if (typeof override.result === "string") {
411
- await appendLineAtomic(historyPath, serializeHistoryLine(override.result, entry));
412
- return;
413
- }
414
- if (typeof override.result === "object" && override.result !== null) {
415
- const record = override.result;
416
- if (record.skip === true) {
417
- return;
418
- }
419
- const nextHistoryPath = typeof record.history_path === "string" ? record.history_path : historyPath;
420
- if (typeof record.line === "string") {
421
- await appendLineAtomic(nextHistoryPath, serializeHistoryLine(record.line, entry));
422
- return;
423
- }
424
- await appendLineAtomic(nextHistoryPath, serializeHistoryLine(record.entry ?? entry, entry));
425
- return;
426
- }
427
- }
428
- await appendLineAtomic(historyPath, serializeHistoryLine(entry, entry));
429
- }
430
-
431
- // dist/core/history/history-stream-policy.js
432
- import fs from "node:fs/promises";
433
- import path from "node:path";
434
- !(function() {
435
- try {
436
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
437
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "02991bdb-fced-50c6-bd43-2e3693f0f438");
438
- } catch (e2) {
439
- }
440
- })();
441
- function toSortedUniqueItemIds(itemIds) {
442
- return [...new Set(itemIds.filter((value) => value.trim().length > 0))].sort((left, right) => left.localeCompare(right));
443
- }
444
- function strictMissingStreamError(itemId, commandLabel) {
445
- return new PmCliError(`Missing history stream for ${itemId}. ${commandLabel} requires history streams when settings.history.missing_stream is strict_error.`, EXIT_CODE.NOT_FOUND);
446
- }
447
- async function createStream(historyPath, commandLabel) {
448
- await ensureDir(path.dirname(historyPath));
449
- const handle = await fs.open(historyPath, "a");
450
- await handle.close();
451
- return runActiveOnWriteHooks({
452
- path: historyPath,
453
- scope: "project",
454
- op: `${commandLabel}:history:auto_create`
455
- });
456
- }
457
- async function enforceHistoryStreamPolicyForItem(params) {
458
- return enforceHistoryStreamPolicyForItems({
459
- pmRoot: params.pmRoot,
460
- settings: params.settings,
461
- itemIds: [params.itemId],
462
- commandLabel: params.commandLabel
463
- });
464
- }
465
- async function enforceHistoryStreamPolicyForItems(params) {
466
- const ids = toSortedUniqueItemIds(params.itemIds);
467
- const autoCreated = [];
468
- const warnings = [];
469
- for (const itemId of ids) {
470
- const historyPath = getHistoryPath(params.pmRoot, itemId);
471
- if (await pathExists(historyPath)) {
472
- continue;
473
- }
474
- if (params.settings.history.missing_stream === "strict_error") {
475
- throw strictMissingStreamError(itemId, params.commandLabel);
476
- }
477
- warnings.push(...await createStream(historyPath, params.commandLabel));
478
- warnings.push(`history_stream_auto_created:${itemId}`);
479
- autoCreated.push(itemId);
480
- }
481
- return {
482
- auto_created_ids: autoCreated,
483
- warnings
484
- };
485
- }
486
-
487
- // dist/core/lock/lock.js
488
- import fs2 from "node:fs/promises";
489
- import path2 from "node:path";
490
- import { randomUUID } from "node:crypto";
491
- !(function() {
492
- try {
493
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
494
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "54aefb1b-1723-52fc-bd7f-a29840fe26dc");
495
- } catch (e2) {
496
- }
497
- })();
498
- function parseLockInfo(raw) {
499
- let parsed;
500
- try {
501
- parsed = JSON.parse(raw);
502
- } catch {
503
- return {
504
- info: null,
505
- warnings: ["lock_info_invalid_json"]
506
- };
507
- }
508
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
509
- return {
510
- info: null,
511
- warnings: ["lock_info_invalid_shape"]
512
- };
513
- }
514
- const candidate = parsed;
515
- const id = candidate.id;
516
- const pid = candidate.pid;
517
- const owner = candidate.owner;
518
- const createdAt = candidate.created_at;
519
- const ttlSeconds = candidate.ttl_seconds;
520
- if (typeof id !== "string" || typeof pid !== "number" || !Number.isFinite(pid) || typeof owner !== "string" || typeof createdAt !== "string" || typeof ttlSeconds !== "number" || !Number.isFinite(ttlSeconds)) {
521
- return {
522
- info: null,
523
- warnings: ["lock_info_invalid_shape"]
524
- };
525
- }
526
- return {
527
- info: {
528
- id,
529
- pid,
530
- owner,
531
- created_at: createdAt,
532
- ttl_seconds: ttlSeconds
533
- },
534
- warnings: []
535
- };
536
- }
537
- async function readLockInfo(lockPath) {
538
- try {
539
- const raw = await fs2.readFile(lockPath, "utf8");
540
- await runActiveOnReadHooks({
541
- path: lockPath,
542
- scope: "project"
543
- });
544
- return parseLockInfo(raw);
545
- } catch (error) {
546
- if (isErrno(error, "ENOENT")) {
547
- return {
548
- info: null,
549
- warnings: []
550
- };
551
- }
552
- return {
553
- info: null,
554
- warnings: ["lock_info_read_failed"]
555
- };
556
- }
557
- }
558
- function isErrno(error, code) {
559
- return typeof error === "object" && error !== null && "code" in error && error.code === code;
560
- }
561
- async function emitLockWriteHook(lockPath, op) {
562
- await runActiveOnWriteHooks({
563
- path: lockPath,
564
- scope: "project",
565
- op
566
- });
567
- }
568
- function buildLockPayload(id, owner, ttlSeconds) {
569
- return {
570
- id,
571
- pid: process.pid,
572
- owner,
573
- created_at: nowIso(),
574
- ttl_seconds: ttlSeconds
575
- };
576
- }
577
- async function createLockFile(lockPath, id, owner, ttlSeconds) {
578
- await fs2.mkdir(path2.dirname(lockPath), { recursive: true });
579
- const handle = await fs2.open(lockPath, "wx");
580
- try {
581
- await handle.writeFile(`${JSON.stringify(buildLockPayload(id, owner, ttlSeconds), null, 2)}
582
- `, "utf8");
583
- } finally {
584
- await handle.close();
585
- }
586
- await emitLockWriteHook(lockPath, "lock:create");
587
- }
588
- async function unlinkLockWithHook(lockPath, op) {
589
- try {
590
- await fs2.unlink(lockPath);
591
- await emitLockWriteHook(lockPath, op);
592
- return true;
593
- } catch {
594
- return false;
595
- }
596
- }
597
- function isStaleLock(info, ttlSeconds) {
598
- const createdAtMs = info?.created_at ? Date.parse(info.created_at) : Number.NaN;
599
- const ageMs = Number.isFinite(createdAtMs) ? Date.now() - createdAtMs : Number.POSITIVE_INFINITY;
600
- return ageMs > ttlSeconds * 1e3;
601
- }
602
- function lockOwnerSuffix(info) {
603
- return info?.owner ? ` (owner ${info.owner})` : "";
604
- }
605
- var LOCK_WAIT_INITIAL_DELAY_MS = 25;
606
- var LOCK_WAIT_MAX_DELAY_MS = 200;
607
- var LOCK_CONFLICT_RETRY_HINT_MS = 250;
608
- var MAX_STALE_LOCK_REMOVALS = 3;
609
- var STALE_CLEANUP_GATE_SUFFIX = ".stale-cleanup";
610
- var STALE_CLEANUP_GATE_OWNER_FILE = "owner.json";
611
- var STALE_CLEANUP_GATE_STALE_MS = 1e4;
612
- var STALE_CLEANUP_GATE_MAX_ACTIVE_MS = 5 * 6e4;
613
- function parseNonNegativeIntegerWaitMs(value) {
614
- if (typeof value === "string") {
615
- const trimmed = value.trim();
616
- if (!/^\d+$/.test(trimmed)) {
617
- return void 0;
618
- }
619
- const parsed = Number(trimmed);
620
- return Number.isSafeInteger(parsed) ? parsed : void 0;
621
- }
622
- if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
623
- return Math.trunc(value);
624
- }
625
- return void 0;
626
- }
627
- function resolveLockWaitMs(waitMs) {
628
- const envRaw = process.env.PM_LOCK_WAIT_MS;
629
- const envParsed = parseNonNegativeIntegerWaitMs(envRaw);
630
- if (envParsed !== void 0) {
631
- return envParsed;
632
- }
633
- const callerParsed = parseNonNegativeIntegerWaitMs(waitMs);
634
- if (callerParsed !== void 0) {
635
- return callerParsed;
636
- }
637
- return 0;
638
- }
639
- function sleepWithJitter(baseDelayMs) {
640
- const jitteredMs = Math.max(1, Math.round(baseDelayMs * (0.5 + Math.random())));
641
- return new Promise((resolve) => setTimeout(resolve, jitteredMs));
642
- }
643
- function buildLockConflictError(id, info, waitedMs) {
644
- const waitedSuffix = waitedMs > 0 ? ` after waiting ${waitedMs}ms` : "";
645
- return new PmCliError(`Item ${id} is locked${lockOwnerSuffix(info)}${waitedSuffix}`, EXIT_CODE.CONFLICT, {
646
- code: "lock_conflict",
647
- recovery: {
648
- retry_after_ms: LOCK_CONFLICT_RETRY_HINT_MS
649
- }
650
- });
651
- }
652
- function resolveLockOverrideRelease(result) {
653
- if (typeof result === "function") {
654
- return result;
655
- }
656
- if (typeof result === "object" && result !== null && "release" in result) {
657
- const release = result.release;
658
- return typeof release === "function" ? release : null;
659
- }
660
- return null;
661
- }
662
- function throwIfStaleLockNeedsForce(id, lockInfo, force, forceRequired) {
663
- if (!force && forceRequired) {
664
- const warningSuffix = lockInfo.warnings.length > 0 ? ` (${lockInfo.warnings.join(",")})` : "";
665
- throw new PmCliError(`Item ${id} lock is stale${warningSuffix}; rerun with --force when supported for this command`, EXIT_CODE.CONFLICT);
666
- }
667
- }
668
- function parseStaleCleanupGateOwner(raw) {
669
- let parsed;
670
- try {
671
- parsed = JSON.parse(raw);
672
- } catch {
673
- return null;
674
- }
675
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
676
- return null;
677
- }
678
- const candidate = parsed;
679
- const pid = candidate.pid;
680
- const token = candidate.token;
681
- if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || typeof token !== "string" || token.length === 0) {
682
- return null;
683
- }
684
- return { pid, token };
685
- }
686
- async function readStaleCleanupGateOwner(gatePath) {
687
- try {
688
- return parseStaleCleanupGateOwner(await fs2.readFile(path2.join(gatePath, STALE_CLEANUP_GATE_OWNER_FILE), "utf8"));
689
- } catch {
690
- return null;
691
- }
692
- }
693
- function isProcessAlive(pid) {
694
- try {
695
- process.kill(pid, 0);
696
- return true;
697
- } catch (error) {
698
- if (isErrno(error, "ESRCH")) {
699
- return false;
700
- }
701
- return true;
702
- }
703
- }
704
- async function removeStaleCleanupGateDirectory(gatePath) {
705
- try {
706
- await fs2.rm(gatePath, { recursive: true, force: true });
707
- return true;
708
- } catch {
709
- return false;
710
- }
711
- }
712
- async function releaseStaleCleanupGate(gatePath, token) {
713
- const owner = await readStaleCleanupGateOwner(gatePath);
714
- if (owner === null || owner.token !== token) {
715
- return;
716
- }
717
- await removeStaleCleanupGateDirectory(gatePath);
718
- }
719
- async function tryCreateStaleCleanupGate(gatePath) {
720
- try {
721
- await fs2.mkdir(gatePath);
722
- } catch (error) {
723
- if (isErrno(error, "EEXIST")) {
724
- return null;
725
- }
726
- return null;
727
- }
728
- const owner = { pid: process.pid, token: randomUUID() };
729
- try {
730
- await fs2.writeFile(path2.join(gatePath, STALE_CLEANUP_GATE_OWNER_FILE), `${JSON.stringify(owner)}
731
- `, "utf8");
732
- } catch {
733
- await removeStaleCleanupGateDirectory(gatePath);
734
- return null;
735
- }
736
- return owner;
737
- }
738
- async function removeExpiredStaleCleanupGate(gatePath) {
739
- let gateAgeMs;
740
- try {
741
- const stats = await fs2.stat(gatePath);
742
- gateAgeMs = Date.now() - stats.mtimeMs;
743
- if (gateAgeMs <= STALE_CLEANUP_GATE_STALE_MS) {
744
- return false;
745
- }
746
- } catch (error) {
747
- return isErrno(error, "ENOENT");
748
- }
749
- const owner = await readStaleCleanupGateOwner(gatePath);
750
- if (owner !== null && isProcessAlive(owner.pid) && gateAgeMs <= STALE_CLEANUP_GATE_MAX_ACTIVE_MS) {
751
- return false;
752
- }
753
- return removeStaleCleanupGateDirectory(gatePath);
754
- }
755
- async function acquireStaleCleanupGate(lockPath, _id) {
756
- const gatePath = `${lockPath}${STALE_CLEANUP_GATE_SUFFIX}`;
757
- const owner = await tryCreateStaleCleanupGate(gatePath);
758
- if (owner !== null) {
759
- return async () => releaseStaleCleanupGate(gatePath, owner.token);
760
- }
761
- if (!await removeExpiredStaleCleanupGate(gatePath)) {
762
- return null;
763
- }
764
- const recoveredOwner = await tryCreateStaleCleanupGate(gatePath);
765
- if (recoveredOwner === null) {
766
- return null;
767
- }
768
- return async () => releaseStaleCleanupGate(gatePath, recoveredOwner.token);
769
- }
770
- async function removeConfirmedStaleLock(params) {
771
- const releaseCleanupGate = await acquireStaleCleanupGate(params.lockPath, params.id);
772
- if (releaseCleanupGate === null) {
773
- return {
774
- lockInfo: params.fallbackLockInfo,
775
- shouldRetryCreate: false,
776
- staleRemovalCounted: false
777
- };
778
- }
779
- try {
780
- const currentLockInfo = await readLockInfo(params.lockPath);
781
- if (currentLockInfo.info === null && currentLockInfo.warnings.length === 0) {
782
- return {
783
- lockInfo: currentLockInfo,
784
- shouldRetryCreate: true,
785
- staleRemovalCounted: false
786
- };
787
- }
788
- if (!isStaleLock(currentLockInfo.info, params.ttlSeconds)) {
789
- return {
790
- lockInfo: currentLockInfo,
791
- shouldRetryCreate: false,
792
- staleRemovalCounted: false
793
- };
794
- }
795
- throwIfStaleLockNeedsForce(params.id, currentLockInfo, params.force, params.forceRequiredForStaleLock);
796
- if (params.staleRemovals >= MAX_STALE_LOCK_REMOVALS) {
797
- throw buildLockConflictError(params.id, currentLockInfo.info, Date.now() - params.startedAtMs);
798
- }
799
- return {
800
- lockInfo: currentLockInfo,
801
- shouldRetryCreate: await unlinkLockWithHook(params.lockPath, "lock:stale_remove"),
802
- staleRemovalCounted: true
803
- };
804
- } finally {
805
- await releaseCleanupGate();
806
- }
807
- }
808
- async function acquireLock(pmRoot, id, ttlSeconds, owner, force = false, forceRequiredForStaleLock = true, waitMs) {
809
- const lockOverride = await runActiveServiceOverride("lock_acquire", {
810
- pm_root: pmRoot,
811
- id,
812
- ttl_seconds: ttlSeconds,
813
- owner,
814
- force,
815
- force_required_for_stale_lock: forceRequiredForStaleLock
816
- });
817
- if (lockOverride.handled) {
818
- const release = resolveLockOverrideRelease(lockOverride.result);
819
- if (release) {
820
- return async () => {
821
- await Promise.resolve(release());
822
- await runActiveServiceOverride("lock_release", {
823
- pm_root: pmRoot,
824
- id,
825
- owner
826
- });
827
- };
828
- }
829
- }
830
- const lockPath = getLockPath(pmRoot, id);
831
- const waitBudgetMs = resolveLockWaitMs(waitMs);
832
- const startedAtMs = Date.now();
833
- let staleRemovals = 0;
834
- let backoffMs = LOCK_WAIT_INITIAL_DELAY_MS;
835
- for (; ; ) {
836
- try {
837
- await createLockFile(lockPath, id, owner, ttlSeconds);
838
- return async () => {
839
- await unlinkLockWithHook(lockPath, "lock:release");
840
- await runActiveServiceOverride("lock_release", {
841
- pm_root: pmRoot,
842
- id,
843
- owner
844
- });
845
- };
846
- } catch (error) {
847
- if (!isErrno(error, "EEXIST")) {
848
- throw new PmCliError(`Failed to acquire lock for ${id}: ${toErrorMessage(error)}`, EXIT_CODE.GENERIC_FAILURE);
849
- }
850
- let lockInfo = await readLockInfo(lockPath);
851
- if (isStaleLock(lockInfo.info, ttlSeconds)) {
852
- const staleRemoval = await removeConfirmedStaleLock({
853
- lockPath,
854
- id,
855
- ttlSeconds,
856
- force,
857
- forceRequiredForStaleLock,
858
- staleRemovals,
859
- waitBudgetMs,
860
- startedAtMs,
861
- fallbackLockInfo: lockInfo
862
- });
863
- lockInfo = staleRemoval.lockInfo;
864
- if (staleRemoval.staleRemovalCounted) {
865
- staleRemovals += 1;
866
- }
867
- if (staleRemoval.shouldRetryCreate) {
868
- continue;
869
- }
870
- }
871
- const elapsedMs = Date.now() - startedAtMs;
872
- if (waitBudgetMs === 0 || elapsedMs >= waitBudgetMs) {
873
- throw buildLockConflictError(id, lockInfo.info, waitBudgetMs === 0 ? 0 : elapsedMs);
874
- }
875
- await sleepWithJitter(Math.min(backoffMs, waitBudgetMs - elapsedMs));
876
- backoffMs = Math.min(backoffMs * 2, LOCK_WAIT_MAX_DELAY_MS);
877
- }
878
- }
879
- }
880
-
881
- // dist/core/store/front-matter-cache.js
882
- import fs3 from "node:fs/promises";
883
- import path3 from "node:path";
884
- import { createHash } from "node:crypto";
885
- !(function() {
886
- try {
887
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
888
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "33a7cae0-25bf-5973-afc6-7666b14bf957");
889
- } catch (e2) {
890
- }
891
- })();
892
- var CACHE_VERSION = 6;
893
- var CACHE_FILENAME = "metadata-cache.json";
894
- var BODY_CACHE_FILENAME = "metadata-cache-bodies.json";
895
- var COLLECTIONS_CACHE_FILENAME = "metadata-cache-collections.json";
896
- var HEAVY_METADATA_KEYS = [
897
- "comments",
898
- "notes",
899
- "learnings",
900
- "files",
901
- "tests",
902
- "test_runs",
903
- "docs"
904
- ];
905
- function resolveActiveExtensionFieldNames() {
906
- return collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
907
- }
908
- function splitHeavyMetadata(metadata) {
909
- const light = { ...metadata };
910
- const heavy = {};
911
- for (const key of HEAVY_METADATA_KEYS) {
912
- if (key in light) {
913
- heavy[key] = light[key];
914
- delete light[key];
915
- }
916
- }
917
- return { light, heavy };
918
- }
919
- function mergeHeavyMetadata(light, heavy) {
920
- if (!heavy || Object.keys(heavy).length === 0) {
921
- return light;
922
- }
923
- return { ...light, ...heavy };
924
- }
925
- function computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames) {
926
- const hash = createHash("sha256");
927
- hash.update(`format:${preferredFormat ?? "default"}`);
928
- const sortedTypes = Object.entries(typeToFolder).sort(([a], [b]) => a.localeCompare(b)).map(([type, folder]) => `${type}=${folder}`).join(",");
929
- hash.update(`|types:${sortedTypes}`);
930
- if (schema) {
931
- hash.update(`|schema:${JSON.stringify(schema)}`);
932
- }
933
- if (extensionFieldNames.length > 0) {
934
- hash.update(`|extension_fields:${extensionFieldNames.join(",")}`);
935
- }
936
- return hash.digest("hex").slice(0, 16);
937
- }
938
- function getCachePath(pmRoot) {
939
- return path3.join(pmRoot, "runtime", CACHE_FILENAME);
940
- }
941
- function getBodyCachePath(pmRoot) {
942
- return path3.join(pmRoot, "runtime", BODY_CACHE_FILENAME);
943
- }
944
- function getCollectionsCachePath(pmRoot) {
945
- return path3.join(pmRoot, "runtime", COLLECTIONS_CACHE_FILENAME);
946
- }
947
- var ENVELOPE_MEMO_MAX_ENTRIES = 24;
948
- var envelopeMemo = /* @__PURE__ */ new Map();
949
- function memoizeEnvelope(cachePath, entry) {
950
- if (envelopeMemo.size >= ENVELOPE_MEMO_MAX_ENTRIES && !envelopeMemo.has(cachePath)) {
951
- evictOldestMemoEntries(envelopeMemo);
952
- }
953
- envelopeMemo.set(cachePath, entry);
954
- }
955
- async function loadEnvelopeMemoized(cachePath, parse) {
956
- let stat;
957
- try {
958
- stat = await fs3.stat(cachePath);
959
- } catch {
960
- envelopeMemo.delete(cachePath);
961
- return null;
962
- }
963
- const memoized = envelopeMemo.get(cachePath);
964
- if (memoized && statMatches(memoized.signature, stat.mtimeMs, stat.ctimeMs, stat.size)) {
965
- envelopeMemo.delete(cachePath);
966
- envelopeMemo.set(cachePath, memoized);
967
- return memoized.envelope;
968
- }
969
- let envelope;
970
- try {
971
- envelope = parse(await fs3.readFile(cachePath, "utf8"));
972
- } catch {
973
- envelope = null;
974
- }
975
- memoizeEnvelope(cachePath, {
976
- signature: { mtime_ms: stat.mtimeMs, ctime_ms: stat.ctimeMs, size: stat.size },
977
- envelope
978
- });
979
- return envelope;
980
- }
981
- async function loadCache(pmRoot) {
982
- return await loadEnvelopeMemoized(getCachePath(pmRoot), (raw) => {
983
- const parsed = JSON.parse(raw);
984
- if (parsed.version !== CACHE_VERSION || typeof parsed.entries !== "object" || parsed.entries === null) {
985
- return null;
986
- }
987
- return parsed;
988
- });
989
- }
990
- async function loadBodyCache(pmRoot) {
991
- return await loadEnvelopeMemoized(getBodyCachePath(pmRoot), (raw) => {
992
- const parsed = JSON.parse(raw);
993
- if (parsed.version !== CACHE_VERSION || typeof parsed.bodies !== "object" || parsed.bodies === null) {
994
- return null;
995
- }
996
- return parsed;
997
- });
998
- }
999
- async function loadCollectionsCache(pmRoot) {
1000
- return await loadEnvelopeMemoized(getCollectionsCachePath(pmRoot), (raw) => {
1001
- const parsed = JSON.parse(raw);
1002
- if (parsed.version !== CACHE_VERSION || typeof parsed.collections !== "object" || parsed.collections === null) {
1003
- return null;
1004
- }
1005
- return parsed;
1006
- });
1007
- }
1008
- async function persistCache(cachePath, envelope) {
1009
- await fs3.mkdir(path3.dirname(cachePath), { recursive: true });
1010
- await writeFileAtomic(cachePath, JSON.stringify(envelope));
1011
- try {
1012
- const stat = await fs3.stat(cachePath);
1013
- memoizeEnvelope(cachePath, {
1014
- signature: { mtime_ms: stat.mtimeMs, ctime_ms: stat.ctimeMs, size: stat.size },
1015
- envelope
1016
- });
1017
- } catch {
1018
- envelopeMemo.delete(cachePath);
1019
- }
1020
- }
1021
- function shouldReplaceCachedDocumentCandidate(existingFormat, candidateFormat, preferredFormat) {
1022
- if (preferredFormat) {
1023
- return candidateFormat === preferredFormat && existingFormat !== preferredFormat;
1024
- }
1025
- return candidateFormat === "toon" && existingFormat !== "toon";
1026
- }
1027
- function appendWarning(warnings, warning) {
1028
- if (warnings && !warnings.includes(warning)) {
1029
- warnings.push(warning);
1030
- }
1031
- }
1032
- function statMatches(signature, mtimeMs, ctimeMs, size) {
1033
- return signature.mtime_ms === mtimeMs && signature.ctime_ms === ctimeMs && signature.size === size;
1034
- }
1035
- async function readItemDirectoryFiles(pmRoot, folder, warnings) {
1036
- const dirPath = path3.join(pmRoot, folder);
1037
- try {
1038
- const files = await fs3.readdir(dirPath);
1039
- return { folder, dirPath, files };
1040
- } catch (error) {
1041
- if (typeof error === "object" && error !== null && "code" in error && error.code !== "ENOENT") {
1042
- appendWarning(warnings, `item_list_directory_read_failed:${folder}`);
1043
- }
1044
- return { folder, dirPath, files: [] };
1045
- }
1046
- }
1047
- function isItemDocumentFile(file) {
1048
- return ITEM_FILE_EXTENSIONS.some((ext) => file.toLowerCase().endsWith(ext));
1049
- }
1050
- function markDocumentCacheMisses(misses, includeBody, includeCollections, metadataCached, bodyCached, collectionsCached) {
1051
- if (!metadataCached) {
1052
- misses.metadata = true;
1053
- }
1054
- if (includeBody && !bodyCached) {
1055
- misses.body = true;
1056
- }
1057
- if (includeCollections && !collectionsCached) {
1058
- misses.collections = true;
1059
- }
1060
- }
1061
- async function dispatchCachedDocumentReadHooks(filePath, warnings, dispatchReadHooks) {
1062
- if (!dispatchReadHooks) {
1063
- return;
1064
- }
1065
- for (const warning of await runActiveOnReadHooks({ path: filePath, scope: "project" })) {
1066
- appendWarning(warnings, warning);
1067
- }
1068
- }
1069
- async function readCachedDocumentParts(filePath, relativePath, context) {
1070
- const stat = await fs3.stat(filePath);
1071
- const mtimeMs = stat.mtimeMs;
1072
- const ctimeMs = stat.ctimeMs;
1073
- const { size } = stat;
1074
- const itemFormat = getItemFormatFromPath(filePath);
1075
- await dispatchCachedDocumentReadHooks(filePath, context.warnings, context.dispatchReadHooks);
1076
- const cachedEntry = context.previousEntries[relativePath];
1077
- const metadataCached = cachedEntry !== void 0 && statMatches(cachedEntry, mtimeMs, ctimeMs, size);
1078
- const cachedBody = context.previousBodies[relativePath];
1079
- const bodyCached = cachedBody !== void 0 && statMatches(cachedBody, mtimeMs, ctimeMs, size);
1080
- const cachedCollections = context.previousCollections[relativePath];
1081
- const collectionsCached = cachedCollections !== void 0 && statMatches(cachedCollections, mtimeMs, ctimeMs, size);
1082
- const needRead = !metadataCached || context.includeBody && !bodyCached || context.includeCollections && !collectionsCached;
1083
- if (!needRead) {
1084
- return {
1085
- mtimeMs,
1086
- ctimeMs,
1087
- size,
1088
- itemFormat,
1089
- lightMetadata: cachedEntry.metadata,
1090
- heavyMetadata: context.includeCollections && cachedCollections ? cachedCollections.collections : void 0,
1091
- bodyLength: cachedEntry.body_length,
1092
- body: context.includeBody ? cachedBody.body : void 0
1093
- };
1094
- }
1095
- const raw = await fs3.readFile(filePath, "utf8");
1096
- const parsed = parseItemDocument(raw, {
1097
- format: itemFormat,
1098
- schema: context.schema,
1099
- extensionFieldNames: context.extensionFieldNames,
1100
- onWarning: (warning) => appendWarning(context.warnings, warning)
1101
- });
1102
- const split = splitHeavyMetadata(parsed.metadata);
1103
- markDocumentCacheMisses(context.state.misses, context.includeBody, context.includeCollections, metadataCached, bodyCached, collectionsCached);
1104
- return {
1105
- mtimeMs,
1106
- ctimeMs,
1107
- size,
1108
- itemFormat,
1109
- lightMetadata: metadataCached ? cachedEntry.metadata : split.light,
1110
- heavyMetadata: context.includeCollections ? collectionsCached ? cachedCollections.collections : split.heavy : void 0,
1111
- bodyLength: metadataCached ? cachedEntry.body_length : parsed.body.length,
1112
- body: context.includeBody ? parsed.body : void 0
1113
- };
1114
- }
1115
- function recordCachedDocumentCandidate(filePath, relativePath, context, parts) {
1116
- context.state.newEntries[relativePath] = {
1117
- mtime_ms: parts.mtimeMs,
1118
- ctime_ms: parts.ctimeMs,
1119
- size: parts.size,
1120
- metadata: parts.lightMetadata,
1121
- body_length: parts.bodyLength
1122
- };
1123
- if (context.includeBody && parts.body !== void 0) {
1124
- context.state.newBodies[relativePath] = {
1125
- mtime_ms: parts.mtimeMs,
1126
- ctime_ms: parts.ctimeMs,
1127
- size: parts.size,
1128
- body: parts.body
1129
- };
1130
- }
1131
- if (context.includeCollections && parts.heavyMetadata !== void 0) {
1132
- context.state.newCollections[relativePath] = {
1133
- mtime_ms: parts.mtimeMs,
1134
- ctime_ms: parts.ctimeMs,
1135
- size: parts.size,
1136
- collections: parts.heavyMetadata
1137
- };
1138
- }
1139
- const metadata = context.includeCollections ? mergeHeavyMetadata(parts.lightMetadata, parts.heavyMetadata) : parts.lightMetadata;
1140
- const existing = context.state.documentsById.get(metadata.id);
1141
- const candidate = {
1142
- metadata,
1143
- body: parts.body,
1144
- item_format: parts.itemFormat,
1145
- item_path: filePath
1146
- };
1147
- if (!existing || shouldReplaceCachedDocumentCandidate(existing.itemFormat, parts.itemFormat, context.preferredFormat)) {
1148
- context.state.documentsById.set(metadata.id, { candidate, itemFormat: parts.itemFormat });
1149
- }
1150
- }
1151
- async function processCachedDocumentFile(folder, filePath, relativePath, context) {
1152
- try {
1153
- const parts = await readCachedDocumentParts(filePath, relativePath, context);
1154
- recordCachedDocumentCandidate(filePath, relativePath, context, parts);
1155
- } catch {
1156
- appendWarning(context.warnings, `item_list_item_read_failed:${folder}/${path3.basename(filePath)}`);
1157
- }
1158
- }
1159
- function selectPreviousMetadataEntries(existingCache, contextFingerprint) {
1160
- return existingCache && existingCache.context_fingerprint === contextFingerprint ? existingCache.entries : {};
1161
- }
1162
- function selectPreviousBodyEntries(existingBodyCache, contextFingerprint) {
1163
- return existingBodyCache && existingBodyCache.context_fingerprint === contextFingerprint ? existingBodyCache.bodies : {};
1164
- }
1165
- function selectPreviousCollectionEntries(existingCollectionsCache, contextFingerprint) {
1166
- return existingCollectionsCache && existingCollectionsCache.context_fingerprint === contextFingerprint ? existingCollectionsCache.collections : {};
1167
- }
1168
- function createDocumentCacheMutableState() {
1169
- return {
1170
- newEntries: {},
1171
- newBodies: {},
1172
- newCollections: {},
1173
- documentsById: /* @__PURE__ */ new Map(),
1174
- misses: {
1175
- metadata: false,
1176
- body: false,
1177
- collections: false
1178
- }
1179
- };
1180
- }
1181
- function collectCachedDocumentParseTasks(dirResults, context) {
1182
- const parseTasks = [];
1183
- for (const { folder, dirPath, files } of dirResults) {
1184
- for (const file of files) {
1185
- if (!isItemDocumentFile(file)) {
1186
- continue;
1187
- }
1188
- const filePath = path3.join(dirPath, file);
1189
- const relativePath = path3.relative(context.pmRoot, filePath);
1190
- parseTasks.push(processCachedDocumentFile(folder, filePath, relativePath, context));
1191
- }
1192
- }
1193
- return parseTasks;
1194
- }
1195
- async function persistMetadataCacheIfNeeded(params) {
1196
- const metadataDirty = params.state.misses.metadata || Object.keys(params.previousEntries).length !== Object.keys(params.state.newEntries).length;
1197
- if (!metadataDirty && params.existingCache !== null && params.existingCache.context_fingerprint === params.contextFingerprint) {
1198
- return;
1199
- }
1200
- await persistCache(getCachePath(params.pmRoot), {
1201
- version: CACHE_VERSION,
1202
- context_fingerprint: params.contextFingerprint,
1203
- entries: params.state.newEntries
1204
- }).catch(() => {
1205
- });
1206
- }
1207
- async function persistBodyCacheIfNeeded(params) {
1208
- const bodyDirty = params.state.misses.body || Object.keys(params.previousBodies).length !== Object.keys(params.state.newBodies).length;
1209
- if (!bodyDirty && params.existingBodyCache !== null && params.existingBodyCache.context_fingerprint === params.contextFingerprint) {
1210
- return;
1211
- }
1212
- await persistCache(getBodyCachePath(params.pmRoot), {
1213
- version: CACHE_VERSION,
1214
- context_fingerprint: params.contextFingerprint,
1215
- bodies: params.state.newBodies
1216
- }).catch(() => {
1217
- });
1218
- }
1219
- async function persistCollectionsCacheIfNeeded(params) {
1220
- const collectionsDirty = params.state.misses.collections || Object.keys(params.previousCollections).length !== Object.keys(params.state.newCollections).length;
1221
- if (!collectionsDirty && params.existingCollectionsCache !== null && params.existingCollectionsCache.context_fingerprint === params.contextFingerprint) {
1222
- return;
1223
- }
1224
- await persistCache(getCollectionsCachePath(params.pmRoot), {
1225
- version: CACHE_VERSION,
1226
- context_fingerprint: params.contextFingerprint,
1227
- collections: params.state.newCollections
1228
- }).catch(() => {
1229
- });
1230
- }
1231
- function sortedCachedDocumentCandidates(state) {
1232
- return [...state.documentsById.values()].sort((left, right) => left.candidate.metadata.id.localeCompare(right.candidate.metadata.id)).map((entry) => entry.candidate);
1233
- }
1234
- async function listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, options = {}) {
1235
- const includeBody = options.includeBody !== false;
1236
- const includeCollections = options.includeCollections !== false;
1237
- const extensionFieldNames = resolveActiveExtensionFieldNames();
1238
- const contextFingerprint = computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames);
1239
- const existingCache = await loadCache(pmRoot);
1240
- const previousEntries = selectPreviousMetadataEntries(existingCache, contextFingerprint);
1241
- const existingBodyCache = includeBody ? await loadBodyCache(pmRoot) : null;
1242
- const previousBodies = selectPreviousBodyEntries(existingBodyCache, contextFingerprint);
1243
- const existingCollectionsCache = includeCollections ? await loadCollectionsCache(pmRoot) : null;
1244
- const previousCollections = selectPreviousCollectionEntries(existingCollectionsCache, contextFingerprint);
1245
- const entries = Object.entries(typeToFolder);
1246
- const dirResults = await Promise.all(entries.map(([, folder]) => readItemDirectoryFiles(pmRoot, folder, warnings)));
1247
- const dispatchReadHooks = hasActiveOnReadHooks();
1248
- const state = createDocumentCacheMutableState();
1249
- const context = {
1250
- pmRoot,
1251
- preferredFormat,
1252
- warnings,
1253
- schema,
1254
- extensionFieldNames,
1255
- includeBody,
1256
- includeCollections,
1257
- dispatchReadHooks,
1258
- previousEntries,
1259
- previousBodies,
1260
- previousCollections,
1261
- state
1262
- };
1263
- await Promise.all(collectCachedDocumentParseTasks(dirResults, context));
1264
- await persistMetadataCacheIfNeeded({ pmRoot, contextFingerprint, existingCache, previousEntries, state });
1265
- if (includeBody) {
1266
- await persistBodyCacheIfNeeded({ pmRoot, contextFingerprint, existingBodyCache, previousBodies, state });
1267
- }
1268
- if (includeCollections) {
1269
- await persistCollectionsCacheIfNeeded({ pmRoot, contextFingerprint, existingCollectionsCache, previousCollections, state });
1270
- }
1271
- return sortedCachedDocumentCandidates(state);
1272
- }
1273
- async function listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema) {
1274
- const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
1275
- includeBody: false
1276
- });
1277
- return candidates.map((candidate) => ({
1278
- metadata: candidate.metadata,
1279
- body: candidate.body ?? ""
1280
- }));
1281
- }
1282
- async function listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema) {
1283
- const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
1284
- includeBody: false,
1285
- includeCollections: false
1286
- });
1287
- return candidates.map((candidate) => ({
1288
- metadata: candidate.metadata,
1289
- body: candidate.body ?? ""
1290
- }));
1291
- }
1292
-
1293
- // dist/core/store/item-store.js
1294
- import fs4 from "node:fs/promises";
1295
- import path4 from "node:path";
1296
- !(function() {
1297
- try {
1298
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
1299
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "c869c984-c9d5-5346-b651-d1b95418a628");
1300
- } catch (e2) {
1301
- }
1302
- })();
1303
- async function fileExists(targetPath) {
1304
- try {
1305
- await fs4.access(targetPath);
1306
- return true;
1307
- } catch {
1308
- return false;
1309
- }
1310
- }
1311
- function appendWarning2(warnings, warning) {
1312
- if (!warnings) {
1313
- return;
1314
- }
1315
- if (!warnings.includes(warning)) {
1316
- warnings.push(warning);
1317
- }
1318
- }
1319
- function resolveActiveExtensionFieldNames2(explicit) {
1320
- return explicit ?? collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
1321
- }
1322
- function resolveItemFormatSearchOrder(preferredFormat) {
1323
- if (preferredFormat === "toon") {
1324
- return ["toon", "json_markdown"];
1325
- }
1326
- if (preferredFormat === "json_markdown") {
1327
- return ["json_markdown", "toon"];
1328
- }
1329
- return ["toon", "json_markdown"];
1330
- }
1331
- async function locateItem(pmRoot, rawId, idPrefix = "pm-", preferredFormat, typeToFolder = TYPE_TO_FOLDER) {
1332
- const normalizedId = normalizeItemId(rawId, idPrefix);
1333
- const rawNormalizedId = normalizeRawItemId(rawId);
1334
- const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];
1335
- const entries = Object.entries(typeToFolder);
1336
- const searchOrder = resolveItemFormatSearchOrder(preferredFormat);
1337
- for (const candidateId of candidateIds) {
1338
- for (const [type] of entries) {
1339
- for (const itemFormat of searchOrder) {
1340
- const itemPath = getItemPath(pmRoot, type, candidateId, itemFormat, typeToFolder);
1341
- if (await fileExists(itemPath)) {
1342
- return {
1343
- id: candidateId,
1344
- type,
1345
- itemPath,
1346
- item_format: itemFormat
1347
- };
1348
- }
1349
- }
1350
- }
1351
- }
1352
- return null;
1353
- }
1354
- async function readLocatedItem(item, options = {}) {
1355
- const raw = await fs4.readFile(item.itemPath, "utf8");
1356
- await runActiveOnReadHooks({
1357
- path: item.itemPath,
1358
- scope: "project"
1359
- });
1360
- const document = parseItemDocument(raw, {
1361
- format: item.item_format,
1362
- schema: options.schema,
1363
- extensionFieldNames: resolveActiveExtensionFieldNames2(options.extensionFieldNames),
1364
- onWarning: (warning) => appendWarning2(options.warnings, warning)
1365
- });
1366
- return { raw, document };
1367
- }
1368
- async function listAllFrontMatter(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
1369
- const documents = await listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema);
1370
- return documents.map((document) => document.metadata);
1371
- }
1372
- async function listAllFrontMatterLight(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
1373
- const documents = await listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema);
1374
- return documents.map((document) => document.metadata);
1375
- }
1376
- async function listAllFrontMatterWithBody(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
1377
- const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, { includeBody: true });
1378
- return candidates.map((candidate) => ({
1379
- ...candidate.metadata,
1380
- // includeBody:true guarantees candidate bodies are materialized.
1381
- body: candidate.body
1382
- }));
1383
- }
1384
- async function listKnownItemIds(pmRoot, typeToFolder) {
1385
- const folders = new Set(Object.values(typeToFolder));
1386
- const allIds = [];
1387
- await Promise.all([...folders].map(async (folder) => {
1388
- try {
1389
- const entries = await fs4.readdir(path4.join(pmRoot, folder));
1390
- for (const entry of entries) {
1391
- for (const ext of ITEM_FILE_EXTENSIONS) {
1392
- if (entry.toLowerCase().endsWith(ext)) {
1393
- allIds.push(entry.slice(0, -ext.length));
1394
- break;
1395
- }
1396
- }
1397
- }
1398
- } catch {
1399
- }
1400
- }));
1401
- return allIds;
1402
- }
1403
- async function buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder) {
1404
- const normalized = normalizeItemId(badId, idPrefix);
1405
- const ids = await listKnownItemIds(pmRoot, typeToFolder);
1406
- if (ids.length === 0)
1407
- return [];
1408
- const limit = Math.max(3, Math.floor(normalized.length / 2));
1409
- const scored = ids.map((id) => ({ id, distance: levenshteinDistanceWithinLimit(id, normalized, limit) })).filter((entry) => entry.distance !== null).sort((left, right) => left.distance - right.distance).slice(0, 3).map((entry) => entry.id);
1410
- return scored;
1411
- }
1412
- async function buildItemNotFoundError(pmRoot, badId, idPrefix, typeToFolder) {
1413
- const suggestions = await buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder);
1414
- const nextSteps = ["Confirm the active --path/PM_PATH scope, then retry with a valid id."];
1415
- if (suggestions.length > 0) {
1416
- nextSteps.unshift(`Did you mean one of: ${suggestions.join(", ")}?`);
1417
- }
1418
- return new PmCliError(`Item ${badId} not found`, EXIT_CODE.NOT_FOUND, { nextSteps });
1419
- }
1420
- function bypassesAssigneeConflict(op, bypassAssigneeConflict) {
1421
- return op === "claim" || bypassAssigneeConflict === true && (op === "comment_add" || op === "comment_edit" || op === "comment_delete" || op === "note_add" || op === "learning_add" || op === "release" || op === "update" || op === "update_audit");
1422
- }
1423
- async function prepareLockedItem(params) {
1424
- const typeToFolder = params.typeToFolder ?? resolveItemTypeRegistry(params.settings, getActiveExtensionRegistrations()).type_to_folder;
1425
- const located = await locateItem(params.pmRoot, params.id, params.settings.id_prefix, params.settings.item_format, typeToFolder);
1426
- if (!located) {
1427
- throw await buildItemNotFoundError(params.pmRoot, params.id, params.settings.id_prefix, typeToFolder);
1428
- }
1429
- 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, params.settings.locks.wait_ms);
1430
- try {
1431
- const warnings = [];
1432
- const { raw: originalRaw, document } = await readLocatedItem(located, {
1433
- schema: params.settings.schema,
1434
- extensionFieldNames: params.extensionFieldNames,
1435
- warnings
1436
- });
1437
- const assigned = document.metadata.assignee?.trim();
1438
- const governance = resolveGovernanceKnobs(params.settings);
1439
- const hasOwnershipConflict = assigned && assigned !== params.author && !params.force && !bypassesAssigneeConflict(params.op, params.bypassAssigneeConflict);
1440
- if (hasOwnershipConflict) {
1441
- if (governance.ownership_enforcement === "strict") {
1442
- throw new PmCliError(`Item ${located.id} is assigned to ${assigned}. Use --force to override.`, EXIT_CODE.CONFLICT);
1443
- }
1444
- if (governance.ownership_enforcement === "warn") {
1445
- warnings.push(`ownership_warning:assignee_conflict:${located.id}:${assigned}`);
1446
- }
1447
- }
1448
- return {
1449
- typeToFolder,
1450
- located,
1451
- originalRaw,
1452
- document,
1453
- warnings,
1454
- releaseLock
1455
- };
1456
- } catch (error) {
1457
- await releaseLock();
1458
- throw error;
1459
- }
1460
- }
1461
- function resolveItemStoreWriteOverride(serviceWriteOverride, targetItemPath, serializedAfter) {
1462
- if (!serviceWriteOverride.handled || typeof serviceWriteOverride.result !== "object" || serviceWriteOverride.result === null) {
1463
- return { effectiveTargetItemPath: targetItemPath, effectiveSerializedAfter: serializedAfter, skipItemWrite: false };
1464
- }
1465
- const overrideRecord = serviceWriteOverride.result;
1466
- return {
1467
- effectiveTargetItemPath: typeof overrideRecord.target_item_path === "string" && overrideRecord.target_item_path.trim().length > 0 ? overrideRecord.target_item_path : targetItemPath,
1468
- effectiveSerializedAfter: typeof overrideRecord.contents === "string" ? overrideRecord.contents : serializedAfter,
1469
- skipItemWrite: overrideRecord.skip_write === true
1470
- };
1471
- }
1472
- async function rollbackMutatedItemWrite(params) {
1473
- if (params.skipItemWrite) {
1474
- return;
1475
- }
1476
- if (params.effectiveTargetItemPath !== params.originalItemPath) {
1477
- await writeFileAtomic(params.originalItemPath, params.originalRaw);
1478
- await fs4.rm(params.effectiveTargetItemPath, { force: true });
1479
- return;
1480
- }
1481
- await writeFileAtomic(params.originalItemPath, params.originalRaw);
1482
- }
1483
- async function mutateItem(params) {
1484
- const prepared = await prepareLockedItem({
1485
- pmRoot: params.pmRoot,
1486
- settings: params.settings,
1487
- id: params.id,
1488
- op: params.op,
1489
- author: params.author,
1490
- force: params.force,
1491
- bypassAssigneeConflict: params.bypassAssigneeConflict,
1492
- extensionFieldNames: params.extensionFieldNames,
1493
- typeToFolder: params.typeToFolder
1494
- });
1495
- const { typeToFolder, located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;
1496
- try {
1497
- const beforeDocument = canonicalDocument(document, {
1498
- schema: params.settings.schema,
1499
- extensionFieldNames: params.extensionFieldNames
1500
- });
1501
- const mutableDocument = canonicalDocument(structuredClone(document), {
1502
- schema: params.settings.schema,
1503
- extensionFieldNames: params.extensionFieldNames
1504
- });
1505
- const mutation = params.mutate(mutableDocument);
1506
- if (params.skipNoop === true && mutation.changedFields.length === 0) {
1507
- return {
1508
- item: beforeDocument.metadata,
1509
- body: beforeDocument.body,
1510
- changedFields: [],
1511
- warnings: [...parseWarnings, ...mutation.warnings ?? []]
1512
- };
1513
- }
1514
- const historyPolicy = await enforceHistoryStreamPolicyForItem({
1515
- pmRoot: params.pmRoot,
1516
- settings: params.settings,
1517
- itemId: located.id,
1518
- commandLabel: params.op
1519
- });
1520
- mutableDocument.metadata.updated_at = nowIso();
1521
- const afterDocument = canonicalDocument(mutableDocument, {
1522
- schema: params.settings.schema,
1523
- extensionFieldNames: params.extensionFieldNames
1524
- });
1525
- const targetItemFormat = "toon";
1526
- const serializedAfter = serializeItemDocument(afterDocument, {
1527
- format: targetItemFormat,
1528
- schema: params.settings.schema,
1529
- extensionFieldNames: params.extensionFieldNames
1530
- });
1531
- const targetItemPath = getItemPath(params.pmRoot, afterDocument.metadata.type, located.id, targetItemFormat, typeToFolder);
1532
- const historyPath = getHistoryPath(params.pmRoot, located.id);
1533
- const serviceWriteOverride = await runActiveServiceOverride("item_store_write", {
1534
- op: params.op,
1535
- pm_root: params.pmRoot,
1536
- item_id: located.id,
1537
- source_item_path: located.itemPath,
1538
- target_item_path: targetItemPath,
1539
- history_path: historyPath,
1540
- item_format: targetItemFormat,
1541
- before: beforeDocument,
1542
- after: afterDocument,
1543
- contents: serializedAfter
1544
- });
1545
- const { effectiveTargetItemPath, effectiveSerializedAfter, skipItemWrite } = resolveItemStoreWriteOverride(serviceWriteOverride, targetItemPath, serializedAfter);
1546
- if (!skipItemWrite) {
1547
- await writeFileAtomic(effectiveTargetItemPath, effectiveSerializedAfter);
1548
- }
1549
- if (!skipItemWrite && effectiveTargetItemPath !== located.itemPath) {
1550
- await fs4.rm(located.itemPath);
1551
- }
1552
- const entry = createHistoryEntry({
1553
- nowIso: afterDocument.metadata.updated_at,
1554
- author: params.author,
1555
- op: params.op,
1556
- before: beforeDocument,
1557
- after: afterDocument,
1558
- message: params.message
1559
- });
1560
- try {
1561
- await appendHistoryEntry(historyPath, entry);
1562
- } catch (error) {
1563
- await rollbackMutatedItemWrite({
1564
- skipItemWrite,
1565
- effectiveTargetItemPath,
1566
- originalItemPath: located.itemPath,
1567
- originalRaw
1568
- });
1569
- throw error;
1570
- }
1571
- const hookWarnings = [
1572
- ...await runActiveOnWriteHooks({
1573
- path: effectiveTargetItemPath,
1574
- scope: "project",
1575
- op: params.op,
1576
- item_id: afterDocument.metadata.id,
1577
- item_type: afterDocument.metadata.type,
1578
- before: beforeDocument,
1579
- after: afterDocument,
1580
- changed_fields: mutation.changedFields
1581
- }),
1582
- ...await runActiveOnWriteHooks({
1583
- path: historyPath,
1584
- scope: "project",
1585
- op: `${params.op}:history`,
1586
- item_id: afterDocument.metadata.id,
1587
- item_type: afterDocument.metadata.type,
1588
- before: beforeDocument,
1589
- after: afterDocument,
1590
- changed_fields: mutation.changedFields
1591
- })
1592
- ];
1593
- recordAfterCommandAffectedItem({
1594
- id: afterDocument.metadata.id,
1595
- op: params.op,
1596
- item_type: afterDocument.metadata.type,
1597
- previous_status: beforeDocument.metadata.status,
1598
- status: afterDocument.metadata.status,
1599
- previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, mutation.changedFields),
1600
- current: projectAfterCommandItemSnapshot(afterDocument.metadata, mutation.changedFields),
1601
- changed_fields: mutation.changedFields
1602
- });
1603
- return {
1604
- item: afterDocument.metadata,
1605
- body: afterDocument.body,
1606
- changedFields: mutation.changedFields,
1607
- warnings: [
1608
- ...parseWarnings,
1609
- ...mutation.warnings ?? [],
1610
- ...historyPolicy.warnings,
1611
- ...serviceWriteOverride.warnings,
1612
- ...hookWarnings
1613
- ]
1614
- };
1615
- } finally {
1616
- await releaseLock();
1617
- }
1618
- }
1619
- async function deleteItem(params) {
1620
- const prepared = await prepareLockedItem({
1621
- pmRoot: params.pmRoot,
1622
- settings: params.settings,
1623
- id: params.id,
1624
- op: "delete",
1625
- author: params.author,
1626
- force: params.force
1627
- });
1628
- const { located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;
1629
- try {
1630
- const historyPolicy = await enforceHistoryStreamPolicyForItem({
1631
- pmRoot: params.pmRoot,
1632
- settings: params.settings,
1633
- itemId: located.id,
1634
- commandLabel: "delete"
1635
- });
1636
- const beforeDocument = canonicalDocument(document, { schema: params.settings.schema });
1637
- const deletionTimestamp = nowIso();
1638
- const tombstoneDocument = EMPTY_CANONICAL_DOCUMENT;
1639
- const historyEntry = createHistoryEntry({
1640
- nowIso: deletionTimestamp,
1641
- author: params.author,
1642
- op: "delete",
1643
- before: beforeDocument,
1644
- after: tombstoneDocument,
1645
- message: params.message
1646
- });
1647
- const historyPath = getHistoryPath(params.pmRoot, located.id);
1648
- const serviceDeleteOverride = await runActiveServiceOverride("item_store_delete", {
1649
- op: "delete",
1650
- pm_root: params.pmRoot,
1651
- item_id: located.id,
1652
- item_path: located.itemPath,
1653
- history_path: historyPath,
1654
- before: beforeDocument
1655
- });
1656
- let effectiveItemPath = located.itemPath;
1657
- let skipDelete = false;
1658
- if (serviceDeleteOverride.handled && typeof serviceDeleteOverride.result === "object" && serviceDeleteOverride.result !== null) {
1659
- const overrideRecord = serviceDeleteOverride.result;
1660
- if (typeof overrideRecord.item_path === "string" && overrideRecord.item_path.trim().length > 0) {
1661
- effectiveItemPath = overrideRecord.item_path;
1662
- }
1663
- if (overrideRecord.skip_delete === true) {
1664
- skipDelete = true;
1665
- }
1666
- }
1667
- if (params.dryRun === true) {
1668
- return {
1669
- item: beforeDocument.metadata,
1670
- changedFields: ["deleted"],
1671
- targetPath: effectiveItemPath,
1672
- warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings]
1673
- };
1674
- }
1675
- if (!skipDelete) {
1676
- await fs4.rm(effectiveItemPath);
1677
- }
1678
- try {
1679
- await appendHistoryEntry(historyPath, historyEntry);
1680
- } catch (error) {
1681
- if (!skipDelete) {
1682
- await writeFileAtomic(effectiveItemPath, originalRaw);
1683
- }
1684
- throw error;
1685
- }
1686
- const hookWarnings = [
1687
- ...await runActiveOnWriteHooks({
1688
- path: effectiveItemPath,
1689
- scope: "project",
1690
- op: "delete",
1691
- item_id: beforeDocument.metadata.id,
1692
- item_type: beforeDocument.metadata.type,
1693
- before: beforeDocument,
1694
- after: tombstoneDocument,
1695
- changed_fields: ["deleted"]
1696
- }),
1697
- ...await runActiveOnWriteHooks({
1698
- path: historyPath,
1699
- scope: "project",
1700
- op: "delete:history",
1701
- item_id: beforeDocument.metadata.id,
1702
- item_type: beforeDocument.metadata.type,
1703
- before: beforeDocument,
1704
- after: tombstoneDocument,
1705
- changed_fields: ["deleted"]
1706
- })
1707
- ];
1708
- recordAfterCommandAffectedItem({
1709
- id: beforeDocument.metadata.id,
1710
- op: "delete",
1711
- item_type: beforeDocument.metadata.type,
1712
- previous_status: beforeDocument.metadata.status,
1713
- previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, Object.keys(beforeDocument.metadata)),
1714
- changed_fields: ["deleted"]
1715
- });
1716
- return {
1717
- item: beforeDocument.metadata,
1718
- changedFields: ["deleted"],
1719
- warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings, ...hookWarnings]
1720
- };
1721
- } finally {
1722
- await releaseLock();
1723
- }
1724
- }
1725
-
1726
- export {
1727
- collectRegisteredItemFieldNames,
1728
- parseRegisteredItemFieldAssignments,
1729
- applyRegisteredItemFieldDefaultsAndValidation,
1730
- toItemRecord,
1731
- hashDocument,
1732
- hashEmptyDocument,
1733
- createHistoryEntry,
1734
- appendHistoryEntry,
1735
- enforceHistoryStreamPolicyForItem,
1736
- enforceHistoryStreamPolicyForItems,
1737
- acquireLock,
1738
- HEAVY_METADATA_KEYS,
1739
- listAllDocumentCandidatesCached,
1740
- locateItem,
1741
- readLocatedItem,
1742
- listAllFrontMatter,
1743
- listAllFrontMatterLight,
1744
- listAllFrontMatterWithBody,
1745
- buildItemNotFoundError,
1746
- mutateItem,
1747
- deleteItem
1748
- };
1749
- //# sourceMappingURL=chunk-3U3VEWK6.js.map