@unbrained/pm-cli 2026.7.1 → 2026.7.3

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 (625) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/CHANGELOG.md +25 -0
  3. package/CONTRIBUTING.md +2 -2
  4. package/README.md +1 -1
  5. package/dist/cli/commander-usage.d.ts +2 -0
  6. package/dist/cli/commander-usage.js +110 -86
  7. package/dist/cli/commander-usage.js.map +1 -1
  8. package/dist/cli/commands/activity.js +79 -57
  9. package/dist/cli/commands/activity.js.map +1 -1
  10. package/dist/cli/commands/aggregate.js +102 -79
  11. package/dist/cli/commands/aggregate.js.map +1 -1
  12. package/dist/cli/commands/calendar.js +278 -243
  13. package/dist/cli/commands/calendar.js.map +1 -1
  14. package/dist/cli/commands/close-many.js +176 -114
  15. package/dist/cli/commands/close-many.js.map +1 -1
  16. package/dist/cli/commands/close.js +157 -129
  17. package/dist/cli/commands/close.js.map +1 -1
  18. package/dist/cli/commands/comments-audit.js +50 -42
  19. package/dist/cli/commands/comments-audit.js.map +1 -1
  20. package/dist/cli/commands/config.d.ts +2 -0
  21. package/dist/cli/commands/config.js +443 -879
  22. package/dist/cli/commands/config.js.map +1 -1
  23. package/dist/cli/commands/context.js +365 -287
  24. package/dist/cli/commands/context.js.map +1 -1
  25. package/dist/cli/commands/contracts.js +352 -238
  26. package/dist/cli/commands/contracts.js.map +1 -1
  27. package/dist/cli/commands/create.js +32 -17
  28. package/dist/cli/commands/create.js.map +1 -1
  29. package/dist/cli/commands/dedupe-audit.js +46 -39
  30. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  31. package/dist/cli/commands/dedupe-merge.js +88 -69
  32. package/dist/cli/commands/dedupe-merge.js.map +1 -1
  33. package/dist/cli/commands/extension/doctor.js +56 -67
  34. package/dist/cli/commands/extension/doctor.js.map +1 -1
  35. package/dist/cli/commands/extension/shared.js +21 -15
  36. package/dist/cli/commands/extension/shared.js.map +1 -1
  37. package/dist/cli/commands/get.js +114 -81
  38. package/dist/cli/commands/get.js.map +1 -1
  39. package/dist/cli/commands/health.d.ts +17 -0
  40. package/dist/cli/commands/health.js +545 -417
  41. package/dist/cli/commands/health.js.map +1 -1
  42. package/dist/cli/commands/history-compact.js +209 -140
  43. package/dist/cli/commands/history-compact.js.map +1 -1
  44. package/dist/cli/commands/history-redact.js +162 -119
  45. package/dist/cli/commands/history-redact.js.map +1 -1
  46. package/dist/cli/commands/history-repair.js +120 -85
  47. package/dist/cli/commands/history-repair.js.map +1 -1
  48. package/dist/cli/commands/init-agent-guidance.js +32 -19
  49. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  50. package/dist/cli/commands/init.d.ts +8 -2
  51. package/dist/cli/commands/init.js +263 -162
  52. package/dist/cli/commands/init.js.map +1 -1
  53. package/dist/cli/commands/list.js +152 -102
  54. package/dist/cli/commands/list.js.map +1 -1
  55. package/dist/cli/commands/next.js +60 -40
  56. package/dist/cli/commands/next.js.map +1 -1
  57. package/dist/cli/commands/plan.js +373 -298
  58. package/dist/cli/commands/plan.js.map +1 -1
  59. package/dist/cli/commands/profile.js +23 -15
  60. package/dist/cli/commands/profile.js.map +1 -1
  61. package/dist/cli/commands/recurrence-parsers.js +43 -25
  62. package/dist/cli/commands/recurrence-parsers.js.map +1 -1
  63. package/dist/cli/commands/reindex.d.ts +21 -5
  64. package/dist/cli/commands/reindex.js +345 -205
  65. package/dist/cli/commands/reindex.js.map +1 -1
  66. package/dist/cli/commands/restore.d.ts +8 -7
  67. package/dist/cli/commands/restore.js +105 -69
  68. package/dist/cli/commands/restore.js.map +1 -1
  69. package/dist/cli/commands/schema.js +33 -30
  70. package/dist/cli/commands/schema.js.map +1 -1
  71. package/dist/cli/commands/search.d.ts +10 -2
  72. package/dist/cli/commands/search.js +503 -470
  73. package/dist/cli/commands/search.js.map +1 -1
  74. package/dist/cli/commands/telemetry.js +98 -87
  75. package/dist/cli/commands/telemetry.js.map +1 -1
  76. package/dist/cli/commands/test-all.js +237 -168
  77. package/dist/cli/commands/test-all.js.map +1 -1
  78. package/dist/cli/commands/test.d.ts +6 -5
  79. package/dist/cli/commands/test.js +424 -344
  80. package/dist/cli/commands/test.js.map +1 -1
  81. package/dist/cli/commands/update-many.js +57 -42
  82. package/dist/cli/commands/update-many.js.map +1 -1
  83. package/dist/cli/commands/update.d.ts +1 -1
  84. package/dist/cli/commands/update.js +738 -671
  85. package/dist/cli/commands/update.js.map +1 -1
  86. package/dist/cli/commands/validate.d.ts +20 -1
  87. package/dist/cli/commands/validate.js +478 -343
  88. package/dist/cli/commands/validate.js.map +1 -1
  89. package/dist/cli/error-guidance.js +406 -361
  90. package/dist/cli/error-guidance.js.map +1 -1
  91. package/dist/cli/extension-command-help.js +27 -19
  92. package/dist/cli/extension-command-help.js.map +1 -1
  93. package/dist/cli/help-json-payload.js +57 -49
  94. package/dist/cli/help-json-payload.js.map +1 -1
  95. package/dist/cli/main.d.ts +47 -0
  96. package/dist/cli/main.js +474 -371
  97. package/dist/cli/main.js.map +1 -1
  98. package/dist/cli/migration-gates.js +22 -45
  99. package/dist/cli/migration-gates.js.map +1 -1
  100. package/dist/cli/register-list-query.js +299 -310
  101. package/dist/cli/register-list-query.js.map +1 -1
  102. package/dist/cli/register-mutation.js +763 -779
  103. package/dist/cli/register-mutation.js.map +1 -1
  104. package/dist/cli/register-operations.js +386 -362
  105. package/dist/cli/register-operations.js.map +1 -1
  106. package/dist/cli/register-setup.js +120 -101
  107. package/dist/cli/register-setup.js.map +1 -1
  108. package/dist/cli/registration-helpers.d.ts +4 -0
  109. package/dist/cli/registration-helpers.js +45 -56
  110. package/dist/cli/registration-helpers.js.map +1 -1
  111. package/dist/cli-bundle/chunks/{activity-DBLQVIP6.js → activity-5YWLSPGE.js} +9 -9
  112. package/dist/cli-bundle/chunks/activity-BIML7K2D.js +16 -0
  113. package/dist/cli-bundle/chunks/{aggregate-SDF7DUOD.js → aggregate-2V2M3JZU.js} +107 -83
  114. package/dist/cli-bundle/chunks/{aggregate-SDF7DUOD.js.map → aggregate-2V2M3JZU.js.map} +2 -2
  115. package/dist/cli-bundle/chunks/{aggregate-JTEF4BP7.js → aggregate-EK7DXML7.js} +108 -84
  116. package/dist/cli-bundle/chunks/aggregate-EK7DXML7.js.map +1 -0
  117. package/dist/cli-bundle/chunks/{append-LOVPGVPT.js → append-EZESUVJT.js} +8 -8
  118. package/dist/cli-bundle/chunks/{append-QCFJSDFL.js → append-JFG4WQMG.js} +8 -8
  119. package/dist/cli-bundle/chunks/{chunk-TP5Q5ZD3.js → chunk-32IUNTG4.js} +158 -119
  120. package/dist/cli-bundle/chunks/chunk-32IUNTG4.js.map +1 -0
  121. package/dist/cli-bundle/chunks/{chunk-BHO33VBQ.js → chunk-3W2HJKJX.js} +3 -3
  122. package/dist/cli-bundle/chunks/{chunk-VARHOHYV.js → chunk-4EXFFP7T.js} +86 -52
  123. package/dist/cli-bundle/chunks/chunk-4EXFFP7T.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-4DUVCVLZ.js → chunk-4PFVUUYV.js} +2 -2
  125. package/dist/cli-bundle/chunks/{chunk-JSU5P7VS.js → chunk-4WB6S4YX.js} +308 -184
  126. package/dist/cli-bundle/chunks/chunk-4WB6S4YX.js.map +1 -0
  127. package/dist/cli-bundle/chunks/{chunk-HXTQJXWT.js → chunk-572FKBRL.js} +61 -102
  128. package/dist/cli-bundle/chunks/chunk-572FKBRL.js.map +1 -0
  129. package/dist/cli-bundle/chunks/{chunk-IJYK2T43.js → chunk-5E7N4T2Z.js} +2 -2
  130. package/dist/cli-bundle/chunks/{chunk-NKZAN7BD.js → chunk-5IZUBZBR.js} +3 -3
  131. package/dist/cli-bundle/chunks/{chunk-NOLPZMSV.js → chunk-5JIWFWOZ.js} +2 -2
  132. package/dist/cli-bundle/chunks/{chunk-FFMQB7WR.js → chunk-67LARBDL.js} +493 -404
  133. package/dist/cli-bundle/chunks/chunk-67LARBDL.js.map +1 -0
  134. package/dist/cli-bundle/chunks/{chunk-6AQZPVHQ.js → chunk-6CDCWKSX.js} +4 -4
  135. package/dist/cli-bundle/chunks/{chunk-3K2M5OYU.js → chunk-6KRFL33E.js} +308 -184
  136. package/dist/cli-bundle/chunks/chunk-6KRFL33E.js.map +7 -0
  137. package/dist/cli-bundle/chunks/{chunk-LB6TP6MC.js → chunk-6NYJGMTY.js} +2 -2
  138. package/dist/cli-bundle/chunks/{chunk-SLMUGTK3.js → chunk-7CLLC75T.js} +4 -4
  139. package/dist/cli-bundle/chunks/{chunk-2466X6E4.js → chunk-7LYO6S5A.js} +8 -8
  140. package/dist/cli-bundle/chunks/{chunk-W4ULYO7Z.js → chunk-A3OQ7TFW.js} +8 -8
  141. package/dist/cli-bundle/chunks/{chunk-5CGRF3L5.js → chunk-AIKU3IIL.js} +153 -90
  142. package/dist/cli-bundle/chunks/chunk-AIKU3IIL.js.map +1 -0
  143. package/dist/cli-bundle/chunks/{chunk-WYDHYJPO.js → chunk-AJHYQCBJ.js} +39 -5
  144. package/dist/cli-bundle/chunks/chunk-AJHYQCBJ.js.map +7 -0
  145. package/dist/cli-bundle/chunks/{chunk-VZDBVEZR.js → chunk-B4O5S7I3.js} +79 -57
  146. package/dist/cli-bundle/chunks/{chunk-VZDBVEZR.js.map → chunk-B4O5S7I3.js.map} +2 -2
  147. package/dist/cli-bundle/chunks/{chunk-OTUHB4HS.js → chunk-BE2SR6QL.js} +92 -77
  148. package/dist/cli-bundle/chunks/chunk-BE2SR6QL.js.map +1 -0
  149. package/dist/cli-bundle/chunks/{chunk-JLM7BHI7.js → chunk-BI4R7HI2.js} +75 -53
  150. package/dist/cli-bundle/chunks/chunk-BI4R7HI2.js.map +7 -0
  151. package/dist/cli-bundle/chunks/{chunk-AXIDKKAT.js → chunk-CXR3CMBQ.js} +33 -6
  152. package/dist/cli-bundle/chunks/chunk-CXR3CMBQ.js.map +1 -0
  153. package/dist/cli-bundle/chunks/{chunk-ZETXE4SE.js → chunk-ECU6MMTQ.js} +713 -613
  154. package/dist/cli-bundle/chunks/chunk-ECU6MMTQ.js.map +1 -0
  155. package/dist/cli-bundle/chunks/{chunk-2D4HATP2.js → chunk-EJ2OCBHF.js} +54 -30
  156. package/dist/cli-bundle/chunks/chunk-EJ2OCBHF.js.map +1 -0
  157. package/dist/cli-bundle/chunks/{chunk-BDTISOSD.js → chunk-EQURFOMH.js} +41 -26
  158. package/dist/cli-bundle/chunks/chunk-EQURFOMH.js.map +7 -0
  159. package/dist/cli-bundle/chunks/{chunk-GJ326ZKX.js → chunk-ER4ME5U2.js} +3 -3
  160. package/dist/cli-bundle/chunks/{chunk-HZZEHPRG.js → chunk-ERG65A2L.js} +2 -2
  161. package/dist/cli-bundle/chunks/{chunk-IZBR4NRW.js → chunk-F6WNBITZ.js} +157 -113
  162. package/dist/cli-bundle/chunks/chunk-F6WNBITZ.js.map +7 -0
  163. package/dist/cli-bundle/chunks/{chunk-L5OEFZQG.js → chunk-FH2H3CBD.js} +3 -3
  164. package/dist/cli-bundle/chunks/{chunk-JPECA746.js → chunk-FUFFPIYA.js} +2 -2
  165. package/dist/cli-bundle/chunks/{chunk-CF7RL6FR.js → chunk-FZJM2TXF.js} +110 -73
  166. package/dist/cli-bundle/chunks/chunk-FZJM2TXF.js.map +1 -0
  167. package/dist/cli-bundle/chunks/{chunk-27BXPBAY.js → chunk-GUYNUXQT.js} +3 -3
  168. package/dist/cli-bundle/chunks/{chunk-MAUKX7JC.js → chunk-GVJE5T7Q.js} +2 -2
  169. package/dist/cli-bundle/chunks/{chunk-3J6JRJ3I.js → chunk-HB4FAT3O.js} +42 -60
  170. package/dist/cli-bundle/chunks/chunk-HB4FAT3O.js.map +7 -0
  171. package/dist/cli-bundle/chunks/{chunk-55SNVXRQ.js → chunk-HQAF23Q2.js} +626 -484
  172. package/dist/cli-bundle/chunks/chunk-HQAF23Q2.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-ZRP4VG5U.js → chunk-JBZ2NTKX.js} +2 -2
  174. package/dist/cli-bundle/chunks/{chunk-RMMQ74TG.js → chunk-JPATY4SE.js} +54 -30
  175. package/dist/cli-bundle/chunks/chunk-JPATY4SE.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-IPYBJWTE.js → chunk-K5DT2YKM.js} +109 -72
  177. package/dist/cli-bundle/chunks/chunk-K5DT2YKM.js.map +7 -0
  178. package/dist/cli-bundle/chunks/{chunk-EJUDVUYZ.js → chunk-KEZOIPCR.js} +3 -3
  179. package/dist/cli-bundle/chunks/{chunk-RVUALSJF.js → chunk-KHVGM5CS.js} +466 -365
  180. package/dist/cli-bundle/chunks/chunk-KHVGM5CS.js.map +7 -0
  181. package/dist/cli-bundle/chunks/{chunk-YITK2PJ6.js → chunk-KS6ATO47.js} +288 -175
  182. package/dist/cli-bundle/chunks/chunk-KS6ATO47.js.map +7 -0
  183. package/dist/cli-bundle/chunks/{chunk-7R4QEMZZ.js → chunk-L4SLHV6G.js} +463 -362
  184. package/dist/cli-bundle/chunks/chunk-L4SLHV6G.js.map +1 -0
  185. package/dist/cli-bundle/chunks/{chunk-RLDHZHQS.js → chunk-LBE5QFMZ.js} +158 -114
  186. package/dist/cli-bundle/chunks/chunk-LBE5QFMZ.js.map +1 -0
  187. package/dist/cli-bundle/chunks/{chunk-22WKIL3H.js → chunk-LCWQP6NM.js} +76 -54
  188. package/dist/cli-bundle/chunks/chunk-LCWQP6NM.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-KNPEF7QG.js → chunk-LOWVNZBZ.js} +91 -76
  190. package/dist/cli-bundle/chunks/chunk-LOWVNZBZ.js.map +7 -0
  191. package/dist/cli-bundle/chunks/{chunk-HYTGA6GI.js → chunk-MDHWWBNZ.js} +3 -3
  192. package/dist/cli-bundle/chunks/{chunk-N74UMG5H.js → chunk-MEZZZBYX.js} +2 -2
  193. package/dist/cli-bundle/chunks/{chunk-V3NOKJF2.js → chunk-MHRS5FUX.js} +288 -175
  194. package/dist/cli-bundle/chunks/chunk-MHRS5FUX.js.map +1 -0
  195. package/dist/cli-bundle/chunks/{chunk-3XZCOZ5J.js → chunk-NOIEVOK5.js} +391 -313
  196. package/dist/cli-bundle/chunks/chunk-NOIEVOK5.js.map +1 -0
  197. package/dist/cli-bundle/chunks/{chunk-SDR5J34Q.js → chunk-NZ7QIUP5.js} +4 -4
  198. package/dist/cli-bundle/chunks/{chunk-UYUYDGIB.js → chunk-OGLGI22K.js} +115 -67
  199. package/dist/cli-bundle/chunks/{chunk-UYUYDGIB.js.map → chunk-OGLGI22K.js.map} +1 -1
  200. package/dist/cli-bundle/chunks/{chunk-DDPTYJIM.js → chunk-P5L7Z2O6.js} +2 -2
  201. package/dist/cli-bundle/chunks/{chunk-BZCEN4JA.js → chunk-PULUSQAV.js} +492 -403
  202. package/dist/cli-bundle/chunks/chunk-PULUSQAV.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-3VGN2UWE.js → chunk-QCDTQCMW.js} +22 -30
  204. package/dist/cli-bundle/chunks/chunk-QCDTQCMW.js.map +1 -0
  205. package/dist/cli-bundle/chunks/{chunk-4A3BJ675.js → chunk-QNNQAAZ5.js} +24 -18
  206. package/dist/cli-bundle/chunks/{chunk-4A3BJ675.js.map → chunk-QNNQAAZ5.js.map} +1 -1
  207. package/dist/cli-bundle/chunks/{chunk-MDPEOIGN.js → chunk-RAHINBVP.js} +60 -101
  208. package/dist/cli-bundle/chunks/chunk-RAHINBVP.js.map +7 -0
  209. package/dist/cli-bundle/chunks/{chunk-CWFNTKQJ.js → chunk-RJH5VQHW.js} +43 -61
  210. package/dist/cli-bundle/chunks/chunk-RJH5VQHW.js.map +1 -0
  211. package/dist/cli-bundle/chunks/{chunk-OGXLACHC.js → chunk-SU2E4AWU.js} +6 -6
  212. package/dist/cli-bundle/chunks/{chunk-HPPFYYOV.js → chunk-SU3TB4NS.js} +2 -2
  213. package/dist/cli-bundle/chunks/{chunk-JWXRETDF.js → chunk-SYE6WMV6.js} +626 -484
  214. package/dist/cli-bundle/chunks/chunk-SYE6WMV6.js.map +1 -0
  215. package/dist/cli-bundle/chunks/{chunk-NWMZWYYB.js → chunk-T3P7PMZP.js} +42 -27
  216. package/dist/cli-bundle/chunks/chunk-T3P7PMZP.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-G7I7DEZA.js → chunk-T4XBKJ3F.js} +4 -4
  218. package/dist/cli-bundle/chunks/{chunk-RH5ZBYFD.js → chunk-T6AXEBOP.js} +23 -17
  219. package/dist/cli-bundle/chunks/{chunk-RH5ZBYFD.js.map → chunk-T6AXEBOP.js.map} +2 -2
  220. package/dist/cli-bundle/chunks/{chunk-5QFDBI4F.js → chunk-TQ6AX5SQ.js} +58 -69
  221. package/dist/cli-bundle/chunks/{chunk-5QFDBI4F.js.map → chunk-TQ6AX5SQ.js.map} +2 -2
  222. package/dist/cli-bundle/chunks/{chunk-4XOIEKSD.js → chunk-U3S2B7TA.js} +86 -52
  223. package/dist/cli-bundle/chunks/chunk-U3S2B7TA.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-VICZWYGZ.js → chunk-U5TR4N7J.js} +7 -7
  225. package/dist/cli-bundle/chunks/{chunk-EVMTBV6V.js → chunk-UMNQZS4H.js} +3 -3
  226. package/dist/cli-bundle/chunks/{chunk-A7FPBAQS.js → chunk-WJA3PXW7.js} +7 -7
  227. package/dist/cli-bundle/chunks/{chunk-RGEMWD6Q.js → chunk-WRYERRZX.js} +157 -118
  228. package/dist/cli-bundle/chunks/chunk-WRYERRZX.js.map +7 -0
  229. package/dist/cli-bundle/chunks/{chunk-NUHHPVVS.js → chunk-WYOIIFSE.js} +712 -612
  230. package/dist/cli-bundle/chunks/chunk-WYOIIFSE.js.map +7 -0
  231. package/dist/cli-bundle/chunks/{chunk-4DSGXSBL.js → chunk-XRYSCRZR.js} +116 -68
  232. package/dist/cli-bundle/chunks/{chunk-4DSGXSBL.js.map → chunk-XRYSCRZR.js.map} +3 -3
  233. package/dist/cli-bundle/chunks/{chunk-NU2UEROZ.js → chunk-YF746GTH.js} +59 -70
  234. package/dist/cli-bundle/chunks/{chunk-NU2UEROZ.js.map → chunk-YF746GTH.js.map} +1 -1
  235. package/dist/cli-bundle/chunks/{chunk-JMP4E6D7.js → chunk-YPWUSH72.js} +390 -312
  236. package/dist/cli-bundle/chunks/{chunk-JMP4E6D7.js.map → chunk-YPWUSH72.js.map} +2 -2
  237. package/dist/cli-bundle/chunks/{chunk-QCWF6IYD.js → chunk-YSDFIY7N.js} +3 -3
  238. package/dist/cli-bundle/chunks/{chunk-UZIWVBE6.js → chunk-YSGTMDWC.js} +2 -2
  239. package/dist/cli-bundle/chunks/{chunk-NFDPYAIP.js → chunk-YVKZ3ANP.js} +21 -29
  240. package/dist/cli-bundle/chunks/chunk-YVKZ3ANP.js.map +7 -0
  241. package/dist/cli-bundle/chunks/{chunk-OKQ22KTH.js → chunk-Z4DGFQDH.js} +80 -58
  242. package/dist/cli-bundle/chunks/{chunk-OKQ22KTH.js.map → chunk-Z4DGFQDH.js.map} +1 -1
  243. package/dist/cli-bundle/chunks/{chunk-64HNBBFQ.js → chunk-Z5F6XZXE.js} +6 -6
  244. package/dist/cli-bundle/chunks/{chunk-AVEE5EHK.js → chunk-Z7RPDF2Y.js} +3 -3
  245. package/dist/cli-bundle/chunks/{chunk-3S2KT7NG.js → chunk-ZFTKYWIF.js} +152 -89
  246. package/dist/cli-bundle/chunks/chunk-ZFTKYWIF.js.map +7 -0
  247. package/dist/cli-bundle/chunks/{claim-T3GCKV7C.js → claim-2BGBGSVI.js} +8 -8
  248. package/dist/cli-bundle/chunks/{claim-EMQLYPRW.js → claim-5GU7OE67.js} +8 -8
  249. package/dist/cli-bundle/chunks/close-6YODBUIV.js +14 -0
  250. package/dist/cli-bundle/chunks/{close-TQYAAFJP.js → close-AFVKPR57.js} +7 -7
  251. package/dist/cli-bundle/chunks/{close-many-BG5QQIDQ.js → close-many-7KLOSYLP.js} +186 -122
  252. package/dist/cli-bundle/chunks/close-many-7KLOSYLP.js.map +7 -0
  253. package/dist/cli-bundle/chunks/{close-many-LDRVEQY2.js → close-many-JKUJMHLG.js} +187 -123
  254. package/dist/cli-bundle/chunks/close-many-JKUJMHLG.js.map +1 -0
  255. package/dist/cli-bundle/chunks/{comments-YUXJRZPQ.js → comments-DNWHEBOS.js} +9 -9
  256. package/dist/cli-bundle/chunks/{comments-QCKR2YY2.js → comments-RW23R3VE.js} +9 -9
  257. package/dist/cli-bundle/chunks/config-AUM5WBYA.js +1072 -0
  258. package/dist/cli-bundle/chunks/config-AUM5WBYA.js.map +7 -0
  259. package/dist/cli-bundle/chunks/config-OZWSA2NP.js +1062 -0
  260. package/dist/cli-bundle/chunks/config-OZWSA2NP.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{context-B6275WPX.js → context-OYXRGY7S.js} +12 -12
  262. package/dist/cli-bundle/chunks/{context-OCZ3FJ4Z.js → context-PKCEHQY3.js} +12 -12
  263. package/dist/cli-bundle/chunks/{contracts-HN7ABKLP.js → contracts-L6ODXNUM.js} +320 -199
  264. package/dist/cli-bundle/chunks/contracts-L6ODXNUM.js.map +7 -0
  265. package/dist/cli-bundle/chunks/{contracts-W4FZVVD6.js → contracts-X74F2GSM.js} +321 -200
  266. package/dist/cli-bundle/chunks/contracts-X74F2GSM.js.map +1 -0
  267. package/dist/cli-bundle/chunks/{copy-DEM4DATS.js → copy-6XOR3HKN.js} +5 -5
  268. package/dist/cli-bundle/chunks/{copy-BTJOSKKT.js → copy-I4NCLBR4.js} +5 -5
  269. package/dist/cli-bundle/chunks/{create-RLRJMRTM.js → create-PM45M6PE.js} +12 -12
  270. package/dist/cli-bundle/chunks/create-Z7YCH3BE.js +28 -0
  271. package/dist/cli-bundle/chunks/{delete-BHK7VB2Z.js → delete-7YXHYG67.js} +5 -5
  272. package/dist/cli-bundle/chunks/{delete-LSVHAB4Y.js → delete-LPISP43T.js} +5 -5
  273. package/dist/cli-bundle/chunks/{deps-XHYXWEPT.js → deps-N2T26FME.js} +5 -5
  274. package/dist/cli-bundle/chunks/{deps-4UDFJRUA.js → deps-WATKQDE3.js} +5 -5
  275. package/dist/cli-bundle/chunks/{docs-GYZNVS26.js → docs-6LQ3GLM7.js} +7 -7
  276. package/dist/cli-bundle/chunks/{docs-26S44RXU.js → docs-Z3X6JZLT.js} +7 -7
  277. package/dist/cli-bundle/chunks/{eval-UYF3ZPVO.js → eval-6DCLG52D.js} +10 -10
  278. package/dist/cli-bundle/chunks/{eval-PGRVIJQU.js → eval-Y3ZCUTHK.js} +10 -10
  279. package/dist/cli-bundle/chunks/{extension-CPSLJQVE.js → extension-BNINIMT7.js} +11 -11
  280. package/dist/cli-bundle/chunks/{extension-CXJ6RELI.js → extension-QWE4YYK5.js} +11 -11
  281. package/dist/cli-bundle/chunks/{files-NQHEXUZD.js → files-6SGKHS6O.js} +7 -7
  282. package/dist/cli-bundle/chunks/{files-MBNICQFM.js → files-FUYPSOFJ.js} +7 -7
  283. package/dist/cli-bundle/chunks/{focus-DWYIG7GU.js → focus-2Q3K76G2.js} +6 -6
  284. package/dist/cli-bundle/chunks/{focus-XZW5423D.js → focus-ATLBWXXD.js} +6 -6
  285. package/dist/cli-bundle/chunks/{gc-LPVMKJQJ.js → gc-RUYEMNRF.js} +3 -3
  286. package/dist/cli-bundle/chunks/{gc-7GQYOS2G.js → gc-TDWSDR66.js} +3 -3
  287. package/dist/cli-bundle/chunks/{get-A7MAOHCU.js → get-2WGLX74N.js} +120 -80
  288. package/dist/cli-bundle/chunks/get-2WGLX74N.js.map +7 -0
  289. package/dist/cli-bundle/chunks/{get-DSDEKJ3L.js → get-LY6M2JIM.js} +121 -81
  290. package/dist/cli-bundle/chunks/get-LY6M2JIM.js.map +1 -0
  291. package/dist/cli-bundle/chunks/{health-3IPFLKXB.js → health-4RKHYS3T.js} +535 -371
  292. package/dist/cli-bundle/chunks/health-4RKHYS3T.js.map +1 -0
  293. package/dist/cli-bundle/chunks/{health-GZXGBZ36.js → health-TMFVNYRA.js} +534 -370
  294. package/dist/cli-bundle/chunks/health-TMFVNYRA.js.map +7 -0
  295. package/dist/cli-bundle/chunks/history-CGNQJXFE.js +18 -0
  296. package/dist/cli-bundle/chunks/{history-NERDJNUB.js → history-SGRRS72R.js} +8 -8
  297. package/dist/cli-bundle/chunks/{history-compact-2WRZ2WK4.js → history-compact-LOED43R3.js} +213 -134
  298. package/dist/cli-bundle/chunks/history-compact-LOED43R3.js.map +7 -0
  299. package/dist/cli-bundle/chunks/{history-compact-HR7BB4LR.js → history-compact-V5DNAQHH.js} +214 -135
  300. package/dist/cli-bundle/chunks/history-compact-V5DNAQHH.js.map +1 -0
  301. package/dist/cli-bundle/chunks/{history-redact-O3NBCNWC.js → history-redact-IRL7WJ3E.js} +9 -9
  302. package/dist/cli-bundle/chunks/history-redact-N3JK7VBW.js +19 -0
  303. package/dist/cli-bundle/chunks/{history-repair-XA3LC4GA.js → history-repair-4WVBVHFR.js} +124 -84
  304. package/dist/cli-bundle/chunks/history-repair-4WVBVHFR.js.map +1 -0
  305. package/dist/cli-bundle/chunks/{history-repair-LCMOS45X.js → history-repair-PGYQJMGD.js} +123 -83
  306. package/dist/cli-bundle/chunks/history-repair-PGYQJMGD.js.map +7 -0
  307. package/dist/cli-bundle/chunks/{init-64XDLQJB.js → init-4GESW7RM.js} +12 -12
  308. package/dist/cli-bundle/chunks/init-XIDPABA4.js +22 -0
  309. package/dist/cli-bundle/chunks/{learnings-LPKCSJX7.js → learnings-4BHWFFUV.js} +9 -9
  310. package/dist/cli-bundle/chunks/{learnings-JR6MA5TI.js → learnings-4FJY7WIW.js} +9 -9
  311. package/dist/cli-bundle/chunks/{list-G5Y65VF6.js → list-472TIOVK.js} +8 -8
  312. package/dist/cli-bundle/chunks/{list-DNBJVO3E.js → list-D7BF5CL2.js} +8 -8
  313. package/dist/cli-bundle/chunks/{next-FYTQF6HG.js → next-D5STGWI2.js} +71 -46
  314. package/dist/cli-bundle/chunks/next-D5STGWI2.js.map +1 -0
  315. package/dist/cli-bundle/chunks/{next-BCERKDUR.js → next-SFQZVX2B.js} +70 -45
  316. package/dist/cli-bundle/chunks/next-SFQZVX2B.js.map +7 -0
  317. package/dist/cli-bundle/chunks/{notes-2BMU3VVQ.js → notes-6KNOSLIT.js} +9 -9
  318. package/dist/cli-bundle/chunks/{notes-6KTGO2OJ.js → notes-W4UEICGF.js} +9 -9
  319. package/dist/cli-bundle/chunks/{plan-RKZHQVXR.js → plan-JO6V7BXO.js} +373 -279
  320. package/dist/cli-bundle/chunks/plan-JO6V7BXO.js.map +1 -0
  321. package/dist/cli-bundle/chunks/{plan-4WXEQCTN.js → plan-MJQW5XK3.js} +372 -278
  322. package/dist/cli-bundle/chunks/plan-MJQW5XK3.js.map +7 -0
  323. package/dist/cli-bundle/chunks/{profile-4OMM32CD.js → profile-3TOTMUR4.js} +27 -19
  324. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js.map +7 -0
  325. package/dist/cli-bundle/chunks/{profile-QLER5ENE.js → profile-WIQY2KCV.js} +28 -20
  326. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js.map +1 -0
  327. package/dist/cli-bundle/chunks/register-list-query-ELBHCCFI.js +416 -0
  328. package/dist/cli-bundle/chunks/register-list-query-ELBHCCFI.js.map +7 -0
  329. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js +406 -0
  330. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js.map +1 -0
  331. package/dist/cli-bundle/chunks/{register-mutation-KK7PHYYU.js → register-mutation-ROFE2YPC.js} +729 -702
  332. package/dist/cli-bundle/chunks/register-mutation-ROFE2YPC.js.map +7 -0
  333. package/dist/cli-bundle/chunks/{register-mutation-ENNDUAZG.js → register-mutation-SJWMVIJ2.js} +730 -703
  334. package/dist/cli-bundle/chunks/register-mutation-SJWMVIJ2.js.map +1 -0
  335. package/dist/cli-bundle/chunks/{register-operations-HZ6XERQG.js → register-operations-IADFVH53.js} +389 -365
  336. package/dist/cli-bundle/chunks/register-operations-IADFVH53.js.map +7 -0
  337. package/dist/cli-bundle/chunks/register-operations-MEKU3AKC.js +510 -0
  338. package/dist/cli-bundle/chunks/register-operations-MEKU3AKC.js.map +1 -0
  339. package/dist/cli-bundle/chunks/{register-setup-ZKJ53RS7.js → register-setup-3QJY43CY.js} +128 -103
  340. package/dist/cli-bundle/chunks/register-setup-3QJY43CY.js.map +7 -0
  341. package/dist/cli-bundle/chunks/{register-setup-P67EMBDJ.js → register-setup-AJWUSSQX.js} +129 -104
  342. package/dist/cli-bundle/chunks/register-setup-AJWUSSQX.js.map +1 -0
  343. package/dist/cli-bundle/chunks/{restore-4MHZFJ2E.js → restore-44IHMMZZ.js} +9 -9
  344. package/dist/cli-bundle/chunks/restore-EXHU34EU.js +17 -0
  345. package/dist/cli-bundle/chunks/{scheduling-shortcuts-LB6DOLRL.js → scheduling-shortcuts-OLHNLAZY.js} +12 -12
  346. package/dist/cli-bundle/chunks/{scheduling-shortcuts-UTOYKLXQ.js → scheduling-shortcuts-TSBK4AY5.js} +12 -12
  347. package/dist/cli-bundle/chunks/{schema-73HR2OJW.js → schema-IB2NZZWD.js} +7 -7
  348. package/dist/cli-bundle/chunks/{schema-U6LJKSIR.js → schema-VBCELP5G.js} +7 -7
  349. package/dist/cli-bundle/chunks/{search-AXPXKZER.js → search-7UBETML4.js} +10 -10
  350. package/dist/cli-bundle/chunks/{search-KILGT37L.js → search-R227JOL6.js} +10 -10
  351. package/dist/cli-bundle/chunks/{stats-W5KNVJWQ.js → stats-FAG7COEH.js} +6 -6
  352. package/dist/cli-bundle/chunks/{stats-PSYVVTNZ.js → stats-MCK7PLYS.js} +6 -6
  353. package/dist/cli-bundle/chunks/{telemetry-GAHHQTOS.js → telemetry-DRPDZMAO.js} +84 -70
  354. package/dist/cli-bundle/chunks/telemetry-DRPDZMAO.js.map +7 -0
  355. package/dist/cli-bundle/chunks/{telemetry-BZUF6H7G.js → telemetry-GVVUQSJQ.js} +85 -71
  356. package/dist/cli-bundle/chunks/telemetry-GVVUQSJQ.js.map +1 -0
  357. package/dist/cli-bundle/chunks/{test-PWDIZ255.js → test-QY44WAMR.js} +15 -15
  358. package/dist/cli-bundle/chunks/{test-ACD52Z3S.js → test-SY76DZTO.js} +15 -15
  359. package/dist/cli-bundle/chunks/test-all-QD6QAEG7.js +430 -0
  360. package/dist/cli-bundle/chunks/test-all-QD6QAEG7.js.map +7 -0
  361. package/dist/cli-bundle/chunks/test-all-USPJHXFR.js +427 -0
  362. package/dist/cli-bundle/chunks/test-all-USPJHXFR.js.map +1 -0
  363. package/dist/cli-bundle/chunks/{test-runs-UXIXPDKU.js → test-runs-MG5VIGSK.js} +185 -147
  364. package/dist/cli-bundle/chunks/test-runs-MG5VIGSK.js.map +1 -0
  365. package/dist/cli-bundle/chunks/{test-runs-PLRAZEFW.js → test-runs-QIR5MJPL.js} +184 -146
  366. package/dist/cli-bundle/chunks/test-runs-QIR5MJPL.js.map +7 -0
  367. package/dist/cli-bundle/chunks/update-A7EICML6.js +24 -0
  368. package/dist/cli-bundle/chunks/{update-KFX2SIAC.js → update-IKJZWLQC.js} +15 -15
  369. package/dist/cli-bundle/chunks/{update-many-RNSBX2TA.js → update-many-BEMTDA2X.js} +84 -69
  370. package/dist/cli-bundle/chunks/{update-many-RNSBX2TA.js.map → update-many-BEMTDA2X.js.map} +1 -1
  371. package/dist/cli-bundle/chunks/{update-many-Z5GJS5LC.js → update-many-RATAARHU.js} +83 -68
  372. package/dist/cli-bundle/chunks/{update-many-Z5GJS5LC.js.map → update-many-RATAARHU.js.map} +2 -2
  373. package/dist/cli-bundle/chunks/{upgrade-BRL6KCOJ.js → upgrade-NWMR3VQL.js} +11 -11
  374. package/dist/cli-bundle/chunks/{upgrade-HAK6JG2O.js → upgrade-VU46BLJZ.js} +11 -11
  375. package/dist/cli-bundle/chunks/{validate-X5W76YJL.js → validate-GAJ6FUSI.js} +451 -321
  376. package/dist/cli-bundle/chunks/validate-GAJ6FUSI.js.map +1 -0
  377. package/dist/cli-bundle/chunks/{validate-MTUVL5VC.js → validate-NRY6MFXN.js} +450 -320
  378. package/dist/cli-bundle/chunks/validate-NRY6MFXN.js.map +7 -0
  379. package/dist/cli-bundle/main.js +1107 -916
  380. package/dist/cli-bundle/main.js.map +3 -3
  381. package/dist/core/config/nested-settings.js +89 -67
  382. package/dist/core/config/nested-settings.js.map +1 -1
  383. package/dist/core/governance/metadata-coverage.js +20 -28
  384. package/dist/core/governance/metadata-coverage.js.map +1 -1
  385. package/dist/core/history/drift-scan.js +93 -81
  386. package/dist/core/history/drift-scan.js.map +1 -1
  387. package/dist/core/item/item-type-definition.js +14 -14
  388. package/dist/core/item/item-type-definition.js.map +1 -1
  389. package/dist/core/item/type-registry.js +114 -99
  390. package/dist/core/item/type-registry.js.map +1 -1
  391. package/dist/core/output/mutation-projection.js +42 -26
  392. package/dist/core/output/mutation-projection.js.map +1 -1
  393. package/dist/core/schema/runtime-schema.js +97 -80
  394. package/dist/core/schema/runtime-schema.js.map +1 -1
  395. package/dist/core/schema/status-defs-file.js +26 -3
  396. package/dist/core/schema/status-defs-file.js.map +1 -1
  397. package/dist/core/search/corpus.js +25 -19
  398. package/dist/core/search/corpus.js.map +1 -1
  399. package/dist/core/search/semantic-defaults.js +64 -37
  400. package/dist/core/search/semantic-defaults.js.map +1 -1
  401. package/dist/core/search/vector-stores.js +32 -17
  402. package/dist/core/search/vector-stores.js.map +1 -1
  403. package/dist/core/sentry/helpers.js +31 -28
  404. package/dist/core/sentry/helpers.js.map +1 -1
  405. package/dist/core/sentry/instrument.js +54 -43
  406. package/dist/core/sentry/instrument.js.map +1 -1
  407. package/dist/core/shared/memo.d.ts +12 -0
  408. package/dist/core/shared/memo.js +25 -0
  409. package/dist/core/shared/memo.js.map +1 -0
  410. package/dist/core/shared/serialization.js +24 -14
  411. package/dist/core/shared/serialization.js.map +1 -1
  412. package/dist/core/shared/time.js +26 -4
  413. package/dist/core/shared/time.js.map +1 -1
  414. package/dist/core/store/front-matter-cache.d.ts +5 -0
  415. package/dist/core/store/front-matter-cache.js +316 -171
  416. package/dist/core/store/front-matter-cache.js.map +1 -1
  417. package/dist/core/store/item-store.js +33 -26
  418. package/dist/core/store/item-store.js.map +1 -1
  419. package/dist/core/store/settings.js +247 -203
  420. package/dist/core/store/settings.js.map +1 -1
  421. package/dist/core/test/background-runs.js +189 -160
  422. package/dist/core/test/background-runs.js.map +1 -1
  423. package/dist/sdk/cli-contracts/flag-contracts.js +71 -99
  424. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  425. package/dist/sdk/compose.js +51 -42
  426. package/dist/sdk/compose.js.map +1 -1
  427. package/docs/AGENT_GUIDE.md +2 -2
  428. package/docs/ARCHITECTURE.md +2 -2
  429. package/docs/COMMANDS.md +8 -4
  430. package/docs/CONFIGURATION.md +1 -1
  431. package/docs/EXTENSIONS.md +12 -12
  432. package/docs/ONBOARDING.md +4 -2
  433. package/docs/README.md +2 -0
  434. package/docs/examples/starter-extension/README.md +11 -10
  435. package/marketplace.json +3 -3
  436. package/package.json +2 -2
  437. package/packages/pm-beads/extensions/beads/runtime.ts +240 -167
  438. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +65 -58
  439. package/packages/pm-todos/extensions/todos/runtime.ts +65 -42
  440. package/plugins/pm-claude/.claude-plugin/plugin.json +2 -2
  441. package/plugins/pm-claude/README.md +6 -3
  442. package/plugins/pm-claude/commands/pm-init.md +1 -1
  443. package/dist/cli-bundle/chunks/activity-AW6XVFH6.js +0 -16
  444. package/dist/cli-bundle/chunks/aggregate-JTEF4BP7.js.map +0 -1
  445. package/dist/cli-bundle/chunks/chunk-22WKIL3H.js.map +0 -1
  446. package/dist/cli-bundle/chunks/chunk-2D4HATP2.js.map +0 -1
  447. package/dist/cli-bundle/chunks/chunk-3J6JRJ3I.js.map +0 -7
  448. package/dist/cli-bundle/chunks/chunk-3K2M5OYU.js.map +0 -7
  449. package/dist/cli-bundle/chunks/chunk-3S2KT7NG.js.map +0 -7
  450. package/dist/cli-bundle/chunks/chunk-3VGN2UWE.js.map +0 -1
  451. package/dist/cli-bundle/chunks/chunk-3XZCOZ5J.js.map +0 -1
  452. package/dist/cli-bundle/chunks/chunk-4XOIEKSD.js.map +0 -1
  453. package/dist/cli-bundle/chunks/chunk-55SNVXRQ.js.map +0 -7
  454. package/dist/cli-bundle/chunks/chunk-5CGRF3L5.js.map +0 -1
  455. package/dist/cli-bundle/chunks/chunk-7R4QEMZZ.js.map +0 -1
  456. package/dist/cli-bundle/chunks/chunk-AXIDKKAT.js.map +0 -1
  457. package/dist/cli-bundle/chunks/chunk-BDTISOSD.js.map +0 -7
  458. package/dist/cli-bundle/chunks/chunk-BZCEN4JA.js.map +0 -7
  459. package/dist/cli-bundle/chunks/chunk-CF7RL6FR.js.map +0 -1
  460. package/dist/cli-bundle/chunks/chunk-CWFNTKQJ.js.map +0 -1
  461. package/dist/cli-bundle/chunks/chunk-FFMQB7WR.js.map +0 -1
  462. package/dist/cli-bundle/chunks/chunk-HXTQJXWT.js.map +0 -1
  463. package/dist/cli-bundle/chunks/chunk-IPYBJWTE.js.map +0 -7
  464. package/dist/cli-bundle/chunks/chunk-IZBR4NRW.js.map +0 -7
  465. package/dist/cli-bundle/chunks/chunk-JLM7BHI7.js.map +0 -7
  466. package/dist/cli-bundle/chunks/chunk-JSU5P7VS.js.map +0 -1
  467. package/dist/cli-bundle/chunks/chunk-JWXRETDF.js.map +0 -1
  468. package/dist/cli-bundle/chunks/chunk-KNPEF7QG.js.map +0 -7
  469. package/dist/cli-bundle/chunks/chunk-MDPEOIGN.js.map +0 -7
  470. package/dist/cli-bundle/chunks/chunk-NFDPYAIP.js.map +0 -7
  471. package/dist/cli-bundle/chunks/chunk-NUHHPVVS.js.map +0 -7
  472. package/dist/cli-bundle/chunks/chunk-NWMZWYYB.js.map +0 -1
  473. package/dist/cli-bundle/chunks/chunk-OTUHB4HS.js.map +0 -1
  474. package/dist/cli-bundle/chunks/chunk-RGEMWD6Q.js.map +0 -7
  475. package/dist/cli-bundle/chunks/chunk-RLDHZHQS.js.map +0 -1
  476. package/dist/cli-bundle/chunks/chunk-RMMQ74TG.js.map +0 -7
  477. package/dist/cli-bundle/chunks/chunk-RVUALSJF.js.map +0 -7
  478. package/dist/cli-bundle/chunks/chunk-TP5Q5ZD3.js.map +0 -1
  479. package/dist/cli-bundle/chunks/chunk-V3NOKJF2.js.map +0 -1
  480. package/dist/cli-bundle/chunks/chunk-VARHOHYV.js.map +0 -7
  481. package/dist/cli-bundle/chunks/chunk-WYDHYJPO.js.map +0 -7
  482. package/dist/cli-bundle/chunks/chunk-YITK2PJ6.js.map +0 -7
  483. package/dist/cli-bundle/chunks/chunk-ZETXE4SE.js.map +0 -1
  484. package/dist/cli-bundle/chunks/close-E6ZZGCJY.js +0 -14
  485. package/dist/cli-bundle/chunks/close-many-BG5QQIDQ.js.map +0 -7
  486. package/dist/cli-bundle/chunks/close-many-LDRVEQY2.js.map +0 -1
  487. package/dist/cli-bundle/chunks/config-DMSU64QO.js +0 -1541
  488. package/dist/cli-bundle/chunks/config-DMSU64QO.js.map +0 -7
  489. package/dist/cli-bundle/chunks/config-QH2DICD6.js +0 -1531
  490. package/dist/cli-bundle/chunks/config-QH2DICD6.js.map +0 -1
  491. package/dist/cli-bundle/chunks/contracts-HN7ABKLP.js.map +0 -7
  492. package/dist/cli-bundle/chunks/contracts-W4FZVVD6.js.map +0 -1
  493. package/dist/cli-bundle/chunks/create-OH3BDGBB.js +0 -28
  494. package/dist/cli-bundle/chunks/get-A7MAOHCU.js.map +0 -7
  495. package/dist/cli-bundle/chunks/get-DSDEKJ3L.js.map +0 -1
  496. package/dist/cli-bundle/chunks/health-3IPFLKXB.js.map +0 -1
  497. package/dist/cli-bundle/chunks/health-GZXGBZ36.js.map +0 -7
  498. package/dist/cli-bundle/chunks/history-WSZHY3PN.js +0 -18
  499. package/dist/cli-bundle/chunks/history-compact-2WRZ2WK4.js.map +0 -7
  500. package/dist/cli-bundle/chunks/history-compact-HR7BB4LR.js.map +0 -1
  501. package/dist/cli-bundle/chunks/history-redact-MP6CH7U5.js +0 -19
  502. package/dist/cli-bundle/chunks/history-repair-LCMOS45X.js.map +0 -7
  503. package/dist/cli-bundle/chunks/history-repair-XA3LC4GA.js.map +0 -1
  504. package/dist/cli-bundle/chunks/init-PAX32BJA.js +0 -22
  505. package/dist/cli-bundle/chunks/next-BCERKDUR.js.map +0 -7
  506. package/dist/cli-bundle/chunks/next-FYTQF6HG.js.map +0 -1
  507. package/dist/cli-bundle/chunks/plan-4WXEQCTN.js.map +0 -7
  508. package/dist/cli-bundle/chunks/plan-RKZHQVXR.js.map +0 -1
  509. package/dist/cli-bundle/chunks/profile-4OMM32CD.js.map +0 -7
  510. package/dist/cli-bundle/chunks/profile-QLER5ENE.js.map +0 -1
  511. package/dist/cli-bundle/chunks/register-list-query-7LV46VAU.js +0 -400
  512. package/dist/cli-bundle/chunks/register-list-query-7LV46VAU.js.map +0 -1
  513. package/dist/cli-bundle/chunks/register-list-query-SNG5PGA4.js +0 -410
  514. package/dist/cli-bundle/chunks/register-list-query-SNG5PGA4.js.map +0 -7
  515. package/dist/cli-bundle/chunks/register-mutation-ENNDUAZG.js.map +0 -1
  516. package/dist/cli-bundle/chunks/register-mutation-KK7PHYYU.js.map +0 -7
  517. package/dist/cli-bundle/chunks/register-operations-C6OWLDSH.js +0 -486
  518. package/dist/cli-bundle/chunks/register-operations-C6OWLDSH.js.map +0 -1
  519. package/dist/cli-bundle/chunks/register-operations-HZ6XERQG.js.map +0 -7
  520. package/dist/cli-bundle/chunks/register-setup-P67EMBDJ.js.map +0 -1
  521. package/dist/cli-bundle/chunks/register-setup-ZKJ53RS7.js.map +0 -7
  522. package/dist/cli-bundle/chunks/restore-YALDGTQR.js +0 -17
  523. package/dist/cli-bundle/chunks/telemetry-BZUF6H7G.js.map +0 -1
  524. package/dist/cli-bundle/chunks/telemetry-GAHHQTOS.js.map +0 -7
  525. package/dist/cli-bundle/chunks/test-all-L2MDDUCA.js +0 -358
  526. package/dist/cli-bundle/chunks/test-all-L2MDDUCA.js.map +0 -1
  527. package/dist/cli-bundle/chunks/test-all-RBZ6DLU2.js +0 -361
  528. package/dist/cli-bundle/chunks/test-all-RBZ6DLU2.js.map +0 -7
  529. package/dist/cli-bundle/chunks/test-runs-PLRAZEFW.js.map +0 -7
  530. package/dist/cli-bundle/chunks/test-runs-UXIXPDKU.js.map +0 -1
  531. package/dist/cli-bundle/chunks/update-AMRSOIWP.js +0 -24
  532. package/dist/cli-bundle/chunks/validate-MTUVL5VC.js.map +0 -7
  533. package/dist/cli-bundle/chunks/validate-X5W76YJL.js.map +0 -1
  534. /package/dist/cli-bundle/chunks/{activity-DBLQVIP6.js.map → activity-5YWLSPGE.js.map} +0 -0
  535. /package/dist/cli-bundle/chunks/{activity-AW6XVFH6.js.map → activity-BIML7K2D.js.map} +0 -0
  536. /package/dist/cli-bundle/chunks/{append-LOVPGVPT.js.map → append-EZESUVJT.js.map} +0 -0
  537. /package/dist/cli-bundle/chunks/{append-QCFJSDFL.js.map → append-JFG4WQMG.js.map} +0 -0
  538. /package/dist/cli-bundle/chunks/{chunk-BHO33VBQ.js.map → chunk-3W2HJKJX.js.map} +0 -0
  539. /package/dist/cli-bundle/chunks/{chunk-4DUVCVLZ.js.map → chunk-4PFVUUYV.js.map} +0 -0
  540. /package/dist/cli-bundle/chunks/{chunk-IJYK2T43.js.map → chunk-5E7N4T2Z.js.map} +0 -0
  541. /package/dist/cli-bundle/chunks/{chunk-NKZAN7BD.js.map → chunk-5IZUBZBR.js.map} +0 -0
  542. /package/dist/cli-bundle/chunks/{chunk-NOLPZMSV.js.map → chunk-5JIWFWOZ.js.map} +0 -0
  543. /package/dist/cli-bundle/chunks/{chunk-6AQZPVHQ.js.map → chunk-6CDCWKSX.js.map} +0 -0
  544. /package/dist/cli-bundle/chunks/{chunk-LB6TP6MC.js.map → chunk-6NYJGMTY.js.map} +0 -0
  545. /package/dist/cli-bundle/chunks/{chunk-SLMUGTK3.js.map → chunk-7CLLC75T.js.map} +0 -0
  546. /package/dist/cli-bundle/chunks/{chunk-2466X6E4.js.map → chunk-7LYO6S5A.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{chunk-W4ULYO7Z.js.map → chunk-A3OQ7TFW.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-GJ326ZKX.js.map → chunk-ER4ME5U2.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-HZZEHPRG.js.map → chunk-ERG65A2L.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-L5OEFZQG.js.map → chunk-FH2H3CBD.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-JPECA746.js.map → chunk-FUFFPIYA.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-27BXPBAY.js.map → chunk-GUYNUXQT.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{chunk-MAUKX7JC.js.map → chunk-GVJE5T7Q.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{chunk-ZRP4VG5U.js.map → chunk-JBZ2NTKX.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{chunk-EJUDVUYZ.js.map → chunk-KEZOIPCR.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{chunk-HYTGA6GI.js.map → chunk-MDHWWBNZ.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{chunk-N74UMG5H.js.map → chunk-MEZZZBYX.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{chunk-SDR5J34Q.js.map → chunk-NZ7QIUP5.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{chunk-DDPTYJIM.js.map → chunk-P5L7Z2O6.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{chunk-OGXLACHC.js.map → chunk-SU2E4AWU.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{chunk-HPPFYYOV.js.map → chunk-SU3TB4NS.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-G7I7DEZA.js.map → chunk-T4XBKJ3F.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-VICZWYGZ.js.map → chunk-U5TR4N7J.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-EVMTBV6V.js.map → chunk-UMNQZS4H.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-A7FPBAQS.js.map → chunk-WJA3PXW7.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-QCWF6IYD.js.map → chunk-YSDFIY7N.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-UZIWVBE6.js.map → chunk-YSGTMDWC.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{chunk-64HNBBFQ.js.map → chunk-Z5F6XZXE.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{chunk-AVEE5EHK.js.map → chunk-Z7RPDF2Y.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{claim-T3GCKV7C.js.map → claim-2BGBGSVI.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{claim-EMQLYPRW.js.map → claim-5GU7OE67.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{close-E6ZZGCJY.js.map → close-6YODBUIV.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{close-TQYAAFJP.js.map → close-AFVKPR57.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{comments-YUXJRZPQ.js.map → comments-DNWHEBOS.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{comments-QCKR2YY2.js.map → comments-RW23R3VE.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{context-B6275WPX.js.map → context-OYXRGY7S.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{context-OCZ3FJ4Z.js.map → context-PKCEHQY3.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{copy-DEM4DATS.js.map → copy-6XOR3HKN.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{copy-BTJOSKKT.js.map → copy-I4NCLBR4.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{create-RLRJMRTM.js.map → create-PM45M6PE.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{create-OH3BDGBB.js.map → create-Z7YCH3BE.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{delete-BHK7VB2Z.js.map → delete-7YXHYG67.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{delete-LSVHAB4Y.js.map → delete-LPISP43T.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{deps-XHYXWEPT.js.map → deps-N2T26FME.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{deps-4UDFJRUA.js.map → deps-WATKQDE3.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{docs-GYZNVS26.js.map → docs-6LQ3GLM7.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{docs-26S44RXU.js.map → docs-Z3X6JZLT.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{eval-UYF3ZPVO.js.map → eval-6DCLG52D.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{eval-PGRVIJQU.js.map → eval-Y3ZCUTHK.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{extension-CPSLJQVE.js.map → extension-BNINIMT7.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{extension-CXJ6RELI.js.map → extension-QWE4YYK5.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{files-NQHEXUZD.js.map → files-6SGKHS6O.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{files-MBNICQFM.js.map → files-FUYPSOFJ.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{focus-DWYIG7GU.js.map → focus-2Q3K76G2.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{focus-XZW5423D.js.map → focus-ATLBWXXD.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{gc-LPVMKJQJ.js.map → gc-RUYEMNRF.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{gc-7GQYOS2G.js.map → gc-TDWSDR66.js.map} +0 -0
  598. /package/dist/cli-bundle/chunks/{history-WSZHY3PN.js.map → history-CGNQJXFE.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{history-NERDJNUB.js.map → history-SGRRS72R.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{history-redact-O3NBCNWC.js.map → history-redact-IRL7WJ3E.js.map} +0 -0
  601. /package/dist/cli-bundle/chunks/{history-redact-MP6CH7U5.js.map → history-redact-N3JK7VBW.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{init-64XDLQJB.js.map → init-4GESW7RM.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{init-PAX32BJA.js.map → init-XIDPABA4.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{learnings-LPKCSJX7.js.map → learnings-4BHWFFUV.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{learnings-JR6MA5TI.js.map → learnings-4FJY7WIW.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{list-G5Y65VF6.js.map → list-472TIOVK.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{list-DNBJVO3E.js.map → list-D7BF5CL2.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{notes-2BMU3VVQ.js.map → notes-6KNOSLIT.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{notes-6KTGO2OJ.js.map → notes-W4UEICGF.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{restore-4MHZFJ2E.js.map → restore-44IHMMZZ.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{restore-YALDGTQR.js.map → restore-EXHU34EU.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-LB6DOLRL.js.map → scheduling-shortcuts-OLHNLAZY.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-UTOYKLXQ.js.map → scheduling-shortcuts-TSBK4AY5.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{schema-73HR2OJW.js.map → schema-IB2NZZWD.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{schema-U6LJKSIR.js.map → schema-VBCELP5G.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{search-AXPXKZER.js.map → search-7UBETML4.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{search-KILGT37L.js.map → search-R227JOL6.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{stats-W5KNVJWQ.js.map → stats-FAG7COEH.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{stats-PSYVVTNZ.js.map → stats-MCK7PLYS.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{test-PWDIZ255.js.map → test-QY44WAMR.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{test-ACD52Z3S.js.map → test-SY76DZTO.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{update-AMRSOIWP.js.map → update-A7EICML6.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{update-KFX2SIAC.js.map → update-IKJZWLQC.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{upgrade-BRL6KCOJ.js.map → upgrade-NWMR3VQL.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{upgrade-HAK6JG2O.js.map → upgrade-VU46BLJZ.js.map} +0 -0
@@ -4,7 +4,7 @@
4
4
  * Implements the pm update command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !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]="17376741-e64e-5a26-9c7e-3f23fee80095")}catch(e){}}();
7
+ !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]="6156dbbd-29ea-58f5-ba6e-c9ae989e23e3")}catch(e){}}();
8
8
  import { pathExists } from "../../core/fs/fs-utils.js";
9
9
  import { canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, } from "../../core/item/type-registry.js";
10
10
  import { normalizeItemId } from "../../core/item/id.js";
@@ -574,7 +574,7 @@ function normalizeUpdatePolicyOptionKey(raw, typeName) {
574
574
  }
575
575
  return canonical;
576
576
  }
577
- function collectProvidedUpdatePolicyOptions(options, extensionFieldNames) {
577
+ function collectProvidedUpdatePolicyOptions(options, runtimeFieldRegistry, extensionFieldNames) {
578
578
  const provided = new Set();
579
579
  const mark = (optionKey, isProvided) => {
580
580
  if (isProvided) {
@@ -655,14 +655,14 @@ function collectProvidedUpdatePolicyOptions(options, extensionFieldNames) {
655
655
  mark("event", options.clearEvents === true);
656
656
  mark("typeOption", options.clearTypeOptions === true);
657
657
  if (options.unset && options.unset.length > 0) {
658
- const unsetTargets = parseUpdateUnsetTargets(options.unset, undefined, extensionFieldNames);
658
+ const unsetTargets = parseUpdateUnsetTargets(options.unset, runtimeFieldRegistry, extensionFieldNames);
659
659
  for (const optionKey of unsetTargets.optionKeys) {
660
660
  mark(optionKey, true);
661
661
  }
662
662
  }
663
663
  return provided;
664
664
  }
665
- function enforceUpdateOptionsByType(typeName, options, typeRegistry, extensionFieldNames) {
665
+ function enforceUpdateOptionsByType(typeName, options, typeRegistry, runtimeFieldRegistry, extensionFieldNames) {
666
666
  const typeDefinition = resolveTypeDefinition(typeName, typeRegistry);
667
667
  if (!typeDefinition) {
668
668
  throw new PmCliError(`Invalid type value "${typeName}"`, EXIT_CODE.USAGE);
@@ -671,7 +671,7 @@ function enforceUpdateOptionsByType(typeName, options, typeRegistry, extensionFi
671
671
  if (policyState.errors.length > 0) {
672
672
  throw new PmCliError(policyState.errors.join("; "), EXIT_CODE.CONFLICT);
673
673
  }
674
- const provided = collectProvidedUpdatePolicyOptions(options, extensionFieldNames);
674
+ const provided = collectProvidedUpdatePolicyOptions(options, runtimeFieldRegistry, extensionFieldNames);
675
675
  for (const disabled of policyState.disabled) {
676
676
  if (provided.has(normalizeUpdatePolicyOptionKey(disabled, typeName))) {
677
677
  throw new PmCliError(`Option ${commandOptionFlagLabel("update", disabled)} is disabled for type "${typeName}" by command_option_policies`, EXIT_CODE.USAGE);
@@ -683,6 +683,95 @@ function enforceUpdateOptionsByType(typeName, options, typeRegistry, extensionFi
683
683
  }
684
684
  }
685
685
  }
686
+ const UPDATE_LEGACY_SCALAR_OPTION_KEYS = [
687
+ "tags",
688
+ "closeReason",
689
+ "deadline",
690
+ "estimatedMinutes",
691
+ "acceptanceCriteria",
692
+ "definitionOfReady",
693
+ "goal",
694
+ "objective",
695
+ "value",
696
+ "impact",
697
+ "outcome",
698
+ "whyNow",
699
+ "assignee",
700
+ "parent",
701
+ "reviewer",
702
+ "risk",
703
+ "confidence",
704
+ "sprint",
705
+ "release",
706
+ "blockedBy",
707
+ "blockedReason",
708
+ "unblockNote",
709
+ "reporter",
710
+ "severity",
711
+ "environment",
712
+ "reproSteps",
713
+ "resolution",
714
+ "expectedResult",
715
+ "actualResult",
716
+ "affectedVersion",
717
+ "fixedVersion",
718
+ "component",
719
+ "regression",
720
+ "customerImpact",
721
+ ];
722
+ const UPDATE_SIMPLE_FIELD_FLAG_KEYS = [
723
+ "title",
724
+ "description",
725
+ "body",
726
+ "status",
727
+ "closeReason",
728
+ "priority",
729
+ "type",
730
+ "deadline",
731
+ "estimatedMinutes",
732
+ "acceptanceCriteria",
733
+ "definitionOfReady",
734
+ "goal",
735
+ "objective",
736
+ "value",
737
+ "impact",
738
+ "outcome",
739
+ "whyNow",
740
+ "assignee",
741
+ "parent",
742
+ "reviewer",
743
+ "risk",
744
+ "confidence",
745
+ "sprint",
746
+ "release",
747
+ "blockedBy",
748
+ "blockedReason",
749
+ "unblockNote",
750
+ "reporter",
751
+ "severity",
752
+ "environment",
753
+ "reproSteps",
754
+ "resolution",
755
+ "expectedResult",
756
+ "actualResult",
757
+ "affectedVersion",
758
+ "fixedVersion",
759
+ "component",
760
+ "regression",
761
+ "customerImpact",
762
+ "dep",
763
+ "depRemove",
764
+ "comment",
765
+ "note",
766
+ "learning",
767
+ "file",
768
+ "test",
769
+ "doc",
770
+ "reminder",
771
+ "event",
772
+ "typeOption",
773
+ "field",
774
+ ];
686
775
  const UPDATE_POST_TAG_SCALAR_MUTATIONS = [
687
776
  {
688
777
  optionKey: "deadline",
@@ -749,12 +838,9 @@ function applyUpdateScalarMutations(definitions, options, context) {
749
838
  context.changedFields.push(definition.metadataKey);
750
839
  }
751
840
  }
752
- /**
753
- * Implements run update for the public runtime surface of this module.
754
- */
755
- export async function runUpdate(id, options, global) {
841
+ async function resolveStdinUpdateOptions(options) {
756
842
  const stdinResolver = createStdinTokenResolver();
757
- options = normalizeLegacyNoneUpdateOptions({
843
+ return normalizeLegacyNoneUpdateOptions({
758
844
  ...options,
759
845
  body: await stdinResolver.resolveValue(options.body, "--body"),
760
846
  dep: await stdinResolver.resolveList(options.dep, "--dep"),
@@ -770,26 +856,9 @@ export async function runUpdate(id, options, global) {
770
856
  typeOption: await stdinResolver.resolveList(options.typeOption, "--type-option"),
771
857
  field: await stdinResolver.resolveList(options.field, "--field"),
772
858
  });
773
- const pmRoot = resolvePmRoot(process.cwd(), global.path);
774
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
775
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
776
- }
777
- const settings = await readSettings(pmRoot);
778
- const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
779
- const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
780
- const extensionRegistrations = getActiveExtensionRegistrations();
781
- const extensionFieldNames = collectRegisteredItemFieldNames(extensionRegistrations);
782
- const typeRegistry = resolveItemTypeRegistry(settings, extensionRegistrations);
783
- // Per-type allowed-transition enforcement is read RAW (not preset-derived) so
784
- // existing projects are unaffected when unset; defaults to "off".
785
- const workflowEnforcement = settings.governance.workflow_enforcement ?? "off";
786
- const typeWorkflows = workflowEnforcement === "off" ? [] : resolveTypeWorkflows(settings.schema);
787
- const parentReferencePolicy = settings.validation.parent_reference;
788
- const sprintReleasePolicy = settings.validation.sprint_release_format;
789
- const unsetTargets = parseUpdateUnsetTargets(options.unset, runtimeFieldRegistry, extensionFieldNames);
790
- const clearOptionKeys = new Set(unsetTargets.optionKeys);
791
- const clearFrontMatterKeys = new Set(unsetTargets.frontMatterKeys);
792
- const clearCollectionDefinitions = [
859
+ }
860
+ function buildClearCollectionDefinitions(options) {
861
+ return [
793
862
  {
794
863
  enabled: options.clearDeps || options.replaceDeps,
795
864
  optionKey: "dep",
@@ -871,6 +940,8 @@ export async function runUpdate(id, options, global) {
871
940
  frontMatterKey: "type_options",
872
941
  },
873
942
  ];
943
+ }
944
+ function validateReplaceOptions(options) {
874
945
  if (options.replaceDeps === true && (options.dep === undefined || options.dep.length === 0)) {
875
946
  throw new PmCliError("--replace-deps requires at least one --dep entry", EXIT_CODE.USAGE);
876
947
  }
@@ -883,57 +954,31 @@ export async function runUpdate(id, options, global) {
883
954
  if (options.replaceTests === true && options.clearTests === true) {
884
955
  throw new PmCliError("--replace-tests cannot be combined with --clear-tests", EXIT_CODE.USAGE);
885
956
  }
886
- for (const definition of clearCollectionDefinitions) {
957
+ }
958
+ function applyClearCollectionDefinitions(params) {
959
+ for (const definition of params.definitions) {
887
960
  if (!definition.enabled) {
888
961
  continue;
889
962
  }
890
- if (definition.values &&
891
- definition.values.length > 0 &&
892
- !((definition.optionKey === "dep" && options.replaceDeps === true) ||
893
- (definition.optionKey === "test" && options.replaceTests === true))) {
963
+ const isReplacement = (definition.optionKey === "dep" && params.options.replaceDeps === true) ||
964
+ (definition.optionKey === "test" && params.options.replaceTests === true);
965
+ if (definition.values && definition.values.length > 0 && !isReplacement) {
894
966
  throw new PmCliError(`Cannot combine ${definition.clearFlag} with ${definition.valueFlag}`, EXIT_CODE.USAGE);
895
967
  }
896
- clearOptionKeys.add(definition.optionKey);
897
- clearFrontMatterKeys.add(definition.frontMatterKey);
968
+ params.clearOptionKeys.add(definition.optionKey);
969
+ params.clearFrontMatterKeys.add(definition.frontMatterKey);
898
970
  }
899
- enforceAllowAuditUpdateScope(id, options, clearFrontMatterKeys);
900
- const scalarOptionPresence = {
901
- tags: options.tags !== undefined,
902
- closeReason: options.closeReason !== undefined,
903
- deadline: options.deadline !== undefined,
904
- estimatedMinutes: options.estimatedMinutes !== undefined,
905
- acceptanceCriteria: options.acceptanceCriteria !== undefined,
906
- definitionOfReady: options.definitionOfReady !== undefined,
907
- order: options.order !== undefined || options.rank !== undefined,
908
- goal: options.goal !== undefined,
909
- objective: options.objective !== undefined,
910
- value: options.value !== undefined,
911
- impact: options.impact !== undefined,
912
- outcome: options.outcome !== undefined,
913
- whyNow: options.whyNow !== undefined,
914
- assignee: options.assignee !== undefined,
915
- parent: options.parent !== undefined,
916
- reviewer: options.reviewer !== undefined,
917
- risk: options.risk !== undefined,
918
- confidence: options.confidence !== undefined,
919
- sprint: options.sprint !== undefined,
920
- release: options.release !== undefined,
921
- blockedBy: options.blockedBy !== undefined,
922
- blockedReason: options.blockedReason !== undefined,
923
- unblockNote: options.unblockNote !== undefined,
924
- reporter: options.reporter !== undefined,
925
- severity: options.severity !== undefined,
926
- environment: options.environment !== undefined,
927
- reproSteps: options.reproSteps !== undefined,
928
- resolution: options.resolution !== undefined,
929
- expectedResult: options.expectedResult !== undefined,
930
- actualResult: options.actualResult !== undefined,
931
- affectedVersion: options.affectedVersion !== undefined,
932
- fixedVersion: options.fixedVersion !== undefined,
933
- component: options.component !== undefined,
934
- regression: options.regression !== undefined,
935
- customerImpact: options.customerImpact !== undefined,
936
- };
971
+ }
972
+ function buildScalarOptionPresence(options) {
973
+ const presence = {};
974
+ for (const key of UPDATE_LEGACY_SCALAR_OPTION_KEYS) {
975
+ presence[String(key)] = options[key] !== undefined;
976
+ }
977
+ presence.order = options.order !== undefined || options.rank !== undefined;
978
+ return presence;
979
+ }
980
+ function rejectUnsetScalarConflicts(options, unsetTargets) {
981
+ const scalarOptionPresence = buildScalarOptionPresence(options);
937
982
  for (const [optionKey, hasValue] of Object.entries(scalarOptionPresence)) {
938
983
  if (!hasValue || !unsetTargets.optionKeys.has(optionKey)) {
939
984
  continue;
@@ -941,59 +986,576 @@ export async function runUpdate(id, options, global) {
941
986
  const unsetField = UPDATE_OPTION_KEY_TO_UNSET_CANONICAL.get(optionKey) ?? optionKey;
942
987
  throw new PmCliError(`Cannot combine --unset ${unsetField} with ${commandOptionFlagLabel("update", optionKey)}`, EXIT_CODE.USAGE);
943
988
  }
944
- // `--add-tags`/`--remove-tags` aren't in the scalar presence map above (they
945
- // are repeatable), but combining them with `--unset tags` is the same
946
- // contradiction as `--unset tags --tags ...`, so reject it explicitly.
947
- if (clearFrontMatterKeys.has("tags")) {
948
- if (Array.isArray(options.addTags) && options.addTags.length > 0) {
949
- throw new PmCliError("Cannot combine --unset tags with --add-tags", EXIT_CODE.USAGE);
950
- }
951
- if (Array.isArray(options.removeTags) && options.removeTags.length > 0) {
952
- throw new PmCliError("Cannot combine --unset tags with --remove-tags", EXIT_CODE.USAGE);
953
- }
989
+ if (!unsetTargets.frontMatterKeys.has("tags")) {
990
+ return;
991
+ }
992
+ if (Array.isArray(options.addTags) && options.addTags.length > 0) {
993
+ throw new PmCliError("Cannot combine --unset tags with --add-tags", EXIT_CODE.USAGE);
954
994
  }
995
+ if (Array.isArray(options.removeTags) && options.removeTags.length > 0) {
996
+ throw new PmCliError("Cannot combine --unset tags with --remove-tags", EXIT_CODE.USAGE);
997
+ }
998
+ }
999
+ function rejectLegacyScalarTokens(options) {
955
1000
  const assertNoLegacyScalarToken = (value, optionKey) => {
956
1001
  const unsetField = UPDATE_OPTION_KEY_TO_UNSET_CANONICAL.get(optionKey);
957
1002
  const hint = unsetField ? `Use --unset ${unsetField} to clear this field.` : undefined;
958
1003
  assertNoLegacyNoneToken(value, commandOptionFlagLabel("update", optionKey), hint);
959
1004
  };
960
- assertNoLegacyScalarToken(options.tags, "tags");
961
- assertNoLegacyScalarToken(options.closeReason, "closeReason");
962
- assertNoLegacyScalarToken(options.deadline, "deadline");
963
- assertNoLegacyScalarToken(options.estimatedMinutes, "estimatedMinutes");
964
- assertNoLegacyScalarToken(options.acceptanceCriteria, "acceptanceCriteria");
965
- assertNoLegacyScalarToken(options.definitionOfReady, "definitionOfReady");
1005
+ for (const key of UPDATE_LEGACY_SCALAR_OPTION_KEYS) {
1006
+ assertNoLegacyScalarToken(options[key], String(key));
1007
+ }
966
1008
  assertNoLegacyScalarToken(options.order ?? options.rank, "order");
967
- assertNoLegacyScalarToken(options.goal, "goal");
968
- assertNoLegacyScalarToken(options.objective, "objective");
969
- assertNoLegacyScalarToken(options.value, "value");
970
- assertNoLegacyScalarToken(options.impact, "impact");
971
- assertNoLegacyScalarToken(options.outcome, "outcome");
972
- assertNoLegacyScalarToken(options.whyNow, "whyNow");
973
- assertNoLegacyScalarToken(options.assignee, "assignee");
974
- assertNoLegacyScalarToken(options.parent, "parent");
975
- assertNoLegacyScalarToken(options.reviewer, "reviewer");
976
- assertNoLegacyScalarToken(options.risk, "risk");
977
- assertNoLegacyScalarToken(options.confidence, "confidence");
978
- assertNoLegacyScalarToken(options.sprint, "sprint");
979
- assertNoLegacyScalarToken(options.release, "release");
980
- assertNoLegacyScalarToken(options.blockedBy, "blockedBy");
981
- assertNoLegacyScalarToken(options.blockedReason, "blockedReason");
982
- assertNoLegacyScalarToken(options.unblockNote, "unblockNote");
983
- assertNoLegacyScalarToken(options.reporter, "reporter");
984
- assertNoLegacyScalarToken(options.severity, "severity");
985
- assertNoLegacyScalarToken(options.environment, "environment");
986
- assertNoLegacyScalarToken(options.reproSteps, "reproSteps");
987
- assertNoLegacyScalarToken(options.resolution, "resolution");
988
- assertNoLegacyScalarToken(options.expectedResult, "expectedResult");
989
- assertNoLegacyScalarToken(options.actualResult, "actualResult");
990
- assertNoLegacyScalarToken(options.affectedVersion, "affectedVersion");
991
- assertNoLegacyScalarToken(options.fixedVersion, "fixedVersion");
992
- assertNoLegacyScalarToken(options.component, "component");
993
- assertNoLegacyScalarToken(options.regression, "regression");
994
- assertNoLegacyScalarToken(options.customerImpact, "customerImpact");
995
1009
  assertNoLegacyNoneTokens(options.reminder, "--reminder", "Use --clear-reminders to clear reminders.");
996
1010
  assertNoLegacyNoneTokens(options.event, "--event", "Use --clear-events to clear linked events.");
1011
+ }
1012
+ function buildUpdateFieldFlags(options, runtimeFieldUpdates) {
1013
+ const flags = {};
1014
+ for (const key of UPDATE_SIMPLE_FIELD_FLAG_KEYS) {
1015
+ flags[String(key)] = options[key] !== undefined;
1016
+ }
1017
+ flags.tags = options.tags !== undefined;
1018
+ flags.addTags = Array.isArray(options.addTags) && options.addTags.length > 0;
1019
+ flags.removeTags = Array.isArray(options.removeTags) && options.removeTags.length > 0;
1020
+ flags.order = options.order !== undefined;
1021
+ flags.rank = options.rank !== undefined;
1022
+ flags.replaceDeps = options.replaceDeps === true;
1023
+ flags.replaceTests = options.replaceTests === true;
1024
+ flags.unset = options.unset !== undefined && options.unset.length > 0;
1025
+ flags.clearDeps = options.clearDeps === true;
1026
+ flags.clearComments = options.clearComments === true;
1027
+ flags.clearNotes = options.clearNotes === true;
1028
+ flags.clearLearnings = options.clearLearnings === true;
1029
+ flags.clearFiles = options.clearFiles === true;
1030
+ flags.clearTests = options.clearTests === true;
1031
+ flags.clearDocs = options.clearDocs === true;
1032
+ flags.clearReminders = options.clearReminders === true;
1033
+ flags.clearEvents = options.clearEvents === true;
1034
+ flags.clearTypeOptions = options.clearTypeOptions === true;
1035
+ flags.runtimeFields = Object.keys(runtimeFieldUpdates).length > 0;
1036
+ return flags;
1037
+ }
1038
+ async function buildNoopUpdateResult(params) {
1039
+ const located = await locateItem(params.pmRoot, params.id, params.settings.id_prefix, params.settings.item_format, params.typeRegistry.type_to_folder);
1040
+ if (!located) {
1041
+ throw await buildItemNotFoundError(params.pmRoot, params.id, params.settings.id_prefix, params.typeRegistry.type_to_folder);
1042
+ }
1043
+ const { document } = await readLocatedItem(located, { schema: params.settings.schema });
1044
+ return {
1045
+ item: toItemRecord(document.metadata),
1046
+ changed_fields: [],
1047
+ warnings: ["noop_no_update_fields"],
1048
+ };
1049
+ }
1050
+ async function assertUpdateTrackerInitialized(pmRoot) {
1051
+ if (!(await pathExists(getSettingsPath(pmRoot)))) {
1052
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
1053
+ }
1054
+ }
1055
+ function assertMatchingOrderRank(options) {
1056
+ if (options.order !== undefined && options.rank !== undefined && options.order !== options.rank) {
1057
+ throw new PmCliError("--order and --rank must match when both are provided", EXIT_CODE.USAGE);
1058
+ }
1059
+ }
1060
+ async function resolveParentReferenceForUpdate(params) {
1061
+ if (params.options.parent === undefined || params.unsetTargets.frontMatterKeys.has("parent")) {
1062
+ return { resolvedParentValue: undefined, warnings: [] };
1063
+ }
1064
+ const resolvedParentValue = normalizeParentReferenceValue(params.options.parent);
1065
+ const parentLocated = await locateItem(params.pmRoot, resolvedParentValue, params.settings.id_prefix, params.settings.item_format, params.typeRegistry.type_to_folder);
1066
+ if (parentLocated) {
1067
+ return { resolvedParentValue, warnings: [] };
1068
+ }
1069
+ const normalizedParentId = normalizeItemId(resolvedParentValue, params.settings.id_prefix);
1070
+ return {
1071
+ resolvedParentValue,
1072
+ warnings: validateMissingParentReference(normalizedParentId, params.parentReferencePolicy).warnings,
1073
+ };
1074
+ }
1075
+ function blockedByResolutionWarnings(resolution) {
1076
+ return resolution.unresolved === undefined ? [] : [`blocked_by_unresolved:${resolution.unresolved}`];
1077
+ }
1078
+ async function collectWorkflowTransitionWarnings(params) {
1079
+ if (params.workflowEnforcement === "off" || params.typeWorkflows.length === 0 || !params.fieldFlags.status || params.options.status === undefined) {
1080
+ return [];
1081
+ }
1082
+ const located = await locateItem(params.pmRoot, params.id, params.settings.id_prefix, params.settings.item_format, params.typeRegistry.type_to_folder);
1083
+ if (!located) {
1084
+ throw await buildItemNotFoundError(params.pmRoot, params.id, params.settings.id_prefix, params.typeRegistry.type_to_folder);
1085
+ }
1086
+ const { document } = await readLocatedItem(located, { schema: params.settings.schema });
1087
+ const effectiveType = params.options.type !== undefined
1088
+ ? (resolveTypeName(params.options.type, params.typeRegistry) ?? params.options.type)
1089
+ : (document.metadata?.type ?? "");
1090
+ const warning = enforceTypeWorkflowTransition({
1091
+ enforcement: params.workflowEnforcement,
1092
+ typeWorkflows: params.typeWorkflows,
1093
+ statusRegistry: params.statusRegistry,
1094
+ typeName: effectiveType,
1095
+ fromStatus: document.metadata?.status ?? "",
1096
+ toStatus: params.options.status,
1097
+ });
1098
+ return warning ? [warning] : [];
1099
+ }
1100
+ async function routeCloseStatusUpdate(context) {
1101
+ if (!context.fieldFlags.status) {
1102
+ return undefined;
1103
+ }
1104
+ const targetStatus = normalizeStatusInput(context.options.status, context.statusRegistry);
1105
+ if (targetStatus !== context.statusRegistry.close_status) {
1106
+ return undefined;
1107
+ }
1108
+ const otherFieldKeys = Object.entries(context.fieldFlags)
1109
+ .filter(([key, value]) => value && key !== "status" && key !== "closeReason")
1110
+ .map(([key]) => key);
1111
+ const routeWarnings = [];
1112
+ let preChangedFields = [];
1113
+ if (otherFieldKeys.length > 0) {
1114
+ const preUpdate = await runUpdate(context.id, { ...context.options, status: undefined, closeReason: undefined, message: undefined }, context.global);
1115
+ preChangedFields = preUpdate.changed_fields;
1116
+ routeWarnings.push(...preUpdate.warnings);
1117
+ }
1118
+ const explicitReason = typeof context.options.closeReason === "string" ? context.options.closeReason.trim() : "";
1119
+ const fallbackMessage = typeof context.options.message === "string" ? context.options.message.trim() : "";
1120
+ const closeReason = explicitReason || fallbackMessage || "Closed via pm update";
1121
+ const closeResult = await runClose(context.id, closeReason, {
1122
+ author: context.options.author,
1123
+ message: context.options.message,
1124
+ force: context.options.force,
1125
+ }, context.global);
1126
+ const warnings = [
1127
+ ...context.workflowTransitionWarnings,
1128
+ ...routeWarnings,
1129
+ ...closeResult.warnings,
1130
+ "auto_routed_from_update_to_close",
1131
+ ];
1132
+ if (explicitReason.length === 0 && fallbackMessage.length === 0) {
1133
+ warnings.push("close_reason_defaulted");
1134
+ }
1135
+ return {
1136
+ item: closeResult.item,
1137
+ changed_fields: [...preChangedFields, ...closeResult.changed_fields],
1138
+ warnings,
1139
+ };
1140
+ }
1141
+ function applySimpleItemMutations(document, options, statusRegistry, changedFields) {
1142
+ if (options.title !== undefined) {
1143
+ document.metadata.title = options.title;
1144
+ changedFields.push("title");
1145
+ }
1146
+ if (options.description !== undefined) {
1147
+ document.metadata.description = options.description;
1148
+ changedFields.push("description");
1149
+ }
1150
+ if (options.body !== undefined) {
1151
+ document.body = options.body;
1152
+ changedFields.push("body");
1153
+ }
1154
+ return normalizeStatusInput(document.metadata.status, statusRegistry) ?? document.metadata.status;
1155
+ }
1156
+ function applyStatusAndCloseReasonMutations(document, context, previousStatusNormalized, changedFields) {
1157
+ if (context.options.status !== undefined) {
1158
+ const status = parseStatus(context.options.status, context.statusRegistry);
1159
+ document.metadata.status = status;
1160
+ changedFields.push("status");
1161
+ }
1162
+ if (context.options.closeReason !== undefined || context.clearFrontMatterKeys.has("close_reason")) {
1163
+ if (context.clearFrontMatterKeys.has("close_reason")) {
1164
+ delete document.metadata.close_reason;
1165
+ }
1166
+ else {
1167
+ const closeReason = context.options.closeReason?.trim() ?? "";
1168
+ if (closeReason.length === 0) {
1169
+ throw new PmCliError("--close-reason must not be empty", EXIT_CODE.USAGE);
1170
+ }
1171
+ document.metadata.close_reason = closeReason;
1172
+ }
1173
+ changedFields.push("close_reason");
1174
+ return;
1175
+ }
1176
+ if (context.options.status !== undefined &&
1177
+ previousStatusNormalized === context.statusRegistry.close_status &&
1178
+ document.metadata.status !== context.statusRegistry.canceled_status &&
1179
+ document.metadata.close_reason !== undefined) {
1180
+ delete document.metadata.close_reason;
1181
+ changedFields.push("close_reason");
1182
+ }
1183
+ }
1184
+ function applyPriorityTypeAndOptions(document, context, changedFields) {
1185
+ let activeTypeName = resolveTypeName(document.metadata.type, context.typeRegistry) ?? document.metadata.type;
1186
+ if (context.options.priority !== undefined) {
1187
+ document.metadata.priority = ensurePriority(context.options.priority);
1188
+ changedFields.push("priority");
1189
+ }
1190
+ if (context.options.type !== undefined) {
1191
+ const resolvedTypeName = resolveTypeName(context.options.type, context.typeRegistry);
1192
+ if (!resolvedTypeName) {
1193
+ throw new PmCliError(buildInvalidTypeError(context.options.type, context.typeRegistry.types, resolveItemTypesFilePath(context.pmRoot, context.settings.schema)), EXIT_CODE.USAGE);
1194
+ }
1195
+ document.metadata.type = resolvedTypeName;
1196
+ activeTypeName = resolvedTypeName;
1197
+ changedFields.push("type");
1198
+ }
1199
+ enforceUpdateOptionsByType(activeTypeName, context.options, context.typeRegistry, context.runtimeFieldRegistry, context.extensionFieldNames);
1200
+ applyTypeOptionMutation(document, context, activeTypeName, changedFields);
1201
+ return activeTypeName;
1202
+ }
1203
+ function applyTypeOptionMutation(document, context, activeTypeName, changedFields) {
1204
+ if (context.options.typeOption !== undefined || context.clearFrontMatterKeys.has("type_options")) {
1205
+ if (context.clearFrontMatterKeys.has("type_options")) {
1206
+ delete document.metadata.type_options;
1207
+ }
1208
+ else {
1209
+ const parsedTypeOptions = parseTypeOptionEntries(context.options.typeOption ?? []);
1210
+ const validation = validateTypeOptions(activeTypeName, parsedTypeOptions, context.typeRegistry);
1211
+ if (validation.errors.length > 0) {
1212
+ throw new PmCliError(validation.errors.join("; "), EXIT_CODE.USAGE);
1213
+ }
1214
+ document.metadata.type_options = validation.normalized;
1215
+ }
1216
+ changedFields.push("type_options");
1217
+ return;
1218
+ }
1219
+ if (context.options.type === undefined || document.metadata.type_options === undefined) {
1220
+ return;
1221
+ }
1222
+ const validation = validateTypeOptions(activeTypeName, document.metadata.type_options, context.typeRegistry);
1223
+ if (validation.errors.length > 0) {
1224
+ throw new PmCliError(`Current type options are incompatible with type "${activeTypeName}". ${validation.errors.join("; ")}. Use --clear-type-options to clear them.`, EXIT_CODE.USAGE);
1225
+ }
1226
+ document.metadata.type_options = validation.normalized;
1227
+ }
1228
+ function applyDependencyMutations(document, context, changedFields) {
1229
+ if (context.options.dep === undefined &&
1230
+ context.options.depRemove === undefined &&
1231
+ !context.clearFrontMatterKeys.has("dependencies")) {
1232
+ return;
1233
+ }
1234
+ let nextDependencies = context.clearFrontMatterKeys.has("dependencies") ? [] : [...(document.metadata.dependencies ?? [])];
1235
+ if (context.dependencyUpdates.additions.length > 0) {
1236
+ const seen = new Set(nextDependencies.map((entry) => dependencyKey(entry)));
1237
+ for (const addition of context.dependencyUpdates.additions) {
1238
+ const key = dependencyKey(addition);
1239
+ if (!seen.has(key)) {
1240
+ nextDependencies.push(addition);
1241
+ seen.add(key);
1242
+ }
1243
+ }
1244
+ }
1245
+ if (context.dependencyRemovals.length > 0) {
1246
+ nextDependencies = nextDependencies.filter((entry) => !context.dependencyRemovals.some((selector) => matchesDependencySelector(entry, selector)));
1247
+ }
1248
+ if (nextDependencies.length === 0) {
1249
+ delete document.metadata.dependencies;
1250
+ }
1251
+ else {
1252
+ document.metadata.dependencies = nextDependencies;
1253
+ }
1254
+ changedFields.push("dependencies");
1255
+ }
1256
+ function applyLogCollectionMutations(document, context, changedFields) {
1257
+ applyLogCollectionMutation(document, "comments", context.options.comment, context.commentUpdates.values, context.clearFrontMatterKeys, changedFields);
1258
+ applyLogCollectionMutation(document, "notes", context.options.note, context.noteUpdates.values, context.clearFrontMatterKeys, changedFields);
1259
+ applyLogCollectionMutation(document, "learnings", context.options.learning, context.learningUpdates.values, context.clearFrontMatterKeys, changedFields);
1260
+ }
1261
+ function applyLogCollectionMutation(document, key, optionValue, values, clearFrontMatterKeys, changedFields) {
1262
+ if (optionValue === undefined && !clearFrontMatterKeys.has(key)) {
1263
+ return;
1264
+ }
1265
+ if (clearFrontMatterKeys.has(key) || !values || values.length === 0) {
1266
+ delete document.metadata[key];
1267
+ }
1268
+ else {
1269
+ document.metadata[key] = [...(document.metadata[key] ?? []), ...values];
1270
+ }
1271
+ changedFields.push(key);
1272
+ }
1273
+ function applyEvidenceCollectionMutations(document, context, changedFields) {
1274
+ applyUniqueLinkedCollectionMutation(document, "files", context.options.file, context.fileUpdates.values, fileKey, context.clearFrontMatterKeys, changedFields);
1275
+ applyTestCollectionMutation(document, context, changedFields);
1276
+ applyUniqueLinkedCollectionMutation(document, "docs", context.options.doc, context.docUpdates.values, docKey, context.clearFrontMatterKeys, changedFields);
1277
+ }
1278
+ function applyUniqueLinkedCollectionMutation(document, key, optionValue, values, keyOf, clearFrontMatterKeys, changedFields) {
1279
+ if (optionValue === undefined && !clearFrontMatterKeys.has(key)) {
1280
+ return;
1281
+ }
1282
+ if (clearFrontMatterKeys.has(key) || !values || values.length === 0) {
1283
+ delete document.metadata[key];
1284
+ }
1285
+ else {
1286
+ const next = [...(document.metadata[key] ?? [])];
1287
+ const seen = new Set(next.map((entry) => keyOf(entry)));
1288
+ for (const entry of values) {
1289
+ const keyValue = keyOf(entry);
1290
+ if (!seen.has(keyValue)) {
1291
+ next.push(entry);
1292
+ seen.add(keyValue);
1293
+ }
1294
+ }
1295
+ document.metadata[key] = next;
1296
+ }
1297
+ changedFields.push(key);
1298
+ }
1299
+ function applyTestCollectionMutation(document, context, changedFields) {
1300
+ if (context.options.test === undefined && !context.clearFrontMatterKeys.has("tests")) {
1301
+ return;
1302
+ }
1303
+ if (context.clearFrontMatterKeys.has("tests") && context.options.replaceTests === true) {
1304
+ document.metadata.tests = dedupeLinkedTests(context.testUpdates.values) ?? [];
1305
+ }
1306
+ else if (context.clearFrontMatterKeys.has("tests") || !context.testUpdates.values || context.testUpdates.values.length === 0) {
1307
+ delete document.metadata.tests;
1308
+ }
1309
+ else {
1310
+ document.metadata.tests = dedupeLinkedTests([...(document.metadata.tests ?? []), ...context.testUpdates.values]);
1311
+ }
1312
+ if (document.metadata.tests !== undefined && document.metadata.tests.length === 0) {
1313
+ delete document.metadata.tests;
1314
+ }
1315
+ changedFields.push("tests");
1316
+ }
1317
+ function dedupeLinkedTests(values) {
1318
+ if (!values || values.length === 0) {
1319
+ return undefined;
1320
+ }
1321
+ const next = [];
1322
+ const seen = new Set();
1323
+ for (const entry of values) {
1324
+ const key = testKey(entry);
1325
+ if (!seen.has(key)) {
1326
+ next.push(entry);
1327
+ seen.add(key);
1328
+ }
1329
+ }
1330
+ return next;
1331
+ }
1332
+ function applyTagsAndPlanningMutations(document, context, scalarMutationContext) {
1333
+ const addTagsValues = context.options.addTags;
1334
+ const removeTagsValues = context.options.removeTags;
1335
+ const hasAdditiveTagMutation = (Array.isArray(addTagsValues) && addTagsValues.length > 0) ||
1336
+ (Array.isArray(removeTagsValues) && removeTagsValues.length > 0);
1337
+ if (context.options.tags !== undefined || context.clearFrontMatterKeys.has("tags") || hasAdditiveTagMutation) {
1338
+ const baseTags = context.clearFrontMatterKeys.has("tags")
1339
+ ? []
1340
+ : context.options.tags !== undefined
1341
+ ? parseTags(context.options.tags)
1342
+ : Array.isArray(document.metadata.tags)
1343
+ ? [...document.metadata.tags]
1344
+ : [];
1345
+ document.metadata.tags = applyTagRemovals(mergeAdditiveTags(baseTags, addTagsValues), removeTagsValues);
1346
+ scalarMutationContext.changedFields.push("tags");
1347
+ }
1348
+ applyUpdateScalarMutations(UPDATE_POST_TAG_SCALAR_MUTATIONS, context.options, scalarMutationContext);
1349
+ applyOrderMutation(document, context, scalarMutationContext.changedFields);
1350
+ }
1351
+ function applyOrderMutation(document, context, changedFields) {
1352
+ const orderRaw = context.options.order ?? context.options.rank;
1353
+ if (orderRaw === undefined && !context.clearFrontMatterKeys.has("order")) {
1354
+ return;
1355
+ }
1356
+ if (context.clearFrontMatterKeys.has("order")) {
1357
+ delete document.metadata.order;
1358
+ }
1359
+ else {
1360
+ const parsedOrder = parseOptionalNumber(orderRaw ?? "", "order");
1361
+ if (!Number.isInteger(parsedOrder)) {
1362
+ throw new PmCliError("Order must be an integer", EXIT_CODE.USAGE);
1363
+ }
1364
+ document.metadata.order = parsedOrder;
1365
+ }
1366
+ changedFields.push("order");
1367
+ }
1368
+ function applyOwnershipAndIssueMutations(document, context, scalarMutationContext, warnings) {
1369
+ applyAssigneeMutation(document, context, scalarMutationContext.changedFields);
1370
+ applyParentMutation(document, context, scalarMutationContext.changedFields);
1371
+ applyUpdateScalarMutations(UPDATE_STAKEHOLDER_SCALAR_MUTATIONS, context.options, scalarMutationContext);
1372
+ applySprintReleaseMutation(document, context, "sprint", warnings, scalarMutationContext.changedFields);
1373
+ applySprintReleaseMutation(document, context, "release", warnings, scalarMutationContext.changedFields);
1374
+ applyBlockedByMutation(document, context, scalarMutationContext.changedFields);
1375
+ applyUpdateScalarMutations(UPDATE_ISSUE_SCALAR_MUTATIONS, context.options, scalarMutationContext);
1376
+ }
1377
+ function applyAssigneeMutation(document, context, changedFields) {
1378
+ if (context.options.assignee === undefined && !context.clearFrontMatterKeys.has("assignee")) {
1379
+ return;
1380
+ }
1381
+ if (context.clearFrontMatterKeys.has("assignee")) {
1382
+ delete document.metadata.assignee;
1383
+ }
1384
+ else {
1385
+ const assignee = context.options.assignee?.trim() ?? "";
1386
+ if (assignee === "") {
1387
+ throw new PmCliError("--assignee must not be empty. Use --unset assignee to clear it.", EXIT_CODE.USAGE);
1388
+ }
1389
+ document.metadata.assignee = assignee;
1390
+ }
1391
+ changedFields.push("assignee");
1392
+ }
1393
+ function applyParentMutation(document, context, changedFields) {
1394
+ if (context.options.parent === undefined && !context.clearFrontMatterKeys.has("parent")) {
1395
+ return;
1396
+ }
1397
+ if (context.clearFrontMatterKeys.has("parent")) {
1398
+ delete document.metadata.parent;
1399
+ }
1400
+ else {
1401
+ document.metadata.parent = context.resolvedParentValue ?? "";
1402
+ }
1403
+ changedFields.push("parent");
1404
+ }
1405
+ function applySprintReleaseMutation(document, context, key, warnings, changedFields) {
1406
+ if (context.options[key] === undefined && !context.clearFrontMatterKeys.has(key)) {
1407
+ return;
1408
+ }
1409
+ if (context.clearFrontMatterKeys.has(key)) {
1410
+ delete document.metadata[key];
1411
+ }
1412
+ else {
1413
+ const validation = validateSprintOrReleaseValue(key, context.options[key] ?? "", context.settings.validation.sprint_release_format);
1414
+ document.metadata[key] = validation.value;
1415
+ warnings.push(...validation.warnings);
1416
+ }
1417
+ changedFields.push(key);
1418
+ }
1419
+ function applyBlockedByMutation(document, context, changedFields) {
1420
+ if (context.options.blockedBy === undefined && !context.clearFrontMatterKeys.has("blocked_by")) {
1421
+ return;
1422
+ }
1423
+ if (context.clearFrontMatterKeys.has("blocked_by")) {
1424
+ delete document.metadata.blocked_by;
1425
+ }
1426
+ else {
1427
+ document.metadata.blocked_by = context.options.blockedBy?.trim() ?? "";
1428
+ }
1429
+ changedFields.push("blocked_by");
1430
+ applyBlockedByDependencyEdge(document.metadata, context.resolvedBlockedByDependencyId, context.nowIso, context.author, changedFields);
1431
+ }
1432
+ function applyScheduleMutations(document, context, changedFields) {
1433
+ if (context.options.reminder !== undefined || context.clearFrontMatterKeys.has("reminders")) {
1434
+ if (context.clearFrontMatterKeys.has("reminders")) {
1435
+ delete document.metadata.reminders;
1436
+ }
1437
+ else {
1438
+ document.metadata.reminders = parseReminderEntries(context.options.reminder ?? [], context.nowValue, { valueMode: "trimmed" });
1439
+ }
1440
+ changedFields.push("reminders");
1441
+ }
1442
+ if (context.options.event !== undefined || context.clearFrontMatterKeys.has("events")) {
1443
+ if (context.clearFrontMatterKeys.has("events")) {
1444
+ delete document.metadata.events;
1445
+ }
1446
+ else {
1447
+ document.metadata.events = parseEventEntries(context.options.event ?? [], context.nowValue, {
1448
+ allDayEmptyGuard: "truthy",
1449
+ recurrenceEmptyNumericGuard: "truthy",
1450
+ });
1451
+ }
1452
+ changedFields.push("events");
1453
+ }
1454
+ }
1455
+ function applyRuntimeAndRegisteredFieldMutations(metadataRecord, context, changedFields) {
1456
+ clearDynamicFields(metadataRecord, context.runtimeFieldRegistry.definitions.map((definition) => definition.metadata_key), context.clearFrontMatterKeys, changedFields);
1457
+ clearDynamicFields(metadataRecord, context.extensionFieldNames, context.clearFrontMatterKeys, changedFields);
1458
+ for (const [fieldKey, fieldValue] of Object.entries(context.runtimeFieldUpdates)) {
1459
+ if (context.clearFrontMatterKeys.has(fieldKey)) {
1460
+ const fieldFlag = fieldKey.replaceAll("_", "-");
1461
+ const definition = context.runtimeFieldRegistry.definitions.find((candidate) => candidate.metadata_key === fieldKey);
1462
+ const updateFlag = definition?.cli_flag ?? fieldFlag;
1463
+ throw new PmCliError(`Cannot combine --unset ${fieldFlag} with --${updateFlag}`, EXIT_CODE.USAGE);
1464
+ }
1465
+ if (stableValueEquals(metadataRecord[fieldKey], fieldValue)) {
1466
+ continue;
1467
+ }
1468
+ metadataRecord[fieldKey] = fieldValue;
1469
+ changedFields.push(fieldKey);
1470
+ }
1471
+ const registeredItemFieldUpdates = parseRegisteredItemFieldAssignments(context.options.field, context.extensionRegistrations);
1472
+ for (const fieldKey of Object.keys(registeredItemFieldUpdates)) {
1473
+ if (context.clearFrontMatterKeys.has(fieldKey)) {
1474
+ throw new PmCliError(`Cannot combine --unset ${fieldKey.replaceAll("_", "-")} with --field ${fieldKey}=...`, EXIT_CODE.USAGE);
1475
+ }
1476
+ }
1477
+ for (const [fieldKey, fieldValue] of Object.entries(registeredItemFieldUpdates)) {
1478
+ if (!stableValueEquals(metadataRecord[fieldKey], fieldValue)) {
1479
+ metadataRecord[fieldKey] = fieldValue;
1480
+ changedFields.push(fieldKey);
1481
+ }
1482
+ }
1483
+ }
1484
+ function clearDynamicFields(metadataRecord, fieldKeys, clearFrontMatterKeys, changedFields) {
1485
+ for (const fieldKey of fieldKeys) {
1486
+ if (!clearFrontMatterKeys.has(fieldKey) || metadataRecord[fieldKey] === undefined) {
1487
+ continue;
1488
+ }
1489
+ delete metadataRecord[fieldKey];
1490
+ changedFields.push(fieldKey);
1491
+ }
1492
+ }
1493
+ function mutateUpdateDocument(document, context) {
1494
+ const changedFields = [];
1495
+ const warnings = [];
1496
+ const previousStatusNormalized = applySimpleItemMutations(document, context.options, context.statusRegistry, changedFields);
1497
+ const metadataRecord = toItemRecord(document.metadata);
1498
+ const scalarMutationContext = {
1499
+ metadataRecord,
1500
+ clearFrontMatterKeys: context.clearFrontMatterKeys,
1501
+ changedFields,
1502
+ nowValue: context.nowValue,
1503
+ };
1504
+ applyStatusAndCloseReasonMutations(document, context, previousStatusNormalized, changedFields);
1505
+ applyPriorityTypeAndOptions(document, context, changedFields);
1506
+ applyDependencyMutations(document, context, changedFields);
1507
+ applyLogCollectionMutations(document, context, changedFields);
1508
+ applyEvidenceCollectionMutations(document, context, changedFields);
1509
+ applyTagsAndPlanningMutations(document, context, scalarMutationContext);
1510
+ applyOwnershipAndIssueMutations(document, context, scalarMutationContext, warnings);
1511
+ if (normalizeStatusInput(document.metadata.status, context.statusRegistry) === context.statusRegistry.canceled_status &&
1512
+ document.metadata.assignee !== undefined) {
1513
+ delete document.metadata.assignee;
1514
+ if (!changedFields.includes("assignee")) {
1515
+ changedFields.push("assignee");
1516
+ }
1517
+ }
1518
+ applyScheduleMutations(document, context, changedFields);
1519
+ applyRuntimeAndRegisteredFieldMutations(metadataRecord, context, changedFields);
1520
+ try {
1521
+ applyRegisteredItemFieldDefaultsAndValidation(metadataRecord, context.extensionRegistrations, { skipDefaultFields: context.clearFrontMatterKeys });
1522
+ }
1523
+ catch (error) {
1524
+ throw new PmCliError(error instanceof Error ? error.message : "Invalid extension item field values", EXIT_CODE.USAGE);
1525
+ }
1526
+ return { changedFields, warnings };
1527
+ }
1528
+ /**
1529
+ * Implements run update for the public runtime surface of this module.
1530
+ */
1531
+ export async function runUpdate(id, options, global) {
1532
+ options = await resolveStdinUpdateOptions(options);
1533
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
1534
+ await assertUpdateTrackerInitialized(pmRoot);
1535
+ const settings = await readSettings(pmRoot);
1536
+ const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
1537
+ const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
1538
+ const extensionRegistrations = getActiveExtensionRegistrations();
1539
+ const extensionFieldNames = collectRegisteredItemFieldNames(extensionRegistrations);
1540
+ const typeRegistry = resolveItemTypeRegistry(settings, extensionRegistrations);
1541
+ // Per-type allowed-transition enforcement is read RAW (not preset-derived) so
1542
+ // existing projects are unaffected when unset; defaults to "off".
1543
+ const workflowEnforcement = settings.governance.workflow_enforcement ?? "off";
1544
+ const typeWorkflows = workflowEnforcement === "off" ? [] : resolveTypeWorkflows(settings.schema);
1545
+ const parentReferencePolicy = settings.validation.parent_reference;
1546
+ const unsetTargets = parseUpdateUnsetTargets(options.unset, runtimeFieldRegistry, extensionFieldNames);
1547
+ const clearOptionKeys = new Set(unsetTargets.optionKeys);
1548
+ const clearFrontMatterKeys = new Set(unsetTargets.frontMatterKeys);
1549
+ validateReplaceOptions(options);
1550
+ applyClearCollectionDefinitions({
1551
+ definitions: buildClearCollectionDefinitions(options),
1552
+ options,
1553
+ clearOptionKeys,
1554
+ clearFrontMatterKeys,
1555
+ });
1556
+ enforceAllowAuditUpdateScope(id, options, clearFrontMatterKeys);
1557
+ rejectUnsetScalarConflicts(options, unsetTargets);
1558
+ rejectLegacyScalarTokens(options);
997
1559
  const author = toAuthor(options.author, settings.author_default);
998
1560
  const nowValue = new Date();
999
1561
  const nowIso = nowValue.toISOString();
@@ -1011,188 +1573,49 @@ export async function runUpdate(id, options, global) {
1011
1573
  const fileUpdates = parseFiles(options.file);
1012
1574
  const testUpdates = parseTests(options.test);
1013
1575
  const docUpdates = parseDocs(options.doc);
1014
- const parentReferenceWarnings = [];
1015
1576
  const workflowTransitionWarnings = [];
1016
- let resolvedParentValue;
1017
- if (options.parent !== undefined && !unsetTargets.frontMatterKeys.has("parent")) {
1018
- resolvedParentValue = normalizeParentReferenceValue(options.parent);
1019
- const parentLocated = await locateItem(pmRoot, resolvedParentValue, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1020
- if (!parentLocated) {
1021
- const normalizedParentId = normalizeItemId(resolvedParentValue, settings.id_prefix);
1022
- parentReferenceWarnings.push(...validateMissingParentReference(normalizedParentId, parentReferencePolicy).warnings);
1023
- }
1024
- }
1577
+ const parentReference = await resolveParentReferenceForUpdate({
1578
+ options,
1579
+ unsetTargets,
1580
+ pmRoot,
1581
+ settings,
1582
+ typeRegistry,
1583
+ parentReferencePolicy,
1584
+ });
1025
1585
  // pm-kyd6: resolve the --blocked-by target up front (async) so the sync
1026
1586
  // mutate callback can mirror create.ts and add a `blocked_by` dependency edge.
1027
1587
  const blockedByResolution = await resolveBlockedByDependencyTarget(options.blockedBy, clearFrontMatterKeys.has("blocked_by"), pmRoot, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1028
1588
  const resolvedBlockedByDependencyId = blockedByResolution.id;
1029
- if (blockedByResolution.unresolved !== undefined) {
1030
- parentReferenceWarnings.push(`blocked_by_unresolved:${blockedByResolution.unresolved}`);
1031
- }
1589
+ const parentReferenceWarnings = [...parentReference.warnings, ...blockedByResolutionWarnings(blockedByResolution)];
1032
1590
  const runtimeFieldUpdates = collectRuntimeUpdateFieldValues(options, runtimeFieldRegistry, options.runtimeFieldCommands);
1033
- const fieldFlags = {
1034
- title: options.title !== undefined,
1035
- description: options.description !== undefined,
1036
- body: options.body !== undefined,
1037
- status: options.status !== undefined,
1038
- closeReason: options.closeReason !== undefined,
1039
- priority: options.priority !== undefined,
1040
- type: options.type !== undefined,
1041
- tags: options.tags !== undefined,
1042
- addTags: Array.isArray(options.addTags) && options.addTags.length > 0,
1043
- removeTags: Array.isArray(options.removeTags) && options.removeTags.length > 0,
1044
- deadline: options.deadline !== undefined,
1045
- estimatedMinutes: options.estimatedMinutes !== undefined,
1046
- acceptanceCriteria: options.acceptanceCriteria !== undefined,
1047
- definitionOfReady: options.definitionOfReady !== undefined,
1048
- order: options.order !== undefined,
1049
- rank: options.rank !== undefined,
1050
- goal: options.goal !== undefined,
1051
- objective: options.objective !== undefined,
1052
- value: options.value !== undefined,
1053
- impact: options.impact !== undefined,
1054
- outcome: options.outcome !== undefined,
1055
- whyNow: options.whyNow !== undefined,
1056
- assignee: options.assignee !== undefined,
1057
- parent: options.parent !== undefined,
1058
- reviewer: options.reviewer !== undefined,
1059
- risk: options.risk !== undefined,
1060
- confidence: options.confidence !== undefined,
1061
- sprint: options.sprint !== undefined,
1062
- release: options.release !== undefined,
1063
- blockedBy: options.blockedBy !== undefined,
1064
- blockedReason: options.blockedReason !== undefined,
1065
- unblockNote: options.unblockNote !== undefined,
1066
- reporter: options.reporter !== undefined,
1067
- severity: options.severity !== undefined,
1068
- environment: options.environment !== undefined,
1069
- reproSteps: options.reproSteps !== undefined,
1070
- resolution: options.resolution !== undefined,
1071
- expectedResult: options.expectedResult !== undefined,
1072
- actualResult: options.actualResult !== undefined,
1073
- affectedVersion: options.affectedVersion !== undefined,
1074
- fixedVersion: options.fixedVersion !== undefined,
1075
- component: options.component !== undefined,
1076
- regression: options.regression !== undefined,
1077
- customerImpact: options.customerImpact !== undefined,
1078
- dep: options.dep !== undefined,
1079
- depRemove: options.depRemove !== undefined,
1080
- replaceDeps: options.replaceDeps === true,
1081
- comment: options.comment !== undefined,
1082
- note: options.note !== undefined,
1083
- learning: options.learning !== undefined,
1084
- file: options.file !== undefined,
1085
- test: options.test !== undefined,
1086
- replaceTests: options.replaceTests === true,
1087
- doc: options.doc !== undefined,
1088
- reminder: options.reminder !== undefined,
1089
- event: options.event !== undefined,
1090
- typeOption: options.typeOption !== undefined,
1091
- field: options.field !== undefined,
1092
- unset: options.unset !== undefined && options.unset.length > 0,
1093
- clearDeps: options.clearDeps === true,
1094
- clearComments: options.clearComments === true,
1095
- clearNotes: options.clearNotes === true,
1096
- clearLearnings: options.clearLearnings === true,
1097
- clearFiles: options.clearFiles === true,
1098
- clearTests: options.clearTests === true,
1099
- clearDocs: options.clearDocs === true,
1100
- clearReminders: options.clearReminders === true,
1101
- clearEvents: options.clearEvents === true,
1102
- clearTypeOptions: options.clearTypeOptions === true,
1103
- runtimeFields: Object.keys(runtimeFieldUpdates).length > 0,
1104
- };
1591
+ const fieldFlags = buildUpdateFieldFlags(options, runtimeFieldUpdates);
1105
1592
  const changedFlags = Object.values(fieldFlags).some(Boolean);
1106
1593
  if (!changedFlags) {
1107
- const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1108
- if (!located) {
1109
- throw await buildItemNotFoundError(pmRoot, id, settings.id_prefix, typeRegistry.type_to_folder);
1110
- }
1111
- const { document } = await readLocatedItem(located, { schema: settings.schema });
1112
- return {
1113
- item: toItemRecord(document.metadata),
1114
- changed_fields: [],
1115
- warnings: ["noop_no_update_fields"],
1116
- };
1117
- }
1118
- // Per-type allowed-transition enforcement runs BEFORE the close-reroute so a
1119
- // transition toward the close status is gated too. We read the item's current
1120
- // status + type once (only when enforcement is active and --status is set) so
1121
- // the default `off` path adds zero extra work. A `strict` violation throws; a
1122
- // `warn` violation surfaces a warning on the result.
1123
- if (workflowEnforcement !== "off" && typeWorkflows.length > 0 && fieldFlags.status && options.status !== undefined) {
1124
- const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1125
- if (!located) {
1126
- throw await buildItemNotFoundError(pmRoot, id, settings.id_prefix, typeRegistry.type_to_folder);
1127
- }
1128
- const { document } = await readLocatedItem(located, { schema: settings.schema });
1129
- // When this update also changes --type, gate the transition against the
1130
- // EFFECTIVE (post-update) type, so a combined --type/--status change can't
1131
- // bypass a target-type rule (or be wrongly blocked by the pre-update type's
1132
- // rule that will no longer apply). Falls back to the raw value when --type is
1133
- // unresolved; the later type resolution surfaces an invalid-type error.
1134
- const effectiveType = options.type !== undefined
1135
- ? (resolveTypeName(options.type, typeRegistry) ?? options.type)
1136
- : (document.metadata?.type ?? "");
1137
- const warning = enforceTypeWorkflowTransition({
1138
- enforcement: workflowEnforcement,
1139
- typeWorkflows,
1140
- statusRegistry,
1141
- typeName: effectiveType,
1142
- fromStatus: document.metadata?.status ?? "",
1143
- toStatus: options.status ?? "",
1144
- });
1145
- if (warning) {
1146
- workflowTransitionWarnings.push(warning);
1147
- }
1148
- }
1149
- // `pm update --status <close_status>` always routes to the auditable close
1150
- // workflow so agents are never blocked by close-through-update errors. Any
1151
- // other field updates in the same call are applied first, then the item is
1152
- // closed with the supplied --close-reason (or a derived default when omitted).
1153
- if (fieldFlags.status) {
1154
- const targetStatus = normalizeStatusInput(options.status, statusRegistry);
1155
- if (targetStatus === statusRegistry.close_status) {
1156
- const otherFieldKeys = Object.entries(fieldFlags)
1157
- .filter(([key, value]) => value && key !== "status" && key !== "closeReason")
1158
- .map(([key]) => key);
1159
- const routeWarnings = [];
1160
- let preChangedFields = [];
1161
- if (otherFieldKeys.length > 0) {
1162
- const preUpdate = await runUpdate(id, { ...options, status: undefined, closeReason: undefined, message: undefined }, global);
1163
- preChangedFields = preUpdate.changed_fields;
1164
- routeWarnings.push(...preUpdate.warnings);
1165
- }
1166
- const explicitReason = typeof options.closeReason === "string" ? options.closeReason.trim() : "";
1167
- const fallbackMessage = typeof options.message === "string" ? options.message.trim() : "";
1168
- const closeReason = explicitReason || fallbackMessage || "Closed via pm update";
1169
- // Only flag a defaulted reason when neither --close-reason nor --message
1170
- // supplied any text and we had to invent the generic placeholder.
1171
- const reasonDefaulted = explicitReason.length === 0 && fallbackMessage.length === 0;
1172
- const closeResult = await runClose(id, closeReason, {
1173
- author: options.author,
1174
- message: options.message,
1175
- force: options.force,
1176
- }, global);
1177
- const warnings = [
1178
- ...workflowTransitionWarnings,
1179
- ...routeWarnings,
1180
- ...closeResult.warnings,
1181
- "auto_routed_from_update_to_close",
1182
- ];
1183
- if (reasonDefaulted) {
1184
- warnings.push("close_reason_defaulted");
1185
- }
1186
- return {
1187
- item: closeResult.item,
1188
- changed_fields: [...preChangedFields, ...closeResult.changed_fields],
1189
- warnings,
1190
- };
1191
- }
1594
+ return buildNoopUpdateResult({ pmRoot, id, settings, typeRegistry });
1192
1595
  }
1193
- if (options.order !== undefined && options.rank !== undefined && options.order !== options.rank) {
1194
- throw new PmCliError("--order and --rank must match when both are provided", EXIT_CODE.USAGE);
1596
+ workflowTransitionWarnings.push(...await collectWorkflowTransitionWarnings({
1597
+ options,
1598
+ fieldFlags,
1599
+ workflowEnforcement,
1600
+ typeWorkflows,
1601
+ statusRegistry,
1602
+ typeRegistry,
1603
+ pmRoot,
1604
+ id,
1605
+ settings,
1606
+ }));
1607
+ const routedClose = await routeCloseStatusUpdate({
1608
+ options,
1609
+ fieldFlags,
1610
+ statusRegistry,
1611
+ workflowTransitionWarnings,
1612
+ global,
1613
+ id,
1614
+ });
1615
+ if (routedClose) {
1616
+ return routedClose;
1195
1617
  }
1618
+ assertMatchingOrderRank(options);
1196
1619
  const result = await mutateItem({
1197
1620
  pmRoot,
1198
1621
  settings,
@@ -1205,387 +1628,31 @@ export async function runUpdate(id, options, global) {
1205
1628
  bypassAssigneeConflict: options.allowAuditUpdate === true || options.allowAuditDepUpdate === true,
1206
1629
  extensionFieldNames,
1207
1630
  mutate(document) {
1208
- const changedFields = [];
1209
- const warnings = [];
1210
- let activeTypeName = resolveTypeName(document.metadata.type, typeRegistry) ?? document.metadata.type;
1211
- // Declarative set-or-clear helpers for the many string scalar fields that
1212
- // share an identical shape: set from `--flag` (optionally transformed) or
1213
- // delete when `--unset <field>` was requested, then record the change.
1214
- // Each call is placed in the same position the inline block occupied so
1215
- // the order of `changedFields` is preserved exactly (pm-why9).
1216
- const metadataRecord = toItemRecord(document.metadata);
1217
- const scalarMutationContext = {
1218
- metadataRecord,
1631
+ return mutateUpdateDocument(document, {
1632
+ options,
1633
+ settings,
1634
+ typeRegistry,
1635
+ statusRegistry,
1636
+ runtimeFieldRegistry,
1637
+ extensionRegistrations,
1638
+ extensionFieldNames,
1219
1639
  clearFrontMatterKeys,
1220
- changedFields,
1640
+ dependencyUpdates,
1641
+ dependencyRemovals,
1642
+ commentUpdates,
1643
+ noteUpdates,
1644
+ learningUpdates,
1645
+ fileUpdates,
1646
+ testUpdates,
1647
+ docUpdates,
1648
+ resolvedParentValue: parentReference.resolvedParentValue,
1649
+ resolvedBlockedByDependencyId,
1650
+ runtimeFieldUpdates,
1221
1651
  nowValue,
1222
- };
1223
- if (options.title !== undefined) {
1224
- document.metadata.title = options.title;
1225
- changedFields.push("title");
1226
- }
1227
- if (options.description !== undefined) {
1228
- document.metadata.description = options.description;
1229
- changedFields.push("description");
1230
- }
1231
- if (options.body !== undefined) {
1232
- document.body = options.body;
1233
- changedFields.push("body");
1234
- }
1235
- const previousStatus = document.metadata.status;
1236
- const previousStatusNormalized = normalizeStatusInput(previousStatus, statusRegistry) ?? previousStatus;
1237
- if (options.status !== undefined) {
1238
- // Close-status routing (with reason + audit) is handled before mutateItem
1239
- // by the close gate above, so only non-close transitions reach this path.
1240
- const status = parseStatus(options.status, statusRegistry);
1241
- document.metadata.status = status;
1242
- if (status === statusRegistry.canceled_status) {
1243
- delete document.metadata.assignee;
1244
- }
1245
- changedFields.push("status");
1246
- }
1247
- if (options.closeReason !== undefined || clearFrontMatterKeys.has("close_reason")) {
1248
- if (clearFrontMatterKeys.has("close_reason")) {
1249
- delete document.metadata.close_reason;
1250
- }
1251
- else {
1252
- const closeReason = options.closeReason?.trim() ?? "";
1253
- if (closeReason.length === 0) {
1254
- throw new PmCliError("--close-reason must not be empty", EXIT_CODE.USAGE);
1255
- }
1256
- document.metadata.close_reason = closeReason;
1257
- }
1258
- changedFields.push("close_reason");
1259
- }
1260
- else if (options.status !== undefined &&
1261
- previousStatusNormalized === statusRegistry.close_status &&
1262
- document.metadata.status !== statusRegistry.canceled_status &&
1263
- document.metadata.close_reason !== undefined) {
1264
- delete document.metadata.close_reason;
1265
- changedFields.push("close_reason");
1266
- }
1267
- if (options.priority !== undefined) {
1268
- document.metadata.priority = ensurePriority(options.priority);
1269
- changedFields.push("priority");
1270
- }
1271
- if (options.type !== undefined) {
1272
- const resolvedTypeName = resolveTypeName(options.type, typeRegistry);
1273
- if (!resolvedTypeName) {
1274
- throw new PmCliError(buildInvalidTypeError(options.type, typeRegistry.types, resolveItemTypesFilePath(pmRoot, settings.schema)), EXIT_CODE.USAGE);
1275
- }
1276
- document.metadata.type = resolvedTypeName;
1277
- activeTypeName = resolvedTypeName;
1278
- changedFields.push("type");
1279
- }
1280
- enforceUpdateOptionsByType(activeTypeName, options, typeRegistry, extensionFieldNames);
1281
- if (options.typeOption !== undefined || clearFrontMatterKeys.has("type_options")) {
1282
- if (clearFrontMatterKeys.has("type_options")) {
1283
- delete document.metadata.type_options;
1284
- }
1285
- else {
1286
- const parsedTypeOptions = parseTypeOptionEntries(options.typeOption ?? []);
1287
- const validation = validateTypeOptions(activeTypeName, parsedTypeOptions, typeRegistry);
1288
- if (validation.errors.length > 0) {
1289
- throw new PmCliError(validation.errors.join("; "), EXIT_CODE.USAGE);
1290
- }
1291
- document.metadata.type_options = validation.normalized;
1292
- }
1293
- changedFields.push("type_options");
1294
- }
1295
- else if (options.type !== undefined && document.metadata.type_options !== undefined) {
1296
- const validation = validateTypeOptions(activeTypeName, document.metadata.type_options, typeRegistry);
1297
- if (validation.errors.length > 0) {
1298
- throw new PmCliError(`Current type options are incompatible with type "${activeTypeName}". ${validation.errors.join("; ")}. Use --clear-type-options to clear them.`, EXIT_CODE.USAGE);
1299
- }
1300
- document.metadata.type_options = validation.normalized;
1301
- }
1302
- if (options.dep !== undefined || options.depRemove !== undefined || clearFrontMatterKeys.has("dependencies")) {
1303
- let nextDependencies = clearFrontMatterKeys.has("dependencies") ? [] : [...(document.metadata.dependencies ?? [])];
1304
- if (dependencyUpdates.additions.length > 0) {
1305
- const seen = new Set(nextDependencies.map((entry) => dependencyKey(entry)));
1306
- for (const addition of dependencyUpdates.additions) {
1307
- const key = dependencyKey(addition);
1308
- if (seen.has(key)) {
1309
- continue;
1310
- }
1311
- nextDependencies.push(addition);
1312
- seen.add(key);
1313
- }
1314
- }
1315
- if (dependencyRemovals.length > 0) {
1316
- nextDependencies = nextDependencies.filter((entry) => !dependencyRemovals.some((selector) => matchesDependencySelector(entry, selector)));
1317
- }
1318
- if (nextDependencies.length === 0) {
1319
- delete document.metadata.dependencies;
1320
- }
1321
- else {
1322
- document.metadata.dependencies = nextDependencies;
1323
- }
1324
- changedFields.push("dependencies");
1325
- }
1326
- if (options.comment !== undefined || clearFrontMatterKeys.has("comments")) {
1327
- if (clearFrontMatterKeys.has("comments") || !commentUpdates.values || commentUpdates.values.length === 0) {
1328
- delete document.metadata.comments;
1329
- }
1330
- else {
1331
- document.metadata.comments = [...(document.metadata.comments ?? []), ...commentUpdates.values];
1332
- }
1333
- changedFields.push("comments");
1334
- }
1335
- if (options.note !== undefined || clearFrontMatterKeys.has("notes")) {
1336
- if (clearFrontMatterKeys.has("notes") || !noteUpdates.values || noteUpdates.values.length === 0) {
1337
- delete document.metadata.notes;
1338
- }
1339
- else {
1340
- document.metadata.notes = [...(document.metadata.notes ?? []), ...noteUpdates.values];
1341
- }
1342
- changedFields.push("notes");
1343
- }
1344
- if (options.learning !== undefined || clearFrontMatterKeys.has("learnings")) {
1345
- if (clearFrontMatterKeys.has("learnings") || !learningUpdates.values || learningUpdates.values.length === 0) {
1346
- delete document.metadata.learnings;
1347
- }
1348
- else {
1349
- document.metadata.learnings = [...(document.metadata.learnings ?? []), ...learningUpdates.values];
1350
- }
1351
- changedFields.push("learnings");
1352
- }
1353
- if (options.file !== undefined || clearFrontMatterKeys.has("files")) {
1354
- if (clearFrontMatterKeys.has("files") || !fileUpdates.values || fileUpdates.values.length === 0) {
1355
- delete document.metadata.files;
1356
- }
1357
- else {
1358
- const nextFiles = [...(document.metadata.files ?? [])];
1359
- const seen = new Set(nextFiles.map((entry) => fileKey(entry)));
1360
- for (const entry of fileUpdates.values) {
1361
- const key = fileKey(entry);
1362
- if (seen.has(key)) {
1363
- continue;
1364
- }
1365
- nextFiles.push(entry);
1366
- seen.add(key);
1367
- }
1368
- document.metadata.files = nextFiles;
1369
- }
1370
- changedFields.push("files");
1371
- }
1372
- if (options.test !== undefined || clearFrontMatterKeys.has("tests")) {
1373
- if (clearFrontMatterKeys.has("tests") && options.replaceTests === true) {
1374
- if (!testUpdates.values || testUpdates.values.length === 0) {
1375
- delete document.metadata.tests;
1376
- }
1377
- else {
1378
- const replacementTests = [];
1379
- const seen = new Set();
1380
- for (const entry of testUpdates.values) {
1381
- const key = testKey(entry);
1382
- if (seen.has(key)) {
1383
- continue;
1384
- }
1385
- replacementTests.push(entry);
1386
- seen.add(key);
1387
- }
1388
- document.metadata.tests = replacementTests;
1389
- }
1390
- }
1391
- else if (clearFrontMatterKeys.has("tests") || !testUpdates.values || testUpdates.values.length === 0) {
1392
- delete document.metadata.tests;
1393
- }
1394
- else {
1395
- const nextTests = [...(document.metadata.tests ?? [])];
1396
- const seen = new Set(nextTests.map((entry) => testKey(entry)));
1397
- for (const entry of testUpdates.values) {
1398
- const key = testKey(entry);
1399
- if (seen.has(key)) {
1400
- continue;
1401
- }
1402
- nextTests.push(entry);
1403
- seen.add(key);
1404
- }
1405
- document.metadata.tests = nextTests;
1406
- }
1407
- changedFields.push("tests");
1408
- }
1409
- if (options.doc !== undefined || clearFrontMatterKeys.has("docs")) {
1410
- if (clearFrontMatterKeys.has("docs") || !docUpdates.values || docUpdates.values.length === 0) {
1411
- delete document.metadata.docs;
1412
- }
1413
- else {
1414
- const nextDocs = [...(document.metadata.docs ?? [])];
1415
- const seen = new Set(nextDocs.map((entry) => docKey(entry)));
1416
- for (const entry of docUpdates.values) {
1417
- const key = docKey(entry);
1418
- if (seen.has(key)) {
1419
- continue;
1420
- }
1421
- nextDocs.push(entry);
1422
- seen.add(key);
1423
- }
1424
- document.metadata.docs = nextDocs;
1425
- }
1426
- changedFields.push("docs");
1427
- }
1428
- const addTagsValues = options.addTags;
1429
- const removeTagsValues = options.removeTags;
1430
- const hasAdditiveTagMutation = (Array.isArray(addTagsValues) && addTagsValues.length > 0) ||
1431
- (Array.isArray(removeTagsValues) && removeTagsValues.length > 0);
1432
- if (options.tags !== undefined || clearFrontMatterKeys.has("tags") || hasAdditiveTagMutation) {
1433
- const baseTags = clearFrontMatterKeys.has("tags")
1434
- ? []
1435
- : options.tags !== undefined
1436
- ? parseTags(options.tags)
1437
- : Array.isArray(document.metadata.tags)
1438
- ? [...document.metadata.tags]
1439
- : [];
1440
- const withAdditions = mergeAdditiveTags(baseTags, addTagsValues);
1441
- const finalTags = applyTagRemovals(withAdditions, removeTagsValues);
1442
- document.metadata.tags = finalTags;
1443
- changedFields.push("tags");
1444
- }
1445
- applyUpdateScalarMutations(UPDATE_POST_TAG_SCALAR_MUTATIONS, options, scalarMutationContext);
1446
- const orderRaw = options.order ?? options.rank;
1447
- if (orderRaw !== undefined || clearFrontMatterKeys.has("order")) {
1448
- if (clearFrontMatterKeys.has("order")) {
1449
- delete document.metadata.order;
1450
- }
1451
- else {
1452
- const parsedOrder = parseOptionalNumber(orderRaw ?? "", "order");
1453
- if (!Number.isInteger(parsedOrder)) {
1454
- throw new PmCliError("Order must be an integer", EXIT_CODE.USAGE);
1455
- }
1456
- document.metadata.order = parsedOrder;
1457
- }
1458
- changedFields.push("order");
1459
- }
1460
- if (options.assignee !== undefined || clearFrontMatterKeys.has("assignee")) {
1461
- if (clearFrontMatterKeys.has("assignee")) {
1462
- delete document.metadata.assignee;
1463
- }
1464
- else {
1465
- const assignee = options.assignee?.trim() ?? "";
1466
- if (assignee === "") {
1467
- throw new PmCliError("--assignee must not be empty. Use --unset assignee to clear it.", EXIT_CODE.USAGE);
1468
- }
1469
- document.metadata.assignee = assignee;
1470
- }
1471
- changedFields.push("assignee");
1472
- }
1473
- if (options.parent !== undefined || clearFrontMatterKeys.has("parent")) {
1474
- if (clearFrontMatterKeys.has("parent")) {
1475
- delete document.metadata.parent;
1476
- }
1477
- else {
1478
- document.metadata.parent = resolvedParentValue ?? "";
1479
- }
1480
- changedFields.push("parent");
1481
- }
1482
- applyUpdateScalarMutations(UPDATE_STAKEHOLDER_SCALAR_MUTATIONS, options, scalarMutationContext);
1483
- if (options.sprint !== undefined || clearFrontMatterKeys.has("sprint")) {
1484
- if (clearFrontMatterKeys.has("sprint")) {
1485
- delete document.metadata.sprint;
1486
- }
1487
- else {
1488
- const sprintValidation = validateSprintOrReleaseValue("sprint", options.sprint ?? "", sprintReleasePolicy);
1489
- document.metadata.sprint = sprintValidation.value;
1490
- warnings.push(...sprintValidation.warnings);
1491
- }
1492
- changedFields.push("sprint");
1493
- }
1494
- if (options.release !== undefined || clearFrontMatterKeys.has("release")) {
1495
- if (clearFrontMatterKeys.has("release")) {
1496
- delete document.metadata.release;
1497
- }
1498
- else {
1499
- const releaseValidation = validateSprintOrReleaseValue("release", options.release ?? "", sprintReleasePolicy);
1500
- document.metadata.release = releaseValidation.value;
1501
- warnings.push(...releaseValidation.warnings);
1502
- }
1503
- changedFields.push("release");
1504
- }
1505
- if (options.blockedBy !== undefined || clearFrontMatterKeys.has("blocked_by")) {
1506
- if (clearFrontMatterKeys.has("blocked_by")) {
1507
- delete document.metadata.blocked_by;
1508
- }
1509
- else {
1510
- document.metadata.blocked_by = options.blockedBy?.trim() ?? "";
1511
- }
1512
- changedFields.push("blocked_by");
1513
- // pm-kyd6: keep the dependency graph in sync with the blocked_by scalar.
1514
- applyBlockedByDependencyEdge(document.metadata, resolvedBlockedByDependencyId, nowIso, author, changedFields);
1515
- }
1516
- applyUpdateScalarMutations(UPDATE_ISSUE_SCALAR_MUTATIONS, options, scalarMutationContext);
1517
- if (options.reminder !== undefined || clearFrontMatterKeys.has("reminders")) {
1518
- if (clearFrontMatterKeys.has("reminders")) {
1519
- delete document.metadata.reminders;
1520
- }
1521
- else {
1522
- document.metadata.reminders = parseReminderEntries(options.reminder ?? [], nowValue, { valueMode: "trimmed" });
1523
- }
1524
- changedFields.push("reminders");
1525
- }
1526
- if (options.event !== undefined || clearFrontMatterKeys.has("events")) {
1527
- if (clearFrontMatterKeys.has("events")) {
1528
- delete document.metadata.events;
1529
- }
1530
- else {
1531
- document.metadata.events = parseEventEntries(options.event ?? [], nowValue, {
1532
- allDayEmptyGuard: "truthy",
1533
- recurrenceEmptyNumericGuard: "truthy",
1534
- });
1535
- }
1536
- changedFields.push("events");
1537
- }
1538
- for (const definition of runtimeFieldRegistry.definitions) {
1539
- if (!clearFrontMatterKeys.has(definition.metadata_key)) {
1540
- continue;
1541
- }
1542
- if (metadataRecord[definition.metadata_key] === undefined) {
1543
- continue;
1544
- }
1545
- delete metadataRecord[definition.metadata_key];
1546
- changedFields.push(definition.metadata_key);
1547
- }
1548
- for (const fieldKey of extensionFieldNames) {
1549
- if (!clearFrontMatterKeys.has(fieldKey)) {
1550
- continue;
1551
- }
1552
- if (metadataRecord[fieldKey] === undefined) {
1553
- continue;
1554
- }
1555
- delete metadataRecord[fieldKey];
1556
- changedFields.push(fieldKey);
1557
- }
1558
- for (const [fieldKey, fieldValue] of Object.entries(runtimeFieldUpdates)) {
1559
- if (clearFrontMatterKeys.has(fieldKey)) {
1560
- continue;
1561
- }
1562
- if (stableValueEquals(metadataRecord[fieldKey], fieldValue)) {
1563
- continue;
1564
- }
1565
- metadataRecord[fieldKey] = fieldValue;
1566
- changedFields.push(fieldKey);
1567
- }
1568
- const registeredItemFieldUpdates = parseRegisteredItemFieldAssignments(options.field, extensionRegistrations);
1569
- for (const fieldKey of Object.keys(registeredItemFieldUpdates)) {
1570
- if (!clearFrontMatterKeys.has(fieldKey)) {
1571
- continue;
1572
- }
1573
- throw new PmCliError(`Cannot combine --unset ${fieldKey.replaceAll("_", "-")} with --field ${fieldKey}=...`, EXIT_CODE.USAGE);
1574
- }
1575
- for (const [fieldKey, fieldValue] of Object.entries(registeredItemFieldUpdates)) {
1576
- if (stableValueEquals(metadataRecord[fieldKey], fieldValue)) {
1577
- continue;
1578
- }
1579
- metadataRecord[fieldKey] = fieldValue;
1580
- changedFields.push(fieldKey);
1581
- }
1582
- try {
1583
- applyRegisteredItemFieldDefaultsAndValidation(metadataRecord, extensionRegistrations, { skipDefaultFields: clearFrontMatterKeys });
1584
- }
1585
- catch (error) {
1586
- throw new PmCliError(error instanceof Error ? error.message : "Invalid extension item field values", EXIT_CODE.USAGE);
1587
- }
1588
- return { changedFields, warnings };
1652
+ nowIso,
1653
+ author,
1654
+ pmRoot,
1655
+ });
1589
1656
  },
1590
1657
  });
1591
1658
  return {
@@ -1611,4 +1678,4 @@ export const _testOnlyUpdateCommand = {
1611
1678
  resolveRuntimeUnsetDefinition: (token, registry) => resolveRuntimeUnsetFieldDefinition(token, "update", registry),
1612
1679
  };
1613
1680
  //# sourceMappingURL=update.js.map
1614
- //# debugId=17376741-e64e-5a26-9c7e-3f23fee80095
1681
+ //# debugId=6156dbbd-29ea-58f5-ba6e-c9ae989e23e3