@unbrained/pm-cli 2026.6.13 → 2026.6.16

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 (770) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +1 -1
  3. package/dist/cli/bootstrap-args.d.ts +29 -0
  4. package/dist/cli/bootstrap-args.js +11 -4
  5. package/dist/cli/bootstrap-args.js.map +1 -1
  6. package/dist/cli/commander-usage.d.ts +12 -0
  7. package/dist/cli/commander-usage.js +18 -7
  8. package/dist/cli/commander-usage.js.map +1 -1
  9. package/dist/cli/commands/activity.d.ts +19 -0
  10. package/dist/cli/commands/activity.js +12 -2
  11. package/dist/cli/commands/activity.js.map +1 -1
  12. package/dist/cli/commands/aggregate.d.ts +58 -0
  13. package/dist/cli/commands/aggregate.js +48 -15
  14. package/dist/cli/commands/aggregate.js.map +1 -1
  15. package/dist/cli/commands/annotation-command.d.ts +6 -1
  16. package/dist/cli/commands/annotation-command.js +72 -2
  17. package/dist/cli/commands/annotation-command.js.map +1 -1
  18. package/dist/cli/commands/append.js +4 -3
  19. package/dist/cli/commands/append.js.map +1 -1
  20. package/dist/cli/commands/close-many.d.ts +20 -0
  21. package/dist/cli/commands/close-many.js +14 -23
  22. package/dist/cli/commands/close-many.js.map +1 -1
  23. package/dist/cli/commands/close.js +37 -4
  24. package/dist/cli/commands/close.js.map +1 -1
  25. package/dist/cli/commands/comments-audit.js +3 -2
  26. package/dist/cli/commands/comments-audit.js.map +1 -1
  27. package/dist/cli/commands/comments.d.ts +2 -0
  28. package/dist/cli/commands/comments.js +49 -23
  29. package/dist/cli/commands/comments.js.map +1 -1
  30. package/dist/cli/commands/completion.js +269 -8
  31. package/dist/cli/commands/completion.js.map +1 -1
  32. package/dist/cli/commands/config.d.ts +51 -1
  33. package/dist/cli/commands/config.js +50 -12
  34. package/dist/cli/commands/config.js.map +1 -1
  35. package/dist/cli/commands/context.d.ts +79 -1
  36. package/dist/cli/commands/context.js +151 -25
  37. package/dist/cli/commands/context.js.map +1 -1
  38. package/dist/cli/commands/contracts.d.ts +80 -1
  39. package/dist/cli/commands/contracts.js +54 -4
  40. package/dist/cli/commands/contracts.js.map +1 -1
  41. package/dist/cli/commands/create.d.ts +49 -0
  42. package/dist/cli/commands/create.js +105 -7
  43. package/dist/cli/commands/create.js.map +1 -1
  44. package/dist/cli/commands/dedupe-audit.d.ts +33 -0
  45. package/dist/cli/commands/dedupe-audit.js +18 -14
  46. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  47. package/dist/cli/commands/deps.js +7 -4
  48. package/dist/cli/commands/deps.js.map +1 -1
  49. package/dist/cli/commands/event-validation-messages.js +3 -3
  50. package/dist/cli/commands/event-validation-messages.js.map +1 -1
  51. package/dist/cli/commands/extension/bundled-catalog.d.ts +7 -0
  52. package/dist/cli/commands/extension/bundled-catalog.js +19 -15
  53. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  54. package/dist/cli/commands/extension/install-sources.d.ts +41 -1
  55. package/dist/cli/commands/extension/install-sources.js +26 -8
  56. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  57. package/dist/cli/commands/extension/shared.d.ts +5 -0
  58. package/dist/cli/commands/extension/shared.js +9 -3
  59. package/dist/cli/commands/extension/shared.js.map +1 -1
  60. package/dist/cli/commands/extension.d.ts +133 -1
  61. package/dist/cli/commands/extension.js +127 -9
  62. package/dist/cli/commands/extension.js.map +1 -1
  63. package/dist/cli/commands/files.d.ts +30 -1
  64. package/dist/cli/commands/files.js +21 -2
  65. package/dist/cli/commands/files.js.map +1 -1
  66. package/dist/cli/commands/focus.d.ts +11 -0
  67. package/dist/cli/commands/focus.js +86 -0
  68. package/dist/cli/commands/focus.js.map +1 -0
  69. package/dist/cli/commands/get.d.ts +9 -2
  70. package/dist/cli/commands/get.js +34 -6
  71. package/dist/cli/commands/get.js.map +1 -1
  72. package/dist/cli/commands/guide.d.ts +5 -0
  73. package/dist/cli/commands/guide.js +6 -3
  74. package/dist/cli/commands/guide.js.map +1 -1
  75. package/dist/cli/commands/health.d.ts +109 -0
  76. package/dist/cli/commands/health.js +87 -35
  77. package/dist/cli/commands/health.js.map +1 -1
  78. package/dist/cli/commands/history-compact.js +27 -36
  79. package/dist/cli/commands/history-compact.js.map +1 -1
  80. package/dist/cli/commands/history-redact.d.ts +46 -0
  81. package/dist/cli/commands/history-redact.js +99 -67
  82. package/dist/cli/commands/history-redact.js.map +1 -1
  83. package/dist/cli/commands/history-repair.js +34 -37
  84. package/dist/cli/commands/history-repair.js.map +1 -1
  85. package/dist/cli/commands/history.js +6 -2
  86. package/dist/cli/commands/history.js.map +1 -1
  87. package/dist/cli/commands/index.d.ts +1 -0
  88. package/dist/cli/commands/index.js +3 -2
  89. package/dist/cli/commands/index.js.map +1 -1
  90. package/dist/cli/commands/init-agent-guidance.d.ts +54 -0
  91. package/dist/cli/commands/init-agent-guidance.js +31 -4
  92. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  93. package/dist/cli/commands/init.d.ts +36 -1
  94. package/dist/cli/commands/init.js +38 -5
  95. package/dist/cli/commands/init.js.map +1 -1
  96. package/dist/cli/commands/learnings.js +4 -3
  97. package/dist/cli/commands/learnings.js.map +1 -1
  98. package/dist/cli/commands/linked-test-parsers.d.ts +5 -0
  99. package/dist/cli/commands/linked-test-parsers.js +5 -2
  100. package/dist/cli/commands/linked-test-parsers.js.map +1 -1
  101. package/dist/cli/commands/list-filter-shared.d.ts +8 -0
  102. package/dist/cli/commands/list-filter-shared.js +70 -0
  103. package/dist/cli/commands/list-filter-shared.js.map +1 -0
  104. package/dist/cli/commands/list.d.ts +116 -0
  105. package/dist/cli/commands/list.js +194 -6
  106. package/dist/cli/commands/list.js.map +1 -1
  107. package/dist/cli/commands/normalize.js +16 -2
  108. package/dist/cli/commands/normalize.js.map +1 -1
  109. package/dist/cli/commands/notes.js +4 -3
  110. package/dist/cli/commands/notes.js.map +1 -1
  111. package/dist/cli/commands/plan.js +3 -2
  112. package/dist/cli/commands/plan.js.map +1 -1
  113. package/dist/cli/commands/reindex.d.ts +83 -0
  114. package/dist/cli/commands/reindex.js +45 -10
  115. package/dist/cli/commands/reindex.js.map +1 -1
  116. package/dist/cli/commands/restore.d.ts +40 -1
  117. package/dist/cli/commands/restore.js +27 -2
  118. package/dist/cli/commands/restore.js.map +1 -1
  119. package/dist/cli/commands/schema.d.ts +18 -0
  120. package/dist/cli/commands/schema.js +30 -3
  121. package/dist/cli/commands/schema.js.map +1 -1
  122. package/dist/cli/commands/search.d.ts +289 -1
  123. package/dist/cli/commands/search.js +367 -60
  124. package/dist/cli/commands/search.js.map +1 -1
  125. package/dist/cli/commands/stats.d.ts +38 -0
  126. package/dist/cli/commands/stats.js +38 -10
  127. package/dist/cli/commands/stats.js.map +1 -1
  128. package/dist/cli/commands/telemetry.js +5 -3
  129. package/dist/cli/commands/telemetry.js.map +1 -1
  130. package/dist/cli/commands/templates.d.ts +18 -0
  131. package/dist/cli/commands/templates.js +9 -2
  132. package/dist/cli/commands/templates.js.map +1 -1
  133. package/dist/cli/commands/test-all.d.ts +5 -0
  134. package/dist/cli/commands/test-all.js +9 -3
  135. package/dist/cli/commands/test-all.js.map +1 -1
  136. package/dist/cli/commands/test.d.ts +70 -1
  137. package/dist/cli/commands/test.js +84 -3
  138. package/dist/cli/commands/test.js.map +1 -1
  139. package/dist/cli/commands/update-many.d.ts +34 -1
  140. package/dist/cli/commands/update-many.js +60 -31
  141. package/dist/cli/commands/update-many.js.map +1 -1
  142. package/dist/cli/commands/update.d.ts +71 -0
  143. package/dist/cli/commands/update.js +74 -8
  144. package/dist/cli/commands/update.js.map +1 -1
  145. package/dist/cli/commands/upgrade.d.ts +28 -1
  146. package/dist/cli/commands/upgrade.js +17 -4
  147. package/dist/cli/commands/upgrade.js.map +1 -1
  148. package/dist/cli/commands/validate.d.ts +114 -0
  149. package/dist/cli/commands/validate.js +153 -8
  150. package/dist/cli/commands/validate.js.map +1 -1
  151. package/dist/cli/error-guidance.d.ts +30 -0
  152. package/dist/cli/error-guidance.js +41 -6
  153. package/dist/cli/error-guidance.js.map +1 -1
  154. package/dist/cli/extension-command-options.js +9 -7
  155. package/dist/cli/extension-command-options.js.map +1 -1
  156. package/dist/cli/help-content.d.ts +8 -0
  157. package/dist/cli/help-content.js +30 -6
  158. package/dist/cli/help-content.js.map +1 -1
  159. package/dist/cli/help-json-payload.d.ts +19 -1
  160. package/dist/cli/help-json-payload.js +16 -7
  161. package/dist/cli/help-json-payload.js.map +1 -1
  162. package/dist/cli/main.d.ts +223 -0
  163. package/dist/cli/main.js +203 -45
  164. package/dist/cli/main.js.map +1 -1
  165. package/dist/cli/register-list-query.js +62 -5
  166. package/dist/cli/register-list-query.js.map +1 -1
  167. package/dist/cli/register-mutation.d.ts +16 -0
  168. package/dist/cli/register-mutation.js +210 -40
  169. package/dist/cli/register-mutation.js.map +1 -1
  170. package/dist/cli/register-operations.d.ts +8 -0
  171. package/dist/cli/register-operations.js +33 -11
  172. package/dist/cli/register-operations.js.map +1 -1
  173. package/dist/cli/register-setup.js +9 -6
  174. package/dist/cli/register-setup.js.map +1 -1
  175. package/dist/cli/registration-helpers.d.ts +4 -0
  176. package/dist/cli/registration-helpers.js +124 -38
  177. package/dist/cli/registration-helpers.js.map +1 -1
  178. package/dist/cli-bundle/chunks/activity-5P2KQCTH.js +18 -0
  179. package/dist/cli-bundle/chunks/{activity-PPO7QWJF.js → activity-MJGTX4LO.js} +13 -11
  180. package/dist/cli-bundle/chunks/{aggregate-XEBW22UQ.js → aggregate-MH3GROKB.js} +54 -25
  181. package/dist/cli-bundle/chunks/aggregate-MH3GROKB.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{aggregate-IRHJWEKG.js → aggregate-OUGCDFNC.js} +55 -26
  183. package/dist/cli-bundle/chunks/aggregate-OUGCDFNC.js.map +1 -0
  184. package/dist/cli-bundle/chunks/{append-N2AWXKZC.js → append-2Q4BPUBW.js} +10 -10
  185. package/dist/cli-bundle/chunks/{append-N2AWXKZC.js.map → append-2Q4BPUBW.js.map} +2 -2
  186. package/dist/cli-bundle/chunks/{append-NL67JNJU.js → append-VCRUG2W6.js} +11 -11
  187. package/dist/cli-bundle/chunks/append-VCRUG2W6.js.map +1 -0
  188. package/dist/cli-bundle/chunks/{chunk-GRZGHGRG.js → chunk-2IUJBMKS.js} +10 -9
  189. package/dist/cli-bundle/chunks/{chunk-GRZGHGRG.js.map → chunk-2IUJBMKS.js.map} +2 -2
  190. package/dist/cli-bundle/chunks/{chunk-6ZFTM65G.js → chunk-2JEGCDYT.js} +2 -2
  191. package/dist/cli-bundle/chunks/{chunk-3CQPVBK3.js → chunk-3WAULYOY.js} +3 -3
  192. package/dist/cli-bundle/chunks/{chunk-AGG32LKL.js → chunk-3XOXWOGA.js} +359 -19
  193. package/dist/cli-bundle/chunks/chunk-3XOXWOGA.js.map +1 -0
  194. package/dist/cli-bundle/chunks/{chunk-XXLMJDUB.js → chunk-4KBK4BA3.js} +13 -15
  195. package/dist/cli-bundle/chunks/chunk-4KBK4BA3.js.map +7 -0
  196. package/dist/cli-bundle/chunks/{chunk-UCVJP4JL.js → chunk-4VLB4JH2.js} +51 -8
  197. package/dist/cli-bundle/chunks/chunk-4VLB4JH2.js.map +7 -0
  198. package/dist/cli-bundle/chunks/{chunk-BVL5KGVA.js → chunk-656HPQPO.js} +27 -12
  199. package/dist/cli-bundle/chunks/chunk-656HPQPO.js.map +1 -0
  200. package/dist/cli-bundle/chunks/{chunk-LYNQ3NGI.js → chunk-667XI4UJ.js} +309 -20
  201. package/dist/cli-bundle/chunks/chunk-667XI4UJ.js.map +1 -0
  202. package/dist/cli-bundle/chunks/{chunk-W6KNFAMZ.js → chunk-6BV7ENQL.js} +9 -8
  203. package/dist/cli-bundle/chunks/chunk-6BV7ENQL.js.map +7 -0
  204. package/dist/cli-bundle/chunks/chunk-6EFCFPNE.js +35 -0
  205. package/dist/cli-bundle/chunks/chunk-6EFCFPNE.js.map +7 -0
  206. package/dist/cli-bundle/chunks/{chunk-7SM7VA5I.js → chunk-6NQXMGYU.js} +19 -8
  207. package/dist/cli-bundle/chunks/chunk-6NQXMGYU.js.map +7 -0
  208. package/dist/cli-bundle/chunks/{chunk-AAUYXSFF.js → chunk-764O7EUA.js} +223 -50
  209. package/dist/cli-bundle/chunks/chunk-764O7EUA.js.map +7 -0
  210. package/dist/cli-bundle/chunks/{chunk-VYZNX4C5.js → chunk-7AGIXLNK.js} +3 -3
  211. package/dist/cli-bundle/chunks/chunk-7EILPFMA.js +404 -0
  212. package/dist/cli-bundle/chunks/chunk-7EILPFMA.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{chunk-L6YQONLM.js → chunk-7K2MXFMX.js} +11 -13
  214. package/dist/cli-bundle/chunks/chunk-7K2MXFMX.js.map +1 -0
  215. package/dist/cli-bundle/chunks/{chunk-HZOX5BYD.js → chunk-7L5VOUYP.js} +6 -17
  216. package/dist/cli-bundle/chunks/chunk-7L5VOUYP.js.map +7 -0
  217. package/dist/cli-bundle/chunks/chunk-7ZGKNHUL.js +61 -0
  218. package/dist/cli-bundle/chunks/chunk-7ZGKNHUL.js.map +7 -0
  219. package/dist/cli-bundle/chunks/{chunk-TOX7YQ7X.js → chunk-A576QZDL.js} +223 -50
  220. package/dist/cli-bundle/chunks/chunk-A576QZDL.js.map +1 -0
  221. package/dist/cli-bundle/chunks/{chunk-RFR2YQGO.js → chunk-AERT7KT3.js} +5 -5
  222. package/dist/cli-bundle/chunks/chunk-ASM4DVRW.js +58 -0
  223. package/dist/cli-bundle/chunks/chunk-ASM4DVRW.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-SQDKAEKG.js → chunk-B5Q7XC4K.js} +117 -37
  225. package/dist/cli-bundle/chunks/chunk-B5Q7XC4K.js.map +7 -0
  226. package/dist/cli-bundle/chunks/{chunk-RHYBR6G7.js → chunk-BJWTFOZM.js} +74 -14
  227. package/dist/cli-bundle/chunks/chunk-BJWTFOZM.js.map +1 -0
  228. package/dist/cli-bundle/chunks/{chunk-4ZKKZMLH.js → chunk-CBMETQ2U.js} +104 -30
  229. package/dist/cli-bundle/chunks/chunk-CBMETQ2U.js.map +1 -0
  230. package/dist/cli-bundle/chunks/{chunk-XOYHMHFF.js → chunk-E6J2PEK6.js} +3 -3
  231. package/dist/cli-bundle/chunks/{chunk-IIOIBAQW.js → chunk-F2GC6L3N.js} +3 -3
  232. package/dist/cli-bundle/chunks/{chunk-3VULHQNS.js → chunk-F7WSO5UX.js} +7 -18
  233. package/dist/cli-bundle/chunks/chunk-F7WSO5UX.js.map +1 -0
  234. package/dist/cli-bundle/chunks/{chunk-JCTZV7TO.js → chunk-FTAZLAR7.js} +8 -5
  235. package/dist/cli-bundle/chunks/{chunk-JCTZV7TO.js.map → chunk-FTAZLAR7.js.map} +1 -1
  236. package/dist/cli-bundle/chunks/{chunk-AUDDXKNX.js → chunk-FXNT5LPX.js} +77 -9
  237. package/dist/cli-bundle/chunks/chunk-FXNT5LPX.js.map +1 -0
  238. package/dist/cli-bundle/chunks/{chunk-IZHCCG4S.js → chunk-G2YVUY7I.js} +14 -9
  239. package/dist/cli-bundle/chunks/chunk-G2YVUY7I.js.map +1 -0
  240. package/dist/cli-bundle/chunks/{chunk-5HSAHRYA.js → chunk-G3CEIXTV.js} +68 -19
  241. package/dist/cli-bundle/chunks/chunk-G3CEIXTV.js.map +7 -0
  242. package/dist/cli-bundle/chunks/{chunk-QQG4HEX7.js → chunk-GAVE4MYM.js} +37 -63
  243. package/dist/cli-bundle/chunks/chunk-GAVE4MYM.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{chunk-3FMQMHAG.js → chunk-GQ4JKNMV.js} +4 -4
  245. package/dist/cli-bundle/chunks/{chunk-3FMQMHAG.js.map → chunk-GQ4JKNMV.js.map} +1 -1
  246. package/dist/cli-bundle/chunks/{chunk-MACCNKSZ.js → chunk-GYMG7AG6.js} +36 -62
  247. package/dist/cli-bundle/chunks/chunk-GYMG7AG6.js.map +7 -0
  248. package/dist/cli-bundle/chunks/{chunk-7CRFV6JR.js → chunk-H6EH6ENJ.js} +362 -22
  249. package/dist/cli-bundle/chunks/chunk-H6EH6ENJ.js.map +7 -0
  250. package/dist/cli-bundle/chunks/{chunk-2J2AH4V5.js → chunk-HDIDUME4.js} +45 -13
  251. package/dist/cli-bundle/chunks/chunk-HDIDUME4.js.map +1 -0
  252. package/dist/cli-bundle/chunks/{chunk-2ANTZBYF.js → chunk-HPELHUTG.js} +122 -45
  253. package/dist/cli-bundle/chunks/chunk-HPELHUTG.js.map +1 -0
  254. package/dist/cli-bundle/chunks/{chunk-VNC2HBL4.js → chunk-II7OGE3V.js} +20 -9
  255. package/dist/cli-bundle/chunks/chunk-II7OGE3V.js.map +1 -0
  256. package/dist/cli-bundle/chunks/{chunk-CEGUH2E5.js → chunk-ILHLIA47.js} +5 -5
  257. package/dist/cli-bundle/chunks/{chunk-CEGUH2E5.js.map → chunk-ILHLIA47.js.map} +1 -1
  258. package/dist/cli-bundle/chunks/{chunk-4TPFXE2R.js → chunk-IMQG4VR3.js} +118 -74
  259. package/dist/cli-bundle/chunks/chunk-IMQG4VR3.js.map +1 -0
  260. package/dist/cli-bundle/chunks/{chunk-MGAQ6KZG.js → chunk-IQVB3YDD.js} +82 -21
  261. package/dist/cli-bundle/chunks/chunk-IQVB3YDD.js.map +7 -0
  262. package/dist/cli-bundle/chunks/{chunk-WLH7X4RN.js → chunk-KQ3LAMDO.js} +45 -13
  263. package/dist/cli-bundle/chunks/chunk-KQ3LAMDO.js.map +7 -0
  264. package/dist/cli-bundle/chunks/{chunk-S2CDTRJ6.js → chunk-KTVETP66.js} +379 -271
  265. package/dist/cli-bundle/chunks/chunk-KTVETP66.js.map +1 -0
  266. package/dist/cli-bundle/chunks/{chunk-36BCSMKP.js → chunk-KZYVTOG5.js} +26 -11
  267. package/dist/cli-bundle/chunks/chunk-KZYVTOG5.js.map +7 -0
  268. package/dist/cli-bundle/chunks/{chunk-XWDZVCBJ.js → chunk-L6FJPOT4.js} +11 -10
  269. package/dist/cli-bundle/chunks/{chunk-XWDZVCBJ.js.map → chunk-L6FJPOT4.js.map} +1 -1
  270. package/dist/cli-bundle/chunks/{chunk-LFW5NQUP.js → chunk-LV5FFQ7M.js} +405 -290
  271. package/dist/cli-bundle/chunks/chunk-LV5FFQ7M.js.map +7 -0
  272. package/dist/cli-bundle/chunks/{chunk-PNYAAB4S.js → chunk-LWGMDLQ6.js} +8 -3
  273. package/dist/cli-bundle/chunks/chunk-LWGMDLQ6.js.map +1 -0
  274. package/dist/cli-bundle/chunks/{chunk-QU3OPNVV.js → chunk-M23HXJL3.js} +2 -2
  275. package/dist/cli-bundle/chunks/{chunk-LSSTKL3Y.js → chunk-MJZUZ2QE.js} +3 -3
  276. package/dist/cli-bundle/chunks/{chunk-LOAR5TKX.js → chunk-NCIBNERT.js} +4 -4
  277. package/dist/cli-bundle/chunks/{chunk-LOAR5TKX.js.map → chunk-NCIBNERT.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{chunk-6TBR5AZ2.js → chunk-NIQHNDBZ.js} +76 -8
  279. package/dist/cli-bundle/chunks/chunk-NIQHNDBZ.js.map +7 -0
  280. package/dist/cli-bundle/chunks/{chunk-Z647PYLD.js → chunk-O46LTCXQ.js} +4 -4
  281. package/dist/cli-bundle/chunks/{chunk-GFBEXDCQ.js → chunk-OCTQJP42.js} +19 -8
  282. package/dist/cli-bundle/chunks/{chunk-GFBEXDCQ.js.map → chunk-OCTQJP42.js.map} +2 -2
  283. package/dist/cli-bundle/chunks/{chunk-HLEGAQXT.js → chunk-OLTYNVJR.js} +5 -5
  284. package/dist/cli-bundle/chunks/{chunk-IXVSSHGV.js → chunk-OY3P2I6B.js} +13 -8
  285. package/dist/cli-bundle/chunks/chunk-OY3P2I6B.js.map +7 -0
  286. package/dist/cli-bundle/chunks/{chunk-KHGTYCJ6.js → chunk-PZD7WPUC.js} +69 -20
  287. package/dist/cli-bundle/chunks/chunk-PZD7WPUC.js.map +1 -0
  288. package/dist/cli-bundle/chunks/{chunk-4FHLNNW7.js → chunk-Q5RLUCP3.js} +74 -14
  289. package/dist/cli-bundle/chunks/chunk-Q5RLUCP3.js.map +7 -0
  290. package/dist/cli-bundle/chunks/{chunk-SOHXUA2Q.js → chunk-RKKIH2ZQ.js} +116 -36
  291. package/dist/cli-bundle/chunks/chunk-RKKIH2ZQ.js.map +1 -0
  292. package/dist/cli-bundle/chunks/{chunk-O3YCJOVX.js → chunk-SPYPC5CB.js} +3 -3
  293. package/dist/cli-bundle/chunks/{chunk-O3YCJOVX.js.map → chunk-SPYPC5CB.js.map} +1 -1
  294. package/dist/cli-bundle/chunks/{chunk-SGMGMCIF.js → chunk-SY4GKIWT.js} +82 -21
  295. package/dist/cli-bundle/chunks/chunk-SY4GKIWT.js.map +1 -0
  296. package/dist/cli-bundle/chunks/{chunk-5LMF75Q7.js → chunk-SY4PZWIZ.js} +7 -4
  297. package/dist/cli-bundle/chunks/{chunk-5LMF75Q7.js.map → chunk-SY4PZWIZ.js.map} +2 -2
  298. package/dist/cli-bundle/chunks/{chunk-HWHONML5.js → chunk-T5VU7ROQ.js} +4 -4
  299. package/dist/cli-bundle/chunks/{chunk-JWXTOYBI.js → chunk-TIRZIQRP.js} +121 -44
  300. package/dist/cli-bundle/chunks/chunk-TIRZIQRP.js.map +7 -0
  301. package/dist/cli-bundle/chunks/{chunk-PEH7SZD2.js → chunk-TUB3DZAZ.js} +105 -31
  302. package/dist/cli-bundle/chunks/chunk-TUB3DZAZ.js.map +7 -0
  303. package/dist/cli-bundle/chunks/chunk-UAR2VNCK.js +394 -0
  304. package/dist/cli-bundle/chunks/chunk-UAR2VNCK.js.map +1 -0
  305. package/dist/cli-bundle/chunks/{chunk-NN6RKGFW.js → chunk-UBMCSJXX.js} +3 -3
  306. package/dist/cli-bundle/chunks/{chunk-JE5IZXDS.js → chunk-UUKORJSN.js} +4 -4
  307. package/dist/cli-bundle/chunks/{chunk-R4VWYWRN.js → chunk-W3HFLORZ.js} +7 -2
  308. package/dist/cli-bundle/chunks/chunk-W3HFLORZ.js.map +7 -0
  309. package/dist/cli-bundle/chunks/{chunk-LGOXXQUW.js → chunk-WZCQVABQ.js} +2 -2
  310. package/dist/cli-bundle/chunks/chunk-X3W5ESZQ.js +32 -0
  311. package/dist/cli-bundle/chunks/chunk-X3W5ESZQ.js.map +1 -0
  312. package/dist/cli-bundle/chunks/{chunk-M3SI2REU.js → chunk-XLNNCKTN.js} +322 -19
  313. package/dist/cli-bundle/chunks/chunk-XLNNCKTN.js.map +7 -0
  314. package/dist/cli-bundle/chunks/{chunk-4JHJ7YG2.js → chunk-XNOY7TCB.js} +118 -74
  315. package/dist/cli-bundle/chunks/chunk-XNOY7TCB.js.map +7 -0
  316. package/dist/cli-bundle/chunks/{chunk-DWG4FHPY.js → chunk-YGRPBFMA.js} +2 -2
  317. package/dist/cli-bundle/chunks/{chunk-JW7D6437.js → chunk-YXTLI4XP.js} +20 -9
  318. package/dist/cli-bundle/chunks/chunk-YXTLI4XP.js.map +1 -0
  319. package/dist/cli-bundle/chunks/{chunk-TSXWFN3L.js → chunk-Z3MUNQRV.js} +52 -9
  320. package/dist/cli-bundle/chunks/chunk-Z3MUNQRV.js.map +1 -0
  321. package/dist/cli-bundle/chunks/{chunk-GOO4UXBI.js → chunk-ZJRDVYZI.js} +4 -4
  322. package/dist/cli-bundle/chunks/{chunk-32XSW44C.js → chunk-ZONXMSVB.js} +10 -9
  323. package/dist/cli-bundle/chunks/chunk-ZONXMSVB.js.map +1 -0
  324. package/dist/cli-bundle/chunks/{claim-QJOQBH7J.js → claim-4APLUXJW.js} +10 -10
  325. package/dist/cli-bundle/chunks/{claim-HE6KEGJW.js → claim-NEO7AGWH.js} +10 -10
  326. package/dist/cli-bundle/chunks/{close-SPUFW5QR.js → close-3QABBNGU.js} +8 -8
  327. package/dist/cli-bundle/chunks/close-ILMZR3D7.js +13 -0
  328. package/dist/cli-bundle/chunks/{close-many-GKAJX54X.js → close-many-MIZLTYGL.js} +32 -20
  329. package/dist/cli-bundle/chunks/close-many-MIZLTYGL.js.map +1 -0
  330. package/dist/cli-bundle/chunks/{close-many-GL6NRUU5.js → close-many-Q7Y5AHQI.js} +31 -19
  331. package/dist/cli-bundle/chunks/close-many-Q7Y5AHQI.js.map +7 -0
  332. package/dist/cli-bundle/chunks/{comments-5FPT6L7N.js → comments-DAIQPOMU.js} +55 -31
  333. package/dist/cli-bundle/chunks/comments-DAIQPOMU.js.map +1 -0
  334. package/dist/cli-bundle/chunks/{comments-TOLOYWNI.js → comments-IWFSVM4P.js} +54 -30
  335. package/dist/cli-bundle/chunks/comments-IWFSVM4P.js.map +7 -0
  336. package/dist/cli-bundle/chunks/{config-4MN45TIH.js → config-IOJELD6O.js} +45 -19
  337. package/dist/cli-bundle/chunks/config-IOJELD6O.js.map +1 -0
  338. package/dist/cli-bundle/chunks/{config-7N6D7YJE.js → config-PXTMAYV3.js} +44 -18
  339. package/dist/cli-bundle/chunks/config-PXTMAYV3.js.map +7 -0
  340. package/dist/cli-bundle/chunks/{context-AQSLE7DZ.js → context-QHJSCJW4.js} +128 -39
  341. package/dist/cli-bundle/chunks/context-QHJSCJW4.js.map +1 -0
  342. package/dist/cli-bundle/chunks/{context-U3PUJMVN.js → context-XZS2VFKU.js} +127 -38
  343. package/dist/cli-bundle/chunks/context-XZS2VFKU.js.map +7 -0
  344. package/dist/cli-bundle/chunks/{contracts-ITSJXO3O.js → contracts-B7U4OJTV.js} +54 -10
  345. package/dist/cli-bundle/chunks/contracts-B7U4OJTV.js.map +1 -0
  346. package/dist/cli-bundle/chunks/{contracts-H7KCQXLY.js → contracts-NSBVLXQ3.js} +54 -10
  347. package/dist/cli-bundle/chunks/contracts-NSBVLXQ3.js.map +7 -0
  348. package/dist/cli-bundle/chunks/{copy-EB3MUCSW.js → copy-Q64T5FD4.js} +7 -7
  349. package/dist/cli-bundle/chunks/{copy-C4W522JM.js → copy-SG34LCMU.js} +7 -7
  350. package/dist/cli-bundle/chunks/create-F5HZX2S4.js +30 -0
  351. package/dist/cli-bundle/chunks/{create-4EQNELMY.js → create-IPAX2SNL.js} +16 -13
  352. package/dist/cli-bundle/chunks/{delete-ZLGUYIXU.js → delete-TLXR7LJ2.js} +7 -7
  353. package/dist/cli-bundle/chunks/{delete-X5QLXIQX.js → delete-VH3L7DZ6.js} +7 -7
  354. package/dist/cli-bundle/chunks/{deps-GPB3LGWN.js → deps-J3HBBLDB.js} +9 -10
  355. package/dist/cli-bundle/chunks/{deps-GPB3LGWN.js.map → deps-J3HBBLDB.js.map} +2 -2
  356. package/dist/cli-bundle/chunks/{deps-HV2C2L46.js → deps-XV6JJ6IN.js} +10 -11
  357. package/dist/cli-bundle/chunks/deps-XV6JJ6IN.js.map +1 -0
  358. package/dist/cli-bundle/chunks/{docs-SRTLCQOL.js → docs-GWDEB7JH.js} +9 -9
  359. package/dist/cli-bundle/chunks/{docs-RJQPLROO.js → docs-RCLNSKID.js} +9 -9
  360. package/dist/cli-bundle/chunks/{extension-MM3TVWOO.js → extension-5RN65LHT.js} +7 -5
  361. package/dist/cli-bundle/chunks/{extension-WKPVPNCC.js → extension-7KO2NX2A.js} +7 -5
  362. package/dist/cli-bundle/chunks/{files-OIFN3DQX.js → files-3TCQHUHA.js} +25 -11
  363. package/dist/cli-bundle/chunks/files-3TCQHUHA.js.map +1 -0
  364. package/dist/cli-bundle/chunks/{files-LIFDKNCN.js → files-5FDUPSEA.js} +24 -10
  365. package/dist/cli-bundle/chunks/files-5FDUPSEA.js.map +7 -0
  366. package/dist/cli-bundle/chunks/focus-7AQMNRSU.js +109 -0
  367. package/dist/cli-bundle/chunks/focus-7AQMNRSU.js.map +7 -0
  368. package/dist/cli-bundle/chunks/focus-HQXBYPKM.js +106 -0
  369. package/dist/cli-bundle/chunks/focus-HQXBYPKM.js.map +1 -0
  370. package/dist/cli-bundle/chunks/{gc-DL6AVOX5.js → gc-2FGKYRJ4.js} +3 -3
  371. package/dist/cli-bundle/chunks/{gc-NRFHLVFT.js → gc-5B6ABL3Z.js} +3 -3
  372. package/dist/cli-bundle/chunks/{get-SAB7CRBG.js → get-FUMVOJQD.js} +43 -16
  373. package/dist/cli-bundle/chunks/get-FUMVOJQD.js.map +1 -0
  374. package/dist/cli-bundle/chunks/{get-K7UULTQF.js → get-H5BZTW4A.js} +42 -15
  375. package/dist/cli-bundle/chunks/get-H5BZTW4A.js.map +7 -0
  376. package/dist/cli-bundle/chunks/{health-NUVZYIEV.js → health-JSVOR6B4.js} +75 -49
  377. package/dist/cli-bundle/chunks/health-JSVOR6B4.js.map +1 -0
  378. package/dist/cli-bundle/chunks/{health-VJWH3ZFK.js → health-LE2ZQGSM.js} +74 -48
  379. package/dist/cli-bundle/chunks/health-LE2ZQGSM.js.map +7 -0
  380. package/dist/cli-bundle/chunks/{history-GYFD2DJW.js → history-QO4JVJJP.js} +10 -10
  381. package/dist/cli-bundle/chunks/history-SSXGGTVZ.js +20 -0
  382. package/dist/cli-bundle/chunks/{history-compact-WQZQ6KXM.js → history-compact-ID74DOUI.js} +37 -46
  383. package/dist/cli-bundle/chunks/history-compact-ID74DOUI.js.map +7 -0
  384. package/dist/cli-bundle/chunks/{history-compact-SLL6ESXH.js → history-compact-SDFRPZ4V.js} +38 -47
  385. package/dist/cli-bundle/chunks/history-compact-SDFRPZ4V.js.map +1 -0
  386. package/dist/cli-bundle/chunks/history-redact-VBH44Y7F.js +21 -0
  387. package/dist/cli-bundle/chunks/{history-redact-SDTDR6WM.js → history-redact-Z4P5MM3G.js} +13 -11
  388. package/dist/cli-bundle/chunks/{history-repair-UCYS55ZX.js → history-repair-ANHEYWKF.js} +43 -48
  389. package/dist/cli-bundle/chunks/history-repair-ANHEYWKF.js.map +7 -0
  390. package/dist/cli-bundle/chunks/{history-repair-BJCGM6Q3.js → history-repair-CKE7GLZR.js} +44 -49
  391. package/dist/cli-bundle/chunks/history-repair-CKE7GLZR.js.map +1 -0
  392. package/dist/cli-bundle/chunks/init-7FBQO77A.js +19 -0
  393. package/dist/cli-bundle/chunks/{init-MXV57LKL.js → init-K6MSMB37.js} +11 -9
  394. package/dist/cli-bundle/chunks/{learnings-QKJOKEAO.js → learnings-VIS3NOQV.js} +13 -12
  395. package/dist/cli-bundle/chunks/learnings-VIS3NOQV.js.map +7 -0
  396. package/dist/cli-bundle/chunks/{learnings-L6KTZGOT.js → learnings-YYNB64GN.js} +14 -13
  397. package/dist/cli-bundle/chunks/learnings-YYNB64GN.js.map +1 -0
  398. package/dist/cli-bundle/chunks/list-7UE44A2R.js +29 -0
  399. package/dist/cli-bundle/chunks/list-UHMA3N2K.js +33 -0
  400. package/dist/cli-bundle/chunks/{notes-3NLK7WTZ.js → notes-2HRMV67I.js} +14 -13
  401. package/dist/cli-bundle/chunks/notes-2HRMV67I.js.map +1 -0
  402. package/dist/cli-bundle/chunks/{notes-HMCB7TK6.js → notes-IN3UMA7W.js} +13 -12
  403. package/dist/cli-bundle/chunks/notes-IN3UMA7W.js.map +7 -0
  404. package/dist/cli-bundle/chunks/{plan-DWBYI5C6.js → plan-I3SVH7FV.js} +16 -15
  405. package/dist/cli-bundle/chunks/plan-I3SVH7FV.js.map +1 -0
  406. package/dist/cli-bundle/chunks/{plan-NANUWH4T.js → plan-PAWCCAPW.js} +15 -14
  407. package/dist/cli-bundle/chunks/plan-PAWCCAPW.js.map +7 -0
  408. package/dist/cli-bundle/chunks/{register-list-query-PWQ5F2VI.js → register-list-query-N7Z7RTDM.js} +31 -22
  409. package/dist/cli-bundle/chunks/register-list-query-N7Z7RTDM.js.map +7 -0
  410. package/dist/cli-bundle/chunks/{register-list-query-SMMMLSWW.js → register-list-query-OTIK4DVA.js} +32 -23
  411. package/dist/cli-bundle/chunks/register-list-query-OTIK4DVA.js.map +1 -0
  412. package/dist/cli-bundle/chunks/{register-mutation-QKFPTIZG.js → register-mutation-UFZK6Q57.js} +216 -66
  413. package/dist/cli-bundle/chunks/register-mutation-UFZK6Q57.js.map +7 -0
  414. package/dist/cli-bundle/chunks/{register-mutation-ZYJQ4DVP.js → register-mutation-XFORLS6D.js} +210 -67
  415. package/dist/cli-bundle/chunks/register-mutation-XFORLS6D.js.map +1 -0
  416. package/dist/cli-bundle/chunks/{register-operations-2FMZ6WEF.js → register-operations-6ZCLKRBG.js} +53 -39
  417. package/dist/cli-bundle/chunks/register-operations-6ZCLKRBG.js.map +7 -0
  418. package/dist/cli-bundle/chunks/{register-operations-BAFQURZG.js → register-operations-ITE7JTH3.js} +54 -40
  419. package/dist/cli-bundle/chunks/register-operations-ITE7JTH3.js.map +1 -0
  420. package/dist/cli-bundle/chunks/{register-setup-QN2XV7UL.js → register-setup-7RKGE4BQ.js} +18 -21
  421. package/dist/cli-bundle/chunks/register-setup-7RKGE4BQ.js.map +1 -0
  422. package/dist/cli-bundle/chunks/{register-setup-DQEIKBIP.js → register-setup-7UKEFKT6.js} +17 -20
  423. package/dist/cli-bundle/chunks/register-setup-7UKEFKT6.js.map +7 -0
  424. package/dist/cli-bundle/chunks/{restore-FJQWXMPY.js → restore-NNVPBBVJ.js} +13 -11
  425. package/dist/cli-bundle/chunks/restore-XXXLQ2XC.js +19 -0
  426. package/dist/cli-bundle/chunks/{schema-RNVJ55V2.js → schema-3HCLXCFX.js} +27 -9
  427. package/dist/cli-bundle/chunks/schema-3HCLXCFX.js.map +7 -0
  428. package/dist/cli-bundle/chunks/{schema-ZZ7ZDM2X.js → schema-3YKCQ3VO.js} +28 -10
  429. package/dist/cli-bundle/chunks/schema-3YKCQ3VO.js.map +1 -0
  430. package/dist/cli-bundle/chunks/{search-BJ457C2A.js → search-NQ42NC6A.js} +328 -71
  431. package/dist/cli-bundle/chunks/search-NQ42NC6A.js.map +7 -0
  432. package/dist/cli-bundle/chunks/{search-FQDZXX7P.js → search-V7PZ2ICH.js} +328 -71
  433. package/dist/cli-bundle/chunks/search-V7PZ2ICH.js.map +1 -0
  434. package/dist/cli-bundle/chunks/{stats-DUQWCVOS.js → stats-7KD4PJC5.js} +41 -16
  435. package/dist/cli-bundle/chunks/stats-7KD4PJC5.js.map +7 -0
  436. package/dist/cli-bundle/chunks/{stats-CUG3ZHOI.js → stats-GRHO6RFB.js} +42 -17
  437. package/dist/cli-bundle/chunks/stats-GRHO6RFB.js.map +1 -0
  438. package/dist/cli-bundle/chunks/{telemetry-33MRGX4Z.js → telemetry-H5GLXNG5.js} +6 -6
  439. package/dist/cli-bundle/chunks/telemetry-H5GLXNG5.js.map +7 -0
  440. package/dist/cli-bundle/chunks/{telemetry-RK2VX75A.js → telemetry-TRRYZXWT.js} +7 -7
  441. package/dist/cli-bundle/chunks/telemetry-TRRYZXWT.js.map +1 -0
  442. package/dist/cli-bundle/chunks/test-6CZNIIGA.js +34 -0
  443. package/dist/cli-bundle/chunks/{test-Y3CTFMEC.js → test-7GVQ3VMN.js} +16 -14
  444. package/dist/cli-bundle/chunks/{test-all-ANYQ33O2.js → test-all-3LF2OZD2.js} +23 -16
  445. package/dist/cli-bundle/chunks/test-all-3LF2OZD2.js.map +7 -0
  446. package/dist/cli-bundle/chunks/{test-all-ARSMX33Q.js → test-all-ODVADHV6.js} +24 -17
  447. package/dist/cli-bundle/chunks/test-all-ODVADHV6.js.map +1 -0
  448. package/dist/cli-bundle/chunks/{test-runs-5URSD34O.js → test-runs-LYT6ZTNQ.js} +62 -65
  449. package/dist/cli-bundle/chunks/test-runs-LYT6ZTNQ.js.map +1 -0
  450. package/dist/cli-bundle/chunks/{test-runs-XNACGSNQ.js → test-runs-RVP6VWN7.js} +61 -64
  451. package/dist/cli-bundle/chunks/test-runs-RVP6VWN7.js.map +7 -0
  452. package/dist/cli-bundle/chunks/update-MPGM6SBE.js +28 -0
  453. package/dist/cli-bundle/chunks/update-UN75XW3C.js +24 -0
  454. package/dist/cli-bundle/chunks/{update-many-6B7PJ33I.js → update-many-FCU6RKTO.js} +80 -34
  455. package/dist/cli-bundle/chunks/update-many-FCU6RKTO.js.map +1 -0
  456. package/dist/cli-bundle/chunks/{update-many-724JCVDE.js → update-many-XSEQJ24X.js} +79 -33
  457. package/dist/cli-bundle/chunks/update-many-XSEQJ24X.js.map +7 -0
  458. package/dist/cli-bundle/chunks/{upgrade-ALBEZAI7.js → upgrade-A6TL3INC.js} +22 -8
  459. package/dist/cli-bundle/chunks/upgrade-A6TL3INC.js.map +7 -0
  460. package/dist/cli-bundle/chunks/{upgrade-QHRGDBSA.js → upgrade-FOB5LHO5.js} +23 -9
  461. package/dist/cli-bundle/chunks/upgrade-FOB5LHO5.js.map +1 -0
  462. package/dist/cli-bundle/chunks/{validate-IQRYFXIV.js → validate-7BLDG3AT.js} +221 -30
  463. package/dist/cli-bundle/chunks/validate-7BLDG3AT.js.map +1 -0
  464. package/dist/cli-bundle/chunks/{validate-UY6DRCG5.js → validate-EHL3MI2V.js} +235 -30
  465. package/dist/cli-bundle/chunks/validate-EHL3MI2V.js.map +7 -0
  466. package/dist/cli-bundle/main.js +270 -139
  467. package/dist/cli-bundle/main.js.map +3 -3
  468. package/dist/cli.d.ts +10 -0
  469. package/dist/cli.js +21 -8
  470. package/dist/cli.js.map +1 -1
  471. package/dist/core/diagnostics/remediation.js +7 -2
  472. package/dist/core/diagnostics/remediation.js.map +1 -1
  473. package/dist/core/extensions/extension-policy.js +14 -15
  474. package/dist/core/extensions/extension-policy.js.map +1 -1
  475. package/dist/core/extensions/item-fields.js +4 -5
  476. package/dist/core/extensions/item-fields.js.map +1 -1
  477. package/dist/core/extensions/loader.d.ts +75 -1
  478. package/dist/core/extensions/loader.js +56 -32
  479. package/dist/core/extensions/loader.js.map +1 -1
  480. package/dist/core/governance/content-fields.d.ts +84 -0
  481. package/dist/core/governance/content-fields.js +182 -0
  482. package/dist/core/governance/content-fields.js.map +1 -0
  483. package/dist/core/governance/issue-codes.d.ts +51 -0
  484. package/dist/core/governance/issue-codes.js +95 -0
  485. package/dist/core/governance/issue-codes.js.map +1 -0
  486. package/dist/core/governance/metadata-coverage.d.ts +168 -0
  487. package/dist/core/governance/metadata-coverage.js +362 -0
  488. package/dist/core/governance/metadata-coverage.js.map +1 -0
  489. package/dist/core/history/history-rewrite.d.ts +22 -0
  490. package/dist/core/history/history-rewrite.js +38 -2
  491. package/dist/core/history/history-rewrite.js.map +1 -1
  492. package/dist/core/history/history.d.ts +7 -0
  493. package/dist/core/history/history.js +6 -2
  494. package/dist/core/history/history.js.map +1 -1
  495. package/dist/core/io/body-file.d.ts +14 -0
  496. package/dist/core/io/body-file.js +47 -0
  497. package/dist/core/io/body-file.js.map +1 -0
  498. package/dist/core/item/item-format.d.ts +46 -1
  499. package/dist/core/item/item-format.js +51 -60
  500. package/dist/core/item/item-format.js.map +1 -1
  501. package/dist/core/item/parse.d.ts +9 -0
  502. package/dist/core/item/parse.js +10 -16
  503. package/dist/core/item/parse.js.map +1 -1
  504. package/dist/core/item/type-registry.d.ts +1 -0
  505. package/dist/core/item/type-registry.js +8 -10
  506. package/dist/core/item/type-registry.js.map +1 -1
  507. package/dist/core/lock/lock.d.ts +26 -0
  508. package/dist/core/lock/lock.js +10 -2
  509. package/dist/core/lock/lock.js.map +1 -1
  510. package/dist/core/output/output.d.ts +7 -0
  511. package/dist/core/output/output.js +6 -2
  512. package/dist/core/output/output.js.map +1 -1
  513. package/dist/core/schema/item-types-file.d.ts +25 -2
  514. package/dist/core/schema/item-types-file.js +78 -6
  515. package/dist/core/schema/item-types-file.js.map +1 -1
  516. package/dist/core/schema/runtime-schema.d.ts +7 -0
  517. package/dist/core/schema/runtime-schema.js +23 -16
  518. package/dist/core/schema/runtime-schema.js.map +1 -1
  519. package/dist/core/search/cache.d.ts +19 -1
  520. package/dist/core/search/cache.js +11 -3
  521. package/dist/core/search/cache.js.map +1 -1
  522. package/dist/core/search/corpus.d.ts +36 -2
  523. package/dist/core/search/corpus.js +120 -24
  524. package/dist/core/search/corpus.js.map +1 -1
  525. package/dist/core/search/providers.d.ts +19 -0
  526. package/dist/core/search/providers.js +19 -2
  527. package/dist/core/search/providers.js.map +1 -1
  528. package/dist/core/sentry/instrument.d.ts +1 -0
  529. package/dist/core/sentry/instrument.js +6 -2
  530. package/dist/core/sentry/instrument.js.map +1 -1
  531. package/dist/core/session/session-state.d.ts +16 -0
  532. package/dist/core/session/session-state.js +48 -0
  533. package/dist/core/session/session-state.js.map +1 -0
  534. package/dist/core/shared/constants.d.ts +8 -0
  535. package/dist/core/shared/constants.js +11 -2
  536. package/dist/core/shared/constants.js.map +1 -1
  537. package/dist/core/shared/text-normalization.js +4 -3
  538. package/dist/core/shared/text-normalization.js.map +1 -1
  539. package/dist/core/shared/time.d.ts +13 -0
  540. package/dist/core/shared/time.js +19 -7
  541. package/dist/core/shared/time.js.map +1 -1
  542. package/dist/core/store/item-store.d.ts +11 -0
  543. package/dist/core/store/item-store.js +12 -3
  544. package/dist/core/store/item-store.js.map +1 -1
  545. package/dist/core/store/settings-validator.d.ts +2 -0
  546. package/dist/core/store/settings-validator.js +25 -2
  547. package/dist/core/store/settings-validator.js.map +1 -1
  548. package/dist/core/store/settings.d.ts +60 -1
  549. package/dist/core/store/settings.js +100 -46
  550. package/dist/core/store/settings.js.map +1 -1
  551. package/dist/core/telemetry/observability.js +10 -8
  552. package/dist/core/telemetry/observability.js.map +1 -1
  553. package/dist/core/telemetry/runtime.d.ts +272 -1
  554. package/dist/core/telemetry/runtime.js +358 -37
  555. package/dist/core/telemetry/runtime.js.map +1 -1
  556. package/dist/core/test/background-runs.d.ts +35 -0
  557. package/dist/core/test/background-runs.js +72 -61
  558. package/dist/core/test/background-runs.js.map +1 -1
  559. package/dist/core/test/run-selectors.js +5 -4
  560. package/dist/core/test/run-selectors.js.map +1 -1
  561. package/dist/core/validate/estimate-defaults.d.ts +39 -0
  562. package/dist/core/validate/estimate-defaults.js +117 -0
  563. package/dist/core/validate/estimate-defaults.js.map +1 -0
  564. package/dist/core/validate/fix-planning.d.ts +21 -3
  565. package/dist/core/validate/fix-planning.js +31 -4
  566. package/dist/core/validate/fix-planning.js.map +1 -1
  567. package/dist/core/validate/missing-link-owners.d.ts +64 -0
  568. package/dist/core/validate/missing-link-owners.js +98 -0
  569. package/dist/core/validate/missing-link-owners.js.map +1 -0
  570. package/dist/mcp/server.d.ts +61 -0
  571. package/dist/mcp/server.js +50 -7
  572. package/dist/mcp/server.js.map +1 -1
  573. package/dist/mcp/tool-definitions.js +17 -4
  574. package/dist/mcp/tool-definitions.js.map +1 -1
  575. package/dist/sdk/cli-contracts/commander-types.js +13 -2
  576. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  577. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  578. package/dist/sdk/cli-contracts/enum-contracts.js +4 -2
  579. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  580. package/dist/sdk/cli-contracts/tool-option-contracts.js +110 -2
  581. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  582. package/dist/sdk/cli-contracts/tool-parameter-tables.js +83 -8
  583. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  584. package/dist/sdk/cli-contracts.d.ts +28 -0
  585. package/dist/sdk/cli-contracts.js +164 -11
  586. package/dist/sdk/cli-contracts.js.map +1 -1
  587. package/dist/types.d.ts +17 -1
  588. package/dist/types.js +3 -3
  589. package/dist/types.js.map +1 -1
  590. package/docs/AGENT_GUIDE.md +15 -3
  591. package/docs/CLAUDE_CODE_PLUGIN.md +2 -2
  592. package/docs/COMMANDS.md +136 -7
  593. package/docs/CONFIGURATION.md +52 -0
  594. package/docs/TESTING.md +6 -4
  595. package/package.json +6 -4
  596. package/packages/pm-calendar/extensions/calendar/runtime.js +6 -0
  597. package/packages/pm-calendar/extensions/calendar/runtime.ts +12 -0
  598. package/packages/pm-todos/extensions/todos/runtime.ts +5 -0
  599. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  600. package/plugins/pm-claude/README.md +3 -3
  601. package/plugins/pm-claude/commands/pm-init.md +1 -1
  602. package/plugins/pm-codex/README.md +1 -1
  603. package/scripts/bundle-cli.mjs +46 -37
  604. package/scripts/finalize-build.mjs +20 -9
  605. package/scripts/prepare-build-cache.mjs +27 -16
  606. package/dist/cli-bundle/chunks/activity-XIOTGZMU.js +0 -16
  607. package/dist/cli-bundle/chunks/aggregate-IRHJWEKG.js.map +0 -1
  608. package/dist/cli-bundle/chunks/aggregate-XEBW22UQ.js.map +0 -7
  609. package/dist/cli-bundle/chunks/append-NL67JNJU.js.map +0 -1
  610. package/dist/cli-bundle/chunks/chunk-2ANTZBYF.js.map +0 -1
  611. package/dist/cli-bundle/chunks/chunk-2J2AH4V5.js.map +0 -1
  612. package/dist/cli-bundle/chunks/chunk-32XSW44C.js.map +0 -1
  613. package/dist/cli-bundle/chunks/chunk-36BCSMKP.js.map +0 -7
  614. package/dist/cli-bundle/chunks/chunk-3VULHQNS.js.map +0 -1
  615. package/dist/cli-bundle/chunks/chunk-4FHLNNW7.js.map +0 -7
  616. package/dist/cli-bundle/chunks/chunk-4JHJ7YG2.js.map +0 -7
  617. package/dist/cli-bundle/chunks/chunk-4TPFXE2R.js.map +0 -1
  618. package/dist/cli-bundle/chunks/chunk-4ZKKZMLH.js.map +0 -1
  619. package/dist/cli-bundle/chunks/chunk-5HSAHRYA.js.map +0 -7
  620. package/dist/cli-bundle/chunks/chunk-6TBR5AZ2.js.map +0 -7
  621. package/dist/cli-bundle/chunks/chunk-7CRFV6JR.js.map +0 -7
  622. package/dist/cli-bundle/chunks/chunk-7SM7VA5I.js.map +0 -7
  623. package/dist/cli-bundle/chunks/chunk-AAUYXSFF.js.map +0 -7
  624. package/dist/cli-bundle/chunks/chunk-AGG32LKL.js.map +0 -1
  625. package/dist/cli-bundle/chunks/chunk-AUDDXKNX.js.map +0 -1
  626. package/dist/cli-bundle/chunks/chunk-BVL5KGVA.js.map +0 -1
  627. package/dist/cli-bundle/chunks/chunk-C24PWDFG.js +0 -138
  628. package/dist/cli-bundle/chunks/chunk-C24PWDFG.js.map +0 -7
  629. package/dist/cli-bundle/chunks/chunk-HZOX5BYD.js.map +0 -7
  630. package/dist/cli-bundle/chunks/chunk-IXVSSHGV.js.map +0 -7
  631. package/dist/cli-bundle/chunks/chunk-IZHCCG4S.js.map +0 -1
  632. package/dist/cli-bundle/chunks/chunk-JW7D6437.js.map +0 -1
  633. package/dist/cli-bundle/chunks/chunk-JWXTOYBI.js.map +0 -7
  634. package/dist/cli-bundle/chunks/chunk-KHGTYCJ6.js.map +0 -1
  635. package/dist/cli-bundle/chunks/chunk-L6YQONLM.js.map +0 -1
  636. package/dist/cli-bundle/chunks/chunk-LFW5NQUP.js.map +0 -7
  637. package/dist/cli-bundle/chunks/chunk-LYNQ3NGI.js.map +0 -1
  638. package/dist/cli-bundle/chunks/chunk-M3SI2REU.js.map +0 -7
  639. package/dist/cli-bundle/chunks/chunk-MACCNKSZ.js.map +0 -7
  640. package/dist/cli-bundle/chunks/chunk-MGAQ6KZG.js.map +0 -7
  641. package/dist/cli-bundle/chunks/chunk-PEH7SZD2.js.map +0 -7
  642. package/dist/cli-bundle/chunks/chunk-PNYAAB4S.js.map +0 -1
  643. package/dist/cli-bundle/chunks/chunk-QQG4HEX7.js.map +0 -1
  644. package/dist/cli-bundle/chunks/chunk-R4VWYWRN.js.map +0 -7
  645. package/dist/cli-bundle/chunks/chunk-RHYBR6G7.js.map +0 -1
  646. package/dist/cli-bundle/chunks/chunk-S2CDTRJ6.js.map +0 -1
  647. package/dist/cli-bundle/chunks/chunk-SGMGMCIF.js.map +0 -1
  648. package/dist/cli-bundle/chunks/chunk-SOHXUA2Q.js.map +0 -1
  649. package/dist/cli-bundle/chunks/chunk-SQDKAEKG.js.map +0 -7
  650. package/dist/cli-bundle/chunks/chunk-TOX7YQ7X.js.map +0 -1
  651. package/dist/cli-bundle/chunks/chunk-TSXWFN3L.js.map +0 -1
  652. package/dist/cli-bundle/chunks/chunk-UCVJP4JL.js.map +0 -7
  653. package/dist/cli-bundle/chunks/chunk-V4KP3TCN.js +0 -128
  654. package/dist/cli-bundle/chunks/chunk-V4KP3TCN.js.map +0 -1
  655. package/dist/cli-bundle/chunks/chunk-VNC2HBL4.js.map +0 -1
  656. package/dist/cli-bundle/chunks/chunk-W6KNFAMZ.js.map +0 -7
  657. package/dist/cli-bundle/chunks/chunk-WLH7X4RN.js.map +0 -7
  658. package/dist/cli-bundle/chunks/chunk-XXLMJDUB.js.map +0 -7
  659. package/dist/cli-bundle/chunks/close-WOG5WTMZ.js +0 -13
  660. package/dist/cli-bundle/chunks/close-many-GKAJX54X.js.map +0 -1
  661. package/dist/cli-bundle/chunks/close-many-GL6NRUU5.js.map +0 -7
  662. package/dist/cli-bundle/chunks/comments-5FPT6L7N.js.map +0 -1
  663. package/dist/cli-bundle/chunks/comments-TOLOYWNI.js.map +0 -7
  664. package/dist/cli-bundle/chunks/config-4MN45TIH.js.map +0 -1
  665. package/dist/cli-bundle/chunks/config-7N6D7YJE.js.map +0 -7
  666. package/dist/cli-bundle/chunks/context-AQSLE7DZ.js.map +0 -1
  667. package/dist/cli-bundle/chunks/context-U3PUJMVN.js.map +0 -7
  668. package/dist/cli-bundle/chunks/contracts-H7KCQXLY.js.map +0 -7
  669. package/dist/cli-bundle/chunks/contracts-ITSJXO3O.js.map +0 -1
  670. package/dist/cli-bundle/chunks/create-NW3K7LVG.js +0 -27
  671. package/dist/cli-bundle/chunks/deps-HV2C2L46.js.map +0 -1
  672. package/dist/cli-bundle/chunks/files-LIFDKNCN.js.map +0 -7
  673. package/dist/cli-bundle/chunks/files-OIFN3DQX.js.map +0 -1
  674. package/dist/cli-bundle/chunks/get-K7UULTQF.js.map +0 -7
  675. package/dist/cli-bundle/chunks/get-SAB7CRBG.js.map +0 -1
  676. package/dist/cli-bundle/chunks/health-NUVZYIEV.js.map +0 -1
  677. package/dist/cli-bundle/chunks/health-VJWH3ZFK.js.map +0 -7
  678. package/dist/cli-bundle/chunks/history-IUVN4NTN.js +0 -20
  679. package/dist/cli-bundle/chunks/history-compact-SLL6ESXH.js.map +0 -1
  680. package/dist/cli-bundle/chunks/history-compact-WQZQ6KXM.js.map +0 -7
  681. package/dist/cli-bundle/chunks/history-redact-75KIIJUJ.js +0 -19
  682. package/dist/cli-bundle/chunks/history-repair-BJCGM6Q3.js.map +0 -1
  683. package/dist/cli-bundle/chunks/history-repair-UCYS55ZX.js.map +0 -7
  684. package/dist/cli-bundle/chunks/init-JJFYRUKG.js +0 -17
  685. package/dist/cli-bundle/chunks/learnings-L6KTZGOT.js.map +0 -1
  686. package/dist/cli-bundle/chunks/learnings-QKJOKEAO.js.map +0 -7
  687. package/dist/cli-bundle/chunks/list-GGVPXEV6.js +0 -23
  688. package/dist/cli-bundle/chunks/list-VOQDQHA4.js +0 -19
  689. package/dist/cli-bundle/chunks/notes-3NLK7WTZ.js.map +0 -1
  690. package/dist/cli-bundle/chunks/notes-HMCB7TK6.js.map +0 -7
  691. package/dist/cli-bundle/chunks/plan-DWBYI5C6.js.map +0 -1
  692. package/dist/cli-bundle/chunks/plan-NANUWH4T.js.map +0 -7
  693. package/dist/cli-bundle/chunks/register-list-query-PWQ5F2VI.js.map +0 -7
  694. package/dist/cli-bundle/chunks/register-list-query-SMMMLSWW.js.map +0 -1
  695. package/dist/cli-bundle/chunks/register-mutation-QKFPTIZG.js.map +0 -7
  696. package/dist/cli-bundle/chunks/register-mutation-ZYJQ4DVP.js.map +0 -1
  697. package/dist/cli-bundle/chunks/register-operations-2FMZ6WEF.js.map +0 -7
  698. package/dist/cli-bundle/chunks/register-operations-BAFQURZG.js.map +0 -1
  699. package/dist/cli-bundle/chunks/register-setup-DQEIKBIP.js.map +0 -7
  700. package/dist/cli-bundle/chunks/register-setup-QN2XV7UL.js.map +0 -1
  701. package/dist/cli-bundle/chunks/restore-DRBNXJJH.js +0 -17
  702. package/dist/cli-bundle/chunks/schema-RNVJ55V2.js.map +0 -7
  703. package/dist/cli-bundle/chunks/schema-ZZ7ZDM2X.js.map +0 -1
  704. package/dist/cli-bundle/chunks/search-BJ457C2A.js.map +0 -7
  705. package/dist/cli-bundle/chunks/search-FQDZXX7P.js.map +0 -1
  706. package/dist/cli-bundle/chunks/stats-CUG3ZHOI.js.map +0 -1
  707. package/dist/cli-bundle/chunks/stats-DUQWCVOS.js.map +0 -7
  708. package/dist/cli-bundle/chunks/telemetry-33MRGX4Z.js.map +0 -7
  709. package/dist/cli-bundle/chunks/telemetry-RK2VX75A.js.map +0 -1
  710. package/dist/cli-bundle/chunks/test-SDMYEQHH.js +0 -32
  711. package/dist/cli-bundle/chunks/test-all-ANYQ33O2.js.map +0 -7
  712. package/dist/cli-bundle/chunks/test-all-ARSMX33Q.js.map +0 -1
  713. package/dist/cli-bundle/chunks/test-runs-5URSD34O.js.map +0 -1
  714. package/dist/cli-bundle/chunks/test-runs-XNACGSNQ.js.map +0 -7
  715. package/dist/cli-bundle/chunks/update-PD46VOXI.js +0 -21
  716. package/dist/cli-bundle/chunks/update-U235A7WP.js +0 -25
  717. package/dist/cli-bundle/chunks/update-many-6B7PJ33I.js.map +0 -1
  718. package/dist/cli-bundle/chunks/update-many-724JCVDE.js.map +0 -7
  719. package/dist/cli-bundle/chunks/upgrade-ALBEZAI7.js.map +0 -7
  720. package/dist/cli-bundle/chunks/upgrade-QHRGDBSA.js.map +0 -1
  721. package/dist/cli-bundle/chunks/validate-IQRYFXIV.js.map +0 -1
  722. package/dist/cli-bundle/chunks/validate-UY6DRCG5.js.map +0 -7
  723. /package/dist/cli-bundle/chunks/{activity-XIOTGZMU.js.map → activity-5P2KQCTH.js.map} +0 -0
  724. /package/dist/cli-bundle/chunks/{activity-PPO7QWJF.js.map → activity-MJGTX4LO.js.map} +0 -0
  725. /package/dist/cli-bundle/chunks/{chunk-6ZFTM65G.js.map → chunk-2JEGCDYT.js.map} +0 -0
  726. /package/dist/cli-bundle/chunks/{chunk-3CQPVBK3.js.map → chunk-3WAULYOY.js.map} +0 -0
  727. /package/dist/cli-bundle/chunks/{chunk-VYZNX4C5.js.map → chunk-7AGIXLNK.js.map} +0 -0
  728. /package/dist/cli-bundle/chunks/{chunk-RFR2YQGO.js.map → chunk-AERT7KT3.js.map} +0 -0
  729. /package/dist/cli-bundle/chunks/{chunk-XOYHMHFF.js.map → chunk-E6J2PEK6.js.map} +0 -0
  730. /package/dist/cli-bundle/chunks/{chunk-IIOIBAQW.js.map → chunk-F2GC6L3N.js.map} +0 -0
  731. /package/dist/cli-bundle/chunks/{chunk-QU3OPNVV.js.map → chunk-M23HXJL3.js.map} +0 -0
  732. /package/dist/cli-bundle/chunks/{chunk-LSSTKL3Y.js.map → chunk-MJZUZ2QE.js.map} +0 -0
  733. /package/dist/cli-bundle/chunks/{chunk-Z647PYLD.js.map → chunk-O46LTCXQ.js.map} +0 -0
  734. /package/dist/cli-bundle/chunks/{chunk-HLEGAQXT.js.map → chunk-OLTYNVJR.js.map} +0 -0
  735. /package/dist/cli-bundle/chunks/{chunk-HWHONML5.js.map → chunk-T5VU7ROQ.js.map} +0 -0
  736. /package/dist/cli-bundle/chunks/{chunk-NN6RKGFW.js.map → chunk-UBMCSJXX.js.map} +0 -0
  737. /package/dist/cli-bundle/chunks/{chunk-JE5IZXDS.js.map → chunk-UUKORJSN.js.map} +0 -0
  738. /package/dist/cli-bundle/chunks/{chunk-LGOXXQUW.js.map → chunk-WZCQVABQ.js.map} +0 -0
  739. /package/dist/cli-bundle/chunks/{chunk-DWG4FHPY.js.map → chunk-YGRPBFMA.js.map} +0 -0
  740. /package/dist/cli-bundle/chunks/{chunk-GOO4UXBI.js.map → chunk-ZJRDVYZI.js.map} +0 -0
  741. /package/dist/cli-bundle/chunks/{claim-QJOQBH7J.js.map → claim-4APLUXJW.js.map} +0 -0
  742. /package/dist/cli-bundle/chunks/{claim-HE6KEGJW.js.map → claim-NEO7AGWH.js.map} +0 -0
  743. /package/dist/cli-bundle/chunks/{close-SPUFW5QR.js.map → close-3QABBNGU.js.map} +0 -0
  744. /package/dist/cli-bundle/chunks/{close-WOG5WTMZ.js.map → close-ILMZR3D7.js.map} +0 -0
  745. /package/dist/cli-bundle/chunks/{copy-EB3MUCSW.js.map → copy-Q64T5FD4.js.map} +0 -0
  746. /package/dist/cli-bundle/chunks/{copy-C4W522JM.js.map → copy-SG34LCMU.js.map} +0 -0
  747. /package/dist/cli-bundle/chunks/{create-NW3K7LVG.js.map → create-F5HZX2S4.js.map} +0 -0
  748. /package/dist/cli-bundle/chunks/{create-4EQNELMY.js.map → create-IPAX2SNL.js.map} +0 -0
  749. /package/dist/cli-bundle/chunks/{delete-ZLGUYIXU.js.map → delete-TLXR7LJ2.js.map} +0 -0
  750. /package/dist/cli-bundle/chunks/{delete-X5QLXIQX.js.map → delete-VH3L7DZ6.js.map} +0 -0
  751. /package/dist/cli-bundle/chunks/{docs-SRTLCQOL.js.map → docs-GWDEB7JH.js.map} +0 -0
  752. /package/dist/cli-bundle/chunks/{docs-RJQPLROO.js.map → docs-RCLNSKID.js.map} +0 -0
  753. /package/dist/cli-bundle/chunks/{extension-MM3TVWOO.js.map → extension-5RN65LHT.js.map} +0 -0
  754. /package/dist/cli-bundle/chunks/{extension-WKPVPNCC.js.map → extension-7KO2NX2A.js.map} +0 -0
  755. /package/dist/cli-bundle/chunks/{gc-DL6AVOX5.js.map → gc-2FGKYRJ4.js.map} +0 -0
  756. /package/dist/cli-bundle/chunks/{gc-NRFHLVFT.js.map → gc-5B6ABL3Z.js.map} +0 -0
  757. /package/dist/cli-bundle/chunks/{history-GYFD2DJW.js.map → history-QO4JVJJP.js.map} +0 -0
  758. /package/dist/cli-bundle/chunks/{history-IUVN4NTN.js.map → history-SSXGGTVZ.js.map} +0 -0
  759. /package/dist/cli-bundle/chunks/{history-redact-75KIIJUJ.js.map → history-redact-VBH44Y7F.js.map} +0 -0
  760. /package/dist/cli-bundle/chunks/{history-redact-SDTDR6WM.js.map → history-redact-Z4P5MM3G.js.map} +0 -0
  761. /package/dist/cli-bundle/chunks/{init-JJFYRUKG.js.map → init-7FBQO77A.js.map} +0 -0
  762. /package/dist/cli-bundle/chunks/{init-MXV57LKL.js.map → init-K6MSMB37.js.map} +0 -0
  763. /package/dist/cli-bundle/chunks/{list-VOQDQHA4.js.map → list-7UE44A2R.js.map} +0 -0
  764. /package/dist/cli-bundle/chunks/{list-GGVPXEV6.js.map → list-UHMA3N2K.js.map} +0 -0
  765. /package/dist/cli-bundle/chunks/{restore-FJQWXMPY.js.map → restore-NNVPBBVJ.js.map} +0 -0
  766. /package/dist/cli-bundle/chunks/{restore-DRBNXJJH.js.map → restore-XXXLQ2XC.js.map} +0 -0
  767. /package/dist/cli-bundle/chunks/{test-SDMYEQHH.js.map → test-6CZNIIGA.js.map} +0 -0
  768. /package/dist/cli-bundle/chunks/{test-Y3CTFMEC.js.map → test-7GVQ3VMN.js.map} +0 -0
  769. /package/dist/cli-bundle/chunks/{update-U235A7WP.js.map → update-MPGM6SBE.js.map} +0 -0
  770. /package/dist/cli-bundle/chunks/{update-PD46VOXI.js.map → update-UN75XW3C.js.map} +0 -0
@@ -1,14 +1,13 @@
1
1
  import {
2
- checkHistoryRewriteOwnership,
3
- resolveHistorySubject,
4
- verifyHistoryRewriteNoDrift
5
- } from "./chunk-4JHJ7YG2.js";
2
+ executeHistoryRewrite,
3
+ resolveHistorySubject
4
+ } from "./chunk-XNOY7TCB.js";
6
5
  import {
7
6
  resolveAuthor
8
7
  } from "./chunk-O7IWB35H.js";
