@unbrained/pm-cli 2026.7.14 → 2026.7.15

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 (708) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +14 -11
  4. package/dist/cli/argv-utils.d.ts +1 -4
  5. package/dist/cli/argv-utils.js +3 -13
  6. package/dist/cli/argv-utils.js.map +1 -1
  7. package/dist/cli/bootstrap-args.d.ts +6 -4
  8. package/dist/cli/bootstrap-args.js +51 -16
  9. package/dist/cli/bootstrap-args.js.map +1 -1
  10. package/dist/cli/bundle-integrity.d.ts +49 -0
  11. package/dist/cli/bundle-integrity.js +111 -0
  12. package/dist/cli/bundle-integrity.js.map +1 -0
  13. package/dist/cli/commands/completion.js +7 -2
  14. package/dist/cli/commands/completion.js.map +1 -1
  15. package/dist/cli/commands/config.d.ts +6 -163
  16. package/dist/cli/commands/config.js +4 -1133
  17. package/dist/cli/commands/config.js.map +1 -1
  18. package/dist/cli/commands/context.d.ts +2 -4
  19. package/dist/cli/commands/context.js +10 -85
  20. package/dist/cli/commands/context.js.map +1 -1
  21. package/dist/cli/commands/create.d.ts +1 -0
  22. package/dist/cli/commands/create.js +3 -2
  23. package/dist/cli/commands/create.js.map +1 -1
  24. package/dist/cli/commands/extension/describe.d.ts +2 -91
  25. package/dist/cli/commands/extension/describe.js +4 -142
  26. package/dist/cli/commands/extension/describe.js.map +1 -1
  27. package/dist/cli/commands/extension/scaffold.d.ts +2 -36
  28. package/dist/cli/commands/extension/scaffold.js +4 -2435
  29. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  30. package/dist/cli/commands/extension/shared.d.ts +2 -28
  31. package/dist/cli/commands/extension/shared.js +4 -130
  32. package/dist/cli/commands/extension/shared.js.map +1 -1
  33. package/dist/cli/commands/extension.d.ts +3 -400
  34. package/dist/cli/commands/extension.js +4 -2183
  35. package/dist/cli/commands/extension.js.map +1 -1
  36. package/dist/cli/commands/gc.d.ts +6 -56
  37. package/dist/cli/commands/gc.js +4 -270
  38. package/dist/cli/commands/gc.js.map +1 -1
  39. package/dist/cli/commands/get.d.ts +18 -5
  40. package/dist/cli/commands/get.js +117 -58
  41. package/dist/cli/commands/get.js.map +1 -1
  42. package/dist/cli/commands/health.d.ts +6 -184
  43. package/dist/cli/commands/health.js +4 -1747
  44. package/dist/cli/commands/health.js.map +1 -1
  45. package/dist/cli/commands/history-compact.d.ts +4 -139
  46. package/dist/cli/commands/history-compact.js +5 -510
  47. package/dist/cli/commands/history-compact.js.map +1 -1
  48. package/dist/cli/commands/history-redact.d.ts +8 -120
  49. package/dist/cli/commands/history-redact.js +6 -581
  50. package/dist/cli/commands/history-redact.js.map +1 -1
  51. package/dist/cli/commands/history-repair.d.ts +7 -89
  52. package/dist/cli/commands/history-repair.js +5 -257
  53. package/dist/cli/commands/history-repair.js.map +1 -1
  54. package/dist/cli/commands/history.d.ts +1 -2
  55. package/dist/cli/commands/history.js +6 -48
  56. package/dist/cli/commands/history.js.map +1 -1
  57. package/dist/cli/commands/index.d.ts +1 -0
  58. package/dist/cli/commands/index.js +3 -2
  59. package/dist/cli/commands/index.js.map +1 -1
  60. package/dist/cli/commands/init-agent-guidance.d.ts +6 -113
  61. package/dist/cli/commands/init-agent-guidance.js +4 -431
  62. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  63. package/dist/cli/commands/init.d.ts +6 -181
  64. package/dist/cli/commands/init.js +4 -690
  65. package/dist/cli/commands/init.js.map +1 -1
  66. package/dist/cli/commands/next.js +3 -3
  67. package/dist/cli/commands/next.js.map +1 -1
  68. package/dist/cli/commands/profile.d.ts +4 -174
  69. package/dist/cli/commands/profile.js +4 -425
  70. package/dist/cli/commands/profile.js.map +1 -1
  71. package/dist/cli/commands/restore.d.ts +4 -19
  72. package/dist/cli/commands/restore.js +9 -158
  73. package/dist/cli/commands/restore.js.map +1 -1
  74. package/dist/cli/commands/schema.d.ts +7 -507
  75. package/dist/cli/commands/schema.js +5 -1254
  76. package/dist/cli/commands/schema.js.map +1 -1
  77. package/dist/cli/commands/test.d.ts +2 -4
  78. package/dist/cli/commands/test.js +7 -97
  79. package/dist/cli/commands/test.js.map +1 -1
  80. package/dist/cli/commands/validate.d.ts +9 -249
  81. package/dist/cli/commands/validate.js +9 -2150
  82. package/dist/cli/commands/validate.js.map +1 -1
  83. package/dist/cli/extension-command-help.js +18 -4
  84. package/dist/cli/extension-command-help.js.map +1 -1
  85. package/dist/cli/extension-command-options.js +3 -3
  86. package/dist/cli/extension-command-options.js.map +1 -1
  87. package/dist/cli/help-content.js +7 -3
  88. package/dist/cli/help-content.js.map +1 -1
  89. package/dist/cli/main.js +20 -30
  90. package/dist/cli/main.js.map +1 -1
  91. package/dist/cli/register-list-query.js +4 -2
  92. package/dist/cli/register-list-query.js.map +1 -1
  93. package/dist/cli/register-mutation.js +11 -3
  94. package/dist/cli/register-mutation.js.map +1 -1
  95. package/dist/cli/register-setup.js +4 -2
  96. package/dist/cli/register-setup.js.map +1 -1
  97. package/dist/cli/registration-helpers.js +3 -2
  98. package/dist/cli/registration-helpers.js.map +1 -1
  99. package/dist/cli-bundle/bundle-manifest.json +782 -0
  100. package/dist/cli-bundle/chunks/{append-PVZJDM6J.js → append-OJQFUQ4T.js} +5 -5
  101. package/dist/cli-bundle/chunks/append-UZVHUO74.js +11 -0
  102. package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js → chunk-2IFFUZLC.js} +2 -2
  103. package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js → chunk-2JKGO6QX.js} +4 -4
  104. package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js → chunk-2NCIPMQP.js} +2 -2
  105. package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js → chunk-2VPAVL7O.js} +2 -2
  106. package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js → chunk-2WSE6PO2.js} +4 -4
  107. package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js → chunk-34L5OT3Y.js} +2 -2
  108. package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js → chunk-3AUGG2DP.js} +3 -3
  109. package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js → chunk-3CLU2XZO.js} +4 -4
  110. package/dist/cli-bundle/chunks/{chunk-N3CMP4NI.js → chunk-3S5QVM5H.js} +43 -7
  111. package/dist/cli-bundle/chunks/chunk-3S5QVM5H.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js +64 -0
  113. package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js.map +7 -0
  114. package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js → chunk-3WM75PWC.js} +3 -3
  115. package/dist/cli-bundle/chunks/chunk-4223PVZT.js +121 -0
  116. package/dist/cli-bundle/chunks/chunk-4223PVZT.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-5URI7TPJ.js → chunk-4XQ3BDV4.js} +281 -164
  118. package/dist/cli-bundle/chunks/chunk-4XQ3BDV4.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js → chunk-5JLUII3O.js} +13 -13
  120. package/dist/cli-bundle/chunks/{chunk-MKL4CP2I.js → chunk-5ZSLZLDN.js} +631 -246
  121. package/dist/cli-bundle/chunks/chunk-5ZSLZLDN.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-Q37E63AM.js → chunk-6CFNAVTF.js} +21 -141
  123. package/dist/cli-bundle/chunks/chunk-6CFNAVTF.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js → chunk-6N2VXVTQ.js} +2 -2
  125. package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js → chunk-6S3YSUYG.js} +3 -3
  126. package/dist/cli-bundle/chunks/{chunk-ZUKSZVBW.js → chunk-7B67ZL4N.js} +8 -7
  127. package/dist/cli-bundle/chunks/chunk-7B67ZL4N.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-IA3YFTXT.js → chunk-7PIWCHTW.js} +11 -13
  129. package/dist/cli-bundle/chunks/chunk-7PIWCHTW.js.map +1 -0
  130. package/dist/cli-bundle/chunks/{chunk-BPD26E3P.js → chunk-7Z4LKRS4.js} +291 -81
  131. package/dist/cli-bundle/chunks/chunk-7Z4LKRS4.js.map +1 -0
  132. package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js → chunk-AHVTB5I5.js} +4 -4
  133. package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js → chunk-APRVSW2O.js} +3 -3
  134. package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js → chunk-B7PE22W6.js} +4 -4
  135. package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js → chunk-BCOFWYW4.js} +3 -3
  136. package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js → chunk-BEP7WJA2.js} +4 -4
  137. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js +1114 -0
  138. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js.map +7 -0
  139. package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js → chunk-BSEQUTQP.js} +2 -2
  140. package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js.map → chunk-BSEQUTQP.js.map} +2 -2
  141. package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js → chunk-CRVF2JDM.js} +10 -10
  142. package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js → chunk-DM4H7FP4.js} +3 -3
  143. package/dist/cli-bundle/chunks/chunk-DUT67M43.js +5 -0
  144. package/dist/cli-bundle/chunks/{chunk-44LNIULG.js → chunk-DYH63FX7.js} +4 -4
  145. package/dist/cli-bundle/chunks/{chunk-LWTIRS3Y.js → chunk-E2OJMKML.js} +306 -82
  146. package/dist/cli-bundle/chunks/chunk-E2OJMKML.js.map +7 -0
  147. package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js → chunk-EAB64KLB.js} +4 -4
  148. package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js → chunk-EACOH7AU.js} +10 -10
  149. package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js → chunk-EH2OPHBI.js} +10 -10
  150. package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js.map → chunk-EH2OPHBI.js.map} +1 -1
  151. package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js → chunk-EJEXHTY5.js} +2 -2
  152. package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js → chunk-EYLCSJAI.js} +2 -2
  153. package/dist/cli-bundle/chunks/{chunk-655STMGA.js → chunk-FMBNM2EN.js} +2 -2
  154. package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js → chunk-FNSPG7MU.js} +12 -12
  155. package/dist/cli-bundle/chunks/{chunk-5CT5BW6E.js → chunk-GM5QHQU6.js} +46 -40
  156. package/dist/cli-bundle/chunks/chunk-GM5QHQU6.js.map +7 -0
  157. package/dist/cli-bundle/chunks/{chunk-FTQLW4JD.js → chunk-GOSLKLFE.js} +418 -24
  158. package/dist/cli-bundle/chunks/chunk-GOSLKLFE.js.map +1 -0
  159. package/dist/cli-bundle/chunks/{chunk-KB726FMH.js → chunk-H2Z3FYXQ.js} +4 -4
  160. package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js +162 -0
  161. package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js.map +1 -0
  162. package/dist/cli-bundle/chunks/{chunk-2QIQGYPW.js → chunk-H5APFTHZ.js} +53 -10
  163. package/dist/cli-bundle/chunks/chunk-H5APFTHZ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js +118 -0
  165. package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{chunk-ZAYYDNB3.js → chunk-HO4KXD6I.js} +22 -142
  167. package/dist/cli-bundle/chunks/chunk-HO4KXD6I.js.map +1 -0
  168. package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js → chunk-HYB5AZ63.js} +203 -62
  169. package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js.map → chunk-HYB5AZ63.js.map} +3 -3
  170. package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js → chunk-IA5FKNII.js} +2 -2
  171. package/dist/cli-bundle/chunks/{chunk-JL7WZ4O2.js → chunk-IG3SWA4A.js} +33 -9
  172. package/dist/cli-bundle/chunks/chunk-IG3SWA4A.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js → chunk-IJIICKVW.js} +2 -2
  174. package/dist/cli-bundle/chunks/{chunk-IGED7NH2.js → chunk-ILX33QXL.js} +668 -251
  175. package/dist/cli-bundle/chunks/chunk-ILX33QXL.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-UGTVWL3E.js → chunk-INU6DKT5.js} +47 -41
  177. package/dist/cli-bundle/chunks/chunk-INU6DKT5.js.map +1 -0
  178. package/dist/cli-bundle/chunks/{chunk-UB2QYSTO.js → chunk-J5AOEGDC.js} +26 -18
  179. package/dist/cli-bundle/chunks/chunk-J5AOEGDC.js.map +1 -0
  180. package/dist/cli-bundle/chunks/{chunk-4DY4KPQI.js → chunk-J6364LFM.js} +1330 -937
  181. package/dist/cli-bundle/chunks/chunk-J6364LFM.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{chunk-DVOLZJ3C.js → chunk-J6EY5V4N.js} +1295 -939
  183. package/dist/cli-bundle/chunks/chunk-J6EY5V4N.js.map +1 -0
  184. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js +1097 -0
  185. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js.map +1 -0
  186. package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js → chunk-JOUQZENX.js} +3 -3
  187. package/dist/cli-bundle/chunks/{chunk-J4NZOP3I.js → chunk-JXQUXVMI.js} +9 -8
  188. package/dist/cli-bundle/chunks/chunk-JXQUXVMI.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js → chunk-JYFOV7FC.js} +4 -4
  190. package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js → chunk-K2X6U4UA.js} +4 -4
  191. package/dist/cli-bundle/chunks/{chunk-6OTZMORS.js → chunk-K3WII2ME.js} +27 -27
  192. package/dist/cli-bundle/chunks/chunk-K3WII2ME.js.map +7 -0
  193. package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js → chunk-KG44YSKD.js} +4 -4
  194. package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js → chunk-KPMKHGEA.js} +4 -4
  195. package/dist/cli-bundle/chunks/{chunk-QASRVKUQ.js → chunk-LPYWLWDS.js} +257 -163
  196. package/dist/cli-bundle/chunks/chunk-LPYWLWDS.js.map +1 -0
  197. package/dist/cli-bundle/chunks/{chunk-RGXD5JJR.js → chunk-LSG2U345.js} +19 -12
  198. package/dist/cli-bundle/chunks/chunk-LSG2U345.js.map +7 -0
  199. package/dist/cli-bundle/chunks/chunk-MIQDDLB5.js +5 -0
  200. package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js → chunk-NLDFBC6J.js} +2 -2
  201. package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js → chunk-NP22ERDF.js} +3 -3
  202. package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js → chunk-NU3IMIEA.js} +2 -2
  203. package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js → chunk-NVPZIJVR.js} +2 -2
  204. package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js → chunk-ODALILG3.js} +2 -2
  205. package/dist/cli-bundle/chunks/{chunk-CDJYP7OQ.js → chunk-ONG5V5CI.js} +190 -63
  206. package/dist/cli-bundle/chunks/chunk-ONG5V5CI.js.map +1 -0
  207. package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js → chunk-ONREO4ST.js} +3 -3
  208. package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js +61 -0
  209. package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js.map +1 -0
  210. package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js → chunk-P74IZQ7A.js} +12 -12
  211. package/dist/cli-bundle/chunks/chunk-PENXZX3U.js +172 -0
  212. package/dist/cli-bundle/chunks/chunk-PENXZX3U.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js → chunk-PGY23YTC.js} +3 -3
  214. package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js → chunk-PMOSXADO.js} +3 -3
  215. package/dist/cli-bundle/chunks/chunk-PNTULOGU.js +9 -0
  216. package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js → chunk-Q7A43DS4.js} +2 -2
  217. package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js → chunk-QEHQ2GVG.js} +2 -2
  218. package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js → chunk-QIPLHNP7.js} +7 -7
  219. package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js → chunk-QKECXBBG.js} +3 -3
  220. package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js.map → chunk-QKECXBBG.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js → chunk-QKJGPFAF.js} +3 -3
  222. package/dist/cli-bundle/chunks/{chunk-F7PSHRNO.js → chunk-QKXHFPYM.js} +27 -10
  223. package/dist/cli-bundle/chunks/chunk-QKXHFPYM.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js → chunk-RLCHOOHC.js} +2 -2
  225. package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js → chunk-RMLWNPH2.js} +2 -2
  226. package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js → chunk-RRM5JYJC.js} +2 -2
  227. package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js → chunk-S6MQESFR.js} +4 -4
  228. package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js → chunk-SDQLJWBO.js} +4 -4
  229. package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js → chunk-SELVXEZK.js} +2 -2
  230. package/dist/cli-bundle/chunks/{chunk-DYEX6NFH.js → chunk-TD3LVC7D.js} +438 -23
  231. package/dist/cli-bundle/chunks/chunk-TD3LVC7D.js.map +7 -0
  232. package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js → chunk-TKOVBP6C.js} +2 -2
  233. package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js → chunk-TQSZFPIS.js} +4 -4
  234. package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js → chunk-TSMHDIW4.js} +2 -2
  235. package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js → chunk-UFXU44HV.js} +4 -4
  236. package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js → chunk-ULTHRDBP.js} +3 -3
  237. package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js → chunk-UMOPHQSU.js} +9 -9
  238. package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js.map → chunk-UMOPHQSU.js.map} +2 -2
  239. package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js → chunk-UOHFKBUV.js} +3 -3
  240. package/dist/cli-bundle/chunks/{chunk-PHKP3AGR.js → chunk-UWQHLMEB.js} +35 -18
  241. package/dist/cli-bundle/chunks/chunk-UWQHLMEB.js.map +7 -0
  242. package/dist/cli-bundle/chunks/{chunk-6TTOHMTB.js → chunk-UXONS674.js} +45 -112
  243. package/dist/cli-bundle/chunks/chunk-UXONS674.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js → chunk-UY2ACEMF.js} +7 -7
  245. package/dist/cli-bundle/chunks/{chunk-6PKA3SJQ.js → chunk-WQPUU7XD.js} +19 -28
  246. package/dist/cli-bundle/chunks/chunk-WQPUU7XD.js.map +1 -0
  247. package/dist/cli-bundle/chunks/{chunk-7TQMR6LK.js → chunk-WT3ZEOGH.js} +70 -20
  248. package/dist/cli-bundle/chunks/chunk-WT3ZEOGH.js.map +7 -0
  249. package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js → chunk-WUJQK4YV.js} +4 -4
  250. package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js → chunk-XSJUSQAE.js} +2 -2
  251. package/dist/cli-bundle/chunks/{chunk-6MHSBDGD.js → chunk-XXXF6PAQ.js} +50 -117
  252. package/dist/cli-bundle/chunks/chunk-XXXF6PAQ.js.map +7 -0
  253. package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js → chunk-YAQEBNY7.js} +4 -4
  254. package/dist/cli-bundle/chunks/{chunk-7QDSYUMF.js → chunk-YAROI3PD.js} +44 -21
  255. package/dist/cli-bundle/chunks/chunk-YAROI3PD.js.map +1 -0
  256. package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js → chunk-YBLZ2VE7.js} +13 -13
  257. package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js → chunk-YCQET3OT.js} +2 -2
  258. package/dist/cli-bundle/chunks/chunk-YUSOJDWM.js +9 -0
  259. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js +58 -0
  260. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js → chunk-ZI6VQWQ7.js} +4 -4
  262. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js +68 -0
  263. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js.map +7 -0
  264. package/dist/cli-bundle/chunks/{close-LZECOMHO.js → close-CWODTPKG.js} +5 -5
  265. package/dist/cli-bundle/chunks/close-W6LI2PKM.js +12 -0
  266. package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js → close-many-CQFUY7MR.js} +15 -13
  267. package/dist/cli-bundle/chunks/close-many-DLDDVSH5.js +23 -0
  268. package/dist/cli-bundle/chunks/comments-E3TNTK24.js +13 -0
  269. package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js → comments-WGLHR7LB.js} +7 -7
  270. package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js → copy-LXVDXH7B.js} +4 -4
  271. package/dist/cli-bundle/chunks/copy-Q5ZJPUKR.js +9 -0
  272. package/dist/cli-bundle/chunks/{create-F53OBTOU.js → create-J5U6ND4K.js} +9 -9
  273. package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js → create-LBVCYMEG.js} +9 -9
  274. package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js → delete-PMJBNY5G.js} +4 -4
  275. package/dist/cli-bundle/chunks/delete-WNHB3LYW.js +10 -0
  276. package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js → deps-JZ7TMVCB.js} +7 -4
  277. package/dist/cli-bundle/chunks/{deps-U57I7EAK.js → deps-OA26IS25.js} +7 -4
  278. package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js → docs-FEWB2DQB.js} +6 -6
  279. package/dist/cli-bundle/chunks/docs-HA2AIDBB.js +14 -0
  280. package/dist/cli-bundle/chunks/{files-TBZD7V6H.js → files-6YFBJRBG.js} +6 -6
  281. package/dist/cli-bundle/chunks/{files-TTY6N2AV.js → files-EFIWKFTM.js} +6 -6
  282. package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js → focus-4QJR7FOQ.js} +5 -5
  283. package/dist/cli-bundle/chunks/focus-POIW5LTJ.js +10 -0
  284. package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js → history-compact-CKRPDTJN.js} +6 -10
  285. package/dist/cli-bundle/chunks/history-compact-FWG2C7FZ.js +16 -0
  286. package/dist/cli-bundle/chunks/history-redact-BB3TGDAE.js +15 -0
  287. package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js → history-redact-D225BHOZ.js} +5 -6
  288. package/dist/cli-bundle/chunks/history-repair-6GEAM7HE.js +16 -0
  289. package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js → history-repair-RQXKQHL4.js} +6 -8
  290. package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js → learnings-JLNLCOL5.js} +7 -7
  291. package/dist/cli-bundle/chunks/learnings-RSNLSWDC.js +13 -0
  292. package/dist/cli-bundle/chunks/notes-2WDH6DXU.js +13 -0
  293. package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js → notes-GB47XXQQ.js} +7 -7
  294. package/dist/cli-bundle/chunks/plan-DOVI2VMW.js +24 -0
  295. package/dist/cli-bundle/chunks/{plan-2NNEO46V.js → plan-VDCJ2PCN.js} +10 -10
  296. package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js → profile-FAU7NZML.js} +10 -10
  297. package/dist/cli-bundle/chunks/{profile-U725ATWZ.js → profile-IVXQEL3D.js} +10 -10
  298. package/dist/cli-bundle/chunks/{register-list-query-BUWCYHBT.js → register-list-query-DKA3EH5D.js} +22 -19
  299. package/dist/cli-bundle/chunks/register-list-query-DKA3EH5D.js.map +7 -0
  300. package/dist/cli-bundle/chunks/{register-list-query-KTZ6AGE7.js → register-list-query-UL4UKBBN.js} +23 -20
  301. package/dist/cli-bundle/chunks/register-list-query-UL4UKBBN.js.map +1 -0
  302. package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js → register-mutation-ARFHRW55.js} +36 -32
  303. package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js.map → register-mutation-ARFHRW55.js.map} +2 -2
  304. package/dist/cli-bundle/chunks/{register-mutation-4FMGJJF7.js → register-mutation-RBBJ52DK.js} +37 -33
  305. package/dist/cli-bundle/chunks/register-mutation-RBBJ52DK.js.map +1 -0
  306. package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js → register-operations-ZIBBRSED.js} +41 -39
  307. package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js.map → register-operations-ZIBBRSED.js.map} +1 -1
  308. package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js → register-operations-ZUJ5JWPE.js} +39 -37
  309. package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js.map → register-operations-ZUJ5JWPE.js.map} +1 -1
  310. package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js → register-setup-BCVLFEYS.js} +29 -17
  311. package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js.map → register-setup-BCVLFEYS.js.map} +2 -2
  312. package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js → register-setup-TDCGWIOS.js} +19 -18
  313. package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js.map → register-setup-TDCGWIOS.js.map} +1 -1
  314. package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js → restore-25DLT2Q2.js} +6 -6
  315. package/dist/cli-bundle/chunks/restore-YPMVUUEX.js +14 -0
  316. package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js → schema-FNU3WE4O.js} +7 -6
  317. package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js → schema-NBCM3RAD.js} +7 -6
  318. package/dist/cli-bundle/chunks/update-WWBYOPXO.js +21 -0
  319. package/dist/cli-bundle/chunks/update-WWBYOPXO.js.map +7 -0
  320. package/dist/cli-bundle/chunks/{update-Q3UCILNR.js → update-XHSIAIXE.js} +12 -12
  321. package/dist/cli-bundle/chunks/update-XHSIAIXE.js.map +1 -0
  322. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js +32 -0
  323. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js.map +7 -0
  324. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js +36 -0
  325. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js.map +1 -0
  326. package/dist/cli-bundle/main.js +826 -43
  327. package/dist/cli-bundle/main.js.map +4 -4
  328. package/dist/cli-bundle/sdk-runtime.js +70 -57
  329. package/dist/cli-bundle/sdk-testing.js +6 -6
  330. package/dist/cli-bundle/sdk.js +876 -74
  331. package/dist/cli-bundle/sdk.js.map +4 -4
  332. package/dist/cli.js +5 -4
  333. package/dist/cli.js.map +1 -1
  334. package/dist/core/diagnostics/remediation.js +12 -2
  335. package/dist/core/diagnostics/remediation.js.map +1 -1
  336. package/dist/core/history/projection.d.ts +39 -0
  337. package/dist/core/history/projection.js +164 -0
  338. package/dist/core/history/projection.js.map +1 -0
  339. package/dist/core/history/read.d.ts +3 -0
  340. package/dist/core/history/read.js +55 -0
  341. package/dist/core/history/read.js.map +1 -0
  342. package/dist/core/output/output-control.d.ts +18 -0
  343. package/dist/core/output/output-control.js +26 -0
  344. package/dist/core/output/output-control.js.map +1 -0
  345. package/dist/core/output/output.js +20 -8
  346. package/dist/core/output/output.js.map +1 -1
  347. package/dist/core/sentry/helpers.js +10 -2
  348. package/dist/core/sentry/helpers.js.map +1 -1
  349. package/dist/core/shared/command-types.d.ts +2 -0
  350. package/dist/core/shared/command-types.js +2 -2
  351. package/dist/core/shared/command-types.js.map +1 -1
  352. package/dist/core/shared/errors.d.ts +11 -0
  353. package/dist/core/shared/errors.js +2 -2
  354. package/dist/core/shared/errors.js.map +1 -1
  355. package/dist/mcp/server.d.ts +2 -2
  356. package/dist/mcp/tool-definitions.js +5 -5
  357. package/dist/mcp/tool-definitions.js.map +1 -1
  358. package/dist/sdk/author-attribution.d.ts +35 -0
  359. package/dist/sdk/author-attribution.js +118 -0
  360. package/dist/sdk/author-attribution.js.map +1 -0
  361. package/dist/sdk/cli-contracts/command-aliases.d.ts +7 -0
  362. package/dist/sdk/cli-contracts/command-aliases.js +17 -0
  363. package/dist/sdk/cli-contracts/command-aliases.js.map +1 -0
  364. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  365. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  366. package/dist/sdk/cli-contracts/tool-option-contracts.js +6 -2
  367. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  368. package/dist/sdk/cli-contracts/tool-parameter-tables.js +21 -2
  369. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  370. package/dist/sdk/cli-contracts/tool-schema.js +3 -3
  371. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  372. package/dist/sdk/cli-contracts.d.ts +1 -0
  373. package/dist/sdk/cli-contracts.js +3 -2
  374. package/dist/sdk/cli-contracts.js.map +1 -1
  375. package/dist/sdk/cli-program.d.ts +8 -0
  376. package/dist/sdk/cli-program.js +39 -0
  377. package/dist/sdk/cli-program.js.map +1 -0
  378. package/dist/sdk/command-line.d.ts +11 -0
  379. package/dist/sdk/command-line.js +40 -0
  380. package/dist/sdk/command-line.js.map +1 -0
  381. package/dist/sdk/config.d.ts +163 -0
  382. package/dist/sdk/config.js +1087 -0
  383. package/dist/sdk/config.js.map +1 -0
  384. package/dist/sdk/context-relevance.d.ts +21 -0
  385. package/dist/sdk/context-relevance.js +70 -2
  386. package/dist/sdk/context-relevance.js.map +1 -1
  387. package/dist/sdk/dependencies.d.ts +15 -2
  388. package/dist/sdk/dependencies.js +97 -8
  389. package/dist/sdk/dependencies.js.map +1 -1
  390. package/dist/{cli/commands → sdk}/extension/bundled-catalog.d.ts +1 -1
  391. package/dist/{cli/commands → sdk}/extension/bundled-catalog.js +12 -12
  392. package/dist/sdk/extension/bundled-catalog.js.map +1 -0
  393. package/dist/sdk/extension/concurrency.d.ts +7 -0
  394. package/dist/sdk/extension/concurrency.js +26 -0
  395. package/dist/sdk/extension/concurrency.js.map +1 -0
  396. package/dist/sdk/extension/describe.d.ts +91 -0
  397. package/dist/sdk/extension/describe.js +144 -0
  398. package/dist/sdk/extension/describe.js.map +1 -0
  399. package/dist/{cli/commands → sdk}/extension/doctor.d.ts +3 -3
  400. package/dist/{cli/commands → sdk}/extension/doctor.js +7 -7
  401. package/dist/sdk/extension/doctor.js.map +1 -0
  402. package/dist/sdk/extension/install-runtime.d.ts +26 -0
  403. package/dist/sdk/extension/install-runtime.js +269 -0
  404. package/dist/sdk/extension/install-runtime.js.map +1 -0
  405. package/dist/sdk/extension/install-snapshot.d.ts +23 -0
  406. package/dist/sdk/extension/install-snapshot.js +66 -0
  407. package/dist/sdk/extension/install-snapshot.js.map +1 -0
  408. package/dist/{cli/commands → sdk}/extension/install-sources.d.ts +3 -3
  409. package/dist/{cli/commands → sdk}/extension/install-sources.js +15 -12
  410. package/dist/sdk/extension/install-sources.js.map +1 -0
  411. package/dist/{cli/commands → sdk}/extension/managed-state.js +6 -6
  412. package/dist/sdk/extension/managed-state.js.map +1 -0
  413. package/dist/sdk/extension/scaffold.d.ts +36 -0
  414. package/dist/sdk/extension/scaffold.js +2436 -0
  415. package/dist/sdk/extension/scaffold.js.map +1 -0
  416. package/dist/sdk/extension/shared.d.ts +28 -0
  417. package/dist/sdk/extension/shared.js +140 -0
  418. package/dist/sdk/extension/shared.js.map +1 -0
  419. package/dist/sdk/extension/update-check.d.ts +15 -0
  420. package/dist/sdk/extension/update-check.js +68 -0
  421. package/dist/sdk/extension/update-check.js.map +1 -0
  422. package/dist/sdk/extension.d.ts +367 -0
  423. package/dist/sdk/extension.js +2174 -0
  424. package/dist/sdk/extension.js.map +1 -0
  425. package/dist/sdk/governance/gc.d.ts +56 -0
  426. package/dist/sdk/governance/gc.js +276 -0
  427. package/dist/sdk/governance/gc.js.map +1 -0
  428. package/dist/sdk/governance/health.d.ts +187 -0
  429. package/dist/sdk/governance/health.js +1796 -0
  430. package/dist/sdk/governance/health.js.map +1 -0
  431. package/dist/sdk/governance/validate.d.ts +255 -0
  432. package/dist/sdk/governance/validate.js +2175 -0
  433. package/dist/sdk/governance/validate.js.map +1 -0
  434. package/dist/sdk/history-compact.d.ts +142 -0
  435. package/dist/sdk/history-compact.js +508 -0
  436. package/dist/sdk/history-compact.js.map +1 -0
  437. package/dist/sdk/history-mcp.d.ts +17 -0
  438. package/dist/sdk/history-mcp.js +68 -0
  439. package/dist/sdk/history-mcp.js.map +1 -0
  440. package/dist/sdk/history-read.d.ts +31 -0
  441. package/dist/sdk/history-read.js +58 -0
  442. package/dist/sdk/history-read.js.map +1 -0
  443. package/dist/sdk/history-redact.d.ts +120 -0
  444. package/dist/sdk/history-redact.js +577 -0
  445. package/dist/sdk/history-redact.js.map +1 -0
  446. package/dist/sdk/history-repair.d.ts +89 -0
  447. package/dist/sdk/history-repair.js +263 -0
  448. package/dist/sdk/history-repair.js.map +1 -0
  449. package/dist/sdk/index.d.ts +25 -1
  450. package/dist/sdk/index.js +27 -3
  451. package/dist/sdk/index.js.map +1 -1
  452. package/dist/sdk/init-agent-guidance.d.ts +113 -0
  453. package/dist/sdk/init-agent-guidance.js +437 -0
  454. package/dist/sdk/init-agent-guidance.js.map +1 -0
  455. package/dist/sdk/init.d.ts +186 -0
  456. package/dist/sdk/init.js +733 -0
  457. package/dist/sdk/init.js.map +1 -0
  458. package/dist/sdk/invocation-author.d.ts +2 -0
  459. package/dist/sdk/invocation-author.js +39 -0
  460. package/dist/sdk/invocation-author.js.map +1 -0
  461. package/dist/sdk/item-children.d.ts +45 -0
  462. package/dist/sdk/item-children.js +75 -0
  463. package/dist/sdk/item-children.js.map +1 -0
  464. package/dist/sdk/item-schedule.d.ts +26 -0
  465. package/dist/sdk/item-schedule.js +28 -0
  466. package/dist/sdk/item-schedule.js.map +1 -0
  467. package/dist/sdk/output.d.ts +7 -0
  468. package/dist/sdk/output.js +11 -0
  469. package/dist/sdk/output.js.map +1 -0
  470. package/dist/sdk/pagination.d.ts +4 -1
  471. package/dist/sdk/pagination.js +13 -5
  472. package/dist/sdk/pagination.js.map +1 -1
  473. package/dist/sdk/profile.d.ts +176 -0
  474. package/dist/sdk/profile.js +431 -0
  475. package/dist/sdk/profile.js.map +1 -0
  476. package/dist/sdk/relationship-analytics.d.ts +108 -0
  477. package/dist/sdk/relationship-analytics.js +292 -0
  478. package/dist/sdk/relationship-analytics.js.map +1 -0
  479. package/dist/sdk/relationship-context.d.ts +67 -0
  480. package/dist/sdk/relationship-context.js +207 -0
  481. package/dist/sdk/relationship-context.js.map +1 -0
  482. package/dist/sdk/relationship-history.d.ts +109 -0
  483. package/dist/sdk/relationship-history.js +401 -0
  484. package/dist/sdk/relationship-history.js.map +1 -0
  485. package/dist/sdk/relationships.d.ts +145 -0
  486. package/dist/sdk/relationships.js +551 -0
  487. package/dist/sdk/relationships.js.map +1 -0
  488. package/dist/sdk/runtime-input.d.ts +10 -0
  489. package/dist/sdk/runtime-input.js +60 -0
  490. package/dist/sdk/runtime-input.js.map +1 -0
  491. package/dist/sdk/runtime.d.ts +31 -8
  492. package/dist/sdk/runtime.js +61 -57
  493. package/dist/sdk/runtime.js.map +1 -1
  494. package/dist/sdk/schema.d.ts +507 -0
  495. package/dist/sdk/schema.js +1269 -0
  496. package/dist/sdk/schema.js.map +1 -0
  497. package/dist/{cli/commands → sdk}/templates.d.ts +1 -1
  498. package/dist/{cli/commands → sdk}/templates.js +9 -9
  499. package/dist/sdk/templates.js.map +1 -0
  500. package/dist/{cli/commands → sdk}/test/linked-command-detection.d.ts +10 -2
  501. package/dist/sdk/test/linked-command-detection.js +525 -0
  502. package/dist/sdk/test/linked-command-detection.js.map +1 -0
  503. package/docs/COMMANDS.md +58 -40
  504. package/docs/EXTENSIONS.md +10 -1
  505. package/docs/RELATIONSHIP_GRAPH.md +113 -0
  506. package/docs/RELEASING.md +2 -0
  507. package/docs/SDK.md +156 -9
  508. package/docs/SDK_CUSTOMIZATION_PRIMITIVES.md +79 -0
  509. package/marketplace.json +2 -2
  510. package/package.json +3 -2
  511. package/packages/pm-beads/package.json +1 -1
  512. package/packages/pm-calendar/package.json +1 -1
  513. package/packages/pm-command-kit/package.json +1 -1
  514. package/packages/pm-governance-audit/extensions/governance-audit/runtime-utils.ts +76 -16
  515. package/packages/pm-governance-audit/extensions/governance-audit/sdk.ts +8 -0
  516. package/packages/pm-governance-audit/package.json +1 -1
  517. package/packages/pm-guide-shell/package.json +1 -1
  518. package/packages/pm-kanban/package.json +1 -1
  519. package/packages/pm-lifecycle-hooks/package.json +1 -1
  520. package/packages/pm-linked-test-adapters/package.json +1 -1
  521. package/packages/pm-search-advanced/package.json +1 -1
  522. package/packages/pm-templates/package.json +1 -1
  523. package/packages/pm-todos/package.json +1 -1
  524. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  525. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  526. package/scripts/bundle-cli.mjs +66 -23
  527. package/dist/cli/commands/extension/bundled-catalog.js.map +0 -1
  528. package/dist/cli/commands/extension/doctor.js.map +0 -1
  529. package/dist/cli/commands/extension/install-sources.js.map +0 -1
  530. package/dist/cli/commands/extension/managed-state.js.map +0 -1
  531. package/dist/cli/commands/templates.js.map +0 -1
  532. package/dist/cli/commands/test/linked-command-detection.js +0 -248
  533. package/dist/cli/commands/test/linked-command-detection.js.map +0 -1
  534. package/dist/cli-bundle/chunks/append-DYQWQK2J.js +0 -11
  535. package/dist/cli-bundle/chunks/chunk-2GA3NK35.js +0 -530
  536. package/dist/cli-bundle/chunks/chunk-2GA3NK35.js.map +0 -1
  537. package/dist/cli-bundle/chunks/chunk-2QIQGYPW.js.map +0 -7
  538. package/dist/cli-bundle/chunks/chunk-4DY4KPQI.js.map +0 -7
  539. package/dist/cli-bundle/chunks/chunk-4WREH7RT.js +0 -554
  540. package/dist/cli-bundle/chunks/chunk-4WREH7RT.js.map +0 -7
  541. package/dist/cli-bundle/chunks/chunk-5CT5BW6E.js.map +0 -7
  542. package/dist/cli-bundle/chunks/chunk-5URI7TPJ.js.map +0 -7
  543. package/dist/cli-bundle/chunks/chunk-6MHSBDGD.js.map +0 -7
  544. package/dist/cli-bundle/chunks/chunk-6OTZMORS.js.map +0 -7
  545. package/dist/cli-bundle/chunks/chunk-6PKA3SJQ.js.map +0 -1
  546. package/dist/cli-bundle/chunks/chunk-6TTOHMTB.js.map +0 -1
  547. package/dist/cli-bundle/chunks/chunk-7QDSYUMF.js.map +0 -1
  548. package/dist/cli-bundle/chunks/chunk-7TQMR6LK.js.map +0 -7
  549. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js +0 -312
  550. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js.map +0 -7
  551. package/dist/cli-bundle/chunks/chunk-BPD26E3P.js.map +0 -1
  552. package/dist/cli-bundle/chunks/chunk-CDJYP7OQ.js.map +0 -1
  553. package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js +0 -858
  554. package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js.map +0 -1
  555. package/dist/cli-bundle/chunks/chunk-DVOLZJ3C.js.map +0 -1
  556. package/dist/cli-bundle/chunks/chunk-DYEX6NFH.js.map +0 -7
  557. package/dist/cli-bundle/chunks/chunk-F7PSHRNO.js.map +0 -1
  558. package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js +0 -875
  559. package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js.map +0 -7
  560. package/dist/cli-bundle/chunks/chunk-FTQLW4JD.js.map +0 -1
  561. package/dist/cli-bundle/chunks/chunk-IA3YFTXT.js.map +0 -1
  562. package/dist/cli-bundle/chunks/chunk-IGED7NH2.js.map +0 -7
  563. package/dist/cli-bundle/chunks/chunk-J4NZOP3I.js.map +0 -1
  564. package/dist/cli-bundle/chunks/chunk-JL7WZ4O2.js.map +0 -7
  565. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js +0 -309
  566. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js.map +0 -1
  567. package/dist/cli-bundle/chunks/chunk-LWTIRS3Y.js.map +0 -7
  568. package/dist/cli-bundle/chunks/chunk-MKL4CP2I.js.map +0 -1
  569. package/dist/cli-bundle/chunks/chunk-N3CMP4NI.js.map +0 -1
  570. package/dist/cli-bundle/chunks/chunk-PHKP3AGR.js.map +0 -7
  571. package/dist/cli-bundle/chunks/chunk-Q37E63AM.js.map +0 -7
  572. package/dist/cli-bundle/chunks/chunk-QASRVKUQ.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-RGXD5JJR.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-UB2QYSTO.js.map +0 -1
  575. package/dist/cli-bundle/chunks/chunk-UGTVWL3E.js.map +0 -1
  576. package/dist/cli-bundle/chunks/chunk-ZAYYDNB3.js.map +0 -1
  577. package/dist/cli-bundle/chunks/chunk-ZUKSZVBW.js.map +0 -7
  578. package/dist/cli-bundle/chunks/close-RI4JQQHU.js +0 -12
  579. package/dist/cli-bundle/chunks/close-many-LY2XJ52M.js +0 -21
  580. package/dist/cli-bundle/chunks/comments-35M273DN.js +0 -13
  581. package/dist/cli-bundle/chunks/copy-NPYM7M7U.js +0 -9
  582. package/dist/cli-bundle/chunks/delete-ODRWJWAM.js +0 -10
  583. package/dist/cli-bundle/chunks/docs-G7N4E2JO.js +0 -14
  584. package/dist/cli-bundle/chunks/focus-U5TRVCRS.js +0 -10
  585. package/dist/cli-bundle/chunks/history-compact-M7GHYVFN.js +0 -20
  586. package/dist/cli-bundle/chunks/history-redact-JIHZLHDP.js +0 -16
  587. package/dist/cli-bundle/chunks/history-repair-NAFCHLH7.js +0 -18
  588. package/dist/cli-bundle/chunks/learnings-SONGPSHI.js +0 -13
  589. package/dist/cli-bundle/chunks/notes-BSD53H2W.js +0 -13
  590. package/dist/cli-bundle/chunks/plan-AWLYGBNV.js +0 -24
  591. package/dist/cli-bundle/chunks/register-list-query-BUWCYHBT.js.map +0 -7
  592. package/dist/cli-bundle/chunks/register-list-query-KTZ6AGE7.js.map +0 -1
  593. package/dist/cli-bundle/chunks/register-mutation-4FMGJJF7.js.map +0 -1
  594. package/dist/cli-bundle/chunks/restore-66GLMHIX.js +0 -14
  595. package/dist/cli-bundle/chunks/update-2XGHIVQ2.js +0 -21
  596. package/dist/cli-bundle/chunks/update-many-75K57FS3.js +0 -34
  597. package/dist/cli-bundle/chunks/update-many-U42YA445.js +0 -30
  598. /package/dist/cli-bundle/chunks/{append-PVZJDM6J.js.map → append-OJQFUQ4T.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{append-DYQWQK2J.js.map → append-UZVHUO74.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js.map → chunk-2IFFUZLC.js.map} +0 -0
  601. /package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js.map → chunk-2JKGO6QX.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js.map → chunk-2NCIPMQP.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js.map → chunk-2VPAVL7O.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js.map → chunk-2WSE6PO2.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js.map → chunk-34L5OT3Y.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js.map → chunk-3AUGG2DP.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js.map → chunk-3CLU2XZO.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js.map → chunk-3WM75PWC.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js.map → chunk-5JLUII3O.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js.map → chunk-6N2VXVTQ.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js.map → chunk-6S3YSUYG.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js.map → chunk-AHVTB5I5.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js.map → chunk-APRVSW2O.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js.map → chunk-B7PE22W6.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js.map → chunk-BCOFWYW4.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js.map → chunk-BEP7WJA2.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js.map → chunk-CRVF2JDM.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js.map → chunk-DM4H7FP4.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{close-LZECOMHO.js.map → chunk-DUT67M43.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{chunk-44LNIULG.js.map → chunk-DYH63FX7.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js.map → chunk-EAB64KLB.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js.map → chunk-EACOH7AU.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js.map → chunk-EJEXHTY5.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js.map → chunk-EYLCSJAI.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{chunk-655STMGA.js.map → chunk-FMBNM2EN.js.map} +0 -0
  626. /package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js.map → chunk-FNSPG7MU.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{chunk-KB726FMH.js.map → chunk-H2Z3FYXQ.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js.map → chunk-IA5FKNII.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js.map → chunk-IJIICKVW.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js.map → chunk-JOUQZENX.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js.map → chunk-JYFOV7FC.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js.map → chunk-K2X6U4UA.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js.map → chunk-KG44YSKD.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js.map → chunk-KPMKHGEA.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js.map → chunk-MIQDDLB5.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js.map → chunk-NLDFBC6J.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js.map → chunk-NP22ERDF.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js.map → chunk-NU3IMIEA.js.map} +0 -0
  639. /package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js.map → chunk-NVPZIJVR.js.map} +0 -0
  640. /package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js.map → chunk-ODALILG3.js.map} +0 -0
  641. /package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js.map → chunk-ONREO4ST.js.map} +0 -0
  642. /package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js.map → chunk-P74IZQ7A.js.map} +0 -0
  643. /package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js.map → chunk-PGY23YTC.js.map} +0 -0
  644. /package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js.map → chunk-PMOSXADO.js.map} +0 -0
  645. /package/dist/cli-bundle/chunks/{close-RI4JQQHU.js.map → chunk-PNTULOGU.js.map} +0 -0
  646. /package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js.map → chunk-Q7A43DS4.js.map} +0 -0
  647. /package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js.map → chunk-QEHQ2GVG.js.map} +0 -0
  648. /package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js.map → chunk-QIPLHNP7.js.map} +0 -0
  649. /package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js.map → chunk-QKJGPFAF.js.map} +0 -0
  650. /package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js.map → chunk-RLCHOOHC.js.map} +0 -0
  651. /package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js.map → chunk-RMLWNPH2.js.map} +0 -0
  652. /package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js.map → chunk-RRM5JYJC.js.map} +0 -0
  653. /package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js.map → chunk-S6MQESFR.js.map} +0 -0
  654. /package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js.map → chunk-SDQLJWBO.js.map} +0 -0
  655. /package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js.map → chunk-SELVXEZK.js.map} +0 -0
  656. /package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js.map → chunk-TKOVBP6C.js.map} +0 -0
  657. /package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js.map → chunk-TQSZFPIS.js.map} +0 -0
  658. /package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js.map → chunk-TSMHDIW4.js.map} +0 -0
  659. /package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js.map → chunk-UFXU44HV.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js.map → chunk-ULTHRDBP.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js.map → chunk-UOHFKBUV.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js.map → chunk-UY2ACEMF.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js.map → chunk-WUJQK4YV.js.map} +0 -0
  664. /package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js.map → chunk-XSJUSQAE.js.map} +0 -0
  665. /package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js.map → chunk-YAQEBNY7.js.map} +0 -0
  666. /package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js.map → chunk-YBLZ2VE7.js.map} +0 -0
  667. /package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js.map → chunk-YCQET3OT.js.map} +0 -0
  668. /package/dist/cli-bundle/chunks/{close-many-LY2XJ52M.js.map → chunk-YUSOJDWM.js.map} +0 -0
  669. /package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js.map → chunk-ZI6VQWQ7.js.map} +0 -0
  670. /package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js.map → close-CWODTPKG.js.map} +0 -0
  671. /package/dist/cli-bundle/chunks/{comments-35M273DN.js.map → close-W6LI2PKM.js.map} +0 -0
  672. /package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js.map → close-many-CQFUY7MR.js.map} +0 -0
  673. /package/dist/cli-bundle/chunks/{copy-NPYM7M7U.js.map → close-many-DLDDVSH5.js.map} +0 -0
  674. /package/dist/cli-bundle/chunks/{create-F53OBTOU.js.map → comments-E3TNTK24.js.map} +0 -0
  675. /package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js.map → comments-WGLHR7LB.js.map} +0 -0
  676. /package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js.map → copy-LXVDXH7B.js.map} +0 -0
  677. /package/dist/cli-bundle/chunks/{delete-ODRWJWAM.js.map → copy-Q5ZJPUKR.js.map} +0 -0
  678. /package/dist/cli-bundle/chunks/{deps-U57I7EAK.js.map → create-J5U6ND4K.js.map} +0 -0
  679. /package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js.map → create-LBVCYMEG.js.map} +0 -0
  680. /package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js.map → delete-PMJBNY5G.js.map} +0 -0
  681. /package/dist/cli-bundle/chunks/{docs-G7N4E2JO.js.map → delete-WNHB3LYW.js.map} +0 -0
  682. /package/dist/cli-bundle/chunks/{files-TTY6N2AV.js.map → deps-JZ7TMVCB.js.map} +0 -0
  683. /package/dist/cli-bundle/chunks/{files-TBZD7V6H.js.map → deps-OA26IS25.js.map} +0 -0
  684. /package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js.map → docs-FEWB2DQB.js.map} +0 -0
  685. /package/dist/cli-bundle/chunks/{focus-U5TRVCRS.js.map → docs-HA2AIDBB.js.map} +0 -0
  686. /package/dist/cli-bundle/chunks/{history-compact-M7GHYVFN.js.map → files-6YFBJRBG.js.map} +0 -0
  687. /package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js.map → files-EFIWKFTM.js.map} +0 -0
  688. /package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js.map → focus-4QJR7FOQ.js.map} +0 -0
  689. /package/dist/cli-bundle/chunks/{history-redact-JIHZLHDP.js.map → focus-POIW5LTJ.js.map} +0 -0
  690. /package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js.map → history-compact-CKRPDTJN.js.map} +0 -0
  691. /package/dist/cli-bundle/chunks/{history-repair-NAFCHLH7.js.map → history-compact-FWG2C7FZ.js.map} +0 -0
  692. /package/dist/cli-bundle/chunks/{learnings-SONGPSHI.js.map → history-redact-BB3TGDAE.js.map} +0 -0
  693. /package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js.map → history-redact-D225BHOZ.js.map} +0 -0
  694. /package/dist/cli-bundle/chunks/{notes-BSD53H2W.js.map → history-repair-6GEAM7HE.js.map} +0 -0
  695. /package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js.map → history-repair-RQXKQHL4.js.map} +0 -0
  696. /package/dist/cli-bundle/chunks/{plan-2NNEO46V.js.map → learnings-JLNLCOL5.js.map} +0 -0
  697. /package/dist/cli-bundle/chunks/{plan-AWLYGBNV.js.map → learnings-RSNLSWDC.js.map} +0 -0
  698. /package/dist/cli-bundle/chunks/{profile-U725ATWZ.js.map → notes-2WDH6DXU.js.map} +0 -0
  699. /package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js.map → notes-GB47XXQQ.js.map} +0 -0
  700. /package/dist/cli-bundle/chunks/{restore-66GLMHIX.js.map → plan-DOVI2VMW.js.map} +0 -0
  701. /package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js.map → plan-VDCJ2PCN.js.map} +0 -0
  702. /package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js.map → profile-FAU7NZML.js.map} +0 -0
  703. /package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js.map → profile-IVXQEL3D.js.map} +0 -0
  704. /package/dist/cli-bundle/chunks/{update-Q3UCILNR.js.map → restore-25DLT2Q2.js.map} +0 -0
  705. /package/dist/cli-bundle/chunks/{update-2XGHIVQ2.js.map → restore-YPMVUUEX.js.map} +0 -0
  706. /package/dist/cli-bundle/chunks/{update-many-75K57FS3.js.map → schema-FNU3WE4O.js.map} +0 -0
  707. /package/dist/cli-bundle/chunks/{update-many-U42YA445.js.map → schema-NBCM3RAD.js.map} +0 -0
  708. /package/dist/{cli/commands → sdk}/extension/managed-state.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../core/history/replay.ts","../../../../../../../../core/history/projection.ts","../../../../../../../../core/history/read.ts","../../../../../../../../sdk/history-redact.ts","../../../../../../../../core/history/history-rewrite.ts"],"sourcesContent":["/**\n * @module core/history/replay\n *\n * Implements append-only history and replay behavior for Replay.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { ITEM_METADATA_KEY_ORDER } from \"../shared/constants.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport {\n orderObject,\n sha256Hex,\n stableStringify,\n} from \"../shared/serialization.js\";\nimport { hashDocument } from \"./history.js\";\nimport type {\n HistoryEntry,\n HistoryPatchOp,\n ItemDocument,\n ItemMetadata,\n} from \"../../types/index.js\";\n\n/**\n * Shared history replay/patch mechanics single-sourced for the history, restore,\n * history-redact, and history-repair commands plus the health/validate drift checks.\n *\n * Each command keeps its own thin error-formatting wrapper so the exact CLI error\n * contracts (restore's rich patch-failure context, redact's op tag, history's\n * generic message) are preserved; only the underlying replay/patch logic is shared.\n */\n\nexport interface ReplayDocument {\n /** Value that configures or reports metadata for this contract. */\n metadata: Record<string, unknown>;\n /** Value that configures or reports body for this contract. */\n body: string;\n}\n\n/** Public contract for empty replay document, shared by SDK and presentation-layer consumers. */\nexport const EMPTY_REPLAY_DOCUMENT: ReplayDocument = {\n metadata: {},\n body: \"\",\n};\n\n/** Implements clone empty replay document for the public runtime surface of this module. */\nexport function cloneEmptyReplayDocument(): ReplayDocument {\n return structuredClone(EMPTY_REPLAY_DOCUMENT);\n}\n\n/** Implements replay hash for the public runtime surface of this module. */\nexport function replayHash(document: ReplayDocument): string {\n try {\n return hashDocument(replayToItemDocument(document));\n } catch {\n // Legacy/malformed replay states (for example a stream whose first entry never\n // established a full `create` document, so the canonicalizer cannot normalize it)\n // cannot be canonically hashed. Fall back to a deterministic structural hash so\n // re-anchor and verification stay internally consistent for these streams. Fully\n // formed documents always take the canonical path above, so valid streams are\n // unaffected.\n return sha256Hex(\n stableStringify({\n replay_fallback: true,\n metadata: document.metadata,\n body: document.body,\n }),\n );\n }\n}\n\n/** Implements replay to item document for the public runtime surface of this module. */\nexport function replayToItemDocument(document: ReplayDocument): ItemDocument {\n return {\n metadata: document.metadata as ItemMetadata,\n body: document.body,\n };\n}\n\n/** Converts a materialized replay document into a canonical item document. Use this when callers have already rejected the empty/deleted replay state and need restored metadata validated through the normal item-metadata rules. */\nexport function replayToCanonicalItemDocument(\n document: ReplayDocument,\n options: Parameters<typeof canonicalDocument>[1] = {},\n): ItemDocument {\n return canonicalDocument(replayToItemDocument(document), options);\n}\n\n/** Canonicalize an item document into the ordered replay form used when comparing a replayed chain against the on-disk item (restore + history-repair reconciliation). */\nexport function toReplayDocument(document: ItemDocument): ReplayDocument {\n if (!document.metadata || Object.keys(document.metadata).length === 0) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n return {\n metadata: orderObject(\n toItemRecord(canonical.metadata),\n ITEM_METADATA_KEY_ORDER,\n ),\n body: canonical.body,\n };\n}\n\n/** Implements normalize replay patch path for the public runtime surface of this module. */\nexport function normalizeReplayPatchPath(path: string): string {\n if (path === \"/front_matter\") {\n return \"/metadata\";\n }\n if (path.startsWith(\"/front_matter/\")) {\n return `/metadata/${path.slice(\"/front_matter/\".length)}`;\n }\n return path;\n}\n\nfunction isHistoryPatchOp(value: unknown): value is HistoryPatchOp {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { op?: unknown }).op === \"string\" &&\n typeof (value as { path?: unknown }).path === \"string\"\n );\n}\n\n/** Implements normalize replay patch ops for the public runtime surface of this module. */\nexport function normalizeReplayPatchOps(\n patch: HistoryPatchOp[] | unknown,\n): HistoryPatchOp[] {\n if (!Array.isArray(patch)) {\n return [];\n }\n return patch.filter(isHistoryPatchOp).map((operation) => ({\n ...operation,\n path: normalizeReplayPatchPath(operation.path),\n from:\n typeof operation.from === \"string\"\n ? normalizeReplayPatchPath(operation.from)\n : undefined,\n }));\n}\n\nfunction isReplayDocumentShape(\n value: unknown,\n): value is { metadata: Record<string, unknown>; body: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"metadata\" in value &&\n \"body\" in value &&\n typeof (value as { body: unknown }).body === \"string\" &&\n typeof (value as { metadata: unknown }).metadata === \"object\" &&\n (value as { metadata: unknown }).metadata !== null\n );\n}\n\n/** Restricts replay apply result values accepted by command, SDK, and storage contracts. */\nexport type ReplayApplyResult =\n | { ok: true; document: ReplayDocument }\n | { ok: false; error: unknown };\n\n/** Strictly apply a history patch (front_matter->metadata normalized) to a replay document. Returns a result envelope rather than throwing so each caller can format its own error contract. */\nexport function tryApplyReplayPatch(\n current: ReplayDocument,\n patch: HistoryPatchOp[],\n): ReplayApplyResult {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (!isReplayDocumentShape(applied)) {\n return {\n ok: false,\n error: new Error(\"history_replay_invalid_document_shape\"),\n };\n }\n return {\n ok: true,\n document: { metadata: applied.metadata, body: applied.body },\n };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/** Deterministically verify a history chain: each entry's before_hash must equal the prior replayed after_hash, the patch must strictly apply, and the recorded after_hash must equal the replayed result. */\nexport function verifyHistoryChain(entries: HistoryEntry[]): {\n ok: boolean;\n errors: string[];\n} {\n let replay = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n return {\n ok: false,\n errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],\n };\n }\n const applied = tryApplyReplayPatch(replay, entry.patch);\n if (!applied.ok) {\n return {\n ok: false,\n errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],\n };\n }\n replay = applied.document;\n if (replayHash(replay) !== entry.after_hash) {\n return {\n ok: false,\n errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],\n };\n }\n }\n return { ok: true, errors: [] };\n}\n\n/** Documents the lenient apply result payload exchanged by command, SDK, and package integrations. */\nexport interface LenientApplyResult {\n /** Value that configures or reports document for this contract. */\n document: ReplayDocument;\n /** Value that configures or reports converted replace to add for this contract. */\n convertedReplaceToAdd: number;\n /** Value that configures or reports skipped ops for this contract. */\n skippedOps: number;\n}\n\nfunction tryApplySingleOp(\n document: unknown,\n op: HistoryPatchOp,\n): { ok: true; document: unknown } | { ok: false } {\n try {\n const applied = jsonPatch.applyPatch(\n structuredClone(document),\n [op as jsonPatch.Operation],\n true,\n false,\n ).newDocument as unknown;\n return { ok: true, document: applied };\n } catch {\n return { ok: false };\n }\n}\n\n/** Apply a legacy patch op-by-op, recovering from drift that strict replay rejects: a `replace` whose path no longer exists is retried as `add`, and any op that still cannot apply against the current replay state is skipped. The resulting document is what the repaired entry's recomputed patch should target. */\nexport function lenientApplyReplayPatch(\n current: ReplayDocument,\n patch: HistoryPatchOp[],\n): LenientApplyResult {\n let working: unknown = structuredClone(current);\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (const op of normalizeReplayPatchOps(patch)) {\n const direct = tryApplySingleOp(working, op);\n if (direct.ok) {\n working = direct.document;\n continue;\n }\n if (op.op === \"replace\") {\n const asAdd = tryApplySingleOp(working, { ...op, op: \"add\" });\n if (asAdd.ok) {\n working = asAdd.document;\n convertedReplaceToAdd += 1;\n continue;\n }\n }\n skippedOps += 1;\n }\n\n const candidate = working as { metadata?: unknown; body?: unknown };\n const document: ReplayDocument = {\n metadata:\n typeof candidate.metadata === \"object\" && candidate.metadata !== null\n ? (candidate.metadata as Record<string, unknown>)\n : {},\n body: typeof candidate.body === \"string\" ? candidate.body : current.body,\n };\n return { document, convertedReplaceToAdd, skippedOps };\n}\n\n/** Documents the reanchor entry detail payload exchanged by command, SDK, and package integrations. */\nexport interface ReanchorEntryDetail {\n /** Value that configures or reports index for this contract. */\n index: number;\n /** Value that configures or reports rehashed for this contract. */\n rehashed: boolean;\n /** Value that configures or reports patch repaired for this contract. */\n patch_repaired: boolean;\n /** Value that configures or reports converted replace to add for this contract. */\n converted_replace_to_add: number;\n /** Value that configures or reports skipped ops for this contract. */\n skipped_ops: number;\n}\n\n/** Documents the reanchor result payload exchanged by command, SDK, and package integrations. */\nexport interface ReanchorResult {\n /** Value that configures or reports entries for this contract. */\n entries: HistoryEntry[];\n /** Value that configures or reports final document for this contract. */\n finalDocument: ReplayDocument;\n /** Value that configures or reports entries rehashed for this contract. */\n entriesRehashed: number;\n /** Value that configures or reports entries patch repaired for this contract. */\n entriesPatchRepaired: number;\n /** Value that configures or reports converted replace to add for this contract. */\n convertedReplaceToAdd: number;\n /** Value that configures or reports skipped ops for this contract. */\n skippedOps: number;\n /** Value that configures or reports details for this contract. */\n details: ReanchorEntryDetail[];\n}\n\n/** Re-anchor a drifted history chain: replay every entry from empty, recompute the before/after hashes, and only rewrite a patch when the original op set no longer strictly applies (legacy drift). Clean entries keep their patch verbatim so the on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain. */\nexport function reanchorHistoryEntries(\n entries: HistoryEntry[],\n): ReanchorResult {\n let replay = cloneEmptyReplayDocument();\n const rewritten: HistoryEntry[] = [];\n const details: ReanchorEntryDetail[] = [];\n let entriesRehashed = 0;\n let entriesPatchRepaired = 0;\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n const beforeHash = replayHash(replay);\n const strict = tryApplyReplayPatch(replay, entry.patch);\n\n let next: ReplayDocument;\n let outPatch: HistoryPatchOp[];\n let patchRepaired = false;\n let entryConverted = 0;\n let entrySkipped = 0;\n\n if (strict.ok) {\n next = strict.document;\n outPatch = entry.patch;\n } else {\n const lenient = lenientApplyReplayPatch(replay, entry.patch);\n next = lenient.document;\n outPatch = jsonPatch.compare(replay, next) as HistoryPatchOp[];\n patchRepaired = true;\n entryConverted = lenient.convertedReplaceToAdd;\n entrySkipped = lenient.skippedOps;\n convertedReplaceToAdd += entryConverted;\n skippedOps += entrySkipped;\n entriesPatchRepaired += 1;\n }\n\n const afterHash = replayHash(next);\n const rehashed =\n beforeHash !== entry.before_hash || afterHash !== entry.after_hash;\n if (rehashed) {\n entriesRehashed += 1;\n }\n\n rewritten.push({\n ...entry,\n patch: outPatch,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n details.push({\n index: index + 1,\n rehashed,\n patch_repaired: patchRepaired,\n converted_replace_to_add: entryConverted,\n skipped_ops: entrySkipped,\n });\n replay = next;\n }\n\n return {\n entries: rewritten,\n finalDocument: replay,\n entriesRehashed,\n entriesPatchRepaired,\n convertedReplaceToAdd,\n skippedOps,\n details,\n };\n}\n\n/** Implements history entries to raw for the public runtime surface of this module. */\nexport function historyEntriesToRaw(entries: HistoryEntry[]): string {\n if (entries.length === 0) {\n return \"\";\n }\n return `${entries.map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`;\n}\n","/**\n * @module core/history/projection\n *\n * Reconstructs verified point-in-time item states from hash-chained history.\n * Restore, SDK reads, and future VCS-style integrations share this single\n * replay kernel so read and write paths cannot disagree about a version.\n */\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport type { HistoryEntry, HistoryPatchOp } from \"../../types/index.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n replayHash,\n tryApplyReplayPatch,\n type ReplayDocument,\n} from \"./replay.js\";\n\n/** Describes the normalized version or timestamp selected from a history stream. */\nexport interface ResolvedHistoryTarget {\n /** Target syntax selected by the caller. */\n kind: \"version\" | \"timestamp\";\n /** Original normalized target text. */\n raw: string;\n /** Zero-based history entry selected for reconstruction. */\n historyIndex: number;\n}\n\n/** Controls caller-specific target diagnostics and future timestamp policy. */\nexport interface ResolveHistoryTargetOptions {\n /** Command concept named in agent-facing validation errors. */\n errorSubject?: \"history\" | \"restore\";\n /** Allow a timestamp after the final entry to select that final entry. */\n allowFutureTimestamp?: boolean;\n}\n\ninterface PatchFailureContext {\n patchIndex?: number;\n op?: string;\n path?: string;\n from?: string;\n reason?: string;\n}\n\n/** Find the final history entry recorded at or before a parsed timestamp. */\nfunction findHistoryIndexAtTimestamp(\n history: readonly HistoryEntry[],\n parsedTarget: number,\n): number {\n let historyIndex = -1;\n history.forEach((entry, index) => {\n const entryTimestamp = Date.parse(entry.ts);\n if (!Number.isFinite(entryTimestamp)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${index + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTimestamp <= parsedTarget) {\n historyIndex = index;\n }\n });\n return historyIndex;\n}\n\n/** Build structured target-range guidance once for every resolver error path. */\nfunction buildHistoryTargetGuidance(history: readonly HistoryEntry[]) {\n const firstTimestamp = history[0]?.ts ?? null;\n const lastTimestamp = history.at(-1)?.ts ?? null;\n const guidance = {\n code: \"history_target_out_of_range\",\n required: \"Choose a target within the available item history.\",\n why: \"Point-in-time reads and restores can only reconstruct recorded versions.\",\n examples: [] as string[],\n nextSteps: [\n \"Run pm history <id> to inspect available versions and timestamps.\",\n ],\n valid_range: {\n first_version: null as number | null,\n last_version: null as number | null,\n first_timestamp: firstTimestamp,\n last_timestamp: lastTimestamp,\n },\n };\n if (lastTimestamp !== null) {\n guidance.examples = [\"1\", String(history.length), lastTimestamp];\n guidance.valid_range.first_version = 1;\n guidance.valid_range.last_version = history.length;\n }\n return { guidance, lastTimestamp };\n}\n\n/** Extract best-effort JSON Patch position details for replay diagnostics. */\nexport function extractPatchFailureContext(\n patch: HistoryPatchOp[],\n error: unknown,\n): PatchFailureContext {\n const failure: PatchFailureContext = {};\n if (error instanceof Error && error.message.trim().length > 0) {\n failure.reason = error.message.trim();\n }\n if (typeof error !== \"object\" || error === null) {\n return failure;\n }\n const candidate = error as { index?: unknown; operation?: unknown };\n if (\n typeof candidate.index === \"number\" &&\n Number.isInteger(candidate.index) &&\n candidate.index >= 0\n ) {\n failure.patchIndex = candidate.index;\n }\n if (typeof candidate.operation === \"object\" && candidate.operation !== null) {\n const operation = candidate.operation as Record<string, unknown>;\n Object.assign(\n failure,\n Object.fromEntries(\n ([\"op\", \"path\", \"from\"] as const).flatMap((field) => {\n const value = operation[field];\n return typeof value === \"string\" ? [[field, value]] : [];\n }),\n ),\n );\n }\n if (failure.patchIndex !== undefined) {\n const fallback = patch[failure.patchIndex];\n if (fallback) {\n failure.op ??= fallback.op;\n failure.path ??= fallback.path;\n failure.from ??= fallback.from;\n }\n }\n return failure;\n}\n\n/**\n * Resolve a one-based version or ISO timestamp into a concrete history entry.\n * Errors include structured valid-range metadata for agent and SDK callers.\n */\nexport function resolveHistoryTarget(\n target: string,\n history: readonly HistoryEntry[],\n options: ResolveHistoryTargetOptions = {},\n): ResolvedHistoryTarget {\n const trimmed = target.trim();\n const errorSubject = options.errorSubject ?? \"history\";\n const errorSubjectTitle = errorSubject === \"restore\" ? \"Restore\" : \"History\";\n const { guidance, lastTimestamp } = buildHistoryTargetGuidance(history);\n if (!trimmed) {\n throw new PmCliError(\n `Missing ${errorSubject} target. Use a timestamp or version number.`,\n EXIT_CODE.USAGE,\n guidance,\n );\n }\n if (/^\\d+$/.test(trimmed)) {\n const version = Number(trimmed);\n if (\n !Number.isSafeInteger(version) ||\n version < 1 ||\n version > history.length\n ) {\n throw new PmCliError(\n `${errorSubjectTitle} version must be between 1 and ${history.length} for this item.`,\n EXIT_CODE.USAGE,\n guidance,\n );\n }\n return { kind: \"version\", raw: trimmed, historyIndex: version - 1 };\n }\n const parsedTarget = Date.parse(trimmed);\n if (!Number.isFinite(parsedTarget)) {\n throw new PmCliError(\n `Invalid ${errorSubject} target \"${target}\". Use a positive version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n guidance,\n );\n }\n const historyIndex = findHistoryIndexAtTimestamp(history, parsedTarget);\n if (\n historyIndex < 0 ||\n (options.allowFutureTimestamp !== true &&\n parsedTarget > Date.parse(lastTimestamp as string))\n ) {\n throw new PmCliError(\n errorSubject === \"restore\"\n ? `No history entries exist at or before timestamp ${trimmed}.`\n : `No history entry exists at timestamp ${trimmed}.`,\n EXIT_CODE.USAGE,\n guidance,\n );\n }\n return { kind: \"timestamp\", raw: trimmed, historyIndex };\n}\n\n/** Apply one normalized JSON Patch entry and retain actionable failure context. */\nexport function applyHistoryPatch(\n current: ReplayDocument,\n patch: HistoryPatchOp[],\n entryNumber: number,\n entryOp: string,\n): ReplayDocument {\n const applied = tryApplyReplayPatch(current, patch);\n if (applied.ok) {\n return applied.document;\n }\n const failure = extractPatchFailureContext(patch, applied.error);\n const tokens = [\n `history_op=${entryOp}`,\n failure.patchIndex === undefined\n ? null\n : `patch_index=${failure.patchIndex}`,\n failure.op ? `op=${failure.op}` : null,\n failure.path ? `path=${failure.path}` : null,\n failure.from ? `from=${failure.from}` : null,\n ].filter((token): token is string => token !== null);\n throw new PmCliError(\n `Failed to apply history patch at entry ${entryNumber} (${tokens.join(\", \")}). ${failure.reason ?? String(applied.error)}`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n}\n\n/** Replay and hash-verify a history stream through a zero-based target entry. */\nexport function replayHistoryToTarget(\n history: readonly HistoryEntry[],\n targetIndex: number,\n): ReplayDocument {\n let document: ReplayDocument = structuredClone(EMPTY_REPLAY_DOCUMENT);\n for (let index = 0; index <= targetIndex; index += 1) {\n const entry = history[index];\n if (!entry) {\n throw new PmCliError(\n `History target entry ${index + 1} does not exist.`,\n EXIT_CODE.USAGE,\n );\n }\n if (replayHash(document) !== entry.before_hash) {\n throw new PmCliError(\n `History hash mismatch before replay at entry ${index + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n document = applyHistoryPatch(document, entry.patch, index + 1, entry.op);\n if (replayHash(document) !== entry.after_hash) {\n throw new PmCliError(\n `History hash mismatch after replay at entry ${index + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n return document;\n}\n\n/** Reject a version whose reconstructed state represents a deleted item. */\nexport function ensureMaterializedHistoryTarget(\n replayDocument: ReplayDocument,\n target: ResolvedHistoryTarget,\n): ReplayDocument {\n if (Object.keys(replayDocument.metadata).length > 0) {\n return replayDocument;\n }\n throw new PmCliError(\n `History target ${target.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,\n EXIT_CODE.USAGE,\n );\n}\n","/**\n * @module core/history/read\n *\n * Reads append-only item history streams with conflict-marker detection,\n * extension read hooks, and line-specific JSONL diagnostics. Keeping this\n * storage primitive below both the CLI and SDK prevents public history\n * maintenance APIs from depending on presentation-layer modules.\n */\nimport { readFileIfExists } from \"../fs/fs-utils.js\";\nimport { runActiveOnReadHooks } from \"../extensions/index.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { findFirstMergeConflictMarker } from \"../shared/conflict-markers.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\n\n/** Read and validate one item's JSONL history stream without mutating it. */\nexport async function readHistoryEntries(\n historyPath: string,\n itemId: string,\n): Promise<HistoryEntry[]> {\n const raw = await readFileIfExists(historyPath);\n if (raw === null) {\n return [];\n }\n await runActiveOnReadHooks({ path: historyPath, scope: \"project\" });\n if (raw.trim() === \"\") {\n return [];\n }\n const conflictMarker = findFirstMergeConflictMarker(raw);\n if (conflictMarker) {\n throw new PmCliError(\n `History for ${itemId} contains merge conflict markers at line ${conflictMarker.line} (${conflictMarker.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,\n EXIT_CODE.GENERIC_FAILURE,\n {\n code: \"history_merge_conflict_markers_detected\",\n required: \"Repair the history stream by resolving merge-conflict markers.\",\n why: \"Conflict markers break JSONL parsing and invalidate deterministic audit history.\",\n examples: [\n `pm history ${itemId}`,\n `pm restore ${itemId} <timestamp-or-version>`,\n ],\n nextSteps: [\"Resolve or restore the history file, then rerun the command.\"],\n },\n );\n }\n\n const entries: HistoryEntry[] = [];\n for (const [index, rawLine] of raw.split(/\\r?\\n/).entries()) {\n const line = rawLine.trim();\n if (!line) {\n continue;\n }\n try {\n entries.push(JSON.parse(line) as HistoryEntry);\n } catch {\n throw new PmCliError(\n `History for ${itemId} contains invalid JSON at line ${index + 1}. Repair or restore the history stream and retry.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n return entries;\n}\n","/**\n * @module sdk/history-redact\n *\n * Implements the pm history redact command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport {\n pathExists,\n readFileIfExists,\n writeFileAtomic,\n} from \"../core/fs/fs-utils.js\";\nimport { createHistoryEntry } from \"../core/history/history.js\";\nimport { executeHistoryRewrite } from \"../core/history/history-rewrite.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../core/history/replay.js\";\nimport { applyHistoryPatch } from \"../core/history/projection.js\";\nimport { readHistoryEntries } from \"../core/history/read.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../core/item/id.js\";\nimport {\n canonicalDocument,\n serializeItemDocument,\n} from \"../core/item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../core/shared/command-types.js\";\nimport { PmCliError } from \"../core/shared/errors.js\";\nimport { nowIso } from \"../core/shared/time.js\";\nimport {\n getActiveExtensionRegistrations,\n runActiveOnWriteHooks,\n} from \"../core/extensions/index.js\";\nimport { locateItem, readLocatedItem } from \"../core/store/item-store.js\";\nimport {\n getHistoryPath,\n getItemPath,\n getSettingsPath,\n resolvePmRoot,\n} from \"../core/store/paths.js\";\nimport { readSettings } from \"../core/store/settings.js\";\nimport { resolveAuthor } from \"../core/shared/author.js\";\nimport type { HistoryEntry, ItemDocument } from \"../types/index.js\";\n\n/** Documents the history redact command options payload exchanged by command, SDK, and package integrations. */\nexport interface HistoryRedactCommandOptions {\n /** Value that configures or reports literal for this contract. */\n literal?: string[] | string;\n /** Value that configures or reports regex for this contract. */\n regex?: string[] | string;\n /** Value that configures or reports replacement for this contract. */\n replacement?: string;\n /** Value that configures or reports dry run for this contract. */\n dryRun?: boolean;\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Human-readable explanation suitable for logs and agent-facing output. */\n message?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\ninterface RegexRule {\n kind: \"regex\";\n source: string;\n flags: string;\n label: string;\n}\n\ninterface LiteralRule {\n kind: \"literal\";\n value: string;\n label: string;\n}\n\ntype RedactionRule = RegexRule | LiteralRule;\n\ninterface RedactionRewriteResult {\n entries: HistoryEntry[];\n finalDocument: ReplayDocument;\n entriesChanged: number;\n replacements: number;\n}\n\ninterface HistoryIntegritySnapshot {\n hashMismatchesBefore: number;\n hashMismatchesAfter: number;\n finalDocument: ReplayDocument;\n}\n\ninterface HistoryRedactCurrentItem {\n raw: string | null;\n path: string | null;\n document: ItemDocument | null;\n}\n\ninterface HistoryRedactNextItem {\n raw: string | null;\n path: string | null;\n document: ItemDocument | null;\n}\n\n/** Documents the history subject payload exchanged by command, SDK, and package integrations. */\nexport interface HistorySubject {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Filesystem path used for history resolution. */\n historyPath: string;\n /** Value that configures or reports located for this contract. */\n located: Awaited<ReturnType<typeof locateItem>>;\n}\n\n/** Documents the history redact result payload exchanged by command, SDK, and package integrations. */\nexport interface HistoryRedactResult {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports dry run for this contract. */\n dry_run: boolean;\n /** Value that configures or reports changed for this contract. */\n changed: boolean;\n /** Value that configures or reports patterns for this contract. */\n patterns: {\n literals: string[];\n regex: string[];\n replacement: string;\n };\n /** Value that configures or reports history for this contract. */\n history: {\n path: string;\n entries_scanned: number;\n entries_changed: number;\n replacements: number;\n hash_mismatches_before: number;\n hash_mismatches_after: number;\n preexisting_hash_mismatches: number;\n audit_entry_added: boolean;\n verify_ok: boolean;\n verify_errors: string[];\n };\n /** Value that configures or reports item for this contract. */\n item: {\n existed_before: boolean;\n exists_after: boolean;\n path_before: string | null;\n path_after: string | null;\n changed: boolean;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\nfunction normalizeStringArrayInput(\n value: string[] | string | undefined,\n): string[] {\n if (Array.isArray(value)) {\n return value;\n }\n if (typeof value === \"string\") {\n return [value];\n }\n return [];\n}\n\nfunction normalizeRegexFlags(flags: string): string {\n const unique: string[] = [];\n for (const token of flags) {\n if (!unique.includes(token)) {\n unique.push(token);\n }\n }\n if (!unique.includes(\"g\")) {\n unique.push(\"g\");\n }\n return unique.join(\"\");\n}\n\nfunction parseRegexRule(spec: string): RegexRule {\n const trimmed = spec.trim();\n if (trimmed.length === 0) {\n throw new PmCliError(\n \"history-redact --regex requires a non-empty pattern.\",\n EXIT_CODE.USAGE,\n );\n }\n\n let source = trimmed;\n let flags = \"g\";\n if (trimmed.startsWith(\"/\") && trimmed.length > 1) {\n /* c8 ignore start -- bare-slash regex literals are rejected earlier in argument validation. */\n const slashIndex = trimmed.lastIndexOf(\"/\");\n if (slashIndex > 0) {\n source = trimmed.slice(1, slashIndex);\n flags = normalizeRegexFlags(trimmed.slice(slashIndex + 1));\n }\n /* c8 ignore stop */\n }\n if (source.length === 0) {\n throw new PmCliError(\n \"history-redact --regex cannot use an empty pattern.\",\n EXIT_CODE.USAGE,\n );\n }\n try {\n new RegExp(source, flags);\n } catch (error) {\n /* c8 ignore start -- RegExp constructor failures are normalized in higher-level parser tests. */\n throw new PmCliError(\n `Invalid --regex value \"${spec}\": ${error instanceof Error ? error.message : String(error)}`,\n EXIT_CODE.USAGE,\n );\n /* c8 ignore stop */\n }\n\n return {\n kind: \"regex\",\n source,\n flags,\n label: `/${source}/${flags}`,\n };\n}\n\nfunction buildRedactionRules(\n literalInput: string[] | string | undefined,\n regexInput: string[] | string | undefined,\n): RedactionRule[] {\n const literalRules = [\n ...new Set(\n normalizeStringArrayInput(literalInput).map((entry) => entry.trim()),\n ),\n ]\n .filter((entry) => entry.length > 0)\n .map<LiteralRule>((entry) => ({\n kind: \"literal\",\n value: entry,\n label: entry,\n }));\n const regexRules = [\n ...new Set(\n normalizeStringArrayInput(regexInput).map((entry) => entry.trim()),\n ),\n ]\n .filter((entry) => entry.length > 0)\n .map(parseRegexRule);\n\n const rules = [...literalRules, ...regexRules];\n if (rules.length === 0) {\n throw new PmCliError(\n \"history-redact requires at least one matcher via --literal or --regex.\",\n EXIT_CODE.USAGE,\n {\n code: \"missing_required_argument\",\n required: \"Provide --literal <value> and/or --regex <pattern>.\",\n examples: [\n 'pm history-redact pm-a1b2 --literal \"[redacted_path_prefix]/private\"',\n 'pm history-redact pm-a1b2 --regex \"/192\\\\\\\\.168\\\\\\\\.[0-9.]+/g\" --replacement \"[scrubbed_ip]\"',\n ],\n },\n );\n }\n return rules;\n}\n\nfunction applyLiteralRule(\n value: string,\n literal: string,\n replacement: string,\n): { value: string; replacements: number } {\n if (literal.length === 0) {\n return { value, replacements: 0 };\n }\n let cursor = 0;\n let replacements = 0;\n while (cursor <= value.length) {\n const index = value.indexOf(literal, cursor);\n if (index === -1) {\n break;\n }\n replacements += 1;\n cursor = index + Math.max(1, literal.length);\n }\n if (replacements === 0) {\n return { value, replacements: 0 };\n }\n return {\n value: value.split(literal).join(replacement),\n replacements,\n };\n}\n\nfunction applyRegexRule(\n value: string,\n rule: RegexRule,\n replacement: string,\n): { value: string; replacements: number } {\n const regex = new RegExp(rule.source, rule.flags);\n const matches = [...value.matchAll(regex)];\n if (matches.length === 0) {\n return { value, replacements: 0 };\n }\n return {\n value: value.replace(regex, replacement),\n replacements: matches.length,\n };\n}\n\nfunction redactStringValue(\n value: string,\n rules: RedactionRule[],\n replacement: string,\n): { value: string; replacements: number } {\n let next = value;\n let replacements = 0;\n for (const rule of rules) {\n const result =\n rule.kind === \"literal\"\n ? applyLiteralRule(next, rule.value, replacement)\n : applyRegexRule(next, rule, replacement);\n next = result.value;\n replacements += result.replacements;\n }\n return {\n value: next,\n replacements,\n };\n}\n\nfunction redactUnknownValue(\n value: unknown,\n rules: RedactionRule[],\n replacement: string,\n): { value: unknown; replacements: number } {\n if (typeof value === \"string\") {\n return redactStringValue(value, rules, replacement);\n }\n if (Array.isArray(value)) {\n let replacements = 0;\n const nextValues = value.map((entry) => {\n const redacted = redactUnknownValue(entry, rules, replacement);\n replacements += redacted.replacements;\n return redacted.value;\n });\n return {\n value: nextValues,\n replacements,\n };\n }\n if (typeof value === \"object\" && value !== null) {\n let replacements = 0;\n const nextRecord: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const redacted = redactUnknownValue(entry, rules, replacement);\n replacements += redacted.replacements;\n nextRecord[key] = redacted.value;\n }\n return {\n value: nextRecord,\n replacements,\n };\n }\n return {\n value,\n replacements: 0,\n };\n}\n\nfunction inspectHistoryIntegrity(\n entries: HistoryEntry[],\n): HistoryIntegritySnapshot {\n let replay = structuredClone(EMPTY_REPLAY_DOCUMENT);\n let hashMismatchesBefore = 0;\n let hashMismatchesAfter = 0;\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n hashMismatchesBefore += 1;\n }\n replay = applyHistoryPatch(replay, entry.patch, index + 1, entry.op);\n /* c8 ignore start -- after-hash mismatch branch is exercised in dedicated history integrity tests. */\n if (replayHash(replay) !== entry.after_hash) {\n hashMismatchesAfter += 1;\n }\n /* c8 ignore stop */\n }\n return {\n hashMismatchesBefore,\n hashMismatchesAfter,\n finalDocument: replay,\n };\n}\n\nfunction redactHistoryEntry(\n entry: HistoryEntry,\n rules: RedactionRule[],\n replacement: string,\n): {\n entry: HistoryEntry;\n replacements: number;\n changed: boolean;\n} {\n let replacements = 0;\n let changed = false;\n let nextMessage = entry.message;\n\n if (typeof entry.message === \"string\") {\n const redactedMessage = redactStringValue(\n entry.message,\n rules,\n replacement,\n );\n nextMessage = redactedMessage.value;\n replacements += redactedMessage.replacements;\n if (redactedMessage.replacements > 0) {\n changed = true;\n }\n }\n\n const nextPatch = entry.patch.map((operation) => {\n /* c8 ignore start -- patch operations without `value` are covered in lower-level patch adapters. */\n if (!Object.prototype.hasOwnProperty.call(operation, \"value\")) {\n return operation;\n }\n /* c8 ignore stop */\n const redactedValue = redactUnknownValue(\n operation.value,\n rules,\n replacement,\n );\n replacements += redactedValue.replacements;\n if (redactedValue.replacements > 0) {\n changed = true;\n return {\n ...operation,\n value: redactedValue.value,\n };\n }\n return operation;\n });\n\n return {\n entry: {\n ...entry,\n message: nextMessage,\n patch: nextPatch,\n },\n replacements,\n changed,\n };\n}\n\nfunction rewriteHistoryEntries(\n entries: HistoryEntry[],\n rules: RedactionRule[],\n replacement: string,\n): RedactionRewriteResult {\n let replay = structuredClone(EMPTY_REPLAY_DOCUMENT);\n let entriesChanged = 0;\n let replacements = 0;\n const rewrittenEntries: HistoryEntry[] = [];\n\n for (let index = 0; index < entries.length; index += 1) {\n const redacted = redactHistoryEntry(entries[index], rules, replacement);\n replacements += redacted.replacements;\n if (redacted.changed) {\n entriesChanged += 1;\n }\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(\n replay,\n redacted.entry.patch,\n index + 1,\n redacted.entry.op,\n );\n const afterHash = replayHash(replay);\n rewrittenEntries.push({\n ...redacted.entry,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n }\n\n return {\n entries: rewrittenEntries,\n finalDocument: replay,\n entriesChanged,\n replacements,\n };\n}\n\nfunction hasItemMetadata(replay: ReplayDocument): boolean {\n return Object.keys(replay.metadata).length > 0;\n}\n\nasync function loadHistoryRedactCurrentItem(\n subject: HistorySubject,\n settings: Awaited<ReturnType<typeof readSettings>>,\n): Promise<HistoryRedactCurrentItem> {\n const currentItemPath = subject.located?.itemPath ?? null;\n if (!subject.located) {\n return { raw: null, path: currentItemPath, document: null };\n }\n const loaded = await readLocatedItem(subject.located, {\n schema: settings.schema,\n });\n return { raw: loaded.raw, path: currentItemPath, document: loaded.document };\n}\n\nfunction resolveHistoryRedactNextItem(params: {\n pmRoot: string;\n subject: HistorySubject;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeToFolder: Record<string, string>;\n finalDocument: ReplayDocument;\n}): HistoryRedactNextItem {\n if (!hasItemMetadata(params.finalDocument)) {\n return { raw: null, path: null, document: null };\n }\n const canonical = canonicalDocument(\n replayToItemDocument(params.finalDocument),\n { schema: params.settings.schema },\n );\n if (canonical.metadata.id !== params.subject.id) {\n throw new PmCliError(\n `history-redact would change item id from ${params.subject.id} to ${canonical.metadata.id}; narrow your patterns.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n document: canonical,\n path: getItemPath(\n params.pmRoot,\n canonical.metadata.type,\n params.subject.id,\n \"toon\",\n params.typeToFolder,\n ),\n raw: serializeItemDocument(canonical, {\n format: \"toon\",\n schema: params.settings.schema,\n }),\n };\n}\n\n/* v8 ignore start -- message passthrough/plural formatting is deterministic around covered redaction outcomes */\nfunction buildHistoryRedactMessage(\n options: HistoryRedactCommandOptions,\n rewritten: RedactionRewriteResult,\n): string {\n if (\n typeof options.message === \"string\" &&\n options.message.trim().length > 0\n ) {\n return options.message;\n }\n return `history-redact replaced ${rewritten.replacements} match(es) across ${rewritten.entriesChanged} entr${\n rewritten.entriesChanged === 1 ? \"y\" : \"ies\"\n }.`;\n}\n/* v8 ignore stop */\n\nfunction buildHistoryRedactEntries(params: {\n rewritten: RedactionRewriteResult;\n dryRun: boolean;\n changed: boolean;\n nextItemDocument: ItemDocument | null;\n author: string;\n message: string;\n}): { rewrittenEntries: HistoryEntry[]; auditEntryAdded: boolean } {\n const rewrittenEntries = [...params.rewritten.entries];\n if (params.dryRun || !params.changed) {\n return { rewrittenEntries, auditEntryAdded: false };\n }\n /* c8 ignore next -- fallback replay-to-item conversion runs only when rewritten final metadata is absent. */\n const finalDocument =\n params.nextItemDocument ??\n replayToItemDocument(params.rewritten.finalDocument);\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author: params.author,\n op: \"history_redact\",\n before: finalDocument,\n after: finalDocument,\n message: params.message,\n }),\n );\n return { rewrittenEntries, auditEntryAdded: true };\n}\n\nasync function applyHistoryRedactRewrite(params: {\n pmRoot: string;\n subject: HistorySubject;\n settings: Awaited<ReturnType<typeof readSettings>>;\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>;\n historyRawBeforeLock: string | null;\n currentItem: HistoryRedactCurrentItem;\n nextItem: HistoryRedactNextItem;\n author: string;\n force: boolean | undefined;\n rewrittenEntries: HistoryEntry[];\n}): Promise<string[]> {\n return executeHistoryRewrite({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItem.raw,\n operation: \"history-redact\",\n author: params.author,\n force: params.force,\n itemDocument: params.currentItem.document,\n applyRewrite: async ({ historyRawUnderLock }) => {\n const affectedItemPaths = new Set<string>();\n if (params.currentItem.path) {\n affectedItemPaths.add(params.currentItem.path);\n }\n if (params.nextItem.path) {\n affectedItemPaths.add(params.nextItem.path);\n }\n const itemSnapshots = new Map<string, string>();\n if (params.currentItem.path && params.currentItem.raw !== null) {\n itemSnapshots.set(params.currentItem.path, params.currentItem.raw);\n }\n try {\n /* c8 ignore next -- item-write diff branch requires path and content divergence under lock races. */\n if (\n params.nextItem.path &&\n params.nextItem.raw !== null &&\n params.nextItem.raw !== params.currentItem.raw\n ) {\n await writeFileAtomic(params.nextItem.path, params.nextItem.raw);\n }\n if (\n params.currentItem.path &&\n (!params.nextItem.path ||\n params.nextItem.path !== params.currentItem.path)\n ) {\n await fs.rm(params.currentItem.path, { force: true });\n }\n await writeFileAtomic(\n params.subject.historyPath,\n historyEntriesToRaw(params.rewrittenEntries),\n );\n } catch (error) {\n await rollbackHistoryRedactRewrite(\n params.subject.historyPath,\n historyRawUnderLock,\n affectedItemPaths,\n itemSnapshots,\n );\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runHistoryRedactWriteHooks(params.subject.historyPath, [\n params.nextItem.path,\n params.currentItem.path,\n ]),\n });\n}\n\nasync function rollbackHistoryRedactRewrite(\n historyPath: string,\n historyRawUnderLock: string | null,\n affectedItemPaths: Set<string>,\n itemSnapshots: Map<string, string>,\n): Promise<void> {\n /* c8 ignore start -- no-history-under-lock rollback path is exercised in lock-race integration tests. */\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n /* c8 ignore stop */\n for (const itemPath of affectedItemPaths) {\n const snapshot = itemSnapshots.get(itemPath);\n /* c8 ignore start -- missing snapshot rollback occurs only for create/delete race permutations. */\n if (snapshot === undefined) {\n await fs.rm(itemPath, { force: true });\n } else {\n await writeFileAtomic(itemPath, snapshot);\n }\n /* c8 ignore stop */\n }\n}\n\nasync function runHistoryRedactWriteHooks(\n historyPath: string,\n itemHookPaths: Array<string | null>,\n): Promise<string[]> {\n const hookWarnings: string[] = [];\n const uniqueItemHookPaths = new Set(\n itemHookPaths.filter((itemPath): itemPath is string => itemPath !== null),\n );\n for (const itemHookPath of uniqueItemHookPaths) {\n hookWarnings.push(\n ...(await runActiveOnWriteHooks({\n path: itemHookPath,\n scope: \"project\",\n op: \"history_redact\",\n })),\n );\n }\n hookWarnings.push(\n ...(await runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_redact:history\",\n })),\n );\n return hookWarnings;\n}\n\n/** Implements resolve history subject for the public runtime surface of this module. */\nexport async function resolveHistorySubject(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<HistorySubject> {\n const located = await locateItem(\n pmRoot,\n id,\n settings.id_prefix,\n settings.item_format,\n typeToFolder,\n );\n if (located) {\n return {\n id: located.id,\n historyPath: getHistoryPath(pmRoot, located.id),\n located,\n };\n }\n\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const rawNormalizedId = normalizeRawItemId(id);\n const candidateIds =\n normalizedId === rawNormalizedId\n ? [normalizedId]\n : [normalizedId, rawNormalizedId];\n for (const candidateId of candidateIds) {\n const historyPath = getHistoryPath(pmRoot, candidateId);\n if (await pathExists(historyPath)) {\n return {\n id: candidateId,\n historyPath,\n located: null,\n };\n }\n }\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n}\n\n/** Implements run history redact for the public runtime surface of this module. */\nexport async function runHistoryRedact(\n id: string,\n options: HistoryRedactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryRedactResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const replacement =\n typeof options.replacement === \"string\" && options.replacement.length > 0\n ? options.replacement\n : \"[redacted]\";\n const rules = buildRedactionRules(options.literal, options.regex);\n const subject = await resolveHistorySubject(\n pmRoot,\n id,\n settings,\n typeRegistry.type_to_folder,\n );\n\n if (!(await pathExists(subject.historyPath))) {\n throw new PmCliError(\n `No history stream exists for ${subject.id}.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const historyEntries = await readHistoryEntries(\n subject.historyPath,\n subject.id,\n );\n if (historyEntries.length === 0) {\n throw new PmCliError(\n `No history entries exist for ${subject.id}; nothing to redact.`,\n EXIT_CODE.USAGE,\n );\n }\n\n const integritySnapshot = inspectHistoryIntegrity(historyEntries);\n const rewritten = rewriteHistoryEntries(historyEntries, rules, replacement);\n const preexistingHashMismatches =\n integritySnapshot.hashMismatchesBefore +\n integritySnapshot.hashMismatchesAfter;\n const dryRun = Boolean(options.dryRun);\n const changed = rewritten.replacements > 0;\n const warnings: string[] = [];\n if (preexistingHashMismatches > 0) {\n warnings.push(\n `history_redact_preexisting_hash_mismatches:${preexistingHashMismatches}`,\n );\n }\n if (!changed) {\n warnings.push(\"history_redact_no_matches\");\n }\n\n const currentItem = await loadHistoryRedactCurrentItem(subject, settings);\n const nextItem = resolveHistoryRedactNextItem({\n pmRoot,\n subject,\n settings,\n typeToFolder: typeRegistry.type_to_folder,\n finalDocument: rewritten.finalDocument,\n });\n\n const itemChanged =\n /* c8 ignore next -- null-coalescing item-path comparison branch is exercised in broader command integration coverage. */\n (currentItem.path ?? null) !== (nextItem.path ?? null) ||\n /* c8 ignore next -- null-coalescing item-content comparison branch is exercised in broader command integration coverage. */\n (currentItem.raw ?? null) !== (nextItem.raw ?? null);\n\n const author = resolveAuthor(options.author, settings.author_default);\n const redactionMessage = buildHistoryRedactMessage(options, rewritten);\n const { rewrittenEntries, auditEntryAdded } = buildHistoryRedactEntries({\n rewritten,\n dryRun,\n changed,\n nextItemDocument: nextItem.document,\n author,\n message: redactionMessage,\n });\n const historyVerify = verifyHistoryChain(rewrittenEntries);\n /* c8 ignore start -- invalid rewritten chains are covered by history verification unit tests. */\n if (!historyVerify.ok) {\n throw new PmCliError(\n `history-redact produced an invalid rewritten chain (${historyVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n /* c8 ignore stop */\n\n if (!dryRun && changed) {\n warnings.push(\n ...(await applyHistoryRedactRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItem,\n nextItem,\n author,\n force: options.force,\n rewrittenEntries,\n })),\n );\n }\n\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n patterns: {\n literals: rules\n .filter((rule): rule is LiteralRule => rule.kind === \"literal\")\n .map((rule) => rule.value),\n regex: rules\n .filter((rule): rule is RegexRule => rule.kind === \"regex\")\n .map((rule) => `/${rule.source}/${rule.flags}`),\n replacement,\n },\n history: {\n path: subject.historyPath,\n entries_scanned: historyEntries.length,\n entries_changed: rewritten.entriesChanged,\n replacements: rewritten.replacements,\n hash_mismatches_before: integritySnapshot.hashMismatchesBefore,\n hash_mismatches_after: integritySnapshot.hashMismatchesAfter,\n preexisting_hash_mismatches: preexistingHashMismatches,\n audit_entry_added: auditEntryAdded,\n verify_ok: historyVerify.ok,\n verify_errors: historyVerify.errors,\n },\n item: {\n existed_before: currentItem.path !== null,\n exists_after: nextItem.path !== null,\n path_before: currentItem.path,\n path_after: nextItem.path,\n changed: itemChanged,\n },\n /* c8 ignore next -- warning dedupe ordering is covered indirectly by command-level smoke tests. */\n warnings: [...new Set(warnings)].sort((left, right) =>\n left.localeCompare(right),\n ),\n generated_at: nowIso(),\n };\n}\n\n/** Public contract for test only, shared by SDK and presentation-layer consumers. */\nexport const _testOnly = {\n applyLiteralRule,\n applyRegexRule,\n buildRedactionRules,\n hasItemMetadata,\n normalizeRegexFlags,\n normalizeStringArrayInput,\n parseRegexRule,\n redactStringValue,\n redactUnknownValue,\n};\n","/**\n * @module core/history/history-rewrite\n *\n * Implements append-only history and replay behavior for History Rewrite.\n */\nimport fs from \"node:fs/promises\";\nimport { readFileIfExists, writeFileAtomic } from \"../fs/fs-utils.js\";\nimport type { ItemTypeRegistry } from \"../item/type-registry.js\";\nimport { acquireLock } from \"../lock/lock.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { locateItem, readLocatedItem } from \"../store/item-store.js\";\nimport { resolveGovernanceKnobs } from \"../store/settings.js\";\nimport type { ItemDocument, PmSettings } from \"../../types/index.js\";\n\ntype LoadedItem = Awaited<ReturnType<typeof readLocatedItem>>;\ntype HistoryRawWriter = (filePath: string, content: string) => Promise<void>;\n\n/** Documents the history rewrite subject payload exchanged by command, SDK, and package integrations. */\nexport interface HistoryRewriteSubject {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Filesystem path used for history resolution. */\n historyPath: string;\n}\n\n/** Documents the history rewrite ownership params payload exchanged by command, SDK, and package integrations. */\nexport interface HistoryRewriteOwnershipParams {\n /** Value that configures or reports item document for this contract. */\n itemDocument: ItemDocument | null;\n /** Value that configures or reports subject id for this contract. */\n subjectId: string;\n /** Value that configures or reports author for this contract. */\n author: string;\n /** Value that configures or reports force for this contract. */\n force: boolean | undefined;\n /** Value that configures or reports settings for this contract. */\n settings: PmSettings;\n}\n\n/** Apply ownership_enforcement governance to a history-rewriting operation. Returns the warning(s) the caller should append (empty when no conflict or strict-throws). Throws PmCliError(CONFLICT) in strict mode when the assignee conflicts and --force is not set. */\nexport function checkHistoryRewriteOwnership(\n params: HistoryRewriteOwnershipParams,\n): string[] {\n if (!params.itemDocument) return [];\n const assigned = params.itemDocument.metadata?.assignee?.trim();\n if (!assigned || assigned === params.author || params.force) return [];\n\n const governance = resolveGovernanceKnobs(params.settings);\n if (governance.ownership_enforcement === \"strict\") {\n throw new PmCliError(\n `Item ${params.subjectId} is assigned to ${assigned}. Use --force to override.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (governance.ownership_enforcement === \"warn\") {\n return [\n `ownership_warning:assignee_conflict:${params.subjectId}:${assigned}`,\n ];\n }\n return [];\n}\n\n/** Documents the verify history rewrite drift params payload exchanged by command, SDK, and package integrations. */\nexport interface VerifyHistoryRewriteDriftParams {\n /** Value that configures or reports pm root for this contract. */\n pmRoot: string;\n /** Value that configures or reports subject for this contract. */\n subject: HistoryRewriteSubject;\n /** Value that configures or reports settings for this contract. */\n settings: PmSettings;\n /** Value that configures or reports type registry for this contract. */\n typeRegistry: ItemTypeRegistry;\n /** Value that configures or reports history raw before lock for this contract. */\n historyRawBeforeLock: string | null;\n /** Value that configures or reports current item raw before lock for this contract. */\n currentItemRawBeforeLock: string | null;\n /** Short operation name used in the conflict message (e.g. \"history-redact\"). */\n operation: string;\n}\n\n/** Documents the verified history rewrite state payload exchanged by command, SDK, and package integrations. */\nexport interface VerifiedHistoryRewriteState {\n /** Value that configures or reports history raw under lock for this contract. */\n historyRawUnderLock: string | null;\n /** Value that configures or reports located under lock for this contract. */\n locatedUnderLock: Awaited<ReturnType<typeof locateItem>>;\n /** Value that configures or reports loaded item under lock for this contract. */\n loadedItemUnderLock: LoadedItem | null;\n}\n\n/** Re-read the history stream and the located item document under the acquired lock and compare both with the pre-lock raw snapshots. Throws PmCliError(CONFLICT) if either diverged while waiting for the lock so the caller surfaces an actionable retry. */\nexport async function verifyHistoryRewriteNoDrift(\n params: VerifyHistoryRewriteDriftParams,\n): Promise<VerifiedHistoryRewriteState> {\n const historyRawUnderLock = await readFileIfExists(\n params.subject.historyPath,\n );\n if (historyRawUnderLock !== params.historyRawBeforeLock) {\n throw new PmCliError(\n `History for ${params.subject.id} changed while waiting for lock; retry ${params.operation}.`,\n EXIT_CODE.CONFLICT,\n );\n }\n const locatedUnderLock = await locateItem(\n params.pmRoot,\n params.subject.id,\n params.settings.id_prefix,\n params.settings.item_format,\n params.typeRegistry.type_to_folder,\n );\n const loadedItemUnderLock = locatedUnderLock\n ? await readLocatedItem(locatedUnderLock, {\n schema: params.settings.schema,\n })\n : null;\n if (\n (loadedItemUnderLock?.raw ?? null) !==\n (params.currentItemRawBeforeLock ?? null)\n ) {\n throw new PmCliError(\n `Item ${params.subject.id} changed while waiting for lock; retry ${params.operation}.`,\n EXIT_CODE.CONFLICT,\n );\n }\n return { historyRawUnderLock, locatedUnderLock, loadedItemUnderLock };\n}\n\n/** Documents the execute history rewrite params payload exchanged by command, SDK, and package integrations. */\nexport interface ExecuteHistoryRewriteParams {\n /** Value that configures or reports pm root for this contract. */\n pmRoot: string;\n /** Value that configures or reports subject for this contract. */\n subject: HistoryRewriteSubject;\n /** Value that configures or reports settings for this contract. */\n settings: PmSettings;\n /** Value that configures or reports type registry for this contract. */\n typeRegistry: ItemTypeRegistry;\n /** Value that configures or reports history raw before lock for this contract. */\n historyRawBeforeLock: string | null;\n /** Value that configures or reports current item raw before lock for this contract. */\n currentItemRawBeforeLock: string | null;\n /** Short operation name used in conflict guidance (e.g. \"history-redact\"). */\n operation: string;\n /** Value that configures or reports author for this contract. */\n author: string;\n /** Value that configures or reports force for this contract. */\n force: boolean | undefined;\n /** Value that configures or reports item document for this contract. */\n itemDocument: ItemDocument | null;\n /** Value that configures or reports apply rewrite for this contract. */\n applyRewrite: (verified: VerifiedHistoryRewriteState) => Promise<void>;\n /** Value that configures or reports apply post rewrite for this contract. */\n applyPostRewrite?: (\n verified: VerifiedHistoryRewriteState,\n ) => Promise<string[]>;\n}\n\n/** Writes the rewritten history stream and restores the under-lock snapshot on failure. */\nexport async function writeHistoryRawWithRollback(params: {\n historyPath: string;\n nextHistoryRaw: string;\n historyRawUnderLock: string | null;\n writeHistoryRaw?: HistoryRawWriter;\n}): Promise<void> {\n const writeHistoryRaw = params.writeHistoryRaw ?? writeFileAtomic;\n try {\n await writeHistoryRaw(params.historyPath, params.nextHistoryRaw);\n } catch (error) {\n try {\n if (params.historyRawUnderLock === null) {\n await fs.rm(params.historyPath, { force: true });\n } else {\n await writeHistoryRaw(params.historyPath, params.historyRawUnderLock);\n }\n } catch (rollbackError) {\n throw new AggregateError(\n [error, rollbackError],\n `History rewrite failed and rollback also failed: ${String(error)}`,\n );\n }\n throw error;\n }\n}\n\n/** Shared lock/verify/ownership orchestration for history-rewrite commands. Callers provide the operation-specific write/rollback logic and optional post-write hook execution while this helper enforces the common governance + lock sequencing contract. */\nexport async function executeHistoryRewrite(\n params: ExecuteHistoryRewriteParams,\n): Promise<string[]> {\n const warnings = [\n ...checkHistoryRewriteOwnership({\n itemDocument: params.itemDocument,\n subjectId: params.subject.id,\n author: params.author,\n force: params.force,\n settings: params.settings,\n }),\n ];\n const releaseLock = await acquireLock(\n params.pmRoot,\n params.subject.id,\n params.settings.locks.ttl_seconds,\n params.author,\n Boolean(params.force),\n params.settings.governance.force_required_for_stale_lock,\n params.settings.locks.wait_ms,\n );\n try {\n const verified = await verifyHistoryRewriteNoDrift({\n pmRoot: params.pmRoot,\n subject: params.subject,\n settings: params.settings,\n typeRegistry: params.typeRegistry,\n historyRawBeforeLock: params.historyRawBeforeLock,\n currentItemRawBeforeLock: params.currentItemRawBeforeLock,\n operation: params.operation,\n });\n await params.applyRewrite(verified);\n if (params.applyPostRewrite) {\n warnings.push(...(await params.applyPostRewrite(verified)));\n }\n return warnings;\n } finally {\n await releaseLock();\n }\n}\n"],"names":["fs","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,eAAe;AAkCf,IAAM,wBAAwC;EACnD,UAAU,CAAA;EACV,MAAM;;AAIF,SAAU,2BAAwB;AACtC,SAAO,gBAAgB,qBAAqB;AAC9C;AAGM,SAAU,WAAW,UAAwB;AACjD,MAAI;AACF,WAAO,aAAa,qBAAqB,QAAQ,CAAC;EACpD,QAAQ;AAON,WAAO,UACL,gBAAgB;MACd,iBAAiB;MACjB,UAAU,SAAS;MACnB,MAAM,SAAS;KAChB,CAAC;EAEN;AACF;AAGM,SAAU,qBAAqB,UAAwB;AAC3D,SAAO;IACL,UAAU,SAAS;IACnB,MAAM,SAAS;;AAEnB;AAGM,SAAU,8BACd,UACA,UAAmD,CAAA,GAAE;AAErD,SAAO,kBAAkB,qBAAqB,QAAQ,GAAG,OAAO;AAClE;AAGM,SAAU,iBAAiB,UAAsB;AACrD,MAAI,CAAC,SAAS,YAAY,OAAO,KAAK,SAAS,QAAQ,EAAE,WAAW,GAAG;AACrE,WAAO;MACL,UAAU,CAA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IACA,UAAU;MACR,UAAU,MACP,OAAO,CAAC,SAA8B,KAAK,SAAS,SAAS,EAC7D,IAAI,CAAC,SAAS,KAAK,KAAK;MAC3B,OAAO,MACJ,OAAO,CAAC,SAA4B,KAAK,SAAS,OAAO,EACzD,IAAI,CAAC,SAAS,IAAI,KAAK,MAAM,IAAI,KAAK,KAAK,EAAE;MAChD;;IAEF,SAAS;MACP,MAAM,QAAQ;MACd,iBAAiB,eAAe;MAChC,iBAAiB,UAAU;MAC3B,cAAc,UAAU;MACxB,wBAAwB,kBAAkB;MAC1C,uBAAuB,kBAAkB;MACzC,6BAA6B;MAC7B,mBAAmB;MACnB,WAAW,cAAc;MACzB,eAAe,cAAc;;IAE/B,MAAM;MACJ,gBAAgB,YAAY,SAAS;MACrC,cAAc,SAAS,SAAS;MAChC,aAAa,YAAY;MACzB,YAAY,SAAS;MACrB,SAAS;;;IAGX,UAAU,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,UAC3C,KAAK,cAAc,KAAK,CAAC;IAE3B,cAAc,OAAM;;AAExB;AAGO,IAAM,YAAY;EACvB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA","debugId":"19224557-a97b-5405-9dc9-894cdbf821fc"}
