@unbrained/pm-cli 2026.5.29 → 2026.5.31

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 (274) hide show
  1. package/CHANGELOG.md +54 -12
  2. package/dist/cli/bootstrap-args.d.ts +1 -1
  3. package/dist/cli/bootstrap-args.js +59 -9
  4. package/dist/cli/bootstrap-args.js.map +1 -1
  5. package/dist/cli/commands/activity.js +4 -4
  6. package/dist/cli/commands/activity.js.map +1 -1
  7. package/dist/cli/commands/calendar.js +83 -11
  8. package/dist/cli/commands/calendar.js.map +1 -1
  9. package/dist/cli/commands/close.js +4 -4
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +4 -4
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/create.js +50 -7
  14. package/dist/cli/commands/create.js.map +1 -1
  15. package/dist/cli/commands/deps.js +4 -4
  16. package/dist/cli/commands/deps.js.map +1 -1
  17. package/dist/cli/commands/extension/install-sources.d.ts +3 -0
  18. package/dist/cli/commands/extension/install-sources.js +29 -4
  19. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  20. package/dist/cli/commands/extension.js +26 -5
  21. package/dist/cli/commands/extension.js.map +1 -1
  22. package/dist/cli/commands/get.js +6 -3
  23. package/dist/cli/commands/get.js.map +1 -1
  24. package/dist/cli/commands/list.js +25 -6
  25. package/dist/cli/commands/list.js.map +1 -1
  26. package/dist/cli/commands/reindex.js +3 -3
  27. package/dist/cli/commands/reindex.js.map +1 -1
  28. package/dist/cli/commands/search.d.ts +17 -0
  29. package/dist/cli/commands/search.js +40 -10
  30. package/dist/cli/commands/search.js.map +1 -1
  31. package/dist/cli/commands/stats.js +4 -4
  32. package/dist/cli/commands/stats.js.map +1 -1
  33. package/dist/cli/commands/test-all.js +4 -4
  34. package/dist/cli/commands/test-all.js.map +1 -1
  35. package/dist/cli/main.d.ts +2 -0
  36. package/dist/cli/main.js +39 -11
  37. package/dist/cli/main.js.map +1 -1
  38. package/dist/cli/register-list-query.js +10 -12
  39. package/dist/cli/register-list-query.js.map +1 -1
  40. package/dist/cli/register-mutation.js +20 -22
  41. package/dist/cli/register-mutation.js.map +1 -1
  42. package/dist/cli/register-operations.js +32 -25
  43. package/dist/cli/register-operations.js.map +1 -1
  44. package/dist/cli/register-setup.js +7 -9
  45. package/dist/cli/register-setup.js.map +1 -1
  46. package/dist/cli/registration-helpers.js +6 -3
  47. package/dist/cli/registration-helpers.js.map +1 -1
  48. package/dist/cli/search-refresh.d.ts +2 -0
  49. package/dist/cli/search-refresh.js +13 -0
  50. package/dist/cli/search-refresh.js.map +1 -0
  51. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +17 -0
  52. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js.map +7 -0
  53. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js +209 -0
  54. package/dist/cli-bundle/chunks/aggregate-ADUOSFRO.js.map +7 -0
  55. package/dist/cli-bundle/chunks/append-JD2DETU7.js +73 -0
  56. package/dist/cli-bundle/chunks/append-JD2DETU7.js.map +7 -0
  57. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
  58. package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
  59. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js +1636 -0
  60. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +7 -0
  61. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +189 -0
  62. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +7 -0
  63. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js +330 -0
  64. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +7 -0
  65. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js +1770 -0
  66. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +7 -0
  67. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js +552 -0
  68. package/dist/cli-bundle/chunks/chunk-6YCV7WSL.js.map +7 -0
  69. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js +202 -0
  70. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +7 -0
  71. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js +157 -0
  72. package/dist/cli-bundle/chunks/chunk-A7E7PUVX.js.map +7 -0
  73. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js +90 -0
  74. package/dist/cli-bundle/chunks/chunk-AKOOMO3T.js.map +7 -0
  75. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js +950 -0
  76. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +7 -0
  77. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js +79 -0
  78. package/dist/cli-bundle/chunks/chunk-CEFIVZPG.js.map +7 -0
  79. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js +349 -0
  80. package/dist/cli-bundle/chunks/chunk-D7AOMPRH.js.map +7 -0
  81. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
  82. package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
  83. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +47 -0
  84. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +7 -0
  85. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +56 -0
  86. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +7 -0
  87. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js +435 -0
  88. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +7 -0
  89. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js +185 -0
  90. package/dist/cli-bundle/chunks/chunk-G57E5D7T.js.map +7 -0
  91. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js +3621 -0
  92. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +7 -0
  93. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js +233 -0
  94. package/dist/cli-bundle/chunks/chunk-JFWUHHS2.js.map +7 -0
  95. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js +1861 -0
  96. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +7 -0
  97. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js +648 -0
  98. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +7 -0
  99. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js +122 -0
  100. package/dist/cli-bundle/chunks/chunk-KBQY3YG5.js.map +7 -0
  101. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js +185 -0
  102. package/dist/cli-bundle/chunks/chunk-L2FXEKDB.js.map +7 -0
  103. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js +189 -0
  104. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +7 -0
  105. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js +5153 -0
  106. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +7 -0
  107. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js +1345 -0
  108. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +7 -0
  109. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js +341 -0
  110. package/dist/cli-bundle/chunks/chunk-NGN7UV5K.js.map +7 -0
  111. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
  112. package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
  113. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js +2929 -0
  114. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +7 -0
  115. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js +674 -0
  116. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +7 -0
  117. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js +176 -0
  118. package/dist/cli-bundle/chunks/chunk-PVNQLCIS.js.map +7 -0
  119. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js +1680 -0
  120. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +7 -0
  121. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
  122. package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
  123. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js +60 -0
  124. package/dist/cli-bundle/chunks/chunk-SEXQN4KL.js.map +7 -0
  125. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js +362 -0
  126. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +7 -0
  127. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +141 -0
  128. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +7 -0
  129. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js +632 -0
  130. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +7 -0
  131. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js +252 -0
  132. package/dist/cli-bundle/chunks/chunk-WJ2NAC37.js.map +7 -0
  133. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js +133 -0
  134. package/dist/cli-bundle/chunks/claim-EE4TKKCV.js.map +7 -0
  135. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +14 -0
  136. package/dist/cli-bundle/chunks/close-XY4CSAYF.js.map +7 -0
  137. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js +104 -0
  138. package/dist/cli-bundle/chunks/comments-AAKJQ6LW.js.map +7 -0
  139. package/dist/cli-bundle/chunks/config-V3FZOKLI.js +1577 -0
  140. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +7 -0
  141. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js +1458 -0
  142. package/dist/cli-bundle/chunks/context-RZ5QPNJB.js.map +7 -0
  143. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js +1245 -0
  144. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +7 -0
  145. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +28 -0
  146. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js.map +7 -0
  147. package/dist/cli-bundle/chunks/delete-RHCTEORS.js +59 -0
  148. package/dist/cli-bundle/chunks/delete-RHCTEORS.js.map +7 -0
  149. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js +229 -0
  150. package/dist/cli-bundle/chunks/deps-MZYCMLAO.js.map +7 -0
  151. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js +35 -0
  152. package/dist/cli-bundle/chunks/docs-FXXUCZYU.js.map +7 -0
  153. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js +25 -0
  154. package/dist/cli-bundle/chunks/extension-B4WL7BQU.js.map +7 -0
  155. package/dist/cli-bundle/chunks/files-WVOX67PE.js +286 -0
  156. package/dist/cli-bundle/chunks/files-WVOX67PE.js.map +7 -0
  157. package/dist/cli-bundle/chunks/gc-JWNF66EC.js +181 -0
  158. package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +7 -0
  159. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js +198 -0
  160. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +7 -0
  161. package/dist/cli-bundle/chunks/health-TCWL55KM.js +1233 -0
  162. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +7 -0
  163. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +21 -0
  164. package/dist/cli-bundle/chunks/history-A2JUDXUE.js.map +7 -0
  165. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +20 -0
  166. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js.map +7 -0
  167. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js +198 -0
  168. package/dist/cli-bundle/chunks/history-repair-ZWSTDRH2.js.map +7 -0
  169. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +16 -0
  170. package/dist/cli-bundle/chunks/init-M2WUB4YH.js.map +7 -0
  171. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js +48 -0
  172. package/dist/cli-bundle/chunks/learnings-NXTWE3FR.js.map +7 -0
  173. package/dist/cli-bundle/chunks/list-OGWQPC26.js +20 -0
  174. package/dist/cli-bundle/chunks/list-OGWQPC26.js.map +7 -0
  175. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js +48 -0
  176. package/dist/cli-bundle/chunks/notes-DFS5ZGOO.js.map +7 -0
  177. package/dist/cli-bundle/chunks/plan-67AB2PLM.js +1175 -0
  178. package/dist/cli-bundle/chunks/plan-67AB2PLM.js.map +7 -0
  179. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js +232 -0
  180. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +7 -0
  181. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js +712 -0
  182. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +7 -0
  183. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js +374 -0
  184. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +7 -0
  185. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js +246 -0
  186. package/dist/cli-bundle/chunks/register-setup-V56GDRUS.js.map +7 -0
  187. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +18 -0
  188. package/dist/cli-bundle/chunks/restore-MB2ISME7.js.map +7 -0
  189. package/dist/cli-bundle/chunks/schema-Q622KC46.js +119 -0
  190. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +7 -0
  191. package/dist/cli-bundle/chunks/search-HENBL456.js +1135 -0
  192. package/dist/cli-bundle/chunks/search-HENBL456.js.map +7 -0
  193. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +124 -0
  194. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +7 -0
  195. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +32 -0
  196. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js.map +7 -0
  197. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js +332 -0
  198. package/dist/cli-bundle/chunks/test-all-G2AZOHXI.js.map +7 -0
  199. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js +939 -0
  200. package/dist/cli-bundle/chunks/test-runs-GX5HTPSF.js.map +7 -0
  201. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +22 -0
  202. package/dist/cli-bundle/chunks/update-H6SCWNMA.js.map +7 -0
  203. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js +676 -0
  204. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +7 -0
  205. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js +271 -0
  206. package/dist/cli-bundle/chunks/upgrade-H5HHM5UV.js.map +7 -0
  207. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js +1110 -0
  208. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +7 -0
  209. package/dist/cli-bundle/main.js +6952 -0
  210. package/dist/cli-bundle/main.js.map +7 -0
  211. package/dist/cli.js +1 -1
  212. package/dist/core/config/nested-settings.d.ts +2 -0
  213. package/dist/core/config/nested-settings.js +17 -2
  214. package/dist/core/config/nested-settings.js.map +1 -1
  215. package/dist/core/item/item-type-definition.js +6 -2
  216. package/dist/core/item/item-type-definition.js.map +1 -1
  217. package/dist/core/item/type-registry.d.ts +4 -0
  218. package/dist/core/item/type-registry.js +10 -2
  219. package/dist/core/item/type-registry.js.map +1 -1
  220. package/dist/core/item/type-synonyms.d.ts +20 -0
  221. package/dist/core/item/type-synonyms.js +42 -0
  222. package/dist/core/item/type-synonyms.js.map +1 -0
  223. package/dist/core/search/background-refresh.d.ts +53 -0
  224. package/dist/core/search/background-refresh.js +286 -0
  225. package/dist/core/search/background-refresh.js.map +1 -0
  226. package/dist/core/search/cache.d.ts +20 -1
  227. package/dist/core/search/cache.js +76 -5
  228. package/dist/core/search/cache.js.map +1 -1
  229. package/dist/core/search/semantic-defaults.js +73 -32
  230. package/dist/core/search/semantic-defaults.js.map +1 -1
  231. package/dist/core/search/vector-stores.js +7 -3
  232. package/dist/core/search/vector-stores.js.map +1 -1
  233. package/dist/core/sentry/helpers.d.ts +1 -1
  234. package/dist/core/sentry/helpers.js +4 -4
  235. package/dist/core/sentry/helpers.js.map +1 -1
  236. package/dist/core/shared/constants.d.ts +2 -2
  237. package/dist/core/shared/constants.js +3 -3
  238. package/dist/core/shared/constants.js.map +1 -1
  239. package/dist/core/shared/html-entity-decode.d.ts +2 -1
  240. package/dist/core/shared/html-entity-decode.js +14 -9
  241. package/dist/core/shared/html-entity-decode.js.map +1 -1
  242. package/dist/core/shared/time.js +52 -2
  243. package/dist/core/shared/time.js.map +1 -1
  244. package/dist/core/store/front-matter-cache.d.ts +24 -0
  245. package/dist/core/store/front-matter-cache.js +119 -8
  246. package/dist/core/store/front-matter-cache.js.map +1 -1
  247. package/dist/core/store/item-format-migration.js +25 -15
  248. package/dist/core/store/item-format-migration.js.map +1 -1
  249. package/dist/core/store/item-store.d.ts +7 -0
  250. package/dist/core/store/item-store.js +13 -3
  251. package/dist/core/store/item-store.js.map +1 -1
  252. package/dist/core/store/settings-validator.d.ts +1 -0
  253. package/dist/core/store/settings-validator.js +7 -2
  254. package/dist/core/store/settings-validator.js.map +1 -1
  255. package/dist/core/store/settings.js +19 -3
  256. package/dist/core/store/settings.js.map +1 -1
  257. package/dist/core/telemetry/runtime.d.ts +10 -0
  258. package/dist/core/telemetry/runtime.js +86 -2
  259. package/dist/core/telemetry/runtime.js.map +1 -1
  260. package/dist/mcp/server.js +3 -3
  261. package/dist/mcp/server.js.map +1 -1
  262. package/dist/sdk/cli-contracts/tool-parameter-tables.js +4 -4
  263. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  264. package/dist/sdk/cli-contracts.js +29 -8
  265. package/dist/sdk/cli-contracts.js.map +1 -1
  266. package/dist/types.d.ts +9 -1
  267. package/dist/types.js +2 -2
  268. package/dist/types.js.map +1 -1
  269. package/docs/CONFIGURATION.md +11 -0
  270. package/docs/RELEASING.md +1 -1
  271. package/package.json +7 -5
  272. package/packages/pm-calendar/extensions/calendar/index.js +27 -2
  273. package/packages/pm-calendar/extensions/calendar/index.ts +28 -2
  274. package/scripts/bundle-cli.mjs +39 -0