9
8
  import {
10
9
  readHistoryEntries
11
- } from "./chunk-GRZGHGRG.js";
10
+ } from "./chunk-2IUJBMKS.js";
12
11
  import {
13
12
  cloneEmptyReplayDocument,
14
13
  historyEntriesToRaw,
@@ -17,21 +16,20 @@ import {
17
16
  toReplayDocument,
18
17
  tryApplyReplayPatch,
19
18
  verifyHistoryChain
20
- } from "./chunk-GOO4UXBI.js";
21
- import "./chunk-VYZNX4C5.js";
19
+ } from "./chunk-ZJRDVYZI.js";
20
+ import "./chunk-7AGIXLNK.js";
22
21
  import {
23
- acquireLock,
24
22
  createHistoryEntry,
25
23
  readLocatedItem
26
- } from "./chunk-XXLMJDUB.js";
27
- import "./chunk-LGOXXQUW.js";
28
- import "./chunk-MACCNKSZ.js";
24
+ } from "./chunk-4KBK4BA3.js";
25
+ import "./chunk-WZCQVABQ.js";
26
+ import "./chunk-GYMG7AG6.js";
29
27
  import {
30
28
  resolveItemTypeRegistry
31
- } from "./chunk-W6KNFAMZ.js";
29
+ } from "./chunk-6BV7ENQL.js";
32
30
  import {
33
31
  nowIso
34
- } from "./chunk-IXVSSHGV.js";
32
+ } from "./chunk-OY3P2I6B.js";
35
33
  import {
36
34
  EXIT_CODE,
37
35
  PmCliError,
@@ -43,14 +41,14 @@ import {
43
41
  resolvePmRoot,
44
42
  runActiveOnWriteHooks,
45
43
  writeFileAtomic
46
- } from "./chunk-LFW5NQUP.js";
44
+ } from "./chunk-LV5FFQ7M.js";
47
45
 
