@unbrained/pm-cli 2026.7.2 → 2026.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/CHANGELOG.md +19 -0
  3. package/CONTRIBUTING.md +2 -2
  4. package/README.md +1 -1
  5. package/dist/cli/commander-usage.js +54 -41
  6. package/dist/cli/commander-usage.js.map +1 -1
  7. package/dist/cli/commands/activity.js +79 -57
  8. package/dist/cli/commands/activity.js.map +1 -1
  9. package/dist/cli/commands/close-many.js +106 -65
  10. package/dist/cli/commands/close-many.js.map +1 -1
  11. package/dist/cli/commands/create.js +32 -17
  12. package/dist/cli/commands/create.js.map +1 -1
  13. package/dist/cli/commands/extension/doctor.js +56 -67
  14. package/dist/cli/commands/extension/doctor.js.map +1 -1
  15. package/dist/cli/commands/extension/shared.js +21 -15
  16. package/dist/cli/commands/extension/shared.js.map +1 -1
  17. package/dist/cli/commands/health.js +101 -112
  18. package/dist/cli/commands/health.js.map +1 -1
  19. package/dist/cli/commands/init-agent-guidance.js +32 -19
  20. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  21. package/dist/cli/commands/next.js +13 -10
  22. package/dist/cli/commands/next.js.map +1 -1
  23. package/dist/cli/commands/profile.js +23 -15
  24. package/dist/cli/commands/profile.js.map +1 -1
  25. package/dist/cli/commands/validate.d.ts +2 -0
  26. package/dist/cli/commands/validate.js +14 -2
  27. package/dist/cli/commands/validate.js.map +1 -1
  28. package/dist/cli/error-guidance.js +9 -6
  29. package/dist/cli/error-guidance.js.map +1 -1
  30. package/dist/cli/extension-command-help.js +27 -19
  31. package/dist/cli/extension-command-help.js.map +1 -1
  32. package/dist/cli/help-json-payload.js +57 -49
  33. package/dist/cli/help-json-payload.js.map +1 -1
  34. package/dist/cli/main.js +48 -32
  35. package/dist/cli/main.js.map +1 -1
  36. package/dist/cli/register-list-query.js +213 -213
  37. package/dist/cli/register-list-query.js.map +1 -1
  38. package/dist/cli/register-mutation.js +368 -368
  39. package/dist/cli/register-mutation.js.map +1 -1
  40. package/dist/cli/register-operations.js +303 -299
  41. package/dist/cli/register-operations.js.map +1 -1
  42. package/dist/cli/registration-helpers.d.ts +4 -0
  43. package/dist/cli/registration-helpers.js +45 -56
  44. package/dist/cli/registration-helpers.js.map +1 -1
  45. package/dist/cli-bundle/chunks/{activity-CUC4JY3U.js → activity-5YWLSPGE.js} +9 -9
  46. package/dist/cli-bundle/chunks/activity-BIML7K2D.js +16 -0
  47. package/dist/cli-bundle/chunks/{aggregate-SW5PNGCS.js → aggregate-2V2M3JZU.js} +8 -8
  48. package/dist/cli-bundle/chunks/{aggregate-DKUTRY6R.js → aggregate-EK7DXML7.js} +8 -8
  49. package/dist/cli-bundle/chunks/{append-UBM632FK.js → append-EZESUVJT.js} +8 -8
  50. package/dist/cli-bundle/chunks/{append-H32VOR2Y.js → append-JFG4WQMG.js} +8 -8
  51. package/dist/cli-bundle/chunks/{chunk-XTHQWXVC.js → chunk-32IUNTG4.js} +5 -5
  52. package/dist/cli-bundle/chunks/{chunk-IEEJQCZ4.js → chunk-3W2HJKJX.js} +3 -3
  53. package/dist/cli-bundle/chunks/{chunk-MNBPX5JS.js → chunk-4EXFFP7T.js} +42 -27
  54. package/dist/cli-bundle/chunks/{chunk-MNBPX5JS.js.map → chunk-4EXFFP7T.js.map} +2 -2
  55. package/dist/cli-bundle/chunks/{chunk-JMK5GCK2.js → chunk-4PFVUUYV.js} +2 -2
  56. package/dist/cli-bundle/chunks/{chunk-NRZS637N.js → chunk-4WB6S4YX.js} +56 -21
  57. package/dist/cli-bundle/chunks/chunk-4WB6S4YX.js.map +1 -0
  58. package/dist/cli-bundle/chunks/{chunk-5GVTFFTC.js → chunk-572FKBRL.js} +61 -102
  59. package/dist/cli-bundle/chunks/chunk-572FKBRL.js.map +1 -0
  60. package/dist/cli-bundle/chunks/{chunk-MRD4T5LF.js → chunk-5E7N4T2Z.js} +2 -2
  61. package/dist/cli-bundle/chunks/{chunk-S62UANU7.js → chunk-5IZUBZBR.js} +3 -3
  62. package/dist/cli-bundle/chunks/{chunk-BTX5MIQF.js → chunk-5JIWFWOZ.js} +2 -2
  63. package/dist/cli-bundle/chunks/{chunk-SYVUU7EK.js → chunk-67LARBDL.js} +9 -9
  64. package/dist/cli-bundle/chunks/{chunk-KIYCOJ63.js → chunk-6CDCWKSX.js} +4 -4
  65. package/dist/cli-bundle/chunks/{chunk-JXAUVO6X.js → chunk-6KRFL33E.js} +55 -20
  66. package/dist/cli-bundle/chunks/chunk-6KRFL33E.js.map +7 -0
  67. package/dist/cli-bundle/chunks/{chunk-3LCUASYG.js → chunk-6NYJGMTY.js} +2 -2
  68. package/dist/cli-bundle/chunks/{chunk-2ASNV4DH.js → chunk-7CLLC75T.js} +4 -4
  69. package/dist/cli-bundle/chunks/{chunk-FFOQHGNH.js → chunk-7LYO6S5A.js} +8 -8
  70. package/dist/cli-bundle/chunks/{chunk-55XRYWEG.js → chunk-A3OQ7TFW.js} +8 -8
  71. package/dist/cli-bundle/chunks/{chunk-Q6K2OACU.js → chunk-AIKU3IIL.js} +7 -7
  72. package/dist/cli-bundle/chunks/{chunk-AIAIXG7I.js → chunk-AJHYQCBJ.js} +39 -5
  73. package/dist/cli-bundle/chunks/chunk-AJHYQCBJ.js.map +7 -0
  74. package/dist/cli-bundle/chunks/{chunk-TTHCEV5Q.js → chunk-BE2SR6QL.js} +4 -4
  75. package/dist/cli-bundle/chunks/{chunk-GFMSLORL.js → chunk-BI4R7HI2.js} +75 -53
  76. package/dist/cli-bundle/chunks/chunk-BI4R7HI2.js.map +7 -0
  77. package/dist/cli-bundle/chunks/{chunk-K2VYLVX4.js → chunk-CXR3CMBQ.js} +33 -6
  78. package/dist/cli-bundle/chunks/chunk-CXR3CMBQ.js.map +1 -0
  79. package/dist/cli-bundle/chunks/{chunk-7W4H4K26.js → chunk-ECU6MMTQ.js} +10 -10
  80. package/dist/cli-bundle/chunks/{chunk-YLZZ6T54.js → chunk-EJ2OCBHF.js} +23 -8
  81. package/dist/cli-bundle/chunks/chunk-EJ2OCBHF.js.map +1 -0
  82. package/dist/cli-bundle/chunks/{chunk-5PGBHRY3.js → chunk-EQURFOMH.js} +2 -2
  83. package/dist/cli-bundle/chunks/{chunk-H4GRLYJS.js → chunk-ER4ME5U2.js} +3 -3
  84. package/dist/cli-bundle/chunks/{chunk-QH3FSKRJ.js → chunk-ERG65A2L.js} +2 -2
  85. package/dist/cli-bundle/chunks/{chunk-UWKEJMZU.js → chunk-F6WNBITZ.js} +7 -7
  86. package/dist/cli-bundle/chunks/{chunk-U2BEEM2X.js → chunk-FH2H3CBD.js} +3 -3
  87. package/dist/cli-bundle/chunks/{chunk-EUKTMRN3.js → chunk-FUFFPIYA.js} +2 -2
  88. package/dist/cli-bundle/chunks/{chunk-7MYWF4ZX.js → chunk-FZJM2TXF.js} +7 -7
  89. package/dist/cli-bundle/chunks/{chunk-CYBDUHNO.js → chunk-GUYNUXQT.js} +3 -3
  90. package/dist/cli-bundle/chunks/{chunk-ZNT7KEWE.js → chunk-GVJE5T7Q.js} +2 -2
  91. package/dist/cli-bundle/chunks/{chunk-SYNKD3ZG.js → chunk-HB4FAT3O.js} +42 -60
  92. package/dist/cli-bundle/chunks/chunk-HB4FAT3O.js.map +7 -0
  93. package/dist/cli-bundle/chunks/{chunk-XEWQKDYZ.js → chunk-HQAF23Q2.js} +8 -8
  94. package/dist/cli-bundle/chunks/{chunk-KLXF7NCC.js → chunk-JBZ2NTKX.js} +2 -2
  95. package/dist/cli-bundle/chunks/{chunk-SPM2XLWI.js → chunk-JPATY4SE.js} +22 -7
  96. package/dist/cli-bundle/chunks/chunk-JPATY4SE.js.map +7 -0
  97. package/dist/cli-bundle/chunks/{chunk-4NUOWFBT.js → chunk-K5DT2YKM.js} +7 -7
  98. package/dist/cli-bundle/chunks/{chunk-KCO2EAN5.js → chunk-KEZOIPCR.js} +3 -3
  99. package/dist/cli-bundle/chunks/{chunk-7NSPKJUS.js → chunk-KHVGM5CS.js} +113 -83
  100. package/dist/cli-bundle/chunks/chunk-KHVGM5CS.js.map +7 -0
  101. package/dist/cli-bundle/chunks/{chunk-66Z3X7ZG.js → chunk-KS6ATO47.js} +33 -20
  102. package/dist/cli-bundle/chunks/{chunk-66Z3X7ZG.js.map → chunk-KS6ATO47.js.map} +2 -2
  103. package/dist/cli-bundle/chunks/{chunk-I66WE2HE.js → chunk-L4SLHV6G.js} +112 -82
  104. package/dist/cli-bundle/chunks/chunk-L4SLHV6G.js.map +1 -0
  105. package/dist/cli-bundle/chunks/{chunk-2227673O.js → chunk-LBE5QFMZ.js} +7 -7
  106. package/dist/cli-bundle/chunks/{chunk-YPKFV2JR.js → chunk-LCWQP6NM.js} +76 -54
  107. package/dist/cli-bundle/chunks/chunk-LCWQP6NM.js.map +1 -0
  108. package/dist/cli-bundle/chunks/{chunk-UGLU6Q2I.js → chunk-LOWVNZBZ.js} +4 -4
  109. package/dist/cli-bundle/chunks/{chunk-Y4NRKBFW.js → chunk-MDHWWBNZ.js} +3 -3
  110. package/dist/cli-bundle/chunks/{chunk-LRKMWUUV.js → chunk-MEZZZBYX.js} +2 -2
  111. package/dist/cli-bundle/chunks/{chunk-6YCYF2AI.js → chunk-MHRS5FUX.js} +34 -21
  112. package/dist/cli-bundle/chunks/{chunk-6YCYF2AI.js.map → chunk-MHRS5FUX.js.map} +1 -1
  113. package/dist/cli-bundle/chunks/{chunk-Q6NXOHS6.js → chunk-NOIEVOK5.js} +7 -7
  114. package/dist/cli-bundle/chunks/{chunk-GRRG3MCT.js → chunk-NZ7QIUP5.js} +4 -4
  115. package/dist/cli-bundle/chunks/{chunk-TPOFWBMY.js → chunk-OGLGI22K.js} +26 -20
  116. package/dist/cli-bundle/chunks/chunk-OGLGI22K.js.map +1 -0
  117. package/dist/cli-bundle/chunks/{chunk-ZNHEYCDD.js → chunk-P5L7Z2O6.js} +2 -2
  118. package/dist/cli-bundle/chunks/{chunk-6ZMBJRDJ.js → chunk-PULUSQAV.js} +9 -9
  119. package/dist/cli-bundle/chunks/{chunk-EMPGXBUF.js → chunk-QCDTQCMW.js} +2 -2
  120. package/dist/cli-bundle/chunks/{chunk-OTUJZKGI.js → chunk-QNNQAAZ5.js} +24 -18
  121. package/dist/cli-bundle/chunks/{chunk-OTUJZKGI.js.map → chunk-QNNQAAZ5.js.map} +1 -1
  122. package/dist/cli-bundle/chunks/{chunk-XWGEMNBR.js → chunk-RAHINBVP.js} +60 -101
  123. package/dist/cli-bundle/chunks/chunk-RAHINBVP.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-AJEBCRIY.js → chunk-RJH5VQHW.js} +43 -61
  125. package/dist/cli-bundle/chunks/chunk-RJH5VQHW.js.map +1 -0
  126. package/dist/cli-bundle/chunks/{chunk-HQTPRV4D.js → chunk-SU2E4AWU.js} +6 -6
  127. package/dist/cli-bundle/chunks/{chunk-3Q2HBMTI.js → chunk-SU3TB4NS.js} +2 -2
  128. package/dist/cli-bundle/chunks/{chunk-XCHUVHKU.js → chunk-SYE6WMV6.js} +8 -8
  129. package/dist/cli-bundle/chunks/{chunk-2KWL5NPW.js → chunk-T3P7PMZP.js} +2 -2
  130. package/dist/cli-bundle/chunks/{chunk-N2JSWVWG.js → chunk-T4XBKJ3F.js} +4 -4
  131. package/dist/cli-bundle/chunks/{chunk-BVZZN2LH.js → chunk-T6AXEBOP.js} +23 -17
  132. package/dist/cli-bundle/chunks/{chunk-BVZZN2LH.js.map → chunk-T6AXEBOP.js.map} +2 -2
  133. package/dist/cli-bundle/chunks/{chunk-N3QCJS4M.js → chunk-TQ6AX5SQ.js} +58 -69
  134. package/dist/cli-bundle/chunks/{chunk-N3QCJS4M.js.map → chunk-TQ6AX5SQ.js.map} +2 -2
  135. package/dist/cli-bundle/chunks/{chunk-RM37OPYK.js → chunk-U3S2B7TA.js} +43 -28
  136. package/dist/cli-bundle/chunks/{chunk-RM37OPYK.js.map → chunk-U3S2B7TA.js.map} +1 -1
  137. package/dist/cli-bundle/chunks/{chunk-UTSH5GWX.js → chunk-U5TR4N7J.js} +7 -7
  138. package/dist/cli-bundle/chunks/{chunk-UT73HUPC.js → chunk-UMNQZS4H.js} +3 -3
  139. package/dist/cli-bundle/chunks/{chunk-CZPVDLD2.js → chunk-WJA3PXW7.js} +7 -7
  140. package/dist/cli-bundle/chunks/{chunk-WJAMWAHZ.js → chunk-WRYERRZX.js} +5 -5
  141. package/dist/cli-bundle/chunks/{chunk-6ITZLD4T.js → chunk-WYOIIFSE.js} +10 -10
  142. package/dist/cli-bundle/chunks/{chunk-7TH5NMVB.js → chunk-XRYSCRZR.js} +25 -19
  143. package/dist/cli-bundle/chunks/chunk-XRYSCRZR.js.map +7 -0
  144. package/dist/cli-bundle/chunks/{chunk-3AZUFQK6.js → chunk-YF746GTH.js} +59 -70
  145. package/dist/cli-bundle/chunks/{chunk-3AZUFQK6.js.map → chunk-YF746GTH.js.map} +1 -1
  146. package/dist/cli-bundle/chunks/{chunk-IG5JYZGU.js → chunk-YPWUSH72.js} +7 -7
  147. package/dist/cli-bundle/chunks/{chunk-KN3URLKS.js → chunk-YSDFIY7N.js} +3 -3
  148. package/dist/cli-bundle/chunks/{chunk-2CHRYUXL.js → chunk-YSGTMDWC.js} +2 -2
  149. package/dist/cli-bundle/chunks/{chunk-36UGKF4O.js → chunk-YVKZ3ANP.js} +2 -2
  150. package/dist/cli-bundle/chunks/{chunk-A6VOGKBA.js → chunk-Z5F6XZXE.js} +6 -6
  151. package/dist/cli-bundle/chunks/{chunk-LTRAF2D7.js → chunk-Z7RPDF2Y.js} +3 -3
  152. package/dist/cli-bundle/chunks/{chunk-W47SML5B.js → chunk-ZFTKYWIF.js} +7 -7
  153. package/dist/cli-bundle/chunks/{claim-SENTPZBN.js → claim-2BGBGSVI.js} +8 -8
  154. package/dist/cli-bundle/chunks/{claim-Z7MEQCBT.js → claim-5GU7OE67.js} +8 -8
  155. package/dist/cli-bundle/chunks/close-6YODBUIV.js +14 -0
  156. package/dist/cli-bundle/chunks/{close-424MX4CU.js → close-AFVKPR57.js} +7 -7
  157. package/dist/cli-bundle/chunks/{close-many-SWY34BII.js → close-many-7KLOSYLP.js} +119 -76
  158. package/dist/cli-bundle/chunks/close-many-7KLOSYLP.js.map +7 -0
  159. package/dist/cli-bundle/chunks/{close-many-2IV4J2TR.js → close-many-JKUJMHLG.js} +120 -77
  160. package/dist/cli-bundle/chunks/close-many-JKUJMHLG.js.map +1 -0
  161. package/dist/cli-bundle/chunks/{comments-4FGNTSNV.js → comments-DNWHEBOS.js} +9 -9
  162. package/dist/cli-bundle/chunks/{comments-7YS5MY5X.js → comments-RW23R3VE.js} +9 -9
  163. package/dist/cli-bundle/chunks/{config-G74GISC4.js → config-AUM5WBYA.js} +7 -7
  164. package/dist/cli-bundle/chunks/{config-BZJKK7FZ.js → config-OZWSA2NP.js} +7 -7
  165. package/dist/cli-bundle/chunks/{context-ZQY54JNS.js → context-OYXRGY7S.js} +12 -12
  166. package/dist/cli-bundle/chunks/{context-LHVKJSPJ.js → context-PKCEHQY3.js} +12 -12
  167. package/dist/cli-bundle/chunks/{contracts-CP2EZJC7.js → contracts-L6ODXNUM.js} +3 -3
  168. package/dist/cli-bundle/chunks/{contracts-FIZLMP7O.js → contracts-X74F2GSM.js} +3 -3
  169. package/dist/cli-bundle/chunks/{copy-GYNQQPW2.js → copy-6XOR3HKN.js} +5 -5
  170. package/dist/cli-bundle/chunks/{copy-TLW7JTQT.js → copy-I4NCLBR4.js} +5 -5
  171. package/dist/cli-bundle/chunks/{create-VSKYSOCD.js → create-PM45M6PE.js} +12 -12
  172. package/dist/cli-bundle/chunks/create-Z7YCH3BE.js +28 -0
  173. package/dist/cli-bundle/chunks/{delete-ANTOTI2I.js → delete-7YXHYG67.js} +5 -5
  174. package/dist/cli-bundle/chunks/{delete-4W5JYCEG.js → delete-LPISP43T.js} +5 -5
  175. package/dist/cli-bundle/chunks/{deps-HPPE6MJN.js → deps-N2T26FME.js} +5 -5
  176. package/dist/cli-bundle/chunks/{deps-ZQZN54EZ.js → deps-WATKQDE3.js} +5 -5
  177. package/dist/cli-bundle/chunks/{docs-RPOVFMP3.js → docs-6LQ3GLM7.js} +7 -7
  178. package/dist/cli-bundle/chunks/{docs-XJNYBJGE.js → docs-Z3X6JZLT.js} +7 -7
  179. package/dist/cli-bundle/chunks/{eval-RFBI5FGS.js → eval-6DCLG52D.js} +10 -10
  180. package/dist/cli-bundle/chunks/{eval-DM6JBZTS.js → eval-Y3ZCUTHK.js} +10 -10
  181. package/dist/cli-bundle/chunks/{extension-B3YY4WY5.js → extension-BNINIMT7.js} +11 -11
  182. package/dist/cli-bundle/chunks/{extension-TTSEFQTS.js → extension-QWE4YYK5.js} +11 -11
  183. package/dist/cli-bundle/chunks/{files-5D65CHGE.js → files-6SGKHS6O.js} +7 -7
  184. package/dist/cli-bundle/chunks/{files-GPIG77EN.js → files-FUYPSOFJ.js} +7 -7
  185. package/dist/cli-bundle/chunks/{focus-ZHN7WIGX.js → focus-2Q3K76G2.js} +6 -6
  186. package/dist/cli-bundle/chunks/{focus-C3PEJV2C.js → focus-ATLBWXXD.js} +6 -6
  187. package/dist/cli-bundle/chunks/{gc-D4JQ6OWN.js → gc-RUYEMNRF.js} +3 -3
  188. package/dist/cli-bundle/chunks/{gc-VZIXDL32.js → gc-TDWSDR66.js} +3 -3
  189. package/dist/cli-bundle/chunks/{get-IOVAN6RU.js → get-2WGLX74N.js} +10 -10
  190. package/dist/cli-bundle/chunks/{get-GIBRUUOP.js → get-LY6M2JIM.js} +10 -10
  191. package/dist/cli-bundle/chunks/{health-L2U3AFKV.js → health-4RKHYS3T.js} +115 -123
  192. package/dist/cli-bundle/chunks/health-4RKHYS3T.js.map +1 -0
  193. package/dist/cli-bundle/chunks/{health-MM7AWXYF.js → health-TMFVNYRA.js} +114 -122
  194. package/dist/cli-bundle/chunks/health-TMFVNYRA.js.map +7 -0
  195. package/dist/cli-bundle/chunks/history-CGNQJXFE.js +18 -0
  196. package/dist/cli-bundle/chunks/{history-IL7XCEX2.js → history-SGRRS72R.js} +8 -8
  197. package/dist/cli-bundle/chunks/{history-compact-MV25P7DM.js → history-compact-LOED43R3.js} +10 -10
  198. package/dist/cli-bundle/chunks/{history-compact-HALOTOU7.js → history-compact-V5DNAQHH.js} +10 -10
  199. package/dist/cli-bundle/chunks/{history-redact-VYCWQFK7.js → history-redact-IRL7WJ3E.js} +9 -9
  200. package/dist/cli-bundle/chunks/history-redact-N3JK7VBW.js +19 -0
  201. package/dist/cli-bundle/chunks/{history-repair-44MODPQF.js → history-repair-4WVBVHFR.js} +10 -10
  202. package/dist/cli-bundle/chunks/{history-repair-CPNAOCNF.js → history-repair-PGYQJMGD.js} +10 -10
  203. package/dist/cli-bundle/chunks/{init-F27NHENZ.js → init-4GESW7RM.js} +12 -12
  204. package/dist/cli-bundle/chunks/init-XIDPABA4.js +22 -0
  205. package/dist/cli-bundle/chunks/{learnings-HJVDQIGY.js → learnings-4BHWFFUV.js} +9 -9
  206. package/dist/cli-bundle/chunks/{learnings-XSFSUUWK.js → learnings-4FJY7WIW.js} +9 -9
  207. package/dist/cli-bundle/chunks/{list-HPMEKCAA.js → list-472TIOVK.js} +8 -8
  208. package/dist/cli-bundle/chunks/{list-VMPWTURB.js → list-D7BF5CL2.js} +8 -8
  209. package/dist/cli-bundle/chunks/{next-QM6YJIIS.js → next-D5STGWI2.js} +26 -23
  210. package/dist/cli-bundle/chunks/next-D5STGWI2.js.map +1 -0
  211. package/dist/cli-bundle/chunks/{next-ETXF2ZCN.js → next-SFQZVX2B.js} +25 -22
  212. package/dist/cli-bundle/chunks/{next-ETXF2ZCN.js.map → next-SFQZVX2B.js.map} +2 -2
  213. package/dist/cli-bundle/chunks/{notes-GDZIKGR6.js → notes-6KNOSLIT.js} +9 -9
  214. package/dist/cli-bundle/chunks/{notes-WDDBPC4D.js → notes-W4UEICGF.js} +9 -9
  215. package/dist/cli-bundle/chunks/{plan-BGDR73Z6.js → plan-JO6V7BXO.js} +12 -12
  216. package/dist/cli-bundle/chunks/{plan-C5IMM335.js → plan-MJQW5XK3.js} +12 -12
  217. package/dist/cli-bundle/chunks/{profile-HUCENIEQ.js → profile-3TOTMUR4.js} +26 -18
  218. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js.map +7 -0
  219. package/dist/cli-bundle/chunks/{profile-CCOKZ2IQ.js → profile-WIQY2KCV.js} +27 -19
  220. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js.map +1 -0
  221. package/dist/cli-bundle/chunks/{register-list-query-XN4ZRHSV.js → register-list-query-ELBHCCFI.js} +179 -170
  222. package/dist/cli-bundle/chunks/register-list-query-ELBHCCFI.js.map +7 -0
  223. package/dist/cli-bundle/chunks/{register-list-query-ROSNIL52.js → register-list-query-GAPQ6DM3.js} +180 -171
  224. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js.map +1 -0
  225. package/dist/cli-bundle/chunks/{register-mutation-KRLAHEL2.js → register-mutation-ROFE2YPC.js} +367 -361
  226. package/dist/cli-bundle/chunks/register-mutation-ROFE2YPC.js.map +7 -0
  227. package/dist/cli-bundle/chunks/{register-mutation-CFSB2MS3.js → register-mutation-SJWMVIJ2.js} +368 -362
  228. package/dist/cli-bundle/chunks/register-mutation-SJWMVIJ2.js.map +1 -0
  229. package/dist/cli-bundle/chunks/{register-operations-4PASGJDB.js → register-operations-IADFVH53.js} +309 -304
  230. package/dist/cli-bundle/chunks/register-operations-IADFVH53.js.map +7 -0
  231. package/dist/cli-bundle/chunks/{register-operations-MBN4KGUM.js → register-operations-MEKU3AKC.js} +310 -305
  232. package/dist/cli-bundle/chunks/register-operations-MEKU3AKC.js.map +1 -0
  233. package/dist/cli-bundle/chunks/{register-setup-ZCGKHDKL.js → register-setup-3QJY43CY.js} +15 -15
  234. package/dist/cli-bundle/chunks/{register-setup-VIAWYFP5.js → register-setup-AJWUSSQX.js} +15 -15
  235. package/dist/cli-bundle/chunks/{restore-4CBWUMCX.js → restore-44IHMMZZ.js} +9 -9
  236. package/dist/cli-bundle/chunks/restore-EXHU34EU.js +17 -0
  237. package/dist/cli-bundle/chunks/{scheduling-shortcuts-6VFKNKCM.js → scheduling-shortcuts-OLHNLAZY.js} +12 -12
  238. package/dist/cli-bundle/chunks/{scheduling-shortcuts-ERHCVTEM.js → scheduling-shortcuts-TSBK4AY5.js} +12 -12
  239. package/dist/cli-bundle/chunks/{schema-TDGK6N3I.js → schema-IB2NZZWD.js} +7 -7
  240. package/dist/cli-bundle/chunks/{schema-UE5KKAUX.js → schema-VBCELP5G.js} +7 -7
  241. package/dist/cli-bundle/chunks/{search-K4CFLQ5S.js → search-7UBETML4.js} +10 -10
  242. package/dist/cli-bundle/chunks/{search-FP7MEU4S.js → search-R227JOL6.js} +10 -10
  243. package/dist/cli-bundle/chunks/{stats-XT6QRKQY.js → stats-FAG7COEH.js} +6 -6
  244. package/dist/cli-bundle/chunks/{stats-NJJCALEZ.js → stats-MCK7PLYS.js} +6 -6
  245. package/dist/cli-bundle/chunks/{telemetry-5SQ5UDXC.js → telemetry-DRPDZMAO.js} +4 -4
  246. package/dist/cli-bundle/chunks/{telemetry-HVXFZA2U.js → telemetry-GVVUQSJQ.js} +4 -4
  247. package/dist/cli-bundle/chunks/{test-YCDAUBWF.js → test-QY44WAMR.js} +15 -15
  248. package/dist/cli-bundle/chunks/{test-UFSJ5YIO.js → test-SY76DZTO.js} +15 -15
  249. package/dist/cli-bundle/chunks/{test-all-PM7UYN42.js → test-all-QD6QAEG7.js} +17 -17
  250. package/dist/cli-bundle/chunks/{test-all-2BWKY3GQ.js → test-all-USPJHXFR.js} +17 -17
  251. package/dist/cli-bundle/chunks/{test-runs-FK5E75AA.js → test-runs-MG5VIGSK.js} +4 -4
  252. package/dist/cli-bundle/chunks/{test-runs-H4TGWGRN.js → test-runs-QIR5MJPL.js} +4 -4
  253. package/dist/cli-bundle/chunks/update-A7EICML6.js +24 -0
  254. package/dist/cli-bundle/chunks/{update-Y5WQVT5O.js → update-IKJZWLQC.js} +15 -15
  255. package/dist/cli-bundle/chunks/{update-many-JTKKSA7Y.js → update-many-BEMTDA2X.js} +28 -28
  256. package/dist/cli-bundle/chunks/{update-many-6YAYYRLE.js → update-many-RATAARHU.js} +28 -28
  257. package/dist/cli-bundle/chunks/{upgrade-JUDU7YL4.js → upgrade-NWMR3VQL.js} +11 -11
  258. package/dist/cli-bundle/chunks/{upgrade-DTAHZ236.js → upgrade-VU46BLJZ.js} +11 -11
  259. package/dist/cli-bundle/chunks/{validate-W7H5TEDC.js → validate-GAJ6FUSI.js} +32 -22
  260. package/dist/cli-bundle/chunks/validate-GAJ6FUSI.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{validate-732RWS5W.js → validate-NRY6MFXN.js} +31 -21
  262. package/dist/cli-bundle/chunks/validate-NRY6MFXN.js.map +7 -0
  263. package/dist/cli-bundle/main.js +180 -122
  264. package/dist/cli-bundle/main.js.map +3 -3
  265. package/dist/core/item/type-registry.js +29 -19
  266. package/dist/core/item/type-registry.js.map +1 -1
  267. package/dist/core/schema/runtime-schema.js +65 -54
  268. package/dist/core/schema/runtime-schema.js.map +1 -1
  269. package/dist/core/schema/status-defs-file.js +26 -3
  270. package/dist/core/schema/status-defs-file.js.map +1 -1
  271. package/dist/core/search/corpus.js +25 -19
  272. package/dist/core/search/corpus.js.map +1 -1
  273. package/dist/core/shared/memo.d.ts +12 -0
  274. package/dist/core/shared/memo.js +25 -0
  275. package/dist/core/shared/memo.js.map +1 -0
  276. package/dist/core/shared/serialization.js +24 -14
  277. package/dist/core/shared/serialization.js.map +1 -1
  278. package/dist/core/shared/time.js +26 -4
  279. package/dist/core/shared/time.js.map +1 -1
  280. package/dist/core/store/front-matter-cache.d.ts +5 -0
  281. package/dist/core/store/front-matter-cache.js +79 -20
  282. package/dist/core/store/front-matter-cache.js.map +1 -1
  283. package/dist/sdk/cli-contracts/flag-contracts.js +71 -99
  284. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  285. package/dist/sdk/compose.js +51 -42
  286. package/dist/sdk/compose.js.map +1 -1
  287. package/docs/AGENT_GUIDE.md +2 -2
  288. package/docs/ARCHITECTURE.md +2 -2
  289. package/docs/COMMANDS.md +8 -4
  290. package/docs/CONFIGURATION.md +1 -1
  291. package/docs/EXTENSIONS.md +12 -12
  292. package/docs/ONBOARDING.md +4 -2
  293. package/docs/README.md +2 -0
  294. package/docs/examples/starter-extension/README.md +11 -10
  295. package/marketplace.json +3 -3
  296. package/package.json +1 -1
  297. package/plugins/pm-claude/.claude-plugin/plugin.json +2 -2
  298. package/plugins/pm-claude/README.md +6 -3
  299. package/plugins/pm-claude/commands/pm-init.md +1 -1
  300. package/dist/cli-bundle/chunks/activity-WEIEMM73.js +0 -16
  301. package/dist/cli-bundle/chunks/chunk-5GVTFFTC.js.map +0 -1
  302. package/dist/cli-bundle/chunks/chunk-7NSPKJUS.js.map +0 -7
  303. package/dist/cli-bundle/chunks/chunk-7TH5NMVB.js.map +0 -7
  304. package/dist/cli-bundle/chunks/chunk-AIAIXG7I.js.map +0 -7
  305. package/dist/cli-bundle/chunks/chunk-AJEBCRIY.js.map +0 -1
  306. package/dist/cli-bundle/chunks/chunk-GFMSLORL.js.map +0 -7
  307. package/dist/cli-bundle/chunks/chunk-I66WE2HE.js.map +0 -1
  308. package/dist/cli-bundle/chunks/chunk-JXAUVO6X.js.map +0 -7
  309. package/dist/cli-bundle/chunks/chunk-K2VYLVX4.js.map +0 -1
  310. package/dist/cli-bundle/chunks/chunk-NRZS637N.js.map +0 -1
  311. package/dist/cli-bundle/chunks/chunk-SPM2XLWI.js.map +0 -7
  312. package/dist/cli-bundle/chunks/chunk-SYNKD3ZG.js.map +0 -7
  313. package/dist/cli-bundle/chunks/chunk-TPOFWBMY.js.map +0 -1
  314. package/dist/cli-bundle/chunks/chunk-XWGEMNBR.js.map +0 -7
  315. package/dist/cli-bundle/chunks/chunk-YLZZ6T54.js.map +0 -1
  316. package/dist/cli-bundle/chunks/chunk-YPKFV2JR.js.map +0 -1
  317. package/dist/cli-bundle/chunks/close-YCWQQPDS.js +0 -14
  318. package/dist/cli-bundle/chunks/close-many-2IV4J2TR.js.map +0 -1
  319. package/dist/cli-bundle/chunks/close-many-SWY34BII.js.map +0 -7
  320. package/dist/cli-bundle/chunks/create-XTMAPS7I.js +0 -28
  321. package/dist/cli-bundle/chunks/health-L2U3AFKV.js.map +0 -1
  322. package/dist/cli-bundle/chunks/health-MM7AWXYF.js.map +0 -7
  323. package/dist/cli-bundle/chunks/history-DD7L7BNL.js +0 -18
  324. package/dist/cli-bundle/chunks/history-redact-IX4YEWMY.js +0 -19
  325. package/dist/cli-bundle/chunks/init-HHVQQP6C.js +0 -22
  326. package/dist/cli-bundle/chunks/next-QM6YJIIS.js.map +0 -1
  327. package/dist/cli-bundle/chunks/profile-CCOKZ2IQ.js.map +0 -1
  328. package/dist/cli-bundle/chunks/profile-HUCENIEQ.js.map +0 -7
  329. package/dist/cli-bundle/chunks/register-list-query-ROSNIL52.js.map +0 -1
  330. package/dist/cli-bundle/chunks/register-list-query-XN4ZRHSV.js.map +0 -7
  331. package/dist/cli-bundle/chunks/register-mutation-CFSB2MS3.js.map +0 -1
  332. package/dist/cli-bundle/chunks/register-mutation-KRLAHEL2.js.map +0 -7
  333. package/dist/cli-bundle/chunks/register-operations-4PASGJDB.js.map +0 -7
  334. package/dist/cli-bundle/chunks/register-operations-MBN4KGUM.js.map +0 -1
  335. package/dist/cli-bundle/chunks/restore-5UEAGG3W.js +0 -17
  336. package/dist/cli-bundle/chunks/update-MTCFES6X.js +0 -24
  337. package/dist/cli-bundle/chunks/validate-732RWS5W.js.map +0 -7
  338. package/dist/cli-bundle/chunks/validate-W7H5TEDC.js.map +0 -1
  339. /package/dist/cli-bundle/chunks/{activity-CUC4JY3U.js.map → activity-5YWLSPGE.js.map} +0 -0
  340. /package/dist/cli-bundle/chunks/{activity-WEIEMM73.js.map → activity-BIML7K2D.js.map} +0 -0
  341. /package/dist/cli-bundle/chunks/{aggregate-SW5PNGCS.js.map → aggregate-2V2M3JZU.js.map} +0 -0
  342. /package/dist/cli-bundle/chunks/{aggregate-DKUTRY6R.js.map → aggregate-EK7DXML7.js.map} +0 -0
  343. /package/dist/cli-bundle/chunks/{append-UBM632FK.js.map → append-EZESUVJT.js.map} +0 -0
  344. /package/dist/cli-bundle/chunks/{append-H32VOR2Y.js.map → append-JFG4WQMG.js.map} +0 -0
  345. /package/dist/cli-bundle/chunks/{chunk-XTHQWXVC.js.map → chunk-32IUNTG4.js.map} +0 -0
  346. /package/dist/cli-bundle/chunks/{chunk-IEEJQCZ4.js.map → chunk-3W2HJKJX.js.map} +0 -0
  347. /package/dist/cli-bundle/chunks/{chunk-JMK5GCK2.js.map → chunk-4PFVUUYV.js.map} +0 -0
  348. /package/dist/cli-bundle/chunks/{chunk-MRD4T5LF.js.map → chunk-5E7N4T2Z.js.map} +0 -0
  349. /package/dist/cli-bundle/chunks/{chunk-S62UANU7.js.map → chunk-5IZUBZBR.js.map} +0 -0
  350. /package/dist/cli-bundle/chunks/{chunk-BTX5MIQF.js.map → chunk-5JIWFWOZ.js.map} +0 -0
  351. /package/dist/cli-bundle/chunks/{chunk-SYVUU7EK.js.map → chunk-67LARBDL.js.map} +0 -0
  352. /package/dist/cli-bundle/chunks/{chunk-KIYCOJ63.js.map → chunk-6CDCWKSX.js.map} +0 -0
  353. /package/dist/cli-bundle/chunks/{chunk-3LCUASYG.js.map → chunk-6NYJGMTY.js.map} +0 -0
  354. /package/dist/cli-bundle/chunks/{chunk-2ASNV4DH.js.map → chunk-7CLLC75T.js.map} +0 -0
  355. /package/dist/cli-bundle/chunks/{chunk-FFOQHGNH.js.map → chunk-7LYO6S5A.js.map} +0 -0
  356. /package/dist/cli-bundle/chunks/{chunk-55XRYWEG.js.map → chunk-A3OQ7TFW.js.map} +0 -0
  357. /package/dist/cli-bundle/chunks/{chunk-Q6K2OACU.js.map → chunk-AIKU3IIL.js.map} +0 -0
  358. /package/dist/cli-bundle/chunks/{chunk-TTHCEV5Q.js.map → chunk-BE2SR6QL.js.map} +0 -0
  359. /package/dist/cli-bundle/chunks/{chunk-7W4H4K26.js.map → chunk-ECU6MMTQ.js.map} +0 -0
  360. /package/dist/cli-bundle/chunks/{chunk-5PGBHRY3.js.map → chunk-EQURFOMH.js.map} +0 -0
  361. /package/dist/cli-bundle/chunks/{chunk-H4GRLYJS.js.map → chunk-ER4ME5U2.js.map} +0 -0
  362. /package/dist/cli-bundle/chunks/{chunk-QH3FSKRJ.js.map → chunk-ERG65A2L.js.map} +0 -0
  363. /package/dist/cli-bundle/chunks/{chunk-UWKEJMZU.js.map → chunk-F6WNBITZ.js.map} +0 -0
  364. /package/dist/cli-bundle/chunks/{chunk-U2BEEM2X.js.map → chunk-FH2H3CBD.js.map} +0 -0
  365. /package/dist/cli-bundle/chunks/{chunk-EUKTMRN3.js.map → chunk-FUFFPIYA.js.map} +0 -0
  366. /package/dist/cli-bundle/chunks/{chunk-7MYWF4ZX.js.map → chunk-FZJM2TXF.js.map} +0 -0
  367. /package/dist/cli-bundle/chunks/{chunk-CYBDUHNO.js.map → chunk-GUYNUXQT.js.map} +0 -0
  368. /package/dist/cli-bundle/chunks/{chunk-ZNT7KEWE.js.map → chunk-GVJE5T7Q.js.map} +0 -0
  369. /package/dist/cli-bundle/chunks/{chunk-XEWQKDYZ.js.map → chunk-HQAF23Q2.js.map} +0 -0
  370. /package/dist/cli-bundle/chunks/{chunk-KLXF7NCC.js.map → chunk-JBZ2NTKX.js.map} +0 -0
  371. /package/dist/cli-bundle/chunks/{chunk-4NUOWFBT.js.map → chunk-K5DT2YKM.js.map} +0 -0
  372. /package/dist/cli-bundle/chunks/{chunk-KCO2EAN5.js.map → chunk-KEZOIPCR.js.map} +0 -0
  373. /package/dist/cli-bundle/chunks/{chunk-2227673O.js.map → chunk-LBE5QFMZ.js.map} +0 -0
  374. /package/dist/cli-bundle/chunks/{chunk-UGLU6Q2I.js.map → chunk-LOWVNZBZ.js.map} +0 -0
  375. /package/dist/cli-bundle/chunks/{chunk-Y4NRKBFW.js.map → chunk-MDHWWBNZ.js.map} +0 -0
  376. /package/dist/cli-bundle/chunks/{chunk-LRKMWUUV.js.map → chunk-MEZZZBYX.js.map} +0 -0
  377. /package/dist/cli-bundle/chunks/{chunk-Q6NXOHS6.js.map → chunk-NOIEVOK5.js.map} +0 -0
  378. /package/dist/cli-bundle/chunks/{chunk-GRRG3MCT.js.map → chunk-NZ7QIUP5.js.map} +0 -0
  379. /package/dist/cli-bundle/chunks/{chunk-ZNHEYCDD.js.map → chunk-P5L7Z2O6.js.map} +0 -0
  380. /package/dist/cli-bundle/chunks/{chunk-6ZMBJRDJ.js.map → chunk-PULUSQAV.js.map} +0 -0
  381. /package/dist/cli-bundle/chunks/{chunk-EMPGXBUF.js.map → chunk-QCDTQCMW.js.map} +0 -0
  382. /package/dist/cli-bundle/chunks/{chunk-HQTPRV4D.js.map → chunk-SU2E4AWU.js.map} +0 -0
  383. /package/dist/cli-bundle/chunks/{chunk-3Q2HBMTI.js.map → chunk-SU3TB4NS.js.map} +0 -0
  384. /package/dist/cli-bundle/chunks/{chunk-XCHUVHKU.js.map → chunk-SYE6WMV6.js.map} +0 -0
  385. /package/dist/cli-bundle/chunks/{chunk-2KWL5NPW.js.map → chunk-T3P7PMZP.js.map} +0 -0
  386. /package/dist/cli-bundle/chunks/{chunk-N2JSWVWG.js.map → chunk-T4XBKJ3F.js.map} +0 -0
  387. /package/dist/cli-bundle/chunks/{chunk-UTSH5GWX.js.map → chunk-U5TR4N7J.js.map} +0 -0
  388. /package/dist/cli-bundle/chunks/{chunk-UT73HUPC.js.map → chunk-UMNQZS4H.js.map} +0 -0
  389. /package/dist/cli-bundle/chunks/{chunk-CZPVDLD2.js.map → chunk-WJA3PXW7.js.map} +0 -0
  390. /package/dist/cli-bundle/chunks/{chunk-WJAMWAHZ.js.map → chunk-WRYERRZX.js.map} +0 -0
  391. /package/dist/cli-bundle/chunks/{chunk-6ITZLD4T.js.map → chunk-WYOIIFSE.js.map} +0 -0
  392. /package/dist/cli-bundle/chunks/{chunk-IG5JYZGU.js.map → chunk-YPWUSH72.js.map} +0 -0
  393. /package/dist/cli-bundle/chunks/{chunk-KN3URLKS.js.map → chunk-YSDFIY7N.js.map} +0 -0
  394. /package/dist/cli-bundle/chunks/{chunk-2CHRYUXL.js.map → chunk-YSGTMDWC.js.map} +0 -0
  395. /package/dist/cli-bundle/chunks/{chunk-36UGKF4O.js.map → chunk-YVKZ3ANP.js.map} +0 -0
  396. /package/dist/cli-bundle/chunks/{chunk-A6VOGKBA.js.map → chunk-Z5F6XZXE.js.map} +0 -0
  397. /package/dist/cli-bundle/chunks/{chunk-LTRAF2D7.js.map → chunk-Z7RPDF2Y.js.map} +0 -0
  398. /package/dist/cli-bundle/chunks/{chunk-W47SML5B.js.map → chunk-ZFTKYWIF.js.map} +0 -0
  399. /package/dist/cli-bundle/chunks/{claim-SENTPZBN.js.map → claim-2BGBGSVI.js.map} +0 -0
  400. /package/dist/cli-bundle/chunks/{claim-Z7MEQCBT.js.map → claim-5GU7OE67.js.map} +0 -0
  401. /package/dist/cli-bundle/chunks/{close-YCWQQPDS.js.map → close-6YODBUIV.js.map} +0 -0
  402. /package/dist/cli-bundle/chunks/{close-424MX4CU.js.map → close-AFVKPR57.js.map} +0 -0
  403. /package/dist/cli-bundle/chunks/{comments-4FGNTSNV.js.map → comments-DNWHEBOS.js.map} +0 -0
  404. /package/dist/cli-bundle/chunks/{comments-7YS5MY5X.js.map → comments-RW23R3VE.js.map} +0 -0
  405. /package/dist/cli-bundle/chunks/{config-G74GISC4.js.map → config-AUM5WBYA.js.map} +0 -0
  406. /package/dist/cli-bundle/chunks/{config-BZJKK7FZ.js.map → config-OZWSA2NP.js.map} +0 -0
  407. /package/dist/cli-bundle/chunks/{context-ZQY54JNS.js.map → context-OYXRGY7S.js.map} +0 -0
  408. /package/dist/cli-bundle/chunks/{context-LHVKJSPJ.js.map → context-PKCEHQY3.js.map} +0 -0
  409. /package/dist/cli-bundle/chunks/{contracts-CP2EZJC7.js.map → contracts-L6ODXNUM.js.map} +0 -0
  410. /package/dist/cli-bundle/chunks/{contracts-FIZLMP7O.js.map → contracts-X74F2GSM.js.map} +0 -0
  411. /package/dist/cli-bundle/chunks/{copy-GYNQQPW2.js.map → copy-6XOR3HKN.js.map} +0 -0
  412. /package/dist/cli-bundle/chunks/{copy-TLW7JTQT.js.map → copy-I4NCLBR4.js.map} +0 -0
  413. /package/dist/cli-bundle/chunks/{create-VSKYSOCD.js.map → create-PM45M6PE.js.map} +0 -0
  414. /package/dist/cli-bundle/chunks/{create-XTMAPS7I.js.map → create-Z7YCH3BE.js.map} +0 -0
  415. /package/dist/cli-bundle/chunks/{delete-ANTOTI2I.js.map → delete-7YXHYG67.js.map} +0 -0
  416. /package/dist/cli-bundle/chunks/{delete-4W5JYCEG.js.map → delete-LPISP43T.js.map} +0 -0
  417. /package/dist/cli-bundle/chunks/{deps-HPPE6MJN.js.map → deps-N2T26FME.js.map} +0 -0
  418. /package/dist/cli-bundle/chunks/{deps-ZQZN54EZ.js.map → deps-WATKQDE3.js.map} +0 -0
  419. /package/dist/cli-bundle/chunks/{docs-RPOVFMP3.js.map → docs-6LQ3GLM7.js.map} +0 -0
  420. /package/dist/cli-bundle/chunks/{docs-XJNYBJGE.js.map → docs-Z3X6JZLT.js.map} +0 -0
  421. /package/dist/cli-bundle/chunks/{eval-RFBI5FGS.js.map → eval-6DCLG52D.js.map} +0 -0
  422. /package/dist/cli-bundle/chunks/{eval-DM6JBZTS.js.map → eval-Y3ZCUTHK.js.map} +0 -0
  423. /package/dist/cli-bundle/chunks/{extension-B3YY4WY5.js.map → extension-BNINIMT7.js.map} +0 -0
  424. /package/dist/cli-bundle/chunks/{extension-TTSEFQTS.js.map → extension-QWE4YYK5.js.map} +0 -0
  425. /package/dist/cli-bundle/chunks/{files-5D65CHGE.js.map → files-6SGKHS6O.js.map} +0 -0
  426. /package/dist/cli-bundle/chunks/{files-GPIG77EN.js.map → files-FUYPSOFJ.js.map} +0 -0
  427. /package/dist/cli-bundle/chunks/{focus-ZHN7WIGX.js.map → focus-2Q3K76G2.js.map} +0 -0
  428. /package/dist/cli-bundle/chunks/{focus-C3PEJV2C.js.map → focus-ATLBWXXD.js.map} +0 -0
  429. /package/dist/cli-bundle/chunks/{gc-D4JQ6OWN.js.map → gc-RUYEMNRF.js.map} +0 -0
  430. /package/dist/cli-bundle/chunks/{gc-VZIXDL32.js.map → gc-TDWSDR66.js.map} +0 -0
  431. /package/dist/cli-bundle/chunks/{get-IOVAN6RU.js.map → get-2WGLX74N.js.map} +0 -0
  432. /package/dist/cli-bundle/chunks/{get-GIBRUUOP.js.map → get-LY6M2JIM.js.map} +0 -0
  433. /package/dist/cli-bundle/chunks/{history-DD7L7BNL.js.map → history-CGNQJXFE.js.map} +0 -0
  434. /package/dist/cli-bundle/chunks/{history-IL7XCEX2.js.map → history-SGRRS72R.js.map} +0 -0
  435. /package/dist/cli-bundle/chunks/{history-compact-MV25P7DM.js.map → history-compact-LOED43R3.js.map} +0 -0
  436. /package/dist/cli-bundle/chunks/{history-compact-HALOTOU7.js.map → history-compact-V5DNAQHH.js.map} +0 -0
  437. /package/dist/cli-bundle/chunks/{history-redact-VYCWQFK7.js.map → history-redact-IRL7WJ3E.js.map} +0 -0
  438. /package/dist/cli-bundle/chunks/{history-redact-IX4YEWMY.js.map → history-redact-N3JK7VBW.js.map} +0 -0
  439. /package/dist/cli-bundle/chunks/{history-repair-44MODPQF.js.map → history-repair-4WVBVHFR.js.map} +0 -0
  440. /package/dist/cli-bundle/chunks/{history-repair-CPNAOCNF.js.map → history-repair-PGYQJMGD.js.map} +0 -0
  441. /package/dist/cli-bundle/chunks/{init-F27NHENZ.js.map → init-4GESW7RM.js.map} +0 -0
  442. /package/dist/cli-bundle/chunks/{init-HHVQQP6C.js.map → init-XIDPABA4.js.map} +0 -0
  443. /package/dist/cli-bundle/chunks/{learnings-HJVDQIGY.js.map → learnings-4BHWFFUV.js.map} +0 -0
  444. /package/dist/cli-bundle/chunks/{learnings-XSFSUUWK.js.map → learnings-4FJY7WIW.js.map} +0 -0
  445. /package/dist/cli-bundle/chunks/{list-HPMEKCAA.js.map → list-472TIOVK.js.map} +0 -0
  446. /package/dist/cli-bundle/chunks/{list-VMPWTURB.js.map → list-D7BF5CL2.js.map} +0 -0
  447. /package/dist/cli-bundle/chunks/{notes-GDZIKGR6.js.map → notes-6KNOSLIT.js.map} +0 -0
  448. /package/dist/cli-bundle/chunks/{notes-WDDBPC4D.js.map → notes-W4UEICGF.js.map} +0 -0
  449. /package/dist/cli-bundle/chunks/{plan-BGDR73Z6.js.map → plan-JO6V7BXO.js.map} +0 -0
  450. /package/dist/cli-bundle/chunks/{plan-C5IMM335.js.map → plan-MJQW5XK3.js.map} +0 -0
  451. /package/dist/cli-bundle/chunks/{register-setup-ZCGKHDKL.js.map → register-setup-3QJY43CY.js.map} +0 -0
  452. /package/dist/cli-bundle/chunks/{register-setup-VIAWYFP5.js.map → register-setup-AJWUSSQX.js.map} +0 -0
  453. /package/dist/cli-bundle/chunks/{restore-4CBWUMCX.js.map → restore-44IHMMZZ.js.map} +0 -0
  454. /package/dist/cli-bundle/chunks/{restore-5UEAGG3W.js.map → restore-EXHU34EU.js.map} +0 -0
  455. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-6VFKNKCM.js.map → scheduling-shortcuts-OLHNLAZY.js.map} +0 -0
  456. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-ERHCVTEM.js.map → scheduling-shortcuts-TSBK4AY5.js.map} +0 -0
  457. /package/dist/cli-bundle/chunks/{schema-TDGK6N3I.js.map → schema-IB2NZZWD.js.map} +0 -0
  458. /package/dist/cli-bundle/chunks/{schema-UE5KKAUX.js.map → schema-VBCELP5G.js.map} +0 -0
  459. /package/dist/cli-bundle/chunks/{search-K4CFLQ5S.js.map → search-7UBETML4.js.map} +0 -0
  460. /package/dist/cli-bundle/chunks/{search-FP7MEU4S.js.map → search-R227JOL6.js.map} +0 -0
  461. /package/dist/cli-bundle/chunks/{stats-XT6QRKQY.js.map → stats-FAG7COEH.js.map} +0 -0
  462. /package/dist/cli-bundle/chunks/{stats-NJJCALEZ.js.map → stats-MCK7PLYS.js.map} +0 -0
  463. /package/dist/cli-bundle/chunks/{telemetry-5SQ5UDXC.js.map → telemetry-DRPDZMAO.js.map} +0 -0
  464. /package/dist/cli-bundle/chunks/{telemetry-HVXFZA2U.js.map → telemetry-GVVUQSJQ.js.map} +0 -0
  465. /package/dist/cli-bundle/chunks/{test-YCDAUBWF.js.map → test-QY44WAMR.js.map} +0 -0
  466. /package/dist/cli-bundle/chunks/{test-UFSJ5YIO.js.map → test-SY76DZTO.js.map} +0 -0
  467. /package/dist/cli-bundle/chunks/{test-all-PM7UYN42.js.map → test-all-QD6QAEG7.js.map} +0 -0
  468. /package/dist/cli-bundle/chunks/{test-all-2BWKY3GQ.js.map → test-all-USPJHXFR.js.map} +0 -0
  469. /package/dist/cli-bundle/chunks/{test-runs-FK5E75AA.js.map → test-runs-MG5VIGSK.js.map} +0 -0
  470. /package/dist/cli-bundle/chunks/{test-runs-H4TGWGRN.js.map → test-runs-QIR5MJPL.js.map} +0 -0
  471. /package/dist/cli-bundle/chunks/{update-MTCFES6X.js.map → update-A7EICML6.js.map} +0 -0
  472. /package/dist/cli-bundle/chunks/{update-Y5WQVT5O.js.map → update-IKJZWLQC.js.map} +0 -0
  473. /package/dist/cli-bundle/chunks/{update-many-JTKKSA7Y.js.map → update-many-BEMTDA2X.js.map} +0 -0
  474. /package/dist/cli-bundle/chunks/{update-many-6YAYYRLE.js.map → update-many-RATAARHU.js.map} +0 -0
  475. /package/dist/cli-bundle/chunks/{upgrade-JUDU7YL4.js.map → upgrade-NWMR3VQL.js.map} +0 -0
  476. /package/dist/cli-bundle/chunks/{upgrade-DTAHZ236.js.map → upgrade-VU46BLJZ.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../cli/commands/validate.ts","../../../../../../../../core/validate/fix-planning.ts","../../../../../../../../core/governance/issue-codes.ts","../../../../../../../../core/validate/missing-by-type.ts","../../../../../../../../core/validate/stale-file-classification.ts","../../../../../../../../core/validate/missing-link-owners.ts"],"sourcesContent":["/**\n * @module cli/commands/validate\n *\n * Implements the pm validate command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport { realpathSync } from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport { execFile } from \"node:child_process\";\nimport path from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { buildRemediationCommands } from \"../../core/diagnostics/remediation.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { scanHistoryDrift } from \"../../core/history/drift-scan.js\";\nimport { normalizeStatusInput } from \"../../core/item/status.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { resolveRuntimeStatusRegistry, type RuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport {\n DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS,\n DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS,\n EXIT_CODE,\n PM_DIRNAME,\n} from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { toNonEmptyStringOrUndefined } from \"../../core/shared/primitives.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport {\n CURRENT_ITEM_FORMAT_VERSION,\n effectiveItemFormatVersion,\n scanItemFormatVersions,\n} from \"../../core/item/item-format-version.js\";\nimport { listAllFrontMatterWithBody } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport {\n partitionFixesByGrant,\n planCloseReasonBackfillFixes,\n planEstimateBackfillFixes,\n planResolutionBackfillFixes,\n planStaleLinkPruneFixes,\n planTerminalParentFixes,\n resolveGrantedFixScopes,\n toFixOutputRow,\n type CloseReasonBackfillRow,\n type EstimateBackfillRow,\n type ResolutionBackfillRow,\n type StaleLinkPruneRow,\n type TerminalParentFixRow,\n type ValidateFixScope,\n type ValidateFixRecord,\n} from \"../../core/validate/fix-planning.js\";\nimport { findDuplicateIssueCodes, type DuplicateIssueCode } from \"../../core/governance/issue-codes.js\";\nimport { buildMissingByTypeCounts, type MissingFieldOccurrence } from \"../../core/validate/missing-by-type.js\";\nimport {\n classifyStaleLinkedPaths,\n summarizeStaleLinkedPathClassifications,\n} from \"../../core/validate/stale-file-classification.js\";\nimport { isRemoteLinkedArtifactReference } from \"../../core/validate/linked-artifact-reference.js\";\nimport {\n buildMissingLinkedPathRows,\n summarizeMissingLinkedPathRows,\n type StaleLinkOwnerInput,\n} from \"../../core/validate/missing-link-owners.js\";\nimport type { ValidateMetadataProfile, ValidateMetadataRequiredField } from \"../../types/index.js\";\nimport { extractReferencedPmItemIdsFromCommand } from \"./test.js\";\n\ntype ValidateCheckName =\n | \"metadata\"\n | \"resolution\"\n | \"lifecycle\"\n | \"files\"\n | \"command_references\"\n | \"history_drift\"\n | \"format_version\";\ntype ValidateStatus = \"ok\" | \"warn\" | \"error\";\ntype ValidateDependencyCycleSeverity = \"off\" | \"warn\" | \"error\";\ntype ValidateFileScanMode = \"default\" | \"tracked-all\" | \"tracked-all-strict\";\ntype ItemWithBody = Awaited<ReturnType<typeof listAllFrontMatterWithBody>>[number];\ntype FileCandidateSource = \"default-curated\" | \"tracked-git\" | \"tracked-all-fallback-default\";\ntype OrphanedPathClassification = \"docs_unowned\" | \"tests_unowned\" | \"source_unowned\" | \"unlinked_existing\";\n\nconst FILE_SCAN_DIRECTORIES = [\"src\", \"tests\", \"docs\"] as const;\nconst FILE_SCAN_ROOT_FILES = [\n \"README.md\",\n \"PRD.md\",\n \"CHANGELOG.md\",\n \"AGENTS.md\",\n \"CONTRIBUTING.md\",\n \"SECURITY.md\",\n \"CODE_OF_CONDUCT.md\",\n \"LICENSE\",\n] as const;\nconst DIRECTORY_IGNORE_SET = new Set([\"node_modules\", \".git\", \".cursor\", \".agents\", \"dist\", \"coverage\"]);\nconst RESOLUTION_FIELD_KEYS = [\"resolution\", \"expected_result\", \"actual_result\"] as const;\ntype ResolutionFieldKey = (typeof RESOLUTION_FIELD_KEYS)[number];\nconst VALIDATE_FILE_SCAN_MODES = [\"default\", \"tracked-all\", \"tracked-all-strict\"] as const;\nconst VALIDATE_METADATA_PROFILE_VALUES = [\"core\", \"strict\", \"custom\"] as const;\nconst VALIDATE_DEPENDENCY_CYCLE_SEVERITY_VALUES = [\"off\", \"warn\", \"error\"] as const;\nconst LIFECYCLE_PATTERN_FIELD_KEYS = [\"blocked_reason\", \"resolution\", \"actual_result\"] as const;\ntype LifecyclePatternFieldKey = (typeof LIFECYCLE_PATTERN_FIELD_KEYS)[number];\nconst CORE_METADATA_REQUIRED_FIELDS = [\"author\", \"acceptance_criteria\", \"estimated_minutes\", \"close_reason\"] as const;\nconst STRICT_METADATA_REQUIRED_FIELDS = [\n ...CORE_METADATA_REQUIRED_FIELDS,\n \"reviewer\",\n \"risk\",\n \"confidence\",\n \"sprint\",\n \"release\",\n] as const;\n// Keep this deduplicated so future list edits cannot double-count metadata diagnostics.\nconst SUPPORTED_METADATA_REQUIRED_FIELDS: readonly ValidateMetadataRequiredField[] = Array.from(\n new Set<ValidateMetadataRequiredField>(STRICT_METADATA_REQUIRED_FIELDS),\n);\nconst METADATA_REQUIRED_FIELD_ALIASES: Record<string, ValidateMetadataRequiredField> = {\n author: \"author\",\n acceptance_criteria: \"acceptance_criteria\",\n \"acceptance-criteria\": \"acceptance_criteria\",\n estimated_minutes: \"estimated_minutes\",\n \"estimated-minutes\": \"estimated_minutes\",\n estimate: \"estimated_minutes\",\n close_reason: \"close_reason\",\n \"close-reason\": \"close_reason\",\n reviewer: \"reviewer\",\n risk: \"risk\",\n confidence: \"confidence\",\n sprint: \"sprint\",\n release: \"release\",\n};\nconst METADATA_WARNING_TOKEN_BY_FIELD: Record<ValidateMetadataRequiredField, string> = {\n author: \"validate_metadata_missing_author\",\n acceptance_criteria: \"validate_metadata_missing_acceptance_criteria\",\n estimated_minutes: \"validate_metadata_missing_estimate\",\n close_reason: \"validate_metadata_missing_close_reason\",\n reviewer: \"validate_metadata_missing_reviewer\",\n risk: \"validate_metadata_missing_risk\",\n confidence: \"validate_metadata_missing_confidence\",\n sprint: \"validate_metadata_missing_sprint\",\n release: \"validate_metadata_missing_release\",\n};\nconst METADATA_COUNT_KEY_BY_FIELD: Record<ValidateMetadataRequiredField, string> = {\n author: \"missing_author\",\n acceptance_criteria: \"missing_acceptance_criteria\",\n estimated_minutes: \"missing_estimated_minutes\",\n close_reason: \"closed_missing_close_reason\",\n reviewer: \"missing_reviewer\",\n risk: \"missing_risk\",\n confidence: \"missing_confidence\",\n sprint: \"missing_sprint\",\n release: \"missing_release\",\n};\nconst METADATA_ITEM_IDS_KEY_BY_FIELD: Record<ValidateMetadataRequiredField, string> = {\n author: \"missing_author_item_ids\",\n acceptance_criteria: \"missing_acceptance_criteria_item_ids\",\n estimated_minutes: \"missing_estimated_minutes_item_ids\",\n close_reason: \"closed_missing_close_reason_item_ids\",\n reviewer: \"missing_reviewer_item_ids\",\n risk: \"missing_risk_item_ids\",\n confidence: \"missing_confidence_item_ids\",\n sprint: \"missing_sprint_item_ids\",\n release: \"missing_release_item_ids\",\n};\nconst METADATA_TRUNCATED_KEY_BY_FIELD: Record<ValidateMetadataRequiredField, string> = {\n author: \"missing_author_truncated\",\n acceptance_criteria: \"missing_acceptance_criteria_truncated\",\n estimated_minutes: \"missing_estimated_minutes_truncated\",\n close_reason: \"closed_missing_close_reason_truncated\",\n reviewer: \"missing_reviewer_truncated\",\n risk: \"missing_risk_truncated\",\n confidence: \"missing_confidence_truncated\",\n sprint: \"missing_sprint_truncated\",\n release: \"missing_release_truncated\",\n};\nconst GIT_LS_FILES_MAX_BUFFER = 32 * 1024 * 1024;\nconst FILE_LIST_SUMMARY_LIMIT = 40;\nconst DIAGNOSTIC_LIST_SUMMARY_LIMIT = 5;\nconst execFileAsync = promisify(execFile);\n\n/**\n * Documents the validate command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidateCommandOptions {\n checkMetadata?: boolean;\n checkResolution?: boolean;\n checkLifecycle?: boolean;\n checkStaleBlockers?: boolean;\n dependencyCycleSeverity?: string;\n parentCycleSeverity?: string;\n checkFiles?: boolean;\n includePmInternals?: boolean;\n verboseFileLists?: boolean;\n verboseDiagnostics?: boolean;\n /** Emit complete *_item_ids diagnostic lists (no 5-item cap); implied by --json. */\n allAffectedIds?: boolean;\n checkHistoryDrift?: boolean;\n checkCommandReferences?: boolean;\n scanMode?: string;\n metadataProfile?: string;\n fixHints?: boolean;\n autoFix?: boolean;\n dryRun?: boolean;\n fixScope?: string[];\n pruneMissing?: boolean;\n}\n\n/**\n * Documents the validate check payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidateCheck {\n name: ValidateCheckName;\n status: ValidateStatus;\n details: Record<string, unknown>;\n}\n\n/**\n * Documents the validate fixes summary payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidateFixesSummary {\n mode: \"apply\" | \"dry_run\";\n auto_fix: boolean;\n prune_missing: boolean;\n granted_fix_scopes: string[];\n planned_count: number;\n applied_count: number;\n gated_count: number;\n failed_count: number;\n planned_fixes: Array<Record<string, unknown>>;\n applied_fixes: Array<Record<string, unknown>>;\n gated_fixes: Array<Record<string, unknown>>;\n failed_fixes: Array<Record<string, unknown>>;\n}\n\n/**\n * Documents the validate result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidateResult {\n ok: boolean;\n has_warnings: boolean;\n checks: ValidateCheck[];\n warnings: string[];\n /** Present when --auto-fix or --prune-missing was requested; checks always reflect the PRE-fix state. */\n fixes?: ValidateFixesSummary;\n generated_at: string;\n}\n\nfunction normalizeRelativePath(value: string): string {\n return value.replaceAll(\"\\\\\", \"/\").replace(/^\\.\\/+/, \"\").replace(/^\\/+/, \"\");\n}\n\nfunction normalizeRelativeDirectoryPath(value: string): string {\n const normalized = normalizeRelativePath(value);\n return normalized.replace(/\\/+$/, \"\");\n}\n\n\n\nfunction toMeaningfulString(value: unknown): string | undefined {\n const normalized = toNonEmptyStringOrUndefined(value);\n if (!normalized) {\n return undefined;\n }\n const lowered = normalized.toLowerCase();\n if (lowered === \"none\" || lowered === \"null\" || lowered === \"n/a\" || lowered === \"na\") {\n return undefined;\n }\n return normalized;\n}\n\n/* c8 ignore start -- runtime-status alias normalization is covered by status-registry integration tests */\nfunction normalizeStatusForRegistry(status: string, statusRegistry: RuntimeStatusRegistry): string {\n return normalizeStatusInput(status, statusRegistry) ?? status;\n}\n/* c8 ignore stop */\n\nfunction isTerminalStatus(status: string, statusRegistry: RuntimeStatusRegistry): boolean {\n return statusRegistry.terminal_statuses.has(normalizeStatusForRegistry(status, statusRegistry));\n}\n\ninterface ValidateMetadataPolicy {\n profile: ValidateMetadataProfile;\n profile_source: \"default\" | \"settings\" | \"option\";\n required_fields: ValidateMetadataRequiredField[];\n configured_custom_fields: ValidateMetadataRequiredField[];\n fallback_to_core: boolean;\n warnings: string[];\n}\n\ntype LifecyclePatternSource = \"default\" | \"settings\";\n\ninterface LifecyclePatternPolicy {\n stale_blocker_reason_patterns: string[];\n stale_blocker_reason_pattern_source: LifecyclePatternSource;\n closure_like_metadata_field_patterns: Record<LifecyclePatternFieldKey, string[]>;\n closure_like_metadata_field_pattern_sources: Record<LifecyclePatternFieldKey, LifecyclePatternSource>;\n}\n\ninterface LifecyclePatternSettingsSource {\n validation: {\n lifecycle_stale_blocker_reason_patterns: string[];\n lifecycle_closure_like_blocked_reason_patterns: string[];\n lifecycle_closure_like_resolution_patterns: string[];\n lifecycle_closure_like_actual_result_patterns: string[];\n };\n}\n\n/* c8 ignore start -- lifecycle pattern normalization/default-vs-settings matrix is covered by lifecycle integration tests */\nfunction normalizeLifecyclePatternList(values: readonly string[] | undefined): string[] {\n return [...new Set((values ?? []).map((value) => value.trim().toLowerCase()).filter((value) => value.length > 0))].sort(\n (left, right) => left.localeCompare(right),\n );\n}\n\nfunction areSortedStringListsEqual(left: readonly string[], right: readonly string[]): boolean {\n if (left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n}\n\nfunction resolveLifecyclePatternPolicy(settings: LifecyclePatternSettingsSource): LifecyclePatternPolicy {\n const defaultStalePatterns = normalizeLifecyclePatternList(DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS);\n const defaultClosureLikePatterns = {\n blocked_reason: normalizeLifecyclePatternList(DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.blocked_reason),\n resolution: normalizeLifecyclePatternList(DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.resolution),\n actual_result: normalizeLifecyclePatternList(DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS.actual_result),\n } satisfies Record<LifecyclePatternFieldKey, string[]>;\n const staleBlockerReasonPatterns = normalizeLifecyclePatternList(\n settings.validation.lifecycle_stale_blocker_reason_patterns,\n );\n const closureLikePatterns = {\n blocked_reason: normalizeLifecyclePatternList(settings.validation.lifecycle_closure_like_blocked_reason_patterns),\n resolution: normalizeLifecyclePatternList(settings.validation.lifecycle_closure_like_resolution_patterns),\n actual_result: normalizeLifecyclePatternList(settings.validation.lifecycle_closure_like_actual_result_patterns),\n } satisfies Record<LifecyclePatternFieldKey, string[]>;\n return {\n stale_blocker_reason_patterns: staleBlockerReasonPatterns,\n stale_blocker_reason_pattern_source: areSortedStringListsEqual(staleBlockerReasonPatterns, defaultStalePatterns)\n ? \"default\"\n : \"settings\",\n closure_like_metadata_field_patterns: closureLikePatterns,\n closure_like_metadata_field_pattern_sources: {\n blocked_reason: areSortedStringListsEqual(closureLikePatterns.blocked_reason, defaultClosureLikePatterns.blocked_reason)\n ? \"default\"\n : \"settings\",\n resolution: areSortedStringListsEqual(closureLikePatterns.resolution, defaultClosureLikePatterns.resolution)\n ? \"default\"\n : \"settings\",\n actual_result: areSortedStringListsEqual(closureLikePatterns.actual_result, defaultClosureLikePatterns.actual_result)\n ? \"default\"\n : \"settings\",\n },\n };\n}\n/* c8 ignore stop */\n\nfunction resolveValidateMetadataProfile(value: string | undefined): ValidateMetadataProfile {\n const normalized = value?.trim().toLowerCase();\n if (!normalized || normalized.length === 0) {\n return \"core\";\n }\n if ((VALIDATE_METADATA_PROFILE_VALUES as readonly string[]).includes(normalized)) {\n return normalized as ValidateMetadataProfile;\n }\n throw new PmCliError(\n `Unknown --metadata-profile value \"${value}\". Supported values: ${VALIDATE_METADATA_PROFILE_VALUES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction resolveDependencyCycleSeverity(value: string | undefined): ValidateDependencyCycleSeverity {\n const normalized = value?.trim().toLowerCase();\n if (!normalized || normalized.length === 0) {\n return \"warn\";\n }\n if ((VALIDATE_DEPENDENCY_CYCLE_SEVERITY_VALUES as readonly string[]).includes(normalized)) {\n return normalized as ValidateDependencyCycleSeverity;\n }\n throw new PmCliError(\n `Unknown --dependency-cycle-severity value \"${value}\". Supported values: ${VALIDATE_DEPENDENCY_CYCLE_SEVERITY_VALUES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction resolveParentCycleSeverity(value: string | undefined): ValidateDependencyCycleSeverity {\n const normalized = value?.trim().toLowerCase();\n if (!normalized || normalized.length === 0) {\n return \"warn\";\n }\n if ((VALIDATE_DEPENDENCY_CYCLE_SEVERITY_VALUES as readonly string[]).includes(normalized)) {\n return normalized as ValidateDependencyCycleSeverity;\n }\n throw new PmCliError(\n `Unknown --parent-cycle-severity value \"${value}\". Supported values: ${VALIDATE_DEPENDENCY_CYCLE_SEVERITY_VALUES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n}\n\n/* c8 ignore start -- metadata required-field alias normalization is covered by metadata-policy integration tests */\nfunction normalizeMetadataRequiredFieldsFromSettings(\n values: readonly ValidateMetadataRequiredField[] | undefined,\n): ValidateMetadataRequiredField[] {\n const normalized = [...new Set((values ?? []).map((value) => value.trim().toLowerCase().replaceAll(\"-\", \"_\")))];\n return normalized\n .map((value) => METADATA_REQUIRED_FIELD_ALIASES[value])\n .filter((value): value is ValidateMetadataRequiredField => value !== undefined)\n .sort((left, right) => left.localeCompare(right));\n}\n/* c8 ignore stop */\n\nfunction resolveValidateMetadataPolicy(\n profile: ValidateMetadataProfile,\n profileSource: \"default\" | \"settings\" | \"option\",\n configuredCustomFields: readonly ValidateMetadataRequiredField[],\n): ValidateMetadataPolicy {\n const normalizedCustomFields = normalizeMetadataRequiredFieldsFromSettings(configuredCustomFields);\n if (profile === \"core\") {\n return {\n profile,\n profile_source: profileSource,\n required_fields: [...CORE_METADATA_REQUIRED_FIELDS],\n configured_custom_fields: normalizedCustomFields,\n fallback_to_core: false,\n warnings: [],\n };\n }\n if (profile === \"strict\") {\n return {\n profile,\n profile_source: profileSource,\n required_fields: [...STRICT_METADATA_REQUIRED_FIELDS],\n configured_custom_fields: normalizedCustomFields,\n fallback_to_core: false,\n warnings: [],\n };\n }\n if (normalizedCustomFields.length > 0) {\n return {\n profile,\n profile_source: profileSource,\n required_fields: normalizedCustomFields,\n configured_custom_fields: normalizedCustomFields,\n fallback_to_core: false,\n warnings: [],\n };\n }\n return {\n profile,\n profile_source: profileSource,\n required_fields: [...CORE_METADATA_REQUIRED_FIELDS],\n configured_custom_fields: normalizedCustomFields,\n fallback_to_core: true,\n warnings: [\"validate_metadata_custom_profile_missing_required_fields:0\"],\n };\n}\n\n/**\n * Planning fields whose absence is only actionable on live work (GH-276): an\n * agent backfills an estimate or acceptance criteria to plan/execute an item,\n * so flagging them on a terminal (closed/canceled) historical item is pure\n * noise. Under the `strict` profile these are still enforced everywhere for\n * projects that want full historical coverage.\n */\nconst TERMINAL_EXEMPT_PLANNING_FIELDS: ReadonlySet<ValidateMetadataRequiredField> = new Set([\n \"acceptance_criteria\",\n \"estimated_minutes\",\n]);\n\nfunction isMetadataFieldMissing(\n item: ItemWithBody,\n field: ValidateMetadataRequiredField,\n statusRegistry: RuntimeStatusRegistry,\n enforcePlanningFieldsOnTerminal: boolean,\n): boolean {\n // GH-276: skip planning-field gaps on retired (closed/canceled) items unless\n // the resolved profile explicitly demands strict historical coverage.\n if (\n !enforcePlanningFieldsOnTerminal &&\n TERMINAL_EXEMPT_PLANNING_FIELDS.has(field) &&\n isTerminalStatus(item.status, statusRegistry)\n ) {\n return false;\n }\n if (field === \"author\") {\n return !toNonEmptyStringOrUndefined(item.author);\n }\n if (field === \"acceptance_criteria\") {\n return !toNonEmptyStringOrUndefined(item.acceptance_criteria);\n }\n if (field === \"estimated_minutes\") {\n return !Number.isFinite(item.estimated_minutes);\n }\n if (field === \"close_reason\") {\n return normalizeStatusForRegistry(item.status, statusRegistry) === statusRegistry.close_status && !toNonEmptyStringOrUndefined(item.close_reason);\n }\n if (field === \"reviewer\") {\n return !toNonEmptyStringOrUndefined(item.reviewer);\n }\n if (field === \"risk\") {\n return !toNonEmptyStringOrUndefined(item.risk);\n }\n if (field === \"confidence\") {\n if (typeof item.confidence === \"number\") {\n return !Number.isFinite(item.confidence);\n }\n return !toNonEmptyStringOrUndefined(item.confidence);\n }\n if (field === \"sprint\") {\n return !toNonEmptyStringOrUndefined(item.sprint);\n }\n return !toNonEmptyStringOrUndefined(item.release);\n}\n\nfunction resolveFileScanMode(scanMode: string | undefined): ValidateFileScanMode {\n if (scanMode === undefined) {\n return \"default\";\n }\n const normalized = scanMode.trim().toLowerCase();\n if (normalized.length === 0) {\n return \"default\";\n }\n if (normalized === \"default\") {\n return \"default\";\n }\n if (normalized === \"tracked-all\" || normalized === \"tracked_all\") {\n return \"tracked-all\";\n }\n if (normalized === \"tracked-all-strict\" || normalized === \"tracked_all_strict\") {\n return \"tracked-all-strict\";\n }\n throw new PmCliError(\n `Unknown --scan-mode value \"${scanMode}\". Supported values: ${VALIDATE_FILE_SCAN_MODES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction resolveWorkspaceRoot(pmRoot: string): string {\n const resolvedPmRoot = path.resolve(pmRoot);\n const normalizedPmRoot = resolvedPmRoot.replaceAll(\"\\\\\", \"/\");\n if (normalizedPmRoot.endsWith(\"/.agents/pm\")) {\n return path.dirname(path.dirname(resolvedPmRoot));\n }\n const resolvedCwd = path.resolve(process.cwd());\n const canonicalPmRoot = realpathForWorkspaceRoot(resolvedPmRoot);\n const canonicalCwd = realpathForWorkspaceRoot(resolvedCwd);\n const relativeFromPmRoot = path.relative(canonicalPmRoot, canonicalCwd);\n const cwdInsidePmRoot =\n relativeFromPmRoot.length === 0 ||\n (!relativeFromPmRoot.startsWith(\"..\") && !path.isAbsolute(relativeFromPmRoot));\n if (cwdInsidePmRoot) {\n return resolvedPmRoot;\n }\n /* c8 ignore next 2 -- non-standard PM root layouts are integration-only edge cases. */\n return resolvedCwd;\n}\n\nfunction realpathForWorkspaceRoot(inputPath: string): string {\n try {\n return realpathSync.native(inputPath);\n } catch {\n return path.resolve(inputPath);\n }\n}\n\n/* c8 ignore start -- recursive file-walk dirent/permission edge cases are covered by filesystem integration suites */\nasync function listFilesRecursive(basePath: string, relativePath: string, output: string[]): Promise<void> {\n const targetDirectory = relativePath.length > 0 ? path.join(basePath, relativePath) : basePath;\n let entries: Dirent[];\n try {\n entries = await fs.readdir(targetDirectory, { withFileTypes: true });\n } catch (error: unknown) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === \"ENOENT\") {\n return;\n }\n throw error;\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith(\".\")) {\n continue;\n }\n const childRelative = relativePath.length > 0 ? path.join(relativePath, entry.name) : entry.name;\n if (entry.isDirectory()) {\n if (DIRECTORY_IGNORE_SET.has(entry.name)) {\n continue;\n }\n await listFilesRecursive(basePath, childRelative, output);\n continue;\n }\n /* c8 ignore next 3 -- non-file dirent variants (symlink/socket) are filesystem-specific. */\n if (!entry.isFile()) {\n continue;\n }\n output.push(normalizeRelativePath(childRelative));\n }\n}\n/* c8 ignore stop */\n\nasync function collectDefaultProjectFileCandidates(workspaceRoot: string): Promise<string[]> {\n const discovered: string[] = [];\n for (const directory of FILE_SCAN_DIRECTORIES) {\n await listFilesRecursive(workspaceRoot, directory, discovered);\n }\n for (const candidate of FILE_SCAN_ROOT_FILES) {\n const absolute = path.join(workspaceRoot, candidate);\n try {\n const stats = await fs.stat(absolute);\n /* c8 ignore start -- root-candidate presence depends on fixture workspace composition. */\n if (stats.isFile()) {\n discovered.push(normalizeRelativePath(candidate));\n }\n /* c8 ignore stop */\n } catch {\n // Ignore root-file candidates that are not present in this workspace.\n }\n }\n return [...new Set(discovered)].sort((left, right) => left.localeCompare(right));\n}\n\nasync function collectTrackedGitFileCandidates(workspaceRoot: string): Promise<string[] | null> {\n try {\n const { stdout } = await execFileAsync(\"git\", [\"ls-files\", \"-z\"], {\n cwd: workspaceRoot,\n encoding: \"utf8\",\n maxBuffer: GIT_LS_FILES_MAX_BUFFER,\n windowsHide: true,\n });\n const discovered = stdout\n .split(\"\\0\")\n .map((value) => normalizeRelativePath(value))\n .filter((value) => value.length > 0);\n return [...new Set(discovered)].sort((left, right) => left.localeCompare(right));\n } catch {\n /* c8 ignore start -- fallback path exercised only when git metadata is unavailable. */\n return null;\n /* c8 ignore stop */\n }\n}\n\ninterface FileCandidateCollection {\n requestedMode: ValidateFileScanMode;\n appliedMode: ValidateFileScanMode;\n source: FileCandidateSource;\n candidateFiles: string[];\n candidateTotal: number;\n candidateScanned: number;\n}\n\n/* c8 ignore start -- PM-internal prefix derivation permutations are covered by file-scan integration tests */\nfunction resolvePmInternalCandidatePrefixes(pmRoot: string, workspaceRoot: string): string[] {\n const prefixes = new Set<string>();\n const configuredDefault = normalizeRelativeDirectoryPath(PM_DIRNAME);\n if (configuredDefault.length > 0) {\n prefixes.add(configuredDefault);\n }\n const relativePmRoot = normalizeRelativeDirectoryPath(path.relative(workspaceRoot, pmRoot));\n if (relativePmRoot.length > 0 && !relativePmRoot.startsWith(\"..\")) {\n prefixes.add(relativePmRoot);\n }\n return [...prefixes].sort((left, right) => left.localeCompare(right));\n}\n/* c8 ignore stop */\n\nfunction hasPathPrefix(candidate: string, prefixes: string[]): boolean {\n for (const prefix of prefixes) {\n if (candidate === prefix || candidate.startsWith(`${prefix}/`)) {\n return true;\n }\n }\n return false;\n}\n\nasync function collectProjectFileCandidates(\n workspaceRoot: string,\n scanMode: ValidateFileScanMode,\n): Promise<FileCandidateCollection> {\n if (scanMode === \"tracked-all\" || scanMode === \"tracked-all-strict\") {\n const trackedCandidates = await collectTrackedGitFileCandidates(workspaceRoot);\n /* c8 ignore start -- tracked-git availability fallback is covered by git/non-git integration fixtures */\n if (trackedCandidates) {\n return {\n requestedMode: scanMode,\n appliedMode: scanMode,\n source: \"tracked-git\",\n candidateFiles: trackedCandidates,\n candidateTotal: trackedCandidates.length,\n candidateScanned: trackedCandidates.length,\n };\n }\n /* c8 ignore stop */\n /* c8 ignore start -- deterministic fallback retained for non-git workspaces. */\n const fallbackCandidates = await collectDefaultProjectFileCandidates(workspaceRoot);\n return {\n requestedMode: scanMode,\n appliedMode: \"default\",\n source: \"tracked-all-fallback-default\",\n candidateFiles: fallbackCandidates,\n candidateTotal: fallbackCandidates.length,\n candidateScanned: fallbackCandidates.length,\n };\n /* c8 ignore stop */\n }\n\n const defaultCandidates = await collectDefaultProjectFileCandidates(workspaceRoot);\n return {\n requestedMode: scanMode,\n appliedMode: \"default\",\n source: \"default-curated\",\n candidateFiles: defaultCandidates,\n candidateTotal: defaultCandidates.length,\n candidateScanned: defaultCandidates.length,\n };\n}\n\nfunction summarizeList(values: string[], limit = DIAGNOSTIC_LIST_SUMMARY_LIMIT): { values: string[]; truncated: boolean } {\n /* c8 ignore start -- truncation behavior only surfaces with very large synthetic datasets. */\n if (values.length <= limit) {\n return { values, truncated: false };\n }\n return {\n values: values.slice(0, limit),\n truncated: true,\n };\n /* c8 ignore stop */\n}\n\nfunction summarizeFileList(\n values: string[],\n verboseFileLists: boolean,\n): {\n values: string[];\n truncated: boolean;\n total: number;\n} {\n if (verboseFileLists) {\n return {\n values,\n truncated: false,\n total: values.length,\n };\n }\n const summary = summarizeList(values, FILE_LIST_SUMMARY_LIMIT);\n return {\n values: summary.values,\n truncated: summary.truncated,\n total: values.length,\n };\n}\n\nconst RESOLUTION_REMEDIATION_FLAG_BY_FIELD: Record<ResolutionFieldKey, string> = {\n resolution: \"--resolution\",\n expected_result: \"--expected-result\",\n actual_result: \"--actual-result\",\n};\n\nconst RESOLUTION_REMEDIATION_PLACEHOLDER_BY_FIELD: Record<ResolutionFieldKey, string> = {\n resolution: \"Describe how this item was resolved\",\n expected_result: \"Describe the expected result\",\n actual_result: \"Describe the actual result\",\n};\n\nfunction buildResolutionRemediationCommand(row: { id: string; missing_fields: ResolutionFieldKey[] }): string {\n const fieldArguments = row.missing_fields\n .map((field) => `${RESOLUTION_REMEDIATION_FLAG_BY_FIELD[field]} \\\"${RESOLUTION_REMEDIATION_PLACEHOLDER_BY_FIELD[field]}\\\"`)\n .join(\" \");\n return `pm update ${row.id} ${fieldArguments} --message \\\"Backfill resolution metadata\\\"`;\n}\n\n/**\n * Attach a uniform, machine-executable `fix_hints` array to a validate check's\n * details when `--fix-hints` is requested. The resolution check's existing\n * per-row remediation commands (which already carry concrete item ids) are\n * aliased in so agents read one uniform field across every check; all other\n * checks derive one generic command per distinct warning code from the shared\n * remediation registry. Generic hints may contain `<id>`/`<field>`/`<path>`\n * placeholders the caller substitutes before running — they are templates, not\n * always directly executable as-is. Read-only: this only enriches the diagnostic\n * output, never mutates any item.\n */\n/* c8 ignore start -- fix-hint projection/truncation combinations are covered by validate output integration tests */\nfunction attachValidateFixHints(check: ValidateCheck, checkWarnings: string[]): void {\n const existingResolutionHints = check.details?.missing_resolution_remediation_hints;\n const aliasedResolution = Array.isArray(existingResolutionHints) && existingResolutionHints.length > 0;\n const fixHints = aliasedResolution\n ? (existingResolutionHints as unknown[]).filter((hint): hint is string => typeof hint === \"string\")\n : buildRemediationCommands(checkWarnings);\n if (fixHints.length === 0) {\n return;\n }\n // The resolution check truncates its per-row hint list for low-token output;\n // carry that marker onto fix_hints so an agent knows the list is partial and\n // there are more items to repair beyond the ones shown.\n const truncated = aliasedResolution && check.details?.missing_resolution_remediation_hints_truncated === true;\n check.details = {\n ...check.details,\n fix_hints: fixHints,\n ...(truncated ? { fix_hints_truncated: true } : {}),\n };\n}\n/* c8 ignore stop */\n\nfunction resolveRequestedChecks(options: ValidateCommandOptions): Set<ValidateCheckName> {\n const requested = new Set<ValidateCheckName>();\n if (options.checkMetadata) {\n requested.add(\"metadata\");\n }\n if (options.checkResolution) {\n requested.add(\"resolution\");\n }\n if (options.checkLifecycle || options.checkStaleBlockers) {\n requested.add(\"lifecycle\");\n }\n if (options.checkFiles) {\n requested.add(\"files\");\n }\n if (options.checkHistoryDrift) {\n requested.add(\"history_drift\");\n }\n if (options.checkCommandReferences) {\n requested.add(\"command_references\");\n }\n if (requested.size === 0) {\n // Remediation flags without explicit --check-* flags scope the run to the\n // checks that can produce fixes: --auto-fix plans metadata/resolution\n // backfills and gated lifecycle fixes; --prune-missing needs the files\n // scan. With neither, the historical run-everything default applies.\n if (options.autoFix) {\n requested.add(\"metadata\");\n requested.add(\"resolution\");\n requested.add(\"lifecycle\");\n }\n if (options.pruneMissing) {\n requested.add(\"files\");\n }\n if (requested.size === 0) {\n requested.add(\"metadata\");\n requested.add(\"resolution\");\n requested.add(\"lifecycle\");\n requested.add(\"files\");\n requested.add(\"command_references\");\n requested.add(\"history_drift\");\n requested.add(\"format_version\");\n }\n return requested;\n }\n // Explicit check flags are respected as-is, except --prune-missing always\n // needs the files scan it acts on.\n if (options.pruneMissing) {\n requested.add(\"files\");\n }\n return requested;\n}\n\nconst DUPLICATE_ISSUE_CODE_WARNING_TOKEN = \"validate_metadata_duplicate_issue_codes\";\n\n/**\n * Project the duplicate logical issue-code findings (GH-235) into the\n * metadata-check `details` shape plus an advisory warning token. Duplicate\n * codes are advisory (warn), never an error — matching every other metadata\n * finding — so an otherwise clean tracker that simply reuses a title prefix is\n * not failed by `pm validate`. Kept outside the c8-ignored builder block so the\n * projection/remediation logic is fully covered by unit tests.\n */\nfunction summarizeDuplicateIssueCodes(\n duplicates: DuplicateIssueCode[],\n verboseDiagnostics: boolean,\n): { rows: Array<Record<string, unknown>>; truncated: boolean; warnings: string[] } {\n if (duplicates.length === 0) {\n return { rows: [], truncated: false, warnings: [] };\n }\n const limit = verboseDiagnostics ? duplicates.length : DIAGNOSTIC_LIST_SUMMARY_LIMIT;\n const shown = duplicates.slice(0, limit);\n const rows = shown.map((duplicate) => ({\n code: duplicate.code,\n count: duplicate.count,\n ids: duplicate.ids,\n titles: duplicate.titles,\n remediation_hint: `Items ${duplicate.ids.join(\", \")} share issue code \"${duplicate.code}\"; rename or merge so each logical code maps to one item.`,\n }));\n return {\n rows,\n truncated: shown.length < duplicates.length,\n warnings: [`${DUPLICATE_ISSUE_CODE_WARNING_TOKEN}:${duplicates.length}`],\n };\n}\n\nfunction initializeMissingMetadataByField(): Record<ValidateMetadataRequiredField, string[]> {\n return Object.fromEntries(\n SUPPORTED_METADATA_REQUIRED_FIELDS.map((field) => [field, [] as string[]]),\n ) as Record<ValidateMetadataRequiredField, string[]>;\n}\n\nfunction collectMissingMetadataByField(\n items: ItemWithBody[],\n statusRegistry: RuntimeStatusRegistry,\n enforcePlanningFieldsOnTerminal: boolean,\n): Record<ValidateMetadataRequiredField, string[]> {\n const missingByField = initializeMissingMetadataByField();\n for (const item of items) {\n for (const field of SUPPORTED_METADATA_REQUIRED_FIELDS) {\n if (isMetadataFieldMissing(item, field, statusRegistry, enforcePlanningFieldsOnTerminal)) {\n missingByField[field].push(item.id);\n }\n }\n }\n return missingByField;\n}\n\nfunction buildMetadataWarningTokens(\n metadataPolicy: ValidateMetadataPolicy,\n missingByField: Record<ValidateMetadataRequiredField, string[]>,\n duplicateWarnings: string[],\n): string[] {\n const warningTokens = [...metadataPolicy.warnings];\n for (const field of metadataPolicy.required_fields) {\n const missingItems = missingByField[field];\n if (missingItems.length > 0) {\n warningTokens.push(`${METADATA_WARNING_TOKEN_BY_FIELD[field]}:${missingItems.length}`);\n }\n }\n warningTokens.push(...duplicateWarnings);\n return warningTokens;\n}\n\nfunction buildMetadataCounts(\n metadataPolicy: ValidateMetadataPolicy,\n missingByField: Record<ValidateMetadataRequiredField, string[]>,\n): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const field of metadataPolicy.required_fields) {\n const missing = missingByField[field];\n const value = missing ? missing.length : 0;\n const countKey = METADATA_COUNT_KEY_BY_FIELD[field];\n if (value > 0 && countKey) {\n counts[countKey] = value;\n }\n }\n return counts;\n}\n\nfunction buildMissingFieldOccurrences(\n metadataPolicy: ValidateMetadataPolicy,\n missingByField: Record<ValidateMetadataRequiredField, string[]>,\n itemsById: Map<string, ItemWithBody>,\n): MissingFieldOccurrence[] {\n const occurrences: MissingFieldOccurrence[] = [];\n for (const field of metadataPolicy.required_fields) {\n const missing = missingByField[field];\n if (!missing) {\n continue;\n }\n for (const itemId of missing) {\n const itemType = itemsById.get(itemId)?.type;\n const normalizedItemType = typeof itemType === \"string\" && itemType.length > 0 ? itemType : \"Unknown\";\n occurrences.push({ item_type: normalizedItemType, field });\n }\n }\n return occurrences;\n}\n\n/* v8 ignore start -- metadata policy keys are validated before this summarizer; fallback branches are defensive */\nfunction attachMissingMetadataItemIds(\n details: Record<string, unknown>,\n metadataPolicy: ValidateMetadataPolicy,\n missingByField: Record<ValidateMetadataRequiredField, string[]>,\n verboseDiagnostics: boolean,\n): void {\n for (const field of metadataPolicy.required_fields) {\n const missing = missingByField[field];\n if (!missing || missing.length === 0) {\n continue;\n }\n const idsKey = METADATA_ITEM_IDS_KEY_BY_FIELD[field];\n const truncatedKey = METADATA_TRUNCATED_KEY_BY_FIELD[field];\n if (!idsKey || !truncatedKey) {\n continue;\n }\n const summarized = summarizeList(missing, verboseDiagnostics ? missing.length : DIAGNOSTIC_LIST_SUMMARY_LIMIT);\n details[idsKey] = summarized.values;\n details[truncatedKey] = summarized.truncated;\n }\n}\n/* v8 ignore stop */\n\nfunction buildCloseReasonBackfillRows(\n metadataPolicy: ValidateMetadataPolicy,\n missingByField: Record<ValidateMetadataRequiredField, string[]>,\n itemsById: Map<string, ItemWithBody>,\n): CloseReasonBackfillRow[] {\n if (!metadataPolicy.required_fields.includes(\"close_reason\")) {\n return [];\n }\n const missing = missingByField.close_reason;\n if (!missing) {\n return [];\n }\n return missing.map((itemId) => ({\n id: itemId,\n resolution: toNonEmptyStringOrUndefined(itemsById.get(itemId)?.resolution),\n }));\n}\n\nfunction buildEstimateBackfillRows(\n metadataPolicy: ValidateMetadataPolicy,\n missingByField: Record<ValidateMetadataRequiredField, string[]>,\n itemsById: Map<string, ItemWithBody>,\n): EstimateBackfillRow[] {\n if (!metadataPolicy.required_fields.includes(\"estimated_minutes\")) {\n return [];\n }\n const missing = missingByField.estimated_minutes;\n if (!missing) {\n return [];\n }\n return missing.map((itemId) => ({\n id: itemId,\n type: toNonEmptyStringOrUndefined(itemsById.get(itemId)?.type),\n }));\n}\n\n/* c8 ignore start -- metadata diagnostics/backfill planning permutations are covered by validate integration suites */\nfunction buildMetadataCheck(\n items: ItemWithBody[],\n metadataPolicy: ValidateMetadataPolicy,\n statusRegistry: RuntimeStatusRegistry,\n verboseDiagnostics: boolean,\n): {\n check: ValidateCheck;\n warnings: string[];\n closeReasonBackfillRows: CloseReasonBackfillRow[];\n estimateBackfillRows: EstimateBackfillRow[];\n} {\n const itemsById = new Map(items.map((item) => [item.id, item]));\n\n // GH-276: only the `strict` profile enforces planning fields on terminal\n // (closed/canceled) historical items; core/minimal/custom profiles treat a\n // retired item's missing estimate or acceptance criteria as resolved.\n const enforcePlanningFieldsOnTerminal = metadataPolicy.profile === \"strict\";\n const missingByField = collectMissingMetadataByField(items, statusRegistry, enforcePlanningFieldsOnTerminal);\n\n // Duplicate logical issue-code detection (GH-235): advisory warning when two\n // or more items share a leading title issue code (e.g. `ISSUE-004`).\n const duplicateIssueCodes = findDuplicateIssueCodes(items);\n const duplicateIssueCodeSummary = summarizeDuplicateIssueCodes(duplicateIssueCodes, verboseDiagnostics);\n const warningTokens = buildMetadataWarningTokens(metadataPolicy, missingByField, duplicateIssueCodeSummary.warnings);\n\n // Zero-suppress counts to reduce agent token cost (telemetry pm-tylj).\n // Only emit counts for the ACTIVE required fields of the resolved profile so a\n // looser profile (e.g. core) never reports missing reviewer/risk/sprint/etc.\n // Defensive guards (Gemini high #1, PR #78 follow-up): a future settings\n // shape could include an unsupported field in required_fields — fall back\n // to 0 instead of throwing TypeError, and skip writing when the count-key\n // mapping is undefined.\n const counts = buildMetadataCounts(metadataPolicy, missingByField);\n // Per-item-type grouping of missing required-field counts (pm-pmyq /\n // GH-172): counts only — never row dumps — and only for the ACTIVE required\n // fields, so the grouping mirrors `counts` at type granularity (e.g.\n // `{ Task: { close_reason: 3 } }`). Zero-suppressed at both levels.\n const missingFieldOccurrences = buildMissingFieldOccurrences(metadataPolicy, missingByField, itemsById);\n const missingByType = buildMissingByTypeCounts(missingFieldOccurrences);\n const details: Record<string, unknown> = {\n checked_items: items.length,\n metadata_profile: metadataPolicy.profile,\n metadata_profile_source: metadataPolicy.profile_source,\n metadata_profile_fallback_to_core: metadataPolicy.fallback_to_core,\n required_fields: [...metadataPolicy.required_fields],\n supported_required_fields: [...SUPPORTED_METADATA_REQUIRED_FIELDS],\n counts,\n missing_by_type: missingByType,\n duplicate_issue_codes_count: duplicateIssueCodes.length,\n duplicate_issue_codes: duplicateIssueCodeSummary.rows,\n duplicate_issue_codes_truncated: duplicateIssueCodeSummary.truncated,\n };\n if (metadataPolicy.configured_custom_fields.length > 0) {\n details.configured_custom_required_fields = [...metadataPolicy.configured_custom_fields];\n }\n\n // Only emit per-field item_ids/truncated keys for the ACTIVE required fields of\n // the resolved profile (and only when there are missing items). This stops a\n // looser profile (e.g. core) from emitting the identical full ID array for\n // reviewer/risk/confidence/sprint/release that it does not even require\n // (pm-edge #2 — ~150 redundant lines per validate run on minimal/core).\n // Defensive guard (Gemini high #2, PR #78 follow-up): same optional-chain\n // safety as the counts loop above — never throw if a future settings shape\n // includes an unsupported field.\n attachMissingMetadataItemIds(details, metadataPolicy, missingByField, verboseDiagnostics);\n\n // Auto-fix planning input (pm-c3sz): closed items flagged for a missing\n // close_reason whose resolution can serve as the derivable source value.\n // Only collected when close_reason is an active required field, so fixes\n // always trace back to an actual finding of this run.\n const closeReasonBackfillRows = buildCloseReasonBackfillRows(metadataPolicy, missingByField, itemsById);\n\n // Estimate auto-fix planning input (GH-212): items flagged for a missing\n // estimated_minutes whose type drives the config-driven default backfill.\n // Only collected when estimated_minutes is an active required field, so fixes\n // always trace back to an actual finding of this run.\n const estimateBackfillRows = buildEstimateBackfillRows(metadataPolicy, missingByField, itemsById);\n\n return {\n check: {\n name: \"metadata\",\n status: warningTokens.length === 0 ? \"ok\" : \"warn\",\n details,\n },\n warnings: warningTokens,\n closeReasonBackfillRows,\n estimateBackfillRows,\n };\n}\n/* c8 ignore stop */\n\nfunction buildResolutionCheck(\n items: ItemWithBody[],\n statusRegistry: RuntimeStatusRegistry,\n verboseDiagnostics: boolean,\n): { check: ValidateCheck; warnings: string[]; resolutionBackfillRows: ResolutionBackfillRow[] } {\n const terminalDoneStatuses = new Set<string>(statusRegistry.terminal_done_statuses);\n terminalDoneStatuses.add(statusRegistry.close_status);\n const closedItems = items.filter((item) => terminalDoneStatuses.has(normalizeStatusForRegistry(item.status, statusRegistry)));\n const missingResolutionRows: Array<{ id: string; missing_fields: ResolutionFieldKey[] }> = [];\n const resolutionBackfillRows: ResolutionBackfillRow[] = [];\n\n for (const item of closedItems) {\n const missingFields = RESOLUTION_FIELD_KEYS.filter((field) => !toNonEmptyStringOrUndefined(item[field]));\n if (missingFields.length === 0) {\n continue;\n }\n missingResolutionRows.push({\n id: item.id,\n missing_fields: missingFields,\n });\n // Auto-fix planning input (pm-c3sz): the planner backfills only the\n // `resolution` field, deriving from the item's close_reason when present.\n resolutionBackfillRows.push({\n id: item.id,\n missing_fields: missingFields,\n close_reason: toNonEmptyStringOrUndefined(item.close_reason),\n });\n }\n\n const warnings =\n missingResolutionRows.length > 0 ? [`validate_resolution_missing_fields:${missingResolutionRows.length}`] : [];\n const diagnosticLimit = verboseDiagnostics ? Number.POSITIVE_INFINITY : DIAGNOSTIC_LIST_SUMMARY_LIMIT;\n const summarizedRows = summarizeList(\n missingResolutionRows.map((row) => `${row.id}:${row.missing_fields.join(\",\")}`),\n diagnosticLimit,\n );\n const remediationHints = missingResolutionRows.map((row) => buildResolutionRemediationCommand(row));\n const summarizedHints = summarizeList(remediationHints, diagnosticLimit);\n return {\n check: {\n name: \"resolution\",\n status: warnings.length === 0 ? \"ok\" : \"warn\",\n details: {\n checked_closed_items: closedItems.length,\n missing_resolution_items: missingResolutionRows.length,\n missing_resolution_rows: summarizedRows.values,\n missing_resolution_rows_truncated: summarizedRows.truncated,\n missing_resolution_remediation_hints: summarizedHints.values,\n missing_resolution_remediation_hints_truncated: summarizedHints.truncated,\n },\n },\n warnings,\n resolutionBackfillRows,\n };\n}\n\n/* c8 ignore start -- lifecycle dependency-graph cycle analysis is covered by lifecycle integration fixtures */\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction buildLifecycleDependencyGraph(activeItems: ItemWithBody[], idPrefix = \"pm\"): Map<string, string[]> {\n const activeItemIds = new Set(activeItems.map((item) => item.id));\n const graph = new Map<string, string[]>();\n const sortedItems = [...activeItems].sort((left, right) => left.id.localeCompare(right.id));\n for (const item of sortedItems) {\n const edges = new Set<string>();\n const blockedBy = toMeaningfulString(item.blocked_by);\n if (blockedBy && activeItemIds.has(blockedBy)) {\n edges.add(blockedBy);\n }\n for (const dependency of item.dependencies ?? []) {\n const dependencyId = toMeaningfulString(dependency.id);\n if (!dependencyId || !activeItemIds.has(dependencyId)) {\n continue;\n }\n edges.add(dependencyId);\n }\n const definitionOfReady = toMeaningfulString(item.definition_of_ready);\n if (definitionOfReady) {\n for (const referencedId of extractItemIds(definitionOfReady, idPrefix)) {\n if (activeItemIds.has(referencedId)) {\n edges.add(referencedId);\n }\n }\n }\n graph.set(item.id, [...edges].sort((left, right) => left.localeCompare(right)));\n }\n return graph;\n}\n/* c8 ignore stop */\n\nfunction extractItemIds(value: string, idPrefix = \"pm\"): string[] {\n const normalizedPrefix = (idPrefix.trim().toLowerCase() || \"pm\").replace(/-+$/g, \"\");\n const pattern = new RegExp(`(?:^|[^a-z0-9-])(${escapeRegExp(normalizedPrefix)}-[a-z0-9][a-z0-9-]*)`, \"gi\");\n return [...new Set([...value.matchAll(pattern)].map((match) => match[1]!.toLowerCase()))].sort(\n (left, right) => left.localeCompare(right),\n );\n}\n\n/* c8 ignore start -- Tarjan SCC traversal branch matrix is covered by lifecycle cycle integration fixtures */\nfunction findLifecycleDependencyCycleComponents(graph: Map<string, string[]>): string[][] {\n let nextIndex = 0;\n const indexById = new Map<string, number>();\n const lowLinkById = new Map<string, number>();\n const stack: string[] = [];\n const inStack = new Set<string>();\n const components: string[][] = [];\n\n const visit = (id: string): void => {\n indexById.set(id, nextIndex);\n lowLinkById.set(id, nextIndex);\n nextIndex += 1;\n stack.push(id);\n inStack.add(id);\n\n for (const dependencyId of graph.get(id) ?? []) {\n if (!indexById.has(dependencyId)) {\n visit(dependencyId);\n lowLinkById.set(id, Math.min(lowLinkById.get(id)!, lowLinkById.get(dependencyId)!));\n } else if (inStack.has(dependencyId)) {\n lowLinkById.set(id, Math.min(lowLinkById.get(id)!, indexById.get(dependencyId)!));\n }\n }\n\n if (lowLinkById.get(id) !== indexById.get(id)) {\n return;\n }\n const component: string[] = [];\n while (stack.length > 0) {\n const member = stack.pop()!;\n inStack.delete(member);\n component.push(member);\n if (member === id) {\n break;\n }\n }\n component.sort((left, right) => left.localeCompare(right));\n components.push(component);\n };\n\n const sortedNodeIds = [...graph.keys()].sort((left, right) => left.localeCompare(right));\n for (const id of sortedNodeIds) {\n if (!indexById.has(id)) {\n visit(id);\n }\n }\n\n const cycleComponents = components.filter((component) => {\n if (component.length > 1) {\n return true;\n }\n const selfId = component[0];\n return (graph.get(selfId) ?? []).includes(selfId);\n });\n return cycleComponents.sort(\n (left, right) =>\n left[0].localeCompare(right[0]) ||\n left.length - right.length ||\n left.join(\",\").localeCompare(right.join(\",\")),\n );\n}\n/* c8 ignore stop */\n\n/* c8 ignore start -- cycle sample-path fallback branches are covered by lifecycle graph integration tests */\nfunction resolveLifecycleDependencyCycleSamplePath(component: string[], graph: Map<string, string[]>): string[] {\n const start = component[0];\n if (component.length === 1) {\n return [start, start];\n }\n const componentSet = new Set(component);\n const path: string[] = [start];\n const visited = new Set<string>([start]);\n\n const search = (current: string): boolean => {\n const neighbors = (graph.get(current) ?? []).filter((candidate) => componentSet.has(candidate));\n for (const next of neighbors) {\n if (next === start && path.length > 1) {\n path.push(start);\n return true;\n }\n if (visited.has(next)) {\n continue;\n }\n visited.add(next);\n path.push(next);\n if (search(next)) {\n return true;\n }\n path.pop();\n visited.delete(next);\n }\n return false;\n };\n\n if (search(start)) {\n return [...path];\n }\n return [...component, start];\n}\n/* c8 ignore stop */\n\nfunction detectLifecycleDependencyCycles(activeItems: ItemWithBody[], idPrefix = \"pm\"): {\n cycle_count: number;\n cycle_item_ids: string[];\n cycle_sample_paths: string[];\n} {\n const graph = buildLifecycleDependencyGraph(activeItems, idPrefix);\n const cycleComponents = findLifecycleDependencyCycleComponents(graph);\n const cycleItemIds = [...new Set(cycleComponents.flat())].sort((left, right) => left.localeCompare(right));\n const cycleSamplePaths = cycleComponents.map((component) =>\n resolveLifecycleDependencyCycleSamplePath(component, graph).join(\"->\"),\n );\n return {\n cycle_count: cycleComponents.length,\n cycle_item_ids: cycleItemIds,\n cycle_sample_paths: cycleSamplePaths,\n };\n}\n\n// Parent (composition) cycle detection (pm-8vul / GH-280). The dependency-cycle\n// path above only walks blocked_by/definition_of_ready edges across ACTIVE items;\n// it never traverses item.parent, so a parent cycle (A.parent=B, B.parent=A, or\n// any longer ring) goes undetected while it silently breaks `pm list --tree`,\n// orphan detection, and progress rollups. We reuse the generic Tarjan SCC helper\n// on a child->[parent] adjacency map. Unlike dependency cycles we scan ALL items\n// (not just active ones) because a parent cycle among closed items is still\n// structural corruption of the hierarchy.\nfunction buildLifecycleParentGraph(items: ItemWithBody[]): Map<string, string[]> {\n // PR #279 made parent matching case-insensitive (e.g. `parent: PM-FK49`\n // resolves to `id: pm-fk49`). Resolve parent references to their canonical\n // item id the same way so a casing mismatch can never silently drop a cycle\n // edge and hide a parent cycle (false negative).\n const canonicalIdByLowercase = new Map(items.map((item) => [item.id.toLowerCase(), item.id]));\n const graph = new Map<string, string[]>();\n const sortedItems = [...items].sort((left, right) => left.id.localeCompare(right.id));\n for (const item of sortedItems) {\n const edges: string[] = [];\n const parentId = toMeaningfulString(item.parent);\n const canonicalParentId = parentId ? canonicalIdByLowercase.get(parentId.toLowerCase()) : undefined;\n if (canonicalParentId) {\n edges.push(canonicalParentId);\n }\n graph.set(item.id, edges);\n }\n return graph;\n}\n\nfunction detectLifecycleParentCycles(items: ItemWithBody[]): {\n cycle_count: number;\n cycle_item_ids: string[];\n cycle_sample_paths: string[];\n} {\n const graph = buildLifecycleParentGraph(items);\n const cycleComponents = findLifecycleDependencyCycleComponents(graph);\n const cycleItemIds = [...new Set(cycleComponents.flat())].sort((left, right) => left.localeCompare(right));\n const cycleSamplePaths = cycleComponents.map((component) =>\n resolveLifecycleDependencyCycleSamplePath(component, graph).join(\"->\"),\n );\n return {\n cycle_count: cycleComponents.length,\n cycle_item_ids: cycleItemIds,\n cycle_sample_paths: cycleSamplePaths,\n };\n}\n\ninterface OrphanedPathRow {\n path: string;\n classification: OrphanedPathClassification;\n owner_candidate: {\n id: string;\n type: string;\n title: string;\n status: string;\n confidence: \"path_prefix\" | \"same_directory\" | \"shared_directory\";\n } | null;\n remediation_hint: string;\n}\n\nfunction classifyOrphanedPath(pathValue: string): OrphanedPathClassification {\n if (pathValue.startsWith(\"docs/\")) {\n return \"docs_unowned\";\n }\n if (pathValue.startsWith(\"tests/\")) {\n return \"tests_unowned\";\n }\n if (pathValue.startsWith(\"src/\")) {\n return \"source_unowned\";\n }\n if (pathValue.endsWith(\".md\")) {\n return \"docs_unowned\";\n }\n return \"unlinked_existing\";\n}\n\nfunction directoryOf(relativePath: string): string {\n const slash = relativePath.lastIndexOf(\"/\");\n return slash === -1 ? \"\" : relativePath.slice(0, slash);\n}\n\nfunction sharedDirectoryPrefixLength(left: string, right: string): number {\n const leftParts = directoryOf(left).split(\"/\").filter(Boolean);\n const rightParts = directoryOf(right).split(\"/\").filter(Boolean);\n let count = 0;\n while (count < leftParts.length && count < rightParts.length && leftParts[count] === rightParts[count]) {\n count += 1;\n }\n return count;\n}\n\ninterface OrphanOwnerCandidateScore {\n score: number;\n confidence: \"path_prefix\" | \"same_directory\" | \"shared_directory\";\n}\n\nfunction scoreOrphanOwnerCandidate(pathValue: string, linkedPath: string): OrphanOwnerCandidateScore | null {\n const linkedDir = directoryOf(linkedPath);\n const orphanDir = directoryOf(pathValue);\n const directoryPrefix = linkedPath.endsWith(\"/\") ? linkedPath : `${linkedPath}/`;\n const isDirectoryPrefix = pathValue.startsWith(directoryPrefix);\n const sameDirectory = linkedDir.length > 0 && linkedDir === orphanDir;\n const sharedPrefixLength = sharedDirectoryPrefixLength(pathValue, linkedPath);\n if (!isDirectoryPrefix && !sameDirectory && sharedPrefixLength === 0) {\n return null;\n }\n if (isDirectoryPrefix) {\n return { score: linkedPath.length + 1000, confidence: \"path_prefix\" };\n }\n return sameDirectory\n ? { score: sharedPrefixLength + 500, confidence: \"same_directory\" }\n : { score: sharedPrefixLength, confidence: \"shared_directory\" };\n}\n\nfunction shouldReplaceOrphanOwnerCandidate(\n best: { item: ItemWithBody; score: number } | undefined,\n item: ItemWithBody,\n score: number,\n): boolean {\n return best === undefined || score > best.score || (score === best.score && item.id.localeCompare(best.item.id) < 0);\n}\n\nfunction findOrphanOwnerCandidate(\n pathValue: string,\n classification: OrphanedPathClassification,\n items: readonly ItemWithBody[],\n): OrphanedPathRow[\"owner_candidate\"] {\n const linkKind = classification === \"docs_unowned\" ? \"docs\" : \"files\";\n let best:\n | {\n item: ItemWithBody;\n score: number;\n confidence: \"path_prefix\" | \"same_directory\" | \"shared_directory\";\n }\n | undefined;\n for (const item of items) {\n const links = linkKind === \"docs\" ? item.docs ?? [] : item.files ?? [];\n for (const link of links) {\n if (link.scope !== \"project\") {\n continue;\n }\n const linkedPath = normalizeRelativePath(link.path);\n if (linkedPath.length === 0 || linkedPath === pathValue) {\n continue;\n }\n const scored = scoreOrphanOwnerCandidate(pathValue, linkedPath);\n if (scored === null) {\n continue;\n }\n if (shouldReplaceOrphanOwnerCandidate(best, item, scored.score)) {\n best = {\n item,\n score: scored.score,\n confidence: scored.confidence,\n };\n }\n }\n }\n if (!best) {\n return null;\n }\n return {\n id: best.item.id,\n type: best.item.type,\n title: best.item.title,\n status: best.item.status,\n confidence: best.confidence,\n };\n}\n\nfunction buildOrphanedPathRows(orphanedFiles: readonly string[], items: readonly ItemWithBody[]): OrphanedPathRow[] {\n return orphanedFiles.map((pathValue) => {\n const classification = classifyOrphanedPath(pathValue);\n const linkCommand = classification === \"docs_unowned\" ? \"docs\" : \"files\";\n const ownerCandidate = findOrphanOwnerCandidate(pathValue, classification, items);\n const target = ownerCandidate?.id ?? \"<id>\";\n return {\n path: pathValue,\n classification,\n owner_candidate: ownerCandidate,\n remediation_hint: `pm ${linkCommand} ${target} --add path=${pathValue},scope=project,note=\"<why this artifact belongs to the item>\"`,\n };\n });\n}\n\nfunction summarizeOrphanedPathRows(rows: readonly OrphanedPathRow[]): string[] {\n return rows.map(\n (row) =>\n `${row.path}:${row.classification} owner_candidate=${row.owner_candidate?.id ?? \"unowned\"} hint=${JSON.stringify(row.remediation_hint)}`,\n );\n}\n\ninterface LifecycleScanRows {\n activeItems: ItemWithBody[];\n closureLikeRows: Array<{ id: string; fields: string[] }>;\n terminalParentRows: Array<{ id: string; parent_id: string; parent_status: string }>;\n terminalParentFixRows: TerminalParentFixRow[];\n staleBlockerRows: Array<{ id: string; status: string; reasons: string[] }>;\n}\n\nfunction closureLikeFieldsForItem(item: ItemWithBody, lifecyclePatternPolicy: LifecyclePatternPolicy): string[] {\n return Object.entries(lifecyclePatternPolicy.closure_like_metadata_field_patterns)\n .filter(([field, patterns]) => {\n const value = toMeaningfulString(item[field as keyof ItemWithBody]);\n return value ? patterns.some((pattern) => value.toLowerCase().includes(pattern)) : false;\n })\n .map(([field]) => field)\n .sort((left, right) => left.localeCompare(right));\n}\n\nfunction buildTerminalParentFixRow(\n item: ItemWithBody,\n parent: ItemWithBody,\n itemsById: Map<string, ItemWithBody>,\n canonicalIdByLowercase: Map<string, string>,\n statusRegistry: RuntimeStatusRegistry,\n): TerminalParentFixRow {\n const grandparentId = toMeaningfulString(parent.parent);\n const grandparent = grandparentId\n ? itemsById.get(canonicalIdByLowercase.get(grandparentId.toLowerCase()) ?? grandparentId)\n : undefined;\n return {\n id: item.id,\n parent_id: parent.id,\n grandparent_id: grandparent?.id,\n grandparent_active: grandparent !== undefined && !isTerminalStatus(grandparent.status, statusRegistry),\n };\n}\n\n/* v8 ignore start -- stale-blocker reason variants are covered through command-level diagnostics; helper branch counters are defensive */\nfunction staleBlockerReasonsForItem(\n item: ItemWithBody,\n blockedStatuses: Set<string>,\n statusRegistry: RuntimeStatusRegistry,\n lifecyclePatternPolicy: LifecyclePatternPolicy,\n): string[] {\n const blockedBy = toMeaningfulString(item.blocked_by);\n const blockedReason = toMeaningfulString(item.blocked_reason);\n const blockedReasonNormalized = blockedReason?.toLowerCase();\n const normalizedStatus = normalizeStatusForRegistry(item.status, statusRegistry);\n const reasons: string[] = [];\n if (!blockedStatuses.has(normalizedStatus)) {\n if (blockedBy) {\n reasons.push(\"non_blocked_status_has_blocked_by\");\n }\n if (blockedReason) {\n reasons.push(\"non_blocked_status_has_blocked_reason\");\n }\n return reasons;\n }\n if (!blockedBy && !blockedReason) {\n /* v8 ignore start -- blocked-status creation paths seed either blocked_by or blocked_reason before lifecycle validation */\n reasons.push(\"blocked_status_missing_blocker_context\");\n /* v8 ignore stop */\n }\n if (blockedReasonNormalized?.includes(\"no active blocker\")) {\n reasons.push(\"blocked_status_reason_reports_no_active_blocker\");\n }\n if (\n blockedReasonNormalized &&\n lifecyclePatternPolicy.stale_blocker_reason_patterns.some((pattern) => blockedReasonNormalized.includes(pattern))\n ) {\n reasons.push(\"blocked_status_reason_matches_stale_pattern\");\n }\n return reasons;\n}\n/* v8 ignore stop */\n\nfunction collectLifecycleScanRows(\n items: ItemWithBody[],\n includeStaleBlockers: boolean,\n statusRegistry: RuntimeStatusRegistry,\n lifecyclePatternPolicy: LifecyclePatternPolicy,\n): LifecycleScanRows {\n const itemsById = new Map(items.map((item) => [item.id, item]));\n const canonicalIdByLowercase = new Map(items.map((item) => [item.id.toLowerCase(), item.id]));\n /* v8 ignore start -- runtime status registry normally supplies blocked statuses; fallback preserves legacy settings safety */\n const blockedStatuses =\n statusRegistry.blocked_statuses.size > 0 ? statusRegistry.blocked_statuses : new Set<string>([\"blocked\"]);\n /* v8 ignore stop */\n const rows: LifecycleScanRows = {\n activeItems: items.filter((item) => !isTerminalStatus(item.status, statusRegistry)),\n closureLikeRows: [],\n terminalParentRows: [],\n terminalParentFixRows: [],\n staleBlockerRows: [],\n };\n for (const item of rows.activeItems) {\n const closureLikeFields = closureLikeFieldsForItem(item, lifecyclePatternPolicy);\n if (closureLikeFields.length > 0) {\n rows.closureLikeRows.push({ id: item.id, fields: closureLikeFields });\n }\n const parentId = toMeaningfulString(item.parent);\n const parent = parentId ? itemsById.get(canonicalIdByLowercase.get(parentId.toLowerCase()) ?? parentId) : undefined;\n if (parent && isTerminalStatus(parent.status, statusRegistry)) {\n rows.terminalParentRows.push({ id: item.id, parent_id: parent.id, parent_status: parent.status });\n rows.terminalParentFixRows.push(buildTerminalParentFixRow(item, parent, itemsById, canonicalIdByLowercase, statusRegistry));\n }\n /* v8 ignore start -- stale-blocker reason presence is covered by command diagnostics; branch accounting here is defensive */\n if (includeStaleBlockers) {\n const reasons = staleBlockerReasonsForItem(item, blockedStatuses, statusRegistry, lifecyclePatternPolicy);\n if (reasons.length > 0) {\n rows.staleBlockerRows.push({\n id: item.id,\n status: item.status,\n reasons: [...new Set(reasons)].sort((left, right) => left.localeCompare(right)),\n });\n }\n }\n /* v8 ignore stop */\n }\n return rows;\n}\n\nfunction sortLifecycleScanRows(rows: LifecycleScanRows): void {\n rows.closureLikeRows.sort((left, right) => left.id.localeCompare(right.id));\n /* v8 ignore start -- parent-id tie breakers only matter for duplicate legacy ids, which the tracker writer prevents */\n rows.terminalParentRows.sort(\n (left, right) => left.id.localeCompare(right.id) || left.parent_id.localeCompare(right.parent_id),\n );\n rows.terminalParentFixRows.sort(\n (left, right) => left.id.localeCompare(right.id) || left.parent_id.localeCompare(right.parent_id),\n );\n /* v8 ignore stop */\n rows.staleBlockerRows.sort((left, right) => left.id.localeCompare(right.id));\n}\n\nfunction lifecycleCycleWarningToken(\n prefix: \"validate_lifecycle_dependency_cycles\" | \"validate_hierarchy_parent_cycle\",\n severity: ValidateDependencyCycleSeverity,\n count: number,\n): string | null {\n if (count <= 0 || severity === \"off\") {\n return null;\n }\n return `${severity === \"error\" ? `${prefix}_error` : prefix}:${count}`;\n}\n\nfunction buildLifecycleWarnings(\n rows: LifecycleScanRows,\n includeStaleBlockers: boolean,\n dependencyCycleSeverity: ValidateDependencyCycleSeverity,\n parentCycleSeverity: ValidateDependencyCycleSeverity,\n dependencyCycleCount: number,\n parentCycleCount: number,\n): string[] {\n const warnings: string[] = [];\n if (rows.closureLikeRows.length > 0) {\n warnings.push(`validate_lifecycle_active_closure_like_metadata:${rows.closureLikeRows.length}`);\n }\n if (rows.terminalParentRows.length > 0) {\n warnings.push(`validate_lifecycle_active_terminal_parent:${rows.terminalParentRows.length}`);\n }\n if (includeStaleBlockers && rows.staleBlockerRows.length > 0) {\n warnings.push(`validate_lifecycle_stale_blockers:${rows.staleBlockerRows.length}`);\n }\n const dependencyWarning = lifecycleCycleWarningToken(\n \"validate_lifecycle_dependency_cycles\",\n dependencyCycleSeverity,\n dependencyCycleCount,\n );\n const parentWarning = lifecycleCycleWarningToken(\"validate_hierarchy_parent_cycle\", parentCycleSeverity, parentCycleCount);\n return [...warnings, ...(dependencyWarning ? [dependencyWarning] : []), ...(parentWarning ? [parentWarning] : [])];\n}\n\ninterface LinkedPathScanState {\n linkedProjectPaths: Set<string>;\n remoteLinkedPaths: Set<string>;\n missingLinkedPaths: string[];\n staleLinkRows: Array<{ item_id: string; path: string; link_kind: \"files\" | \"docs\" }>;\n}\n\nasync function linkedArtifactIsMissing(workspaceRoot: string, artifactPath: string): Promise<boolean> {\n const absolutePath = path.isAbsolute(artifactPath) ? artifactPath : path.resolve(workspaceRoot, artifactPath);\n try {\n const stats = await fs.stat(absolutePath);\n return !stats.isFile() && !stats.isDirectory();\n } catch (error) {\n const code =\n typeof error === \"object\" && error !== null && \"code\" in error\n ? (error as { code?: unknown }).code\n : undefined;\n return code === \"ENOENT\" || code === \"ENOTDIR\";\n }\n}\n\nasync function collectLinkedPathScanState(items: ItemWithBody[], workspaceRoot: string): Promise<LinkedPathScanState> {\n const state: LinkedPathScanState = {\n linkedProjectPaths: new Set<string>(),\n remoteLinkedPaths: new Set<string>(),\n missingLinkedPaths: [],\n staleLinkRows: [],\n };\n for (const item of items) {\n const linkedArtifactGroups = [\n { link_kind: \"files\" as const, artifacts: item.files ?? [] },\n { link_kind: \"docs\" as const, artifacts: item.docs ?? [] },\n ];\n for (const group of linkedArtifactGroups) {\n for (const artifact of group.artifacts) {\n if (artifact.scope !== \"project\") {\n continue;\n }\n if (isRemoteLinkedArtifactReference(artifact.path)) {\n state.remoteLinkedPaths.add(artifact.path.trim());\n continue;\n }\n const normalizedPath = normalizeRelativePath(artifact.path);\n if (normalizedPath.length === 0) {\n continue;\n }\n state.linkedProjectPaths.add(normalizedPath);\n if (await linkedArtifactIsMissing(workspaceRoot, artifact.path)) {\n state.missingLinkedPaths.push(normalizedPath);\n state.staleLinkRows.push({ item_id: item.id, path: normalizedPath, link_kind: group.link_kind });\n }\n }\n }\n }\n return state;\n}\n\ninterface FileCandidatePartition {\n strictTrackedAllMode: boolean;\n strictModeForcesPmInternals: boolean;\n includePmInternalsEffective: boolean;\n pmInternalCandidatePrefixes: string[];\n excludedPmInternalPaths: string[];\n candidateFiles: string[];\n excludedByReason: Record<string, unknown>;\n}\n\nfunction partitionFileCandidates(\n fileCandidates: FileCandidateCollection,\n pmRoot: string,\n workspaceRoot: string,\n fileScanMode: ValidateFileScanMode,\n includePmInternals: boolean,\n verboseFileLists: boolean,\n): FileCandidatePartition {\n const strictTrackedAllMode = fileScanMode === \"tracked-all-strict\";\n const strictModeForcesPmInternals = strictTrackedAllMode && !includePmInternals;\n const includePmInternalsEffective = includePmInternals || strictTrackedAllMode;\n const pmInternalCandidatePrefixes = includePmInternalsEffective ? [] : resolvePmInternalCandidatePrefixes(pmRoot, workspaceRoot);\n const excludedPmInternalPaths =\n pmInternalCandidatePrefixes.length === 0\n ? []\n : fileCandidates.candidateFiles.filter((candidate) => hasPathPrefix(candidate, pmInternalCandidatePrefixes));\n const candidateFiles =\n pmInternalCandidatePrefixes.length === 0\n ? fileCandidates.candidateFiles\n : fileCandidates.candidateFiles.filter((candidate) => !hasPathPrefix(candidate, pmInternalCandidatePrefixes));\n const excludedByReason: Record<string, unknown> = {};\n if (excludedPmInternalPaths.length > 0) {\n const summarizedPmInternalPaths = summarizeFileList(excludedPmInternalPaths, verboseFileLists);\n excludedByReason.pm_internals = {\n count: excludedPmInternalPaths.length,\n paths: summarizedPmInternalPaths.values,\n paths_truncated: summarizedPmInternalPaths.truncated,\n paths_total: summarizedPmInternalPaths.total,\n };\n }\n return {\n strictTrackedAllMode,\n strictModeForcesPmInternals,\n includePmInternalsEffective,\n pmInternalCandidatePrefixes,\n excludedPmInternalPaths,\n candidateFiles,\n excludedByReason,\n };\n}\n\n/* c8 ignore start -- lifecycle stale/terminal/dependency diagnostics matrix is covered by end-to-end validate integration runs */\nfunction buildLifecycleCheck(\n items: ItemWithBody[],\n includeStaleBlockers: boolean,\n dependencyCycleSeverity: ValidateDependencyCycleSeverity,\n parentCycleSeverity: ValidateDependencyCycleSeverity,\n statusRegistry: RuntimeStatusRegistry,\n lifecyclePatternPolicy: LifecyclePatternPolicy,\n verboseDiagnostics: boolean,\n idPrefix = \"pm\",\n): { check: ValidateCheck; warnings: string[]; terminalParentFixRows: TerminalParentFixRow[] } {\n const rows = collectLifecycleScanRows(items, includeStaleBlockers, statusRegistry, lifecyclePatternPolicy);\n sortLifecycleScanRows(rows);\n const dependencyCycleDiagnostics = detectLifecycleDependencyCycles(rows.activeItems, idPrefix);\n const parentCycleDiagnostics = detectLifecycleParentCycles(items);\n const warnings = buildLifecycleWarnings(\n rows,\n includeStaleBlockers,\n dependencyCycleSeverity,\n parentCycleSeverity,\n dependencyCycleDiagnostics.cycle_count,\n parentCycleDiagnostics.cycle_count,\n );\n\n const diagnosticLimit = verboseDiagnostics ? Number.POSITIVE_INFINITY : DIAGNOSTIC_LIST_SUMMARY_LIMIT;\n const summarizedClosureLikeRows = summarizeList(\n rows.closureLikeRows.map((row) => `${row.id}:${row.fields.join(\",\")}`),\n diagnosticLimit,\n );\n const summarizedTerminalParentRows = summarizeList(\n rows.terminalParentRows.map((row) => `${row.id}:${row.parent_id}:${row.parent_status}`),\n diagnosticLimit,\n );\n const summarizedStaleBlockerRows = summarizeList(\n rows.staleBlockerRows.map((row) => `${row.id}:${row.status}:${row.reasons.join(\",\")}`),\n diagnosticLimit,\n );\n const summarizedDependencyCycleItemIds = summarizeList(dependencyCycleDiagnostics.cycle_item_ids, diagnosticLimit);\n const summarizedDependencyCycleSamplePaths = summarizeList(dependencyCycleDiagnostics.cycle_sample_paths, diagnosticLimit);\n const summarizedParentCycleItemIds = summarizeList(parentCycleDiagnostics.cycle_item_ids, diagnosticLimit);\n const summarizedParentCycleSamplePaths = summarizeList(parentCycleDiagnostics.cycle_sample_paths, diagnosticLimit);\n\n const hasErrorSeverityCycle =\n (dependencyCycleDiagnostics.cycle_count > 0 && dependencyCycleSeverity === \"error\") ||\n (parentCycleDiagnostics.cycle_count > 0 && parentCycleSeverity === \"error\");\n\n return {\n check: {\n name: \"lifecycle\",\n status: hasErrorSeverityCycle\n ? \"error\"\n : warnings.length === 0\n ? \"ok\"\n : \"warn\",\n details: {\n checked_active_items: rows.activeItems.length,\n active_closure_like_metadata_items: rows.closureLikeRows.length,\n active_closure_like_metadata_rows: summarizedClosureLikeRows.values,\n active_closure_like_metadata_rows_truncated: summarizedClosureLikeRows.truncated,\n active_terminal_parent_items: rows.terminalParentRows.length,\n active_terminal_parent_rows: summarizedTerminalParentRows.values,\n active_terminal_parent_rows_truncated: summarizedTerminalParentRows.truncated,\n stale_blocker_checks_enabled: includeStaleBlockers,\n stale_blocker_items: rows.staleBlockerRows.length,\n stale_blocker_rows: summarizedStaleBlockerRows.values,\n stale_blocker_rows_truncated: summarizedStaleBlockerRows.truncated,\n dependency_cycle_severity_policy: dependencyCycleSeverity,\n dependency_cycle_count: dependencyCycleDiagnostics.cycle_count,\n dependency_cycle_item_count: dependencyCycleDiagnostics.cycle_item_ids.length,\n dependency_cycle_item_ids: summarizedDependencyCycleItemIds.values,\n dependency_cycle_item_ids_truncated: summarizedDependencyCycleItemIds.truncated,\n dependency_cycle_sample_paths: summarizedDependencyCycleSamplePaths.values,\n dependency_cycle_sample_paths_truncated: summarizedDependencyCycleSamplePaths.truncated,\n parent_cycle_severity_policy: parentCycleSeverity,\n parent_cycle_count: parentCycleDiagnostics.cycle_count,\n parent_cycle_item_count: parentCycleDiagnostics.cycle_item_ids.length,\n parent_cycle_item_ids: summarizedParentCycleItemIds.values,\n parent_cycle_item_ids_truncated: summarizedParentCycleItemIds.truncated,\n parent_cycle_sample_paths: summarizedParentCycleSamplePaths.values,\n parent_cycle_sample_paths_truncated: summarizedParentCycleSamplePaths.truncated,\n stale_blocker_reason_patterns: [...lifecyclePatternPolicy.stale_blocker_reason_patterns],\n stale_blocker_reason_pattern_source: lifecyclePatternPolicy.stale_blocker_reason_pattern_source,\n closure_like_blocked_reason_patterns: [\n ...lifecyclePatternPolicy.closure_like_metadata_field_patterns.blocked_reason,\n ],\n closure_like_blocked_reason_pattern_source:\n lifecyclePatternPolicy.closure_like_metadata_field_pattern_sources.blocked_reason,\n closure_like_resolution_patterns: [...lifecyclePatternPolicy.closure_like_metadata_field_patterns.resolution],\n closure_like_resolution_pattern_source:\n lifecyclePatternPolicy.closure_like_metadata_field_pattern_sources.resolution,\n closure_like_actual_result_patterns: [...lifecyclePatternPolicy.closure_like_metadata_field_patterns.actual_result],\n closure_like_actual_result_pattern_source:\n lifecyclePatternPolicy.closure_like_metadata_field_pattern_sources.actual_result,\n },\n },\n warnings,\n terminalParentFixRows: rows.terminalParentFixRows,\n };\n}\n/* c8 ignore stop */\n\n/* c8 ignore start -- files-check candidate filtering/classification permutations are covered by file-audit integration suites */\nasync function buildFilesCheck(\n items: ItemWithBody[],\n workspaceRoot: string,\n pmRoot: string,\n fileScanMode: ValidateFileScanMode,\n includePmInternals: boolean,\n verboseFileLists: boolean,\n): Promise<{ check: ValidateCheck; warnings: string[]; staleLinkPruneRows: StaleLinkPruneRow[] }> {\n const linkedPathState = await collectLinkedPathScanState(items, workspaceRoot);\n const itemsById = new Map(items.map((item) => [item.id, item]));\n const uniqueMissingLinkedPaths = [...new Set(linkedPathState.missingLinkedPaths)].sort((left, right) => left.localeCompare(right));\n const fileCandidates = await collectProjectFileCandidates(workspaceRoot, fileScanMode);\n const partition = partitionFileCandidates(fileCandidates, pmRoot, workspaceRoot, fileScanMode, includePmInternals, verboseFileLists);\n const orphanedFiles = partition.candidateFiles.filter((candidate) => !linkedPathState.linkedProjectPaths.has(candidate));\n const orphanedPathRows = buildOrphanedPathRows(orphanedFiles, items);\n // Stale-path classification (pm-0v2m / GH-184): a missing linked path whose\n // basename still exists in the candidate scan is reported as `moved` (with\n // relink candidates); otherwise it is `deleted` and safe to prune.\n const classifiedStalePaths = classifyStaleLinkedPaths(uniqueMissingLinkedPaths, partition.candidateFiles);\n const classificationByPath = new Map(classifiedStalePaths.map((entry) => [entry.path, entry.classification]));\n const movedStalePathCount = classifiedStalePaths.filter((entry) => entry.classification === \"moved\").length;\n const staleLinkPruneRows: StaleLinkPruneRow[] = linkedPathState.staleLinkRows\n .map((row) => ({\n ...row,\n classification: classificationByPath.get(row.path) ?? (\"deleted\" as const),\n }))\n .sort(\n (left, right) =>\n left.item_id.localeCompare(right.item_id) ||\n left.path.localeCompare(right.path) ||\n left.link_kind.localeCompare(right.link_kind),\n );\n const warnings: string[] = [];\n if (partition.strictModeForcesPmInternals) {\n warnings.push(\"validate_files_tracked_all_strict_forces_pm_internals\");\n }\n if (uniqueMissingLinkedPaths.length > 0) {\n warnings.push(`validate_files_missing_linked_paths:${uniqueMissingLinkedPaths.length}`);\n }\n if (orphanedFiles.length > 0) {\n warnings.push(`validate_files_orphaned_paths:${orphanedFiles.length}`);\n }\n const uniqueRemoteLinkedPaths = [...linkedPathState.remoteLinkedPaths].sort((left, right) => left.localeCompare(right));\n const summarizedRemote = summarizeFileList(uniqueRemoteLinkedPaths, verboseFileLists);\n const summarizedMissing = summarizeFileList(uniqueMissingLinkedPaths, verboseFileLists);\n const summarizedOrphaned = summarizeFileList(orphanedFiles, verboseFileLists);\n const summarizedOrphanedClassifications = summarizeFileList(\n orphanedPathRows.map((row) => `${row.path}:${row.classification}:owner_candidate=${row.owner_candidate?.id ?? \"unowned\"}`),\n verboseFileLists,\n );\n const orphanedPathRowDetail = verboseFileLists\n ? orphanedPathRows\n : summarizeFileList(summarizeOrphanedPathRows(orphanedPathRows), false).values;\n const summarizedClassifications = summarizeFileList(\n summarizeStaleLinkedPathClassifications(classifiedStalePaths),\n verboseFileLists,\n );\n // Owner attribution for missing linked paths (GH-210): per-path rows naming\n // the owning item(s) so cleanup is evidence-based instead of requiring a\n // reverse lookup. Full structured objects under --verbose-file-lists; compact\n // `path:classification owner=… field=…` one-liners (capped) otherwise — same\n // full/summary split as the other file-check lists (file_list_detail_mode).\n const missingLinkedPathRows: StaleLinkOwnerInput[] = staleLinkPruneRows.map((row) => ({\n item_id: row.item_id,\n path: row.path,\n link_kind: row.link_kind,\n classification: row.classification,\n }));\n const ownerRows = buildMissingLinkedPathRows(missingLinkedPathRows, (id) => {\n const owner = itemsById.get(id);\n return owner ? { type: owner.type, title: owner.title, status: owner.status } : undefined;\n });\n // Default to token-efficient compact one-liners; expose the full structured\n // rows (the GH-210 JSON shape) under --verbose-file-lists.\n const ownerRowDetail = verboseFileLists\n ? ownerRows\n : summarizeFileList(summarizeMissingLinkedPathRows(ownerRows), false).values;\n\n return {\n check: {\n name: \"files\",\n status: warnings.length === 0 ? \"ok\" : \"warn\",\n details: {\n workspace_root: workspaceRoot,\n scan_mode_requested: fileCandidates.requestedMode,\n scan_mode_applied: fileCandidates.appliedMode,\n strict_tracked_all_mode: partition.strictTrackedAllMode,\n strict_mode_forces_pm_internals: partition.strictModeForcesPmInternals,\n strict_mode_forces_pm_internals_notice: partition.strictModeForcesPmInternals\n ? \"tracked-all-strict force-enables PM internals; pass --include-pm-internals to make inclusion explicit.\"\n : null,\n file_list_detail_mode: verboseFileLists ? \"full\" : \"summary\",\n file_list_summary_limit: FILE_LIST_SUMMARY_LIMIT,\n candidate_scan_source: fileCandidates.source,\n include_pm_internals: partition.includePmInternalsEffective,\n include_pm_internals_requested: includePmInternals,\n pm_internal_candidate_prefixes: partition.pmInternalCandidatePrefixes,\n pm_internal_excluded_count: partition.excludedPmInternalPaths.length,\n excluded_total: partition.excludedPmInternalPaths.length,\n excluded_by_reason: partition.excludedByReason,\n linked_project_paths: linkedPathState.linkedProjectPaths.size,\n remote_linked_paths_count: uniqueRemoteLinkedPaths.length,\n remote_linked_paths_total: summarizedRemote.total,\n remote_linked_paths: summarizedRemote.values,\n remote_linked_paths_truncated: summarizedRemote.truncated,\n candidate_total_raw: fileCandidates.candidateTotal,\n candidate_scanned_raw: fileCandidates.candidateScanned,\n candidate_total: partition.candidateFiles.length,\n candidate_scanned: partition.candidateFiles.length,\n scanned_candidate_files: partition.candidateFiles.length,\n missing_linked_paths_count: uniqueMissingLinkedPaths.length,\n missing_linked_paths_total: summarizedMissing.total,\n missing_linked_paths: summarizedMissing.values,\n missing_linked_paths_truncated: summarizedMissing.truncated,\n missing_linked_paths_moved_count: movedStalePathCount,\n missing_linked_paths_deleted_count: uniqueMissingLinkedPaths.length - movedStalePathCount,\n missing_linked_path_classifications: summarizedClassifications.values,\n missing_linked_path_classifications_truncated: summarizedClassifications.truncated,\n missing_linked_path_rows_count: ownerRows.length,\n missing_linked_path_rows: ownerRowDetail,\n orphaned_paths_count: orphanedFiles.length,\n orphaned_paths_total: summarizedOrphaned.total,\n orphaned_paths: summarizedOrphaned.values,\n orphaned_paths_truncated: summarizedOrphaned.truncated,\n orphaned_path_classifications: summarizedOrphanedClassifications.values,\n orphaned_path_classifications_truncated: summarizedOrphanedClassifications.truncated,\n orphaned_path_rows_count: orphanedPathRows.length,\n orphaned_path_rows: orphanedPathRowDetail,\n },\n },\n warnings,\n staleLinkPruneRows,\n };\n}\n/* c8 ignore stop */\n\n/* c8 ignore start -- history-drift warning/count projection permutations are covered by drift integration tests */\nasync function buildHistoryDriftCheck(\n pmRoot: string,\n items: ItemWithBody[],\n verboseDiagnostics: boolean,\n): Promise<{ check: ValidateCheck; warnings: string[] }> {\n const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems } = await scanHistoryDrift(\n pmRoot,\n items,\n );\n const warnings: string[] = [];\n if (missingStreams.length > 0) {\n warnings.push(`validate_history_drift_missing_streams:${missingStreams.length}`);\n }\n if (unreadableStreams.length > 0) {\n warnings.push(`validate_history_drift_unreadable_streams:${unreadableStreams.length}`);\n }\n if (hashMismatches.length > 0) {\n warnings.push(`validate_history_drift_hash_mismatches:${hashMismatches.length}`);\n }\n if (chainMismatches.length > 0) {\n warnings.push(`validate_history_drift_chain_mismatches:${chainMismatches.length}`);\n }\n const diagnosticLimit = verboseDiagnostics ? Number.POSITIVE_INFINITY : DIAGNOSTIC_LIST_SUMMARY_LIMIT;\n const summarizedDrifted = summarizeList(driftedItems, diagnosticLimit);\n return {\n check: {\n name: \"history_drift\",\n status: warnings.length === 0 ? \"ok\" : \"warn\",\n details: {\n checked_items: items.length,\n drifted_items_count: driftedItems.length,\n drifted_items: summarizedDrifted.values,\n drifted_items_truncated: summarizedDrifted.truncated,\n counts: {\n missing_streams: missingStreams.length,\n unreadable_streams: unreadableStreams.length,\n hash_mismatches: hashMismatches.length,\n chain_mismatches: chainMismatches.length,\n },\n },\n },\n warnings,\n };\n}\n/* c8 ignore stop */\n\n/* c8 ignore start -- command preview truncation formatting is covered by command-reference integration fixtures */\nfunction summarizeCommandReferenceRow(ownerId: string, referencedId: string, command: string): string {\n const normalizedCommand = command.trim().replaceAll(/\\s+/g, \" \");\n const commandPreview = normalizedCommand.length > 120 ? `${normalizedCommand.slice(0, 117)}...` : normalizedCommand;\n return `${ownerId}:${referencedId}:${commandPreview}`;\n}\n/* c8 ignore stop */\n\n/* c8 ignore start -- command-reference discovery/stale-id permutations are covered by linked-test integration suites */\nfunction buildCommandReferencesCheck(\n items: ItemWithBody[],\n idPrefix: string,\n verboseDiagnostics: boolean,\n): { check: ValidateCheck; warnings: string[] } {\n const knownIds = new Set(items.map((item) => item.id.toLowerCase()));\n let linkedCommandsScanned = 0;\n let referencedPmIdCount = 0;\n const referencedPmIds = new Set<string>();\n const staleReferenceRows: string[] = [];\n\n for (const item of items) {\n for (const linkedTest of item.tests ?? []) {\n if (typeof linkedTest.command !== \"string\" || linkedTest.command.trim().length === 0) {\n continue;\n }\n linkedCommandsScanned += 1;\n const referencedIds = extractReferencedPmItemIdsFromCommand(linkedTest.command, idPrefix);\n if (referencedIds.length === 0) {\n continue;\n }\n referencedPmIdCount += referencedIds.length;\n for (const referencedId of referencedIds) {\n referencedPmIds.add(referencedId);\n if (!knownIds.has(referencedId.toLowerCase())) {\n staleReferenceRows.push(summarizeCommandReferenceRow(item.id, referencedId, linkedTest.command));\n }\n }\n }\n }\n\n const uniqueStaleReferenceRows = [...new Set(staleReferenceRows)].sort((left, right) => left.localeCompare(right));\n const stalePmIds = [...new Set(uniqueStaleReferenceRows.map((row) => row.split(\":\")[1] ?? \"\"))]\n .filter((value) => value.length > 0)\n .sort((left, right) => left.localeCompare(right));\n const warnings =\n uniqueStaleReferenceRows.length > 0 ? [`validate_command_references_stale_pm_ids:${uniqueStaleReferenceRows.length}`] : [];\n const diagnosticLimit = verboseDiagnostics ? Number.POSITIVE_INFINITY : DIAGNOSTIC_LIST_SUMMARY_LIMIT;\n const summarizedRows = summarizeList(uniqueStaleReferenceRows, diagnosticLimit);\n const summarizedStalePmIds = summarizeList(stalePmIds, diagnosticLimit);\n const summarizedReferencedPmIds = summarizeList(\n [...referencedPmIds].sort((left, right) => left.localeCompare(right)),\n diagnosticLimit,\n );\n\n return {\n check: {\n name: \"command_references\",\n status: warnings.length === 0 ? \"ok\" : \"warn\",\n details: {\n checked_items: items.length,\n linked_commands_scanned: linkedCommandsScanned,\n referenced_pm_ids_count: referencedPmIdCount,\n unique_referenced_pm_ids_count: referencedPmIds.size,\n unique_referenced_pm_ids: summarizedReferencedPmIds.values,\n unique_referenced_pm_ids_truncated: summarizedReferencedPmIds.truncated,\n stale_pm_id_references_count: uniqueStaleReferenceRows.length,\n stale_pm_ids_count: stalePmIds.length,\n stale_pm_ids: summarizedStalePmIds.values,\n stale_pm_ids_truncated: summarizedStalePmIds.truncated,\n stale_pm_id_reference_rows: summarizedRows.values,\n stale_pm_id_reference_rows_truncated: summarizedRows.truncated,\n },\n },\n warnings,\n };\n}\n/* c8 ignore stop */\n\n/* c8 ignore start -- format-version diagnostics projection is covered by validate format-version integration fixtures */\nfunction buildFormatVersionCheck(\n items: ItemWithBody[],\n verboseDiagnostics: boolean,\n): { check: ValidateCheck; warnings: string[] } {\n const scan = scanItemFormatVersions(\n items.map((item) => ({ ref: item.id, version: effectiveItemFormatVersion(item) })),\n );\n const warnings: string[] = [];\n if (scan.outdated.length > 0) {\n warnings.push(`validate_format_version_outdated_items:${scan.outdated.length}`);\n }\n if (scan.ahead.length > 0) {\n warnings.push(`validate_format_version_ahead_items:${scan.ahead.length}`);\n }\n const diagnosticLimit = verboseDiagnostics ? Number.POSITIVE_INFINITY : DIAGNOSTIC_LIST_SUMMARY_LIMIT;\n const summarizedOutdated = summarizeList(scan.outdated, diagnosticLimit);\n const summarizedAhead = summarizeList(scan.ahead, diagnosticLimit);\n // `ahead` items were written by a newer pm than this runtime: validation\n // cannot vouch for fields it does not understand, so it is an error (upgrade\n // pm). `outdated` items are a non-fatal warning (a migration would rewrite\n // them). At the current baseline version neither list is populated.\n const status: ValidateStatus = scan.ahead.length > 0 ? \"error\" : scan.outdated.length > 0 ? \"warn\" : \"ok\";\n return {\n check: {\n name: \"format_version\",\n status,\n details: {\n checked_items: items.length,\n current_format_version: CURRENT_ITEM_FORMAT_VERSION,\n outdated_items_count: scan.outdated.length,\n outdated_items: summarizedOutdated.values,\n outdated_items_truncated: summarizedOutdated.truncated,\n ahead_items_count: scan.ahead.length,\n ahead_items: summarizedAhead.values,\n ahead_items_truncated: summarizedAhead.truncated,\n },\n },\n warnings,\n };\n}\n/* c8 ignore stop */\n\nconst VALIDATE_AUTO_FIX_MESSAGE = \"pm validate auto-fix\";\n\n/**\n * Apply one planned fix through the SAME audited command paths an operator\n * would use by hand (`pm update` / `pm files --remove` / `pm docs --remove`),\n * so every applied fix carries normal history, locking, and hook behavior.\n * Command modules are imported lazily: plain validate runs stay read-only and\n * never pay the mutation-stack import cost.\n */\n/* c8 ignore start -- lazy mutation-command dispatch branches are covered by validate auto-fix integration tests */\nasync function applyValidateFix(fix: ValidateFixRecord, global: GlobalOptions): Promise<void> {\n switch (fix.kind) {\n case \"set_resolution\":\n case \"set_close_reason\":\n case \"set_estimate\":\n case \"reparent\":\n case \"unset_parent\": {\n const { runUpdate } = await import(\"./update.js\");\n const updateOptions: Record<string, unknown> = { message: VALIDATE_AUTO_FIX_MESSAGE };\n if (fix.kind === \"set_resolution\") {\n updateOptions.resolution = fix.value;\n } else if (fix.kind === \"set_close_reason\") {\n updateOptions.closeReason = fix.value;\n } else if (fix.kind === \"set_estimate\") {\n updateOptions.estimatedMinutes = fix.value;\n } else if (fix.kind === \"reparent\") {\n updateOptions.parent = fix.parent_id;\n } else {\n updateOptions.unset = [\"parent\"];\n }\n await runUpdate(fix.item_id, updateOptions, global);\n return;\n }\n case \"prune_file_link\": {\n throw new Error(`Unsupported non-batched fix kind: ${fix.kind}`);\n }\n case \"prune_doc_link\": {\n throw new Error(`Unsupported non-batched fix kind: ${fix.kind}`);\n }\n }\n}\n/* c8 ignore stop */\n\nfunction pruneBatchKey(fix: ValidateFixRecord): string | null {\n if (fix.kind !== \"prune_file_link\" && fix.kind !== \"prune_doc_link\") {\n return null;\n }\n return `${fix.kind}:${fix.item_id}`;\n}\n\n/* c8 ignore start -- batched prune/apply failure fan-out permutations are covered by auto-fix integration suites */\nasync function applyValidateFixes(applicable: ValidateFixRecord[], global: GlobalOptions): Promise<{\n applied: ValidateFixRecord[];\n failed: Array<{ fix: ValidateFixRecord; error: unknown }>;\n}> {\n const applied: ValidateFixRecord[] = [];\n const failed: Array<{ fix: ValidateFixRecord; error: unknown }> = [];\n const pruneBatches = new Map<string, ValidateFixRecord[]>();\n\n for (const fix of applicable) {\n const batchKey = pruneBatchKey(fix);\n if (batchKey === null) {\n try {\n await applyValidateFix(fix, global);\n applied.push(fix);\n } catch (error) {\n failed.push({ fix, error });\n }\n continue;\n }\n const existing = pruneBatches.get(batchKey);\n if (existing) {\n existing.push(fix);\n } else {\n pruneBatches.set(batchKey, [fix]);\n }\n }\n\n for (const batch of pruneBatches.values()) {\n const first = batch[0];\n /* c8 ignore next 2 -- pruneBatches values are only created with at least one fix */\n if (!first) {\n continue;\n }\n const remove = batch\n .map((fix) => fix.path)\n .filter((value): value is string => typeof value === \"string\" && value.length > 0);\n try {\n if (first.kind === \"prune_file_link\") {\n const { runFiles } = await import(\"./files.js\");\n await runFiles(first.item_id, { remove, message: VALIDATE_AUTO_FIX_MESSAGE }, global);\n } else {\n const { runDocs } = await import(\"./docs.js\");\n await runDocs(first.item_id, { remove, message: VALIDATE_AUTO_FIX_MESSAGE }, global);\n }\n applied.push(...batch);\n } catch (error) {\n failed.push(...batch.map((fix) => ({ fix, error })));\n }\n }\n\n return { applied, failed };\n}\n/* c8 ignore stop */\n\nexport const _testOnlyValidateCommand = {\n applyValidateFix,\n applyValidateFixes,\n attachValidateFixHints,\n buildCommandReferencesCheck,\n buildCloseReasonBackfillRows,\n buildFilesCheck,\n buildLifecycleCheck,\n buildLifecycleDependencyGraph,\n buildLifecycleParentGraph,\n buildEstimateBackfillRows,\n buildMetadataCounts,\n buildMissingFieldOccurrences,\n buildOrphanedPathRows,\n classifyOrphanedPath,\n collectDefaultProjectFileCandidates,\n collectTrackedGitFileCandidates,\n detectLifecycleDependencyCycles,\n detectLifecycleParentCycles,\n escapeRegExp,\n extractItemIds,\n findLifecycleDependencyCycleComponents,\n isMetadataFieldMissing,\n listFilesRecursive,\n resolveDependencyCycleSeverity,\n resolveParentCycleSeverity,\n resolveFileScanMode,\n resolveLifecycleDependencyCycleSamplePath,\n resolveRequestedChecks,\n resolveValidateMetadataProfile,\n resolveWorkspaceRoot,\n sharedDirectoryPrefixLength,\n summarizeOrphanedPathRows,\n summarizeDuplicateIssueCodes,\n toMeaningfulString,\n};\n\ntype LoadedValidateSettings = Awaited<ReturnType<typeof readSettings>>;\n\ninterface ValidateCheckExecutionState {\n checks: ValidateCheck[];\n warnings: string[];\n closeReasonBackfillRows: CloseReasonBackfillRow[];\n estimateBackfillRows: EstimateBackfillRow[];\n resolutionBackfillRows: ResolutionBackfillRow[];\n terminalParentFixRows: TerminalParentFixRow[];\n staleLinkPruneRows: StaleLinkPruneRow[];\n}\n\nfunction recordValidateCheck(\n state: ValidateCheckExecutionState,\n built: { check: ValidateCheck; warnings: string[] },\n fixHintsEnabled: boolean,\n): void {\n if (fixHintsEnabled) {\n attachValidateFixHints(built.check, built.warnings);\n }\n state.checks.push(built.check);\n state.warnings.push(...built.warnings);\n}\n\nasync function executeRequestedValidateChecks(params: {\n requestedChecks: Set<ValidateCheckName>;\n options: ValidateCommandOptions;\n global: GlobalOptions;\n pmRoot: string;\n workspaceRoot: string;\n settings: LoadedValidateSettings;\n items: ItemWithBody[];\n statusRegistry: RuntimeStatusRegistry;\n metadataPolicy: ValidateMetadataPolicy;\n lifecyclePatternPolicy: LifecyclePatternPolicy;\n dependencyCycleSeverity: ValidateDependencyCycleSeverity;\n parentCycleSeverity: ValidateDependencyCycleSeverity;\n fileScanMode: ValidateFileScanMode;\n initialWarnings: string[];\n}): Promise<ValidateCheckExecutionState> {\n const state: ValidateCheckExecutionState = {\n checks: [],\n warnings: [...params.initialWarnings],\n closeReasonBackfillRows: [],\n estimateBackfillRows: [],\n resolutionBackfillRows: [],\n terminalParentFixRows: [],\n staleLinkPruneRows: [],\n };\n const fixHintsEnabled = params.options.fixHints === true;\n const fullDiagnostics =\n params.options.verboseDiagnostics === true || params.options.allAffectedIds === true || params.global.json === true;\n if (params.requestedChecks.has(\"metadata\")) {\n const built = buildMetadataCheck(params.items, params.metadataPolicy, params.statusRegistry, fullDiagnostics);\n state.closeReasonBackfillRows = built.closeReasonBackfillRows;\n state.estimateBackfillRows = built.estimateBackfillRows;\n recordValidateCheck(state, built, fixHintsEnabled);\n }\n if (params.requestedChecks.has(\"resolution\")) {\n const built = buildResolutionCheck(params.items, params.statusRegistry, fullDiagnostics);\n state.resolutionBackfillRows = built.resolutionBackfillRows;\n recordValidateCheck(state, built, fixHintsEnabled);\n }\n if (params.requestedChecks.has(\"lifecycle\")) {\n const built = buildLifecycleCheck(\n params.items,\n Boolean(params.options.checkStaleBlockers),\n params.dependencyCycleSeverity,\n params.parentCycleSeverity,\n params.statusRegistry,\n params.lifecyclePatternPolicy,\n fullDiagnostics,\n params.settings.id_prefix,\n );\n state.terminalParentFixRows = built.terminalParentFixRows;\n recordValidateCheck(state, built, fixHintsEnabled);\n }\n if (params.requestedChecks.has(\"files\")) {\n const built = await buildFilesCheck(\n params.items,\n params.workspaceRoot,\n params.pmRoot,\n params.fileScanMode,\n Boolean(params.options.includePmInternals),\n Boolean(params.options.verboseFileLists),\n );\n state.staleLinkPruneRows = built.staleLinkPruneRows;\n recordValidateCheck(state, built, fixHintsEnabled);\n }\n if (params.requestedChecks.has(\"command_references\")) {\n recordValidateCheck(\n state,\n buildCommandReferencesCheck(params.items, params.settings.id_prefix, fullDiagnostics),\n fixHintsEnabled,\n );\n }\n if (params.requestedChecks.has(\"history_drift\")) {\n recordValidateCheck(state, await buildHistoryDriftCheck(params.pmRoot, params.items, fullDiagnostics), fixHintsEnabled);\n }\n if (params.requestedChecks.has(\"format_version\")) {\n recordValidateCheck(state, buildFormatVersionCheck(params.items, fullDiagnostics), fixHintsEnabled);\n }\n return state;\n}\n\nfunction planValidateFixes(\n options: ValidateCommandOptions,\n state: ValidateCheckExecutionState,\n settings: LoadedValidateSettings,\n): ValidateFixRecord[] {\n const planned: ValidateFixRecord[] = [];\n if (options.autoFix === true) {\n planned.push(...planCloseReasonBackfillFixes(state.closeReasonBackfillRows));\n planned.push(...planResolutionBackfillFixes(state.resolutionBackfillRows));\n planned.push(...planEstimateBackfillFixes(state.estimateBackfillRows, settings.validation.estimate_defaults_by_type));\n planned.push(...planTerminalParentFixes(state.terminalParentFixRows));\n }\n if (options.pruneMissing === true) {\n planned.push(...planStaleLinkPruneFixes(state.staleLinkPruneRows));\n }\n return planned;\n}\n\n/* v8 ignore start -- validate fix-summary matrix is covered end-to-end; direct helper fallback branches are defensive */\nasync function buildValidateFixesSummary(\n options: ValidateCommandOptions,\n state: ValidateCheckExecutionState,\n settings: LoadedValidateSettings,\n grantedFixScopes: Set<ValidateFixScope>,\n global: GlobalOptions,\n): Promise<ValidateFixesSummary | undefined> {\n if (options.autoFix !== true && options.pruneMissing !== true) {\n return undefined;\n }\n const planned = planValidateFixes(options, state, settings);\n const { applicable, gated } = partitionFixesByGrant(planned, grantedFixScopes);\n const dryRun = options.dryRun === true;\n const appliedFixRows: Array<Record<string, unknown>> = [];\n const failedFixRows: Array<Record<string, unknown>> = [];\n if (!dryRun) {\n const applied = await applyValidateFixes(applicable, global);\n appliedFixRows.push(...applied.applied.map(toFixOutputRow));\n failedFixRows.push(\n ...applied.failed.map(({ fix, error }) => ({\n ...toFixOutputRow(fix),\n error: error instanceof Error ? error.message : String(error),\n })),\n );\n }\n return {\n mode: dryRun ? \"dry_run\" : \"apply\",\n auto_fix: options.autoFix === true,\n prune_missing: options.pruneMissing === true,\n granted_fix_scopes: [...grantedFixScopes].sort((left, right) => left.localeCompare(right)),\n planned_count: planned.length,\n applied_count: appliedFixRows.length,\n gated_count: gated.length,\n failed_count: failedFixRows.length,\n planned_fixes: planned.map(toFixOutputRow),\n applied_fixes: appliedFixRows,\n gated_fixes: gated.map((fix) => ({\n ...toFixOutputRow(fix),\n gate_hint: `Withheld: re-run with --fix-scope ${fix.gate} to apply.`,\n })),\n failed_fixes: failedFixRows,\n };\n}\n/* v8 ignore stop */\n\n/* c8 ignore start -- validate orchestration + fix-application matrices are covered by end-to-end command integration runs */\n/**\n * Implements run validate for the public runtime surface of this module.\n */\nexport async function runValidate(options: ValidateCommandOptions, global: GlobalOptions): Promise<ValidateResult> {\n const fixesRequested = options.autoFix === true || options.pruneMissing === true;\n if (options.dryRun === true && !fixesRequested) {\n throw new PmCliError(\n \"--dry-run requires --auto-fix or --prune-missing (there is nothing to preview otherwise).\",\n EXIT_CODE.USAGE,\n );\n }\n if (options.fixScope !== undefined && options.fixScope.length > 0 && options.autoFix !== true) {\n throw new PmCliError(\"--fix-scope requires --auto-fix.\", EXIT_CODE.USAGE);\n }\n // Resolved up-front so unknown --fix-scope values fail fast before any scan.\n const grantedFixScopes = resolveGrantedFixScopes(options.fixScope);\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const itemReadWarnings: string[] = [];\n const items = await listAllFrontMatterWithBody(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n itemReadWarnings,\n settings.schema,\n );\n const requestedChecks = resolveRequestedChecks(options);\n const metadataProfileSource: \"default\" | \"settings\" | \"option\" =\n typeof options.metadataProfile === \"string\" ? \"option\" : \"settings\";\n const metadataProfile = resolveValidateMetadataProfile(\n typeof options.metadataProfile === \"string\" ? options.metadataProfile : settings.validation.metadata_profile,\n );\n const metadataPolicy = resolveValidateMetadataPolicy(\n metadataProfile,\n metadataProfileSource,\n settings.validation.metadata_required_fields,\n );\n const lifecyclePatternPolicy = resolveLifecyclePatternPolicy(settings);\n const dependencyCycleSeverity = resolveDependencyCycleSeverity(options.dependencyCycleSeverity);\n const parentCycleSeverity = resolveParentCycleSeverity(options.parentCycleSeverity);\n const fileScanMode = resolveFileScanMode(options.scanMode);\n const workspaceRoot = resolveWorkspaceRoot(pmRoot);\n const state = await executeRequestedValidateChecks({\n requestedChecks,\n options,\n global,\n pmRoot,\n workspaceRoot,\n settings,\n items,\n statusRegistry,\n metadataPolicy,\n lifecyclePatternPolicy,\n dependencyCycleSeverity,\n parentCycleSeverity,\n fileScanMode,\n initialWarnings: [...new Set(itemReadWarnings)],\n });\n\n // Remediation phase (pm-c3sz / pm-8jss / pm-0v2m). Plans are derived from\n // the findings of THIS run; checks above always report the pre-fix state.\n // Safe field backfills apply by default under --auto-fix; gated lifecycle\n // fixes are planned but withheld unless --fix-scope lifecycle grants them;\n // --dry-run previews without mutating; failures never abort the run.\n const fixes = fixesRequested\n ? await buildValidateFixesSummary(options, state, settings, grantedFixScopes, global)\n : undefined;\n\n const normalizedWarnings = [...new Set(state.warnings)].sort((left, right) => left.localeCompare(right));\n const hasErrors = state.checks.some((check) => check.status === \"error\");\n return {\n ok: !hasErrors,\n has_warnings: normalizedWarnings.length > 0,\n checks: state.checks,\n warnings: normalizedWarnings,\n ...(fixes !== undefined ? { fixes } : {}),\n generated_at: nowIso(),\n };\n}\n/* c8 ignore stop */\n","/**\n * Fix planning for `pm validate --auto-fix` / `--prune-missing` (pm-c3sz,\n * pm-8jss, pm-0v2m).\n *\n * Pure module: planners turn check findings into declarative\n * {@link ValidateFixRecord}s; the validate command decides whether to apply\n * them (apply mode), preview them (`--dry-run`), or withhold gated fixes\n * (lifecycle structural changes require an explicit `--fix-scope lifecycle`).\n *\n * Safety invariants:\n * - Every planned fix is deterministic and non-destructive: it only sets a\n * derivable field value or removes a stale LINK (never a real file).\n * - No fix ever closes, deletes, or cancels an item.\n * - Lifecycle fixes (reparent / unset parent) are structural, so they are\n * planned with `gate: \"lifecycle\"` and only applied when that scope was\n * explicitly granted.\n */\n\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { resolveEstimateDefaultMinutes } from \"./estimate-defaults.js\";\n\n/**\n * Restricts validate fix check values accepted by command, SDK, and storage contracts.\n */\nexport type ValidateFixCheck = \"metadata\" | \"resolution\" | \"lifecycle\" | \"files\";\n\n/**\n * Restricts validate fix kind values accepted by command, SDK, and storage contracts.\n */\nexport type ValidateFixKind =\n | \"set_resolution\"\n | \"set_close_reason\"\n | \"set_estimate\"\n | \"reparent\"\n | \"unset_parent\"\n | \"prune_file_link\"\n | \"prune_doc_link\";\n\n/**\n * Restricts validate fix scope values accepted by command, SDK, and storage contracts.\n */\nexport type ValidateFixScope = \"metadata\" | \"resolution\" | \"estimates\" | \"lifecycle\";\n\n/** Scopes auto-applied without an explicit `--fix-scope` (safe field backfills). */\nexport const DEFAULT_GRANTED_FIX_SCOPES: readonly ValidateFixScope[] = [\"metadata\", \"resolution\"];\n\n/**\n * Scopes accepted by `--fix-scope`. `estimates` and `lifecycle` are opt-in:\n * estimate backfills are heuristic per-type guesses (not derived facts) and\n * lifecycle changes are structural, so neither is granted by default.\n */\nexport const SUPPORTED_FIX_SCOPES: readonly ValidateFixScope[] = [\"metadata\", \"resolution\", \"estimates\", \"lifecycle\"];\n\n/**\n * Documents the validate fix record payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidateFixRecord {\n /** Item the fix targets. */\n item_id: string;\n /** Validate check the finding came from. */\n check: ValidateFixCheck;\n /** Front-matter field (or link list) the fix changes. */\n field: string;\n /** Declarative fix kind the applier dispatches on. */\n kind: ValidateFixKind;\n /** Equivalent standalone `pm` command for the fix. */\n command: string;\n /** New value for set-field fixes. */\n value?: string;\n /** Stale link path for prune fixes. */\n path?: string;\n /** Target parent id for reparent fixes. */\n parent_id?: string;\n /**\n * Fix scope the `--fix-scope` allowlist must grant for the fix to be\n * applied. Every `--auto-fix` record carries one (the granted default is\n * metadata+resolution; lifecycle must be named explicitly). Absent only on\n * `--prune-missing` records, which are governed by their own flag.\n */\n gate?: ValidateFixScope;\n}\n\n/** Default resolution backfilled onto closed items with no derivable source text. */\nexport const DEFAULT_RESOLUTION_BACKFILL_VALUE = \"completed\";\n\nfunction quoteForCommand(value: string): string {\n return `\"${value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"')}\"`;\n}\n\nfunction toMeaningfulValue(value: string | undefined): string | undefined {\n const trimmed = value?.trim();\n return trimmed !== undefined && trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Documents the resolution backfill row payload exchanged by command, SDK, and package integrations.\n */\nexport interface ResolutionBackfillRow {\n id: string;\n /** Resolution-check missing field keys for this closed item. */\n missing_fields: readonly string[];\n /** The item's close_reason, when present (preferred derivation source). */\n close_reason?: string;\n}\n\n/**\n * Plan resolution backfills for closed items flagged by the resolution check.\n * Only the `resolution` field is mechanical enough to auto-fix: it derives\n * from the item's own `close_reason` when present and falls back to the\n * `\"completed\"` default. `expected_result` / `actual_result` stay hint-only —\n * no deterministic source text exists for them.\n */\nexport function planResolutionBackfillFixes(rows: readonly ResolutionBackfillRow[]): ValidateFixRecord[] {\n const fixes: ValidateFixRecord[] = [];\n for (const row of rows) {\n if (!row.missing_fields.includes(\"resolution\")) {\n continue;\n }\n const value = toMeaningfulValue(row.close_reason) ?? DEFAULT_RESOLUTION_BACKFILL_VALUE;\n fixes.push({\n item_id: row.id,\n check: \"resolution\",\n field: \"resolution\",\n kind: \"set_resolution\",\n value,\n command: `pm update ${row.id} --resolution ${quoteForCommand(value)}`,\n gate: \"resolution\",\n });\n }\n return fixes;\n}\n\n/**\n * Documents the close reason backfill row payload exchanged by command, SDK, and package integrations.\n */\nexport interface CloseReasonBackfillRow {\n id: string;\n /** The item's resolution, when present (the only derivation source). */\n resolution?: string;\n}\n\n/**\n * Plan close_reason backfills for closed items flagged by the metadata check.\n * Only derivable when the item already carries a resolution; items missing\n * both stay hint-only (any synthesized reason would be fabricated, not\n * derived).\n */\nexport function planCloseReasonBackfillFixes(rows: readonly CloseReasonBackfillRow[]): ValidateFixRecord[] {\n const fixes: ValidateFixRecord[] = [];\n for (const row of rows) {\n const value = toMeaningfulValue(row.resolution);\n if (value === undefined) {\n continue;\n }\n fixes.push({\n item_id: row.id,\n check: \"metadata\",\n field: \"close_reason\",\n kind: \"set_close_reason\",\n value,\n command: `pm update ${row.id} --close-reason ${quoteForCommand(value)}`,\n gate: \"metadata\",\n });\n }\n return fixes;\n}\n\n/**\n * Documents the estimate backfill row payload exchanged by command, SDK, and package integrations.\n */\nexport interface EstimateBackfillRow {\n id: string;\n /** Item type, used to resolve the per-type default estimate. */\n type?: string;\n}\n\n/**\n * Plan estimate backfills for items flagged by the metadata check as missing\n * `estimated_minutes` (GH-212). The value is a config-driven per-type default\n * (overrides > built-in map > fallback), never a derived fact — so these fixes\n * carry `gate: \"estimates\"`, an opt-in scope that is NOT granted by default.\n * `overrides` is the already-normalized `validation.estimate_defaults_by_type`\n * map; pass `undefined`/`{}` to use the built-in defaults.\n */\nexport function planEstimateBackfillFixes(\n rows: readonly EstimateBackfillRow[],\n overrides?: Readonly<Record<string, number>>,\n): ValidateFixRecord[] {\n return rows.map((row) => {\n const minutes = resolveEstimateDefaultMinutes(row.type, overrides);\n return {\n item_id: row.id,\n check: \"metadata\" as const,\n field: \"estimated_minutes\",\n kind: \"set_estimate\" as const,\n value: String(minutes),\n command: `pm update ${row.id} --estimate ${minutes}`,\n gate: \"estimates\" as const,\n };\n });\n}\n\n/**\n * Documents the terminal parent fix row payload exchanged by command, SDK, and package integrations.\n */\nexport interface TerminalParentFixRow {\n id: string;\n parent_id: string;\n /** The terminal parent's own parent, when one exists. */\n grandparent_id?: string;\n /** True when the grandparent exists and is NOT terminal (safe reparent target). */\n grandparent_active?: boolean;\n}\n\n/**\n * Plan lifecycle fixes for active items whose parent is terminal (pm-8jss /\n * GH-168). When the terminal parent has an active grandparent, the child is\n * reparented one level up (it stays inside the same hierarchy); otherwise the\n * parent link is cleared so the item surfaces as unparented active work.\n * Either way the item itself is never closed or mutated beyond `parent` —\n * and every fix carries `gate: \"lifecycle\"` so it is only applied under an\n * explicit `--fix-scope lifecycle`.\n */\nexport function planTerminalParentFixes(rows: readonly TerminalParentFixRow[]): ValidateFixRecord[] {\n return rows.map((row) => {\n if (row.grandparent_id !== undefined && row.grandparent_active === true) {\n return {\n item_id: row.id,\n check: \"lifecycle\" as const,\n field: \"parent\",\n kind: \"reparent\" as const,\n parent_id: row.grandparent_id,\n command: `pm update ${row.id} --parent ${row.grandparent_id}`,\n gate: \"lifecycle\" as const,\n };\n }\n return {\n item_id: row.id,\n check: \"lifecycle\" as const,\n field: \"parent\",\n kind: \"unset_parent\" as const,\n command: `pm update ${row.id} --unset parent`,\n gate: \"lifecycle\" as const,\n };\n });\n}\n\n/**\n * Documents the stale link prune row payload exchanged by command, SDK, and package integrations.\n */\nexport interface StaleLinkPruneRow {\n item_id: string;\n path: string;\n link_kind: \"files\" | \"docs\";\n classification: \"moved\" | \"deleted\";\n}\n\n/**\n * Plan link prunes for `--prune-missing` (pm-0v2m / GH-184). Only links whose\n * stale path classified as `deleted` are pruned; `moved` links keep their\n * relink candidates in the files-check details instead of being dropped, so\n * recoverable link information is never destroyed. Link removal only — real\n * files are never touched.\n */\nexport function planStaleLinkPruneFixes(rows: readonly StaleLinkPruneRow[]): ValidateFixRecord[] {\n const fixes: ValidateFixRecord[] = [];\n for (const row of rows) {\n if (row.classification !== \"deleted\") {\n continue;\n }\n const noun = row.link_kind === \"files\" ? \"files\" : \"docs\";\n fixes.push({\n item_id: row.item_id,\n check: \"files\",\n field: row.link_kind,\n kind: row.link_kind === \"files\" ? \"prune_file_link\" : \"prune_doc_link\",\n path: row.path,\n command: `pm ${noun} ${row.item_id} --remove ${quoteForCommand(row.path)}`,\n });\n }\n return fixes;\n}\n\n/**\n * Resolve the granted `--fix-scope` set (repeatable and/or comma-separated).\n * With no explicit scopes the safe field-backfill scopes (metadata,\n * resolution) are granted; lifecycle must always be named explicitly. Unknown\n * values fail fast with the supported list.\n */\nexport function resolveGrantedFixScopes(rawScopes: readonly string[] | undefined): Set<ValidateFixScope> {\n const tokens = (rawScopes ?? [])\n .flatMap((raw) => raw.split(\",\"))\n .map((raw) => raw.trim())\n .filter((raw) => raw.length > 0);\n if (tokens.length === 0) {\n if (rawScopes !== undefined && rawScopes.length > 0) {\n throw new PmCliError(\n `--fix-scope values must not be empty. Supported values: ${SUPPORTED_FIX_SCOPES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n }\n return new Set(DEFAULT_GRANTED_FIX_SCOPES);\n }\n const granted = new Set<ValidateFixScope>();\n for (const raw of tokens) {\n const normalized = raw.toLowerCase().replaceAll(\"-\", \"_\");\n if ((SUPPORTED_FIX_SCOPES as readonly string[]).includes(normalized)) {\n granted.add(normalized as ValidateFixScope);\n continue;\n }\n throw new PmCliError(\n `Unknown --fix-scope value \"${raw}\". Supported values: ${SUPPORTED_FIX_SCOPES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n }\n return granted;\n}\n\n/**\n * Split a fix plan into the records that may be applied under the granted\n * scopes and the gated records that were withheld. `--fix-scope` is an exact\n * allowlist: every `--auto-fix` record requires its gate scope in `granted`.\n * Ungated records (`--prune-missing` link prunes, governed by their own flag)\n * are always applicable.\n */\nexport function partitionFixesByGrant(\n fixes: readonly ValidateFixRecord[],\n granted: ReadonlySet<ValidateFixScope>,\n): { applicable: ValidateFixRecord[]; gated: ValidateFixRecord[] } {\n const applicable: ValidateFixRecord[] = [];\n const gated: ValidateFixRecord[] = [];\n for (const fix of fixes) {\n if (fix.gate !== undefined && !granted.has(fix.gate)) {\n gated.push(fix);\n } else {\n applicable.push(fix);\n }\n }\n return { applicable, gated };\n}\n\n/** Compact serialization of a fix for planned/applied output rows. */\nexport function toFixOutputRow(fix: ValidateFixRecord): Record<string, unknown> {\n return {\n item_id: fix.item_id,\n check: fix.check,\n field: fix.field,\n command: fix.command,\n ...(fix.gate !== undefined ? { gate: fix.gate } : {}),\n };\n}\n","/**\n * Logical issue-code governance primitives (GH-235).\n *\n * Trackers frequently adopt a title convention that embeds a logical issue\n * code at the START of the title, e.g. `ISSUE-004: ...`, `BUG-12 ...`,\n * `TASK-7 — ...`, `ADR-001`, `RFC-9`. When two distinct items share the same\n * logical code, auditability and duplicate detection both suffer: a human or\n * agent searching for \"ISSUE-004\" can no longer assume a single canonical item.\n *\n * These primitives detect that condition. They are pure: no IO, no heavy\n * runtime dependencies. Callers pass plain structural item shapes so the logic\n * stays trivially unit-testable.\n */\n\n/** Minimal structural shape needed to detect duplicate issue codes. */\nexport interface IssueCodeItem {\n id: string;\n title?: string | null;\n /**\n * The id of this item's parent, when it is a child in a hierarchy. Used to\n * suppress false positives where a child intentionally reuses its parent's\n * code prefix (the `PARENT` + `PARENT-T0n` task-breakdown convention, GH-275):\n * when an item's parent is another item in the same code group, the shared\n * code is by design and the child does not constitute a collision.\n */\n parent?: string | null;\n /**\n * The id of the canonical item this one was closed as a duplicate of, when\n * set. A closed-as-duplicate item has already been adjudicated, so it is\n * excluded from collision detection entirely (GH-278) — re-flagging a\n * resolved duplicate is permanent noise that erodes trust in `validate`.\n */\n duplicate_of?: string | null;\n}\n\n/** A logical issue code shared by two or more items. */\nexport interface DuplicateIssueCode {\n /** The canonical (normalized, upper-case) issue code, e.g. `ISSUE-004`. */\n code: string;\n /** How many items carry this code. */\n count: number;\n /** The ids of the items carrying this code, sorted ascending. */\n ids: string[];\n /** The titles of the items carrying this code, in the same order as `ids`. */\n titles: string[];\n}\n\n/**\n * Match a conventional leading logical issue code: an upper-case alphanumeric\n * prefix (starting with a letter) followed by a `-` separator and a number, at\n * the very start of the title (after optional leading whitespace).\n *\n * Examples that match: `ISSUE-004`, `BUG-12`, `TASK-7`, `ADR-001`, `RFC-9`,\n * `GH-235`, `PM2-14`. The trailing `\\b` requires the digit run to end at a word\n * boundary, so `ISSUE-004-extra` extracts `ISSUE-004` while `ISSUE-004foo`\n * (digit immediately followed by a letter — no boundary) does not match.\n */\nconst ISSUE_CODE_PATTERN = /^([A-Z][A-Z0-9]*-\\d+)\\b/;\n\n/**\n * Extract the leading logical issue code from a title, or `null` when the title\n * does not begin with one. The title is trimmed and upper-cased before matching\n * so case differences (`issue-004` vs `ISSUE-004`) collapse to one logical\n * code; the returned code is therefore always normalized upper-case.\n *\n * Accepts unknown-ish input defensively (exported helper SDK consumers may call\n * from untyped JS): a non-string or empty title resolves to `null`.\n */\nexport function extractIssueCode(title: string | null | undefined): string | null {\n if (typeof title !== \"string\") {\n return null;\n }\n const normalized = title.trim().toUpperCase();\n if (normalized.length === 0) {\n return null;\n }\n const match = ISSUE_CODE_PATTERN.exec(normalized);\n return match ? match[1] : null;\n}\n\n/** Test whether a value is a usable (non-empty after trim) item-id reference. */\nfunction isNonEmptyIdReference(value: string | null | undefined): value is string {\n return typeof value === \"string\" && value.trim().length > 0;\n}\n\n/**\n * Find logical issue codes used by 2+ items. Any item whose title begins with a\n * conventional issue code contributes; codes used by a single item are not\n * reported. Status is intentionally NOT considered for genuine collisions — a\n * closed item and an open item sharing a code still collide for audit purposes.\n *\n * Two adjudicated/by-design cases are excluded so `validate` output stays\n * trustworthy in real trackers (GH-275, GH-278):\n *\n * - **Closed-as-duplicate** (GH-278): an item with a non-empty `duplicate_of`\n * has already been resolved against its canonical keeper, so it is dropped\n * before grouping and never contributes to a collision.\n * - **Parent/child prefix sharing** (GH-275): the `PARENT` + `PARENT-T0n`\n * task-breakdown convention makes a child's title share the parent's code.\n * Within each code group, any item whose `parent` is another item in the same\n * group is dropped, because the shared code is intentional hierarchy, not a\n * collision. A genuine duplicate (two items with the same code, neither the\n * parent of the other) still surfaces after this filtering.\n *\n * Results are deterministic: duplicate groups are sorted by code, and the\n * `ids`/`titles` within each group are sorted by id. The first-seen title for a\n * given (id) is used; duplicate ids (should not occur for a valid corpus) are\n * de-duplicated so an item never inflates its own code's count.\n */\nexport function findDuplicateIssueCodes(items: readonly IssueCodeItem[]): DuplicateIssueCode[] {\n const byCode = new Map<string, Array<{ id: string; title: string; parent: string | null }>>();\n for (const item of items) {\n // A non-string title can never carry a code, so skip it before extraction;\n // this also guarantees every stored title below is a real string.\n if (typeof item.title !== \"string\") {\n continue;\n }\n // GH-278: an item closed as a duplicate of another is already adjudicated.\n if (isNonEmptyIdReference(item.duplicate_of)) {\n continue;\n }\n const code = extractIssueCode(item.title);\n if (code === null) {\n continue;\n }\n let entries = byCode.get(code);\n if (!entries) {\n entries = [];\n byCode.set(code, entries);\n }\n if (!entries.some((entry) => entry.id === item.id)) {\n entries.push({ id: item.id, title: item.title, parent: isNonEmptyIdReference(item.parent) ? item.parent.trim() : null });\n }\n }\n\n const duplicates: DuplicateIssueCode[] = [];\n for (const [code, entries] of byCode) {\n if (entries.length < 2) {\n continue;\n }\n // GH-275: drop children whose parent is another item carrying the same code\n // (intentional `PARENT` + `PARENT-T0n` breakdown), then re-check the group.\n // The parent reference is resolved only against the same-code group on\n // purpose: a child is by-design noise solely when its parent shares the code\n // (resolving against the full corpus would suppress genuinely colliding\n // siblings whose parent merely exists elsewhere). Comparison is\n // case-insensitive so a `parent` reference recorded in a different case than\n // the canonical id (e.g. an upper-case `id_prefix`) still matches.\n const idsInGroup = new Set(entries.map((entry) => entry.id.toLowerCase()));\n const collisionEntries = entries.filter(\n (entry) => entry.parent === null || !idsInGroup.has(entry.parent.toLowerCase()),\n );\n if (collisionEntries.length < 2) {\n continue;\n }\n const sorted = [...collisionEntries].sort((left, right) => left.id.localeCompare(right.id));\n duplicates.push({\n code,\n count: sorted.length,\n ids: sorted.map((entry) => entry.id),\n titles: sorted.map((entry) => entry.title),\n });\n }\n return duplicates.sort((left, right) => left.code.localeCompare(right.code));\n}\n","/**\n * Per-item-type grouping of missing-required-field counts for\n * `pm validate --check-metadata` (pm-pmyq / GH-172).\n *\n * Pure module: callers stream `(item_type, field)` pairs — one per missing\n * required field occurrence — and receive a compact, deterministically sorted\n * `missing_by_type` map of counts (never row dumps), e.g.\n * `{ Task: { close_reason: 3, reviewer: 1 } }`.\n */\n\n/** One missing required metadata field observed on an item of a specific type. */\nexport interface MissingFieldOccurrence {\n /** Item type name as stored in front matter (e.g. \"Task\"). */\n item_type: string;\n /** Required metadata field that is missing on the item. */\n field: string;\n}\n\n/**\n * Aggregate missing-field occurrences into `{ type: { field: count } }` with\n * both levels sorted lexicographically for stable, diff-friendly output.\n * Zero counts never appear (only observed occurrences are aggregated).\n */\nexport function buildMissingByTypeCounts(\n occurrences: Iterable<MissingFieldOccurrence>,\n): Record<string, Record<string, number>> {\n const countsByType = new Map<string, Map<string, number>>();\n for (const occurrence of occurrences) {\n let fieldCounts = countsByType.get(occurrence.item_type);\n if (!fieldCounts) {\n fieldCounts = new Map<string, number>();\n countsByType.set(occurrence.item_type, fieldCounts);\n }\n fieldCounts.set(occurrence.field, (fieldCounts.get(occurrence.field) ?? 0) + 1);\n }\n\n const result: Record<string, Record<string, number>> = {};\n for (const type of [...countsByType.keys()].sort((left, right) => left.localeCompare(right))) {\n const fieldCounts = countsByType.get(type)!;\n const fields: Record<string, number> = {};\n for (const field of [...fieldCounts.keys()].sort((left, right) => left.localeCompare(right))) {\n fields[field] = fieldCounts.get(field)!;\n }\n result[type] = fields;\n }\n return result;\n}\n","/**\n * Classification of stale linked paths reported by `pm validate --check-files`.\n *\n * A linked file path that no longer exists is either:\n * - `moved`: a file with the same basename still exists elsewhere in the\n * scanned candidate set — the candidates are reported so an agent can relink\n * the item to the new location instead of dropping the link, or\n * - `deleted`: no candidate with that basename exists anywhere in the scan,\n * so the link points at content that is gone and pruning it is safe.\n *\n * Pure module (pm-0v2m / GH-184): no filesystem access — callers pass the\n * already-collected candidate file list from the files check scan.\n */\n\n/** Classification labels for linked paths that no longer exist on disk. */\nexport type StaleLinkedPathClassification = \"moved\" | \"deleted\";\n\n/**\n * Documents the classified stale linked path payload exchanged by command, SDK, and package integrations.\n */\nexport interface ClassifiedStaleLinkedPath {\n /** Normalized workspace-relative stale linked path. */\n path: string;\n classification: StaleLinkedPathClassification;\n /**\n * Candidate new locations (same basename, different path), sorted and capped\n * at `candidateLimit`. Empty for `deleted`.\n */\n candidates: string[];\n /** True when more candidates existed than `candidateLimit` allowed. */\n candidates_truncated: boolean;\n}\n\nexport const DEFAULT_STALE_PATH_CANDIDATE_LIMIT = 3;\n\nfunction basenameOf(relativePath: string): string {\n const lastSlash = Math.max(relativePath.lastIndexOf(\"/\"), relativePath.lastIndexOf(\"\\\\\"));\n return lastSlash === -1 ? relativePath : relativePath.slice(lastSlash + 1);\n}\n\n/**\n * Classify each stale (missing) linked path as `moved` or `deleted` by\n * matching its basename against the candidate file list. Output preserves the\n * input order of `stalePaths` (callers pass an already-sorted unique list).\n * A candidate equal to the stale path itself never matches (the path is known\n * missing; an identical candidate would be self-referential noise).\n */\nexport function classifyStaleLinkedPaths(\n stalePaths: readonly string[],\n candidateFiles: readonly string[],\n candidateLimit: number = DEFAULT_STALE_PATH_CANDIDATE_LIMIT,\n): ClassifiedStaleLinkedPath[] {\n const limit = Number.isFinite(candidateLimit) && candidateLimit >= 1 ? Math.floor(candidateLimit) : DEFAULT_STALE_PATH_CANDIDATE_LIMIT;\n const candidatesByBasename = new Map<string, string[]>();\n for (const candidate of candidateFiles) {\n const basename = basenameOf(candidate);\n if (basename.length === 0) {\n continue;\n }\n const bucket = candidatesByBasename.get(basename);\n if (bucket) {\n bucket.push(candidate);\n } else {\n candidatesByBasename.set(basename, [candidate]);\n }\n }\n\n return stalePaths.map((stalePath) => {\n const matches = (candidatesByBasename.get(basenameOf(stalePath)) ?? [])\n .filter((candidate) => candidate !== stalePath)\n .sort((left, right) => left.localeCompare(right));\n if (matches.length === 0) {\n return {\n path: stalePath,\n classification: \"deleted\" as const,\n candidates: [],\n candidates_truncated: false,\n };\n }\n return {\n path: stalePath,\n classification: \"moved\" as const,\n candidates: matches.slice(0, limit),\n candidates_truncated: matches.length > limit,\n };\n });\n}\n\n/**\n * Render compact `<path>:moved:<top-candidate>` / `<path>:deleted` rows for\n * the files check details (token-efficient counterpart to the full\n * classification objects).\n */\nexport function summarizeStaleLinkedPathClassifications(classified: readonly ClassifiedStaleLinkedPath[]): string[] {\n return classified.map((entry) =>\n entry.classification === \"moved\" ? `${entry.path}:moved:${entry.candidates[0]}` : `${entry.path}:deleted`,\n );\n}\n","/**\n * Owner attribution for stale linked paths reported by `pm validate --check-files`.\n *\n * The files check collects, per item, the linked paths (from the item's `files`\n * and `docs` link lists) that no longer resolve on disk. By default those are\n * surfaced as bare path strings + `path:classification` rows, which forces a\n * reverse lookup to discover which item owns each stale link. This module turns\n * the already-collected stale-link rows into owner-attributed, path-grouped rows\n * so an agent can perform evidence-based cleanup (relink/prune) without that\n * reverse lookup.\n *\n * Pure module (GH-210): no filesystem access and no heavy imports — callers pass\n * the already-collected stale-link rows plus a metadata `lookup` closure.\n */\n\n/** Classification assigned to a stale linked path during files validation. */\nexport type StaleLinkClassification = \"moved\" | \"deleted\";\n\n/**\n * Documents the stale link owner input payload exchanged by command, SDK, and package integrations.\n */\nexport interface StaleLinkOwnerInput {\n item_id: string;\n /** Normalized workspace-relative path that no longer resolves. */\n path: string;\n /** Which link list of the owning item the path lives in. */\n link_kind: \"files\" | \"docs\";\n classification: StaleLinkClassification;\n}\n\n/**\n * Documents the missing linked path owner payload exchanged by command, SDK, and package integrations.\n */\nexport interface MissingLinkedPathOwner {\n id: string;\n /** Owning item type, `\"Unknown\"` if metadata is absent. */\n type: string;\n /** Owning item title, `\"\"` if absent. */\n title: string;\n /** Owning item status, `\"\"` if absent. */\n status: string;\n /** The link list the path lives in (= the input `link_kind`). */\n field: \"files\" | \"docs\";\n}\n\n/**\n * Documents the missing linked path row payload exchanged by command, SDK, and package integrations.\n */\nexport interface MissingLinkedPathRow {\n path: string;\n classification: StaleLinkClassification;\n items: MissingLinkedPathOwner[];\n}\n\n/**\n * Documents the owner item metadata payload exchanged by command, SDK, and package integrations.\n */\nexport interface OwnerItemMetadata {\n type?: string;\n title?: string;\n status?: string;\n}\n\ninterface PathBucket {\n classification: StaleLinkClassification;\n /** Keyed by `<id> <field>` so identical owners de-duplicate. */\n owners: Map<string, StaleLinkOwnerInput>;\n}\n\n/**\n * `moved` wins over `deleted` when a single path's rows disagree on\n * classification: `moved` means a relink candidate exists, which is the safer,\n * more-actionable signal (relink instead of risk pruning a still-reachable\n * link). In practice all rows for one path share a classification; this is a\n * deterministic tie-break for the degenerate case.\n */\nfunction preferClassification(\n current: StaleLinkClassification,\n next: StaleLinkClassification,\n): StaleLinkClassification {\n return current === \"moved\" || next === \"moved\" ? \"moved\" : \"deleted\";\n}\n\nfunction ownerKey(input: StaleLinkOwnerInput): string {\n return `${input.item_id} ${input.link_kind}`;\n}\n\n/**\n * Group stale-link owner inputs by linked path and attach owning-item metadata.\n *\n * - Paths sorted ascending (`localeCompare`); items within a path sorted by `id`\n * then `field`.\n * - De-duplicates identical `(id, field)` owners for the same path.\n * - `classification` per path follows {@link preferClassification} (moved wins).\n * - Missing metadata falls back: type `\"Unknown\"`, title `\"\"`, status `\"\"`.\n */\nexport function buildMissingLinkedPathRows(\n rows: readonly StaleLinkOwnerInput[],\n lookup: (itemId: string) => OwnerItemMetadata | undefined,\n): MissingLinkedPathRow[] {\n const buckets = new Map<string, PathBucket>();\n for (const row of rows) {\n const bucket = buckets.get(row.path);\n if (bucket) {\n bucket.classification = preferClassification(bucket.classification, row.classification);\n bucket.owners.set(ownerKey(row), row);\n } else {\n buckets.set(row.path, {\n classification: row.classification,\n owners: new Map([[ownerKey(row), row]]),\n });\n }\n }\n\n return [...buckets.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, bucket]) => ({\n path,\n classification: bucket.classification,\n items: [...bucket.owners.values()]\n .map((owner): MissingLinkedPathOwner => {\n const metadata = lookup(owner.item_id);\n return {\n id: owner.item_id,\n type: metadata?.type ?? \"Unknown\",\n title: metadata?.title ?? \"\",\n status: metadata?.status ?? \"\",\n field: owner.link_kind,\n };\n })\n .sort((leftOwner, rightOwner) => {\n const byId = leftOwner.id.localeCompare(rightOwner.id);\n return byId !== 0 ? byId : leftOwner.field.localeCompare(rightOwner.field);\n }),\n }));\n}\n\nfunction escapeTitle(title: string): string {\n return title.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n}\n\n/**\n * Token-efficient one-line-per-owner serialization for the files-check details\n * (compact text counterpart to the full {@link MissingLinkedPathRow} objects).\n * Format per owner row:\n * `<path>:<classification> owner=<id> status=<status> field=<field> title=\"<title>\"`\n * Title is double-quoted with backslash/quote escaping; empty status/title still\n * render (`status=` and `title=\"\"`). Order follows\n * {@link buildMissingLinkedPathRows} output order.\n */\nexport function summarizeMissingLinkedPathRows(rows: readonly MissingLinkedPathRow[]): string[] {\n const lines: string[] = [];\n for (const row of rows) {\n for (const owner of row.items) {\n lines.push(\n `${row.path}:${row.classification} owner=${owner.id} status=${owner.status} field=${owner.field} title=\"${escapeTitle(owner.title)}\"`,\n );\n }\n }\n return lines;\n}\n"],"names":["path","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAS,iBAAiB;;;ACmCnB,IAAM,6BAA0D,CAAC,YAAY,YAAY;AAOzF,IAAM,uBAAoD,CAAC,YAAY,cAAc,aAAa,WAAW;AAgC7G,IAAM,oCAAoC;AAEjD,SAAS,gBAAgB,OAAa;AACpC,SAAO,IAAI,MAAM,WAAW,MAAM,MAAM,EAAE,WAAW,KAAK,KAAK,CAAC;AAClE;AAEA,SAAS,kBAAkB,OAAyB;AAClD,QAAM,UAAU,OAAO,KAAI;AAC3B,SAAO,YAAY,UAAa,QAAQ,SAAS,IAAI,UAAU;AACjE;AAoBM,SAAU,4BAA4B,MAAsC;AAChF,QAAM,QAA6B,CAAA;AACnC,aAAW,OAAO,MAAM;AACtB,QAAI,CAAC,IAAI,eAAe,SAAS,YAAY,GAAG;AAC9C;IACF;AACA,UAAM,QAAQ,kBAAkB,IAAI,YAAY,KAAK;AACrD,UAAM,KAAK;MACT,SAAS,IAAI;MACb,OAAO;MACP,OAAO;MACP,MAAM;MACN;MACA,SAAS,aAAa,IAAI,EAAE,iBAAiB,gBAAgB,KAAK,CAAC;MACnE,MAAM;KACP;EACH;AACA,SAAO;AACT;AAiBM,SAAU,6BAA6B,MAAuC;AAClF,QAAM,QAA6B,CAAA;AACnC,aAAW,OAAO,MAAM;AACtB,UAAM,QAAQ,kBAAkB,IAAI,UAAU;AAC9C,QAAI,UAAU,QAAW;AACvB;IACF;AACA,UAAM,KAAK;MACT,SAAS,IAAI;MACb,OAAO;MACP,OAAO;MACP,MAAM;MACN;MACA,SAAS,aAAa,IAAI,EAAE,mBAAm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