@unbrained/pm-cli 2026.7.20 → 2026.7.21

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 (421) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +11 -0
  3. package/dist/cli/commander-usage.d.ts +1 -1
  4. package/dist/cli/commander-usage.js +5 -5
  5. package/dist/cli/commander-usage.js.map +1 -1
  6. package/dist/cli/commands/completion.js +13 -5
  7. package/dist/cli/commands/completion.js.map +1 -1
  8. package/dist/cli/commands/contracts.js +4 -3
  9. package/dist/cli/commands/contracts.js.map +1 -1
  10. package/dist/cli/error-guidance.d.ts +2 -0
  11. package/dist/cli/error-guidance.js +7 -2
  12. package/dist/cli/error-guidance.js.map +1 -1
  13. package/dist/cli/main.d.ts +1 -5
  14. package/dist/cli/main.js +12 -50
  15. package/dist/cli/main.js.map +1 -1
  16. package/dist/cli/register-list-query.js +13 -3
  17. package/dist/cli/register-list-query.js.map +1 -1
  18. package/dist/cli/register-mutation.js +45 -3
  19. package/dist/cli/register-mutation.js.map +1 -1
  20. package/dist/cli/register-structured-mutation.d.ts +14 -0
  21. package/dist/cli/register-structured-mutation.js +62 -0
  22. package/dist/cli/register-structured-mutation.js.map +1 -0
  23. package/dist/cli/registration-helpers.js +5 -3
  24. package/dist/cli/registration-helpers.js.map +1 -1
  25. package/dist/cli-bundle/bundle-manifest.json +280 -296
  26. package/dist/cli-bundle/chunks/{append-E6V54WOQ.js → append-7OVFYR3C.js} +3 -3
  27. package/dist/cli-bundle/chunks/{append-NNJ3EFIT.js → append-DFETHAZL.js} +3 -3
  28. package/dist/cli-bundle/chunks/{chunk-C3KD7U3T.js → chunk-2L6ZP22J.js} +241 -10
  29. package/dist/cli-bundle/chunks/chunk-2L6ZP22J.js.map +7 -0
  30. package/dist/cli-bundle/chunks/{chunk-KZEANWJS.js → chunk-4PUUNQDV.js} +98 -30
  31. package/dist/cli-bundle/chunks/chunk-4PUUNQDV.js.map +7 -0
  32. package/dist/cli-bundle/chunks/{chunk-RDV4ZFYS.js → chunk-4QOB7L7I.js} +7 -9
  33. package/dist/cli-bundle/chunks/{chunk-RDV4ZFYS.js.map → chunk-4QOB7L7I.js.map} +1 -1
  34. package/dist/cli-bundle/chunks/{chunk-3LPFHE3P.js → chunk-4QSQ6XDK.js} +62 -20
  35. package/dist/cli-bundle/chunks/chunk-4QSQ6XDK.js.map +1 -0
  36. package/dist/cli-bundle/chunks/{chunk-QJKL5PHS.js → chunk-7656MAUL.js} +2 -2
  37. package/dist/cli-bundle/chunks/{chunk-3AO5VSDR.js → chunk-7RW4JCU2.js} +328 -6
  38. package/dist/cli-bundle/chunks/chunk-7RW4JCU2.js.map +7 -0
  39. package/dist/cli-bundle/chunks/{chunk-X6K5XTTN.js → chunk-7W2UAXXT.js} +5 -5
  40. package/dist/cli-bundle/chunks/{chunk-SSKOQNMS.js → chunk-ABWCF646.js} +9 -11
  41. package/dist/cli-bundle/chunks/{chunk-SSKOQNMS.js.map → chunk-ABWCF646.js.map} +1 -1
  42. package/dist/cli-bundle/chunks/{chunk-WVA4DVNV.js → chunk-ADBTSVGK.js} +71 -33
  43. package/dist/cli-bundle/chunks/chunk-ADBTSVGK.js.map +7 -0
  44. package/dist/cli-bundle/chunks/{chunk-J4FBIFU6.js → chunk-AELMUANP.js} +12 -6
  45. package/dist/cli-bundle/chunks/chunk-AELMUANP.js.map +1 -0
  46. package/dist/cli-bundle/chunks/{chunk-4F6BWJ4J.js → chunk-AMJPSANK.js} +57 -36
  47. package/dist/cli-bundle/chunks/chunk-AMJPSANK.js.map +7 -0
  48. package/dist/cli-bundle/chunks/{chunk-6VIJ7UA5.js → chunk-AS4SAZ5R.js} +850 -819
  49. package/dist/cli-bundle/chunks/chunk-AS4SAZ5R.js.map +7 -0
  50. package/dist/cli-bundle/chunks/{chunk-SG74J6MV.js → chunk-ATBCUC7Y.js} +574 -5
  51. package/dist/cli-bundle/chunks/chunk-ATBCUC7Y.js.map +1 -0
  52. package/dist/cli-bundle/chunks/{chunk-5OK4UGFV.js → chunk-BXNDKOR2.js} +3 -3
  53. package/dist/cli-bundle/chunks/{chunk-KSPWRNVP.js → chunk-CPX275C6.js} +2 -2
  54. package/dist/cli-bundle/chunks/{chunk-JH2ZSLO3.js → chunk-DZRV2OPA.js} +2 -2
  55. package/dist/cli-bundle/chunks/{chunk-L7BH7IWU.js → chunk-E5XMKOSB.js} +2 -2
  56. package/dist/cli-bundle/chunks/{chunk-CQTQKUUV.js → chunk-EWJWSNRU.js} +3 -3
  57. package/dist/cli-bundle/chunks/{chunk-DAQ45GCS.js → chunk-F2LBF7XJ.js} +22 -15
  58. package/dist/cli-bundle/chunks/chunk-F2LBF7XJ.js.map +7 -0
  59. package/dist/cli-bundle/chunks/{chunk-6XMUURSS.js → chunk-FJIFFBJX.js} +64 -33
  60. package/dist/cli-bundle/chunks/chunk-FJIFFBJX.js.map +1 -0
  61. package/dist/cli-bundle/chunks/{chunk-E7ICD63T.js → chunk-FO6OSVEN.js} +4 -6
  62. package/dist/cli-bundle/chunks/{chunk-E7ICD63T.js.map → chunk-FO6OSVEN.js.map} +1 -1
  63. package/dist/cli-bundle/chunks/{chunk-3MCTMJXI.js → chunk-FPBMLYPI.js} +2 -2
  64. package/dist/cli-bundle/chunks/{chunk-UZDQXNUB.js → chunk-FSE2IKJQ.js} +46 -5
  65. package/dist/cli-bundle/chunks/chunk-FSE2IKJQ.js.map +1 -0
  66. package/dist/cli-bundle/chunks/{chunk-IX677TRO.js → chunk-GKX4NJ7U.js} +8 -10
  67. package/dist/cli-bundle/chunks/{chunk-IX677TRO.js.map → chunk-GKX4NJ7U.js.map} +1 -1
  68. package/dist/cli-bundle/chunks/{chunk-DVDBQA3B.js → chunk-GTK4DTEW.js} +5 -5
  69. package/dist/cli-bundle/chunks/chunk-H7EAER5L.js +974 -0
  70. package/dist/cli-bundle/chunks/chunk-H7EAER5L.js.map +1 -0
  71. package/dist/cli-bundle/chunks/{chunk-5UX66S6U.js → chunk-ICDAQ4TD.js} +316 -8
  72. package/dist/cli-bundle/chunks/chunk-ICDAQ4TD.js.map +1 -0
  73. package/dist/cli-bundle/chunks/{chunk-YQQNAKW3.js → chunk-JFD5LPMI.js} +6 -8
  74. package/dist/cli-bundle/chunks/{chunk-YQQNAKW3.js.map → chunk-JFD5LPMI.js.map} +1 -1
  75. package/dist/cli-bundle/chunks/{chunk-QANSTTC7.js → chunk-JXCW2TI2.js} +6 -8
  76. package/dist/cli-bundle/chunks/{chunk-QANSTTC7.js.map → chunk-JXCW2TI2.js.map} +1 -1
  77. package/dist/cli-bundle/chunks/{chunk-GSJSM5BJ.js → chunk-K36WV5J6.js} +76 -13
  78. package/dist/cli-bundle/chunks/chunk-K36WV5J6.js.map +1 -0
  79. package/dist/cli-bundle/chunks/{chunk-GVI6FAFG.js → chunk-K55VMLSS.js} +7 -5
  80. package/dist/cli-bundle/chunks/chunk-K55VMLSS.js.map +7 -0
  81. package/dist/cli-bundle/chunks/{chunk-GIQSU6S2.js → chunk-KBLZ3AA5.js} +2 -2
  82. package/dist/cli-bundle/chunks/{chunk-XJF7CDNH.js → chunk-KH44WBAT.js} +2 -2
  83. package/dist/cli-bundle/chunks/{chunk-GV2262OF.js → chunk-LAV26CQG.js} +2 -2
  84. package/dist/cli-bundle/chunks/{chunk-VDO2JMD4.js → chunk-LVC72YRD.js} +2 -2
  85. package/dist/cli-bundle/chunks/{chunk-3VY6MIEO.js → chunk-LZYP423P.js} +35 -6
  86. package/dist/cli-bundle/chunks/chunk-LZYP423P.js.map +7 -0
  87. package/dist/cli-bundle/chunks/{chunk-ZYPFOO3L.js → chunk-MATHDCGG.js} +3 -3
  88. package/dist/cli-bundle/chunks/{chunk-OV7MSW3I.js → chunk-MWQ2HC2A.js} +99 -31
  89. package/dist/cli-bundle/chunks/chunk-MWQ2HC2A.js.map +1 -0
  90. package/dist/cli-bundle/chunks/{chunk-NHT3F4WZ.js → chunk-NUF7ROFH.js} +840 -816
  91. package/dist/cli-bundle/chunks/chunk-NUF7ROFH.js.map +1 -0
  92. package/dist/cli-bundle/chunks/{chunk-AOEOYL3S.js → chunk-O4BCOJTZ.js} +3 -3
  93. package/dist/cli-bundle/chunks/{chunk-RJO3YAFM.js → chunk-OCUBRA6D.js} +2 -2
  94. package/dist/cli-bundle/chunks/{chunk-5IZJWSDB.js → chunk-OG5DVFMA.js} +22 -15
  95. package/dist/cli-bundle/chunks/chunk-OG5DVFMA.js.map +1 -0
  96. package/dist/cli-bundle/chunks/{chunk-I577UHC7.js → chunk-OR42SO64.js} +2 -2
  97. package/dist/cli-bundle/chunks/{chunk-ZOJ3LR7O.js → chunk-OY7DMU5P.js} +2 -2
  98. package/dist/cli-bundle/chunks/{chunk-HEWM6CEN.js → chunk-P7MTHPJQ.js} +50 -9
  99. package/dist/cli-bundle/chunks/chunk-P7MTHPJQ.js.map +7 -0
  100. package/dist/cli-bundle/chunks/{chunk-2BO4CA46.js → chunk-PFNHX655.js} +236 -12
  101. package/dist/cli-bundle/chunks/{chunk-2BO4CA46.js.map → chunk-PFNHX655.js.map} +1 -1
  102. package/dist/cli-bundle/chunks/{chunk-ZV2NTVMJ.js → chunk-PONKZPCJ.js} +2 -2
  103. package/dist/cli-bundle/chunks/{chunk-THAOZG4U.js → chunk-PQSEQD6E.js} +8 -6
  104. package/dist/cli-bundle/chunks/chunk-PQSEQD6E.js.map +1 -0
  105. package/dist/cli-bundle/chunks/chunk-PWDEHT3L.js +991 -0
  106. package/dist/cli-bundle/chunks/chunk-PWDEHT3L.js.map +7 -0
  107. package/dist/cli-bundle/chunks/{chunk-UX6SSO2I.js → chunk-PZC2FUOQ.js} +2 -2
  108. package/dist/cli-bundle/chunks/{chunk-WUVEBQW6.js → chunk-QG4GFLQ6.js} +3 -5
  109. package/dist/cli-bundle/chunks/{chunk-WUVEBQW6.js.map → chunk-QG4GFLQ6.js.map} +1 -1
  110. package/dist/cli-bundle/chunks/{chunk-VQIHNHMJ.js → chunk-QIH77CAG.js} +2 -2
  111. package/dist/cli-bundle/chunks/{chunk-R3EWPG4A.js → chunk-QJIKE24M.js} +2 -2
  112. package/dist/cli-bundle/chunks/{chunk-QLZ643FM.js → chunk-QOOTOD3W.js} +10 -12
  113. package/dist/cli-bundle/chunks/{chunk-QLZ643FM.js.map → chunk-QOOTOD3W.js.map} +1 -1
  114. package/dist/cli-bundle/chunks/{chunk-MYSS5H2A.js → chunk-R3P6FZJW.js} +5 -7
  115. package/dist/cli-bundle/chunks/{chunk-MYSS5H2A.js.map → chunk-R3P6FZJW.js.map} +1 -1
  116. package/dist/cli-bundle/chunks/{chunk-G3COA6GS.js → chunk-RNPZYNHS.js} +56 -35
  117. package/dist/cli-bundle/chunks/chunk-RNPZYNHS.js.map +1 -0
  118. package/dist/cli-bundle/chunks/{chunk-T44FMVRL.js → chunk-RPESLSO5.js} +62 -20
  119. package/dist/cli-bundle/chunks/chunk-RPESLSO5.js.map +7 -0
  120. package/dist/cli-bundle/chunks/{chunk-INSTSQNZ.js → chunk-SY4SFZSD.js} +595 -3
  121. package/dist/cli-bundle/chunks/chunk-SY4SFZSD.js.map +7 -0
  122. package/dist/cli-bundle/chunks/{chunk-HB3P4M52.js → chunk-TRSHFPRZ.js} +2 -2
  123. package/dist/cli-bundle/chunks/{chunk-HRW7GF6T.js → chunk-UCBDQI5E.js} +2 -2
  124. package/dist/cli-bundle/chunks/{chunk-4U4Z6AHI.js → chunk-V22ZPOKN.js} +2 -2
  125. package/dist/cli-bundle/chunks/{chunk-JM6YAXTR.js → chunk-VHXHVTUU.js} +2 -2
  126. package/dist/cli-bundle/chunks/{chunk-LPEYZRUR.js → chunk-VJQG4BIM.js} +35 -6
  127. package/dist/cli-bundle/chunks/chunk-VJQG4BIM.js.map +1 -0
  128. package/dist/cli-bundle/chunks/{chunk-D6NXDNP3.js → chunk-VLRGDBLY.js} +2 -2
  129. package/dist/cli-bundle/chunks/{chunk-JAPE62Y5.js → chunk-VNTCM3VW.js} +3 -3
  130. package/dist/cli-bundle/chunks/{chunk-FDHPAVVB.js → chunk-VXOOB6YX.js} +2 -2
  131. package/dist/cli-bundle/chunks/{chunk-GFQP7HAZ.js → chunk-VZIZB6QH.js} +3 -5
  132. package/dist/cli-bundle/chunks/{chunk-GFQP7HAZ.js.map → chunk-VZIZB6QH.js.map} +1 -1
  133. package/dist/cli-bundle/chunks/{chunk-HQ3SB4CN.js → chunk-X3W65QK3.js} +2 -2
  134. package/dist/cli-bundle/chunks/{chunk-RZJLNXFG.js → chunk-XJTABV3X.js} +3 -3
  135. package/dist/cli-bundle/chunks/{chunk-GVT754PX.js → chunk-YCIUJJOD.js} +11 -5
  136. package/dist/cli-bundle/chunks/chunk-YCIUJJOD.js.map +7 -0
  137. package/dist/cli-bundle/chunks/{chunk-IJNK6WW2.js → chunk-Z75ONV25.js} +75 -12
  138. package/dist/cli-bundle/chunks/chunk-Z75ONV25.js.map +7 -0
  139. package/dist/cli-bundle/chunks/{chunk-4L23AGQ7.js → chunk-Z7VWXXJM.js} +5 -7
  140. package/dist/cli-bundle/chunks/{chunk-4L23AGQ7.js.map → chunk-Z7VWXXJM.js.map} +1 -1
  141. package/dist/cli-bundle/chunks/{chunk-YBT7O4KT.js → chunk-ZTVA4KLN.js} +4 -6
  142. package/dist/cli-bundle/chunks/{chunk-YBT7O4KT.js.map → chunk-ZTVA4KLN.js.map} +1 -1
  143. package/dist/cli-bundle/chunks/{chunk-TYHJDFYW.js → chunk-ZVZGXPQ5.js} +2 -2
  144. package/dist/cli-bundle/chunks/{close-many-SDA426VT.js → close-many-5RZXVN4J.js} +5 -6
  145. package/dist/cli-bundle/chunks/{close-many-UTZANOCQ.js → close-many-RZVTUGBG.js} +5 -6
  146. package/dist/cli-bundle/chunks/{comments-LZN6FXXC.js → comments-TPU7QRBL.js} +4 -4
  147. package/dist/cli-bundle/chunks/{comments-VBQ345ND.js → comments-Z4KV6FU3.js} +4 -4
  148. package/dist/cli-bundle/chunks/{create-GG4RBCGC.js → create-EIFBIVNQ.js} +6 -6
  149. package/dist/cli-bundle/chunks/{create-JBC5KUW6.js → create-RGSPN5GD.js} +6 -6
  150. package/dist/cli-bundle/chunks/{deps-FI4O6NQS.js → deps-UH5EQQUY.js} +3 -3
  151. package/dist/cli-bundle/chunks/{deps-DELOO4TL.js → deps-YG7UF3VR.js} +3 -3
  152. package/dist/cli-bundle/chunks/{docs-6Z2MP526.js → docs-G32TK6XS.js} +4 -4
  153. package/dist/cli-bundle/chunks/{docs-2UYBP5D6.js → docs-JWWNRC27.js} +4 -4
  154. package/dist/cli-bundle/chunks/{files-HKEAN5MA.js → files-3H32UQ4K.js} +4 -4
  155. package/dist/cli-bundle/chunks/{files-HEUGSJZL.js → files-4ALMCSKB.js} +4 -4
  156. package/dist/cli-bundle/chunks/{history-compact-7NDVP3PT.js → history-compact-77BT2LUB.js} +3 -4
  157. package/dist/cli-bundle/chunks/{history-compact-65YVN5DB.js → history-compact-VCKGTX64.js} +3 -4
  158. package/dist/cli-bundle/chunks/{history-redact-7YBL4XSG.js → history-redact-LJPZPNFA.js} +2 -3
  159. package/dist/cli-bundle/chunks/{history-redact-IZGNJBU4.js → history-redact-PWTTJ3XS.js} +2 -3
  160. package/dist/cli-bundle/chunks/{history-repair-7M4PYQUH.js → history-repair-I7CBNCV3.js} +5 -6
  161. package/dist/cli-bundle/chunks/{history-repair-GNGETJLI.js → history-repair-YTDZRK5E.js} +5 -6
  162. package/dist/cli-bundle/chunks/{learnings-3YXDRWFT.js → learnings-CYNOICKR.js} +4 -4
  163. package/dist/cli-bundle/chunks/{learnings-ALC6IMNL.js → learnings-KTYW3AL7.js} +4 -4
  164. package/dist/cli-bundle/chunks/{notes-7JMLQ447.js → notes-FGO63FXL.js} +4 -4
  165. package/dist/cli-bundle/chunks/{notes-JFCLTC5C.js → notes-ZERD3KB2.js} +4 -4
  166. package/dist/cli-bundle/chunks/{plan-T3XB3WTK.js → plan-OFJUBIM5.js} +7 -7
  167. package/dist/cli-bundle/chunks/{plan-KOIPWVOZ.js → plan-SGCDDTYR.js} +7 -7
  168. package/dist/cli-bundle/chunks/{profile-OILJHKUW.js → profile-3THJPIQY.js} +4 -5
  169. package/dist/cli-bundle/chunks/{profile-RJXA7PGS.js → profile-XEZAMMBW.js} +4 -5
  170. package/dist/cli-bundle/chunks/{register-list-query-CFVG75P3.js → register-list-query-BR435Q2H.js} +19 -16
  171. package/dist/cli-bundle/chunks/register-list-query-BR435Q2H.js.map +1 -0
  172. package/dist/cli-bundle/chunks/{register-list-query-E7UVY4TN.js → register-list-query-RWTWLOBE.js} +18 -15
  173. package/dist/cli-bundle/chunks/register-list-query-RWTWLOBE.js.map +7 -0
  174. package/dist/cli-bundle/chunks/{register-mutation-IQ55E25C.js → register-mutation-HLWC2WNP.js} +167 -31
  175. package/dist/cli-bundle/chunks/register-mutation-HLWC2WNP.js.map +1 -0
  176. package/dist/cli-bundle/chunks/{register-mutation-4VJTXBZW.js → register-mutation-ZJX5AZM5.js} +173 -30
  177. package/dist/cli-bundle/chunks/register-mutation-ZJX5AZM5.js.map +7 -0
  178. package/dist/cli-bundle/chunks/{register-operations-AR7RMX4W.js → register-operations-744YBJMV.js} +23 -25
  179. package/dist/cli-bundle/chunks/{register-operations-AR7RMX4W.js.map → register-operations-744YBJMV.js.map} +1 -1
  180. package/dist/cli-bundle/chunks/{register-operations-NOLZGORC.js → register-operations-UEBJH6AN.js} +21 -23
  181. package/dist/cli-bundle/chunks/{register-operations-NOLZGORC.js.map → register-operations-UEBJH6AN.js.map} +1 -1
  182. package/dist/cli-bundle/chunks/{register-setup-EYZ7VTPZ.js → register-setup-5DA4UZXI.js} +7 -8
  183. package/dist/cli-bundle/chunks/{register-setup-EYZ7VTPZ.js.map → register-setup-5DA4UZXI.js.map} +1 -1
  184. package/dist/cli-bundle/chunks/{register-setup-BB77VUEE.js → register-setup-6H25M3BH.js} +9 -10
  185. package/dist/cli-bundle/chunks/{register-setup-BB77VUEE.js.map → register-setup-6H25M3BH.js.map} +1 -1
  186. package/dist/cli-bundle/chunks/{restore-ZH65GZFB.js → restore-6TDVSATY.js} +4 -5
  187. package/dist/cli-bundle/chunks/{restore-L6IAGOD7.js → restore-RSL7C7LO.js} +4 -5
  188. package/dist/cli-bundle/chunks/{schema-4ERWM5QJ.js → schema-HFXFSGPG.js} +2 -3
  189. package/dist/cli-bundle/chunks/{schema-55DL3Q52.js → schema-TPVTIJPO.js} +2 -3
  190. package/dist/cli-bundle/chunks/{update-FW6FKDOP.js → update-LJZCL5SI.js} +7 -7
  191. package/dist/cli-bundle/chunks/{update-TJHSPRPT.js → update-SIA7LH5Y.js} +7 -7
  192. package/dist/cli-bundle/chunks/{update-many-PWXX5WHO.js → update-many-BDBZVGQL.js} +11 -12
  193. package/dist/cli-bundle/chunks/{update-many-NNALYQCN.js → update-many-MOY3A5B3.js} +11 -12
  194. package/dist/cli-bundle/main.js +60 -85
  195. package/dist/cli-bundle/main.js.map +2 -2
  196. package/dist/cli-bundle/sdk-runtime.js +37 -37
  197. package/dist/cli-bundle/sdk.js +126 -291
  198. package/dist/cli-bundle/sdk.js.map +4 -4
  199. package/dist/core/item/parse.d.ts +1 -1
  200. package/dist/core/item/parse.js +13 -7
  201. package/dist/core/item/parse.js.map +1 -1
  202. package/dist/core/output/mutation-projection.d.ts +2 -0
  203. package/dist/core/output/mutation-projection.js +33 -2
  204. package/dist/core/output/mutation-projection.js.map +1 -1
  205. package/dist/core/output/output.d.ts +4 -0
  206. package/dist/core/output/output.js +18 -13
  207. package/dist/core/output/output.js.map +1 -1
  208. package/dist/core/shared/command-types.d.ts +4 -0
  209. package/dist/core/shared/command-types.js +2 -2
  210. package/dist/core/shared/command-types.js.map +1 -1
  211. package/dist/mcp/server.js +39 -4
  212. package/dist/mcp/server.js.map +1 -1
  213. package/dist/mcp/tool-definitions.js +45 -4
  214. package/dist/mcp/tool-definitions.js.map +1 -1
  215. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  216. package/dist/sdk/cli-bootstrap.js +20 -27
  217. package/dist/sdk/cli-bootstrap.js.map +1 -1
  218. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  219. package/dist/sdk/cli-contracts/enum-contracts.js +7 -2
  220. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  221. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  222. package/dist/sdk/cli-contracts/flag-contracts.js +21 -2
  223. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  224. package/dist/sdk/cli-contracts/tool-option-contracts.js +10 -2
  225. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  226. package/dist/sdk/cli-contracts/tool-parameter-tables.js +16 -3
  227. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  228. package/dist/sdk/cli-contracts/tool-schema.js +6 -2
  229. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  230. package/dist/sdk/cli-contracts.d.ts +1 -1
  231. package/dist/sdk/cli-contracts.js +3 -3
  232. package/dist/sdk/cli-contracts.js.map +1 -1
  233. package/dist/sdk/cli-program.js +4 -2
  234. package/dist/sdk/cli-program.js.map +1 -1
  235. package/dist/sdk/dependencies.d.ts +3 -2
  236. package/dist/sdk/dependencies.js +13 -12
  237. package/dist/sdk/dependencies.js.map +1 -1
  238. package/dist/sdk/error-runtime.d.ts +10 -0
  239. package/dist/sdk/error-runtime.js +59 -0
  240. package/dist/sdk/error-runtime.js.map +1 -0
  241. package/dist/sdk/graph/analytics.d.ts +9 -0
  242. package/dist/sdk/graph/analytics.js +24 -13
  243. package/dist/sdk/graph/analytics.js.map +1 -1
  244. package/dist/sdk/graph/assembly.d.ts +39 -0
  245. package/dist/sdk/graph/assembly.js +92 -12
  246. package/dist/sdk/graph/assembly.js.map +1 -1
  247. package/dist/sdk/graph/cache.d.ts +4 -1
  248. package/dist/sdk/graph/cache.js +17 -4
  249. package/dist/sdk/graph/cache.js.map +1 -1
  250. package/dist/sdk/graph/centrality.d.ts +82 -0
  251. package/dist/sdk/graph/centrality.js +259 -0
  252. package/dist/sdk/graph/centrality.js.map +1 -0
  253. package/dist/sdk/graph/durable-cache.d.ts +71 -0
  254. package/dist/sdk/graph/durable-cache.js +205 -0
  255. package/dist/sdk/graph/durable-cache.js.map +1 -0
  256. package/dist/sdk/graph/governance.d.ts +69 -1
  257. package/dist/sdk/graph/governance.js +143 -35
  258. package/dist/sdk/graph/governance.js.map +1 -1
  259. package/dist/sdk/graph/index.d.ts +7 -4
  260. package/dist/sdk/graph/index.js +8 -5
  261. package/dist/sdk/graph/index.js.map +1 -1
  262. package/dist/sdk/graph/mutation-advisory.d.ts +35 -4
  263. package/dist/sdk/graph/mutation-advisory.js +124 -35
  264. package/dist/sdk/graph/mutation-advisory.js.map +1 -1
  265. package/dist/sdk/graph/remediation.js +12 -2
  266. package/dist/sdk/graph/remediation.js.map +1 -1
  267. package/dist/sdk/graph/run.d.ts +133 -2
  268. package/dist/sdk/graph/run.js +217 -8
  269. package/dist/sdk/graph/run.js.map +1 -1
  270. package/dist/sdk/graph/scheduling.d.ts +59 -0
  271. package/dist/sdk/graph/scheduling.js +125 -0
  272. package/dist/sdk/graph/scheduling.js.map +1 -0
  273. package/dist/sdk/graph/traversal.d.ts +11 -0
  274. package/dist/sdk/graph/traversal.js +16 -2
  275. package/dist/sdk/graph/traversal.js.map +1 -1
  276. package/dist/sdk/index.d.ts +4 -0
  277. package/dist/sdk/index.js +6 -2
  278. package/dist/sdk/index.js.map +1 -1
  279. package/dist/sdk/runtime-input.js +7 -2
  280. package/dist/sdk/runtime-input.js.map +1 -1
  281. package/dist/sdk/runtime-primitives.d.ts +10 -0
  282. package/dist/sdk/runtime-primitives.js +14 -0
  283. package/dist/sdk/runtime-primitives.js.map +1 -0
  284. package/dist/sdk/runtime.d.ts +15 -0
  285. package/dist/sdk/runtime.js +16 -3
  286. package/dist/sdk/runtime.js.map +1 -1
  287. package/dist/sdk/structured-mutations.d.ts +21 -0
  288. package/dist/sdk/structured-mutations.js +375 -0
  289. package/dist/sdk/structured-mutations.js.map +1 -0
  290. package/docs/COMMANDS.md +85 -5
  291. package/docs/RELATIONSHIP_GRAPH.md +48 -7
  292. package/docs/SDK.md +78 -3
  293. package/marketplace.json +2 -2
  294. package/package.json +1 -1
  295. package/packages/pm-beads/package.json +1 -1
  296. package/packages/pm-calendar/package.json +1 -1
  297. package/packages/pm-command-kit/package.json +1 -1
  298. package/packages/pm-governance-audit/package.json +1 -1
  299. package/packages/pm-guide-shell/package.json +1 -1
  300. package/packages/pm-kanban/package.json +1 -1
  301. package/packages/pm-lifecycle-hooks/package.json +1 -1
  302. package/packages/pm-linked-test-adapters/package.json +1 -1
  303. package/packages/pm-search-advanced/package.json +1 -1
  304. package/packages/pm-templates/package.json +1 -1
  305. package/packages/pm-todos/package.json +1 -1
  306. package/packages/pm-vcs/package.json +1 -1
  307. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  308. package/plugins/pm-claude/README.md +5 -3
  309. package/plugins/pm-claude/commands/pm-init.md +1 -1
  310. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  311. package/dist/cli-bundle/chunks/chunk-3AO5VSDR.js.map +0 -7
  312. package/dist/cli-bundle/chunks/chunk-3LPFHE3P.js.map +0 -1
  313. package/dist/cli-bundle/chunks/chunk-3VY6MIEO.js.map +0 -7
  314. package/dist/cli-bundle/chunks/chunk-4F6BWJ4J.js.map +0 -7
  315. package/dist/cli-bundle/chunks/chunk-5IZJWSDB.js.map +0 -1
  316. package/dist/cli-bundle/chunks/chunk-5UX66S6U.js.map +0 -1
  317. package/dist/cli-bundle/chunks/chunk-6C2ZZX5Z.js +0 -286
  318. package/dist/cli-bundle/chunks/chunk-6C2ZZX5Z.js.map +0 -1
  319. package/dist/cli-bundle/chunks/chunk-6VIJ7UA5.js.map +0 -7
  320. package/dist/cli-bundle/chunks/chunk-6XMUURSS.js.map +0 -1
  321. package/dist/cli-bundle/chunks/chunk-C3KD7U3T.js.map +0 -7
  322. package/dist/cli-bundle/chunks/chunk-CFHAODHQ.js +0 -334
  323. package/dist/cli-bundle/chunks/chunk-CFHAODHQ.js.map +0 -1
  324. package/dist/cli-bundle/chunks/chunk-DAQ45GCS.js.map +0 -7
  325. package/dist/cli-bundle/chunks/chunk-E6LEMURX.js +0 -249
  326. package/dist/cli-bundle/chunks/chunk-E6LEMURX.js.map +0 -7
  327. package/dist/cli-bundle/chunks/chunk-G3COA6GS.js.map +0 -1
  328. package/dist/cli-bundle/chunks/chunk-GSJSM5BJ.js.map +0 -1
  329. package/dist/cli-bundle/chunks/chunk-GVI6FAFG.js.map +0 -7
  330. package/dist/cli-bundle/chunks/chunk-GVT754PX.js.map +0 -7
  331. package/dist/cli-bundle/chunks/chunk-HEWM6CEN.js.map +0 -7
  332. package/dist/cli-bundle/chunks/chunk-IJNK6WW2.js.map +0 -7
  333. package/dist/cli-bundle/chunks/chunk-INSTSQNZ.js.map +0 -7
  334. package/dist/cli-bundle/chunks/chunk-J4FBIFU6.js.map +0 -1
  335. package/dist/cli-bundle/chunks/chunk-KZEANWJS.js.map +0 -7
  336. package/dist/cli-bundle/chunks/chunk-LPEYZRUR.js.map +0 -1
  337. package/dist/cli-bundle/chunks/chunk-NHT3F4WZ.js.map +0 -1
  338. package/dist/cli-bundle/chunks/chunk-OV7MSW3I.js.map +0 -1
  339. package/dist/cli-bundle/chunks/chunk-P7JTWYLH.js +0 -246
  340. package/dist/cli-bundle/chunks/chunk-P7JTWYLH.js.map +0 -1
  341. package/dist/cli-bundle/chunks/chunk-R5U2VZ3K.js +0 -344
  342. package/dist/cli-bundle/chunks/chunk-R5U2VZ3K.js.map +0 -7
  343. package/dist/cli-bundle/chunks/chunk-SG74J6MV.js.map +0 -1
  344. package/dist/cli-bundle/chunks/chunk-T44FMVRL.js.map +0 -7
  345. package/dist/cli-bundle/chunks/chunk-THAOZG4U.js.map +0 -1
  346. package/dist/cli-bundle/chunks/chunk-UQLXSG72.js +0 -289
  347. package/dist/cli-bundle/chunks/chunk-UQLXSG72.js.map +0 -7
  348. package/dist/cli-bundle/chunks/chunk-UZDQXNUB.js.map +0 -1
  349. package/dist/cli-bundle/chunks/chunk-WVA4DVNV.js.map +0 -7
  350. package/dist/cli-bundle/chunks/register-list-query-CFVG75P3.js.map +0 -1
  351. package/dist/cli-bundle/chunks/register-list-query-E7UVY4TN.js.map +0 -7
  352. package/dist/cli-bundle/chunks/register-mutation-4VJTXBZW.js.map +0 -7
  353. package/dist/cli-bundle/chunks/register-mutation-IQ55E25C.js.map +0 -1
  354. /package/dist/cli-bundle/chunks/{append-E6V54WOQ.js.map → append-7OVFYR3C.js.map} +0 -0
  355. /package/dist/cli-bundle/chunks/{append-NNJ3EFIT.js.map → append-DFETHAZL.js.map} +0 -0
  356. /package/dist/cli-bundle/chunks/{chunk-QJKL5PHS.js.map → chunk-7656MAUL.js.map} +0 -0
  357. /package/dist/cli-bundle/chunks/{chunk-X6K5XTTN.js.map → chunk-7W2UAXXT.js.map} +0 -0
  358. /package/dist/cli-bundle/chunks/{chunk-5OK4UGFV.js.map → chunk-BXNDKOR2.js.map} +0 -0
  359. /package/dist/cli-bundle/chunks/{chunk-KSPWRNVP.js.map → chunk-CPX275C6.js.map} +0 -0
  360. /package/dist/cli-bundle/chunks/{chunk-JH2ZSLO3.js.map → chunk-DZRV2OPA.js.map} +0 -0
  361. /package/dist/cli-bundle/chunks/{chunk-L7BH7IWU.js.map → chunk-E5XMKOSB.js.map} +0 -0
  362. /package/dist/cli-bundle/chunks/{chunk-CQTQKUUV.js.map → chunk-EWJWSNRU.js.map} +0 -0
  363. /package/dist/cli-bundle/chunks/{chunk-3MCTMJXI.js.map → chunk-FPBMLYPI.js.map} +0 -0
  364. /package/dist/cli-bundle/chunks/{chunk-DVDBQA3B.js.map → chunk-GTK4DTEW.js.map} +0 -0
  365. /package/dist/cli-bundle/chunks/{chunk-GIQSU6S2.js.map → chunk-KBLZ3AA5.js.map} +0 -0
  366. /package/dist/cli-bundle/chunks/{chunk-XJF7CDNH.js.map → chunk-KH44WBAT.js.map} +0 -0
  367. /package/dist/cli-bundle/chunks/{chunk-GV2262OF.js.map → chunk-LAV26CQG.js.map} +0 -0
  368. /package/dist/cli-bundle/chunks/{chunk-VDO2JMD4.js.map → chunk-LVC72YRD.js.map} +0 -0
  369. /package/dist/cli-bundle/chunks/{chunk-ZYPFOO3L.js.map → chunk-MATHDCGG.js.map} +0 -0
  370. /package/dist/cli-bundle/chunks/{chunk-AOEOYL3S.js.map → chunk-O4BCOJTZ.js.map} +0 -0
  371. /package/dist/cli-bundle/chunks/{chunk-RJO3YAFM.js.map → chunk-OCUBRA6D.js.map} +0 -0
  372. /package/dist/cli-bundle/chunks/{chunk-I577UHC7.js.map → chunk-OR42SO64.js.map} +0 -0
  373. /package/dist/cli-bundle/chunks/{chunk-ZOJ3LR7O.js.map → chunk-OY7DMU5P.js.map} +0 -0
  374. /package/dist/cli-bundle/chunks/{chunk-ZV2NTVMJ.js.map → chunk-PONKZPCJ.js.map} +0 -0
  375. /package/dist/cli-bundle/chunks/{chunk-UX6SSO2I.js.map → chunk-PZC2FUOQ.js.map} +0 -0
  376. /package/dist/cli-bundle/chunks/{chunk-VQIHNHMJ.js.map → chunk-QIH77CAG.js.map} +0 -0
  377. /package/dist/cli-bundle/chunks/{chunk-R3EWPG4A.js.map → chunk-QJIKE24M.js.map} +0 -0
  378. /package/dist/cli-bundle/chunks/{chunk-HB3P4M52.js.map → chunk-TRSHFPRZ.js.map} +0 -0
  379. /package/dist/cli-bundle/chunks/{chunk-HRW7GF6T.js.map → chunk-UCBDQI5E.js.map} +0 -0
  380. /package/dist/cli-bundle/chunks/{chunk-4U4Z6AHI.js.map → chunk-V22ZPOKN.js.map} +0 -0
  381. /package/dist/cli-bundle/chunks/{chunk-JM6YAXTR.js.map → chunk-VHXHVTUU.js.map} +0 -0
  382. /package/dist/cli-bundle/chunks/{chunk-D6NXDNP3.js.map → chunk-VLRGDBLY.js.map} +0 -0
  383. /package/dist/cli-bundle/chunks/{chunk-JAPE62Y5.js.map → chunk-VNTCM3VW.js.map} +0 -0
  384. /package/dist/cli-bundle/chunks/{chunk-FDHPAVVB.js.map → chunk-VXOOB6YX.js.map} +0 -0
  385. /package/dist/cli-bundle/chunks/{chunk-HQ3SB4CN.js.map → chunk-X3W65QK3.js.map} +0 -0
  386. /package/dist/cli-bundle/chunks/{chunk-RZJLNXFG.js.map → chunk-XJTABV3X.js.map} +0 -0
  387. /package/dist/cli-bundle/chunks/{chunk-TYHJDFYW.js.map → chunk-ZVZGXPQ5.js.map} +0 -0
  388. /package/dist/cli-bundle/chunks/{close-many-SDA426VT.js.map → close-many-5RZXVN4J.js.map} +0 -0
  389. /package/dist/cli-bundle/chunks/{close-many-UTZANOCQ.js.map → close-many-RZVTUGBG.js.map} +0 -0
  390. /package/dist/cli-bundle/chunks/{comments-LZN6FXXC.js.map → comments-TPU7QRBL.js.map} +0 -0
  391. /package/dist/cli-bundle/chunks/{comments-VBQ345ND.js.map → comments-Z4KV6FU3.js.map} +0 -0
  392. /package/dist/cli-bundle/chunks/{create-GG4RBCGC.js.map → create-EIFBIVNQ.js.map} +0 -0
  393. /package/dist/cli-bundle/chunks/{create-JBC5KUW6.js.map → create-RGSPN5GD.js.map} +0 -0
  394. /package/dist/cli-bundle/chunks/{deps-FI4O6NQS.js.map → deps-UH5EQQUY.js.map} +0 -0
  395. /package/dist/cli-bundle/chunks/{deps-DELOO4TL.js.map → deps-YG7UF3VR.js.map} +0 -0
  396. /package/dist/cli-bundle/chunks/{docs-6Z2MP526.js.map → docs-G32TK6XS.js.map} +0 -0
  397. /package/dist/cli-bundle/chunks/{docs-2UYBP5D6.js.map → docs-JWWNRC27.js.map} +0 -0
  398. /package/dist/cli-bundle/chunks/{files-HKEAN5MA.js.map → files-3H32UQ4K.js.map} +0 -0
  399. /package/dist/cli-bundle/chunks/{files-HEUGSJZL.js.map → files-4ALMCSKB.js.map} +0 -0
  400. /package/dist/cli-bundle/chunks/{history-compact-7NDVP3PT.js.map → history-compact-77BT2LUB.js.map} +0 -0
  401. /package/dist/cli-bundle/chunks/{history-compact-65YVN5DB.js.map → history-compact-VCKGTX64.js.map} +0 -0
  402. /package/dist/cli-bundle/chunks/{history-redact-7YBL4XSG.js.map → history-redact-LJPZPNFA.js.map} +0 -0
  403. /package/dist/cli-bundle/chunks/{history-redact-IZGNJBU4.js.map → history-redact-PWTTJ3XS.js.map} +0 -0
  404. /package/dist/cli-bundle/chunks/{history-repair-7M4PYQUH.js.map → history-repair-I7CBNCV3.js.map} +0 -0
  405. /package/dist/cli-bundle/chunks/{history-repair-GNGETJLI.js.map → history-repair-YTDZRK5E.js.map} +0 -0
  406. /package/dist/cli-bundle/chunks/{learnings-3YXDRWFT.js.map → learnings-CYNOICKR.js.map} +0 -0
  407. /package/dist/cli-bundle/chunks/{learnings-ALC6IMNL.js.map → learnings-KTYW3AL7.js.map} +0 -0
  408. /package/dist/cli-bundle/chunks/{notes-7JMLQ447.js.map → notes-FGO63FXL.js.map} +0 -0
  409. /package/dist/cli-bundle/chunks/{notes-JFCLTC5C.js.map → notes-ZERD3KB2.js.map} +0 -0
  410. /package/dist/cli-bundle/chunks/{plan-T3XB3WTK.js.map → plan-OFJUBIM5.js.map} +0 -0
  411. /package/dist/cli-bundle/chunks/{plan-KOIPWVOZ.js.map → plan-SGCDDTYR.js.map} +0 -0
  412. /package/dist/cli-bundle/chunks/{profile-OILJHKUW.js.map → profile-3THJPIQY.js.map} +0 -0
  413. /package/dist/cli-bundle/chunks/{profile-RJXA7PGS.js.map → profile-XEZAMMBW.js.map} +0 -0
  414. /package/dist/cli-bundle/chunks/{restore-ZH65GZFB.js.map → restore-6TDVSATY.js.map} +0 -0
  415. /package/dist/cli-bundle/chunks/{restore-L6IAGOD7.js.map → restore-RSL7C7LO.js.map} +0 -0
  416. /package/dist/cli-bundle/chunks/{schema-4ERWM5QJ.js.map → schema-HFXFSGPG.js.map} +0 -0
  417. /package/dist/cli-bundle/chunks/{schema-55DL3Q52.js.map → schema-TPVTIJPO.js.map} +0 -0
  418. /package/dist/cli-bundle/chunks/{update-FW6FKDOP.js.map → update-LJZCL5SI.js.map} +0 -0
  419. /package/dist/cli-bundle/chunks/{update-TJHSPRPT.js.map → update-SIA7LH5Y.js.map} +0 -0
  420. /package/dist/cli-bundle/chunks/{update-many-PWXX5WHO.js.map → update-many-BDBZVGQL.js.map} +0 -0
  421. /package/dist/cli-bundle/chunks/{update-many-NNALYQCN.js.map → update-many-MOY3A5B3.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../sdk/graph/cache.ts","../../../../../../../../sdk/relationship-context.ts","../../../../../../../../sdk/dependencies.ts"],"sourcesContent":["/**\n * @module sdk/graph/cache\n *\n * Incremental workspace graph cache: fingerprint-keyed reuse of the assembled\n * relationship graph plus memoized analytics results, so long-lived processes\n * (the MCP server, SDK consumers, packages) stop paying the full-workspace\n * assembly and analysis cost on every bounded query. The fingerprint is a\n * deterministic digest of every relationship-relevant item field — id, title,\n * lifecycle status and its terminal classification, hierarchy parent, legacy\n * blocker, and structured dependency edges — so any mutation that could change\n * the graph or its projections invalidates the entry, while unrelated payload\n * churn (bodies, comments) does not enter the digest at all. Every lookup\n * reports hit/miss observability so envelopes can explain their freshness.\n */\nimport { createHash } from \"node:crypto\";\nimport type { Dependency, ItemStatus } from \"../../types/index.js\";\nimport type {\n WorkspaceRelationshipAssembly,\n WorkspaceRelationshipItem,\n} from \"./assembly.js\";\n\n/** Default memoized query results retained per workspace entry. */\nconst DEFAULT_MAX_RESULTS_PER_WORKSPACE = 64;\n/** Default workspace entries retained by one cache instance. */\nconst DEFAULT_MAX_WORKSPACES = 8;\n\n/** Cache observability attached to graph result envelopes. */\nexport interface GraphCacheMetadata {\n /** Truncated workspace graph fingerprint identifying the snapshot answered from. */\n fingerprint: string;\n /** Whether the workspace assembly was reused from cache. */\n assembly: \"hit\" | \"miss\";\n /** Whether the full query result was reused from cache. */\n result: \"hit\" | \"miss\";\n}\n\n/** Digest one item's relationship-relevant fields into a deterministic line. */\nfunction fingerprintLine(\n item: WorkspaceRelationshipItem,\n isTerminal: (status: ItemStatus) => boolean,\n): string {\n const dependencies = (item.dependencies ?? [])\n .map((rawDependency) => {\n // Public SDK callers may supply legacy or JSON-decoded payloads; mirror\n // assembly's defensive normalization so the digest tracks what assembly\n // would actually index.\n if (typeof rawDependency !== \"object\" || rawDependency === null)\n return \"\";\n const dependency = rawDependency as Partial<Dependency>;\n return `${typeof dependency.kind === \"string\" ? dependency.kind : \"related\"}:${\n typeof dependency.id === \"string\" ? dependency.id : \"\"\n }`;\n })\n .sort()\n .join(\",\");\n return [\n item.id,\n item.title,\n item.status,\n isTerminal(item.status) ? \"1\" : \"0\",\n item.parent ?? \"\",\n item.blocked_by ?? \"\",\n dependencies,\n ].join(\"\\u0000\");\n}\n\n/**\n * Compute the deterministic workspace graph fingerprint for one item snapshot.\n * Items are digested in sorted order so storage enumeration order never\n * changes the fingerprint, and the terminal classification of each status is\n * folded in so schema changes to lifecycle semantics invalidate cached\n * assemblies even when raw statuses are unchanged.\n */\nexport function computeWorkspaceGraphFingerprint(\n items: readonly WorkspaceRelationshipItem[],\n isTerminal: (status: ItemStatus) => boolean = (status) =>\n status === \"closed\" || status === \"canceled\",\n): string {\n const lines = items\n .filter((item) => typeof item?.id === \"string\" && item.id.trim().length > 0)\n .map((item) => fingerprintLine(item, isTerminal))\n .sort();\n // Separate fields and records with control characters no stored field can\n // contain unescaped, so adjacent free-text fields can never collide.\n return createHash(\"sha256\").update(lines.join(\"\\u0001\")).digest(\"hex\");\n}\n\n/** One cached workspace snapshot: its assembly plus memoized query results. */\ninterface WorkspaceGraphCacheEntry {\n /** Fingerprint of the item snapshot this entry answers for. */\n fingerprint: string;\n /** Assembled relationship graph reused across queries. */\n assembly: WorkspaceRelationshipAssembly;\n /** Bounded insertion-ordered memo of deterministic query results. */\n results: Map<string, unknown>;\n}\n\n/** One resolved cache lookup bound to a workspace snapshot. */\nexport interface WorkspaceGraphCacheLookup {\n /** The (possibly reused) workspace assembly. */\n assembly: WorkspaceRelationshipAssembly;\n /** Whether the assembly came from cache instead of being rebuilt. */\n assemblyReused: boolean;\n /** Full fingerprint of the snapshot this lookup is bound to. */\n fingerprint: string;\n /**\n * Memoize one deterministic query result under this snapshot. On a miss the\n * freshly computed value is returned as-is while an independent clone is\n * stored, so mutating a miss result never corrupts the cache; every hit\n * returns a fresh clone of the stored entry. Callers must not rely on the\n * miss and hit paths returning the same object identity.\n */\n memoize<T>(queryKey: string, compute: () => T): { value: T; reused: boolean };\n}\n\n/** Validate one optional positive-integer cache bound, applying its default. */\nfunction requirePositiveCacheBound(\n name: string,\n value: number | undefined,\n fallback: number,\n): number {\n const bound = value ?? fallback;\n if (!Number.isInteger(bound) || bound < 1)\n throw new TypeError(`Invalid ${name} bound: ${String(value)}`);\n return bound;\n}\n\n/**\n * Fingerprint-keyed cache of workspace relationship assemblies and memoized\n * deterministic query results. One entry is retained per workspace key; a\n * changed fingerprint atomically replaces the entry and drops its memoized\n * results. Memoized values are structured-cloned on store and on read so\n * neither the producer nor any consumer can mutate cached state.\n */\nexport class WorkspaceGraphCache {\n readonly #entries = new Map<string, WorkspaceGraphCacheEntry>();\n readonly #maxResultsPerWorkspace: number;\n readonly #maxWorkspaces: number;\n\n /** Create a cache, optionally bounding workspaces and memoized results. */\n public constructor(\n options: { maxResultsPerWorkspace?: number; maxWorkspaces?: number } = {},\n ) {\n this.#maxResultsPerWorkspace = requirePositiveCacheBound(\n \"maxResultsPerWorkspace\",\n options.maxResultsPerWorkspace,\n DEFAULT_MAX_RESULTS_PER_WORKSPACE,\n );\n this.#maxWorkspaces = requirePositiveCacheBound(\n \"maxWorkspaces\",\n options.maxWorkspaces,\n DEFAULT_MAX_WORKSPACES,\n );\n }\n\n /**\n * Resolve the cached assembly for one workspace key and fingerprint,\n * building and storing it on miss. The returned lookup exposes snapshot-\n * scoped memoization for query results derived from the same assembly.\n */\n public lookup(\n key: string,\n fingerprint: string,\n build: () => WorkspaceRelationshipAssembly,\n ): WorkspaceGraphCacheLookup {\n let entry = this.#entries.get(key);\n let assemblyReused = true;\n if (entry === undefined || entry.fingerprint !== fingerprint) {\n entry = { fingerprint, assembly: build(), results: new Map() };\n assemblyReused = false;\n if (\n !this.#entries.has(key) &&\n this.#entries.size >= this.#maxWorkspaces\n ) {\n // Evict the least recently used workspace; every lookup refreshes\n // recency below, so insertion order tracks use order.\n this.#entries.delete(this.#entries.keys().next().value!);\n }\n }\n // Delete-and-reinsert keeps Map insertion order equal to recency order,\n // making workspace eviction genuinely least-recently-used.\n this.#entries.delete(key);\n this.#entries.set(key, entry);\n const resolved = entry;\n const maxResults = this.#maxResultsPerWorkspace;\n return {\n assembly: resolved.assembly,\n assemblyReused,\n fingerprint,\n memoize<T>(\n queryKey: string,\n compute: () => T,\n ): { value: T; reused: boolean } {\n const cached = resolved.results.get(queryKey);\n if (cached !== undefined || resolved.results.has(queryKey)) {\n // Refresh recency so eviction below is least-recently-used rather\n // than first-inserted.\n resolved.results.delete(queryKey);\n resolved.results.set(queryKey, cached);\n return { value: structuredClone(cached) as T, reused: true };\n }\n const value = compute();\n if (resolved.results.size >= maxResults) {\n // Evict the oldest memoized result; Map preserves insertion order.\n resolved.results.delete(resolved.results.keys().next().value!);\n }\n resolved.results.set(queryKey, structuredClone(value));\n return { value, reused: false };\n },\n };\n }\n\n /** Drop every cached workspace entry and memoized result. */\n public clear(): void {\n this.#entries.clear();\n }\n}\n\n/** Process-wide shared cache used by the CLI/MCP graph and deps adapters. */\nconst sharedCache = new WorkspaceGraphCache();\n\n/** Return the process-wide shared workspace graph cache. */\nexport function workspaceGraphCache(): WorkspaceGraphCache {\n return sharedCache;\n}\n\n/** Reset the process-wide shared workspace graph cache (tests and long-lived hosts). */\nexport function resetWorkspaceGraphCache(): void {\n sharedCache.clear();\n}\n","/**\n * @module sdk/relationship-context\n *\n * Assembles one explainable, cursorable, token-bounded relationship context\n * packet for agents, custom tools, and presentation-layer adapters.\n */\nimport {\n createQueryFingerprint,\n encodeQueryCursor,\n resolveQueryCursorStart,\n} from \"./pagination.js\";\nimport {\n RelationshipGraph,\n RelationshipKindRegistry,\n createRelationshipKindRegistry,\n type RelationshipEdge,\n type RelationshipTraversalDirection,\n} from \"./relationships.js\";\n\n/** Semantic family explaining why a node or edge participates in graph context. */\nexport type RelationshipContextRole =\n | \"prerequisite\"\n | \"dependent\"\n | \"ancestor\"\n | \"descendant\"\n | \"provenance\"\n | \"related\";\n\n/**\n * Completeness marker for one graph-context packet.\n *\n * The exact in-memory kernel only produces \"complete\" and \"truncated\" today;\n * the remaining values are reserved so index-backed, sampled, or policy-redacted\n * providers can report their result quality through the same contract.\n */\nexport type RelationshipContextCompleteness =\n | \"complete\"\n | \"truncated\"\n | \"sampled\"\n | \"approximate\"\n | \"stale_index\"\n | \"redacted\";\n\n/** Caller-owned compact node details joined into graph context. */\nexport interface RelationshipContextNodeDetails {\n /** Stable graph node identifier. */\n id: string;\n /** Optional display title. */\n title?: string;\n /** Optional lifecycle status. */\n status?: string;\n /** Optional evidence pointers such as files, tests, or history ids. */\n evidence?: readonly string[];\n}\n\n/** One selected graph-context node with explainable inclusion. */\nexport interface RelationshipContextNode extends RelationshipContextNodeDetails {\n /** Shortest bounded distance from the root. */\n distance: number;\n /** Semantic family of this node relative to its discovery counterpart. */\n role: RelationshipContextRole;\n /** Node through which bounded traversal first discovered this node. */\n via: string;\n /** Concise deterministic reasons the node was selected. */\n reasons: string[];\n}\n\n/** Counts-first packet overview served before any row payload. */\nexport interface RelationshipContextSummary {\n /** Root node identifier. */\n rootId: string;\n /** Root lifecycle status when the caller supplied node details. */\n rootStatus?: string;\n /** Root-incident edge counts per semantic family under the active filters. */\n directEdges: Record<RelationshipContextRole, number>;\n /** Total root-incident edges under the active filters. */\n directTotal: number;\n /** Nodes discovered by the bounded traversal, excluding the root. */\n discoveredNodes: number;\n /** Nodes returned in this page. */\n returnedNodes: number;\n /** Edges returned in this page. */\n returnedEdges: number;\n /** Discovered nodes omitted by pagination, node, or token bounds. */\n omittedNodes: number;\n /** Qualifying edges omitted by edge or token bounds. */\n omittedEdges: number;\n /** Root evidence pointers promoted into the packet. */\n evidenceCount: number;\n /** Whether a continuation cursor is available. */\n hasMore: boolean;\n}\n\n/** Controls for bounded graph-context assembly. */\nexport interface RelationshipContextOptions {\n /** Traversal direction relative to each visited node. */\n direction?: RelationshipTraversalDirection;\n /** Optional registered kind filter. */\n kinds?: readonly string[];\n /** Maximum traversal depth. */\n maxDepth?: number;\n /** Maximum nodes returned in this page. */\n nodeLimit?: number;\n /** Maximum edges returned in this page. */\n edgeLimit?: number;\n /** Maximum estimated output tokens charged to rows and edges. */\n tokenBudget?: number;\n /** Opaque continuation from an equivalent query. */\n cursor?: string;\n /** Registry used to explain custom relationship semantics. */\n registry?: RelationshipKindRegistry;\n /** Abort signal checked during traversal. */\n signal?: AbortSignal;\n}\n\n/** Explainable graph context packet. */\nexport interface RelationshipContextResult {\n /** Root node details. */\n root: RelationshipContextNodeDetails;\n /** Counts-first overview of the packet. */\n summary: RelationshipContextSummary;\n /** Bounded related-node page. */\n nodes: RelationshipContextNode[];\n /** Bounded edges whose endpoints are present in the packet. */\n edges: RelationshipEdge[];\n /** Root evidence pointers promoted for immediate consumption. */\n evidence: string[];\n /** Completeness, continuation, and cost envelope. */\n meta: {\n exact: true;\n truncated: boolean;\n completeness: RelationshipContextCompleteness;\n nodeLimit: number;\n edgeLimit: number;\n tokenBudget: number;\n usedTokens: number;\n visitedNodes: number;\n inspectedEdges: number;\n omittedNodes: number;\n omittedEdges: number;\n nextCursor?: string;\n };\n}\n\ninterface DiscoveredNode {\n id: string;\n distance: number;\n via: string;\n role: RelationshipContextRole;\n}\n\n/** Deterministic priority used when one node matches several semantic families. */\nconst RELATIONSHIP_CONTEXT_ROLE_PRIORITY: readonly RelationshipContextRole[] = [\n \"prerequisite\",\n \"dependent\",\n \"ancestor\",\n \"descendant\",\n \"provenance\",\n \"related\",\n];\n\nconst tokenEncoder = new TextEncoder();\n\nfunction positiveInteger(\n value: number | undefined,\n fallback: number,\n field: string,\n): number {\n const resolved = value ?? fallback;\n if (!Number.isInteger(resolved) || resolved < 1)\n throw new TypeError(`Relationship context ${field} must be positive`);\n return resolved;\n}\n\nfunction estimateTokens(value: unknown): number {\n return Math.max(\n 1,\n Math.ceil(tokenEncoder.encode(JSON.stringify(value)).byteLength / 4),\n );\n}\n\nfunction explainDirectEdge(\n edge: RelationshipEdge,\n node: string,\n registry: RelationshipKindRegistry,\n): RelationshipContextRole {\n const definition = registry.resolve(edge.kind);\n if (definition?.ordering) {\n // Legacy and JSON-parsed definitions may predate explicit precedence.\n const sourceFirst =\n (definition.precedence ?? \"source_before_target\") ===\n \"source_before_target\";\n const before = sourceFirst ? edge.source : edge.target;\n return node === before ? \"prerequisite\" : \"dependent\";\n }\n if (definition?.hierarchy) {\n // Legacy and JSON-parsed definitions may predate explicit hierarchy direction.\n const sourceIsParent =\n (definition.hierarchyDirection ?? \"source_parent\") === \"source_parent\";\n const parent = sourceIsParent ? edge.source : edge.target;\n return node === parent ? \"ancestor\" : \"descendant\";\n }\n if (edge.kind === \"discovered_from\" || edge.kind === \"incident_from\")\n return \"provenance\";\n return \"related\";\n}\n\nfunction directReasons(\n rootEdges: readonly RelationshipEdge[],\n root: string,\n node: string,\n registry: RelationshipKindRegistry,\n): RelationshipContextRole[] {\n const reasons = rootEdges\n .filter(\n (edge) =>\n (edge.source === root && edge.target === node) ||\n (edge.target === root && edge.source === node),\n )\n .map((edge) => explainDirectEdge(edge, node, registry));\n return [...new Set(reasons)].sort();\n}\n\n/** Pick the deterministic primary family when a node matches several. */\nfunction primaryRole(\n roles: readonly RelationshipContextRole[],\n): RelationshipContextRole {\n // Callers only pass non-empty classification sets drawn from the fixed\n // family list, so a priority match always exists.\n return RELATIONSHIP_CONTEXT_ROLE_PRIORITY.find((role) =>\n roles.includes(role),\n )!;\n}\n\nfunction discoverNodes(\n graph: RelationshipGraph,\n root: string,\n registry: RelationshipKindRegistry,\n options: RelationshipContextOptions,\n): {\n rows: DiscoveredNode[];\n visitedNodes: number;\n inspectedEdges: number;\n depthTruncated: boolean;\n} {\n const direction = options.direction ?? \"both\";\n const maxDepth = options.maxDepth ?? 3;\n if (!Number.isInteger(maxDepth) || maxDepth < 0)\n throw new TypeError(\"Relationship context maxDepth must be non-negative\");\n const seen = new Set([root]);\n const queue: { id: string; distance: number }[] = [\n { id: root, distance: 0 },\n ];\n const rows: DiscoveredNode[] = [];\n let inspectedEdges = 0;\n let depthTruncated = false;\n for (let index = 0; index < queue.length; index += 1) {\n options.signal?.throwIfAborted();\n const current = queue[index]!;\n if (current.distance >= maxDepth && depthTruncated) continue;\n const adjacent = graph.neighborEdges(current.id, {\n direction,\n kinds: options.kinds,\n signal: options.signal,\n });\n inspectedEdges += adjacent.meta.inspectedEdges;\n if (current.distance >= maxDepth) {\n if (adjacent.value.some((row) => !seen.has(row.id))) depthTruncated = true;\n continue;\n }\n for (const { id, edge } of adjacent.value) {\n if (seen.has(id)) continue;\n seen.add(id);\n const row = {\n id,\n distance: current.distance + 1,\n via: current.id,\n role: explainDirectEdge(edge, id, registry),\n };\n rows.push(row);\n queue.push(row);\n }\n }\n rows.sort(\n (left, right) =>\n left.distance - right.distance || left.id.localeCompare(right.id),\n );\n return {\n rows,\n visitedNodes: queue.length,\n inspectedEdges,\n depthTruncated,\n };\n}\n\n/** Count root-incident edges per semantic family under the active filters. */\nfunction summarizeDirectEdges(\n graph: RelationshipGraph,\n root: string,\n registry: RelationshipKindRegistry,\n options: RelationshipContextOptions,\n): {\n directEdges: Record<RelationshipContextRole, number>;\n directTotal: number;\n rootEdges: RelationshipEdge[];\n} {\n const directEdges: Record<RelationshipContextRole, number> = {\n prerequisite: 0,\n dependent: 0,\n ancestor: 0,\n descendant: 0,\n provenance: 0,\n related: 0,\n };\n const rows = graph.neighborEdges(root, {\n direction: options.direction ?? \"both\",\n kinds: options.kinds,\n signal: options.signal,\n }).value;\n for (const { id, edge } of rows)\n directEdges[explainDirectEdge(edge, id, registry)] += 1;\n return {\n directEdges,\n directTotal: rows.length,\n rootEdges: rows.map(({ edge }) => edge),\n };\n}\n\nfunction selectContextNodes(params: {\n candidates: readonly DiscoveredNode[];\n details: ReadonlyMap<string, RelationshipContextNodeDetails>;\n rootEdges: readonly RelationshipEdge[];\n rootId: string;\n registry: RelationshipKindRegistry;\n nodeLimit: number;\n tokenBudget: number;\n initialTokens: number;\n}): { nodes: RelationshipContextNode[]; usedTokens: number } {\n const nodes: RelationshipContextNode[] = [];\n let usedTokens = params.initialTokens;\n for (const candidate of params.candidates) {\n if (nodes.length >= params.nodeLimit) break;\n const direct =\n candidate.distance === 1\n ? directReasons(\n params.rootEdges,\n params.rootId,\n candidate.id,\n params.registry,\n )\n : [];\n const node: RelationshipContextNode = {\n ...(params.details.get(candidate.id) ?? { id: candidate.id }),\n distance: candidate.distance,\n role: direct.length > 0 ? primaryRole(direct) : candidate.role,\n via: candidate.via,\n reasons:\n direct.length > 0\n ? direct\n : [\n `${candidate.role} via ${candidate.via} (depth ${candidate.distance})`,\n ],\n };\n const cost = estimateTokens(node);\n if (usedTokens + cost > params.tokenBudget) break;\n nodes.push(node);\n usedTokens += cost;\n }\n if (params.candidates.length > 0 && nodes.length === 0)\n throw new TypeError(\"Relationship context tokenBudget cannot fit one node\");\n return { nodes, usedTokens };\n}\n\nfunction selectContextEdges(params: {\n graph: RelationshipGraph;\n included: ReadonlySet<string>;\n options: RelationshipContextOptions;\n registry: RelationshipKindRegistry;\n edgeLimit: number;\n tokenBudget: number;\n initialTokens: number;\n}): {\n edges: RelationshipEdge[];\n usedTokens: number;\n candidateCount: number;\n} {\n const kinds = params.options.kinds\n ? new Set(\n params.options.kinds.map((kind) => params.registry.require(kind).kind),\n )\n : undefined;\n const candidates = params.graph\n .edges()\n .filter(\n (edge) => {\n if (\n !params.included.has(edge.source) ||\n !params.included.has(edge.target)\n )\n return false;\n if (kinds === undefined || kinds.has(edge.kind)) return true;\n const inverse = params.registry.resolve(edge.kind)?.inverse;\n return inverse !== undefined && kinds.has(inverse);\n },\n );\n const edges: RelationshipEdge[] = [];\n let usedTokens = params.initialTokens;\n for (const edge of candidates) {\n if (edges.length >= params.edgeLimit) break;\n const cost = estimateTokens(edge);\n if (usedTokens + cost > params.tokenBudget) break;\n edges.push(edge);\n usedTokens += cost;\n }\n return { edges, usedTokens, candidateCount: candidates.length };\n}\n\n/** Build one deterministic bounded graph-context packet with continuation. */\nexport function buildRelationshipContext(\n graph: RelationshipGraph,\n rootId: string,\n details: readonly RelationshipContextNodeDetails[],\n options: RelationshipContextOptions = {},\n): RelationshipContextResult {\n if (!graph.nodes().includes(rootId))\n throw new TypeError(`Relationship node not found: ${rootId}`);\n const nodeLimit = positiveInteger(options.nodeLimit, 20, \"nodeLimit\");\n const edgeLimit = positiveInteger(options.edgeLimit, 40, \"edgeLimit\");\n const tokenBudget = positiveInteger(options.tokenBudget, 1200, \"tokenBudget\");\n const registry = options.registry ?? createRelationshipKindRegistry();\n const byId = new Map(details.map((detail) => [detail.id, detail]));\n const rootDetails: RelationshipContextNodeDetails = byId.get(rootId) ?? {\n id: rootId,\n };\n const { evidence: rootEvidence = [], ...root } = rootDetails;\n const evidence = [...rootEvidence];\n const discovery = discoverNodes(graph, rootId, registry, options);\n const { rootEdges, ...directSummary } = summarizeDirectEdges(\n graph,\n rootId,\n registry,\n options,\n );\n const fingerprint = createQueryFingerprint(\"relationship-context\", {\n rootId,\n direction: options.direction ?? \"both\",\n kinds: [...(options.kinds ?? [])].sort(),\n maxDepth: options.maxDepth ?? 3,\n });\n const pageStart = resolveQueryCursorStart(\n discovery.rows,\n options.cursor,\n fingerprint,\n ({ id }) => id,\n );\n const candidates = discovery.rows.slice(pageStart);\n const initialTokens = estimateTokens(root) + estimateTokens(evidence);\n if (initialTokens > tokenBudget)\n throw new TypeError(\n \"Relationship context tokenBudget cannot fit root and evidence\",\n );\n const nodeSelection = selectContextNodes({\n candidates,\n details: byId,\n rootEdges,\n rootId,\n registry,\n nodeLimit,\n tokenBudget,\n initialTokens,\n });\n const { nodes } = nodeSelection;\n\n const included = new Set([rootId, ...nodes.map(({ id }) => id)]);\n const edgeSelection = selectContextEdges({\n graph,\n included,\n options,\n registry,\n edgeLimit,\n tokenBudget,\n initialTokens: nodeSelection.usedTokens,\n });\n const { edges, usedTokens } = edgeSelection;\n\n const consumed = pageStart + nodes.length;\n const hasMoreNodes = consumed < discovery.rows.length;\n const lastNode = nodes.at(-1);\n const omittedEdges = edgeSelection.candidateCount - edges.length;\n const truncated =\n discovery.depthTruncated || hasMoreNodes || omittedEdges > 0;\n const summary: RelationshipContextSummary = {\n rootId,\n ...(root.status === undefined ? {} : { rootStatus: root.status }),\n ...directSummary,\n discoveredNodes: discovery.rows.length,\n returnedNodes: nodes.length,\n returnedEdges: edges.length,\n omittedNodes: discovery.rows.length - consumed,\n omittedEdges,\n evidenceCount: evidence.length,\n hasMore: hasMoreNodes,\n };\n return {\n root,\n summary,\n nodes,\n edges,\n evidence,\n meta: {\n exact: true,\n truncated,\n completeness: truncated ? \"truncated\" : \"complete\",\n nodeLimit,\n edgeLimit,\n tokenBudget,\n usedTokens,\n visitedNodes: discovery.visitedNodes,\n inspectedEdges: discovery.inspectedEdges,\n omittedNodes: discovery.rows.length - consumed,\n omittedEdges,\n ...(hasMoreNodes && lastNode\n ? {\n nextCursor: encodeQueryCursor(\n fingerprint,\n lastNode.id,\n consumed - 1,\n ),\n }\n : {}),\n },\n };\n}\n","/**\n * @module sdk/dependencies\n *\n * Implements the pm deps command surface and its agent-facing runtime behavior.\n */\nimport { getActiveExtensionRegistrations } from \"../core/extensions/index.js\";\nimport { pathExists } from \"../core/fs/fs-utils.js\";\nimport { resolveItemTypeRegistry } from \"../core/item/type-registry.js\";\nimport { isTerminalStatus } from \"../core/item/status.js\";\nimport { resolveRuntimeStatusRegistry } from \"../core/schema/runtime-schema.js\";\nimport { EXIT_CODE } from \"../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../core/shared/command-types.js\";\nimport { PmCliError } from \"../core/shared/errors.js\";\nimport {\n listAllItemMetadataLight,\n locateItem,\n readLocatedItem,\n} from \"../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../core/store/paths.js\";\nimport { readSettings } from \"../core/store/settings.js\";\nimport type {\n Dependency,\n ItemMetadata,\n ItemStatus,\n ItemType,\n} from \"../types/index.js\";\nimport {\n assembleWorkspaceRelationshipGraph,\n collectDanglingDependencyReferences,\n type DanglingDependencyReference,\n type WorkspaceRelationshipAssembly,\n} from \"./graph/assembly.js\";\nimport {\n computeWorkspaceGraphFingerprint,\n workspaceGraphCache,\n} from \"./graph/cache.js\";\nimport {\n buildRelationshipContext,\n type RelationshipContextOptions,\n type RelationshipContextResult,\n} from \"./relationship-context.js\";\nimport { createRelationshipKindRegistry } from \"./relationships.js\";\n\n/** Supported values accepted by the deps format contract. */\nexport const DEPS_FORMAT_VALUES = [\"tree\", \"graph\", \"context\"] as const;\n/** Restricts deps format values accepted by command, SDK, and storage contracts. */\nexport type DepsFormat = (typeof DEPS_FORMAT_VALUES)[number];\n/** Supported values accepted by the deps collapse contract. */\nexport const DEPS_COLLAPSE_VALUES = [\"none\", \"repeated\"] as const;\n/** Restricts deps collapse mode values accepted by command, SDK, and storage contracts. */\nexport type DepsCollapseMode = (typeof DEPS_COLLAPSE_VALUES)[number];\n/** Supported values accepted by the deps graph-context direction contract. */\nexport const DEPS_DIRECTION_VALUES = [\"outgoing\", \"incoming\", \"both\"] as const;\n/** Restricts deps traversal-direction values accepted by command, SDK, and storage contracts. */\nexport type DepsDirection = (typeof DEPS_DIRECTION_VALUES)[number];\n\n/** Documents the deps command options payload exchanged by command, SDK, and package integrations. */\nexport interface DepsCommandOptions {\n /** Value that configures or reports format for this contract. */\n format?: string;\n /** Value that configures or reports max depth for this contract. */\n maxDepth?: string | number;\n /** Value that configures or reports collapse for this contract. */\n collapse?: string;\n /** Value that configures or reports summary for this contract. */\n summary?: boolean;\n /** Maximum graph-context nodes returned. */\n nodeLimit?: string | number;\n /** Maximum graph-context edges and enumerated missing-reference rows returned. */\n edgeLimit?: string | number;\n /** Maximum estimated graph-context output tokens. */\n tokenBudget?: string | number;\n /** Opaque continuation cursor for graph-context output. */\n cursor?: string;\n /** Graph-context traversal direction relative to each visited node. */\n direction?: string;\n /** Registered relationship kinds narrowing graph-context traversal. */\n kind?: string | string[];\n}\n\ninterface IndexedItem {\n id: string;\n title: string;\n type: ItemType;\n status: ItemStatus;\n dependencies: IndexedDependency[];\n}\n\ninterface IndexedDependency {\n id: string;\n kind: string;\n}\n\n/** Documents the deps tree node payload exchanged by command, SDK, and package integrations. */\nexport interface DepsTreeNode {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title?: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type?: ItemType;\n /** Lifecycle state reported for status. */\n status?: ItemStatus;\n /** Value that configures or reports via for this contract. */\n via?: string;\n /** Value that configures or reports missing for this contract. */\n missing: boolean;\n /** Value that configures or reports cycle for this contract. */\n cycle: boolean;\n /** Value that configures or reports truncated for this contract. */\n truncated?: boolean;\n /** Value that configures or reports collapsed for this contract. */\n collapsed?: boolean;\n /** Value that configures or reports dependencies for this contract. */\n dependencies: DepsTreeNode[];\n}\n\n/** Documents the deps graph node payload exchanged by command, SDK, and package integrations. */\nexport interface DepsGraphNode {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title?: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type?: ItemType;\n /** Lifecycle state reported for status. */\n status?: ItemStatus;\n /** Value that configures or reports missing for this contract. */\n missing: boolean;\n}\n\n/** Documents the deps graph edge payload exchanged by command, SDK, and package integrations. */\nexport interface DepsGraphEdge {\n /** Value that configures or reports from for this contract. */\n from: string;\n /** Value that configures or reports to for this contract. */\n to: string;\n /** Value that configures or reports kind for this contract. */\n kind: string;\n}\n\n/** Documents the deps graph result payload exchanged by command, SDK, and package integrations. */\nexport interface DepsGraphResult {\n /** Value that configures or reports root id for this contract. */\n root_id: string;\n /** Value that configures or reports nodes for this contract. */\n nodes: DepsGraphNode[];\n /** Value that configures or reports edges for this contract. */\n edges: DepsGraphEdge[];\n /** Value that configures or reports missing ids for this contract. */\n missing_ids: string[];\n}\n\n/** Documents the deps result payload exchanged by command, SDK, and package integrations. */\nexport interface DepsResult {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports format for this contract. */\n format: DepsFormat;\n /** Number of node entries represented by this result. */\n node_count: number;\n /** Number of edge entries represented by this result. */\n edge_count: number;\n /**\n * Number of missing entries represented by this result.\n *\n * Tree and graph formats count missing nodes encountered while walking\n * dependency edges; context format counts missing nodes reachable within the\n * same bounded traversal (direction, kinds, and depth) that produced the\n * packet, independent of node or token pagination, so the two formats agree\n * for equal traversal parameters over the dependency edge family.\n */\n missing_count: number;\n /** Traversal scope documenting the missing_count semantics for context format. */\n missing_scope?: \"traversal\";\n /** Total dangling references declared into the traversed missing nodes. */\n missing_reference_count?: number;\n /** Bounded enumeration of dangling references, capped by the context edge limit. */\n missing_references?: DanglingDependencyReference[];\n /** Value that configures or reports tree for this contract. */\n tree?: DepsTreeNode;\n /** Value that configures or reports graph for this contract. */\n graph?: DepsGraphResult;\n /** Explainable bounded graph-context projection. */\n context?: RelationshipContextResult;\n}\n\nfunction parseFormat(raw: string | undefined): DepsFormat {\n const candidate = raw?.trim().toLowerCase() ?? \"tree\";\n if ((DEPS_FORMAT_VALUES as readonly string[]).includes(candidate)) {\n return candidate as DepsFormat;\n }\n throw new PmCliError(\n `Invalid --format value \"${raw}\". Use \"tree\", \"graph\", or \"context\".`,\n EXIT_CODE.USAGE,\n );\n}\n\n/** Parse one positive-integer graph bound, failing fast with the offending flag name. */\nexport function parsePositiveInteger(raw: string | number | undefined, flag: string): number | undefined {\n if (raw === undefined) return undefined;\n const value = typeof raw === \"number\" ? raw : Number(raw.trim());\n if (!Number.isInteger(value) || value < 1)\n throw new PmCliError(`Invalid --${flag} value \"${raw}\". Use a positive integer.`, EXIT_CODE.USAGE);\n return value;\n}\n\n/** Parse the shared non-negative --max-depth traversal bound. */\nexport function parseMaxDepth(raw: string | number | undefined): number | undefined {\n if (raw === undefined) {\n return undefined;\n }\n const normalized = typeof raw === \"number\" ? raw : Number(raw.trim());\n if (!Number.isInteger(normalized) || normalized < 0) {\n throw new PmCliError(\n `Invalid --max-depth value \"${raw}\". Use a non-negative integer.`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized;\n}\n\nfunction parseCollapse(raw: string | undefined): DepsCollapseMode {\n const candidate = raw?.trim().toLowerCase() ?? \"none\";\n if ((DEPS_COLLAPSE_VALUES as readonly string[]).includes(candidate)) {\n return candidate as DepsCollapseMode;\n }\n throw new PmCliError(\n `Invalid --collapse value \"${raw}\". Use \"none\" or \"repeated\".`,\n EXIT_CODE.USAGE,\n );\n}\n\n/** Parse the shared graph traversal --direction value, defaulting to \"both\". */\nexport function parseDirection(raw: string | undefined): DepsDirection {\n const candidate = raw?.trim().toLowerCase() ?? \"both\";\n if ((DEPS_DIRECTION_VALUES as readonly string[]).includes(candidate)) {\n return candidate as DepsDirection;\n }\n throw new PmCliError(\n `Invalid --direction value \"${raw}\". Use \"outgoing\", \"incoming\", or \"both\".`,\n EXIT_CODE.USAGE,\n );\n}\n\n/**\n * Normalize repeatable and comma-separated --kind values against the built-in\n * relationship ontology, failing fast on unknown kinds instead of silently\n * matching nothing (the multi-value filter-grammar trap tracked by pm-gknu).\n */\nexport function parseKinds(raw: string | string[] | undefined): string[] | undefined {\n if (raw === undefined) return undefined;\n const registry = createRelationshipKindRegistry();\n const values = (Array.isArray(raw) ? raw : [raw])\n .flatMap((value) => value.split(\",\"))\n .map((value) => value.trim())\n .filter((value) => value.length > 0);\n if (values.length === 0) return undefined;\n const kinds = new Set<string>();\n for (const value of values) {\n const definition = registry.resolve(value);\n if (!definition) {\n const known = registry\n .list()\n .map((entry) => entry.kind)\n .join(\", \");\n throw new PmCliError(\n `Invalid --kind value \"${value}\". Registered kinds: ${known}.`,\n EXIT_CODE.USAGE,\n );\n }\n kinds.add(definition.kind);\n }\n return [...kinds].sort();\n}\n\nfunction normalizeDependencies(\n dependencies: Dependency[] | undefined,\n): IndexedDependency[] {\n if (!dependencies || dependencies.length === 0) {\n return [];\n }\n const sorted = dependencies.map(({ id, kind }) => ({\n id: id.trim(),\n kind: kind.trim().toLowerCase(),\n })).sort((left, right) => {\n const byKind = left.kind.localeCompare(right.kind);\n if (byKind !== 0) return byKind;\n return left.id.localeCompare(right.id);\n });\n const deduped = new Map<string, IndexedDependency>();\n for (const dependency of sorted) {\n const key = `${dependency.kind.toLowerCase()}::${dependency.id.toLowerCase()}`;\n if (!deduped.has(key)) {\n deduped.set(key, { id: dependency.id, kind: dependency.kind });\n }\n }\n return [...deduped.values()];\n}\n\nfunction toIndexedItem(item: ItemMetadata): IndexedItem {\n return {\n id: item.id,\n title: item.title,\n type: item.type,\n status: item.status,\n dependencies: normalizeDependencies(item.dependencies),\n };\n}\n\nfunction toTreeNode(\n id: string,\n index: Map<string, IndexedItem>,\n lineage: Set<string>,\n maxDepth: number | undefined,\n collapse: DepsCollapseMode,\n expanded: Set<string>,\n depth = 0,\n via?: string,\n): DepsTreeNode {\n const lookupId = id.trim().toLowerCase();\n const item = index.get(lookupId);\n const baseNode: DepsTreeNode = {\n id: item?.id ?? id,\n title: item?.title,\n type: item?.type,\n status: item?.status,\n via,\n missing: !item,\n cycle: lineage.has(lookupId),\n dependencies: [],\n };\n if (!item || baseNode.cycle) {\n return baseNode;\n }\n if (maxDepth !== undefined && depth >= maxDepth) {\n if (item.dependencies.length > 0) {\n baseNode.truncated = true;\n }\n return baseNode;\n }\n if (collapse === \"repeated\" && expanded.has(lookupId)) {\n baseNode.collapsed = true;\n return baseNode;\n }\n if (collapse === \"repeated\") {\n expanded.add(lookupId);\n }\n const nextLineage = new Set(lineage);\n nextLineage.add(lookupId);\n baseNode.dependencies = item.dependencies.map((dependency) =>\n toTreeNode(\n dependency.id,\n index,\n nextLineage,\n maxDepth,\n collapse,\n expanded,\n depth + 1,\n dependency.kind,\n ),\n );\n return baseNode;\n}\n\nfunction mergeGraphNode(\n existing: DepsGraphNode | undefined,\n candidate: DepsGraphNode,\n): DepsGraphNode {\n if (!existing) {\n return candidate;\n }\n /* c8 ignore start -- defensive: mixed missing/non-missing duplicates only occur in malformed synthetic trees. */\n if (existing.missing && !candidate.missing) return candidate;\n /* c8 ignore stop */\n return {\n ...existing,\n title: existing.title ?? candidate.title,\n type: existing.type ?? candidate.type,\n status: existing.status ?? candidate.status,\n };\n}\n\nfunction toGraph(root: DepsTreeNode): DepsGraphResult {\n const nodesById = new Map<string, DepsGraphNode>();\n const edgesByKey = new Map<string, DepsGraphEdge>();\n\n const visit = (node: DepsTreeNode): void => {\n nodesById.set(\n node.id,\n mergeGraphNode(nodesById.get(node.id), {\n id: node.id,\n title: node.title,\n type: node.type,\n status: node.status,\n missing: node.missing,\n }),\n );\n for (const child of node.dependencies) {\n nodesById.set(\n child.id,\n mergeGraphNode(nodesById.get(child.id), {\n id: child.id,\n title: child.title,\n type: child.type,\n status: child.status,\n missing: child.missing,\n }),\n );\n /* c8 ignore start -- legacy malformed dependency payloads may omit kind/via. */\n const relationKind = child.via ?? \"related\";\n const edgeKey = `${node.id}::${child.id}::${relationKind}`;\n if (!edgesByKey.has(edgeKey)) {\n edgesByKey.set(edgeKey, {\n from: node.id,\n to: child.id,\n kind: relationKind,\n });\n }\n /* c8 ignore stop */\n if (!child.cycle) {\n visit(child);\n }\n }\n };\n\n visit(root);\n\n const nodes = [...nodesById.values()].sort((left, right) =>\n left.id.localeCompare(right.id),\n );\n const edges = [...edgesByKey.values()].sort((left, right) => {\n const byFrom = left.from.localeCompare(right.from);\n if (byFrom !== 0) return byFrom;\n const byTo = left.to.localeCompare(right.to);\n if (byTo !== 0) return byTo;\n return left.kind.localeCompare(right.kind);\n });\n const missingIds = nodes\n .filter((node) => node.missing)\n .map((node) => node.id);\n return {\n root_id: root.id,\n nodes,\n edges,\n missing_ids: missingIds,\n };\n}\n\n/** Count a dependency result without allocating its potentially exponential tree payload. */\nfunction countDependencyGraph(\n rootId: string,\n index: Map<string, IndexedItem>,\n maxDepth: number | undefined,\n): Pick<DepsResult, \"node_count\" | \"edge_count\" | \"missing_count\"> {\n const nodeIds = new Set<string>();\n const edgeKeys = new Set<string>();\n const missingIds = new Set<string>();\n const expanded = new Set<string>();\n const pending = [{ id: rootId, depth: 0 }];\n let pendingIndex = 0;\n while (pendingIndex < pending.length) {\n const current = pending[pendingIndex++]!;\n const lookupId = current.id.trim().toLowerCase();\n nodeIds.add(lookupId);\n const item = index.get(lookupId);\n if (!item) {\n missingIds.add(lookupId);\n continue;\n }\n if (maxDepth !== undefined && current.depth >= maxDepth) {\n continue;\n }\n if (expanded.has(lookupId)) {\n continue;\n }\n expanded.add(lookupId);\n for (const dependency of item.dependencies) {\n edgeKeys.add(\n `${lookupId}::${dependency.id.trim().toLowerCase()}::${dependency.kind}`,\n );\n pending.push({ id: dependency.id, depth: current.depth + 1 });\n }\n }\n return {\n node_count: nodeIds.size,\n edge_count: edgeKeys.size,\n missing_count: missingIds.size,\n };\n}\n\n/** Options subset consumed by the deps graph-context projection. */\ntype DepsContextOptions = Pick<\n DepsCommandOptions,\n | \"maxDepth\"\n | \"nodeLimit\"\n | \"edgeLimit\"\n | \"tokenBudget\"\n | \"cursor\"\n | \"direction\"\n | \"kind\"\n>;\n\n/** Parse CLI-compatible deps context options once for packet and closure parity. */\nfunction parseDepsContextOptions(\n options: DepsContextOptions,\n): RelationshipContextOptions {\n const maxDepth = parseMaxDepth(options.maxDepth);\n const nodeLimit = parsePositiveInteger(options.nodeLimit, \"node-limit\");\n const edgeLimit = parsePositiveInteger(options.edgeLimit, \"edge-limit\");\n const tokenBudget = parsePositiveInteger(options.tokenBudget, \"token-budget\");\n const kinds = parseKinds(options.kind);\n return {\n direction: parseDirection(options.direction),\n ...(kinds === undefined ? {} : { kinds }),\n ...(maxDepth === undefined ? {} : { maxDepth }),\n ...(nodeLimit === undefined ? {} : { nodeLimit }),\n ...(edgeLimit === undefined ? {} : { edgeLimit }),\n ...(tokenBudget === undefined ? {} : { tokenBudget }),\n ...(options.cursor?.trim() ? { cursor: options.cursor.trim() } : {}),\n };\n}\n\n/** Build one bounded context packet from an assembled deps relationship graph. */\nfunction buildContextFromAssembly(\n assembly: WorkspaceRelationshipAssembly,\n rootId: string,\n options: RelationshipContextOptions,\n rootEvidence: readonly string[],\n): RelationshipContextResult {\n return buildRelationshipContext(\n assembly.graph,\n rootId,\n assembly.details.map((detail) =>\n detail.id === rootId && rootEvidence.length > 0\n ? { ...detail, evidence: rootEvidence }\n : detail,\n ),\n options,\n );\n}\n\n/** Build the SDK-backed bounded relationship-context projection for deps. */\nexport function buildDepsRelationshipContext(\n rootId: string,\n items: readonly ItemMetadata[],\n options: DepsContextOptions,\n rootEvidence: readonly string[] = [],\n): RelationshipContextResult {\n return buildContextFromAssembly(\n assembleWorkspaceRelationshipGraph(items),\n rootId,\n parseDepsContextOptions(options),\n rootEvidence,\n );\n}\n\n/** Append up to `limit` labeled pointers from one linked collection. */\nfunction appendEvidencePointers(\n evidence: string[],\n label: string,\n values: readonly (string | undefined)[],\n limit: number,\n): void {\n for (const value of values.slice(0, limit)) {\n const trimmed = value?.trim();\n if (trimmed) evidence.push(`${label}:${trimmed}`);\n }\n}\n\n/**\n * Load bounded root evidence pointers (linked files, tests, docs, and\n * annotation counts) so the context packet answers \"where is the proof\"\n * without a follow-up item read.\n */\nasync function collectRootEvidence(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<string[]> {\n const located = await locateItem(\n pmRoot,\n id,\n settings.id_prefix,\n settings.item_format,\n typeToFolder,\n );\n // The caller already resolved the root against the light index, so a miss\n // can only happen when storage mutates mid-read; degrade to no evidence.\n /* c8 ignore start -- defensive: unreachable without a concurrent delete between the index scan and this read. */\n if (!located) return [];\n /* c8 ignore stop */\n const { document } = await readLocatedItem(located, {\n schema: settings.schema,\n });\n const metadata = document.metadata;\n const files = metadata.files ?? [];\n const tests = metadata.tests ?? [];\n const docs = metadata.docs ?? [];\n const counts = [\n [\"files\", files.length],\n [\"tests\", tests.length],\n [\"docs\", docs.length],\n [\"comments\", (metadata.comments ?? []).length],\n [\"notes\", (metadata.notes ?? []).length],\n [\"learnings\", (metadata.learnings ?? []).length],\n ] as const;\n if (counts.every(([, count]) => count === 0)) return [];\n const evidence = [\n `linked:${counts.map(([key, count]) => `${key}=${count}`).join(\",\")}`,\n ];\n appendEvidencePointers(evidence, \"file\", files.map((file) => file.path), 3);\n appendEvidencePointers(\n evidence,\n \"test\",\n tests.map((test) => test.command ?? test.path),\n 2,\n );\n appendEvidencePointers(evidence, \"doc\", docs.map((doc) => doc.path), 2);\n return evidence;\n}\n\n/** Assemble the context-format deps result with traversal-scoped missing enumeration. */\nfunction buildContextDepsResult(params: {\n assembly: WorkspaceRelationshipAssembly;\n canonicalId: string;\n options: DepsCommandOptions;\n rootEvidence: readonly string[];\n summaryOnly: boolean;\n}): DepsResult {\n const { assembly, canonicalId, options, rootEvidence, summaryOnly } = params;\n const contextOptions = parseDepsContextOptions(options);\n const context = buildContextFromAssembly(\n assembly,\n canonicalId,\n contextOptions,\n rootEvidence,\n );\n const reachable = assembly.graph.closure(canonicalId, {\n direction: contextOptions.direction,\n ...(contextOptions.kinds === undefined\n ? {}\n : { kinds: contextOptions.kinds }),\n maxDepth: contextOptions.maxDepth ?? 3,\n });\n const missingReachable = reachable.value.filter((nodeId) =>\n assembly.missingIdSet.has(nodeId.toLowerCase()),\n );\n const missingReachableSet = new Set(\n missingReachable.map((nodeId) => nodeId.toLowerCase()),\n );\n const relationshipRegistry = assembly.graph.registry();\n const filteredKinds = contextOptions.kinds\n ? new Set(\n contextOptions.kinds.map(\n (kind) => relationshipRegistry.require(kind).kind,\n ),\n )\n : undefined;\n const packetIds = new Set([canonicalId, ...reachable.value]);\n const missingReferences = [\n ...assembly.dangling.active,\n ...assembly.dangling.legacy_terminal,\n ].filter((row) => {\n if (\n row.no_active_blocker_sentinel ||\n !missingReachableSet.has(row.target_id.trim().toLowerCase()) ||\n !packetIds.has(row.holder_id)\n )\n return false;\n if (filteredKinds === undefined) return true;\n const definition = relationshipRegistry.resolve(row.kind);\n return (\n definition !== undefined &&\n (filteredKinds.has(definition.kind) ||\n (definition.inverse !== undefined &&\n filteredKinds.has(definition.inverse)))\n );\n });\n const referenceLimit = contextOptions.edgeLimit ?? 40;\n return {\n id: canonicalId,\n format: \"context\",\n node_count: context.nodes.length + 1,\n edge_count: context.edges.length,\n missing_count: missingReachable.length,\n missing_scope: \"traversal\",\n missing_reference_count: missingReferences.length,\n ...(summaryOnly\n ? {}\n : {\n missing_references: missingReferences.slice(0, referenceLimit),\n context,\n }),\n };\n}\n\n/** Implements run deps for the public runtime surface of this module. */\nexport async function runDeps(\n id: string,\n options: DepsCommandOptions,\n global: GlobalOptions,\n): Promise<DepsResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n const format = parseFormat(options.format);\n const maxDepth = parseMaxDepth(options.maxDepth);\n const collapse = parseCollapse(options.collapse);\n const summaryOnly = options.summary === true;\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n settings.schema,\n );\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const index = new Map(\n items.map((item) => [item.id.trim().toLowerCase(), toIndexedItem(item)]),\n );\n const dangling = collectDanglingDependencyReferences(\n items,\n (status) => isTerminalStatus(status, statusRegistry),\n );\n for (const reference of [...dangling.active, ...dangling.legacy_terminal]) {\n const holder = index.get(reference.holder_id.trim().toLowerCase());\n const referenceKind = reference.kind.trim().toLowerCase();\n if (\n holder &&\n !holder.dependencies.some(\n (dependency) =>\n dependency.id.trim().toLowerCase() === reference.target_id.trim().toLowerCase() &&\n dependency.kind === referenceKind,\n )\n ) {\n holder.dependencies.push({ id: reference.target_id, kind: referenceKind });\n }\n }\n if (!index.has(id.trim().toLowerCase())) {\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n }\n\n if (format === \"context\") {\n const canonicalId = index.get(id.trim().toLowerCase())!.id;\n const rootEvidence = summaryOnly\n ? []\n : await collectRootEvidence(\n pmRoot,\n canonicalId,\n settings,\n typeRegistry.type_to_folder,\n );\n const isTerminal = (status: ItemStatus): boolean =>\n isTerminalStatus(status, statusRegistry);\n // Reuse the fingerprint-keyed shared cache so bounded context packets in\n // long-lived hosts stop paying full-workspace assembly on every call.\n const lookup = workspaceGraphCache().lookup(\n pmRoot,\n computeWorkspaceGraphFingerprint(items, isTerminal),\n () => assembleWorkspaceRelationshipGraph(items, isTerminal),\n );\n return buildContextDepsResult({\n assembly: lookup.assembly,\n canonicalId,\n options,\n rootEvidence,\n summaryOnly,\n });\n }\n\n if (summaryOnly) {\n return {\n id,\n format,\n ...countDependencyGraph(id, index, maxDepth),\n };\n }\n\n const tree = toTreeNode(\n id,\n index,\n new Set<string>(),\n maxDepth,\n collapse,\n new Set<string>(),\n );\n const graph = toGraph(tree);\n const baseResult = {\n id,\n format,\n node_count: graph.nodes.length,\n edge_count: graph.edges.length,\n missing_count: graph.missing_ids.length,\n };\n if (format === \"tree\") {\n return {\n ...baseResult,\n tree,\n };\n }\n return {\n ...baseResult,\n graph,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAQ3B,IAAM,oCAAoC;AAE1C,IAAM,yBAAyB;AAa/B,SAAS,gBACP,MACA,YAA2C;AAE3C,QAAM,gBAAgB,KAAK,gBAAgB,CAA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I,EAAG,YAAW,CAAE,GAAG;AACvC,UAAM,IAAI,WAAW,QAAQ,EAAE,cAAc,UAAU,SAAS;EAClE;AAEA,MAAI,WAAW,WAAW;AACxB,UAAM,cAAc,MAAM,IAAI,GAAG,KAAI,EAAG,YAAW,CAAE,EAAG;AACxD,UAAM,eAAe,cACjB,CAAA,IACA,MAAM,oBACJ,QACA,aACA,UACA,aAAa,cAAc;AAEjC,UAAM,aAAa,CAAC,WAClB,iBAAiB,QAAQ,cAAc;AAGzC,UAAM,SAAS,oBAAmB,EAAG,OACnC,QACA,iCAAiC,OAAO,UAAU,GAClD,MAAM,mCAAmC,OAAO,UAAU,CAAC;AAE7D,WAAO,uBAAuB;MAC5B,UAAU,OAAO;MACjB;MACA;MACA;MACA;KACD;EACH;AAEA,MAAI,aAAa;AACf,WAAO;MACL;MACA;MACA,GAAG,qBAAqB,IAAI,OAAO,QAAQ;;EAE/C;AAEA,QAAM,OAAO,WACX,IACA,OACA,oBAAI,IAAG,GACP,UACA,UACA,oBAAI,IAAG,CAAU;AAEnB,QAAM,QAAQ,QAAQ,IAAI;AAC1B,QAAM,aAAa;IACjB;IACA;IACA,YAAY,MAAM,MAAM;IACxB,YAAY,MAAM,MAAM;IACxB,eAAe,MAAM,YAAY;;AAEnC,MAAI,WAAW,QAAQ;AACrB,WAAO;MACL,GAAG;MACH;;EAEJ;AACA,SAAO;IACL,GAAG;IACH;;AAEJ","debugId":"26ac40fe-0a65-5304-af3b-0c7117682cca"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../../sdk/schema.ts","../../../../../../../../core/schema/type-inference.ts"],"sourcesContent":["/**\n * @module sdk/schema\n *\n * Owns typed schema customization primitives shared by SDK, CLI, and MCP consumers.\n */\nimport path from \"node:path\";\nimport { mkdir } from \"node:fs/promises\";\nimport {\n pathExists,\n readFileIfExists,\n writeFileAtomic,\n} from \"../core/fs/fs-utils.js\";\nimport { acquireLock } from \"../core/lock/lock.js\";\nimport { refreshMergeAttributeFenceIfInstalled } from \"./merge/install.js\";\nimport {\n assertAliasesAvailable,\n assertTypeFolderAvailable,\n buildInvalidTypeHint,\n escapeForDoubleQuotes,\n normalizeAddTypeInput,\n parseItemTypesFile,\n removeItemType,\n serializeItemTypesFile,\n upsertItemType,\n type ItemTypeDefinition,\n} from \"../core/schema/item-types-file.js\";\nimport {\n assertStatusTokensAvailable,\n BUILTIN_STATUS_IDS,\n normalizeAddStatusInput,\n normalizeStatusToken,\n parseStatusDefsFile,\n removeStatusDef,\n serializeStatusDefsFile,\n upsertStatusDef,\n type RuntimeStatusDefinition,\n} from \"../core/schema/status-defs-file.js\";\nimport {\n normalizeAddFieldInput,\n normalizeFieldKey,\n parseFieldsFile,\n removeField,\n serializeFieldsFile,\n upsertField,\n type RuntimeFieldDefinition,\n} from \"../core/schema/fields-file.js\";\nimport {\n normalizeTypePresetName,\n resolveTypePresetDefinitions,\n TYPE_PRESET_NAMES,\n type TypePresetName,\n} from \"../core/schema/type-presets.js\";\nimport {\n inferTypesFromTitles,\n type InferredTypeCandidate,\n} from \"../core/schema/type-inference.js\";\nimport {\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,\n filePathForSchemaSection,\n normalizeRuntimeSchemaSettings,\n resolveRuntimeFieldRegistry,\n resolveRuntimeStatusRegistry,\n} from \"../core/schema/runtime-schema.js\";\nimport {\n resolveItemTypeRegistry,\n toDefaultFolder,\n type ResolvedItemTypeDefinition,\n} from \"../core/item/type-registry.js\";\nimport { listAllItemMetadataLight } from \"../core/store/item-store.js\";\nimport { EXIT_CODE } from \"../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../core/shared/command-types.js\";\nimport type { PmSettings } from \"../types/index.js\";\nimport { PmCliError } from \"../core/shared/errors.js\";\nimport { nowIso } from \"../core/shared/time.js\";\nimport {\n getActiveExtensionRegistrations,\n runActiveOnWriteHooks,\n} from \"../core/extensions/index.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../core/store/paths.js\";\nimport {\n readSettings,\n resolveGovernanceKnobs,\n} from \"../core/store/settings.js\";\n\n/** Public contract for schema subcommands, shared by SDK and presentation-layer consumers. */\nexport const SCHEMA_SUBCOMMANDS = [\n \"add-type\",\n \"remove-type\",\n \"add-status\",\n \"remove-status\",\n \"add-field\",\n \"remove-field\",\n \"list-fields\",\n \"show-field\",\n \"apply-preset\",\n \"list\",\n \"show\",\n \"show-status\",\n] as const;\n/** Restricts schema subcommand values accepted by command, SDK, and storage contracts. */\nexport type SchemaSubcommand = (typeof SCHEMA_SUBCOMMANDS)[number];\n\nconst SCHEMA_TYPES_LOCK_ID = \"schema-types\";\nconst SCHEMA_STATUSES_LOCK_ID = \"schema-statuses\";\nconst SCHEMA_FIELDS_LOCK_ID = \"schema-fields\";\n\n/** Documents the schema add type command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddTypeCommandOptions {\n /** Value that configures or reports description for this contract. */\n description?: string;\n /** Default status id newly created items of this type receive. */\n defaultStatus?: string;\n /** Value that configures or reports folder for this contract. */\n folder?: string;\n /** Value that configures or reports alias for this contract. */\n alias?: string[];\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema remove type command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaRemoveTypeCommandOptions {\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema add status command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddStatusCommandOptions {\n /** Value that configures or reports role for this contract. */\n role?: string[];\n /** Value that configures or reports alias for this contract. */\n alias?: string[];\n /** Value that configures or reports description for this contract. */\n description?: string;\n /** Value that configures or reports order for this contract. */\n order?: number;\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema remove status command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaRemoveStatusCommandOptions {\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema add type result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddTypeResult {\n /** Value that configures or reports action for this contract. */\n action: \"add-type\";\n /** Value that configures or reports registered for this contract. */\n registered: boolean;\n /** Value that configures or reports replaced for this contract. */\n replaced: boolean;\n /** Schema type that determines the shape and validation rules for this value. */\n type: ItemTypeDefinition;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n definitions: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema remove type result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaRemoveTypeResult {\n /** Value that configures or reports action for this contract. */\n action: \"remove-type\";\n /** Value that configures or reports removed for this contract. */\n removed: boolean;\n /** Schema type that determines the shape and validation rules for this value. */\n type?: ItemTypeDefinition;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n definitions: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema add status result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddStatusResult {\n /** Value that configures or reports action for this contract. */\n action: \"add-status\";\n /** Value that configures or reports registered for this contract. */\n registered: boolean;\n /** Value that configures or reports replaced for this contract. */\n replaced: boolean;\n /** Lifecycle state reported for status. */\n status: RuntimeStatusDefinition;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n statuses: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema remove status result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaRemoveStatusResult {\n /** Value that configures or reports action for this contract. */\n action: \"remove-status\";\n /** Value that configures or reports removed for this contract. */\n removed: boolean;\n /** Lifecycle state reported for status. */\n status?: RuntimeStatusDefinition;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n statuses: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema add field command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddFieldCommandOptions {\n /** Schema type that determines the shape and validation rules for this value. */\n type?: string;\n /** Value that configures or reports commands for this contract. */\n commands?: string[];\n /** Value that configures or reports description for this contract. */\n description?: string;\n /** Value that configures or reports cli flag for this contract. */\n cliFlag?: string;\n /** Value that configures or reports alias for this contract. */\n alias?: string[];\n /** Value that configures or reports required for this contract. */\n required?: boolean;\n /** Value that configures or reports required on create for this contract. */\n requiredOnCreate?: boolean;\n /** Value that configures or reports allow unset for this contract. */\n allowUnset?: boolean;\n /** Value that configures or reports required types for this contract. */\n requiredTypes?: string[];\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema remove field command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaRemoveFieldCommandOptions {\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema apply preset command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaApplyPresetCommandOptions {\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema add type infer command options payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddTypeInferCommandOptions {\n /** Number of min entries represented by this result. */\n minCount?: number;\n /** Value that configures or reports apply for this contract. */\n apply?: boolean;\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports force for this contract. */\n force?: boolean;\n}\n\n/** Documents the schema field summary payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaFieldSummary {\n /** Value that configures or reports key for this contract. */\n key: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type: string;\n /** Value that configures or reports commands for this contract. */\n commands: string[];\n /** Value that configures or reports cli flag for this contract. */\n cli_flag: string;\n /** Value that configures or reports cli aliases for this contract. */\n cli_aliases: string[];\n /** Value that configures or reports description for this contract. */\n description?: string;\n /** Value that configures or reports required for this contract. */\n required: boolean;\n /** Value that configures or reports required on create for this contract. */\n required_on_create: boolean;\n /** Value that configures or reports allow unset for this contract. */\n allow_unset: boolean;\n /** Value that configures or reports required types for this contract. */\n required_types: string[];\n}\n\n/** Documents the schema add field result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddFieldResult {\n /** Value that configures or reports action for this contract. */\n action: \"add-field\";\n /** Value that configures or reports registered for this contract. */\n registered: boolean;\n /** Value that configures or reports replaced for this contract. */\n replaced: boolean;\n /** Value that configures or reports field for this contract. */\n field: RuntimeFieldDefinition;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n fields: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema remove field result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaRemoveFieldResult {\n /** Value that configures or reports action for this contract. */\n action: \"remove-field\";\n /** Value that configures or reports removed for this contract. */\n removed: boolean;\n /** Value that configures or reports field for this contract. */\n field?: RuntimeFieldDefinition;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n fields: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema list fields result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaListFieldsResult {\n /** Value that configures or reports action for this contract. */\n action: \"list-fields\";\n /** Value that configures or reports fields for this contract. */\n fields: SchemaFieldSummary[];\n /** Value that configures or reports counts for this contract. */\n counts: {\n total: number;\n };\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n };\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema show field result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaShowFieldResult {\n /** Value that configures or reports action for this contract. */\n action: \"show-field\";\n /** Value that configures or reports field for this contract. */\n field: SchemaFieldSummary;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n };\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema apply preset result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaApplyPresetResult {\n /** Value that configures or reports action for this contract. */\n action: \"apply-preset\";\n /** Value that configures or reports preset for this contract. */\n preset: TypePresetName;\n /** Value that configures or reports registered for this contract. */\n registered: string[];\n /** Value that configures or reports replaced for this contract. */\n replaced: string[];\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n definitions: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema add type infer result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaAddTypeInferResult {\n /** Value that configures or reports action for this contract. */\n action: \"infer-types\";\n /** Value that configures or reports applied for this contract. */\n applied: boolean;\n /** Number of min entries represented by this result. */\n min_count: number;\n /** Value that configures or reports candidates for this contract. */\n candidates: InferredTypeCandidate[];\n /** Value that configures or reports registered for this contract. */\n registered: string[];\n /** Value that configures or reports replaced for this contract. */\n replaced: string[];\n /** Value that configures or reports skipped for this contract. */\n skipped: Array<{ name: string; reason: string }>;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n definitions: number;\n };\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema type summary payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaTypeSummary {\n /** Value that configures or reports name for this contract. */\n name: string;\n /** Value that configures or reports folder for this contract. */\n folder: string;\n /** Value that configures or reports aliases for this contract. */\n aliases: string[];\n /** Default status id newly created items of this type receive. */\n default_status?: string;\n /** Value that configures or reports description for this contract. */\n description?: string;\n}\n\n/** Documents the schema status summary payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaStatusSummary {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports source for this contract. */\n source: \"builtin\" | \"custom\";\n /** Value that configures or reports roles for this contract. */\n roles: string[];\n /** Value that configures or reports aliases for this contract. */\n aliases: string[];\n /** Value that configures or reports description for this contract. */\n description?: string;\n /** Value that configures or reports order for this contract. */\n order?: number;\n}\n\n/** Documents the schema type definition result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaTypeDefinitionResult extends SchemaTypeSummary {\n /** Value that configures or reports source for this contract. */\n source: \"builtin\" | \"custom\" | \"extension\";\n /** Value that configures or reports extension for this contract. */\n extension?: {\n layer: string;\n name: string;\n };\n /** Value that configures or reports required create fields for this contract. */\n required_create_fields: string[];\n /** Value that configures or reports required create repeatables for this contract. */\n required_create_repeatables: string[];\n /** Value that configures or reports options for this contract. */\n options: ResolvedItemTypeDefinition[\"options\"];\n /** Value that configures or reports command option policies for this contract. */\n command_option_policies: ResolvedItemTypeDefinition[\"command_option_policies\"];\n}\n\n/** Documents the schema list result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaListResult {\n /** Value that configures or reports action for this contract. */\n action: \"list\";\n /** Value that configures or reports builtin for this contract. */\n builtin: SchemaTypeSummary[];\n /** Value that configures or reports custom for this contract. */\n custom: SchemaTypeSummary[];\n /** Value that configures or reports extension for this contract. */\n extension: SchemaTypeSummary[];\n /** Value that configures or reports counts for this contract. */\n counts: {\n builtin: number;\n custom: number;\n extension: number;\n total: number;\n };\n /** Value that configures or reports statuses for this contract. */\n statuses: {\n builtin: SchemaStatusSummary[];\n custom: SchemaStatusSummary[];\n counts: {\n builtin: number;\n custom: number;\n total: number;\n };\n };\n /** Value that configures or reports fields for this contract. */\n fields: {\n custom: SchemaFieldSummary[];\n counts: {\n total: number;\n };\n };\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n };\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema show result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaShowResult {\n /** Value that configures or reports action for this contract. */\n action: \"show\";\n /** Schema type that determines the shape and validation rules for this value. */\n type: SchemaTypeDefinitionResult;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n };\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Documents the schema show status result payload exchanged by command, SDK, and package integrations. */\nexport interface SchemaShowStatusResult {\n /** Value that configures or reports action for this contract. */\n action: \"show-status\";\n /** Lifecycle state reported for status. */\n status: SchemaStatusSummary;\n /** Value that configures or reports file for this contract. */\n file: {\n path: string;\n };\n /** ISO 8601 timestamp recording when generated occurred. */\n generated_at: string;\n}\n\n/** Restricts schema inspect result values accepted by command, SDK, and storage contracts. */\nexport type SchemaInspectResult =\n | SchemaListResult\n | SchemaShowResult\n | SchemaShowStatusResult\n | SchemaListFieldsResult\n | SchemaShowFieldResult;\n\nfunction toAuthor(\n candidate: string | undefined,\n defaultAuthor: string,\n): string {\n const resolved = candidate ?? process.env.PM_AUTHOR ?? defaultAuthor;\n const trimmed = resolved.trim();\n return trimmed.length > 0 ? trimmed : \"unknown\";\n}\n\n/* c8 ignore start -- schema command mutation/inspection branches are covered by broader schema integration workflows. */\n/** Implements run schema add type for the public runtime surface of this module. */\nexport async function runSchemaAddType(\n name: string | undefined,\n options: SchemaAddTypeCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaAddTypeResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n let normalized;\n try {\n normalized = normalizeAddTypeInput({\n name,\n description: options.description,\n defaultStatus: options.defaultStatus,\n folder: options.folder,\n aliases: options.alias,\n });\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const typesPath = filePathForSchemaSection(\n pmRoot,\n schema.files.types,\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types,\n );\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_TYPES_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n let upsert;\n try {\n const previousRaw = await readFileIfExists(typesPath);\n let parsed;\n try {\n parsed = parseItemTypesFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n try {\n assertAliasesAvailable(normalized, parsed);\n // GH-248: reject distinct type names that would slug to the same storage\n // folder (e.g. \"Spike\"/\"Spikes\") so item files never silently share a\n // directory. Same-named upserts (recase/idempotent re-runs) are exempt.\n // reservedFolders covers built-in + extension + settings-resolved custom\n // folders so a slug like \"Tasks\" can't collide with the built-in Task.\n const reservedFolders = new Map<string, string>();\n const resolvedRegistry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n for (const [typeName, folder] of Object.entries(\n resolvedRegistry.type_to_folder,\n )) {\n const folderKey = folder.trim().toLowerCase();\n if (folderKey.length > 0 && !reservedFolders.has(folderKey)) {\n reservedFolders.set(folderKey, typeName);\n }\n }\n assertTypeFolderAvailable(normalized, parsed, reservedFolders);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n upsert = upsertItemType(parsed, normalized);\n // GH-248: an upsert that only differs in case from the existing canonical\n // name silently renames the stored type (e.g. registering \"spike\" over\n // \"Spike\"). Surface it as a non-blocking warning so the operator knows the\n // existing definition was replaced rather than a new type created.\n if (\n upsert.replaced &&\n upsert.previousName !== undefined &&\n upsert.previousName !== upsert.definition.name\n ) {\n warnings.push(\n `type_recased:${upsert.previousName}->${upsert.definition.name}`,\n );\n }\n // writeFileAtomic writes to a temp file then renames, so a failure leaves the\n // existing types.json untouched; no manual rollback is needed.\n await writeFileAtomic(typesPath, serializeItemTypesFile(upsert.file));\n await ensureTypeFolderScaffold(\n pmRoot,\n [upsert.definition],\n warnings,\n \"schema:add-type-folder\",\n );\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: typesPath,\n scope: \"project\",\n op: \"schema:add-type\",\n })),\n );\n } finally {\n await releaseLock();\n }\n await appendMergeFenceWarnings(pmRoot, warnings);\n\n return {\n action: \"add-type\",\n registered: true,\n replaced: upsert.replaced,\n type: upsert.definition,\n file: {\n path: typesPath,\n definitions: upsert.file.definitions.length,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\nasync function ensureInitialized(pmRoot: string): Promise<void> {\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n}\n\n/**\n * Reconcile the committed merge-driver fence with the type folders that exist\n * after a schema type mutation. When `pm merge install` already ran the fence\n * is rewritten in place (`merge_fence_refreshed`); when the repository has a\n * tracker inside git but never installed the fence, an actionable hint warning\n * is emitted instead — new type folders would otherwise merge under git's\n * default text driver and reintroduce whole-file item conflicts (pm-i4fx).\n */\nasync function appendMergeFenceWarnings(\n pmRoot: string,\n warnings: string[],\n): Promise<void> {\n try {\n const fence = await refreshMergeAttributeFenceIfInstalled(pmRoot);\n if (fence.status === \"refreshed\") {\n warnings.push(\"merge_fence_refreshed\");\n } else if (fence.status === \"not_installed\") {\n warnings.push(\n 'merge_fence_not_installed:type folders lack git merge drivers; run \"pm merge install\"',\n );\n }\n } catch {\n warnings.push(\n 'merge_fence_refresh_failed:run \"pm merge install\" to reconcile',\n );\n }\n}\n\n/** Deduplicates schema mutation warnings and returns their stable locale-aware order. */\nfunction finalizeWarnings(warnings: string[]): string[] {\n return [...new Set(warnings)].sort((left, right) =>\n left.localeCompare(right),\n );\n}\n\n/** Counts items whose resolved type matches `typeName` (case-insensitive). Uses the lightest existing read path (listAllItemMetadataLight skips the heavy collections cache). All items are counted — not just open ones — so the advisory warning surfaces every item the removed definition would orphan; the count is non-blocking. The caller passes its already-loaded `settings` so we never re-read settings.json from disk here. */\nasync function countItemsUsingType(\n pmRoot: string,\n settings: PmSettings,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n typeName: string,\n): Promise<number> {\n const registry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const lowerName = typeName.trim().toLowerCase();\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n registry.type_to_folder,\n [],\n schema,\n );\n return items.filter(\n (item) =>\n typeof item.type === \"string\" && item.type.toLowerCase() === lowerName,\n ).length;\n}\n\n/** Counts items currently set to the status whose id/aliases resolve to `statusId`. Uses listAllItemMetadataLight (the lightest read path). All items are counted regardless of lifecycle phase; the count is advisory only. The caller passes its already-loaded `settings` so we never re-read from disk. */\nasync function countItemsUsingStatus(\n pmRoot: string,\n settings: PmSettings,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n statusId: string,\n): Promise<number> {\n const registry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const statusRegistry = resolveRuntimeStatusRegistry(schema);\n const normalizedId = normalizeStatusToken(statusId);\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n registry.type_to_folder,\n [],\n schema,\n );\n return items.filter((item) => {\n const itemStatus = typeof item.status === \"string\" ? item.status : \"\";\n const resolved =\n statusRegistry.alias_to_id.get(normalizeStatusToken(itemStatus)) ??\n normalizeStatusToken(itemStatus);\n return resolved === normalizedId;\n }).length;\n}\n\n/** Adds non-blocking usage and workflow diagnostics for a removed custom status. */\nasync function appendRemovedStatusWarnings(\n warnings: string[],\n pmRoot: string,\n settings: PmSettings,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n removedId: string,\n): Promise<void> {\n if (removedId.length === 0 || BUILTIN_STATUS_IDS.has(removedId)) {\n return;\n }\n const usingStatus = await countItemsUsingStatus(\n pmRoot,\n settings,\n schema,\n removedId,\n );\n if (usingStatus > 0) {\n warnings.push(`items_using_status:${usingStatus}`);\n }\n const referencingSlots = workflowSlotsReferencing(schema.workflow, removedId);\n if (referencingSlots.length > 0) {\n warnings.push(\n `status_referenced_by_workflow:${referencingSlots.join(\",\")}`,\n );\n }\n}\n\n/** Returns the workflow role-slot names (open_status, close_status, ...) that currently point at `statusId` (normalized). Used to warn before removing a status that a workflow default still references. */\nfunction workflowSlotsReferencing(\n workflow: {\n draft_status?: string;\n open_status?: string;\n in_progress_status?: string;\n blocked_status?: string;\n close_status?: string;\n canceled_status?: string;\n },\n statusId: string,\n): string[] {\n const slots: Array<[string, string | undefined]> = [\n [\"draft_status\", workflow.draft_status],\n [\"open_status\", workflow.open_status],\n [\"in_progress_status\", workflow.in_progress_status],\n [\"blocked_status\", workflow.blocked_status],\n [\"close_status\", workflow.close_status],\n [\"canceled_status\", workflow.canceled_status],\n ];\n return slots\n .filter(\n ([, value]) =>\n value !== undefined && normalizeStatusToken(value) === statusId,\n )\n .map(([slot]) => slot);\n}\n\n/** Implements run schema remove type for the public runtime surface of this module. */\nexport async function runSchemaRemoveType(\n name: string | undefined,\n options: SchemaRemoveTypeCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaRemoveTypeResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const typesPath = filePathForSchemaSection(\n pmRoot,\n schema.files.types,\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types,\n );\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_TYPES_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n let removal;\n try {\n const previousRaw = await readFileIfExists(typesPath);\n let parsed;\n try {\n parsed = parseItemTypesFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n try {\n removal = removeItemType(parsed, name);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n if (removal.removed) {\n // Only emit the advisory orphan-count warning once a removable custom\n // definition was actually removed; a no-op/unknown removal would otherwise\n // surface a misleading items_using_type:* warning. The count is\n // non-blocking and reuses the already-loaded settings (no disk re-read).\n const removedName = (removal.definition?.name ?? name ?? \"\").trim();\n if (removedName.length > 0) {\n const usingType = await countItemsUsingType(\n pmRoot,\n settings,\n schema,\n removedName,\n );\n if (usingType > 0) {\n warnings.push(`items_using_type:${usingType}`);\n }\n }\n // writeFileAtomic writes to a temp file then renames, so a failure leaves\n // the existing types.json untouched; no manual rollback is needed.\n await writeFileAtomic(typesPath, serializeItemTypesFile(removal.file));\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: typesPath,\n scope: \"project\",\n op: \"schema:remove-type\",\n })),\n );\n }\n } finally {\n await releaseLock();\n }\n if (removal.removed) {\n await appendMergeFenceWarnings(pmRoot, warnings);\n }\n\n return {\n action: \"remove-type\",\n removed: removal.removed,\n ...(removal.definition ? { type: removal.definition } : {}),\n file: {\n path: typesPath,\n definitions: removal.file.definitions.length,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\nfunction statusesPathFor(\n pmRoot: string,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n): string {\n return filePathForSchemaSection(\n pmRoot,\n schema.files.statuses,\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses,\n );\n}\n\nfunction fieldsPathFor(\n pmRoot: string,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n): string {\n return filePathForSchemaSection(\n pmRoot,\n schema.files.fields,\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields,\n );\n}\n\nfunction typesPathFor(\n pmRoot: string,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n): string {\n return filePathForSchemaSection(\n pmRoot,\n schema.files.types,\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types,\n );\n}\n\n/** Creates the storage folder for each item-type definition (resolving the default folder when unset) and runs on-write hooks for newly created folders. Shared with `pm profile apply` so profile-staged types scaffold identically to `pm schema add-type`. Existing folders are skipped, keeping the call idempotent. */\nexport async function ensureTypeFolderScaffold(\n pmRoot: string,\n definitions: readonly ItemTypeDefinition[],\n warnings: string[],\n op: string,\n): Promise<void> {\n for (const definition of definitions) {\n const folder = definition.folder ?? toDefaultFolder(definition.name);\n const target = path.join(pmRoot, folder);\n if (await pathExists(target)) {\n continue;\n }\n await mkdir(target, { recursive: true });\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: target,\n scope: \"project\",\n op,\n })),\n );\n }\n}\n\nfunction toSchemaFieldSummary(\n field: ReturnType<typeof resolveRuntimeFieldRegistry>[\"definitions\"][number],\n): SchemaFieldSummary {\n return {\n key: field.key,\n type: field.type,\n commands: [...field.commands],\n cli_flag: `--${field.cli_flag}`,\n cli_aliases: field.cli_aliases.map((alias) => `--${alias}`),\n ...(field.description ? { description: field.description } : {}),\n required: field.required,\n required_on_create: field.required_on_create,\n allow_unset: field.allow_unset,\n required_types: [...field.required_types],\n };\n}\n\nfunction toExistingStatusDefinition(\n resolvedExisting:\n | ReturnType<typeof resolveRuntimeStatusRegistry>[\"definitions\"][number]\n | undefined,\n): RuntimeStatusDefinition | undefined {\n if (!resolvedExisting) {\n return undefined;\n }\n return {\n id: resolvedExisting.id,\n ...(resolvedExisting.roles.length > 0\n ? { roles: [...resolvedExisting.roles] }\n : {}),\n ...(resolvedExisting.aliases.length > 0\n ? { aliases: [...resolvedExisting.aliases] }\n : {}),\n ...(resolvedExisting.description\n ? { description: resolvedExisting.description }\n : {}),\n ...(typeof resolvedExisting.order === \"number\"\n ? { order: resolvedExisting.order }\n : {}),\n };\n}\n\nfunction buildStatusFileAliasMap(\n statuses: RuntimeStatusDefinition[],\n): Map<string, string> {\n const fileAliasToId = new Map<string, string>();\n for (const definition of statuses) {\n const defId = normalizeStatusToken(definition.id);\n if (defId.length === 0) {\n continue;\n }\n fileAliasToId.set(defId, defId);\n for (const alias of Array.isArray(definition.aliases)\n ? definition.aliases\n : []) {\n const aliasToken = normalizeStatusToken(alias);\n if (aliasToken.length > 0 && !fileAliasToId.has(aliasToken)) {\n fileAliasToId.set(aliasToken, defId);\n }\n }\n }\n return fileAliasToId;\n}\n\n/** Implements run schema add status for the public runtime surface of this module. */\nexport async function runSchemaAddStatus(\n id: string | undefined,\n options: SchemaAddStatusCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaAddStatusResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n let normalized;\n try {\n normalized = normalizeAddStatusInput({\n id,\n roles: options.role,\n aliases: options.alias,\n description: options.description,\n order: options.order,\n });\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const statusesPath = statusesPathFor(pmRoot, schema);\n const statusRegistry = resolveRuntimeStatusRegistry(schema);\n\n // Reject id/alias collisions with a DIFFERENT existing status so a custom\n // status can never shadow a built-in lifecycle token (e.g. --alias open).\n try {\n assertStatusTokensAvailable(normalized, statusRegistry.alias_to_id);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n\n // Seed the upsert from the resolved (settings-or-file) definition so omitting\n // --role/--alias preserves metadata defined in settings.schema.statuses, not\n // only what is already in statuses.json.\n const baseDefinition = toExistingStatusDefinition(\n statusRegistry.by_id.get(normalized.id),\n );\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_STATUSES_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n let upsert;\n try {\n const previousRaw = await readFileIfExists(statusesPath);\n let parsed;\n try {\n parsed = parseStatusDefsFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n // Re-check collisions against the CURRENT file under the lock: the pre-lock\n // check used the registry loaded before acquiring schema-statuses, so a\n // concurrent add-status could have written a colliding id/alias in between.\n // The lock serializes writes; this serializes the collision decision too.\n const fileAliasToId = buildStatusFileAliasMap(parsed.statuses);\n try {\n assertStatusTokensAvailable(normalized, fileAliasToId);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n upsert = upsertStatusDef(parsed, normalized, baseDefinition);\n // writeFileAtomic writes to a temp file then renames, so a failure leaves\n // the existing statuses.json untouched; no manual rollback is needed.\n await writeFileAtomic(statusesPath, serializeStatusDefsFile(upsert.file));\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: statusesPath,\n scope: \"project\",\n op: \"schema:add-status\",\n })),\n );\n } finally {\n await releaseLock();\n }\n\n return {\n action: \"add-status\",\n registered: true,\n replaced: upsert.replaced,\n status: upsert.definition,\n file: {\n path: statusesPath,\n statuses: upsert.file.statuses.length,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema remove status for the public runtime surface of this module. */\nexport async function runSchemaRemoveStatus(\n id: string | undefined,\n options: SchemaRemoveStatusCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaRemoveStatusResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const statusesPath = statusesPathFor(pmRoot, schema);\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_STATUSES_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n let removal;\n try {\n const previousRaw = await readFileIfExists(statusesPath);\n let parsed;\n try {\n parsed = parseStatusDefsFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n try {\n removal = removeStatusDef(parsed, id);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n if (removal.removed) {\n // Only emit the advisory orphan-count warning once a removable custom\n // status was actually removed; a no-op/unknown removal would otherwise\n // surface a misleading items_using_status:* warning. The count reuses the\n // already-loaded settings (no disk re-read) and is non-blocking.\n const removedId = normalizeStatusToken(removal.definition?.id ?? id);\n // Removing a status that a workflow default still points at would leave\n // pm close / default pm create resolving to an unregistered status. Warn\n // (non-blocking, consistent with remove-type) so the operator re-points\n // the workflow slot via schema/workflows.json or pm config.\n await appendRemovedStatusWarnings(\n warnings,\n pmRoot,\n settings,\n schema,\n removedId,\n );\n await writeFileAtomic(\n statusesPath,\n serializeStatusDefsFile(removal.file),\n );\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: statusesPath,\n scope: \"project\",\n op: \"schema:remove-status\",\n })),\n );\n }\n } finally {\n await releaseLock();\n }\n\n return {\n action: \"remove-status\",\n removed: removal.removed,\n ...(removal.definition ? { status: removal.definition } : {}),\n file: {\n path: statusesPath,\n statuses: removal.file.statuses.length,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\nfunction toSchemaTypeSummary(\n definition: ResolvedItemTypeDefinition,\n): SchemaTypeSummary {\n return {\n name: definition.name,\n folder: definition.folder,\n aliases: Array.isArray(definition.aliases) ? [...definition.aliases] : [],\n ...(definition.default_status\n ? { default_status: definition.default_status }\n : {}),\n ...(definition.description ? { description: definition.description } : {}),\n };\n}\n\nfunction toSchemaTypeDefinition(\n definition: ResolvedItemTypeDefinition,\n source: SchemaTypeDefinitionResult[\"source\"],\n extensionProvenance?: SchemaTypeDefinitionResult[\"extension\"],\n): SchemaTypeDefinitionResult {\n return {\n ...toSchemaTypeSummary(definition),\n source,\n ...(extensionProvenance ? { extension: extensionProvenance } : {}),\n required_create_fields: [...definition.required_create_fields],\n required_create_repeatables: [...definition.required_create_repeatables],\n options: structuredClone(definition.options),\n command_option_policies: structuredClone(\n definition.command_option_policies,\n ),\n };\n}\n\nfunction toSchemaStatusSummary(\n definition: RuntimeStatusDefinition,\n): SchemaStatusSummary {\n return {\n id: definition.id,\n source: BUILTIN_STATUS_IDS.has(definition.id) ? \"builtin\" : \"custom\",\n roles: Array.isArray(definition.roles) ? [...definition.roles] : [],\n aliases: Array.isArray(definition.aliases) ? [...definition.aliases] : [],\n ...(definition.description ? { description: definition.description } : {}),\n ...(typeof definition.order === \"number\"\n ? { order: definition.order }\n : {}),\n };\n}\n\nfunction classifyTypeSource(\n name: string,\n customNames: Set<string>,\n extensionNames: Set<string>,\n): SchemaTypeDefinitionResult[\"source\"] {\n const lowerName = name.toLowerCase();\n if (extensionNames.has(lowerName)) {\n return \"extension\";\n }\n if (customNames.has(lowerName)) {\n return \"custom\";\n }\n return \"builtin\";\n}\n\nfunction collectExtensionTypeProvenance(): Map<\n string,\n SchemaTypeDefinitionResult[\"extension\"]\n> {\n const provenance = new Map<string, SchemaTypeDefinitionResult[\"extension\"]>();\n const registrations = getActiveExtensionRegistrations();\n for (const registration of registrations?.item_types ?? []) {\n const rawTypes = (registration as { types?: unknown[] }).types;\n if (!Array.isArray(rawTypes)) {\n continue;\n }\n for (const rawType of rawTypes) {\n if (\n typeof rawType !== \"object\" ||\n rawType === null ||\n Array.isArray(rawType)\n ) {\n continue;\n }\n const name = (rawType as { name?: unknown }).name;\n if (typeof name === \"string\" && name.trim().length > 0) {\n provenance.set(name.trim().toLowerCase(), {\n layer: registration.layer,\n name: registration.name,\n });\n }\n }\n }\n return provenance;\n}\n\nfunction buildSchemaStatusSummaries(\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n): { builtin: SchemaStatusSummary[]; custom: SchemaStatusSummary[] } {\n const registry = resolveRuntimeStatusRegistry(schema);\n const builtin: SchemaStatusSummary[] = [];\n const custom: SchemaStatusSummary[] = [];\n for (const definition of registry.definitions) {\n const summary = toSchemaStatusSummary(definition);\n if (summary.source === \"builtin\") {\n builtin.push(summary);\n } else {\n custom.push(summary);\n }\n }\n return { builtin, custom };\n}\n\nasync function loadSchemaInspectionContext(global: GlobalOptions): Promise<{\n pmRoot: string;\n typesPath: string;\n statusesPath: string;\n byType: Record<string, ResolvedItemTypeDefinition>;\n customNames: Set<string>;\n extensionProvenance: Map<string, SchemaTypeDefinitionResult[\"extension\"]>;\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>;\n}> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const typesPath = filePathForSchemaSection(\n pmRoot,\n schema.files.types,\n DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types,\n );\n const statusesPath = statusesPathFor(pmRoot, schema);\n const registry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const extensionProvenance = collectExtensionTypeProvenance();\n const customNames = new Set(\n (settings.item_types?.definitions ?? [])\n .map((definition) => definition.name.trim().toLowerCase())\n .filter((name) => name.length > 0 && !extensionProvenance.has(name)),\n );\n return {\n pmRoot,\n typesPath,\n statusesPath,\n byType: registry.by_type,\n customNames,\n extensionProvenance,\n schema,\n };\n}\n\n/** Implements run schema list for the public runtime surface of this module. */\nexport async function runSchemaList(\n global: GlobalOptions,\n): Promise<SchemaListResult> {\n const context = await loadSchemaInspectionContext(global);\n const builtin: SchemaTypeSummary[] = [];\n const custom: SchemaTypeSummary[] = [];\n const extension: SchemaTypeSummary[] = [];\n for (const definition of Object.values(context.byType).sort((left, right) =>\n left.name.localeCompare(right.name),\n )) {\n const source = classifyTypeSource(\n definition.name,\n context.customNames,\n new Set(context.extensionProvenance.keys()),\n );\n const summary = toSchemaTypeSummary(definition);\n if (source === \"extension\") {\n extension.push(summary);\n } else if (source === \"custom\") {\n custom.push(summary);\n } else {\n builtin.push(summary);\n }\n }\n const statusSummaries = buildSchemaStatusSummaries(context.schema);\n const fieldSummaries = resolveRuntimeFieldRegistry(\n context.schema,\n ).definitions.map(toSchemaFieldSummary);\n return {\n action: \"list\",\n builtin,\n custom,\n extension,\n counts: {\n builtin: builtin.length,\n custom: custom.length,\n extension: extension.length,\n total: builtin.length + custom.length + extension.length,\n },\n statuses: {\n builtin: statusSummaries.builtin,\n custom: statusSummaries.custom,\n counts: {\n builtin: statusSummaries.builtin.length,\n custom: statusSummaries.custom.length,\n total: statusSummaries.builtin.length + statusSummaries.custom.length,\n },\n },\n fields: {\n custom: fieldSummaries,\n counts: {\n total: fieldSummaries.length,\n },\n },\n file: {\n path: context.typesPath,\n },\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema show for the public runtime surface of this module. */\nexport async function runSchemaShow(\n name: string | undefined,\n global: GlobalOptions,\n): Promise<SchemaShowResult> {\n const typeName = (name ?? \"\").trim();\n if (typeName.length === 0) {\n throw new PmCliError(\"Type name must not be empty.\", EXIT_CODE.USAGE);\n }\n const context = await loadSchemaInspectionContext(global);\n const match = Object.values(context.byType).find(\n (definition) =>\n definition.name.toLowerCase() === typeName.toLowerCase() ||\n definition.aliases.some(\n (alias) => alias.toLowerCase() === typeName.toLowerCase(),\n ),\n );\n if (!match) {\n throw new PmCliError(\n `Unknown item type \"${typeName}\". Run pm schema list to inspect registered types, or pm schema add-type \"${escapeForDoubleQuotes(typeName)}\" to register it.`,\n EXIT_CODE.NOT_FOUND,\n { code: \"unknown_item_type\" },\n );\n }\n return {\n action: \"show\",\n type: toSchemaTypeDefinition(\n match,\n classifyTypeSource(\n match.name,\n context.customNames,\n new Set(context.extensionProvenance.keys()),\n ),\n context.extensionProvenance.get(match.name.toLowerCase()),\n ),\n file: {\n path: context.typesPath,\n },\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema show status for the public runtime surface of this module. */\nexport async function runSchemaShowStatus(\n id: string | undefined,\n global: GlobalOptions,\n): Promise<SchemaShowStatusResult> {\n const statusToken = normalizeStatusToken(id);\n if (statusToken.length === 0) {\n throw new PmCliError(\"Status id must not be empty.\", EXIT_CODE.USAGE);\n }\n const context = await loadSchemaInspectionContext(global);\n const statusRegistry = resolveRuntimeStatusRegistry(context.schema);\n const resolvedId = statusRegistry.alias_to_id.get(statusToken) ?? statusToken;\n const match = statusRegistry.by_id.get(resolvedId);\n if (!match) {\n throw new PmCliError(\n `Unknown status \"${id}\". Run pm schema list to inspect registered statuses, or pm schema add-status \"${escapeForDoubleQuotes(\n id ?? \"\",\n )}\" to register it.`,\n EXIT_CODE.NOT_FOUND,\n { code: \"unknown_status\" },\n );\n }\n return {\n action: \"show-status\",\n status: toSchemaStatusSummary(match),\n file: {\n path: context.statusesPath,\n },\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema add field for the public runtime surface of this module. */\nexport async function runSchemaAddField(\n key: string | undefined,\n options: SchemaAddFieldCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaAddFieldResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n let normalized;\n try {\n normalized = normalizeAddFieldInput({\n key,\n type: options.type,\n commands: options.commands,\n description: options.description,\n cliFlag: options.cliFlag,\n aliases: options.alias,\n required: options.required,\n requiredOnCreate: options.requiredOnCreate,\n allowUnset: options.allowUnset,\n requiredTypes: options.requiredTypes,\n });\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const fieldsPath = fieldsPathFor(pmRoot, schema);\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_FIELDS_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n let upsert;\n try {\n const previousRaw = await readFileIfExists(fieldsPath);\n let parsed;\n try {\n parsed = parseFieldsFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n upsert = upsertField(parsed, normalized);\n await writeFileAtomic(fieldsPath, serializeFieldsFile(upsert.file));\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: fieldsPath,\n scope: \"project\",\n op: \"schema:add-field\",\n })),\n );\n } finally {\n await releaseLock();\n }\n\n return {\n action: \"add-field\",\n registered: true,\n replaced: upsert.replaced,\n field: upsert.definition,\n file: {\n path: fieldsPath,\n fields: upsert.file.fields.length,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\n/** Counts items carrying a non-empty value for the custom field's metadata key. Advisory only (non-blocking) so remove-field can surface how many items would lose a managed column. Reuses the already-loaded settings (no disk re-read). */\nasync function countItemsUsingField(\n pmRoot: string,\n settings: PmSettings,\n schema: ReturnType<typeof normalizeRuntimeSchemaSettings>,\n metadataKey: string,\n): Promise<number> {\n const registry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n registry.type_to_folder,\n [],\n schema,\n );\n return items.filter((item) => {\n const value = (item as unknown as Record<string, unknown>)[metadataKey];\n if (value === undefined || value === null) {\n return false;\n }\n if (Array.isArray(value)) {\n return value.length > 0;\n }\n if (typeof value === \"string\") {\n return value.trim().length > 0;\n }\n return true;\n }).length;\n}\n\n/** Implements run schema remove field for the public runtime surface of this module. */\nexport async function runSchemaRemoveField(\n key: string | undefined,\n options: SchemaRemoveFieldCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaRemoveFieldResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const fieldsPath = fieldsPathFor(pmRoot, schema);\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_FIELDS_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n let removal;\n try {\n const previousRaw = await readFileIfExists(fieldsPath);\n let parsed;\n try {\n parsed = parseFieldsFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n try {\n removal = removeField(parsed, key);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n if (removal.removed) {\n const removedKey = normalizeFieldKey(removal.definition?.key ?? key);\n const metadataKey = normalizeFieldKey(\n removal.definition?.metadata_key ??\n removal.definition?.front_matter_key ??\n removedKey,\n );\n if (metadataKey.length > 0) {\n const usingField = await countItemsUsingField(\n pmRoot,\n settings,\n schema,\n metadataKey,\n );\n if (usingField > 0) {\n warnings.push(`items_using_field:${usingField}`);\n }\n }\n await writeFileAtomic(fieldsPath, serializeFieldsFile(removal.file));\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: fieldsPath,\n scope: \"project\",\n op: \"schema:remove-field\",\n })),\n );\n }\n } finally {\n await releaseLock();\n }\n\n return {\n action: \"remove-field\",\n removed: removal.removed,\n ...(removal.definition ? { field: removal.definition } : {}),\n file: {\n path: fieldsPath,\n fields: removal.file.fields.length,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema list fields for the public runtime surface of this module. */\nexport async function runSchemaListFields(\n global: GlobalOptions,\n): Promise<SchemaListFieldsResult> {\n const context = await loadSchemaInspectionContext(global);\n const fields = resolveRuntimeFieldRegistry(context.schema).definitions.map(\n toSchemaFieldSummary,\n );\n return {\n action: \"list-fields\",\n fields,\n counts: {\n total: fields.length,\n },\n file: {\n path: fieldsPathFor(context.pmRoot, context.schema),\n },\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema show field for the public runtime surface of this module. */\nexport async function runSchemaShowField(\n key: string | undefined,\n global: GlobalOptions,\n): Promise<SchemaShowFieldResult> {\n const fieldKey = normalizeFieldKey(key);\n if (fieldKey.length === 0) {\n throw new PmCliError(\"Field key must not be empty.\", EXIT_CODE.USAGE);\n }\n const context = await loadSchemaInspectionContext(global);\n const match = resolveRuntimeFieldRegistry(context.schema).by_key.get(\n fieldKey,\n );\n if (!match) {\n throw new PmCliError(\n `Unknown custom field \"${key}\". Run pm schema list-fields to inspect registered fields, or pm schema add-field \"${escapeForDoubleQuotes(\n key ?? \"\",\n )}\" to register it.`,\n EXIT_CODE.NOT_FOUND,\n { code: \"unknown_field\" },\n );\n }\n return {\n action: \"show-field\",\n field: toSchemaFieldSummary(match),\n file: {\n path: fieldsPathFor(context.pmRoot, context.schema),\n },\n generated_at: nowIso(),\n };\n}\n\n/** Implements run schema apply preset for the public runtime surface of this module. */\nexport async function runSchemaApplyPreset(\n preset: string | undefined,\n options: SchemaApplyPresetCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaApplyPresetResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n let presetName: TypePresetName;\n try {\n const normalized = normalizeTypePresetName(preset);\n if (normalized === undefined) {\n throw new Error(\n `Type preset name is required. Allowed: ${TYPE_PRESET_NAMES.join(\", \")}.`,\n );\n }\n presetName = normalized;\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.USAGE,\n );\n }\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const typesPath = typesPathFor(pmRoot, schema);\n\n const warnings: string[] = [];\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n\n const registered: string[] = [];\n const replaced: string[] = [];\n let definitionsCount: number;\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_TYPES_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n try {\n const previousRaw = await readFileIfExists(typesPath);\n let parsed;\n try {\n parsed = parseItemTypesFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n let nextFile = parsed;\n for (const normalized of resolveTypePresetDefinitions(presetName)) {\n const upsert = upsertItemType(nextFile, normalized);\n nextFile = upsert.file;\n (upsert.replaced ? replaced : registered).push(upsert.definition.name);\n }\n definitionsCount = nextFile.definitions.length;\n await writeFileAtomic(typesPath, serializeItemTypesFile(nextFile));\n await ensureTypeFolderScaffold(\n pmRoot,\n resolveTypePresetDefinitions(presetName),\n warnings,\n \"schema:apply-preset-folder\",\n );\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: typesPath,\n scope: \"project\",\n op: \"schema:apply-preset\",\n })),\n );\n } finally {\n await releaseLock();\n }\n\n return {\n action: \"apply-preset\",\n preset: presetName,\n registered,\n replaced,\n file: {\n path: typesPath,\n definitions: definitionsCount,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\n/** Validates the positive inference threshold while preserving the command default. */\nfunction resolveSchemaInferenceMinCount(value: number | undefined): number {\n if (value === undefined) {\n return 10;\n }\n if (!Number.isInteger(value) || value < 1) {\n throw new PmCliError(\n \"--min-count must be a positive integer (>= 1).\",\n EXIT_CODE.USAGE,\n );\n }\n return value;\n}\n\n/** Implements run schema infer types for the public runtime surface of this module. */\nexport async function runSchemaInferTypes(\n options: SchemaAddTypeInferCommandOptions,\n global: GlobalOptions,\n): Promise<SchemaAddTypeInferResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n await ensureInitialized(pmRoot);\n\n const settings = await readSettings(pmRoot);\n const schema = normalizeRuntimeSchemaSettings(settings.schema);\n const typesPath = typesPathFor(pmRoot, schema);\n const minCount = resolveSchemaInferenceMinCount(options.minCount);\n\n const registry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n registry.type_to_folder,\n [],\n schema,\n );\n const titles = items.map((item) =>\n typeof item.title === \"string\" ? item.title : \"\",\n );\n const candidates = inferTypesFromTitles(titles, { minCount });\n\n const warnings: string[] = [];\n const registered: string[] = [];\n const replaced: string[] = [];\n const skipped: Array<{ name: string; reason: string }> = [];\n let definitionsCount: number;\n\n // Dry-run preview by default: only --apply mutates schema/types.json.\n if (!options.apply) {\n let parsed;\n try {\n parsed = parseItemTypesFile(await readFileIfExists(typesPath));\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n definitionsCount = parsed.definitions.length;\n return {\n action: \"infer-types\",\n applied: false,\n min_count: minCount,\n candidates,\n registered,\n replaced,\n skipped,\n file: {\n path: typesPath,\n definitions: definitionsCount,\n },\n warnings,\n generated_at: nowIso(),\n };\n }\n\n const author = toAuthor(options.author, settings.author_default);\n const governance = resolveGovernanceKnobs(settings);\n const releaseLock = await acquireLock(\n pmRoot,\n SCHEMA_TYPES_LOCK_ID,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n try {\n const previousRaw = await readFileIfExists(typesPath);\n let parsed;\n try {\n parsed = parseItemTypesFile(previousRaw);\n } catch (error) {\n throw new PmCliError(\n error instanceof Error ? error.message : String(error),\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n let nextFile = parsed;\n for (const candidate of candidates) {\n if (candidate.shadows_builtin) {\n skipped.push({ name: candidate.name, reason: \"shadows_builtin\" });\n continue;\n }\n let normalized;\n try {\n normalized = normalizeAddTypeInput({ name: candidate.name });\n } catch {\n // A title prefix that does not normalize to a valid type token (rare,\n // given the inference pattern) is skipped rather than aborting the batch.\n skipped.push({ name: candidate.name, reason: \"invalid_type_token\" });\n continue;\n }\n const upsert = upsertItemType(nextFile, normalized);\n nextFile = upsert.file;\n (upsert.replaced ? replaced : registered).push(upsert.definition.name);\n }\n definitionsCount = nextFile.definitions.length;\n await writeFileAtomic(typesPath, serializeItemTypesFile(nextFile));\n await ensureTypeFolderScaffold(\n pmRoot,\n nextFile.definitions.filter(\n (definition) =>\n registered.includes(definition.name) ||\n replaced.includes(definition.name),\n ),\n warnings,\n \"schema:infer-types-folder\",\n );\n warnings.push(\n ...(await runActiveOnWriteHooks({\n path: typesPath,\n scope: \"project\",\n op: \"schema:infer-types\",\n })),\n );\n } finally {\n await releaseLock();\n }\n\n return {\n action: \"infer-types\",\n applied: true,\n min_count: minCount,\n candidates,\n registered,\n replaced,\n skipped,\n file: {\n path: typesPath,\n definitions: definitionsCount,\n },\n warnings: finalizeWarnings(warnings),\n generated_at: nowIso(),\n };\n}\n\n/** Implements format schema add type human for the public runtime surface of this module. */\nexport function formatSchemaAddTypeHuman(result: SchemaAddTypeResult): string {\n const verb = result.replaced ? \"Updated\" : \"Registered\";\n const aliasSuffix =\n result.type.aliases && result.type.aliases.length > 0\n ? ` (aliases: ${result.type.aliases.join(\", \")})`\n : \"\";\n return `${verb} custom item type \"${result.type.name}\"${aliasSuffix} in ${result.file.path}. Run: pm create \"${escapeForDoubleQuotes(result.type.name)}\" \"<title>\"`;\n}\n\n/** Implements format schema remove type human for the public runtime surface of this module. */\nexport function formatSchemaRemoveTypeHuman(\n result: SchemaRemoveTypeResult,\n): string {\n if (!result.removed) {\n return `No custom item type matched; nothing removed from ${result.file.path}.`;\n }\n const name = result.type?.name ?? \"(unknown)\";\n return `Removed custom item type \"${name}\" from ${result.file.path}.`;\n}\n\n/** Implements format schema add status human for the public runtime surface of this module. */\nexport function formatSchemaAddStatusHuman(\n result: SchemaAddStatusResult,\n): string {\n const verb = result.replaced ? \"Updated\" : \"Registered\";\n const roleSuffix =\n result.status.roles && result.status.roles.length > 0\n ? ` (roles: ${result.status.roles.join(\", \")})`\n : \"\";\n const aliasSuffix =\n result.status.aliases && result.status.aliases.length > 0\n ? ` (aliases: ${result.status.aliases.join(\", \")})`\n : \"\";\n return `${verb} status \"${result.status.id}\"${roleSuffix}${aliasSuffix} in ${result.file.path}.`;\n}\n\n/** Implements format schema remove status human for the public runtime surface of this module. */\nexport function formatSchemaRemoveStatusHuman(\n result: SchemaRemoveStatusResult,\n): string {\n if (!result.removed) {\n return `No custom status matched; nothing removed from ${result.file.path}.`;\n }\n const id = result.status?.id ?? \"(unknown)\";\n return `Removed custom status \"${id}\" from ${result.file.path}.`;\n}\n\n/** Implements format schema list human for the public runtime surface of this module. */\nexport function formatSchemaListHuman(result: SchemaListResult): string {\n const lines = [\n `Schema types: ${result.counts.total} total (${result.counts.builtin} builtin, ${result.counts.custom} custom, ${result.counts.extension} extension)`,\n ];\n for (const [label, entries] of [\n [\"builtin\", result.builtin],\n [\"custom\", result.custom],\n [\"extension\", result.extension],\n ] as const) {\n if (entries.length === 0) {\n continue;\n }\n lines.push(`${label}: ${entries.map((entry) => entry.name).join(\", \")}`);\n }\n lines.push(\n `statuses: ${result.statuses.counts.total} total (${result.statuses.counts.builtin} builtin, ${result.statuses.counts.custom} custom)`,\n );\n for (const [label, entries] of [\n [\"builtin statuses\", result.statuses.builtin],\n [\"custom statuses\", result.statuses.custom],\n ] as const) {\n if (entries.length === 0) {\n continue;\n }\n lines.push(`${label}: ${entries.map((entry) => entry.id).join(\", \")}`);\n }\n lines.push(`custom fields: ${result.fields.counts.total} total`);\n if (result.fields.custom.length > 0) {\n lines.push(\n `fields: ${result.fields.custom.map((field) => `${field.key} (${field.type}, ${field.cli_flag})`).join(\", \")}`,\n );\n }\n lines.push(`Inspect one: pm schema show <Type>`);\n lines.push(`Inspect one status: pm schema show-status <status>`);\n lines.push(`Inspect one field: pm schema show-field <key>`);\n return lines.join(\"\\n\");\n}\n\n/** Implements format schema show human for the public runtime surface of this module. */\nexport function formatSchemaShowHuman(result: SchemaShowResult): string {\n const parts = [\n `type: ${result.type.name}`,\n `source: ${result.type.source}`,\n `folder: ${result.type.folder}`,\n ];\n if (result.type.default_status) {\n parts.push(`default_status: ${result.type.default_status}`);\n }\n if (result.type.aliases.length > 0) {\n parts.push(`aliases: ${result.type.aliases.join(\", \")}`);\n }\n if (result.type.description) {\n parts.push(`description: ${result.type.description}`);\n }\n if (result.type.options.length > 0) {\n parts.push(\n `options: ${result.type.options.map((option) => option.key).join(\", \")}`,\n );\n }\n return parts.join(\"\\n\");\n}\n\n/** Implements format schema show status human for the public runtime surface of this module. */\nexport function formatSchemaShowStatusHuman(\n result: SchemaShowStatusResult,\n): string {\n const parts = [\n `status: ${result.status.id}`,\n `source: ${result.status.source}`,\n ];\n if (result.status.roles.length > 0) {\n parts.push(`roles: ${result.status.roles.join(\", \")}`);\n }\n if (result.status.aliases.length > 0) {\n parts.push(`aliases: ${result.status.aliases.join(\", \")}`);\n }\n if (result.status.description) {\n parts.push(`description: ${result.status.description}`);\n }\n if (typeof result.status.order === \"number\") {\n parts.push(`order: ${result.status.order}`);\n }\n return parts.join(\"\\n\");\n}\n\nfunction formatFieldSummaryLine(field: SchemaFieldSummary): string {\n const flags: string[] = [];\n if (field.required) {\n flags.push(\"required\");\n }\n if (field.required_on_create) {\n flags.push(\"required_on_create\");\n }\n if (!field.allow_unset) {\n flags.push(\"no_unset\");\n }\n const flagSuffix = flags.length > 0 ? ` [${flags.join(\", \")}]` : \"\";\n return `${field.key} (${field.type}) ${field.cli_flag} commands=${field.commands.join(\"/\")}${flagSuffix}`;\n}\n\n/** Implements format schema add field human for the public runtime surface of this module. */\nexport function formatSchemaAddFieldHuman(\n result: SchemaAddFieldResult,\n): string {\n const verb = result.replaced ? \"Updated\" : \"Registered\";\n return `${verb} custom field \"${result.field.key}\" in ${result.file.path}. Use it: pm create \"<title>\" --${(result.field.cli_flag ?? result.field.key).replaceAll(\"_\", \"-\")} <value>`;\n}\n\n/** Implements format schema remove field human for the public runtime surface of this module. */\nexport function formatSchemaRemoveFieldHuman(\n result: SchemaRemoveFieldResult,\n): string {\n if (!result.removed) {\n return `No custom field matched; nothing removed from ${result.file.path}.`;\n }\n const key = result.field?.key ?? \"(unknown)\";\n return `Removed custom field \"${key}\" from ${result.file.path}.`;\n}\n\n/** Implements format schema list fields human for the public runtime surface of this module. */\nexport function formatSchemaListFieldsHuman(\n result: SchemaListFieldsResult,\n): string {\n const lines = [`Custom fields: ${result.counts.total} total`];\n for (const field of result.fields) {\n lines.push(` ${formatFieldSummaryLine(field)}`);\n }\n lines.push(`Inspect one: pm schema show-field <key>`);\n return lines.join(\"\\n\");\n}\n\n/** Implements format schema show field human for the public runtime surface of this module. */\nexport function formatSchemaShowFieldHuman(\n result: SchemaShowFieldResult,\n): string {\n const field = result.field;\n const parts = [\n `field: ${field.key}`,\n `type: ${field.type}`,\n `cli_flag: ${field.cli_flag}`,\n `commands: ${field.commands.join(\", \")}`,\n ];\n if (field.cli_aliases.length > 0) {\n parts.push(`cli_aliases: ${field.cli_aliases.join(\", \")}`);\n }\n if (field.description) {\n parts.push(`description: ${field.description}`);\n }\n if (field.required) {\n parts.push(`required: true`);\n }\n if (field.required_on_create) {\n parts.push(`required_on_create: true`);\n }\n if (!field.allow_unset) {\n parts.push(`allow_unset: false`);\n }\n if (field.required_types.length > 0) {\n parts.push(`required_types: ${field.required_types.join(\", \")}`);\n }\n return parts.join(\"\\n\");\n}\n\n/** Implements format schema apply preset human for the public runtime surface of this module. */\nexport function formatSchemaApplyPresetHuman(\n result: SchemaApplyPresetResult,\n): string {\n const registered =\n result.registered.length > 0\n ? `registered: ${result.registered.join(\", \")}`\n : \"\";\n const replaced =\n result.replaced.length > 0 ? `updated: ${result.replaced.join(\", \")}` : \"\";\n const detail = [registered, replaced]\n .filter((part) => part.length > 0)\n .join(\"; \");\n return `Applied \"${result.preset}\" type preset to ${result.file.path}${detail.length > 0 ? ` (${detail})` : \"\"}.`;\n}\n\n/** Implements format schema infer types human for the public runtime surface of this module. */\nexport function formatSchemaInferTypesHuman(\n result: SchemaAddTypeInferResult,\n): string {\n if (result.candidates.length === 0) {\n return `No title-prefix conventions found with at least ${result.min_count} items. Lower the threshold with --min-count <n>.`;\n }\n const lines = result.applied\n ? [\n `Inferred and registered custom types from title prefixes (min-count ${result.min_count}):`,\n ]\n : [\n `Inferred custom type candidates from title prefixes (min-count ${result.min_count}, dry-run):`,\n ];\n for (const candidate of result.candidates) {\n const note = candidate.shadows_builtin\n ? \" [shadows built-in, skipped]\"\n : \"\";\n lines.push(\n ` ${candidate.name} <- \"${candidate.prefix}\" (${candidate.count} items)${note}`,\n );\n }\n if (!result.applied) {\n lines.push(`Re-run with --apply to register the non-shadowing candidates.`);\n } else {\n if (result.registered.length > 0) {\n lines.push(`registered: ${result.registered.join(\", \")}`);\n }\n if (result.replaced.length > 0) {\n lines.push(`updated: ${result.replaced.join(\", \")}`);\n }\n }\n return lines.join(\"\\n\");\n}\n\n/* c8 ignore stop */\n\n/** Re-export so register-mutation can surface the hint in usage examples without importing the core module directly. */\nexport { buildInvalidTypeHint };\n\n/** Public contract for test only schema command, shared by SDK and presentation-layer consumers. */\nexport const _testOnlySchemaCommand = {\n toAuthor,\n workflowSlotsReferencing,\n};\n","/**\n * @module core/schema/type-inference\n *\n * Resolves configurable schema, fields, statuses, and workflows for Type Inference.\n */\nimport { matchBuiltinTypeName } from \"./item-types-file.js\";\n\n/**\n * Pure logic for `pm schema add-type --infer`: scan existing item titles for\n * stable `PREFIX-`/`PREFIX:` conventions and propose them as custom item types.\n * The CLI command file (schema.ts) owns IO and the optional registration; this\n * module only derives candidates from a list of titles so it is fully testable\n * and coverage-gated to 100%.\n *\n * Conventions recognized (case-insensitive, first run wins per title):\n * - `INFRA- ...` / `SECURITY-...` (hyphen-delimited prefix)\n * - `BUG: ...` / `SPIKE: ...` (colon-delimited prefix)\n * The prefix token must be a letter-led identifier of letters, digits, and\n * internal hyphens/underscores so it maps cleanly to a single PascalCase type\n * name. Purely numeric or sequence-style prefixes (e.g. `S001-`, `E12-`) are\n * intentionally skipped: they index items, they are not type boundaries.\n */\n\nconst PREFIX_PATTERN = /^([A-Za-z][A-Za-z0-9_-]*?)\\s*[-:]\\s+\\S/;\n\n/** Documents the inferred type candidate payload exchanged by command, SDK, and package integrations. */\nexport interface InferredTypeCandidate {\n /** Suggested PascalCase type name derived from the prefix. */\n name: string;\n /** The normalized prefix token (lowercase) the items share. */\n prefix: string;\n /** How many scanned titles carry this prefix. */\n count: number;\n /** A few example titles (capped) for human/agent review. */\n examples: string[];\n /** True when `name` already resolves to a reserved built-in type. */\n shadows_builtin: boolean;\n}\n\n/** Documents the infer types options payload exchanged by command, SDK, and package integrations. */\nexport interface InferTypesOptions {\n /** Minimum number of titles that must share a prefix to surface it (default 10). */\n minCount?: number;\n /** Maximum example titles retained per candidate (default 3). */\n maxExamples?: number;\n}\n\n/** Extracts the leading prefix token from a title, or undefined when the title has no stable letter-led `PREFIX-`/`PREFIX:` convention. */\nexport function extractTitlePrefix(title: string): string | undefined {\n const match = PREFIX_PATTERN.exec(title.trim());\n if (!match) {\n return undefined;\n }\n const token = match[1];\n // Reject single-character prefixes (e.g. \"S-\", \"E-\"): they are sequence/index\n // markers far more often than genuine type boundaries.\n if (token.length < 2) {\n return undefined;\n }\n // Reject sequence/index-style prefixes — a single leading letter followed by\n // only digits (e.g. \"S001-\", \"E12-\", \"V1-\"). These index items rather than\n // mark a type boundary, matching the convention documented above.\n if (/^[A-Za-z]\\d+$/.test(token)) {\n return undefined;\n }\n return token.toLowerCase();\n}\n\n/** Converts a normalized prefix token into a PascalCase type name. Internal hyphen/underscore runs become word boundaries; each word is capitalized. */\nexport function prefixToTypeName(prefix: string): string {\n return prefix\n .split(/[-_]+/)\n .filter((segment) => segment.length > 0)\n .map(\n (segment) =>\n `${segment.slice(0, 1).toUpperCase()}${segment.slice(1).toLowerCase()}`,\n )\n .join(\"\");\n}\n\n/** Scans titles for shared prefix conventions and returns candidate custom types, sorted by descending frequency then name. Only prefixes carried by at least `minCount` titles are returned. */\nexport function inferTypesFromTitles(\n titles: string[],\n options: InferTypesOptions = {},\n): InferredTypeCandidate[] {\n const minCount =\n typeof options.minCount === \"number\" && options.minCount > 0\n ? Math.trunc(options.minCount)\n : 10;\n const maxExamples =\n typeof options.maxExamples === \"number\" && options.maxExamples > 0\n ? Math.trunc(options.maxExamples)\n : 3;\n const byPrefix = new Map<string, { count: number; examples: string[] }>();\n for (const rawTitle of titles) {\n const title = typeof rawTitle === \"string\" ? rawTitle.trim() : \"\";\n if (title.length === 0) {\n continue;\n }\n const prefix = extractTitlePrefix(title);\n if (prefix === undefined) {\n continue;\n }\n const bucket = byPrefix.get(prefix) ?? { count: 0, examples: [] };\n bucket.count += 1;\n if (bucket.examples.length < maxExamples) {\n bucket.examples.push(title);\n }\n byPrefix.set(prefix, bucket);\n }\n const candidates: InferredTypeCandidate[] = [];\n for (const [prefix, bucket] of byPrefix.entries()) {\n if (bucket.count < minCount) {\n continue;\n }\n const name = prefixToTypeName(prefix);\n candidates.push({\n name,\n prefix,\n count: bucket.count,\n examples: bucket.examples,\n shadows_builtin: matchBuiltinTypeName(name) !== undefined,\n });\n }\n candidates.sort(\n (left, right) =>\n right.count - left.count || left.name.localeCompare(right.name),\n );\n return candidates;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,UAAU;AACjB,SAAS,aAAa;;;ACiBtB,IAAM,iBAAiB;AAyBjB,SAAU,mBAAmB,OAAa;AAC9C,QAAM,QAAQ,eAAe,KAAK,MAAM,KAAI,CAAE;AAC9C,MAAI,CAAC,OAAO;AACV,WAAO;EACT;AACA,QAAM,QAAQ,MAAM,CAAC;AAGrB,MAAI,MAAM,SAAS,GAAG;AACpB,WAAO;EACT;AAIA,MAAI,gBAAgB,KAAK,KAAK,GAAG;AAC/B,WAAO;EACT;AACA,SAAO,MAAM,YAAW;AAC1B;AAGM,SAAU,iBAAiB,QAAc;AAC7C,SAAO,OACJ,MAAM,OAAO,EACb,OAAO,CAAC,YAAY,QAAQ,SAAS,CAAC,EACtC,IACC,CAAC,YACC,GAAG,QAAQ,MAAM,GAAG,CAAC,EAAE,YAAW,CAAE,GAAG,QAAQ,MAAM,CAAC,EAAE,YAAW,CAAE,EAAE,EAE1E,KAAK,EAAE;AACZ;AAGM,SAAU,qBACd,QACA,UAA6B,CAAA,GAAE;AAE/B,QAAM,WACJ,OAAO,QAAQ,aAAa,YAAY,QAAQ,WAAW,IACvD,KAAK,MAAM,QAAQ,QAAQ,IAC3B;AACN,QAAM,cACJ,OAAO,QAAQ,gBAAgB,YAAY,QAAQ,cAAc,IAC7D,KAAK,MAAM,QAAQ,WAAW,IAC9B;AACN,QAAM,WAAW,oBAAI,IAAG;AACxB,aAAW,YAAY,QAAQ;AAC7B,UAAM,QAAQ,OAAO,aAAa,WAAW,SAAS,KAAI,IAAK;AAC/D,QAAI,MAAM,WAAW,GAAG;AACtB;IACF;AACA,UAAM,SAAS,mBAAmB,KAAK;AACvC,QAAI,WA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