48
46
  // dist/cli/commands/history-compact.js
49
47
  import fs from "node:fs/promises";
50
48
  !(function() {
51
49
  try {
52
50
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
53
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "a55058bd-5e0f-51f5-991c-573cdb9112bb");
51
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "d808735a-4bab-500b-9a34-56e198b409bb");
54
52
  } catch (e2) {
55
53
  }
56
54
  })();
@@ -217,42 +215,35 @@ async function runHistoryCompact(id, options, global2) {
217
215
  throw new PmCliError(`history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(", ")}).`, EXIT_CODE.GENERIC_FAILURE);
218
216
  }
219
217
  if (changed && !dryRun) {
220
- warnings.push(...checkHistoryRewriteOwnership({
221
- itemDocument: loadedItem?.document ?? null,
222
- subjectId: subject.id,
218
+ warnings.push(...await executeHistoryRewrite({
219
+ pmRoot,
220
+ subject,
221
+ settings,
222
+ typeRegistry,
223
+ historyRawBeforeLock,
224
+ currentItemRawBeforeLock,
225
+ operation: "history-compact",
223
226
  author,
224
227
  force: options.force,
225
- settings
226
- }));
227
- const releaseLock = await acquireLock(pmRoot, subject.id, settings.locks.ttl_seconds, author, Boolean(options.force), settings.governance.force_required_for_stale_lock);
228
- try {
229
- const { historyRawUnderLock } = await verifyHistoryRewriteNoDrift({
230
- pmRoot,
231
- subject,
232
- settings,
233
- typeRegistry,
234
- historyRawBeforeLock,
235
- currentItemRawBeforeLock,
236
- operation: "history-compact"
237
- });
238
- try {
239
- await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));
240
- } catch (error) {
241
- if (historyRawUnderLock === null) {
242
- await fs.rm(historyPath, { force: true });
243
- } else {
244
- await writeFileAtomic(historyPath, historyRawUnderLock);
228
+ itemDocument: loadedItem?.document ?? null,
229
+ applyRewrite: async ({ historyRawUnderLock }) => {
230
+ try {
231
+ await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));
232
+ } catch (error) {
233
+ if (historyRawUnderLock === null) {
234
+ await fs.rm(historyPath, { force: true });
235
+ } else {
236
+ await writeFileAtomic(historyPath, historyRawUnderLock);
237
+ }
238
+ throw error;
245
239
  }
246
- throw error;
247
- }
248
- warnings.push(...await runActiveOnWriteHooks({
240
+ },
241
+ applyPostRewrite: async () => runActiveOnWriteHooks({
249
242
  path: historyPath,
250
243
  scope: "project",
251
244
  op: "history_compact:history"
252
- }));
253
- } finally {
254
- await releaseLock();
255
- }
245
+ })
246
+ }));
256
247
  }