@@ -0,0 +1,1636 @@
1
+ import {
2
+ applyRegisteredItemFieldDefaultsAndValidation,
3
+ assertNoLegacyNoneToken,
4
+ assertNoLegacyNoneTokens,
5
+ ensureEnumValue,
6
+ isLegacyNoneToken,
7
+ normalizeRiskInput,
8
+ normalizeSeverityInput,
9
+ parseConfidenceInput,
10
+ parseDocs,
11
+ parseEventBoolean,
12
+ parseFiles,
13
+ parseLogSeed,
14
+ parseRecurrenceRule,
15
+ parseRegressionInput,
16
+ parseTests,
17
+ resolveEventEndAt,
18
+ resolvePriority
19
+ } from "./chunk-JTWRXG4B.js";
20
+ import {
21
+ buildInvalidTypeError
22
+ } from "./chunk-7Y53ZJIQ.js";
23
+ import {
24
+ applyTagRemovals,
25
+ createStdinTokenResolver,
26
+ mergeAdditiveTags,
27
+ parseCsvKv,
28
+ parseOptionalNumber,
29
+ parseTags
30
+ } from "./chunk-NGN7UV5K.js";
31
+ import {
32
+ runClose
33
+ } from "./chunk-G57E5D7T.js";
34
+ import {
35
+ normalizeParentReferenceValue,
36
+ validateMissingParentReference,
37
+ validateSprintOrReleaseValue
38
+ } from "./chunk-AKOOMO3T.js";
39
+ import {
40
+ buildItemNotFoundError,
41
+ locateItem,
42
+ mutateItem,
43
+ readLocatedItem,
44
+ toItemRecord
45
+ } from "./chunk-BUPWJ3IJ.js";
46
+ import {
47
+ normalizeItemId
48
+ } from "./chunk-CEFIVZPG.js";
49
+ import {
50
+ collectRuntimeUpdateFieldValues,
51
+ normalizeStatusInput
52
+ } from "./chunk-MD7K4JYF.js";
53
+ import {
54
+ canonicalizeCommandOptionKey,
55
+ commandOptionFlagLabel,
56
+ resolveCommandOptionPolicyState,
57
+ resolveItemTypeRegistry,
58
+ resolveTypeDefinition,
59
+ resolveTypeName,
60
+ validateTypeOptions
61
+ } from "./chunk-WDPXDQFG.js";
62
+ import {
63
+ resolveIsoOrRelative
64
+ } from "./chunk-PVNQLCIS.js";
65
+ import {
66
+ DEPENDENCY_KIND_VALUES,
67
+ EXIT_CODE,
68
+ ISSUE_SEVERITY_VALUES,
69
+ PmCliError,
70
+ RISK_VALUES,
71
+ getActiveExtensionRegistrations,
72
+ getSettingsPath,
73
+ pathExists,
74
+ readSettings,
75
+ resolvePmRoot,
76
+ resolveRuntimeFieldRegistry,
77
+ resolveRuntimeStatusRegistry
78
+ } from "./chunk-LSXGH6NE.js";
79
+
80
+ // dist/cli/commands/update.js
81
+ !(function() {
82
+ try {
83
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
84
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3722af32-cd81-5b1e-bc17-bdb1f3335754");
85
+ } catch (e2) {
86
+ }
87
+ })();
88
+ var UPDATE_UNSET_FIELD_DEFINITIONS = [
89
+ { canonical: "tags", aliases: ["tags"], optionKey: "tags", frontMatterKey: "tags" },
90
+ { canonical: "close-reason", aliases: ["close_reason", "close-reason"], optionKey: "closeReason", frontMatterKey: "close_reason" },
91
+ { canonical: "deadline", aliases: ["deadline"], optionKey: "deadline", frontMatterKey: "deadline" },
92
+ {
93
+ canonical: "estimate",
94
+ aliases: ["estimate", "estimated_minutes", "estimated-minutes"],
95
+ optionKey: "estimatedMinutes",
96
+ frontMatterKey: "estimated_minutes"
97
+ },
98
+ {
99
+ canonical: "acceptance-criteria",
100
+ aliases: ["acceptance_criteria", "acceptance-criteria", "ac"],
101
+ optionKey: "acceptanceCriteria",
102
+ frontMatterKey: "acceptance_criteria"
103
+ },
104
+ {
105
+ canonical: "definition-of-ready",
106
+ aliases: ["definition_of_ready", "definition-of-ready"],
107
+ optionKey: "definitionOfReady",
108
+ frontMatterKey: "definition_of_ready"
109
+ },
110
+ { canonical: "order", aliases: ["order", "rank"], optionKey: "order", frontMatterKey: "order" },
111
+ { canonical: "goal", aliases: ["goal"], optionKey: "goal", frontMatterKey: "goal" },
112
+ { canonical: "objective", aliases: ["objective"], optionKey: "objective", frontMatterKey: "objective" },
113
+ { canonical: "value", aliases: ["value"], optionKey: "value", frontMatterKey: "value" },
114
+ { canonical: "impact", aliases: ["impact"], optionKey: "impact", frontMatterKey: "impact" },
115
+ { canonical: "outcome", aliases: ["outcome"], optionKey: "outcome", frontMatterKey: "outcome" },
116
+ { canonical: "why-now", aliases: ["why_now", "why-now"], optionKey: "whyNow", frontMatterKey: "why_now" },
117
+ { canonical: "assignee", aliases: ["assignee"], optionKey: "assignee", frontMatterKey: "assignee" },
118
+ { canonical: "parent", aliases: ["parent"], optionKey: "parent", frontMatterKey: "parent" },
119
+ { canonical: "reviewer", aliases: ["reviewer"], optionKey: "reviewer", frontMatterKey: "reviewer" },
120
+ { canonical: "risk", aliases: ["risk"], optionKey: "risk", frontMatterKey: "risk" },
121
+ { canonical: "confidence", aliases: ["confidence"], optionKey: "confidence", frontMatterKey: "confidence" },
122
+ { canonical: "sprint", aliases: ["sprint"], optionKey: "sprint", frontMatterKey: "sprint" },
123
+ { canonical: "release", aliases: ["release"], optionKey: "release", frontMatterKey: "release" },
124
+ {
125
+ canonical: "blocked-by",
126
+ aliases: ["blocked_by", "blocked-by"],
127
+ optionKey: "blockedBy",
128
+ frontMatterKey: "blocked_by"
129
+ },
130
+ {
131
+ canonical: "blocked-reason",
132
+ aliases: ["blocked_reason", "blocked-reason"],
133
+ optionKey: "blockedReason",
134
+ frontMatterKey: "blocked_reason"
135
+ },
136
+ {
137
+ canonical: "unblock-note",
138
+ aliases: ["unblock_note", "unblock-note"],
139
+ optionKey: "unblockNote",
140
+ frontMatterKey: "unblock_note"
141
+ },
142
+ { canonical: "reporter", aliases: ["reporter"], optionKey: "reporter", frontMatterKey: "reporter" },
143
+ { canonical: "severity", aliases: ["severity"], optionKey: "severity", frontMatterKey: "severity" },
144
+ {
145
+ canonical: "environment",
146
+ aliases: ["environment"],
147
+ optionKey: "environment",
148
+ frontMatterKey: "environment"
149
+ },
150
+ {
151
+ canonical: "repro-steps",
152
+ aliases: ["repro_steps", "repro-steps"],
153
+ optionKey: "reproSteps",
154
+ frontMatterKey: "repro_steps"
155
+ },
156
+ {
157
+ canonical: "resolution",
158
+ aliases: ["resolution"],
159
+ optionKey: "resolution",
160
+ frontMatterKey: "resolution"
161
+ },
162
+ {
163
+ canonical: "expected-result",
164
+ aliases: ["expected_result", "expected-result"],
165
+ optionKey: "expectedResult",
166
+ frontMatterKey: "expected_result"
167
+ },
168
+ {
169
+ canonical: "actual-result",
170
+ aliases: ["actual_result", "actual-result"],
171
+ optionKey: "actualResult",
172
+ frontMatterKey: "actual_result"
173
+ },
174
+ {
175
+ canonical: "affected-version",
176
+ aliases: ["affected_version", "affected-version"],
177
+ optionKey: "affectedVersion",
178
+ frontMatterKey: "affected_version"
179
+ },
180
+ {
181
+ canonical: "fixed-version",
182
+ aliases: ["fixed_version", "fixed-version"],
183
+ optionKey: "fixedVersion",
184
+ frontMatterKey: "fixed_version"
185
+ },
186
+ { canonical: "component", aliases: ["component"], optionKey: "component", frontMatterKey: "component" },
187
+ { canonical: "regression", aliases: ["regression"], optionKey: "regression", frontMatterKey: "regression" },
188
+ {
189
+ canonical: "customer-impact",
190
+ aliases: ["customer_impact", "customer-impact"],
191
+ optionKey: "customerImpact",
192
+ frontMatterKey: "customer_impact"
193
+ }
194
+ ];
195
+ var UPDATE_UNSET_ALIAS_MAP = (() => {
196
+ const map = /* @__PURE__ */ new Map();
197
+ for (const definition of UPDATE_UNSET_FIELD_DEFINITIONS) {
198
+ for (const alias of definition.aliases) {
199
+ map.set(alias, {
200
+ optionKey: definition.optionKey,
201
+ frontMatterKey: definition.frontMatterKey
202
+ });
203
+ }
204
+ }
205
+ return map;
206
+ })();
207
+ var UPDATE_OPTION_KEY_TO_UNSET_CANONICAL = new Map(UPDATE_UNSET_FIELD_DEFINITIONS.map((definition) => [definition.optionKey, definition.canonical]));
208
+ var UPDATE_UNSET_SUPPORTED_CANONICAL_FIELDS = UPDATE_UNSET_FIELD_DEFINITIONS.map((definition) => definition.canonical).sort((left, right) => left.localeCompare(right)).join(", ");
209
+ var AUDIT_UPDATE_DISALLOWED_UNSET_FRONT_MATTER_KEYS = /* @__PURE__ */ new Set([
210
+ "close_reason",
211
+ "assignee",
212
+ "parent",
213
+ "blocked_by",
214
+ "blocked_reason",
215
+ "unblock_note",
216
+ "dependencies",
217
+ "comments",
218
+ "notes",
219
+ "learnings",
220
+ "files",
221
+ "tests",
222
+ "docs",
223
+ "reminders",
224
+ "events"
225
+ ]);
226
+ function toAuthor(candidate, defaultAuthor) {
227
+ const resolved = candidate ?? process.env.PM_AUTHOR ?? defaultAuthor;
228
+ const trimmed = resolved.trim();
229
+ return trimmed || "unknown";
230
+ }
231
+ var UPDATE_LEGACY_NONE_COLLECTION_NORMALIZERS = [
232
+ { optionKey: "dep", clearFlagKey: "clearDeps", valueFlag: "--dep", clearFlag: "--clear-deps", disableReplaceFlagKey: "replaceDeps" },
233
+ { optionKey: "comment", clearFlagKey: "clearComments", valueFlag: "--comment", clearFlag: "--clear-comments" },
234
+ { optionKey: "note", clearFlagKey: "clearNotes", valueFlag: "--note", clearFlag: "--clear-notes" },
235
+ { optionKey: "learning", clearFlagKey: "clearLearnings", valueFlag: "--learning", clearFlag: "--clear-learnings" },
236
+ { optionKey: "file", clearFlagKey: "clearFiles", valueFlag: "--file", clearFlag: "--clear-files" },
237
+ { optionKey: "test", clearFlagKey: "clearTests", valueFlag: "--test", clearFlag: "--clear-tests", disableReplaceFlagKey: "replaceTests" },
238
+ { optionKey: "doc", clearFlagKey: "clearDocs", valueFlag: "--doc", clearFlag: "--clear-docs" },
239
+ { optionKey: "reminder", clearFlagKey: "clearReminders", valueFlag: "--reminder", clearFlag: "--clear-reminders" },
240
+ { optionKey: "event", clearFlagKey: "clearEvents", valueFlag: "--event", clearFlag: "--clear-events" },
241
+ { optionKey: "typeOption", clearFlagKey: "clearTypeOptions", valueFlag: "--type-option", clearFlag: "--clear-type-options" }
242
+ ];
243
+ function normalizeLegacyNoneUpdateOptions(options) {
244
+ const normalized = {
245
+ ...options,
246
+ unset: options.unset ? [...options.unset] : void 0
247
+ };
248
+ const appendUnsetTarget = (value) => {
249
+ const current = normalized.unset ? [...normalized.unset] : [];
250
+ if (!current.includes(value)) {
251
+ current.push(value);
252
+ }
253
+ normalized.unset = current;
254
+ };
255
+ const scalarOptionKeys = /* @__PURE__ */ new Set([...UPDATE_OPTION_KEY_TO_UNSET_CANONICAL.keys(), "rank"]);
256
+ for (const optionKey of scalarOptionKeys) {
257
+ const candidate = normalized[optionKey];
258
+ if (typeof candidate !== "string" || !isLegacyNoneToken(candidate)) {
259
+ continue;
260
+ }
261
+ const canonicalUnset = optionKey === "rank" ? "order" : UPDATE_OPTION_KEY_TO_UNSET_CANONICAL.get(optionKey) ?? optionKey;
262
+ appendUnsetTarget(canonicalUnset);
263
+ normalized[optionKey] = void 0;
264
+ }
265
+ for (const definition of UPDATE_LEGACY_NONE_COLLECTION_NORMALIZERS) {
266
+ const entries = normalized[definition.optionKey];
267
+ if (!Array.isArray(entries) || entries.length === 0) {
268
+ continue;
269
+ }
270
+ const hasLegacy = entries.some((entry) => isLegacyNoneToken(entry));
271
+ if (!hasLegacy) {
272
+ continue;
273
+ }
274
+ const concreteEntries = entries.filter((entry) => !isLegacyNoneToken(entry));
275
+ if (concreteEntries.length > 0) {
276
+ throw new PmCliError(`Cannot mix legacy clear token "none"/"null" with concrete ${definition.valueFlag} entries. Use ${definition.clearFlag} to clear or provide explicit entries.`, EXIT_CODE.USAGE);
277
+ }
278
+ normalized[definition.optionKey] = void 0;
279
+ normalized[definition.clearFlagKey] = true;
280
+ if (definition.disableReplaceFlagKey) {
281
+ normalized[definition.disableReplaceFlagKey] = false;
282
+ }
283
+ }
284
+ return normalized;
285
+ }
286
+ function resolveRuntimeUnsetDefinition(token, runtimeFieldRegistry) {
287
+ if (!runtimeFieldRegistry) {
288
+ return void 0;
289
+ }
290
+ for (const definition of runtimeFieldRegistry.definitions) {
291
+ if (definition.allow_unset === false) {
292
+ continue;
293
+ }
294
+ const candidates = /* @__PURE__ */ new Set([
295
+ definition.key,
296
+ definition.metadata_key,
297
+ definition.cli_flag.replaceAll("-", "_"),
298
+ definition.cli_flag,
299
+ ...definition.cli_aliases.map((alias) => alias.replaceAll("-", "_")),
300
+ ...definition.cli_aliases
301
+ ]);
302
+ if (!candidates.has(token)) {
303
+ continue;
304
+ }
305
+ return {
306
+ optionKey: definition.key,
307
+ frontMatterKey: definition.metadata_key
308
+ };
309
+ }
310
+ return void 0;
311
+ }
312
+ function parseUpdateUnsetTargets(raw, runtimeFieldRegistry) {
313
+ const frontMatterKeys = /* @__PURE__ */ new Set();
314
+ const optionKeys = /* @__PURE__ */ new Set();
315
+ if (!raw || raw.length === 0) {
316
+ return { frontMatterKeys, optionKeys };
317
+ }
318
+ for (const entry of raw) {
319
+ const trimmed = entry.trim().toLowerCase();
320
+ if (!trimmed) {
321
+ throw new PmCliError("--unset values must not be empty", EXIT_CODE.USAGE);
322
+ }
323
+ if (isLegacyNoneToken(trimmed)) {
324
+ throw new PmCliError('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline', EXIT_CODE.USAGE);
325
+ }
326
+ const definition = UPDATE_UNSET_ALIAS_MAP.get(trimmed) ?? resolveRuntimeUnsetDefinition(trimmed, runtimeFieldRegistry);
327
+ if (!definition) {
328
+ throw new PmCliError(`Unsupported --unset field "${entry}". Supported fields: ${UPDATE_UNSET_SUPPORTED_CANONICAL_FIELDS}`, EXIT_CODE.USAGE);
329
+ }
330
+ frontMatterKeys.add(definition.frontMatterKey);
331
+ optionKeys.add(definition.optionKey);
332
+ }
333
+ return { frontMatterKeys, optionKeys };
334
+ }
335
+ function enforceAllowAuditUpdateScope(options, clearFrontMatterKeys) {
336
+ const allowAuditUpdate = options.allowAuditUpdate === true;
337
+ const allowAuditDepUpdate = options.allowAuditDepUpdate === true;
338
+ if (!allowAuditUpdate && !allowAuditDepUpdate) {
339
+ return;
340
+ }
341
+ if (allowAuditUpdate && allowAuditDepUpdate) {
342
+ throw new PmCliError("Choose either --allow-audit-update or --allow-audit-dep-update; these override modes are mutually exclusive.", EXIT_CODE.USAGE);
343
+ }
344
+ const pushIf = (condition, flag, list) => {
345
+ if (condition) {
346
+ list.push(flag);
347
+ }
348
+ };
349
+ if (allowAuditDepUpdate) {
350
+ const disallowedFlags2 = [];
351
+ pushIf(options.title !== void 0, "--title", disallowedFlags2);
352
+ pushIf(options.description !== void 0, "--description", disallowedFlags2);
353
+ pushIf(options.body !== void 0, "--body", disallowedFlags2);
354
+ pushIf(options.status !== void 0, "--status", disallowedFlags2);
355
+ pushIf(options.closeReason !== void 0, "--close-reason", disallowedFlags2);
356
+ pushIf(options.priority !== void 0, "--priority", disallowedFlags2);
357
+ pushIf(options.type !== void 0, "--type", disallowedFlags2);
358
+ pushIf(options.tags !== void 0, "--tags", disallowedFlags2);
359
+ pushIf(Array.isArray(options.addTags) && options.addTags.length > 0, "--add-tags", disallowedFlags2);
360
+ pushIf(Array.isArray(options.removeTags) && options.removeTags.length > 0, "--remove-tags", disallowedFlags2);
361
+ pushIf(options.deadline !== void 0, "--deadline", disallowedFlags2);
362
+ pushIf(options.estimatedMinutes !== void 0, "--estimate", disallowedFlags2);
363
+ pushIf(options.acceptanceCriteria !== void 0, "--acceptance-criteria", disallowedFlags2);
364
+ pushIf(options.definitionOfReady !== void 0, "--definition-of-ready", disallowedFlags2);
365
+ pushIf(options.order !== void 0 || options.rank !== void 0, "--order/--rank", disallowedFlags2);
366
+ pushIf(options.goal !== void 0, "--goal", disallowedFlags2);
367
+ pushIf(options.objective !== void 0, "--objective", disallowedFlags2);
368
+ pushIf(options.value !== void 0, "--value", disallowedFlags2);
369
+ pushIf(options.impact !== void 0, "--impact", disallowedFlags2);
370
+ pushIf(options.outcome !== void 0, "--outcome", disallowedFlags2);
371
+ pushIf(options.whyNow !== void 0, "--why-now", disallowedFlags2);
372
+ pushIf(options.assignee !== void 0, "--assignee", disallowedFlags2);
373
+ pushIf(options.parent !== void 0, "--parent", disallowedFlags2);
374
+ pushIf(options.reviewer !== void 0, "--reviewer", disallowedFlags2);
375
+ pushIf(options.risk !== void 0, "--risk", disallowedFlags2);
376
+ pushIf(options.confidence !== void 0, "--confidence", disallowedFlags2);
377
+ pushIf(options.sprint !== void 0, "--sprint", disallowedFlags2);
378
+ pushIf(options.release !== void 0, "--release", disallowedFlags2);
379
+ pushIf(options.blockedBy !== void 0, "--blocked-by", disallowedFlags2);
380
+ pushIf(options.blockedReason !== void 0, "--blocked-reason", disallowedFlags2);
381
+ pushIf(options.unblockNote !== void 0, "--unblock-note", disallowedFlags2);
382
+ pushIf(options.reporter !== void 0, "--reporter", disallowedFlags2);
383
+ pushIf(options.severity !== void 0, "--severity", disallowedFlags2);
384
+ pushIf(options.environment !== void 0, "--environment", disallowedFlags2);
385
+ pushIf(options.reproSteps !== void 0, "--repro-steps", disallowedFlags2);
386
+ pushIf(options.resolution !== void 0, "--resolution", disallowedFlags2);
387
+ pushIf(options.expectedResult !== void 0, "--expected-result", disallowedFlags2);
388
+ pushIf(options.actualResult !== void 0, "--actual-result", disallowedFlags2);
389
+ pushIf(options.affectedVersion !== void 0, "--affected-version", disallowedFlags2);
390
+ pushIf(options.fixedVersion !== void 0, "--fixed-version", disallowedFlags2);
391
+ pushIf(options.component !== void 0, "--component", disallowedFlags2);
392
+ pushIf(options.regression !== void 0, "--regression", disallowedFlags2);
393
+ pushIf(options.customerImpact !== void 0, "--customer-impact", disallowedFlags2);
394
+ pushIf(options.depRemove !== void 0, "--dep-remove", disallowedFlags2);
395
+ pushIf(options.replaceDeps === true, "--replace-deps", disallowedFlags2);
396
+ pushIf(options.replaceTests === true, "--replace-tests", disallowedFlags2);
397
+ pushIf(options.comment !== void 0, "--comment", disallowedFlags2);
398
+ pushIf(options.note !== void 0, "--note", disallowedFlags2);
399
+ pushIf(options.learning !== void 0, "--learning", disallowedFlags2);
400
+ pushIf(options.file !== void 0, "--file", disallowedFlags2);
401
+ pushIf(options.test !== void 0, "--test", disallowedFlags2);
402
+ pushIf(options.doc !== void 0, "--doc", disallowedFlags2);
403
+ pushIf(options.reminder !== void 0, "--reminder", disallowedFlags2);
404
+ pushIf(options.event !== void 0, "--event", disallowedFlags2);
405
+ pushIf(options.typeOption !== void 0, "--type-option", disallowedFlags2);
406
+ pushIf(options.clearDeps === true, "--clear-deps", disallowedFlags2);
407
+ pushIf(options.clearComments === true, "--clear-comments", disallowedFlags2);
408
+ pushIf(options.clearNotes === true, "--clear-notes", disallowedFlags2);
409
+ pushIf(options.clearLearnings === true, "--clear-learnings", disallowedFlags2);
410
+ pushIf(options.clearFiles === true, "--clear-files", disallowedFlags2);
411
+ pushIf(options.clearTests === true, "--clear-tests", disallowedFlags2);
412
+ pushIf(options.clearDocs === true, "--clear-docs", disallowedFlags2);
413
+ pushIf(options.clearReminders === true, "--clear-reminders", disallowedFlags2);
414
+ pushIf(options.clearEvents === true, "--clear-events", disallowedFlags2);
415
+ pushIf(options.clearTypeOptions === true, "--clear-type-options", disallowedFlags2);
416
+ pushIf(options.force === true, "--force", disallowedFlags2);
417
+ pushIf(clearFrontMatterKeys.size > 0, "--unset", disallowedFlags2);
418
+ if (options.dep === void 0 || options.dep.length === 0) {
419
+ throw new PmCliError("--allow-audit-dep-update requires at least one --dep value", EXIT_CODE.USAGE);
420
+ }
421
+ if (disallowedFlags2.length > 0) {
422
+ throw new PmCliError(`--allow-audit-dep-update supports append-only dependency additions via --dep. Remove restricted options: ${disallowedFlags2.join(", ")}`, EXIT_CODE.USAGE);
423
+ }
424
+ return;
425
+ }
426
+ const disallowedFlags = [];
427
+ if (options.status !== void 0) {
428
+ disallowedFlags.push("--status");
429
+ }
430
+ if (options.closeReason !== void 0) {
431
+ disallowedFlags.push("--close-reason");
432
+ }
433
+ if (options.assignee !== void 0) {
434
+ disallowedFlags.push("--assignee");
435
+ }
436
+ if (options.parent !== void 0) {
437
+ disallowedFlags.push("--parent");
438
+ }
439
+ if (options.blockedBy !== void 0) {
440
+ disallowedFlags.push("--blocked-by");
441
+ }
442
+ if (options.blockedReason !== void 0) {
443
+ disallowedFlags.push("--blocked-reason");
444
+ }
445
+ if (options.unblockNote !== void 0) {
446
+ disallowedFlags.push("--unblock-note");
447
+ }
448
+ if (options.dep !== void 0) {
449
+ disallowedFlags.push("--dep");
450
+ }
451
+ if (options.depRemove !== void 0) {
452
+ disallowedFlags.push("--dep-remove");
453
+ }
454
+ if (options.replaceDeps === true) {
455
+ disallowedFlags.push("--replace-deps");
456
+ }
457
+ if (options.replaceTests === true) {
458
+ disallowedFlags.push("--replace-tests");
459
+ }
460
+ if (options.comment !== void 0) {
461
+ disallowedFlags.push("--comment");
462
+ }
463
+ if (options.note !== void 0) {
464
+ disallowedFlags.push("--note");
465
+ }
466
+ if (options.learning !== void 0) {
467
+ disallowedFlags.push("--learning");
468
+ }
469
+ if (options.file !== void 0) {
470
+ disallowedFlags.push("--file");
471
+ }
472
+ if (options.test !== void 0) {
473
+ disallowedFlags.push("--test");
474
+ }
475
+ if (options.doc !== void 0) {
476
+ disallowedFlags.push("--doc");
477
+ }
478
+ if (options.reminder !== void 0) {
479
+ disallowedFlags.push("--reminder");
480
+ }
481
+ if (options.event !== void 0) {
482
+ disallowedFlags.push("--event");
483
+ }
484
+ if (options.clearDeps === true) {
485
+ disallowedFlags.push("--clear-deps");
486
+ }
487
+ if (options.clearComments === true) {
488
+ disallowedFlags.push("--clear-comments");
489
+ }
490
+ if (options.clearNotes === true) {
491
+ disallowedFlags.push("--clear-notes");
492
+ }
493
+ if (options.clearLearnings === true) {
494
+ disallowedFlags.push("--clear-learnings");
495
+ }
496
+ if (options.clearFiles === true) {
497
+ disallowedFlags.push("--clear-files");
498
+ }
499
+ if (options.clearTests === true) {
500
+ disallowedFlags.push("--clear-tests");
501
+ }
502
+ if (options.clearDocs === true) {
503
+ disallowedFlags.push("--clear-docs");
504
+ }
505
+ if (options.clearReminders === true) {
506
+ disallowedFlags.push("--clear-reminders");
507
+ }
508
+ if (options.clearEvents === true) {
509
+ disallowedFlags.push("--clear-events");
510
+ }
511
+ const disallowedUnset = [...clearFrontMatterKeys].filter((field) => AUDIT_UPDATE_DISALLOWED_UNSET_FRONT_MATTER_KEYS.has(field)).sort((left, right) => left.localeCompare(right)).map((field) => `--unset ${field.replaceAll("_", "-")}`);
512
+ disallowedFlags.push(...disallowedUnset);
513
+ if (disallowedFlags.length > 0) {
514
+ throw new PmCliError(`--allow-audit-update only supports non-lifecycle metadata fields. Remove restricted options: ${disallowedFlags.join(", ")}`, EXIT_CODE.USAGE);
515
+ }
516
+ }
517
+ function parseStatus(value, statusRegistry) {
518
+ const normalized = normalizeStatusInput(value, statusRegistry);
519
+ if (!normalized) {
520
+ const allowedStatuses = statusRegistry.definitions.map((definition) => definition.id);
521
+ throw new PmCliError(`Invalid --status value "${value}". Allowed: ${allowedStatuses.join(", ")}`, EXIT_CODE.USAGE);
522
+ }
523
+ return normalized;
524
+ }
525
+ function parseReminderEntries(raw, nowValue) {
526
+ return raw.map((entry) => {
527
+ const kv = parseCsvKv(entry, "--reminder");
528
+ const atRaw = (kv.at ?? kv.date)?.trim();
529
+ const textRaw = (kv.text ?? kv.title)?.trim();
530
+ if (!atRaw || !textRaw) {
531
+ throw new PmCliError("--reminder requires at=<iso|relative> or date=<iso|relative>, plus text=<value> or title=<value>", EXIT_CODE.USAGE);
532
+ }
533
+ return {
534
+ at: resolveIsoOrRelative(atRaw, nowValue, "reminder.at"),
535
+ text: textRaw
536
+ };
537
+ });
538
+ }
539
+ function parseEventEntries(raw, nowValue) {
540
+ return raw.map((entry) => {
541
+ const kv = parseCsvKv(entry, "--event");
542
+ const startRaw = (kv.start ?? kv.date)?.trim();
543
+ if (!startRaw) {
544
+ throw new PmCliError("--event requires start=<iso|relative> or date=<iso|relative>", EXIT_CODE.USAGE);
545
+ }
546
+ const startAt = resolveIsoOrRelative(startRaw, nowValue, "event.start");
547
+ const endRaw = kv.end?.trim();
548
+ const durationRaw = kv.duration?.trim();
549
+ const endAt = resolveEventEndAt(startAt, endRaw, durationRaw, nowValue);
550
+ const titleRaw = kv.title;
551
+ const descriptionRaw = kv.description;
552
+ const locationRaw = kv.location;
553
+ const timezoneRaw = kv.timezone;
554
+ const title = titleRaw?.trim();
555
+ const description = descriptionRaw?.trim();
556
+ const location = locationRaw?.trim();
557
+ const timezone = timezoneRaw?.trim();
558
+ if (titleRaw !== void 0 && !title) {
559
+ throw new PmCliError("--event title must not be empty", EXIT_CODE.USAGE);
560
+ }
561
+ if (descriptionRaw !== void 0 && !description) {
562
+ throw new PmCliError("--event description must not be empty", EXIT_CODE.USAGE);
563
+ }
564
+ if (locationRaw !== void 0 && !location) {
565
+ throw new PmCliError("--event location must not be empty", EXIT_CODE.USAGE);
566
+ }
567
+ if (timezoneRaw !== void 0 && !timezone) {
568
+ throw new PmCliError("--event timezone must not be empty", EXIT_CODE.USAGE);
569
+ }
570
+ const allDayRaw = kv.all_day?.trim();
571
+ const recurrence = parseRecurrenceRule(kv, startAt, nowValue, "truthy");
572
+ return {
573
+ start_at: startAt,
574
+ end_at: endAt,
575
+ title,
576
+ description,
577
+ location,
578
+ all_day: allDayRaw ? parseEventBoolean(allDayRaw, "--event all_day") : void 0,
579
+ timezone,
580
+ recurrence
581
+ };
582
+ });
583
+ }
584
+ function parseTypeOptionEntries(raw) {
585
+ const values = {};
586
+ for (const entry of raw) {
587
+ const trimmedEntry = entry.trim();
588
+ if (trimmedEntry.length === 0) {
589
+ throw new PmCliError("--type-option values must not be empty", EXIT_CODE.USAGE);
590
+ }
591
+ let key;
592
+ let value;
593
+ const prefersStructuredKv = trimmedEntry.includes(",") || trimmedEntry.includes("\n") || trimmedEntry.startsWith("```") || /^(?:[-*+]\s+)?(?:key|value)\s*[:=]/i.test(trimmedEntry);
594
+ if (prefersStructuredKv) {
595
+ const kv = parseCsvKv(trimmedEntry, "--type-option");
596
+ key = kv.key?.trim();
597
+ value = kv.value?.trim();
598
+ } else {
599
+ const equalsIndex = trimmedEntry.indexOf("=");
600
+ const colonIndex = trimmedEntry.indexOf(":");
601
+ let separatorIndex = equalsIndex;
602
+ if (equalsIndex <= 0 && colonIndex > 0) {
603
+ separatorIndex = colonIndex;
604
+ }
605
+ if (separatorIndex <= 0 || separatorIndex === trimmedEntry.length - 1) {
606
+ throw new PmCliError("--type-option requires key=value or key=<name>,value=<value> entries", EXIT_CODE.USAGE);
607
+ }
608
+ key = trimmedEntry.slice(0, separatorIndex).trim();
609
+ value = trimmedEntry.slice(separatorIndex + 1).trim();
610
+ }
611
+ if (!key || !value) {
612
+ throw new PmCliError("--type-option requires key and value", EXIT_CODE.USAGE);
613
+ }
614
+ values[key] = value;
615
+ }
616
+ return Object.fromEntries(Object.entries(values).sort((left, right) => left[0].localeCompare(right[0])));
617
+ }
618
+ function parseDependencyCreatedAt(value, currentIso) {
619
+ if (!value || value.trim() === "" || value.trim().toLowerCase() === "now") {
620
+ return currentIso;
621
+ }
622
+ const parsed = Date.parse(value);
623
+ if (!Number.isFinite(parsed)) {
624
+ throw new PmCliError(`Invalid dependency created_at timestamp "${value}"`, EXIT_CODE.USAGE);
625
+ }
626
+ return new Date(parsed).toISOString();
627
+ }
628
+ function parseOptionalDependencyString(value) {
629
+ if (value === void 0)
630
+ return void 0;
631
+ const trimmed = value.trim();
632
+ return trimmed.length > 0 ? trimmed : void 0;
633
+ }
634
+ function looksLikeStructuredDependencyEntry(raw) {
635
+ if (raw.startsWith("```") || raw.includes("\n")) {
636
+ return true;
637
+ }
638
+ return /^(?:[-*+]\s+)?(?:id|kind|author|created_at|source_kind)\s*[:=]/i.test(raw);
639
+ }
640
+ var DEPENDENCY_KIND_INPUT_ALIASES = {
641
+ depends_on: "blocked_by",
642
+ "depends-on": "blocked_by"
643
+ };
644
+ function normalizeDependencyKindInput(raw) {
645
+ if (typeof raw !== "string") {
646
+ return raw;
647
+ }
648
+ const trimmed = raw.trim();
649
+ const alias = DEPENDENCY_KIND_INPUT_ALIASES[trimmed.toLowerCase()];
650
+ return alias ?? trimmed;
651
+ }
652
+ function parseDependencyAdditions(raw, prefix, nowIso) {
653
+ if (!raw) {
654
+ return { additions: [] };
655
+ }
656
+ assertNoLegacyNoneTokens(raw, "--dep", "Use --clear-deps to clear dependencies.");
657
+ const additions = raw.map((entry) => {
658
+ const trimmedEntry = entry.trim();
659
+ const kv = looksLikeStructuredDependencyEntry(trimmedEntry) ? parseCsvKv(entry, "--dep") : { id: trimmedEntry, kind: "related" };
660
+ const id = kv.id?.trim();
661
+ const kind = normalizeDependencyKindInput(kv.kind?.trim());
662
+ if (!id || !kind) {
663
+ throw new PmCliError("--dep requires id and kind, or a bare item id to add a related dependency", EXIT_CODE.USAGE);
664
+ }
665
+ if (id.toLowerCase() === "undefined") {
666
+ throw new PmCliError(`--dep id must not use placeholder token "${id}". Use --clear-deps to clear dependencies.`, EXIT_CODE.USAGE);
667
+ }
668
+ const sourceKind = parseOptionalDependencyString(kv.source_kind);
669
+ return {
670
+ id: normalizeItemId(id, prefix),
671
+ kind: ensureEnumValue(kind, DEPENDENCY_KIND_VALUES, "dependency kind"),
672
+ created_at: parseDependencyCreatedAt(kv.created_at, nowIso),
673
+ author: parseOptionalDependencyString(kv.author),
674
+ source_kind: sourceKind
675
+ };
676
+ });
677
+ return { additions };
678
+ }
679
+ function parseDependencyRemovals(raw, prefix) {
680
+ if (!raw) {
681
+ return [];
682
+ }
683
+ assertNoLegacyNoneTokens(raw, "--dep-remove");
684
+ return raw.map((entry) => {
685
+ const trimmed = entry.trim();
686
+ if (!trimmed) {
687
+ throw new PmCliError("--dep-remove requires id or key/value selectors", EXIT_CODE.USAGE);
688
+ }
689
+ if (trimmed.includes("=") || /^(?:[-*+]\s+)?(?:id|kind|source_kind)\s*[:=]/i.test(trimmed) || trimmed.startsWith("```")) {
690
+ const kv = parseCsvKv(trimmed, "--dep-remove");
691
+ const idRaw = kv.id?.trim();
692
+ if (!idRaw) {
693
+ throw new PmCliError("--dep-remove key/value form requires id=<value>", EXIT_CODE.USAGE);
694
+ }
695
+ if (idRaw.toLowerCase() === "undefined") {
696
+ throw new PmCliError(`--dep-remove id must not use placeholder token "${idRaw}"`, EXIT_CODE.USAGE);
697
+ }
698
+ const kindRaw = normalizeDependencyKindInput(parseOptionalDependencyString(kv.kind));
699
+ const sourceKind = parseOptionalDependencyString(kv.source_kind);
700
+ return {
701
+ id: normalizeItemId(idRaw, prefix),
702
+ kind: kindRaw ? ensureEnumValue(kindRaw, DEPENDENCY_KIND_VALUES, "dependency kind") : void 0,
703
+ source_kind: sourceKind
704
+ };
705
+ }
706
+ if (trimmed.toLowerCase() === "undefined") {
707
+ throw new PmCliError(`--dep-remove id must not use placeholder token "${trimmed}"`, EXIT_CODE.USAGE);
708
+ }
709
+ return {
710
+ id: normalizeItemId(trimmed, prefix)
711
+ };
712
+ });
713
+ }
714
+ function dependencyKey(value) {
715
+ return `${value.id}::${value.kind}::${value.source_kind ?? ""}`;
716
+ }
717
+ function reconcileBlockedByDependency(current, nextBlockedById, nowIsoValue, author) {
718
+ let next = [...current ?? []];
719
+ let changed = false;
720
+ const filtered = next.filter((dep) => dep.kind !== "blocked_by" || dep.id === nextBlockedById);
721
+ if (filtered.length !== next.length) {
722
+ next = filtered;
723
+ changed = true;
724
+ }
725
+ if (nextBlockedById && !next.some((dep) => dep.kind === "blocked_by" && dep.id === nextBlockedById)) {
726
+ next.push({ id: nextBlockedById, kind: "blocked_by", created_at: nowIsoValue, author });
727
+ changed = true;
728
+ }
729
+ if (!changed) {
730
+ return { dependencies: current, changed: false };
731
+ }
732
+ return { dependencies: next.length > 0 ? next : void 0, changed: true };
733
+ }
734
+ async function resolveBlockedByDependencyTarget(blockedByOption, blockedByCleared, pmRoot, idPrefix, itemFormat, typeToFolder) {
735
+ if (blockedByOption === void 0 || blockedByCleared) {
736
+ return {};
737
+ }
738
+ const blockedByValue = blockedByOption.trim();
739
+ if (blockedByValue.length === 0) {
740
+ return {};
741
+ }
742
+ const located = await locateItem(pmRoot, normalizeItemId(blockedByValue, idPrefix), idPrefix, itemFormat, typeToFolder);
743
+ return located ? { id: located.id } : { unresolved: blockedByValue };
744
+ }
745
+ function applyBlockedByDependencyEdge(metadata, resolvedBlockedById, nowIsoValue, author, changedFields) {
746
+ const reconciled = reconcileBlockedByDependency(metadata.dependencies, resolvedBlockedById, nowIsoValue, author);
747
+ if (!reconciled.changed) {
748
+ return;
749
+ }
750
+ if (reconciled.dependencies === void 0) {
751
+ delete metadata.dependencies;
752
+ } else {
753
+ metadata.dependencies = reconciled.dependencies;
754
+ }
755
+ if (!changedFields.includes("dependencies")) {
756
+ changedFields.push("dependencies");
757
+ }
758
+ }
759
+ function fileKey(value) {
760
+ return `${value.path}::${value.scope}`;
761
+ }
762
+ function docKey(value) {
763
+ return `${value.path}::${value.scope}`;
764
+ }
765
+ function testKey(value) {
766
+ return `${value.command}::${value.path ?? ""}::${value.scope}::${value.pm_context_mode ?? ""}`;
767
+ }
768
+ function matchesDependencySelector(value, selector) {
769
+ if (value.id !== selector.id) {
770
+ return false;
771
+ }
772
+ if (selector.kind && value.kind !== selector.kind) {
773
+ return false;
774
+ }
775
+ if (selector.source_kind !== void 0 && (value.source_kind ?? void 0) !== selector.source_kind) {
776
+ return false;
777
+ }
778
+ return true;
779
+ }
780
+ function ensurePriority(raw) {
781
+ return resolvePriority(raw);
782
+ }
783
+ function normalizeUpdatePolicyOptionKey(raw, typeName) {
784
+ const canonical = canonicalizeCommandOptionKey("update", raw);
785
+ if (!canonical) {
786
+ throw new PmCliError(`Unsupported command_option_policies option "${raw}" for update command on type "${typeName}"`, EXIT_CODE.CONFLICT);
787
+ }
788
+ return canonical;
789
+ }
790
+ function collectProvidedUpdatePolicyOptions(options) {
791
+ const provided = /* @__PURE__ */ new Set();
792
+ const mark = (optionKey, isProvided) => {
793
+ if (isProvided) {
794
+ provided.add(optionKey);
795
+ }
796
+ };
797
+ mark("title", options.title !== void 0);
798
+ mark("description", options.description !== void 0);
799
+ mark("body", options.body !== void 0);
800
+ mark("status", options.status !== void 0);
801
+ mark("closeReason", options.closeReason !== void 0);
802
+ mark("priority", options.priority !== void 0);
803
+ mark("type", options.type !== void 0);
804
+ mark("tags", options.tags !== void 0 || Array.isArray(options.addTags) && options.addTags.length > 0 || Array.isArray(options.removeTags) && options.removeTags.length > 0);
805
+ mark("deadline", options.deadline !== void 0);
806
+ mark("estimatedMinutes", options.estimatedMinutes !== void 0);
807
+ mark("acceptanceCriteria", options.acceptanceCriteria !== void 0);
808
+ mark("definitionOfReady", options.definitionOfReady !== void 0);
809
+ mark("order", options.order !== void 0 || options.rank !== void 0);
810
+ mark("goal", options.goal !== void 0);
811
+ mark("objective", options.objective !== void 0);
812
+ mark("value", options.value !== void 0);
813
+ mark("impact", options.impact !== void 0);
814
+ mark("outcome", options.outcome !== void 0);
815
+ mark("whyNow", options.whyNow !== void 0);
816
+ mark("author", options.author !== void 0);
817
+ mark("message", options.message !== void 0);
818
+ mark("assignee", options.assignee !== void 0);
819
+ mark("parent", options.parent !== void 0);
820
+ mark("reviewer", options.reviewer !== void 0);
821
+ mark("risk", options.risk !== void 0);
822
+ mark("confidence", options.confidence !== void 0);
823
+ mark("sprint", options.sprint !== void 0);
824
+ mark("release", options.release !== void 0);
825
+ mark("blockedBy", options.blockedBy !== void 0);
826
+ mark("blockedReason", options.blockedReason !== void 0);
827
+ mark("unblockNote", options.unblockNote !== void 0);
828
+ mark("reporter", options.reporter !== void 0);
829
+ mark("severity", options.severity !== void 0);
830
+ mark("environment", options.environment !== void 0);
831
+ mark("reproSteps", options.reproSteps !== void 0);
832
+ mark("resolution", options.resolution !== void 0);
833
+ mark("expectedResult", options.expectedResult !== void 0);
834
+ mark("actualResult", options.actualResult !== void 0);
835
+ mark("affectedVersion", options.affectedVersion !== void 0);
836
+ mark("fixedVersion", options.fixedVersion !== void 0);
837
+ mark("component", options.component !== void 0);
838
+ mark("regression", options.regression !== void 0);
839
+ mark("customerImpact", options.customerImpact !== void 0);
840
+ mark("dep", options.dep !== void 0);
841
+ mark("depRemove", options.depRemove !== void 0);
842
+ mark("dep", options.replaceDeps === true);
843
+ mark("comment", options.comment !== void 0);
844
+ mark("note", options.note !== void 0);
845
+ mark("learning", options.learning !== void 0);
846
+ mark("file", options.file !== void 0);
847
+ mark("test", options.test !== void 0);
848
+ mark("test", options.replaceTests === true);
849
+ mark("doc", options.doc !== void 0);
850
+ mark("reminder", options.reminder !== void 0);
851
+ mark("event", options.event !== void 0);
852
+ mark("typeOption", options.typeOption !== void 0);
853
+ mark("force", options.force === true);
854
+ mark("allowAuditUpdate", options.allowAuditUpdate === true);
855
+ mark("dep", options.clearDeps === true);
856
+ mark("comment", options.clearComments === true);
857
+ mark("note", options.clearNotes === true);
858
+ mark("learning", options.clearLearnings === true);
859
+ mark("file", options.clearFiles === true);
860
+ mark("test", options.clearTests === true);
861
+ mark("doc", options.clearDocs === true);
862
+ mark("reminder", options.clearReminders === true);
863
+ mark("event", options.clearEvents === true);
864
+ mark("typeOption", options.clearTypeOptions === true);
865
+ if (options.unset && options.unset.length > 0) {
866
+ const unsetTargets = parseUpdateUnsetTargets(options.unset);
867
+ for (const optionKey of unsetTargets.optionKeys) {
868
+ mark(optionKey, true);
869
+ }
870
+ }
871
+ return provided;
872
+ }
873
+ function enforceUpdateOptionsByType(typeName, options, typeRegistry) {
874
+ const typeDefinition = resolveTypeDefinition(typeName, typeRegistry);
875
+ if (!typeDefinition) {
876
+ throw new PmCliError(`Invalid type value "${typeName}"`, EXIT_CODE.USAGE);
877
+ }
878
+ const policyState = resolveCommandOptionPolicyState(typeDefinition, "update", []);
879
+ if (policyState.errors.length > 0) {
880
+ throw new PmCliError(policyState.errors.join("; "), EXIT_CODE.CONFLICT);
881
+ }
882
+ const provided = collectProvidedUpdatePolicyOptions(options);
883
+ for (const disabled of policyState.disabled) {
884
+ if (provided.has(normalizeUpdatePolicyOptionKey(disabled, typeName))) {
885
+ throw new PmCliError(`Option ${commandOptionFlagLabel("update", disabled)} is disabled for type "${typeName}" by command_option_policies`, EXIT_CODE.USAGE);
886
+ }
887
+ }
888
+ for (const required of policyState.required) {
889
+ if (!provided.has(normalizeUpdatePolicyOptionKey(required, typeName))) {
890
+ throw new PmCliError(`Missing required option ${commandOptionFlagLabel("update", required)} for type "${typeName}"`, EXIT_CODE.USAGE);
891
+ }
892
+ }
893
+ }
894
+ async function runUpdate(id, options, global2) {
895
+ const stdinResolver = createStdinTokenResolver();
896
+ options = normalizeLegacyNoneUpdateOptions({
897
+ ...options,
898
+ body: await stdinResolver.resolveValue(options.body, "--body"),
899
+ dep: await stdinResolver.resolveList(options.dep, "--dep"),
900
+ depRemove: await stdinResolver.resolveList(options.depRemove, "--dep-remove"),
901
+ comment: await stdinResolver.resolveList(options.comment, "--comment"),
902
+ note: await stdinResolver.resolveList(options.note, "--note"),
903
+ learning: await stdinResolver.resolveList(options.learning, "--learning"),
904
+ file: await stdinResolver.resolveList(options.file, "--file"),
905
+ test: await stdinResolver.resolveList(options.test, "--test"),
906
+ doc: await stdinResolver.resolveList(options.doc, "--doc"),
907
+ reminder: await stdinResolver.resolveList(options.reminder, "--reminder"),
908
+ event: await stdinResolver.resolveList(options.event, "--event"),
909
+ typeOption: await stdinResolver.resolveList(options.typeOption, "--type-option")
910
+ });
911
+ const pmRoot = resolvePmRoot(process.cwd(), global2.path);
912
+ if (!await pathExists(getSettingsPath(pmRoot))) {
913
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
914
+ }
915
+ const settings = await readSettings(pmRoot);
916
+ const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
917
+ const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
918
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
919
+ const parentReferencePolicy = settings.validation.parent_reference;
920
+ const sprintReleasePolicy = settings.validation.sprint_release_format;
921
+ const unsetTargets = parseUpdateUnsetTargets(options.unset, runtimeFieldRegistry);
922
+ const clearOptionKeys = new Set(unsetTargets.optionKeys);
923
+ const clearFrontMatterKeys = new Set(unsetTargets.frontMatterKeys);
924
+ const clearCollectionDefinitions = [
925
+ {
926
+ enabled: options.clearDeps || options.replaceDeps,
927
+ optionKey: "dep",
928
+ clearFlag: "--clear-deps",
929
+ valueFlag: "--dep",
930
+ values: options.dep,
931
+ frontMatterKey: "dependencies"
932
+ },
933
+ {
934
+ enabled: options.clearComments,
935
+ optionKey: "comment",
936
+ clearFlag: "--clear-comments",
937
+ valueFlag: "--comment",
938
+ values: options.comment,
939
+ frontMatterKey: "comments"
940
+ },
941
+ {
942
+ enabled: options.clearNotes,
943
+ optionKey: "note",
944
+ clearFlag: "--clear-notes",
945
+ valueFlag: "--note",
946
+ values: options.note,
947
+ frontMatterKey: "notes"
948
+ },
949
+ {
950
+ enabled: options.clearLearnings,
951
+ optionKey: "learning",
952
+ clearFlag: "--clear-learnings",
953
+ valueFlag: "--learning",
954
+ values: options.learning,
955
+ frontMatterKey: "learnings"
956
+ },
957
+ {
958
+ enabled: options.clearFiles,
959
+ optionKey: "file",
960
+ clearFlag: "--clear-files",
961
+ valueFlag: "--file",
962
+ values: options.file,
963
+ frontMatterKey: "files"
964
+ },
965
+ {
966
+ enabled: options.clearTests || options.replaceTests,
967
+ optionKey: "test",
968
+ clearFlag: "--clear-tests",
969
+ valueFlag: "--test",
970
+ values: options.test,
971
+ frontMatterKey: "tests"
972
+ },
973
+ {
974
+ enabled: options.clearDocs,
975
+ optionKey: "doc",
976
+ clearFlag: "--clear-docs",
977
+ valueFlag: "--doc",
978
+ values: options.doc,
979
+ frontMatterKey: "docs"
980
+ },
981
+ {
982
+ enabled: options.clearReminders,
983
+ optionKey: "reminder",
984
+ clearFlag: "--clear-reminders",
985
+ valueFlag: "--reminder",
986
+ values: options.reminder,
987
+ frontMatterKey: "reminders"
988
+ },
989
+ {
990
+ enabled: options.clearEvents,
991
+ optionKey: "event",
992
+ clearFlag: "--clear-events",
993
+ valueFlag: "--event",
994
+ values: options.event,
995
+ frontMatterKey: "events"
996
+ },
997
+ {
998
+ enabled: options.clearTypeOptions,
999
+ optionKey: "typeOption",
1000
+ clearFlag: "--clear-type-options",
1001
+ valueFlag: "--type-option",
1002
+ values: options.typeOption,
1003
+ frontMatterKey: "type_options"
1004
+ }
1005
+ ];
1006
+ if (options.replaceDeps === true && (options.dep === void 0 || options.dep.length === 0)) {
1007
+ throw new PmCliError("--replace-deps requires at least one --dep entry", EXIT_CODE.USAGE);
1008
+ }
1009
+ if (options.replaceDeps === true && options.depRemove !== void 0 && options.depRemove.length > 0) {
1010
+ throw new PmCliError("--replace-deps cannot be combined with --dep-remove", EXIT_CODE.USAGE);
1011
+ }
1012
+ if (options.replaceTests === true && (options.test === void 0 || options.test.length === 0)) {
1013
+ throw new PmCliError("--replace-tests requires at least one --test entry", EXIT_CODE.USAGE);
1014
+ }
1015
+ if (options.replaceTests === true && options.clearTests === true) {
1016
+ throw new PmCliError("--replace-tests cannot be combined with --clear-tests", EXIT_CODE.USAGE);
1017
+ }
1018
+ for (const definition of clearCollectionDefinitions) {
1019
+ if (!definition.enabled) {
1020
+ continue;
1021
+ }
1022
+ if (definition.values && definition.values.length > 0 && !(definition.optionKey === "dep" && options.replaceDeps === true || definition.optionKey === "test" && options.replaceTests === true)) {
1023
+ throw new PmCliError(`Cannot combine ${definition.clearFlag} with ${definition.valueFlag}`, EXIT_CODE.USAGE);
1024
+ }
1025
+ clearOptionKeys.add(definition.optionKey);
1026
+ clearFrontMatterKeys.add(definition.frontMatterKey);
1027
+ }
1028
+ enforceAllowAuditUpdateScope(options, clearFrontMatterKeys);
1029
+ const scalarOptionPresence = {
1030
+ tags: options.tags !== void 0,
1031
+ closeReason: options.closeReason !== void 0,
1032
+ deadline: options.deadline !== void 0,
1033
+ estimatedMinutes: options.estimatedMinutes !== void 0,
1034
+ acceptanceCriteria: options.acceptanceCriteria !== void 0,
1035
+ definitionOfReady: options.definitionOfReady !== void 0,
1036
+ order: options.order !== void 0 || options.rank !== void 0,
1037
+ goal: options.goal !== void 0,
1038
+ objective: options.objective !== void 0,
1039
+ value: options.value !== void 0,
1040
+ impact: options.impact !== void 0,
1041
+ outcome: options.outcome !== void 0,
1042
+ whyNow: options.whyNow !== void 0,
1043
+ assignee: options.assignee !== void 0,
1044
+ parent: options.parent !== void 0,
1045
+ reviewer: options.reviewer !== void 0,
1046
+ risk: options.risk !== void 0,
1047
+ confidence: options.confidence !== void 0,
1048
+ sprint: options.sprint !== void 0,
1049
+ release: options.release !== void 0,
1050
+ blockedBy: options.blockedBy !== void 0,
1051
+ blockedReason: options.blockedReason !== void 0,
1052
+ unblockNote: options.unblockNote !== void 0,
1053
+ reporter: options.reporter !== void 0,
1054
+ severity: options.severity !== void 0,
1055
+ environment: options.environment !== void 0,
1056
+ reproSteps: options.reproSteps !== void 0,
1057
+ resolution: options.resolution !== void 0,
1058
+ expectedResult: options.expectedResult !== void 0,
1059
+ actualResult: options.actualResult !== void 0,
1060
+ affectedVersion: options.affectedVersion !== void 0,
1061
+ fixedVersion: options.fixedVersion !== void 0,
1062
+ component: options.component !== void 0,
1063
+ regression: options.regression !== void 0,
1064
+ customerImpact: options.customerImpact !== void 0
1065
+ };
1066
+ for (const [optionKey, hasValue] of Object.entries(scalarOptionPresence)) {
1067
+ if (!hasValue || !unsetTargets.optionKeys.has(optionKey)) {
1068
+ continue;
1069
+ }
1070
+ const unsetField = UPDATE_OPTION_KEY_TO_UNSET_CANONICAL.get(optionKey) ?? optionKey;
1071
+ throw new PmCliError(`Cannot combine --unset ${unsetField} with ${commandOptionFlagLabel("update", optionKey)}`, EXIT_CODE.USAGE);
1072
+ }
1073
+ if (clearFrontMatterKeys.has("tags")) {
1074
+ if (Array.isArray(options.addTags) && options.addTags.length > 0) {
1075
+ throw new PmCliError("Cannot combine --unset tags with --add-tags", EXIT_CODE.USAGE);
1076
+ }
1077
+ if (Array.isArray(options.removeTags) && options.removeTags.length > 0) {
1078
+ throw new PmCliError("Cannot combine --unset tags with --remove-tags", EXIT_CODE.USAGE);
1079
+ }
1080
+ }
1081
+ const assertNoLegacyScalarToken = (value, optionKey) => {
1082
+ const unsetField = UPDATE_OPTION_KEY_TO_UNSET_CANONICAL.get(optionKey);
1083
+ const hint = unsetField ? `Use --unset ${unsetField} to clear this field.` : void 0;
1084
+ assertNoLegacyNoneToken(value, commandOptionFlagLabel("update", optionKey), hint);
1085
+ };
1086
+ assertNoLegacyScalarToken(options.tags, "tags");
1087
+ assertNoLegacyScalarToken(options.closeReason, "closeReason");
1088
+ assertNoLegacyScalarToken(options.deadline, "deadline");
1089
+ assertNoLegacyScalarToken(options.estimatedMinutes, "estimatedMinutes");
1090
+ assertNoLegacyScalarToken(options.acceptanceCriteria, "acceptanceCriteria");
1091
+ assertNoLegacyScalarToken(options.definitionOfReady, "definitionOfReady");
1092
+ assertNoLegacyScalarToken(options.order ?? options.rank, "order");
1093
+ assertNoLegacyScalarToken(options.goal, "goal");
1094
+ assertNoLegacyScalarToken(options.objective, "objective");
1095
+ assertNoLegacyScalarToken(options.value, "value");
1096
+ assertNoLegacyScalarToken(options.impact, "impact");
1097
+ assertNoLegacyScalarToken(options.outcome, "outcome");
1098
+ assertNoLegacyScalarToken(options.whyNow, "whyNow");
1099
+ assertNoLegacyScalarToken(options.assignee, "assignee");
1100
+ assertNoLegacyScalarToken(options.parent, "parent");
1101
+ assertNoLegacyScalarToken(options.reviewer, "reviewer");
1102
+ assertNoLegacyScalarToken(options.risk, "risk");
1103
+ assertNoLegacyScalarToken(options.confidence, "confidence");
1104
+ assertNoLegacyScalarToken(options.sprint, "sprint");
1105
+ assertNoLegacyScalarToken(options.release, "release");
1106
+ assertNoLegacyScalarToken(options.blockedBy, "blockedBy");
1107
+ assertNoLegacyScalarToken(options.blockedReason, "blockedReason");
1108
+ assertNoLegacyScalarToken(options.unblockNote, "unblockNote");
1109
+ assertNoLegacyScalarToken(options.reporter, "reporter");
1110
+ assertNoLegacyScalarToken(options.severity, "severity");
1111
+ assertNoLegacyScalarToken(options.environment, "environment");
1112
+ assertNoLegacyScalarToken(options.reproSteps, "reproSteps");
1113
+ assertNoLegacyScalarToken(options.resolution, "resolution");
1114
+ assertNoLegacyScalarToken(options.expectedResult, "expectedResult");
1115
+ assertNoLegacyScalarToken(options.actualResult, "actualResult");
1116
+ assertNoLegacyScalarToken(options.affectedVersion, "affectedVersion");
1117
+ assertNoLegacyScalarToken(options.fixedVersion, "fixedVersion");
1118
+ assertNoLegacyScalarToken(options.component, "component");
1119
+ assertNoLegacyScalarToken(options.regression, "regression");
1120
+ assertNoLegacyScalarToken(options.customerImpact, "customerImpact");
1121
+ assertNoLegacyNoneTokens(options.reminder, "--reminder", "Use --clear-reminders to clear reminders.");
1122
+ assertNoLegacyNoneTokens(options.event, "--event", "Use --clear-events to clear linked events.");
1123
+ const author = toAuthor(options.author, settings.author_default);
1124
+ const nowValue = /* @__PURE__ */ new Date();
1125
+ const nowIso = nowValue.toISOString();
1126
+ const dependencyUpdates = parseDependencyAdditions(options.dep, settings.id_prefix, nowIso);
1127
+ const dependencyRemovals = parseDependencyRemovals(options.depRemove, settings.id_prefix);
1128
+ const commentUpdates = parseLogSeed("--comment", options.comment, nowIso, author);
1129
+ const noteUpdates = parseLogSeed("--note", options.note, nowIso, author);
1130
+ const learningUpdates = parseLogSeed("--learning", options.learning, nowIso, author);
1131
+ const fileUpdates = parseFiles(options.file);
1132
+ const testUpdates = parseTests(options.test);
1133
+ const docUpdates = parseDocs(options.doc);
1134
+ const parentReferenceWarnings = [];
1135
+ let resolvedParentValue;
1136
+ if (options.parent !== void 0 && !unsetTargets.frontMatterKeys.has("parent")) {
1137
+ resolvedParentValue = normalizeParentReferenceValue(options.parent);
1138
+ const parentLocated = await locateItem(pmRoot, resolvedParentValue, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1139
+ if (!parentLocated) {
1140
+ const normalizedParentId = normalizeItemId(resolvedParentValue, settings.id_prefix);
1141
+ parentReferenceWarnings.push(...validateMissingParentReference(normalizedParentId, parentReferencePolicy).warnings);
1142
+ }
1143
+ }
1144
+ const blockedByResolution = await resolveBlockedByDependencyTarget(options.blockedBy, clearFrontMatterKeys.has("blocked_by"), pmRoot, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1145
+ const resolvedBlockedByDependencyId = blockedByResolution.id;
1146
+ if (blockedByResolution.unresolved !== void 0) {
1147
+ parentReferenceWarnings.push(`blocked_by_unresolved:${blockedByResolution.unresolved}`);
1148
+ }
1149
+ const fieldFlags = {
1150
+ title: options.title !== void 0,
1151
+ description: options.description !== void 0,
1152
+ body: options.body !== void 0,
1153
+ status: options.status !== void 0,
1154
+ closeReason: options.closeReason !== void 0,
1155
+ priority: options.priority !== void 0,
1156
+ type: options.type !== void 0,
1157
+ tags: options.tags !== void 0,
1158
+ addTags: Array.isArray(options.addTags) && options.addTags.length > 0,
1159
+ removeTags: Array.isArray(options.removeTags) && options.removeTags.length > 0,
1160
+ deadline: options.deadline !== void 0,
1161
+ estimatedMinutes: options.estimatedMinutes !== void 0,
1162
+ acceptanceCriteria: options.acceptanceCriteria !== void 0,
1163
+ definitionOfReady: options.definitionOfReady !== void 0,
1164
+ order: options.order !== void 0,
1165
+ rank: options.rank !== void 0,
1166
+ goal: options.goal !== void 0,
1167
+ objective: options.objective !== void 0,
1168
+ value: options.value !== void 0,
1169
+ impact: options.impact !== void 0,
1170
+ outcome: options.outcome !== void 0,
1171
+ whyNow: options.whyNow !== void 0,
1172
+ assignee: options.assignee !== void 0,
1173
+ parent: options.parent !== void 0,
1174
+ reviewer: options.reviewer !== void 0,
1175
+ risk: options.risk !== void 0,
1176
+ confidence: options.confidence !== void 0,
1177
+ sprint: options.sprint !== void 0,
1178
+ release: options.release !== void 0,
1179
+ blockedBy: options.blockedBy !== void 0,
1180
+ blockedReason: options.blockedReason !== void 0,
1181
+ unblockNote: options.unblockNote !== void 0,
1182
+ reporter: options.reporter !== void 0,
1183
+ severity: options.severity !== void 0,
1184
+ environment: options.environment !== void 0,
1185
+ reproSteps: options.reproSteps !== void 0,
1186
+ resolution: options.resolution !== void 0,
1187
+ expectedResult: options.expectedResult !== void 0,
1188
+ actualResult: options.actualResult !== void 0,
1189
+ affectedVersion: options.affectedVersion !== void 0,
1190
+ fixedVersion: options.fixedVersion !== void 0,
1191
+ component: options.component !== void 0,
1192
+ regression: options.regression !== void 0,
1193
+ customerImpact: options.customerImpact !== void 0,
1194
+ dep: options.dep !== void 0,
1195
+ depRemove: options.depRemove !== void 0,
1196
+ replaceDeps: options.replaceDeps === true,
1197
+ comment: options.comment !== void 0,
1198
+ note: options.note !== void 0,
1199
+ learning: options.learning !== void 0,
1200
+ file: options.file !== void 0,
1201
+ test: options.test !== void 0,
1202
+ replaceTests: options.replaceTests === true,
1203
+ doc: options.doc !== void 0,
1204
+ reminder: options.reminder !== void 0,
1205
+ event: options.event !== void 0,
1206
+ typeOption: options.typeOption !== void 0,
1207
+ unset: options.unset !== void 0 && options.unset.length > 0,
1208
+ clearDeps: options.clearDeps === true,
1209
+ clearComments: options.clearComments === true,
1210
+ clearNotes: options.clearNotes === true,
1211
+ clearLearnings: options.clearLearnings === true,
1212
+ clearFiles: options.clearFiles === true,
1213
+ clearTests: options.clearTests === true,
1214
+ clearDocs: options.clearDocs === true,
1215
+ clearReminders: options.clearReminders === true,
1216
+ clearEvents: options.clearEvents === true,
1217
+ clearTypeOptions: options.clearTypeOptions === true
1218
+ };
1219
+ const changedFlags = Object.values(fieldFlags).some(Boolean);
1220
+ if (!changedFlags) {
1221
+ const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
1222
+ if (!located) {
1223
+ throw await buildItemNotFoundError(pmRoot, id, settings.id_prefix, typeRegistry.type_to_folder);
1224
+ }
1225
+ const { document } = await readLocatedItem(located, { schema: settings.schema });
1226
+ return {
1227
+ item: toItemRecord(document.metadata),
1228
+ changed_fields: [],
1229
+ warnings: ["noop_no_update_fields"]
1230
+ };
1231
+ }
1232
+ if (fieldFlags.status) {
1233
+ const targetStatus = normalizeStatusInput(options.status, statusRegistry);
1234
+ if (targetStatus === statusRegistry.close_status) {
1235
+ const otherFieldKeys = Object.entries(fieldFlags).filter(([key, value]) => value && key !== "status" && key !== "closeReason").map(([key]) => key);
1236
+ const routeWarnings = [];
1237
+ let preChangedFields = [];
1238
+ if (otherFieldKeys.length > 0) {
1239
+ const preUpdate = await runUpdate(id, { ...options, status: void 0, closeReason: void 0, message: void 0 }, global2);
1240
+ preChangedFields = preUpdate.changed_fields;
1241
+ routeWarnings.push(...preUpdate.warnings);
1242
+ }
1243
+ const explicitReason = typeof options.closeReason === "string" ? options.closeReason.trim() : "";
1244
+ const fallbackMessage = typeof options.message === "string" ? options.message.trim() : "";
1245
+ const closeReason = explicitReason || fallbackMessage || "Closed via pm update";
1246
+ const reasonDefaulted = explicitReason.length === 0 && fallbackMessage.length === 0;
1247
+ const closeResult = await runClose(id, closeReason, {
1248
+ author: options.author,
1249
+ message: options.message,
1250
+ force: options.force
1251
+ }, global2);
1252
+ const warnings = [...routeWarnings, ...closeResult.warnings, "auto_routed_from_update_to_close"];
1253
+ if (reasonDefaulted) {
1254
+ warnings.push("close_reason_defaulted");
1255
+ }
1256
+ return {
1257
+ item: closeResult.item,
1258
+ changed_fields: [...preChangedFields, ...closeResult.changed_fields],
1259
+ warnings
1260
+ };
1261
+ }
1262
+ }
1263
+ if (options.order !== void 0 && options.rank !== void 0 && options.order !== options.rank) {
1264
+ throw new PmCliError("--order and --rank must match when both are provided", EXIT_CODE.USAGE);
1265
+ }
1266
+ const result = await mutateItem({
1267
+ pmRoot,
1268
+ settings,
1269
+ typeToFolder: typeRegistry.type_to_folder,
1270
+ id,
1271
+ op: options.allowAuditUpdate === true || options.allowAuditDepUpdate === true ? "update_audit" : "update",
1272
+ author,
1273
+ message: options.message,
1274
+ force: options.force,
1275
+ bypassAssigneeConflict: options.allowAuditUpdate === true || options.allowAuditDepUpdate === true,
1276
+ mutate(document) {
1277
+ const changedFields = [];
1278
+ const warnings = [];
1279
+ let activeTypeName = resolveTypeName(document.metadata.type, typeRegistry) ?? document.metadata.type;
1280
+ const metadataRecord = toItemRecord(document.metadata);
1281
+ const setOrClearScalar = (optionValue, metadataKey, transform) => {
1282
+ if (optionValue === void 0 && !clearFrontMatterKeys.has(metadataKey)) {
1283
+ return;
1284
+ }
1285
+ if (clearFrontMatterKeys.has(metadataKey)) {
1286
+ delete metadataRecord[metadataKey];
1287
+ } else {
1288
+ metadataRecord[metadataKey] = transform(optionValue);
1289
+ }
1290
+ changedFields.push(metadataKey);
1291
+ };
1292
+ const setOrClearTrimScalar = (optionValue, metadataKey) => {
1293
+ setOrClearScalar(optionValue, metadataKey, (value) => value.trim());
1294
+ };
1295
+ if (options.title !== void 0) {
1296
+ document.metadata.title = options.title;
1297
+ changedFields.push("title");
1298
+ }
1299
+ if (options.description !== void 0) {
1300
+ document.metadata.description = options.description;
1301
+ changedFields.push("description");
1302
+ }
1303
+ if (options.body !== void 0) {
1304
+ document.body = options.body;
1305
+ changedFields.push("body");
1306
+ }
1307
+ const previousStatus = document.metadata.status;
1308
+ const previousStatusNormalized = normalizeStatusInput(previousStatus, statusRegistry) ?? previousStatus;
1309
+ if (options.status !== void 0) {
1310
+ const status = parseStatus(options.status, statusRegistry);
1311
+ document.metadata.status = status;
1312
+ if (status === statusRegistry.canceled_status) {
1313
+ delete document.metadata.assignee;
1314
+ }
1315
+ changedFields.push("status");
1316
+ }
1317
+ if (options.closeReason !== void 0 || clearFrontMatterKeys.has("close_reason")) {
1318
+ if (clearFrontMatterKeys.has("close_reason")) {
1319
+ delete document.metadata.close_reason;
1320
+ } else {
1321
+ const closeReason = options.closeReason.trim();
1322
+ if (closeReason.length === 0) {
1323
+ throw new PmCliError("--close-reason must not be empty", EXIT_CODE.USAGE);
1324
+ }
1325
+ document.metadata.close_reason = closeReason;
1326
+ }
1327
+ changedFields.push("close_reason");
1328
+ } else if (options.status !== void 0 && previousStatusNormalized === statusRegistry.close_status && document.metadata.status !== statusRegistry.canceled_status && document.metadata.close_reason !== void 0) {
1329
+ delete document.metadata.close_reason;
1330
+ changedFields.push("close_reason");
1331
+ }
1332
+ if (options.priority !== void 0) {
1333
+ document.metadata.priority = ensurePriority(options.priority);
1334
+ changedFields.push("priority");
1335
+ }
1336
+ if (options.type !== void 0) {
1337
+ const resolvedTypeName = resolveTypeName(options.type, typeRegistry);
1338
+ if (!resolvedTypeName) {
1339
+ throw new PmCliError(buildInvalidTypeError(options.type, typeRegistry.types), EXIT_CODE.USAGE);
1340
+ }
1341
+ document.metadata.type = resolvedTypeName;
1342
+ activeTypeName = resolvedTypeName;
1343
+ changedFields.push("type");
1344
+ }
1345
+ enforceUpdateOptionsByType(activeTypeName, options, typeRegistry);
1346
+ if (options.typeOption !== void 0 || clearFrontMatterKeys.has("type_options")) {
1347
+ if (clearFrontMatterKeys.has("type_options")) {
1348
+ delete document.metadata.type_options;
1349
+ } else {
1350
+ const parsedTypeOptions = parseTypeOptionEntries(options.typeOption);
1351
+ const validation = validateTypeOptions(activeTypeName, parsedTypeOptions, typeRegistry);
1352
+ if (validation.errors.length > 0) {
1353
+ throw new PmCliError(validation.errors.join("; "), EXIT_CODE.USAGE);
1354
+ }
1355
+ document.metadata.type_options = validation.normalized;
1356
+ }
1357
+ changedFields.push("type_options");
1358
+ } else if (options.type !== void 0 && document.metadata.type_options !== void 0) {
1359
+ const validation = validateTypeOptions(activeTypeName, document.metadata.type_options, typeRegistry);
1360
+ if (validation.errors.length > 0) {
1361
+ throw new PmCliError(`Current type options are incompatible with type "${activeTypeName}". ${validation.errors.join("; ")}. Use --clear-type-options to clear them.`, EXIT_CODE.USAGE);
1362
+ }
1363
+ document.metadata.type_options = validation.normalized;
1364
+ }
1365
+ if (options.dep !== void 0 || options.depRemove !== void 0 || clearFrontMatterKeys.has("dependencies")) {
1366
+ let nextDependencies = clearFrontMatterKeys.has("dependencies") ? [] : [...document.metadata.dependencies ?? []];
1367
+ if (dependencyUpdates.additions.length > 0) {
1368
+ const seen = new Set(nextDependencies.map((entry) => dependencyKey(entry)));
1369
+ for (const addition of dependencyUpdates.additions) {
1370
+ const key = dependencyKey(addition);
1371
+ if (seen.has(key)) {
1372
+ continue;
1373
+ }
1374
+ nextDependencies.push(addition);
1375
+ seen.add(key);
1376
+ }
1377
+ }
1378
+ if (dependencyRemovals.length > 0) {
1379
+ nextDependencies = nextDependencies.filter((entry) => !dependencyRemovals.some((selector) => matchesDependencySelector(entry, selector)));
1380
+ }
1381
+ if (nextDependencies.length === 0) {
1382
+ delete document.metadata.dependencies;
1383
+ } else {
1384
+ document.metadata.dependencies = nextDependencies;
1385
+ }
1386
+ changedFields.push("dependencies");
1387
+ }
1388
+ if (options.comment !== void 0 || clearFrontMatterKeys.has("comments")) {
1389
+ if (clearFrontMatterKeys.has("comments") || !commentUpdates.values || commentUpdates.values.length === 0) {
1390
+ delete document.metadata.comments;
1391
+ } else {
1392
+ document.metadata.comments = [...document.metadata.comments ?? [], ...commentUpdates.values];
1393
+ }
1394
+ changedFields.push("comments");
1395
+ }
1396
+ if (options.note !== void 0 || clearFrontMatterKeys.has("notes")) {
1397
+ if (clearFrontMatterKeys.has("notes") || !noteUpdates.values || noteUpdates.values.length === 0) {
1398
+ delete document.metadata.notes;
1399
+ } else {
1400
+ document.metadata.notes = [...document.metadata.notes ?? [], ...noteUpdates.values];
1401
+ }
1402
+ changedFields.push("notes");
1403
+ }
1404
+ if (options.learning !== void 0 || clearFrontMatterKeys.has("learnings")) {
1405
+ if (clearFrontMatterKeys.has("learnings") || !learningUpdates.values || learningUpdates.values.length === 0) {
1406
+ delete document.metadata.learnings;
1407
+ } else {
1408
+ document.metadata.learnings = [...document.metadata.learnings ?? [], ...learningUpdates.values];
1409
+ }
1410
+ changedFields.push("learnings");
1411
+ }
1412
+ if (options.file !== void 0 || clearFrontMatterKeys.has("files")) {
1413
+ if (clearFrontMatterKeys.has("files") || !fileUpdates.values || fileUpdates.values.length === 0) {
1414
+ delete document.metadata.files;
1415
+ } else {
1416
+ const nextFiles = [...document.metadata.files ?? []];
1417
+ const seen = new Set(nextFiles.map((entry) => fileKey(entry)));
1418
+ for (const entry of fileUpdates.values) {
1419
+ const key = fileKey(entry);
1420
+ if (seen.has(key)) {
1421
+ continue;
1422
+ }
1423
+ nextFiles.push(entry);
1424
+ seen.add(key);
1425
+ }
1426
+ document.metadata.files = nextFiles;
1427
+ }
1428
+ changedFields.push("files");
1429
+ }
1430
+ if (options.test !== void 0 || clearFrontMatterKeys.has("tests")) {
1431
+ if (clearFrontMatterKeys.has("tests") && options.replaceTests === true) {
1432
+ if (!testUpdates.values || testUpdates.values.length === 0) {
1433
+ delete document.metadata.tests;
1434
+ } else {
1435
+ const replacementTests = [];
1436
+ const seen = /* @__PURE__ */ new Set();
1437
+ for (const entry of testUpdates.values) {
1438
+ const key = testKey(entry);
1439
+ if (seen.has(key)) {
1440
+ continue;
1441
+ }
1442
+ replacementTests.push(entry);
1443
+ seen.add(key);
1444
+ }
1445
+ document.metadata.tests = replacementTests;
1446
+ }
1447
+ } else if (clearFrontMatterKeys.has("tests") || !testUpdates.values || testUpdates.values.length === 0) {
1448
+ delete document.metadata.tests;
1449
+ } else {
1450
+ const nextTests = [...document.metadata.tests ?? []];
1451
+ const seen = new Set(nextTests.map((entry) => testKey(entry)));
1452
+ for (const entry of testUpdates.values) {
1453
+ const key = testKey(entry);
1454
+ if (seen.has(key)) {
1455
+ continue;
1456
+ }
1457
+ nextTests.push(entry);
1458
+ seen.add(key);
1459
+ }
1460
+ document.metadata.tests = nextTests;
1461
+ }
1462
+ changedFields.push("tests");
1463
+ }
1464
+ if (options.doc !== void 0 || clearFrontMatterKeys.has("docs")) {
1465
+ if (clearFrontMatterKeys.has("docs") || !docUpdates.values || docUpdates.values.length === 0) {
1466
+ delete document.metadata.docs;
1467
+ } else {
1468
+ const nextDocs = [...document.metadata.docs ?? []];
1469
+ const seen = new Set(nextDocs.map((entry) => docKey(entry)));
1470
+ for (const entry of docUpdates.values) {
1471
+ const key = docKey(entry);
1472
+ if (seen.has(key)) {
1473
+ continue;
1474
+ }
1475
+ nextDocs.push(entry);
1476
+ seen.add(key);
1477
+ }
1478
+ document.metadata.docs = nextDocs;
1479
+ }
1480
+ changedFields.push("docs");
1481
+ }
1482
+ const addTagsValues = options.addTags;
1483
+ const removeTagsValues = options.removeTags;
1484
+ const hasAdditiveTagMutation = Array.isArray(addTagsValues) && addTagsValues.length > 0 || Array.isArray(removeTagsValues) && removeTagsValues.length > 0;
1485
+ if (options.tags !== void 0 || clearFrontMatterKeys.has("tags") || hasAdditiveTagMutation) {
1486
+ const baseTags = clearFrontMatterKeys.has("tags") ? [] : options.tags !== void 0 ? parseTags(options.tags) : Array.isArray(document.metadata.tags) ? [...document.metadata.tags] : [];
1487
+ const withAdditions = mergeAdditiveTags(baseTags, addTagsValues);
1488
+ const finalTags = applyTagRemovals(withAdditions, removeTagsValues);
1489
+ document.metadata.tags = finalTags;
1490
+ changedFields.push("tags");
1491
+ }
1492
+ setOrClearScalar(options.deadline, "deadline", (value) => resolveIsoOrRelative(value, nowValue, "deadline"));
1493
+ setOrClearScalar(options.estimatedMinutes, "estimated_minutes", (value) => parseOptionalNumber(value, "estimated-minutes"));
1494
+ setOrClearScalar(options.acceptanceCriteria, "acceptance_criteria", (value) => value);
1495
+ setOrClearTrimScalar(options.definitionOfReady, "definition_of_ready");
1496
+ const orderRaw = options.order ?? options.rank;
1497
+ if (orderRaw !== void 0 || clearFrontMatterKeys.has("order")) {
1498
+ if (clearFrontMatterKeys.has("order")) {
1499
+ delete document.metadata.order;
1500
+ } else {
1501
+ const parsedOrder = parseOptionalNumber(orderRaw, "order");
1502
+ if (!Number.isInteger(parsedOrder)) {
1503
+ throw new PmCliError("Order must be an integer", EXIT_CODE.USAGE);
1504
+ }
1505
+ document.metadata.order = parsedOrder;
1506
+ }
1507
+ changedFields.push("order");
1508
+ }
1509
+ setOrClearTrimScalar(options.goal, "goal");
1510
+ setOrClearTrimScalar(options.objective, "objective");
1511
+ setOrClearTrimScalar(options.value, "value");
1512
+ setOrClearTrimScalar(options.impact, "impact");
1513
+ setOrClearTrimScalar(options.outcome, "outcome");
1514
+ setOrClearTrimScalar(options.whyNow, "why_now");
1515
+ if (options.assignee !== void 0 || clearFrontMatterKeys.has("assignee")) {
1516
+ if (clearFrontMatterKeys.has("assignee")) {
1517
+ delete document.metadata.assignee;
1518
+ } else {
1519
+ if (options.assignee.trim() === "") {
1520
+ throw new PmCliError("--assignee must not be empty. Use --unset assignee to clear it.", EXIT_CODE.USAGE);
1521
+ }
1522
+ document.metadata.assignee = options.assignee.trim();
1523
+ }
1524
+ changedFields.push("assignee");
1525
+ }
1526
+ if (options.parent !== void 0 || clearFrontMatterKeys.has("parent")) {
1527
+ if (clearFrontMatterKeys.has("parent")) {
1528
+ delete document.metadata.parent;
1529
+ } else {
1530
+ document.metadata.parent = resolvedParentValue;
1531
+ }
1532
+ changedFields.push("parent");
1533
+ }
1534
+ setOrClearTrimScalar(options.reviewer, "reviewer");
1535
+ setOrClearScalar(options.risk, "risk", (value) => ensureEnumValue(normalizeRiskInput(value), RISK_VALUES, "risk"));
1536
+ setOrClearScalar(options.confidence, "confidence", (value) => parseConfidenceInput(value));
1537
+ if (options.sprint !== void 0 || clearFrontMatterKeys.has("sprint")) {
1538
+ if (clearFrontMatterKeys.has("sprint")) {
1539
+ delete document.metadata.sprint;
1540
+ } else {
1541
+ const sprintValidation = validateSprintOrReleaseValue("sprint", options.sprint, sprintReleasePolicy);
1542
+ document.metadata.sprint = sprintValidation.value;
1543
+ warnings.push(...sprintValidation.warnings);
1544
+ }
1545
+ changedFields.push("sprint");
1546
+ }
1547
+ if (options.release !== void 0 || clearFrontMatterKeys.has("release")) {
1548
+ if (clearFrontMatterKeys.has("release")) {
1549
+ delete document.metadata.release;
1550
+ } else {
1551
+ const releaseValidation = validateSprintOrReleaseValue("release", options.release, sprintReleasePolicy);
1552
+ document.metadata.release = releaseValidation.value;
1553
+ warnings.push(...releaseValidation.warnings);
1554
+ }
1555
+ changedFields.push("release");
1556
+ }
1557
+ if (options.blockedBy !== void 0 || clearFrontMatterKeys.has("blocked_by")) {
1558
+ if (clearFrontMatterKeys.has("blocked_by")) {
1559
+ delete document.metadata.blocked_by;
1560
+ } else {
1561
+ document.metadata.blocked_by = options.blockedBy.trim();
1562
+ }
1563
+ changedFields.push("blocked_by");
1564
+ applyBlockedByDependencyEdge(document.metadata, resolvedBlockedByDependencyId, nowIso, author, changedFields);
1565
+ }
1566
+ setOrClearTrimScalar(options.blockedReason, "blocked_reason");
1567
+ setOrClearTrimScalar(options.unblockNote, "unblock_note");
1568
+ setOrClearTrimScalar(options.reporter, "reporter");
1569
+ setOrClearScalar(options.severity, "severity", (value) => ensureEnumValue(normalizeSeverityInput(value), ISSUE_SEVERITY_VALUES, "severity"));
1570
+ setOrClearTrimScalar(options.environment, "environment");
1571
+ setOrClearTrimScalar(options.reproSteps, "repro_steps");
1572
+ setOrClearTrimScalar(options.resolution, "resolution");
1573
+ setOrClearTrimScalar(options.expectedResult, "expected_result");
1574
+ setOrClearTrimScalar(options.actualResult, "actual_result");
1575
+ setOrClearTrimScalar(options.affectedVersion, "affected_version");
1576
+ setOrClearTrimScalar(options.fixedVersion, "fixed_version");
1577
+ setOrClearTrimScalar(options.component, "component");
1578
+ setOrClearScalar(options.regression, "regression", (value) => parseRegressionInput(value));
1579
+ setOrClearTrimScalar(options.customerImpact, "customer_impact");
1580
+ if (options.reminder !== void 0 || clearFrontMatterKeys.has("reminders")) {
1581
+ if (clearFrontMatterKeys.has("reminders")) {
1582
+ delete document.metadata.reminders;
1583
+ } else {
1584
+ document.metadata.reminders = parseReminderEntries(options.reminder, nowValue);
1585
+ }
1586
+ changedFields.push("reminders");
1587
+ }
1588
+ if (options.event !== void 0 || clearFrontMatterKeys.has("events")) {
1589
+ if (clearFrontMatterKeys.has("events")) {
1590
+ delete document.metadata.events;
1591
+ } else {
1592
+ document.metadata.events = parseEventEntries(options.event, nowValue);
1593
+ }
1594
+ changedFields.push("events");
1595
+ }
1596
+ for (const definition of runtimeFieldRegistry.definitions) {
1597
+ if (!clearFrontMatterKeys.has(definition.metadata_key)) {
1598
+ continue;
1599
+ }
1600
+ if (metadataRecord[definition.metadata_key] === void 0) {
1601
+ continue;
1602
+ }
1603
+ delete metadataRecord[definition.metadata_key];
1604
+ changedFields.push(definition.metadata_key);
1605
+ }
1606
+ const runtimeFieldUpdates = collectRuntimeUpdateFieldValues(options, runtimeFieldRegistry);
1607
+ for (const [fieldKey, fieldValue] of Object.entries(runtimeFieldUpdates)) {
1608
+ if (clearFrontMatterKeys.has(fieldKey)) {
1609
+ continue;
1610
+ }
1611
+ if (JSON.stringify(metadataRecord[fieldKey]) === JSON.stringify(fieldValue)) {
1612
+ continue;
1613
+ }
1614
+ metadataRecord[fieldKey] = fieldValue;
1615
+ changedFields.push(fieldKey);
1616
+ }
1617
+ try {
1618
+ applyRegisteredItemFieldDefaultsAndValidation(metadataRecord, getActiveExtensionRegistrations());
1619
+ } catch (error) {
1620
+ throw new PmCliError(error instanceof Error ? error.message : "Invalid extension item field values", EXIT_CODE.USAGE);
1621
+ }
1622
+ return { changedFields, warnings };
1623
+ }
1624
+ });
1625
+ return {
1626
+ item: toItemRecord(result.item),
1627
+ changed_fields: result.changedFields,
1628
+ warnings: [...parentReferenceWarnings, ...result.warnings],
1629
+ ...options.allowAuditUpdate === true || options.allowAuditDepUpdate === true ? { audit_update: true } : {}
1630
+ };
1631
+ }
1632
+
1633
+ export {
1634
+ runUpdate
1635
+ };
1636
+ //# sourceMappingURL=chunk-3M73P3G6.js.map