@@ -2,7 +2,7 @@ import {
2
2
  clearFocusedItem,
3
3
  getFocusedItem,
4
4
  setFocusedItem
5
- } from "./chunk-IAPHYPRL.js";
5
+ } from "./chunk-RMLWNPH2.js";
6
6
  import {
7
7
  buildItemNotFoundError,
8
8
  getActiveExtensionRegistrations,
@@ -10,7 +10,7 @@ import {
10
10
  normalizeItemId,
11
11
  readLocatedItem,
12
12
  readSettings
13
- } from "./chunk-T4BRCB6Z.js";
13
+ } from "./chunk-XSJUSQAE.js";
14
14
  import {
15
15
  EXIT_CODE,
16
16
  PmCliError,
@@ -18,7 +18,7 @@ import {
18
18
  pathExists,
19
19
  resolveItemTypeRegistry,
20
20
  resolvePmRoot
21
- } from "./chunk-AFWZRL7M.js";
21
+ } from "./chunk-BSEQUTQP.js";
22
22
 
23
23
  // dist/cli/commands/focus.js
24
24
  !(function() {
@@ -101,4 +101,4 @@ function nonEmptyTitleOrNull(title) {
101
101
  export {
102
102
  runFocus
103
103
  };
104
- //# sourceMappingURL=chunk-KB726FMH.js.map
104
+ //# sourceMappingURL=chunk-H2Z3FYXQ.js.map
@@ -0,0 +1,162 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0e94a766-6f3b-59e0-83b2-987c167effd6")}catch(e){}}();
3
+ import {
4
+ DEFAULT_EXTENSION_PRIORITY,
5
+ EXIT_CODE,
6
+ PmCliError,
7
+ isCanonicalPathWithinDirectory,
8
+ isPathWithinDirectory,
9
+ pathExists
10
+ } from "./chunk-QKECXBBG.js";
11
+
12
+ // dist/sdk/command-line.js
13
+ var quoteWindowsCommandArg = (arg) => {
14
+ let escaped = '"';
15
+ let pendingBackslashes = 0;
16
+ for (const character of arg) {
17
+ if (character === "\\") {
18
+ pendingBackslashes += 1;
19
+ continue;
20
+ }
21
+ escaped += "\\".repeat(character === '"' ? pendingBackslashes * 2 + 1 : pendingBackslashes);
22
+ escaped += character;
23
+ pendingBackslashes = 0;
24
+ }
25
+ return `${escaped}${"\\".repeat(pendingBackslashes * 2)}"`;
26
+ };
27
+ var quoteCommandArg = (arg, platform = process.platform) => {
28
+ const safePattern = platform === "win32" ? /^[A-Za-z0-9._:/\\@=-]+$/ : /^[A-Za-z0-9._:/@=-]+$/;
29
+ if (safePattern.test(arg)) {
30
+ return arg;
31
+ }
32
+ if (platform === "win32") {
33
+ return quoteWindowsCommandArg(arg);
34
+ }
35
+ return `"${arg.replace(/(["\\$`])/g, "\\$1")}"`;
36
+ };
37
+ var renderPmCommand = (argv, platform = process.platform) => {
38
+ const args = argv.map((token) => quoteCommandArg(token, platform)).join(" ");
39
+ return args.length > 0 ? `pm ${args}` : "pm";
40
+ };
41
+
42
+ // dist/sdk/extension/shared.js
43
+ import fs from "node:fs/promises";
44
+ import path from "node:path";
45
+ function normalizeStringList(values) {
46
+ return [
47
+ ...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))
48
+ ].sort((left, right) => left.localeCompare(right));
49
+ }
50
+ function normalizeExtensionNameForMatch(value) {
51
+ return value.trim().toLowerCase();
52
+ }
53
+ function normalizeManagedDirectoryName(name) {
54
+ const normalized = name.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-");
55
+ let start = 0;
56
+ while (normalized[start] === "-") {
57
+ start += 1;
58
+ }
59
+ let end = normalized.length;
60
+ while (end > start && normalized[end - 1] === "-") {
61
+ end -= 1;
62
+ }
63
+ const directoryName = normalized.slice(start, end);
64
+ if (directoryName.length === 0) {
65
+ throw new PmCliError("Extension manifest name must resolve to a non-empty directory name.", EXIT_CODE.USAGE);
66
+ }
67
+ if (directoryName === "." || directoryName === "..") {
68
+ throw new PmCliError('Extension manifest name must not resolve to "." or "..".', EXIT_CODE.USAGE);
69
+ }
70
+ return directoryName;
71
+ }
72
+ function parseOptionalManifestPriority(value) {
73
+ if (value === void 0 || value === null) {
74
+ return DEFAULT_EXTENSION_PRIORITY;
75
+ }
76
+ return typeof value === "number" && Number.isInteger(value) ? value : null;
77
+ }
78
+ function parseOptionalManifestCapabilities(value) {
79
+ if (value === void 0 || value === null) {
80
+ return [];
81
+ }
82
+ if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
83
+ return null;
84
+ }
85
+ return normalizeStringList(value.map((entry) => String(entry).toLowerCase()));
86
+ }
87
+ function parseExtensionManifest(raw) {
88
+ if (typeof raw !== "object" || raw === null) {
89
+ return null;
90
+ }
91
+ const candidate = raw;
92
+ if (typeof candidate.name !== "string" || candidate.name.trim().length === 0) {
93
+ return null;
94
+ }
95
+ if (typeof candidate.version !== "string" || candidate.version.trim().length === 0) {
96
+ return null;
97
+ }
98
+ if (typeof candidate.entry !== "string" || candidate.entry.trim().length === 0) {
99
+ return null;
100
+ }
101
+ const priority = parseOptionalManifestPriority(candidate.priority);
102
+ const capabilities = parseOptionalManifestCapabilities(candidate.capabilities);
103
+ if (priority === null || capabilities === null) {
104
+ return null;
105
+ }
106
+ return {
107
+ name: candidate.name.trim(),
108
+ version: candidate.version.trim(),
109
+ entry: candidate.entry.trim(),
110
+ priority,
111
+ capabilities
112
+ };
113
+ }
114
+ async function validateExtensionDirectory(directory) {
115
+ const manifestPath = path.join(directory, "manifest.json");
116
+ if (!await pathExists(manifestPath)) {
117
+ throw new PmCliError(`Extension manifest is missing at "${manifestPath}".`, EXIT_CODE.USAGE);
118
+ }
119
+ let parsedManifest;
120
+ try {
121
+ parsedManifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
122
+ } catch (error) {
123
+ throw new PmCliError(`Failed to parse extension manifest at "${manifestPath}": ${formatManifestReadError(error)}`, EXIT_CODE.USAGE);
124
+ }
125
+ const manifest = parseExtensionManifest(parsedManifest);
126
+ if (!manifest) {
127
+ throw new PmCliError(`Extension manifest at "${manifestPath}" is invalid.`, EXIT_CODE.USAGE);
128
+ }
129
+ const entryPath = path.resolve(directory, manifest.entry);
130
+ if (!isPathWithinDirectory(directory, entryPath)) {
131
+ throw new PmCliError(`Extension entry "${manifest.entry}" resolves outside extension directory "${directory}".`, EXIT_CODE.USAGE);
132
+ }
133
+ if (!await pathExists(entryPath)) {
134
+ throw new PmCliError(`Extension entry file is missing at "${entryPath}".`, EXIT_CODE.USAGE);
135
+ }
136
+ if (!await isCanonicalPathWithinDirectory(directory, entryPath)) {
137
+ throw new PmCliError(`Extension entry "${manifest.entry}" resolves outside extension directory after symlink resolution.`, EXIT_CODE.USAGE);
138
+ }
139
+ return {
140
+ directory,
141
+ manifest_path: manifestPath,
142
+ entry_path: entryPath,
143
+ manifest
144
+ };
145
+ }
146
+ function formatManifestReadError(error) {
147
+ return error instanceof Error ? error.message : String(error);
148
+ }
149
+
150
+ export {
151
+ quoteWindowsCommandArg,
152
+ quoteCommandArg,
153
+ renderPmCommand,
154
+ normalizeStringList,
155
+ normalizeExtensionNameForMatch,
156
+ normalizeManagedDirectoryName,
157
+ parseExtensionManifest,
158
+ validateExtensionDirectory
159
+ };
160
+ //# sourceMappingURL=chunk-H3EIEWGR.js.map
161
+
162
+ //# debugId=0e94a766-6f3b-59e0-83b2-987c167effd6
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../sdk/command-line.ts","../../../../../../../../sdk/extension/shared.ts"],"sourcesContent":["/**\n * @module sdk/command-line\n *\n * Renders copy-safe pm command suggestions for SDK and CLI diagnostics.\n */\n\n/** Quote one Windows argument with the linear CommandLineToArgvW escaping algorithm. */\nexport const quoteWindowsCommandArg = (arg: string): string => {\n let escaped = '\"';\n let pendingBackslashes = 0;\n for (const character of arg) {\n if (character === \"\\\\\") {\n pendingBackslashes += 1;\n continue;\n }\n escaped += \"\\\\\".repeat(\n character === '\"' ? pendingBackslashes * 2 + 1 : pendingBackslashes,\n );\n escaped += character;\n pendingBackslashes = 0;\n }\n return `${escaped}${\"\\\\\".repeat(pendingBackslashes * 2)}\"`;\n};\n\n/** Quote one command argument only when platform shell-significant characters require it. */\nexport const quoteCommandArg = (\n arg: string,\n platform: NodeJS.Platform = process.platform,\n): string => {\n const safePattern =\n platform === \"win32\" ? /^[A-Za-z0-9._:/\\\\@=-]+$/ : /^[A-Za-z0-9._:/@=-]+$/;\n if (safePattern.test(arg)) {\n return arg;\n }\n if (platform === \"win32\") {\n return quoteWindowsCommandArg(arg);\n }\n return `\"${arg.replace(/([\"\\\\$`])/g, \"\\\\$1\")}\"`;\n};\n\n/** Render a complete pm command from already-tokenized arguments. */\nexport const renderPmCommand = (\n argv: string[],\n platform: NodeJS.Platform = process.platform,\n): string => {\n const args = argv.map((token) => quoteCommandArg(token, platform)).join(\" \");\n return args.length > 0 ? `pm ${args}` : \"pm\";\n};\n","/**\n * @module sdk/extension/shared\n *\n * Implements extension package-management support for Shared.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { isPathWithinDirectory } from \"../../core/fs/path-utils.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport {\n DEFAULT_EXTENSION_PRIORITY,\n isCanonicalPathWithinDirectory,\n type ExtensionManifest,\n} from \"../../core/extensions/loader.js\";\n\nexport { DEFAULT_EXTENSION_PRIORITY, isCanonicalPathWithinDirectory };\n\n/** Documents the validated extension directory payload exchanged by command, SDK, and package integrations. */\nexport interface ValidatedExtensionDirectory {\n /** Value that configures or reports directory for this contract. */\n directory: string;\n /** Filesystem path used for manifest resolution. */\n manifest_path: string;\n /** Filesystem path used for entry resolution. */\n entry_path: string;\n /** Declarative package manifest consumed by the extension loader. */\n manifest: ExtensionManifest;\n}\n\n/** Implements normalize string list for the public runtime surface of this module. */\nexport function normalizeStringList(values: readonly string[]): string[] {\n return [\n ...new Set(\n values.map((value) => value.trim()).filter((value) => value.length > 0),\n ),\n ].sort((left, right) => left.localeCompare(right));\n}\n\n/** Implements normalize extension name for match for the public runtime surface of this module. */\nexport function normalizeExtensionNameForMatch(value: string): string {\n return value.trim().toLowerCase();\n}\n\n/** Implements normalize managed directory name for the public runtime surface of this module. */\nexport function normalizeManagedDirectoryName(name: string): string {\n const normalized = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\");\n let start = 0;\n while (normalized[start] === \"-\") {\n start += 1;\n }\n let end = normalized.length;\n while (end > start && normalized[end - 1] === \"-\") {\n end -= 1;\n }\n const directoryName = normalized.slice(start, end);\n if (directoryName.length === 0) {\n throw new PmCliError(\n \"Extension manifest name must resolve to a non-empty directory name.\",\n EXIT_CODE.USAGE,\n );\n }\n if (directoryName === \".\" || directoryName === \"..\") {\n // Manifest-controlled input must resolve to a dedicated child directory, never\n // the extensions root itself or its parent (path-traversal guard).\n throw new PmCliError(\n 'Extension manifest name must not resolve to \".\" or \"..\".',\n EXIT_CODE.USAGE,\n );\n }\n return directoryName;\n}\n\nfunction parseOptionalManifestPriority(value: unknown): number | null {\n if (value === undefined || value === null) {\n return DEFAULT_EXTENSION_PRIORITY;\n }\n return typeof value === \"number\" && Number.isInteger(value) ? value : null;\n}\n\nfunction parseOptionalManifestCapabilities(value: unknown): string[] | null {\n if (value === undefined || value === null) {\n return [];\n }\n if (\n !Array.isArray(value) ||\n value.some((entry) => typeof entry !== \"string\")\n ) {\n return null;\n }\n return normalizeStringList(value.map((entry) => String(entry).toLowerCase()));\n}\n\n/** Implements parse extension manifest for the public runtime surface of this module. */\nexport function parseExtensionManifest(raw: unknown): ExtensionManifest | null {\n if (typeof raw !== \"object\" || raw === null) {\n return null;\n }\n const candidate = raw as Record<string, unknown>;\n if (\n typeof candidate.name !== \"string\" ||\n candidate.name.trim().length === 0\n ) {\n return null;\n }\n if (\n typeof candidate.version !== \"string\" ||\n candidate.version.trim().length === 0\n ) {\n return null;\n }\n if (\n typeof candidate.entry !== \"string\" ||\n candidate.entry.trim().length === 0\n ) {\n return null;\n }\n\n const priority = parseOptionalManifestPriority(candidate.priority);\n const capabilities = parseOptionalManifestCapabilities(\n candidate.capabilities,\n );\n if (priority === null || capabilities === null) {\n return null;\n }\n\n return {\n name: candidate.name.trim(),\n version: candidate.version.trim(),\n entry: candidate.entry.trim(),\n priority,\n capabilities,\n };\n}\n\n/** Implements validate extension directory for the public runtime surface of this module. */\nexport async function validateExtensionDirectory(\n directory: string,\n): Promise<ValidatedExtensionDirectory> {\n const manifestPath = path.join(directory, \"manifest.json\");\n if (!(await pathExists(manifestPath))) {\n throw new PmCliError(\n `Extension manifest is missing at \"${manifestPath}\".`,\n EXIT_CODE.USAGE,\n );\n }\n\n let parsedManifest: unknown;\n try {\n parsedManifest = JSON.parse(\n await fs.readFile(manifestPath, \"utf8\"),\n ) as unknown;\n } catch (error: unknown) {\n throw new PmCliError(\n `Failed to parse extension manifest at \"${manifestPath}\": ${formatManifestReadError(error)}`,\n EXIT_CODE.USAGE,\n );\n }\n\n const manifest = parseExtensionManifest(parsedManifest);\n if (!manifest) {\n throw new PmCliError(\n `Extension manifest at \"${manifestPath}\" is invalid.`,\n EXIT_CODE.USAGE,\n );\n }\n\n const entryPath = path.resolve(directory, manifest.entry);\n if (!isPathWithinDirectory(directory, entryPath)) {\n throw new PmCliError(\n `Extension entry \"${manifest.entry}\" resolves outside extension directory \"${directory}\".`,\n EXIT_CODE.USAGE,\n );\n }\n if (!(await pathExists(entryPath))) {\n throw new PmCliError(\n `Extension entry file is missing at \"${entryPath}\".`,\n EXIT_CODE.USAGE,\n );\n }\n if (!(await isCanonicalPathWithinDirectory(directory, entryPath))) {\n throw new PmCliError(\n `Extension entry \"${manifest.entry}\" resolves outside extension directory after symlink resolution.`,\n EXIT_CODE.USAGE,\n );\n }\n\n return {\n directory,\n manifest_path: manifestPath,\n entry_path: entryPath,\n manifest,\n };\n}\n\nfunction formatManifestReadError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** Public contract for test only extension shared, shared by SDK and presentation-layer consumers. */\nexport const _testOnlyExtensionShared = {\n formatManifestReadError,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAOO,IAAM,yBAAyB,CAAC,QAAuB;AAC5D,MAAI,UAAU;AACd,MAAI,qBAAqB;AACzB,aAAW,aAAa,KAAK;AAC3B,QAAI,cAAc,MAAM;AACtB,4BAAsB;AACtB;IACF;AACA,eAAW,KAAK,OACd,cAAc,MAAM,qBAAqB,IAAI,IAAI,kBAAkB;AAErE,eAAW;AACX,yBAAqB;EACvB;AACA,SAAO,GAAG,OAAO,GAAG,KAAK,OAAO,qBAAqB,CAAC,CAAC;AACzD;AAGO,IAAM,kBAAkB,CAC7B,KACA,WAA4B,QAAQ,aAC1B;AACV,QAAM,cACJ,aAAa,UAAU,4BAA4B;AACrD,MAAI,YAAY,KAAK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EAE3C,SAAS,OAAgB;AACvB,UAAM,IAAI,WACR,0CAA0C,YAAY,MAAM,wBAAwB,KAAK,CAAC,IAC1F,UAAU,KAAK;EAEnB;AAEA,QAAM,WAAW,uBAAuB,cAAc;AACtD,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,WACR,0BAA0B,YAAY,iBACtC,UAAU,KAAK;EAEnB;AAEA,QAAM,YAAY,KAAK,QAAQ,WAAW,SAAS,KAAK;AACxD,MAAI,CAAC,sBAAsB,WAAW,SAAS,GAAG;AAChD,UAAM,IAAI,WACR,oBAAoB,SAAS,KAAK,2CAA2C,SAAS,MACtF,UAAU,KAAK;EAEnB;AACA,MAAI,CAAE,MAAM,WAAW,SAAS,GAAI;AAClC,UAAM,IAAI,WACR,uCAAuC,SAAS,MAChD,UAAU,KAAK;EAEnB;AACA,MAAI,CAAE,MAAM,+BAA+B,WAAW,SAAS,GAAI;AACjE,UAAM,IAAI,WACR,oBAAoB,SAAS,KAAK,oEAClC,UAAU,KAAK;EAEnB;AAEA,SAAO;IACL;IACA,eAAe;IACf,YAAY;IACZ;;AAEJ;AAEA,SAAS,wBAAwB,OAAc;AAC7C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D","debugId":"0e94a766-6f3b-59e0-83b2-987c167effd6"}
@@ -9,7 +9,7 @@ import {
9
9
  PLAN_MODE_VALUES,
10
10
  PLAN_STEP_LINK_KIND_VALUES,
11
11
  PLAN_STEP_STATUS_VALUES
12
- } from "./chunk-AFWZRL7M.js";
12
+ } from "./chunk-BSEQUTQP.js";
13
13
 
14
14
  // dist/sdk/cli-contracts/commander-types.js
15
15
  !(function() {
@@ -1349,7 +1349,7 @@ function isPmExtensionPolicySurfaceContract(value) {
1349
1349
  !(function() {
1350
1350
  try {
1351
1351
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
1352
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "8ab6e4b1-0fd0-548c-902e-a9908a8fe21a");
1352
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "737c225c-aa32-5277-b169-faedbb057f39");
1353
1353
  } catch (e2) {
1354
1354
  }
1355
1355
  })();
@@ -1690,7 +1690,11 @@ var TOOL_DEPS_OPTION_CONTRACTS = [
1690
1690
  { param: "format", flag: "--format" },
1691
1691
  { param: "maxDepth", flag: "--max-depth" },
1692
1692
  { param: "collapse", flag: "--collapse" },
1693
- { param: "summary", flag: "--summary" }
1693
+ { param: "summary", flag: "--summary" },
1694
+ { param: "nodeLimit", flag: "--node-limit" },
1695
+ { param: "edgeLimit", flag: "--edge-limit" },
1696
+ { param: "tokenBudget", flag: "--token-budget" },
1697
+ { param: "cursor", flag: "--cursor" }
1694
1698
  ];
1695
1699
 
1696
1700
  // dist/sdk/cli-contracts/string-lists.js
@@ -1711,7 +1715,7 @@ function normalizeUniqueStringList(values) {
1711
1715
  !(function() {
1712
1716
  try {
1713
1717
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
1714
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e9f582fa-4daa-55e7-8019-d302301d54cd");
1718
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "cb1e2010-bf9f-5eb9-a77d-70e31f5463ac");
1715
1719
  } catch (e2) {
1716
1720
  }
1717
1721
  })();
@@ -1771,7 +1775,8 @@ var SUBCOMMAND_GLOBAL_FLAG_CONTRACTS = [
1771
1775
  { flag: "--no-extensions" },
1772
1776
  { flag: "--no-pager" },
1773
1777
  { flag: "--profile" },
1774
- { flag: "--help" }
1778
+ { flag: "--help" },
1779
+ { flag: "--author", value_name: "id" }
1775
1780
  ];
1776
1781
  var GLOBAL_FLAG_CONTRACTS = [
1777
1782
  ...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,
@@ -2077,6 +2082,7 @@ var PLAN_FLAG_CONTRACTS = [
2077
2082
  { flag: "--force" }
2078
2083
  ];
2079
2084
  var INIT_FLAG_CONTRACTS = [
2085
+ { flag: "--id-prefix", aliases: ["--prefix"] },
2080
2086
  { flag: "--preset" },
2081
2087
  { flag: "--type-preset" },
2082
2088
  { flag: "--defaults", short: "-y", aliases: ["--yes"] },
@@ -2841,6 +2847,7 @@ var GET_FLAG_CONTRACTS = [
2841
2847
  { flag: "--depth" },
2842
2848
  { flag: "--full" },
2843
2849
  { flag: "--fields", list: true },
2850
+ { flag: "--at" },
2844
2851
  { flag: "--tree" },
2845
2852
  { flag: "--tree-depth" },
2846
2853
  { flag: "--tree_depth" },
@@ -3080,7 +3087,7 @@ function toCompletionFlagString(flagContracts, includeGlobal = true) {
3080
3087
  !(function() {
3081
3088
  try {
3082
3089
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
3083
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "34ee8cba-071e-5277-bc8b-c3dd2c1600e8");
3090
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "ced0a4db-9b0d-50c6-9de1-1d08dcf39c93");
3084
3091
  } catch (e2) {
3085
3092
  }
3086
3093
  })();
@@ -3422,6 +3429,10 @@ var PM_TOOL_PARAMETER_PROPERTIES = {
3422
3429
  }
3423
3430
  },
3424
3431
  maxDepth: { anyOf: [{ type: "string" }, { type: "number" }] },
3432
+ nodeLimit: { anyOf: [{ type: "string" }, { type: "integer", minimum: 1 }] },
3433
+ edgeLimit: { anyOf: [{ type: "string" }, { type: "integer", minimum: 1 }] },
3434
+ tokenBudget: { anyOf: [{ type: "string" }, { type: "integer", minimum: 1 }] },
3435
+ cursor: { type: "string" },
3425
3436
  collapse: { type: "string", enum: ["none", "repeated"] },
3426
3437
  shell: { type: "string", enum: ["bash", "zsh", "fish"] },
3427
3438
  stdin: { type: "boolean" },
@@ -4302,6 +4313,21 @@ var PM_TOOL_PARAMETER_METADATA = {
4302
4313
  description: "Maximum dependency traversal depth for deps action (0 keeps only the root node).",
4303
4314
  examples: [0, 1, "2"]
4304
4315
  },
4316
+ nodeLimit: {
4317
+ description: "Maximum related nodes returned by deps --format context.",
4318
+ examples: [10, "20"]
4319
+ },
4320
+ edgeLimit: {
4321
+ description: "Maximum related edges returned by deps --format context.",
4322
+ examples: [20, "40"]
4323
+ },
4324
+ tokenBudget: {
4325
+ description: "Maximum estimated output tokens for deps --format context.",
4326
+ examples: [600, "1200"]
4327
+ },
4328
+ cursor: {
4329
+ description: "Opaque continuation cursor returned by deps --format context."
4330
+ },
4305
4331
  collapse: {
4306
4332
  description: 'Dependency tree collapse mode for deps action ("none" or "repeated").',
4307
4333
  examples: ["none", "repeated"]
@@ -4378,7 +4404,7 @@ var PM_TOOL_ACTION_SCOPED_PARAMETER_METADATA = {
4378
4404
  !(function() {
4379
4405
  try {
4380
4406
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
4381
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "0da07ad9-bb86-5626-8c6e-f1d67cd3a988");
4407
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "15ef6d3d-a3e4-50ab-a3d8-ac9cfa57c110");
4382
4408
  } catch (e2) {
4383
4409
  }
4384
4410
  })();
@@ -4966,7 +4992,7 @@ var PM_TOOL_ACTION_SCHEMA_CONTRACTS = {
4966
4992
  },
4967
4993
  deps: {
4968
4994
  required: ["id"],
4969
- optional: ["format", "maxDepth", "collapse", "summary"]
4995
+ optional: ["format", "maxDepth", "collapse", "summary", "nodeLimit", "edgeLimit", "tokenBudget", "cursor"]
4970
4996
  },
4971
4997
  test: {
4972
4998
  required: ["id"],
@@ -5372,16 +5398,33 @@ function buildProviderCompatibleToolSchema() {
5372
5398
  }
5373
5399
  var PM_PROVIDER_TOOL_PARAMETERS_SCHEMA = createLazyContractSchema(buildProviderCompatibleToolSchema);
5374
5400
 
5401
+ // dist/sdk/cli-contracts/command-aliases.js
5402
+ !(function() {
5403
+ try {
5404
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5405
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e5081784-d3d0-5fd3-9f6a-294a621995ef");
5406
+ } catch (e2) {
5407
+ }
5408
+ })();
5409
+ var EXECUTABLE_COMMAND_ALIASES = {
5410
+ show: "get",
5411
+ view: "get",
5412
+ comment: "comments",
5413
+ note: "notes",
5414
+ learning: "learnings"
5415
+ };
5416
+
5375
5417
  // dist/sdk/cli-contracts.js
5376
5418
  !(function() {
5377
5419
  try {
5378
5420
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5379
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "d945b6b1-da70-5142-a422-e20888faafaa");
5421
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "03628345-205e-5ae0-9a16-1f47628ea7af");
5380
5422
  } catch (e2) {
5381
5423
  }
5382
5424
  })();
5383
5425
 
5384
5426
  export {
5427
+ EXECUTABLE_COMMAND_ALIASES,
5385
5428
  LIST_COMMANDER_STRING_OPTION_CONTRACTS,
5386
5429
  SEARCH_COMMANDER_STRING_OPTION_CONTRACTS,
5387
5430
  CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS,
@@ -5507,4 +5550,4 @@ export {
5507
5550
  PM_TOOL_PARAMETERS_SCHEMA,
5508
5551
  PM_PROVIDER_TOOL_PARAMETERS_SCHEMA
5509
5552
  };
5510
- //# sourceMappingURL=chunk-2QIQGYPW.js.map
5553
+ //# sourceMappingURL=chunk-H5APFTHZ.js.map