257
248
  const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;
258
249
  return {
@@ -287,4 +278,4 @@ async function runHistoryCompact(id, options, global2) {
287
278
  export {
288
279
  runHistoryCompact
289
280
  };
290
- //# sourceMappingURL=history-compact-WQZQ6KXM.js.map
281
+ //# sourceMappingURL=history-compact-ID74DOUI.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../cli/commands/history-compact.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs/promises\";\nimport { createHistoryEntry } from \"../../core/history/history.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n cloneEmptyReplayDocument,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n toReplayDocument,\n tryApplyReplayPatch,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { getActiveExtensionRegistrations, runActiveOnWriteHooks } from \"../../core/extensions/index.js\";\nimport { readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\nexport interface HistoryCompactCommandOptions {\n before?: string;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\ntype HistoryCompactBoundaryKind = \"default\" | \"version\" | \"timestamp\";\n\ninterface HistoryCompactBoundary {\n kind: HistoryCompactBoundaryKind;\n raw: string | null;\n compactCount: number;\n retainedCount: number;\n}\n\nexport interface HistoryCompactResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n compact_boundary: {\n kind: HistoryCompactBoundaryKind;\n before: string | null;\n entries_compacted: number;\n entries_retained: number;\n first_retained_entry: number | null;\n };\n history: {\n path: string;\n entries_scanned: number;\n entries_after: number;\n baseline_entry_added: boolean;\n audit_entry_added: boolean;\n verify_ok: boolean;\n verify_errors: string[];\n };\n item: {\n exists: boolean;\n path: string | null;\n matched_chain_before: boolean | null;\n };\n warnings: string[];\n generated_at: string;\n}\n\nfunction parseBeforeBoundary(before: string | undefined, entries: HistoryEntry[]): HistoryCompactBoundary {\n if (before === undefined) {\n return {\n kind: \"default\",\n raw: null,\n compactCount: entries.length,\n retainedCount: 0,\n };\n }\n\n const raw = before.trim();\n if (raw.length === 0) {\n throw new PmCliError(\"history-compact --before requires a non-empty value.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(raw)) {\n const version = Number.parseInt(raw, 10);\n if (!Number.isSafeInteger(version) || version < 1 || version > entries.length + 1) {\n throw new PmCliError(\n `history-compact --before version must be between 1 and ${entries.length + 1}.`,\n EXIT_CODE.USAGE,\n );\n }\n const compactCount = Math.max(0, Math.min(entries.length, version - 1));\n return {\n kind: \"version\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n }\n\n const beforeTs = Date.parse(raw);\n if (!Number.isFinite(beforeTs)) {\n throw new PmCliError(\n `Invalid history-compact --before value \"${before}\". Use a version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let compactCount = 0;\n for (const [index, entry] of entries.entries()) {\n const entryTs = Date.parse(entry.ts);\n if (!Number.isFinite(entryTs)) {\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 (entryTs >= beforeTs) {\n break;\n }\n compactCount += 1;\n }\n\n return {\n kind: \"timestamp\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n}\n\nfunction applyHistoryPatch(current: ReplayDocument, entry: HistoryEntry, entryNumber: number): ReplayDocument {\n const result = tryApplyReplayPatch(current, entry.patch);\n if (!result.ok) {\n throw new PmCliError(\n `history-compact failed to apply patch at entry ${entryNumber} (op=${entry.op}): ${\n result.error instanceof Error ? result.error.message : String(result.error)\n }`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n return result.document;\n}\n\nfunction replayHistoryAndResolveCheckpoint(\n entries: HistoryEntry[],\n compactCount: number,\n): {\n checkpoint: ReplayDocument;\n finalReplay: ReplayDocument;\n} {\n let replay = cloneEmptyReplayDocument();\n let checkpoint = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n throw new PmCliError(\n `history-compact detected before-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n replay = applyHistoryPatch(replay, entry, index + 1);\n if (replayHash(replay) !== entry.after_hash) {\n throw new PmCliError(\n `history-compact detected after-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (index + 1 === compactCount) {\n checkpoint = structuredClone(replay);\n }\n }\n return {\n checkpoint,\n finalReplay: replay,\n };\n}\n\nfunction reanchorRetainedEntries(\n retainedEntries: HistoryEntry[],\n seed: ReplayDocument,\n retainedEntryOffset: number,\n): {\n entries: HistoryEntry[];\n finalReplay: ReplayDocument;\n} {\n let replay = structuredClone(seed);\n const rewritten: HistoryEntry[] = [];\n for (const [index, entry] of retainedEntries.entries()) {\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(replay, entry, retainedEntryOffset + index + 1);\n rewritten.push({\n ...entry,\n before_hash: beforeHash,\n after_hash: replayHash(replay),\n });\n }\n return {\n entries: rewritten,\n finalReplay: replay,\n };\n}\n\nexport async function runHistoryCompact(\n id: string,\n options: HistoryCompactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n const historyPath = subject.historyPath;\n const historyRawBeforeLock = await readFileIfExists(historyPath);\n if (historyRawBeforeLock === null) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyEntries = await readHistoryEntries(historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to compact.`, EXIT_CODE.USAGE);\n }\n\n const chainVerification = verifyHistoryChain(historyEntries);\n if (!chainVerification.ok) {\n throw new PmCliError(\n `history-compact requires a valid history chain (${chainVerification.errors.join(\", \")}). Run pm history-repair ${subject.id} first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n\n const boundary = parseBeforeBoundary(options.before, historyEntries);\n const changed = boundary.compactCount > 0;\n const dryRun = Boolean(options.dryRun);\n const author = resolveAuthor(options.author, settings.author_default);\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_compact_noop_before_boundary\");\n }\n\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItem?.raw ?? null;\n const matchedChainBefore =\n loadedItem === null\n ? null\n : replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash;\n if (matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n let rewrittenEntries: HistoryEntry[] = historyEntries;\n let baselineEntryAdded = false;\n let auditEntryAdded = false;\n\n if (changed) {\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(historyEntries, boundary.compactCount);\n const retained = historyEntries.slice(boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message:\n boundary.raw === null\n ? `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`\n : `history-compact baseline snapshot before ${boundary.raw}.`,\n });\n rewrittenEntries = [baselineEntry, ...reanchored.entries];\n baselineEntryAdded = true;\n const compactMessage =\n typeof options.message === \"string\" && options.message.trim().length > 0\n ? options.message\n : boundary.raw === null\n ? `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`\n : `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n if (!dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: compactMessage,\n }),\n );\n auditEntryAdded = true;\n }\n }\n\n const rewrittenVerify = verifyHistoryChain(rewrittenEntries);\n if (!rewrittenVerify.ok) {\n throw new PmCliError(\n `history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await executeHistoryRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n operation: \"history-compact\",\n author,\n force: options.force,\n itemDocument: loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) => {\n try {\n await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));\n } catch (error) {\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\n })),\n );\n }\n\n const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n compact_boundary: {\n kind: boundary.kind,\n before: boundary.raw,\n entries_compacted: boundary.compactCount,\n entries_retained: boundary.retainedCount,\n first_retained_entry: firstRetainedEntry,\n },\n history: {\n path: historyPath,\n entries_scanned: historyEntries.length,\n entries_after: rewrittenEntries.length,\n baseline_entry_added: baselineEntryAdded,\n audit_entry_added: auditEntryAdded,\n verify_ok: rewrittenVerify.ok,\n verify_errors: rewrittenVerify.errors,\n },\n item: {\n exists: subject.located !== null,\n path: subject.located?.itemPath ?? null,\n matched_chain_before: matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;;;;;;;;AA0Ef,SAAS,oBAAoB,QAA4B,SAAuB;AAC9E,MAAI,WAAW,QAAW;AACxB,WAAO;MACL,MAAM;MACN,KAAK;MACL,cAAc,QAAQ;MACtB,eAAe;;EAEnB;AAEA,QAAM,MAAM,OAAO,KAAI;AACvB,MAAI,IAAI,WAAW,GAAG;AACpB,UAAM,IAAI,WAAW,wDAAwD,UAAU,KAAK;EAC9F;AAEA,MAAI,QAAQ,KAAK,GAAG,GAAG;AACrB,UAAM,UAAU,OAAO,SAAS,KAAK,EAAE;AACvC,QAAI,CAAC,OAAO,cAAc,OAAO,KAAK,UAAU,KAAK,UAAU,QAAQ,SAAS,GAAG;AACjF,YAAM,IAAI,WACR,0DAA0D,QAAQ,SAAS,CAAC,KAC5E,UAAU,KAAK;IAEnB;AACA,UAAMA,gBAAe,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,QAAQ,UAAU,CAAC,CAAC;AACtE,WAAO;MACL,MAAM;MACN;MACA,cAAAA;MACA,eAAe,QAAQ,SAASA;;EAEpC;AAEA,QAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,MAAI,CAAC,OAAO,SAAS,QAAQ,GAAG;AAC9B,UAAM,IAAI,WACR,2CAA2C,MAAM,6CACjD,UAAU,KAAK;EAEnB;AAEA,MAAI,eAAe;AACnB,aAAW,CAAC,OAAO,KAAK,KAAK,QAAQ,QAAO,GAAI;AAC9C,UAAM,UAAU,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MAC5B,MAAM,QAAQ,SAAS,YAAY;MACnC,sBAAsB;;IAExB,UAAU,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAChF,cAAc,OAAM;;AAExB;",
6
+ "names": ["compactCount", "global"]
7
+ }
@@ -1,16 +1,15 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2bf36f48-8774-58e6-b5c1-d6bea6514888")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aa9aaba1-07f8-54c5-ae45-96ccfa40f4ba")}catch(e){}}();
3
3
  import {
4
- checkHistoryRewriteOwnership,
5
- resolveHistorySubject,
6
- verifyHistoryRewriteNoDrift
7
- } from "./chunk-4TPFXE2R.js";
4
+ executeHistoryRewrite,
5
+ resolveHistorySubject
6
+ } from "./chunk-IMQG4VR3.js";
8
7
  import {
9
8
  resolveAuthor
10
9
  } from "./chunk-J27KIHTG.js";
11
10
  import {
12
11
  readHistoryEntries
13
- } from "./chunk-XWDZVCBJ.js";
12
+ } from "./chunk-L6FJPOT4.js";
14
13
  import {
15
14
  cloneEmptyReplayDocument,
16
15
  historyEntriesToRaw,
@@ -19,21 +18,20 @@ import {
19
18
  toReplayDocument,
20
19
  tryApplyReplayPatch,
21
20
  verifyHistoryChain
22
- } from "./chunk-JE5IZXDS.js";
23
- import "./chunk-NN6RKGFW.js";
21
+ } from "./chunk-UUKORJSN.js";
22
+ import "./chunk-UBMCSJXX.js";
24
23
  import {
25
- acquireLock,
26
24
  createHistoryEntry,
27
25
  readLocatedItem
28
- } from "./chunk-L6YQONLM.js";
29
- import "./chunk-6ZFTM65G.js";
30
- import "./chunk-QQG4HEX7.js";
26
+ } from "./chunk-7K2MXFMX.js";
27
+ import "./chunk-2JEGCDYT.js";
28
+ import "./chunk-GAVE4MYM.js";
31
29
  import {
32
30
  resolveItemTypeRegistry
33
- } from "./chunk-32XSW44C.js";
31
+ } from "./chunk-ZONXMSVB.js";
34
32
  import {
35
33
  nowIso
36
- } from "./chunk-IZHCCG4S.js";
34
+ } from "./chunk-G2YVUY7I.js";
37
35
  import {
38
36
  EXIT_CODE,
39
37
  PmCliError,
@@ -45,7 +43,7 @@ import {
45
43
  resolvePmRoot,
46
44
  runActiveOnWriteHooks,
47
45
  writeFileAtomic
48
- } from "./chunk-S2CDTRJ6.js";
46
+ } from "./chunk-KTVETP66.js";
49
47
 
50
48
  // dist/cli/commands/history-compact.js
51
49
  import fs from "node:fs/promises";
@@ -212,42 +210,35 @@ async function runHistoryCompact(id, options, global) {
212
210
  throw new PmCliError(`history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(", ")}).`, EXIT_CODE.GENERIC_FAILURE);
213
211
  }
214
212
  if (changed && !dryRun) {
215
- warnings.push(...checkHistoryRewriteOwnership({
216
- itemDocument: loadedItem?.document ?? null,
217
- subjectId: subject.id,
213
+ warnings.push(...await executeHistoryRewrite({
214
+ pmRoot,
215
+ subject,
216
+ settings,
217
+ typeRegistry,
218
+ historyRawBeforeLock,
219
+ currentItemRawBeforeLock,
220
+ operation: "history-compact",
218
221
  author,
219
222
  force: options.force,
220
- settings
221
- }));
222
- const releaseLock = await acquireLock(pmRoot, subject.id, settings.locks.ttl_seconds, author, Boolean(options.force), settings.governance.force_required_for_stale_lock);
223
- try {
224
- const { historyRawUnderLock } = await verifyHistoryRewriteNoDrift({
225
- pmRoot,
226
- subject,
227
- settings,
228
- typeRegistry,
229
- historyRawBeforeLock,
230
- currentItemRawBeforeLock,
231
- operation: "history-compact"
232
- });
233
- try {
234
- await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));
235
- } catch (error) {
236
- if (historyRawUnderLock === null) {
237
- await fs.rm(historyPath, { force: true });
238
- } else {
239
- await writeFileAtomic(historyPath, historyRawUnderLock);
223
+ itemDocument: loadedItem?.document ?? null,
224
+ applyRewrite: async ({ historyRawUnderLock }) => {
225
+ try {
226
+ await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));
227
+ } catch (error) {
228
+ if (historyRawUnderLock === null) {
229
+ await fs.rm(historyPath, { force: true });
230
+ } else {
231
+ await writeFileAtomic(historyPath, historyRawUnderLock);
232
+ }
233
+ throw error;
240
234
  }
241
- throw error;
242
- }
243
- warnings.push(...await runActiveOnWriteHooks({
235
+ },
236
+ applyPostRewrite: async () => runActiveOnWriteHooks({
244
237
  path: historyPath,
245
238
  scope: "project",
246
239
  op: "history_compact:history"
247
- }));
248
- } finally {
249
- await releaseLock();
250
- }
240
+ })
241
+ }));
251
242
  }
252
243
  const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;
253
244
  return {
@@ -282,6 +273,6 @@ async function runHistoryCompact(id, options, global) {
282
273
  export {
283
274
  runHistoryCompact
284
275
  };
285
- //# sourceMappingURL=history-compact-SLL6ESXH.js.map
276
+ //# sourceMappingURL=history-compact-SDFRPZ4V.js.map
286
277
 
287
- //# debugId=2bf36f48-8774-58e6-b5c1-d6bea6514888
278
+ //# debugId=aa9aaba1-07f8-54c5-ae45-96ccfa40f4ba
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../cli/commands/history-compact.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport { createHistoryEntry } from \"../../core/history/history.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n cloneEmptyReplayDocument,\n historyEntriesToRaw,\n replayHash,\n replayToItemDocument,\n toReplayDocument,\n tryApplyReplayPatch,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { getActiveExtensionRegistrations, runActiveOnWriteHooks } from \"../../core/extensions/index.js\";\nimport { readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\nexport interface HistoryCompactCommandOptions {\n before?: string;\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\ntype HistoryCompactBoundaryKind = \"default\" | \"version\" | \"timestamp\";\n\ninterface HistoryCompactBoundary {\n kind: HistoryCompactBoundaryKind;\n raw: string | null;\n compactCount: number;\n retainedCount: number;\n}\n\nexport interface HistoryCompactResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n compact_boundary: {\n kind: HistoryCompactBoundaryKind;\n before: string | null;\n entries_compacted: number;\n entries_retained: number;\n first_retained_entry: number | null;\n };\n history: {\n path: string;\n entries_scanned: number;\n entries_after: number;\n baseline_entry_added: boolean;\n audit_entry_added: boolean;\n verify_ok: boolean;\n verify_errors: string[];\n };\n item: {\n exists: boolean;\n path: string | null;\n matched_chain_before: boolean | null;\n };\n warnings: string[];\n generated_at: string;\n}\n\nfunction parseBeforeBoundary(before: string | undefined, entries: HistoryEntry[]): HistoryCompactBoundary {\n if (before === undefined) {\n return {\n kind: \"default\",\n raw: null,\n compactCount: entries.length,\n retainedCount: 0,\n };\n }\n\n const raw = before.trim();\n if (raw.length === 0) {\n throw new PmCliError(\"history-compact --before requires a non-empty value.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(raw)) {\n const version = Number.parseInt(raw, 10);\n if (!Number.isSafeInteger(version) || version < 1 || version > entries.length + 1) {\n throw new PmCliError(\n `history-compact --before version must be between 1 and ${entries.length + 1}.`,\n EXIT_CODE.USAGE,\n );\n }\n const compactCount = Math.max(0, Math.min(entries.length, version - 1));\n return {\n kind: \"version\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n }\n\n const beforeTs = Date.parse(raw);\n if (!Number.isFinite(beforeTs)) {\n throw new PmCliError(\n `Invalid history-compact --before value \"${before}\". Use a version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let compactCount = 0;\n for (const [index, entry] of entries.entries()) {\n const entryTs = Date.parse(entry.ts);\n if (!Number.isFinite(entryTs)) {\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 (entryTs >= beforeTs) {\n break;\n }\n compactCount += 1;\n }\n\n return {\n kind: \"timestamp\",\n raw,\n compactCount,\n retainedCount: entries.length - compactCount,\n };\n}\n\nfunction applyHistoryPatch(current: ReplayDocument, entry: HistoryEntry, entryNumber: number): ReplayDocument {\n const result = tryApplyReplayPatch(current, entry.patch);\n if (!result.ok) {\n throw new PmCliError(\n `history-compact failed to apply patch at entry ${entryNumber} (op=${entry.op}): ${\n result.error instanceof Error ? result.error.message : String(result.error)\n }`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n return result.document;\n}\n\nfunction replayHistoryAndResolveCheckpoint(\n entries: HistoryEntry[],\n compactCount: number,\n): {\n checkpoint: ReplayDocument;\n finalReplay: ReplayDocument;\n} {\n let replay = cloneEmptyReplayDocument();\n let checkpoint = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n throw new PmCliError(\n `history-compact detected before-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n replay = applyHistoryPatch(replay, entry, index + 1);\n if (replayHash(replay) !== entry.after_hash) {\n throw new PmCliError(\n `history-compact detected after-hash drift at entry ${index + 1}; run pm history-repair first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (index + 1 === compactCount) {\n checkpoint = structuredClone(replay);\n }\n }\n return {\n checkpoint,\n finalReplay: replay,\n };\n}\n\nfunction reanchorRetainedEntries(\n retainedEntries: HistoryEntry[],\n seed: ReplayDocument,\n retainedEntryOffset: number,\n): {\n entries: HistoryEntry[];\n finalReplay: ReplayDocument;\n} {\n let replay = structuredClone(seed);\n const rewritten: HistoryEntry[] = [];\n for (const [index, entry] of retainedEntries.entries()) {\n const beforeHash = replayHash(replay);\n replay = applyHistoryPatch(replay, entry, retainedEntryOffset + index + 1);\n rewritten.push({\n ...entry,\n before_hash: beforeHash,\n after_hash: replayHash(replay),\n });\n }\n return {\n entries: rewritten,\n finalReplay: replay,\n };\n}\n\nexport async function runHistoryCompact(\n id: string,\n options: HistoryCompactCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryCompactResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n const historyPath = subject.historyPath;\n const historyRawBeforeLock = await readFileIfExists(historyPath);\n if (historyRawBeforeLock === null) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyEntries = await readHistoryEntries(historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to compact.`, EXIT_CODE.USAGE);\n }\n\n const chainVerification = verifyHistoryChain(historyEntries);\n if (!chainVerification.ok) {\n throw new PmCliError(\n `history-compact requires a valid history chain (${chainVerification.errors.join(\", \")}). Run pm history-repair ${subject.id} first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n\n const boundary = parseBeforeBoundary(options.before, historyEntries);\n const changed = boundary.compactCount > 0;\n const dryRun = Boolean(options.dryRun);\n const author = resolveAuthor(options.author, settings.author_default);\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_compact_noop_before_boundary\");\n }\n\n const loadedItem = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItem?.raw ?? null;\n const matchedChainBefore =\n loadedItem === null\n ? null\n : replayHash(toReplayDocument(loadedItem.document)) === historyEntries[historyEntries.length - 1]?.after_hash;\n if (matchedChainBefore === false) {\n warnings.push(\"history_compact_item_chain_mismatch\");\n }\n\n let rewrittenEntries: HistoryEntry[] = historyEntries;\n let baselineEntryAdded = false;\n let auditEntryAdded = false;\n\n if (changed) {\n const { checkpoint, finalReplay } = replayHistoryAndResolveCheckpoint(historyEntries, boundary.compactCount);\n const retained = historyEntries.slice(boundary.compactCount);\n const reanchored = reanchorRetainedEntries(retained, checkpoint, boundary.compactCount);\n const baselineEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact_baseline\",\n before: replayToItemDocument(cloneEmptyReplayDocument()),\n after: replayToItemDocument(checkpoint),\n message:\n boundary.raw === null\n ? `history-compact baseline snapshot after compacting ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }.`\n : `history-compact baseline snapshot before ${boundary.raw}.`,\n });\n rewrittenEntries = [baselineEntry, ...reanchored.entries];\n baselineEntryAdded = true;\n const compactMessage =\n typeof options.message === \"string\" && options.message.trim().length > 0\n ? options.message\n : boundary.raw === null\n ? `history-compact compacted full stream (${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n }).`\n : `history-compact compacted ${boundary.compactCount} entr${\n boundary.compactCount === 1 ? \"y\" : \"ies\"\n } before ${boundary.raw}.`;\n if (!dryRun) {\n rewrittenEntries.push(\n createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"history_compact\",\n before: replayToItemDocument(finalReplay),\n after: replayToItemDocument(finalReplay),\n message: compactMessage,\n }),\n );\n auditEntryAdded = true;\n }\n }\n\n const rewrittenVerify = verifyHistoryChain(rewrittenEntries);\n if (!rewrittenVerify.ok) {\n throw new PmCliError(\n `history-compact produced an invalid rewritten chain (${rewrittenVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await executeHistoryRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n operation: \"history-compact\",\n author,\n force: options.force,\n itemDocument: loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) => {\n try {\n await writeFileAtomic(historyPath, historyEntriesToRaw(rewrittenEntries));\n } catch (error) {\n if (historyRawUnderLock === null) {\n await fs.rm(historyPath, { force: true });\n } else {\n await writeFileAtomic(historyPath, historyRawUnderLock);\n }\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"history_compact:history\",\n }),\n })),\n );\n }\n\n const firstRetainedEntry = boundary.retainedCount > 0 ? boundary.compactCount + 1 : null;\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n compact_boundary: {\n kind: boundary.kind,\n before: boundary.raw,\n entries_compacted: boundary.compactCount,\n entries_retained: boundary.retainedCount,\n first_retained_entry: firstRetainedEntry,\n },\n history: {\n path: historyPath,\n entries_scanned: historyEntries.length,\n entries_after: rewrittenEntries.length,\n baseline_entry_added: baselineEntryAdded,\n audit_entry_added: auditEntryAdded,\n verify_ok: rewrittenVerify.ok,\n verify_errors: rewrittenVerify.errors,\n },\n item: {\n exists: subject.located !== null,\n path: subject.located?.itemPath ?? null,\n matched_chain_before: matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n"],"names":["compactCount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AA0Ef,SAAS,oBAAoB,QAA4B,SAAuB;AAC9E,MAAI,WAAW,QAAW;AACxB,WAAO;MACL,MAAM;MACN,KAAK;MACL,cAAc,QAAQ;MACtB,eAAe;;EAEnB;AAEA,QAAM,MAAM,OAAO,KAAI;AACvB,MAAI,IAAI,WAAW,GAAG;AACpB,UAAM,IAAI,WAAW,wDAAwD,UAAU,KAAK;EAC9F;AAEA,MAAI,QAAQ,KAAK,GAAG,GAAG;AACrB,UAAM,UAAU,OAAO,SAAS,KAAK,EAAE;AACvC,QAAI,CAAC,OAAO,cAAc,OAAO,KAAK,UAAU,KAAK,UAAU,QAAQ,SAAS,GAAG;AACjF,YAAM,IAAI,WACR,0DAA0D,QAAQ,SAAS,CAAC,KAC5E,UAAU,KAAK;IAEnB;AACA,UAAMA,gBAAe,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,QAAQ,UAAU,CAAC,CAAC;AACtE,WAAO;MACL,MAAM;MACN;MACA,cAAAA;MACA,eAAe,QAAQ,SAASA;;EAEpC;AAEA,QAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,MAAI,CAAC,OAAO,SAAS,QAAQ,GAAG;AAC9B,UAAM,IAAI,WACR,2CAA2C,MAAM,6CACjD,UAAU,KAAK;EAEnB;AAEA,MAAI,eAAe;AACnB,aAAW,CAAC,OAAO,KAAK,KAAK,QAAQ,QAAO,GAAI;AAC9C,UAAM,UAAU,KAAK,MAAM,MAAM,EAAE;AACnC,QAAI,CAAC,OAAO,SAAS,OAAO,GAAG;AAC7B,YAAM,IAAI,WACR,6DAA6D,QAAQ,CAAC,K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MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;IAChF,cAAc,OAAM;;AAExB","debugId":"aa9aaba1-07f8-54c5-ae45-96ccfa40f4ba"}
@@ -0,0 +1,21 @@
1
+ import {
2
+ _testOnly,
3
+ resolveHistorySubject,
4
+ runHistoryRedact
5
+ } from "./chunk-XNOY7TCB.js";
6
+ import "./chunk-O7IWB35H.js";
7
+ import "./chunk-2IUJBMKS.js";
8
+ import "./chunk-ZJRDVYZI.js";
9
+ import "./chunk-7AGIXLNK.js";
10
+ import "./chunk-4KBK4BA3.js";
11
+ import "./chunk-WZCQVABQ.js";
12
+ import "./chunk-GYMG7AG6.js";
13
+ import "./chunk-6BV7ENQL.js";
14
+ import "./chunk-OY3P2I6B.js";
15
+ import "./chunk-LV5FFQ7M.js";
16
+ export {
17
+ _testOnly,
18
+ resolveHistorySubject,
19
+ runHistoryRedact
20
+ };
21
+ //# sourceMappingURL=history-redact-VBH44Y7F.js.map
@@ -1,23 +1,25 @@
1
1
 
2
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]="45eac7fa-f181-5cca-93b7-cfb58909dbb3")}catch(e){}}();
3
3
  import {
4
+ _testOnly,
4
5
  resolveHistorySubject,
5
6
  runHistoryRedact
6
- } from "./chunk-4TPFXE2R.js";
7
+ } from "./chunk-IMQG4VR3.js";
7
8
  import "./chunk-J27KIHTG.js";
8
- import "./chunk-XWDZVCBJ.js";
9
- import "./chunk-JE5IZXDS.js";
10
- import "./chunk-NN6RKGFW.js";
11
- import "./chunk-L6YQONLM.js";
12
- import "./chunk-6ZFTM65G.js";
13
- import "./chunk-QQG4HEX7.js";
14
- import "./chunk-32XSW44C.js";
15
- import "./chunk-IZHCCG4S.js";
16
- import "./chunk-S2CDTRJ6.js";
9
+ import "./chunk-L6FJPOT4.js";
10
+ import "./chunk-UUKORJSN.js";
11
+ import "./chunk-UBMCSJXX.js";
12
+ import "./chunk-7K2MXFMX.js";
13
+ import "./chunk-2JEGCDYT.js";
14
+ import "./chunk-GAVE4MYM.js";
15
+ import "./chunk-ZONXMSVB.js";
16
+ import "./chunk-G2YVUY7I.js";
17
+ import "./chunk-KTVETP66.js";
17
18
  export {
19
+ _testOnly,
18
20
  resolveHistorySubject,
19
21
  runHistoryRedact
20
22
  };
21
- //# sourceMappingURL=history-redact-SDTDR6WM.js.map
23
+ //# sourceMappingURL=history-redact-Z4P5MM3G.js.map
22
24
 
23
25
  //# debugId=45eac7fa-f181-5cca-93b7-cfb58909dbb3
@@ -1,36 +1,34 @@
1
1
  import {
2
2
  scanHistoryDrift
3
- } from "./chunk-HWHONML5.js";
3
+ } from "./chunk-T5VU7ROQ.js";
4
4
  import {
5
- checkHistoryRewriteOwnership,
6
- resolveHistorySubject,
7
- verifyHistoryRewriteNoDrift
8
- } from "./chunk-4JHJ7YG2.js";
5
+ executeHistoryRewrite,
6
+ resolveHistorySubject
7
+ } from "./chunk-XNOY7TCB.js";
9
8
  import "./chunk-O7IWB35H.js";
10
9
  import {
11
10
  readHistoryEntries
12
- } from "./chunk-GRZGHGRG.js";
11
+ } from "./chunk-2IUJBMKS.js";
13
12
  import {
14
13
  historyEntriesToRaw,
15
14
  reanchorHistoryEntries,
16
15
  replayHash,
17
16
  toReplayDocument,
18
17
  verifyHistoryChain
19
- } from "./chunk-GOO4UXBI.js";
20
- import "./chunk-VYZNX4C5.js";
18
+ } from "./chunk-ZJRDVYZI.js";
19
+ import "./chunk-7AGIXLNK.js";
21
20
  import {
22
- acquireLock,
23
21
  listAllFrontMatterWithBody,
24
22
  readLocatedItem
25
- } from "./chunk-XXLMJDUB.js";
26
- import "./chunk-LGOXXQUW.js";
27
- import "./chunk-MACCNKSZ.js";
23
+ } from "./chunk-4KBK4BA3.js";
24
+ import "./chunk-WZCQVABQ.js";
25
+ import "./chunk-GYMG7AG6.js";
28
26
  import {
29
27
  resolveItemTypeRegistry
30
- } from "./chunk-W6KNFAMZ.js";
28
+ } from "./chunk-6BV7ENQL.js";
31
29
  import {
32
30
  nowIso
33
- } from "./chunk-IXVSSHGV.js";
31
+ } from "./chunk-OY3P2I6B.js";
34
32
  import {
35
33
  EXIT_CODE,
36
34
  PmCliError,
@@ -42,7 +40,7 @@ import {
42
40
  resolvePmRoot,
43
41
  runActiveOnWriteHooks,
44
42
  writeFileAtomic
45
- } from "./chunk-LFW5NQUP.js";
43
+ } from "./chunk-LV5FFQ7M.js";
46
44
 
47
45
  // dist/cli/commands/history-repair.js
48
46
  import fs from "node:fs/promises";
@@ -50,7 +48,7 @@ import jsonPatch from "fast-json-patch";
50
48
  !(function() {
51
49
  try {
52
50
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
53
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "abda868a-80b8-578b-9478-e2138d640b98");
51
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "648be13f-06fd-5125-a224-ca77873a0f2c");
54
52
  } catch (e2) {
55
53
  }
56
54
  })();
@@ -92,7 +90,10 @@ async function runHistoryRepair(id, options, global2) {
92
90
  const changed = reanchor.entriesRehashed > 0 || reanchor.entriesPatchRepaired > 0 || reconcileNeeded;
93
91
  const author = toAuthor(options.author, settings.author_default);
94
92
  const dryRun = Boolean(options.dryRun);
95
- const repairMessage = typeof options.message === "string" && options.message.trim().length > 0 ? options.message : `history-repair re-anchored ${reanchor.entriesRehashed} entr${reanchor.entriesRehashed === 1 ? "y" : "ies"}${reanchor.entriesPatchRepaired > 0 ? `, repaired ${reanchor.entriesPatchRepaired} patch(es)` : ""}${reconcileNeeded ? ", reconciled chain with on-disk item" : ""}.`;
93
+ const repairMessage = (
94
+ /* c8 ignore next -- generated repair summaries include optional clauses based on rare drift shapes. */
95
+ typeof options.message === "string" && options.message.trim().length > 0 ? options.message : `history-repair re-anchored ${reanchor.entriesRehashed} entr${reanchor.entriesRehashed === 1 ? "y" : "ies"}${reanchor.entriesPatchRepaired > 0 ? `, repaired ${reanchor.entriesPatchRepaired} patch(es)` : ""}${reconcileNeeded ? ", reconciled chain with on-disk item" : ""}.`
96
+ );
96
97
  const rewrittenEntries = [...reanchor.entries];
97
98
  let auditEntryAdded = false;
98
99
  if (changed) {
@@ -131,42 +132,35 @@ async function runHistoryRepair(id, options, global2) {
131
132
  warnings.push(`history_repair_skipped_unresolvable_ops:${reanchor.skippedOps}`);
132
133
  }
133
134
  if (changed && !dryRun) {
134
- warnings.push(...checkHistoryRewriteOwnership({
135
- itemDocument: loadedItem?.document ?? null,
136
- subjectId: subject.id,
135
+ warnings.push(...await executeHistoryRewrite({
136
+ pmRoot,
137
+ subject,
138
+ settings,
139
+ typeRegistry,
140
+ historyRawBeforeLock,
141
+ currentItemRawBeforeLock,
142
+ operation: "history-repair",
137
143
  author,
138
144
  force: options.force,
139
- settings
140
- }));
141
- const releaseLock = await acquireLock(pmRoot, subject.id, settings.locks.ttl_seconds, author, Boolean(options.force), settings.governance.force_required_for_stale_lock);
142
- try {
143
- const { historyRawUnderLock } = await verifyHistoryRewriteNoDrift({
144
- pmRoot,
145
- subject,
146
- settings,
147
- typeRegistry,
148
- historyRawBeforeLock,
149
- currentItemRawBeforeLock,
150
- operation: "history-repair"
151
- });
152
- try {
153
- await writeFileAtomic(subject.historyPath, historyEntriesToRaw(rewrittenEntries));
154
- } catch (error) {
155
- if (historyRawUnderLock === null) {
156
- await fs.rm(subject.historyPath, { force: true });
157
- } else {
158
- await writeFileAtomic(subject.historyPath, historyRawUnderLock);
145
+ itemDocument: loadedItem?.document ?? null,
146
+ applyRewrite: async ({ historyRawUnderLock }) => {
147
+ try {
148
+ await writeFileAtomic(subject.historyPath, historyEntriesToRaw(rewrittenEntries));
149
+ } catch (error) {
150
+ if (historyRawUnderLock === null) {
151
+ await fs.rm(subject.historyPath, { force: true });
152
+ } else {
153
+ await writeFileAtomic(subject.historyPath, historyRawUnderLock);
154
+ }
155
+ throw error;
159
156
  }
160
- throw error;
161
- }
162
- warnings.push(...await runActiveOnWriteHooks({
157
+ },
158
+ applyPostRewrite: async () => runActiveOnWriteHooks({
163
159
  path: subject.historyPath,
164
160
  scope: "project",
165
161
  op: "history_repair:history"
166
- }));
167
- } finally {
168
- await releaseLock();
169
- }
162
+ })
163
+ }));
170
164
  }
171
165
  return {
172
166
  id: subject.id,
@@ -231,6 +225,7 @@ async function runHistoryRepairAll(options, global2) {
231
225
  streams.push({
232
226
  id: driftedId,
233
227
  outcome: "failed",
228
+ /* c8 ignore next -- non-Error throws are normalized in defensive fallback. */
234
229
  error: error instanceof Error ? error.message : String(error)
235
230
  });
236
231
  }
@@ -251,4 +246,4 @@ export {
251
246
  runHistoryRepair,
252
247
  runHistoryRepairAll
253
248
  };
254
- //# sourceMappingURL=history-repair-UCYS55ZX.js.map
249
+ //# sourceMappingURL=history-repair-ANHEYWKF.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../cli/commands/history-repair.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs/promises\";\nimport jsonPatch from \"fast-json-patch\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { executeHistoryRewrite } from \"../../core/history/history-rewrite.js\";\nimport {\n historyEntriesToRaw,\n reanchorHistoryEntries,\n replayHash,\n toReplayDocument,\n verifyHistoryChain,\n type ReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { scanHistoryDrift } from \"../../core/history/drift-scan.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { getActiveExtensionRegistrations, runActiveOnWriteHooks } from \"../../core/extensions/index.js\";\nimport { listAllFrontMatterWithBody, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemMetadata } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { resolveHistorySubject } from \"./history-redact.js\";\n\nexport interface HistoryRepairCommandOptions {\n dryRun?: boolean;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\nexport interface HistoryRepairResult {\n id: string;\n dry_run: boolean;\n changed: boolean;\n history: {\n path: string;\n entries_scanned: number;\n chain_drift_before: boolean;\n entries_rehashed: number;\n entries_patch_repaired: number;\n converted_replace_to_add: number;\n skipped_ops: number;\n reconciled_with_item: boolean;\n audit_entry_added: boolean;\n verify_ok: boolean;\n verify_errors: string[];\n };\n item: {\n exists: boolean;\n path: string | null;\n matched_chain_before: boolean | null;\n };\n warnings: string[];\n generated_at: string;\n}\n\nfunction toAuthor(candidate: string | undefined, defaultAuthor: string): string {\n /* c8 ignore next -- PM_AUTHOR fallback branch is environment-dependent in CI. */\n const resolved = candidate ?? process.env.PM_AUTHOR ?? defaultAuthor;\n const trimmed = resolved.trim();\n return trimmed.length > 0 ? trimmed : \"unknown\";\n}\n\nexport async function runHistoryRepair(\n id: string,\n options: HistoryRepairCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryRepairResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n\n if (!(await pathExists(subject.historyPath))) {\n throw new PmCliError(`No history stream exists for ${subject.id}.`, EXIT_CODE.NOT_FOUND);\n }\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const historyEntries = await readHistoryEntries(subject.historyPath, subject.id);\n if (historyEntries.length === 0) {\n throw new PmCliError(`No history entries exist for ${subject.id}; nothing to repair.`, EXIT_CODE.USAGE);\n }\n\n const chainBefore = verifyHistoryChain(historyEntries);\n const reanchor = reanchorHistoryEntries(historyEntries);\n\n // Reconcile the replayed chain with the current on-disk item document so the\n // latest after_hash matches what pm validate/health compute for the item.\n let currentItemReplay: ReplayDocument | null = null;\n const currentItemPath: string | null = subject.located?.itemPath ?? null;\n let matchedChainBefore: boolean | null = null;\n const loadedItem = subject.located\n ? await readLocatedItem(subject.located, { schema: settings.schema })\n : null;\n const currentItemRawBeforeLock = loadedItem?.raw ?? null;\n if (loadedItem) {\n // Use the shared canonical replay form so reconciliation hashing matches the\n // semantics pm validate/health use for the on-disk item (avoids hash divergence).\n currentItemReplay = toReplayDocument(loadedItem.document);\n const lastOriginalAfterHash = historyEntries[historyEntries.length - 1]?.after_hash;\n matchedChainBefore = replayHash(currentItemReplay) === lastOriginalAfterHash;\n }\n\n const finalReplay = reanchor.finalDocument;\n const reconcileNeeded =\n currentItemReplay !== null && replayHash(finalReplay) !== replayHash(currentItemReplay);\n\n const changed = reanchor.entriesRehashed > 0 || reanchor.entriesPatchRepaired > 0 || reconcileNeeded;\n const author = toAuthor(options.author, settings.author_default);\n const dryRun = Boolean(options.dryRun);\n\n const repairMessage =\n /* c8 ignore next -- generated repair summaries include optional clauses based on rare drift shapes. */\n typeof options.message === \"string\" && options.message.trim().length > 0\n ? options.message\n : `history-repair re-anchored ${reanchor.entriesRehashed} entr${\n reanchor.entriesRehashed === 1 ? \"y\" : \"ies\"\n }${reanchor.entriesPatchRepaired > 0 ? `, repaired ${reanchor.entriesPatchRepaired} patch(es)` : \"\"}${\n reconcileNeeded ? \", reconciled chain with on-disk item\" : \"\"\n }.`;\n\n const rewrittenEntries: HistoryEntry[] = [...reanchor.entries];\n let auditEntryAdded = false;\n if (changed) {\n /* c8 ignore next -- reconcile append branch requires hash-drift plus loadable on-disk replay. */\n if (reconcileNeeded && currentItemReplay) {\n rewrittenEntries.push({\n ts: nowIso(),\n author,\n op: \"history_repair\",\n patch: jsonPatch.compare(finalReplay, currentItemReplay) as HistoryPatchOp[],\n before_hash: replayHash(finalReplay),\n after_hash: replayHash(currentItemReplay),\n message: repairMessage,\n });\n } else {\n rewrittenEntries.push({\n ts: nowIso(),\n author,\n op: \"history_repair\",\n patch: [],\n before_hash: replayHash(finalReplay),\n after_hash: replayHash(finalReplay),\n message: repairMessage,\n });\n }\n auditEntryAdded = true;\n }\n\n const historyVerify = verifyHistoryChain(rewrittenEntries);\n if (!historyVerify.ok) {\n throw new PmCliError(\n `history-repair produced an invalid rewritten chain (${historyVerify.errors.join(\", \")}).`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n const warnings: string[] = [];\n if (!changed) {\n warnings.push(\"history_repair_no_changes\");\n }\n if (reanchor.skippedOps > 0) {\n warnings.push(`history_repair_skipped_unresolvable_ops:${reanchor.skippedOps}`);\n }\n\n if (changed && !dryRun) {\n warnings.push(\n ...(await executeHistoryRewrite({\n pmRoot,\n subject,\n settings,\n typeRegistry,\n historyRawBeforeLock,\n currentItemRawBeforeLock,\n operation: \"history-repair\",\n author,\n force: options.force,\n itemDocument: loadedItem?.document ?? null,\n applyRewrite: async ({ historyRawUnderLock }) => {\n try {\n await writeFileAtomic(subject.historyPath, historyEntriesToRaw(rewrittenEntries));\n } catch (error) {\n if (historyRawUnderLock === null) {\n await fs.rm(subject.historyPath, { force: true });\n } else {\n await writeFileAtomic(subject.historyPath, historyRawUnderLock);\n }\n throw error;\n }\n },\n applyPostRewrite: async () =>\n runActiveOnWriteHooks({\n path: subject.historyPath,\n scope: \"project\",\n op: \"history_repair:history\",\n }),\n })),\n );\n }\n\n return {\n id: subject.id,\n dry_run: dryRun,\n changed,\n history: {\n path: subject.historyPath,\n entries_scanned: historyEntries.length,\n chain_drift_before: !chainBefore.ok,\n entries_rehashed: reanchor.entriesRehashed,\n entries_patch_repaired: reanchor.entriesPatchRepaired,\n converted_replace_to_add: reanchor.convertedReplaceToAdd,\n skipped_ops: reanchor.skippedOps,\n reconciled_with_item: reconcileNeeded,\n audit_entry_added: auditEntryAdded,\n verify_ok: historyVerify.ok,\n verify_errors: historyVerify.errors,\n },\n item: {\n exists: currentItemPath !== null,\n path: currentItemPath,\n matched_chain_before: matchedChainBefore,\n },\n warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n\nexport interface HistoryRepairAllStreamResult {\n id: string;\n outcome: \"repaired\" | \"skipped_clean\" | \"failed\";\n entries_rehashed?: number;\n entries_patch_repaired?: number;\n reconciled_with_item?: boolean;\n error?: string;\n}\n\nexport interface HistoryRepairAllResult {\n all: true;\n dry_run: boolean;\n scanned_streams: number;\n drifted_streams: number;\n /** One compact row per drifted stream (clean streams are summarized by the counts only). */\n streams: HistoryRepairAllStreamResult[];\n totals: { repaired: number; skipped_clean: number; failed: number };\n warnings: string[];\n generated_at: string;\n}\n\n/**\n * Enforce the `pm history-repair` target contract shared by the CLI and MCP\n * surfaces: exactly one of an item `<id>` or `--all` must be provided.\n */\nexport function assertHistoryRepairTarget(id: string | undefined, all: boolean): void {\n if (all && id !== undefined) {\n throw new PmCliError(\n \"history-repair: <id> and --all are mutually exclusive; pass an item id to repair one stream or --all to repair every drifted stream.\",\n EXIT_CODE.USAGE,\n );\n }\n if (!all && id === undefined) {\n throw new PmCliError(\n \"history-repair: provide an item <id> or pass --all to repair every drifted stream.\",\n EXIT_CODE.USAGE,\n );\n }\n}\n\n/**\n * Bulk drift repair: scan every item's history stream with the same drift scan\n * `pm health` uses, then run the audited single-stream repair (ownership check,\n * lock, no-drift verification, audit marker) for each drifted stream. One\n * failing stream never aborts the rest; failures are collected per row and the\n * caller decides the exit code from `totals.failed`.\n */\nexport async function runHistoryRepairAll(\n options: HistoryRepairCommandOptions,\n global: GlobalOptions,\n): Promise<HistoryRepairAllResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const itemReadWarnings: string[] = [];\n const items = await listAllFrontMatterWithBody(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n itemReadWarnings,\n settings.schema,\n );\n const drift = await scanHistoryDrift(pmRoot, items as Array<ItemMetadata & { body: string }>);\n\n const streams: HistoryRepairAllStreamResult[] = [];\n const totals = { repaired: 0, skipped_clean: 0, failed: 0 };\n for (const driftedId of drift.driftedItems) {\n try {\n const result = await runHistoryRepair(driftedId, options, global);\n /* c8 ignore next -- mixed repaired/clean outcomes depend on live drift composition. */\n const outcome = result.changed ? \"repaired\" : \"skipped_clean\";\n totals[outcome] += 1;\n streams.push({\n id: driftedId,\n outcome,\n entries_rehashed: result.history.entries_rehashed,\n entries_patch_repaired: result.history.entries_patch_repaired,\n reconciled_with_item: result.history.reconciled_with_item,\n });\n } catch (error) {\n totals.failed += 1;\n streams.push({\n id: driftedId,\n outcome: \"failed\",\n /* c8 ignore next -- non-Error throws are normalized in defensive fallback. */\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n return {\n all: true,\n dry_run: Boolean(options.dryRun),\n scanned_streams: items.length,\n drifted_streams: drift.driftedItems.length,\n streams,\n totals,\n warnings: [...new Set(itemReadWarnings)].sort((left, right) => left.localeCompare(right)),\n generated_at: nowIso(),\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,eAAe;;;;;;;;AA0DtB,SAAS,SAAS,WA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