@unbrained/pm-cli 2026.7.2 → 2026.7.4

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 (546) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/CHANGELOG.md +29 -0
  3. package/CONTRIBUTING.md +38 -9
  4. package/README.md +1 -5
  5. package/dist/cli/commander-usage.js +54 -41
  6. package/dist/cli/commander-usage.js.map +1 -1
  7. package/dist/cli/commands/activity.js +79 -57
  8. package/dist/cli/commands/activity.js.map +1 -1
  9. package/dist/cli/commands/calendar.js +3 -3
  10. package/dist/cli/commands/calendar.js.map +1 -1
  11. package/dist/cli/commands/close-many.js +106 -65
  12. package/dist/cli/commands/close-many.js.map +1 -1
  13. package/dist/cli/commands/completion.js +231 -345
  14. package/dist/cli/commands/completion.js.map +1 -1
  15. package/dist/cli/commands/create.d.ts +2 -59
  16. package/dist/cli/commands/create.js +38 -39
  17. package/dist/cli/commands/create.js.map +1 -1
  18. package/dist/cli/commands/extension/doctor.js +56 -67
  19. package/dist/cli/commands/extension/doctor.js.map +1 -1
  20. package/dist/cli/commands/extension/scaffold.js +54 -133
  21. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  22. package/dist/cli/commands/extension/shared.js +21 -15
  23. package/dist/cli/commands/extension/shared.js.map +1 -1
  24. package/dist/cli/commands/files.js +3 -3
  25. package/dist/cli/commands/files.js.map +1 -1
  26. package/dist/cli/commands/health.js +101 -112
  27. package/dist/cli/commands/health.js.map +1 -1
  28. package/dist/cli/commands/history-compact.js +9 -18
  29. package/dist/cli/commands/history-compact.js.map +1 -1
  30. package/dist/cli/commands/history-repair.js +9 -19
  31. package/dist/cli/commands/history-repair.js.map +1 -1
  32. package/dist/cli/commands/init-agent-guidance.js +160 -111
  33. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  34. package/dist/cli/commands/init.js +3 -3
  35. package/dist/cli/commands/init.js.map +1 -1
  36. package/dist/cli/commands/item-filter-options.d.ts +2 -0
  37. package/dist/cli/commands/item-filter-options.js +2 -2
  38. package/dist/cli/commands/item-filter-options.js.map +1 -1
  39. package/dist/cli/commands/mutation-command-options.d.ts +78 -0
  40. package/dist/cli/commands/mutation-command-options.js +10 -0
  41. package/dist/cli/commands/mutation-command-options.js.map +1 -0
  42. package/dist/cli/commands/next.js +13 -10
  43. package/dist/cli/commands/next.js.map +1 -1
  44. package/dist/cli/commands/profile.js +23 -15
  45. package/dist/cli/commands/profile.js.map +1 -1
  46. package/dist/cli/commands/reindex.js +3 -3
  47. package/dist/cli/commands/reindex.js.map +1 -1
  48. package/dist/cli/commands/shared-unset-fields.d.ts +19 -0
  49. package/dist/cli/commands/shared-unset-fields.js +31 -2
  50. package/dist/cli/commands/shared-unset-fields.js.map +1 -1
  51. package/dist/cli/commands/update.d.ts +2 -59
  52. package/dist/cli/commands/update.js +26 -97
  53. package/dist/cli/commands/update.js.map +1 -1
  54. package/dist/cli/commands/validate.d.ts +2 -0
  55. package/dist/cli/commands/validate.js +16 -4
  56. package/dist/cli/commands/validate.js.map +1 -1
  57. package/dist/cli/error-guidance.js +9 -6
  58. package/dist/cli/error-guidance.js.map +1 -1
  59. package/dist/cli/extension-command-help.js +27 -19
  60. package/dist/cli/extension-command-help.js.map +1 -1
  61. package/dist/cli/help-json-payload.js +57 -49
  62. package/dist/cli/help-json-payload.js.map +1 -1
  63. package/dist/cli/main.js +48 -32
  64. package/dist/cli/main.js.map +1 -1
  65. package/dist/cli/register-list-query.js +215 -213
  66. package/dist/cli/register-list-query.js.map +1 -1
  67. package/dist/cli/register-mutation.js +368 -368
  68. package/dist/cli/register-mutation.js.map +1 -1
  69. package/dist/cli/register-operations.js +303 -299
  70. package/dist/cli/register-operations.js.map +1 -1
  71. package/dist/cli/registration-helpers.d.ts +4 -0
  72. package/dist/cli/registration-helpers.js +51 -56
  73. package/dist/cli/registration-helpers.js.map +1 -1
  74. package/dist/cli-bundle/chunks/activity-IDS5GSYG.js +16 -0
  75. package/dist/cli-bundle/chunks/{activity-CUC4JY3U.js → activity-OENQCYZD.js} +9 -9
  76. package/dist/cli-bundle/chunks/{aggregate-SW5PNGCS.js → aggregate-EC4LWS3U.js} +8 -8
  77. package/dist/cli-bundle/chunks/{aggregate-DKUTRY6R.js → aggregate-RCB3QJJE.js} +8 -8
  78. package/dist/cli-bundle/chunks/{append-H32VOR2Y.js → append-ADBOI3A6.js} +8 -8
  79. package/dist/cli-bundle/chunks/{append-UBM632FK.js → append-XLEKVVWB.js} +8 -8
  80. package/dist/cli-bundle/chunks/{chunk-Q6NXOHS6.js → chunk-2LRMWMZ6.js} +7 -7
  81. package/dist/cli-bundle/chunks/{chunk-2227673O.js → chunk-2ONH3WG6.js} +32 -13
  82. package/dist/cli-bundle/chunks/{chunk-2227673O.js.map → chunk-2ONH3WG6.js.map} +1 -1
  83. package/dist/cli-bundle/chunks/{chunk-MNBPX5JS.js → chunk-2VK677OA.js} +72 -49
  84. package/dist/cli-bundle/chunks/chunk-2VK677OA.js.map +7 -0
  85. package/dist/cli-bundle/chunks/{chunk-KLXF7NCC.js → chunk-3C5T3ZEO.js} +2 -2
  86. package/dist/cli-bundle/chunks/{chunk-JMK5GCK2.js → chunk-3MLQZI3H.js} +2 -2
  87. package/dist/cli-bundle/chunks/{chunk-BTX5MIQF.js → chunk-4EVY7CQN.js} +2 -2
  88. package/dist/cli-bundle/chunks/{chunk-Q6K2OACU.js → chunk-4IW7STMB.js} +7 -7
  89. package/dist/cli-bundle/chunks/{chunk-6YCYF2AI.js → chunk-4KPQQ42D.js} +166 -110
  90. package/dist/cli-bundle/chunks/chunk-4KPQQ42D.js.map +1 -0
  91. package/dist/cli-bundle/chunks/{chunk-BVZZN2LH.js → chunk-4OXNQHKQ.js} +23 -17
  92. package/dist/cli-bundle/chunks/{chunk-BVZZN2LH.js.map → chunk-4OXNQHKQ.js.map} +2 -2
  93. package/dist/cli-bundle/chunks/{chunk-UWKEJMZU.js → chunk-4PJYRA3V.js} +31 -12
  94. package/dist/cli-bundle/chunks/{chunk-UWKEJMZU.js.map → chunk-4PJYRA3V.js.map} +3 -3
  95. package/dist/cli-bundle/chunks/{chunk-EMPGXBUF.js → chunk-4SHME4VR.js} +2 -2
  96. package/dist/cli-bundle/chunks/{chunk-6ITZLD4T.js → chunk-5FYY76HR.js} +28 -99
  97. package/dist/cli-bundle/chunks/chunk-5FYY76HR.js.map +7 -0
  98. package/dist/cli-bundle/chunks/{chunk-OTUJZKGI.js → chunk-6QY2NA2M.js} +24 -18
  99. package/dist/cli-bundle/chunks/{chunk-OTUJZKGI.js.map → chunk-6QY2NA2M.js.map} +1 -1
  100. package/dist/cli-bundle/chunks/{chunk-2KWL5NPW.js → chunk-6YB7HG2J.js} +2 -2
  101. package/dist/cli-bundle/chunks/{chunk-36UGKF4O.js → chunk-724VLYDJ.js} +2 -2
  102. package/dist/cli-bundle/chunks/{chunk-XCHUVHKU.js → chunk-75VMARGO.js} +11 -11
  103. package/dist/cli-bundle/chunks/chunk-75VMARGO.js.map +1 -0
  104. package/dist/cli-bundle/chunks/{chunk-XWGEMNBR.js → chunk-7745CXNI.js} +119 -195
  105. package/dist/cli-bundle/chunks/chunk-7745CXNI.js.map +7 -0
  106. package/dist/cli-bundle/chunks/{chunk-YPKFV2JR.js → chunk-7G5SUU6F.js} +76 -54
  107. package/dist/cli-bundle/chunks/chunk-7G5SUU6F.js.map +1 -0
  108. package/dist/cli-bundle/chunks/{chunk-Y4NRKBFW.js → chunk-7ITQSEBL.js} +3 -3
  109. package/dist/cli-bundle/chunks/{chunk-W47SML5B.js → chunk-A222YWOQ.js} +7 -7
  110. package/dist/cli-bundle/chunks/{chunk-3LCUASYG.js → chunk-A2W3XKAD.js} +2 -2
  111. package/dist/cli-bundle/chunks/{chunk-KN3URLKS.js → chunk-AOP2EMK3.js} +3 -3
  112. package/dist/cli-bundle/chunks/{chunk-RM37OPYK.js → chunk-AZMPKLIA.js} +72 -49
  113. package/dist/cli-bundle/chunks/chunk-AZMPKLIA.js.map +1 -0
  114. package/dist/cli-bundle/chunks/{chunk-7NSPKJUS.js → chunk-BDDYM4LH.js} +262 -252
  115. package/dist/cli-bundle/chunks/chunk-BDDYM4LH.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-JXAUVO6X.js → chunk-CN4OAA2G.js} +55 -20
  117. package/dist/cli-bundle/chunks/chunk-CN4OAA2G.js.map +7 -0
  118. package/dist/cli-bundle/chunks/{chunk-IEEJQCZ4.js → chunk-CQFZRLXQ.js} +3 -3
  119. package/dist/cli-bundle/chunks/{chunk-4NUOWFBT.js → chunk-CQISNF3Z.js} +7 -7
  120. package/dist/cli-bundle/chunks/{chunk-S62UANU7.js → chunk-D2LDM35X.js} +3 -3
  121. package/dist/cli-bundle/chunks/{chunk-GRRG3MCT.js → chunk-DEIDJQZK.js} +57 -136
  122. package/dist/cli-bundle/chunks/chunk-DEIDJQZK.js.map +7 -0
  123. package/dist/cli-bundle/chunks/{chunk-IG5JYZGU.js → chunk-DJ5S2LDY.js} +7 -7
  124. package/dist/cli-bundle/chunks/{chunk-A6VOGKBA.js → chunk-EB4BBEZD.js} +6 -6
  125. package/dist/cli-bundle/chunks/{chunk-QH3FSKRJ.js → chunk-EH23N5FX.js} +2 -2
  126. package/dist/cli-bundle/chunks/{chunk-HQTPRV4D.js → chunk-FDNJMYZB.js} +6 -6
  127. package/dist/cli-bundle/chunks/{chunk-K2VYLVX4.js → chunk-FMWQRMHS.js} +33 -6
  128. package/dist/cli-bundle/chunks/chunk-FMWQRMHS.js.map +1 -0
  129. package/dist/cli-bundle/chunks/{chunk-N2JSWVWG.js → chunk-HL742IBM.js} +4 -4
  130. package/dist/cli-bundle/chunks/{chunk-3AZUFQK6.js → chunk-J4KNRDI3.js} +59 -70
  131. package/dist/cli-bundle/chunks/{chunk-3AZUFQK6.js.map → chunk-J4KNRDI3.js.map} +1 -1
  132. package/dist/cli-bundle/chunks/{chunk-66Z3X7ZG.js → chunk-JYLFF7GJ.js} +166 -110
  133. package/dist/cli-bundle/chunks/chunk-JYLFF7GJ.js.map +7 -0
  134. package/dist/cli-bundle/chunks/{chunk-GFMSLORL.js → chunk-JZJJEJBR.js} +75 -53
  135. package/dist/cli-bundle/chunks/chunk-JZJJEJBR.js.map +7 -0
  136. package/dist/cli-bundle/chunks/{chunk-7TH5NMVB.js → chunk-KKHIQOTN.js} +25 -19
  137. package/dist/cli-bundle/chunks/chunk-KKHIQOTN.js.map +7 -0
  138. package/dist/cli-bundle/chunks/{chunk-5GVTFFTC.js → chunk-LLQLLAKU.js} +118 -194
  139. package/dist/cli-bundle/chunks/chunk-LLQLLAKU.js.map +1 -0
  140. package/dist/cli-bundle/chunks/{chunk-KIYCOJ63.js → chunk-M34MVAOP.js} +58 -137
  141. package/dist/cli-bundle/chunks/chunk-M34MVAOP.js.map +1 -0
  142. package/dist/cli-bundle/chunks/{chunk-CZPVDLD2.js → chunk-M6PR5BC6.js} +7 -7
  143. package/dist/cli-bundle/chunks/{chunk-XEWQKDYZ.js → chunk-MTB4PRA3.js} +10 -10
  144. package/dist/cli-bundle/chunks/chunk-MTB4PRA3.js.map +7 -0
  145. package/dist/cli-bundle/chunks/{chunk-MRD4T5LF.js → chunk-MZ4NH46V.js} +2 -2
  146. package/dist/cli-bundle/chunks/{chunk-AIAIXG7I.js → chunk-MZG6I2Q2.js} +39 -5
  147. package/dist/cli-bundle/chunks/chunk-MZG6I2Q2.js.map +7 -0
  148. package/dist/cli-bundle/chunks/{chunk-ZNHEYCDD.js → chunk-N2LOJUBB.js} +2 -2
  149. package/dist/cli-bundle/chunks/{chunk-WJAMWAHZ.js → chunk-NGDK3KEZ.js} +5 -5
  150. package/dist/cli-bundle/chunks/{chunk-SYNKD3ZG.js → chunk-NHDR3UCW.js} +46 -60
  151. package/dist/cli-bundle/chunks/chunk-NHDR3UCW.js.map +7 -0
  152. package/dist/cli-bundle/chunks/{chunk-2CHRYUXL.js → chunk-NHKXOMZ5.js} +2 -2
  153. package/dist/cli-bundle/chunks/{chunk-7MYWF4ZX.js → chunk-OTSP6UEX.js} +7 -7
  154. package/dist/cli-bundle/chunks/{chunk-UGLU6Q2I.js → chunk-PUVPC5DL.js} +4 -4
  155. package/dist/cli-bundle/chunks/{chunk-LTRAF2D7.js → chunk-PV5JS7MP.js} +3 -3
  156. package/dist/cli-bundle/chunks/{chunk-KCO2EAN5.js → chunk-Q2266G4S.js} +3 -3
  157. package/dist/cli-bundle/chunks/{chunk-SYVUU7EK.js → chunk-Q3XVLRCJ.js} +9 -9
  158. package/dist/cli-bundle/chunks/{chunk-AJEBCRIY.js → chunk-QFXFKYNQ.js} +47 -61
  159. package/dist/cli-bundle/chunks/chunk-QFXFKYNQ.js.map +1 -0
  160. package/dist/cli-bundle/chunks/{chunk-6ZMBJRDJ.js → chunk-R7EMP4JG.js} +9 -9
  161. package/dist/cli-bundle/chunks/{chunk-SPM2XLWI.js → chunk-SBNT6SLO.js} +22 -7
  162. package/dist/cli-bundle/chunks/chunk-SBNT6SLO.js.map +7 -0
  163. package/dist/cli-bundle/chunks/{chunk-I66WE2HE.js → chunk-SL2ANJSV.js} +260 -250
  164. package/dist/cli-bundle/chunks/chunk-SL2ANJSV.js.map +1 -0
  165. package/dist/cli-bundle/chunks/{chunk-U2BEEM2X.js → chunk-T5RTYLZJ.js} +3 -3
  166. package/dist/cli-bundle/chunks/{chunk-UTSH5GWX.js → chunk-TGYDJEJH.js} +7 -7
  167. package/dist/cli-bundle/chunks/{chunk-H4GRLYJS.js → chunk-TO4KCIOT.js} +3 -3
  168. package/dist/cli-bundle/chunks/{chunk-EUKTMRN3.js → chunk-TUV7SIWZ.js} +2 -2
  169. package/dist/cli-bundle/chunks/{chunk-N3QCJS4M.js → chunk-UGDONITK.js} +58 -69
  170. package/dist/cli-bundle/chunks/{chunk-N3QCJS4M.js.map → chunk-UGDONITK.js.map} +2 -2
  171. package/dist/cli-bundle/chunks/{chunk-NRZS637N.js → chunk-UYLA5ROU.js} +56 -21
  172. package/dist/cli-bundle/chunks/chunk-UYLA5ROU.js.map +1 -0
  173. package/dist/cli-bundle/chunks/{chunk-55XRYWEG.js → chunk-V655JQ5J.js} +8 -8
  174. package/dist/cli-bundle/chunks/{chunk-3Q2HBMTI.js → chunk-W5X3AHJN.js} +2 -2
  175. package/dist/cli-bundle/chunks/{chunk-XTHQWXVC.js → chunk-WBWRQS32.js} +5 -5
  176. package/dist/cli-bundle/chunks/{chunk-UT73HUPC.js → chunk-WOOB7PV7.js} +3 -3
  177. package/dist/cli-bundle/chunks/{chunk-5PGBHRY3.js → chunk-WSDIALO4.js} +2 -2
  178. package/dist/cli-bundle/chunks/{chunk-LRKMWUUV.js → chunk-WTXDLBSZ.js} +2 -2
  179. package/dist/cli-bundle/chunks/{chunk-FFOQHGNH.js → chunk-XBIYI23P.js} +8 -8
  180. package/dist/cli-bundle/chunks/{chunk-7W4H4K26.js → chunk-XFO2NJY6.js} +29 -100
  181. package/dist/cli-bundle/chunks/chunk-XFO2NJY6.js.map +1 -0
  182. package/dist/cli-bundle/chunks/{chunk-TPOFWBMY.js → chunk-XQCWTSLO.js} +26 -20
  183. package/dist/cli-bundle/chunks/chunk-XQCWTSLO.js.map +1 -0
  184. package/dist/cli-bundle/chunks/{chunk-2ASNV4DH.js → chunk-Y2VSCQ77.js} +4 -4
  185. package/dist/cli-bundle/chunks/{chunk-ZNT7KEWE.js → chunk-YZR7UMZ6.js} +2 -2
  186. package/dist/cli-bundle/chunks/{chunk-YLZZ6T54.js → chunk-YZWXMDNH.js} +23 -8
  187. package/dist/cli-bundle/chunks/chunk-YZWXMDNH.js.map +1 -0
  188. package/dist/cli-bundle/chunks/{chunk-CYBDUHNO.js → chunk-ZIEGTQCY.js} +3 -3
  189. package/dist/cli-bundle/chunks/{chunk-TTHCEV5Q.js → chunk-ZZWMJVW2.js} +4 -4
  190. package/dist/cli-bundle/chunks/{claim-Z7MEQCBT.js → claim-D6L33A5Y.js} +8 -8
  191. package/dist/cli-bundle/chunks/{claim-SENTPZBN.js → claim-YAFUTPVK.js} +8 -8
  192. package/dist/cli-bundle/chunks/close-KLDLHAOP.js +14 -0
  193. package/dist/cli-bundle/chunks/{close-424MX4CU.js → close-TGYXG7TV.js} +7 -7
  194. package/dist/cli-bundle/chunks/{close-many-SWY34BII.js → close-many-4QSWKCRU.js} +119 -76
  195. package/dist/cli-bundle/chunks/close-many-4QSWKCRU.js.map +7 -0
  196. package/dist/cli-bundle/chunks/{close-many-2IV4J2TR.js → close-many-SNA6LNZH.js} +120 -77
  197. package/dist/cli-bundle/chunks/close-many-SNA6LNZH.js.map +1 -0
  198. package/dist/cli-bundle/chunks/{comments-4FGNTSNV.js → comments-QC6ARR5X.js} +9 -9
  199. package/dist/cli-bundle/chunks/{comments-7YS5MY5X.js → comments-ZHVYGUVC.js} +9 -9
  200. package/dist/cli-bundle/chunks/{config-G74GISC4.js → config-O6W2EU2G.js} +7 -7
  201. package/dist/cli-bundle/chunks/{config-BZJKK7FZ.js → config-XQRFJXJP.js} +7 -7
  202. package/dist/cli-bundle/chunks/{context-LHVKJSPJ.js → context-IHE3IXN5.js} +12 -12
  203. package/dist/cli-bundle/chunks/{context-ZQY54JNS.js → context-WSYWBEUL.js} +12 -12
  204. package/dist/cli-bundle/chunks/{contracts-FIZLMP7O.js → contracts-CVBINC7C.js} +3 -3
  205. package/dist/cli-bundle/chunks/{contracts-CP2EZJC7.js → contracts-NLCDIZAT.js} +3 -3
  206. package/dist/cli-bundle/chunks/{copy-TLW7JTQT.js → copy-7MUQC44A.js} +5 -5
  207. package/dist/cli-bundle/chunks/{copy-GYNQQPW2.js → copy-ANWXDJVC.js} +5 -5
  208. package/dist/cli-bundle/chunks/create-AJ6HUR5W.js +28 -0
  209. package/dist/cli-bundle/chunks/{create-VSKYSOCD.js → create-JIA2IFCO.js} +12 -12
  210. package/dist/cli-bundle/chunks/{delete-ANTOTI2I.js → delete-5OLYWQIC.js} +5 -5
  211. package/dist/cli-bundle/chunks/{delete-4W5JYCEG.js → delete-INHKCIRN.js} +5 -5
  212. package/dist/cli-bundle/chunks/{deps-HPPE6MJN.js → deps-CCSWGZW7.js} +5 -5
  213. package/dist/cli-bundle/chunks/{deps-ZQZN54EZ.js → deps-IYEID3QX.js} +5 -5
  214. package/dist/cli-bundle/chunks/{docs-XJNYBJGE.js → docs-3XZK22WF.js} +7 -7
  215. package/dist/cli-bundle/chunks/{docs-RPOVFMP3.js → docs-PKO7OEIM.js} +7 -7
  216. package/dist/cli-bundle/chunks/{eval-RFBI5FGS.js → eval-5XYP6NMY.js} +10 -10
  217. package/dist/cli-bundle/chunks/{eval-DM6JBZTS.js → eval-O4WGQYDI.js} +10 -10
  218. package/dist/cli-bundle/chunks/{extension-TTSEFQTS.js → extension-PVGRRZZG.js} +11 -11
  219. package/dist/cli-bundle/chunks/{extension-B3YY4WY5.js → extension-T7JNTAAA.js} +11 -11
  220. package/dist/cli-bundle/chunks/{files-5D65CHGE.js → files-7IU56S6R.js} +10 -10
  221. package/dist/cli-bundle/chunks/files-7IU56S6R.js.map +1 -0
  222. package/dist/cli-bundle/chunks/{files-GPIG77EN.js → files-W7HH5EOD.js} +9 -9
  223. package/dist/cli-bundle/chunks/{files-GPIG77EN.js.map → files-W7HH5EOD.js.map} +1 -1
  224. package/dist/cli-bundle/chunks/{focus-ZHN7WIGX.js → focus-6FA5KYRY.js} +6 -6
  225. package/dist/cli-bundle/chunks/{focus-C3PEJV2C.js → focus-CQ63JFDG.js} +6 -6
  226. package/dist/cli-bundle/chunks/{gc-D4JQ6OWN.js → gc-3BG67KTO.js} +3 -3
  227. package/dist/cli-bundle/chunks/{gc-VZIXDL32.js → gc-PEZYGNVB.js} +3 -3
  228. package/dist/cli-bundle/chunks/{get-GIBRUUOP.js → get-J6CSJ4SX.js} +10 -10
  229. package/dist/cli-bundle/chunks/{get-IOVAN6RU.js → get-KJTKGNEQ.js} +10 -10
  230. package/dist/cli-bundle/chunks/{health-L2U3AFKV.js → health-32UQICEL.js} +115 -123
  231. package/dist/cli-bundle/chunks/health-32UQICEL.js.map +1 -0
  232. package/dist/cli-bundle/chunks/{health-MM7AWXYF.js → health-ZUZG5ULV.js} +114 -122
  233. package/dist/cli-bundle/chunks/health-ZUZG5ULV.js.map +7 -0
  234. package/dist/cli-bundle/chunks/history-IOH6FKG7.js +18 -0
  235. package/dist/cli-bundle/chunks/{history-IL7XCEX2.js → history-W6QVR6FA.js} +8 -8
  236. package/dist/cli-bundle/chunks/{history-compact-HALOTOU7.js → history-compact-F355EGL4.js} +20 -27
  237. package/dist/cli-bundle/chunks/history-compact-F355EGL4.js.map +1 -0
  238. package/dist/cli-bundle/chunks/{history-compact-MV25P7DM.js → history-compact-JQ6ZGYSJ.js} +19 -26
  239. package/dist/cli-bundle/chunks/history-compact-JQ6ZGYSJ.js.map +7 -0
  240. package/dist/cli-bundle/chunks/{history-redact-VYCWQFK7.js → history-redact-TUWOUYX5.js} +9 -9
  241. package/dist/cli-bundle/chunks/history-redact-VVDOARNO.js +19 -0
  242. package/dist/cli-bundle/chunks/{history-repair-44MODPQF.js → history-repair-MPCAIKYE.js} +20 -28
  243. package/dist/cli-bundle/chunks/history-repair-MPCAIKYE.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{history-repair-CPNAOCNF.js → history-repair-ZKS3LKPV.js} +19 -27
  245. package/dist/cli-bundle/chunks/history-repair-ZKS3LKPV.js.map +7 -0
  246. package/dist/cli-bundle/chunks/init-CZLEEE6Q.js +22 -0
  247. package/dist/cli-bundle/chunks/{init-F27NHENZ.js → init-MAA6UMNQ.js} +12 -12
  248. package/dist/cli-bundle/chunks/{learnings-XSFSUUWK.js → learnings-EYC3OKS2.js} +9 -9
  249. package/dist/cli-bundle/chunks/{learnings-HJVDQIGY.js → learnings-HKJJUVTA.js} +9 -9
  250. package/dist/cli-bundle/chunks/{list-VMPWTURB.js → list-HFD5737R.js} +8 -8
  251. package/dist/cli-bundle/chunks/{list-HPMEKCAA.js → list-KN3TL5Y5.js} +8 -8
  252. package/dist/cli-bundle/chunks/{next-ETXF2ZCN.js → next-DQUMFAHG.js} +25 -22
  253. package/dist/cli-bundle/chunks/{next-ETXF2ZCN.js.map → next-DQUMFAHG.js.map} +2 -2
  254. package/dist/cli-bundle/chunks/{next-QM6YJIIS.js → next-JUEYC5HE.js} +26 -23
  255. package/dist/cli-bundle/chunks/next-JUEYC5HE.js.map +1 -0
  256. package/dist/cli-bundle/chunks/{notes-WDDBPC4D.js → notes-XATYT43P.js} +9 -9
  257. package/dist/cli-bundle/chunks/{notes-GDZIKGR6.js → notes-ZG6RLZXB.js} +9 -9
  258. package/dist/cli-bundle/chunks/{plan-BGDR73Z6.js → plan-5NWQL2DH.js} +12 -12
  259. package/dist/cli-bundle/chunks/{plan-C5IMM335.js → plan-DVVLX7LK.js} +12 -12
  260. package/dist/cli-bundle/chunks/{profile-CCOKZ2IQ.js → profile-54DZ4CLB.js} +27 -19
  261. package/dist/cli-bundle/chunks/profile-54DZ4CLB.js.map +1 -0
  262. package/dist/cli-bundle/chunks/{profile-HUCENIEQ.js → profile-PLIQVEOY.js} +26 -18
  263. package/dist/cli-bundle/chunks/profile-PLIQVEOY.js.map +7 -0
  264. package/dist/cli-bundle/chunks/{register-list-query-ROSNIL52.js → register-list-query-PNRAHNIQ.js} +181 -172
  265. package/dist/cli-bundle/chunks/register-list-query-PNRAHNIQ.js.map +1 -0
  266. package/dist/cli-bundle/chunks/{register-list-query-XN4ZRHSV.js → register-list-query-WRS6ACUW.js} +180 -171
  267. package/dist/cli-bundle/chunks/register-list-query-WRS6ACUW.js.map +7 -0
  268. package/dist/cli-bundle/chunks/{register-mutation-KRLAHEL2.js → register-mutation-ET6E4VLE.js} +367 -361
  269. package/dist/cli-bundle/chunks/register-mutation-ET6E4VLE.js.map +7 -0
  270. package/dist/cli-bundle/chunks/{register-mutation-CFSB2MS3.js → register-mutation-K2MNRWGI.js} +368 -362
  271. package/dist/cli-bundle/chunks/register-mutation-K2MNRWGI.js.map +1 -0
  272. package/dist/cli-bundle/chunks/{register-operations-MBN4KGUM.js → register-operations-6DQRUTIX.js} +310 -305
  273. package/dist/cli-bundle/chunks/register-operations-6DQRUTIX.js.map +1 -0
  274. package/dist/cli-bundle/chunks/{register-operations-4PASGJDB.js → register-operations-73UDWMVB.js} +309 -304
  275. package/dist/cli-bundle/chunks/register-operations-73UDWMVB.js.map +7 -0
  276. package/dist/cli-bundle/chunks/{register-setup-ZCGKHDKL.js → register-setup-FXZJ2CEJ.js} +15 -15
  277. package/dist/cli-bundle/chunks/{register-setup-VIAWYFP5.js → register-setup-LYYCMQFV.js} +15 -15
  278. package/dist/cli-bundle/chunks/restore-L27TMMCF.js +17 -0
  279. package/dist/cli-bundle/chunks/{restore-4CBWUMCX.js → restore-R6YJHQK3.js} +9 -9
  280. package/dist/cli-bundle/chunks/{scheduling-shortcuts-6VFKNKCM.js → scheduling-shortcuts-LE4S7OI7.js} +12 -12
  281. package/dist/cli-bundle/chunks/{scheduling-shortcuts-ERHCVTEM.js → scheduling-shortcuts-OGODPUBL.js} +12 -12
  282. package/dist/cli-bundle/chunks/{schema-UE5KKAUX.js → schema-ICCD3HOP.js} +7 -7
  283. package/dist/cli-bundle/chunks/{schema-TDGK6N3I.js → schema-RHH23PQX.js} +7 -7
  284. package/dist/cli-bundle/chunks/{search-FP7MEU4S.js → search-HDDKOPFE.js} +10 -10
  285. package/dist/cli-bundle/chunks/{search-K4CFLQ5S.js → search-Z2VGP2Q5.js} +10 -10
  286. package/dist/cli-bundle/chunks/{stats-NJJCALEZ.js → stats-DHMRXHOB.js} +6 -6
  287. package/dist/cli-bundle/chunks/{stats-XT6QRKQY.js → stats-ETFP37MB.js} +6 -6
  288. package/dist/cli-bundle/chunks/{telemetry-HVXFZA2U.js → telemetry-NUZNKDCP.js} +4 -4
  289. package/dist/cli-bundle/chunks/{telemetry-5SQ5UDXC.js → telemetry-ZRBM22QD.js} +4 -4
  290. package/dist/cli-bundle/chunks/{test-UFSJ5YIO.js → test-H36PM746.js} +15 -15
  291. package/dist/cli-bundle/chunks/{test-YCDAUBWF.js → test-XNKTIP4Y.js} +15 -15
  292. package/dist/cli-bundle/chunks/{test-all-2BWKY3GQ.js → test-all-APCBSXQI.js} +17 -17
  293. package/dist/cli-bundle/chunks/{test-all-PM7UYN42.js → test-all-KIK3OYBY.js} +17 -17
  294. package/dist/cli-bundle/chunks/{test-runs-H4TGWGRN.js → test-runs-5SLLV3XU.js} +4 -4
  295. package/dist/cli-bundle/chunks/{test-runs-FK5E75AA.js → test-runs-L3WKLO67.js} +4 -4
  296. package/dist/cli-bundle/chunks/update-RQKI3AMW.js +24 -0
  297. package/dist/cli-bundle/chunks/{update-Y5WQVT5O.js → update-ZM7NJWHY.js} +15 -15
  298. package/dist/cli-bundle/chunks/{update-many-JTKKSA7Y.js → update-many-GFCQG6ZQ.js} +28 -28
  299. package/dist/cli-bundle/chunks/{update-many-6YAYYRLE.js → update-many-XGTJ7QIU.js} +28 -28
  300. package/dist/cli-bundle/chunks/{upgrade-DTAHZ236.js → upgrade-KJ3JGELR.js} +11 -11
  301. package/dist/cli-bundle/chunks/{upgrade-JUDU7YL4.js → upgrade-RBRQ7PQU.js} +11 -11
  302. package/dist/cli-bundle/chunks/{validate-732RWS5W.js → validate-EW6TGC7R.js} +31 -21
  303. package/dist/cli-bundle/chunks/validate-EW6TGC7R.js.map +7 -0
  304. package/dist/cli-bundle/chunks/{validate-W7H5TEDC.js → validate-T6PR5WAL.js} +32 -22
  305. package/dist/cli-bundle/chunks/validate-T6PR5WAL.js.map +1 -0
  306. package/dist/cli-bundle/main.js +180 -122
  307. package/dist/cli-bundle/main.js.map +3 -3
  308. package/dist/core/extensions/extension-types.d.ts +1 -2
  309. package/dist/core/extensions/extension-types.js +2 -2
  310. package/dist/core/extensions/extension-types.js.map +1 -1
  311. package/dist/core/history/history-rewrite.d.ts +10 -0
  312. package/dist/core/history/history-rewrite.js +27 -3
  313. package/dist/core/history/history-rewrite.js.map +1 -1
  314. package/dist/core/item/type-registry.d.ts +1 -0
  315. package/dist/core/item/type-registry.js +180 -194
  316. package/dist/core/item/type-registry.js.map +1 -1
  317. package/dist/core/schema/runtime-schema.js +65 -54
  318. package/dist/core/schema/runtime-schema.js.map +1 -1
  319. package/dist/core/schema/status-defs-file.js +26 -3
  320. package/dist/core/schema/status-defs-file.js.map +1 -1
  321. package/dist/core/search/corpus.js +25 -19
  322. package/dist/core/search/corpus.js.map +1 -1
  323. package/dist/core/shared/memo.d.ts +12 -0
  324. package/dist/core/shared/memo.js +25 -0
  325. package/dist/core/shared/memo.js.map +1 -0
  326. package/dist/core/shared/serialization.js +24 -14
  327. package/dist/core/shared/serialization.js.map +1 -1
  328. package/dist/core/shared/time.js +26 -4
  329. package/dist/core/shared/time.js.map +1 -1
  330. package/dist/core/store/front-matter-cache.d.ts +5 -0
  331. package/dist/core/store/front-matter-cache.js +79 -20
  332. package/dist/core/store/front-matter-cache.js.map +1 -1
  333. package/dist/sdk/cli-contracts/flag-contracts.js +73 -99
  334. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  335. package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
  336. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  337. package/dist/sdk/cli-contracts/tool-schema.js +55 -94
  338. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  339. package/dist/sdk/compose.js +51 -42
  340. package/dist/sdk/compose.js.map +1 -1
  341. package/dist/sdk/package-import-adapters.d.ts +90 -2
  342. package/dist/sdk/package-import-adapters.js +274 -2
  343. package/dist/sdk/package-import-adapters.js.map +1 -1
  344. package/dist/sdk/runtime.d.ts +1 -1
  345. package/dist/sdk/runtime.js +3 -3
  346. package/dist/sdk/runtime.js.map +1 -1
  347. package/docs/AGENT_GUIDE.md +2 -2
  348. package/docs/ARCHITECTURE.md +2 -2
  349. package/docs/COMMANDS.md +8 -4
  350. package/docs/CONFIGURATION.md +1 -1
  351. package/docs/EXTENSIONS.md +12 -12
  352. package/docs/ONBOARDING.md +4 -2
  353. package/docs/README.md +2 -0
  354. package/docs/examples/starter-extension/README.md +11 -10
  355. package/marketplace.json +3 -3
  356. package/package.json +4 -3
  357. package/packages/pm-beads/extensions/beads/runtime-loader.ts +27 -40
  358. package/packages/pm-beads/extensions/beads/runtime.ts +106 -223
  359. package/packages/pm-calendar/extensions/calendar/runtime.ts +21 -18
  360. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +9 -11
  361. package/packages/pm-todos/extensions/todos/runtime-loader.ts +48 -76
  362. package/packages/pm-todos/extensions/todos/runtime.ts +61 -257
  363. package/plugins/pm-claude/.claude-plugin/plugin.json +2 -2
  364. package/plugins/pm-claude/README.md +6 -3
  365. package/plugins/pm-claude/commands/pm-init.md +1 -1
  366. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +73 -31
  367. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +80 -34
  368. package/scripts/install.ps1 +7 -7
  369. package/dist/cli-bundle/chunks/activity-WEIEMM73.js +0 -16
  370. package/dist/cli-bundle/chunks/chunk-5GVTFFTC.js.map +0 -1
  371. package/dist/cli-bundle/chunks/chunk-66Z3X7ZG.js.map +0 -7
  372. package/dist/cli-bundle/chunks/chunk-6ITZLD4T.js.map +0 -7
  373. package/dist/cli-bundle/chunks/chunk-6YCYF2AI.js.map +0 -1
  374. package/dist/cli-bundle/chunks/chunk-7NSPKJUS.js.map +0 -7
  375. package/dist/cli-bundle/chunks/chunk-7TH5NMVB.js.map +0 -7
  376. package/dist/cli-bundle/chunks/chunk-7W4H4K26.js.map +0 -1
  377. package/dist/cli-bundle/chunks/chunk-AIAIXG7I.js.map +0 -7
  378. package/dist/cli-bundle/chunks/chunk-AJEBCRIY.js.map +0 -1
  379. package/dist/cli-bundle/chunks/chunk-GFMSLORL.js.map +0 -7
  380. package/dist/cli-bundle/chunks/chunk-GRRG3MCT.js.map +0 -7
  381. package/dist/cli-bundle/chunks/chunk-I66WE2HE.js.map +0 -1
  382. package/dist/cli-bundle/chunks/chunk-JXAUVO6X.js.map +0 -7
  383. package/dist/cli-bundle/chunks/chunk-K2VYLVX4.js.map +0 -1
  384. package/dist/cli-bundle/chunks/chunk-KIYCOJ63.js.map +0 -1
  385. package/dist/cli-bundle/chunks/chunk-MNBPX5JS.js.map +0 -7
  386. package/dist/cli-bundle/chunks/chunk-NRZS637N.js.map +0 -1
  387. package/dist/cli-bundle/chunks/chunk-RM37OPYK.js.map +0 -1
  388. package/dist/cli-bundle/chunks/chunk-SPM2XLWI.js.map +0 -7
  389. package/dist/cli-bundle/chunks/chunk-SYNKD3ZG.js.map +0 -7
  390. package/dist/cli-bundle/chunks/chunk-TPOFWBMY.js.map +0 -1
  391. package/dist/cli-bundle/chunks/chunk-XCHUVHKU.js.map +0 -1
  392. package/dist/cli-bundle/chunks/chunk-XEWQKDYZ.js.map +0 -7
  393. package/dist/cli-bundle/chunks/chunk-XWGEMNBR.js.map +0 -7
  394. package/dist/cli-bundle/chunks/chunk-YLZZ6T54.js.map +0 -1
  395. package/dist/cli-bundle/chunks/chunk-YPKFV2JR.js.map +0 -1
  396. package/dist/cli-bundle/chunks/close-YCWQQPDS.js +0 -14
  397. package/dist/cli-bundle/chunks/close-many-2IV4J2TR.js.map +0 -1
  398. package/dist/cli-bundle/chunks/close-many-SWY34BII.js.map +0 -7
  399. package/dist/cli-bundle/chunks/create-XTMAPS7I.js +0 -28
  400. package/dist/cli-bundle/chunks/files-5D65CHGE.js.map +0 -1
  401. package/dist/cli-bundle/chunks/health-L2U3AFKV.js.map +0 -1
  402. package/dist/cli-bundle/chunks/health-MM7AWXYF.js.map +0 -7
  403. package/dist/cli-bundle/chunks/history-DD7L7BNL.js +0 -18
  404. package/dist/cli-bundle/chunks/history-compact-HALOTOU7.js.map +0 -1
  405. package/dist/cli-bundle/chunks/history-compact-MV25P7DM.js.map +0 -7
  406. package/dist/cli-bundle/chunks/history-redact-IX4YEWMY.js +0 -19
  407. package/dist/cli-bundle/chunks/history-repair-44MODPQF.js.map +0 -1
  408. package/dist/cli-bundle/chunks/history-repair-CPNAOCNF.js.map +0 -7
  409. package/dist/cli-bundle/chunks/init-HHVQQP6C.js +0 -22
  410. package/dist/cli-bundle/chunks/next-QM6YJIIS.js.map +0 -1
  411. package/dist/cli-bundle/chunks/profile-CCOKZ2IQ.js.map +0 -1
  412. package/dist/cli-bundle/chunks/profile-HUCENIEQ.js.map +0 -7
  413. package/dist/cli-bundle/chunks/register-list-query-ROSNIL52.js.map +0 -1
  414. package/dist/cli-bundle/chunks/register-list-query-XN4ZRHSV.js.map +0 -7
  415. package/dist/cli-bundle/chunks/register-mutation-CFSB2MS3.js.map +0 -1
  416. package/dist/cli-bundle/chunks/register-mutation-KRLAHEL2.js.map +0 -7
  417. package/dist/cli-bundle/chunks/register-operations-4PASGJDB.js.map +0 -7
  418. package/dist/cli-bundle/chunks/register-operations-MBN4KGUM.js.map +0 -1
  419. package/dist/cli-bundle/chunks/restore-5UEAGG3W.js +0 -17
  420. package/dist/cli-bundle/chunks/update-MTCFES6X.js +0 -24
  421. package/dist/cli-bundle/chunks/validate-732RWS5W.js.map +0 -7
  422. package/dist/cli-bundle/chunks/validate-W7H5TEDC.js.map +0 -1
  423. /package/dist/cli-bundle/chunks/{activity-WEIEMM73.js.map → activity-IDS5GSYG.js.map} +0 -0
  424. /package/dist/cli-bundle/chunks/{activity-CUC4JY3U.js.map → activity-OENQCYZD.js.map} +0 -0
  425. /package/dist/cli-bundle/chunks/{aggregate-SW5PNGCS.js.map → aggregate-EC4LWS3U.js.map} +0 -0
  426. /package/dist/cli-bundle/chunks/{aggregate-DKUTRY6R.js.map → aggregate-RCB3QJJE.js.map} +0 -0
  427. /package/dist/cli-bundle/chunks/{append-H32VOR2Y.js.map → append-ADBOI3A6.js.map} +0 -0
  428. /package/dist/cli-bundle/chunks/{append-UBM632FK.js.map → append-XLEKVVWB.js.map} +0 -0
  429. /package/dist/cli-bundle/chunks/{chunk-Q6NXOHS6.js.map → chunk-2LRMWMZ6.js.map} +0 -0
  430. /package/dist/cli-bundle/chunks/{chunk-KLXF7NCC.js.map → chunk-3C5T3ZEO.js.map} +0 -0
  431. /package/dist/cli-bundle/chunks/{chunk-JMK5GCK2.js.map → chunk-3MLQZI3H.js.map} +0 -0
  432. /package/dist/cli-bundle/chunks/{chunk-BTX5MIQF.js.map → chunk-4EVY7CQN.js.map} +0 -0
  433. /package/dist/cli-bundle/chunks/{chunk-Q6K2OACU.js.map → chunk-4IW7STMB.js.map} +0 -0
  434. /package/dist/cli-bundle/chunks/{chunk-EMPGXBUF.js.map → chunk-4SHME4VR.js.map} +0 -0
  435. /package/dist/cli-bundle/chunks/{chunk-2KWL5NPW.js.map → chunk-6YB7HG2J.js.map} +0 -0
  436. /package/dist/cli-bundle/chunks/{chunk-36UGKF4O.js.map → chunk-724VLYDJ.js.map} +0 -0
  437. /package/dist/cli-bundle/chunks/{chunk-Y4NRKBFW.js.map → chunk-7ITQSEBL.js.map} +0 -0
  438. /package/dist/cli-bundle/chunks/{chunk-W47SML5B.js.map → chunk-A222YWOQ.js.map} +0 -0
  439. /package/dist/cli-bundle/chunks/{chunk-3LCUASYG.js.map → chunk-A2W3XKAD.js.map} +0 -0
  440. /package/dist/cli-bundle/chunks/{chunk-KN3URLKS.js.map → chunk-AOP2EMK3.js.map} +0 -0
  441. /package/dist/cli-bundle/chunks/{chunk-IEEJQCZ4.js.map → chunk-CQFZRLXQ.js.map} +0 -0
  442. /package/dist/cli-bundle/chunks/{chunk-4NUOWFBT.js.map → chunk-CQISNF3Z.js.map} +0 -0
  443. /package/dist/cli-bundle/chunks/{chunk-S62UANU7.js.map → chunk-D2LDM35X.js.map} +0 -0
  444. /package/dist/cli-bundle/chunks/{chunk-IG5JYZGU.js.map → chunk-DJ5S2LDY.js.map} +0 -0
  445. /package/dist/cli-bundle/chunks/{chunk-A6VOGKBA.js.map → chunk-EB4BBEZD.js.map} +0 -0
  446. /package/dist/cli-bundle/chunks/{chunk-QH3FSKRJ.js.map → chunk-EH23N5FX.js.map} +0 -0
  447. /package/dist/cli-bundle/chunks/{chunk-HQTPRV4D.js.map → chunk-FDNJMYZB.js.map} +0 -0
  448. /package/dist/cli-bundle/chunks/{chunk-N2JSWVWG.js.map → chunk-HL742IBM.js.map} +0 -0
  449. /package/dist/cli-bundle/chunks/{chunk-CZPVDLD2.js.map → chunk-M6PR5BC6.js.map} +0 -0
  450. /package/dist/cli-bundle/chunks/{chunk-MRD4T5LF.js.map → chunk-MZ4NH46V.js.map} +0 -0
  451. /package/dist/cli-bundle/chunks/{chunk-ZNHEYCDD.js.map → chunk-N2LOJUBB.js.map} +0 -0
  452. /package/dist/cli-bundle/chunks/{chunk-WJAMWAHZ.js.map → chunk-NGDK3KEZ.js.map} +0 -0
  453. /package/dist/cli-bundle/chunks/{chunk-2CHRYUXL.js.map → chunk-NHKXOMZ5.js.map} +0 -0
  454. /package/dist/cli-bundle/chunks/{chunk-7MYWF4ZX.js.map → chunk-OTSP6UEX.js.map} +0 -0
  455. /package/dist/cli-bundle/chunks/{chunk-UGLU6Q2I.js.map → chunk-PUVPC5DL.js.map} +0 -0
  456. /package/dist/cli-bundle/chunks/{chunk-LTRAF2D7.js.map → chunk-PV5JS7MP.js.map} +0 -0
  457. /package/dist/cli-bundle/chunks/{chunk-KCO2EAN5.js.map → chunk-Q2266G4S.js.map} +0 -0
  458. /package/dist/cli-bundle/chunks/{chunk-SYVUU7EK.js.map → chunk-Q3XVLRCJ.js.map} +0 -0
  459. /package/dist/cli-bundle/chunks/{chunk-6ZMBJRDJ.js.map → chunk-R7EMP4JG.js.map} +0 -0
  460. /package/dist/cli-bundle/chunks/{chunk-U2BEEM2X.js.map → chunk-T5RTYLZJ.js.map} +0 -0
  461. /package/dist/cli-bundle/chunks/{chunk-UTSH5GWX.js.map → chunk-TGYDJEJH.js.map} +0 -0
  462. /package/dist/cli-bundle/chunks/{chunk-H4GRLYJS.js.map → chunk-TO4KCIOT.js.map} +0 -0
  463. /package/dist/cli-bundle/chunks/{chunk-EUKTMRN3.js.map → chunk-TUV7SIWZ.js.map} +0 -0
  464. /package/dist/cli-bundle/chunks/{chunk-55XRYWEG.js.map → chunk-V655JQ5J.js.map} +0 -0
  465. /package/dist/cli-bundle/chunks/{chunk-3Q2HBMTI.js.map → chunk-W5X3AHJN.js.map} +0 -0
  466. /package/dist/cli-bundle/chunks/{chunk-XTHQWXVC.js.map → chunk-WBWRQS32.js.map} +0 -0
  467. /package/dist/cli-bundle/chunks/{chunk-UT73HUPC.js.map → chunk-WOOB7PV7.js.map} +0 -0
  468. /package/dist/cli-bundle/chunks/{chunk-5PGBHRY3.js.map → chunk-WSDIALO4.js.map} +0 -0
  469. /package/dist/cli-bundle/chunks/{chunk-LRKMWUUV.js.map → chunk-WTXDLBSZ.js.map} +0 -0
  470. /package/dist/cli-bundle/chunks/{chunk-FFOQHGNH.js.map → chunk-XBIYI23P.js.map} +0 -0
  471. /package/dist/cli-bundle/chunks/{chunk-2ASNV4DH.js.map → chunk-Y2VSCQ77.js.map} +0 -0
  472. /package/dist/cli-bundle/chunks/{chunk-ZNT7KEWE.js.map → chunk-YZR7UMZ6.js.map} +0 -0
  473. /package/dist/cli-bundle/chunks/{chunk-CYBDUHNO.js.map → chunk-ZIEGTQCY.js.map} +0 -0
  474. /package/dist/cli-bundle/chunks/{chunk-TTHCEV5Q.js.map → chunk-ZZWMJVW2.js.map} +0 -0
  475. /package/dist/cli-bundle/chunks/{claim-Z7MEQCBT.js.map → claim-D6L33A5Y.js.map} +0 -0
  476. /package/dist/cli-bundle/chunks/{claim-SENTPZBN.js.map → claim-YAFUTPVK.js.map} +0 -0
  477. /package/dist/cli-bundle/chunks/{close-YCWQQPDS.js.map → close-KLDLHAOP.js.map} +0 -0
  478. /package/dist/cli-bundle/chunks/{close-424MX4CU.js.map → close-TGYXG7TV.js.map} +0 -0
  479. /package/dist/cli-bundle/chunks/{comments-4FGNTSNV.js.map → comments-QC6ARR5X.js.map} +0 -0
  480. /package/dist/cli-bundle/chunks/{comments-7YS5MY5X.js.map → comments-ZHVYGUVC.js.map} +0 -0
  481. /package/dist/cli-bundle/chunks/{config-G74GISC4.js.map → config-O6W2EU2G.js.map} +0 -0
  482. /package/dist/cli-bundle/chunks/{config-BZJKK7FZ.js.map → config-XQRFJXJP.js.map} +0 -0
  483. /package/dist/cli-bundle/chunks/{context-LHVKJSPJ.js.map → context-IHE3IXN5.js.map} +0 -0
  484. /package/dist/cli-bundle/chunks/{context-ZQY54JNS.js.map → context-WSYWBEUL.js.map} +0 -0
  485. /package/dist/cli-bundle/chunks/{contracts-FIZLMP7O.js.map → contracts-CVBINC7C.js.map} +0 -0
  486. /package/dist/cli-bundle/chunks/{contracts-CP2EZJC7.js.map → contracts-NLCDIZAT.js.map} +0 -0
  487. /package/dist/cli-bundle/chunks/{copy-TLW7JTQT.js.map → copy-7MUQC44A.js.map} +0 -0
  488. /package/dist/cli-bundle/chunks/{copy-GYNQQPW2.js.map → copy-ANWXDJVC.js.map} +0 -0
  489. /package/dist/cli-bundle/chunks/{create-XTMAPS7I.js.map → create-AJ6HUR5W.js.map} +0 -0
  490. /package/dist/cli-bundle/chunks/{create-VSKYSOCD.js.map → create-JIA2IFCO.js.map} +0 -0
  491. /package/dist/cli-bundle/chunks/{delete-ANTOTI2I.js.map → delete-5OLYWQIC.js.map} +0 -0
  492. /package/dist/cli-bundle/chunks/{delete-4W5JYCEG.js.map → delete-INHKCIRN.js.map} +0 -0
  493. /package/dist/cli-bundle/chunks/{deps-HPPE6MJN.js.map → deps-CCSWGZW7.js.map} +0 -0
  494. /package/dist/cli-bundle/chunks/{deps-ZQZN54EZ.js.map → deps-IYEID3QX.js.map} +0 -0
  495. /package/dist/cli-bundle/chunks/{docs-XJNYBJGE.js.map → docs-3XZK22WF.js.map} +0 -0
  496. /package/dist/cli-bundle/chunks/{docs-RPOVFMP3.js.map → docs-PKO7OEIM.js.map} +0 -0
  497. /package/dist/cli-bundle/chunks/{eval-RFBI5FGS.js.map → eval-5XYP6NMY.js.map} +0 -0
  498. /package/dist/cli-bundle/chunks/{eval-DM6JBZTS.js.map → eval-O4WGQYDI.js.map} +0 -0
  499. /package/dist/cli-bundle/chunks/{extension-TTSEFQTS.js.map → extension-PVGRRZZG.js.map} +0 -0
  500. /package/dist/cli-bundle/chunks/{extension-B3YY4WY5.js.map → extension-T7JNTAAA.js.map} +0 -0
  501. /package/dist/cli-bundle/chunks/{focus-ZHN7WIGX.js.map → focus-6FA5KYRY.js.map} +0 -0
  502. /package/dist/cli-bundle/chunks/{focus-C3PEJV2C.js.map → focus-CQ63JFDG.js.map} +0 -0
  503. /package/dist/cli-bundle/chunks/{gc-D4JQ6OWN.js.map → gc-3BG67KTO.js.map} +0 -0
  504. /package/dist/cli-bundle/chunks/{gc-VZIXDL32.js.map → gc-PEZYGNVB.js.map} +0 -0
  505. /package/dist/cli-bundle/chunks/{get-GIBRUUOP.js.map → get-J6CSJ4SX.js.map} +0 -0
  506. /package/dist/cli-bundle/chunks/{get-IOVAN6RU.js.map → get-KJTKGNEQ.js.map} +0 -0
  507. /package/dist/cli-bundle/chunks/{history-DD7L7BNL.js.map → history-IOH6FKG7.js.map} +0 -0
  508. /package/dist/cli-bundle/chunks/{history-IL7XCEX2.js.map → history-W6QVR6FA.js.map} +0 -0
  509. /package/dist/cli-bundle/chunks/{history-redact-VYCWQFK7.js.map → history-redact-TUWOUYX5.js.map} +0 -0
  510. /package/dist/cli-bundle/chunks/{history-redact-IX4YEWMY.js.map → history-redact-VVDOARNO.js.map} +0 -0
  511. /package/dist/cli-bundle/chunks/{init-HHVQQP6C.js.map → init-CZLEEE6Q.js.map} +0 -0
  512. /package/dist/cli-bundle/chunks/{init-F27NHENZ.js.map → init-MAA6UMNQ.js.map} +0 -0
  513. /package/dist/cli-bundle/chunks/{learnings-XSFSUUWK.js.map → learnings-EYC3OKS2.js.map} +0 -0
  514. /package/dist/cli-bundle/chunks/{learnings-HJVDQIGY.js.map → learnings-HKJJUVTA.js.map} +0 -0
  515. /package/dist/cli-bundle/chunks/{list-VMPWTURB.js.map → list-HFD5737R.js.map} +0 -0
  516. /package/dist/cli-bundle/chunks/{list-HPMEKCAA.js.map → list-KN3TL5Y5.js.map} +0 -0
  517. /package/dist/cli-bundle/chunks/{notes-WDDBPC4D.js.map → notes-XATYT43P.js.map} +0 -0
  518. /package/dist/cli-bundle/chunks/{notes-GDZIKGR6.js.map → notes-ZG6RLZXB.js.map} +0 -0
  519. /package/dist/cli-bundle/chunks/{plan-BGDR73Z6.js.map → plan-5NWQL2DH.js.map} +0 -0
  520. /package/dist/cli-bundle/chunks/{plan-C5IMM335.js.map → plan-DVVLX7LK.js.map} +0 -0
  521. /package/dist/cli-bundle/chunks/{register-setup-ZCGKHDKL.js.map → register-setup-FXZJ2CEJ.js.map} +0 -0
  522. /package/dist/cli-bundle/chunks/{register-setup-VIAWYFP5.js.map → register-setup-LYYCMQFV.js.map} +0 -0
  523. /package/dist/cli-bundle/chunks/{restore-5UEAGG3W.js.map → restore-L27TMMCF.js.map} +0 -0
  524. /package/dist/cli-bundle/chunks/{restore-4CBWUMCX.js.map → restore-R6YJHQK3.js.map} +0 -0
  525. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-6VFKNKCM.js.map → scheduling-shortcuts-LE4S7OI7.js.map} +0 -0
  526. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-ERHCVTEM.js.map → scheduling-shortcuts-OGODPUBL.js.map} +0 -0
  527. /package/dist/cli-bundle/chunks/{schema-UE5KKAUX.js.map → schema-ICCD3HOP.js.map} +0 -0
  528. /package/dist/cli-bundle/chunks/{schema-TDGK6N3I.js.map → schema-RHH23PQX.js.map} +0 -0
  529. /package/dist/cli-bundle/chunks/{search-FP7MEU4S.js.map → search-HDDKOPFE.js.map} +0 -0
  530. /package/dist/cli-bundle/chunks/{search-K4CFLQ5S.js.map → search-Z2VGP2Q5.js.map} +0 -0
  531. /package/dist/cli-bundle/chunks/{stats-NJJCALEZ.js.map → stats-DHMRXHOB.js.map} +0 -0
  532. /package/dist/cli-bundle/chunks/{stats-XT6QRKQY.js.map → stats-ETFP37MB.js.map} +0 -0
  533. /package/dist/cli-bundle/chunks/{telemetry-HVXFZA2U.js.map → telemetry-NUZNKDCP.js.map} +0 -0
  534. /package/dist/cli-bundle/chunks/{telemetry-5SQ5UDXC.js.map → telemetry-ZRBM22QD.js.map} +0 -0
  535. /package/dist/cli-bundle/chunks/{test-UFSJ5YIO.js.map → test-H36PM746.js.map} +0 -0
  536. /package/dist/cli-bundle/chunks/{test-YCDAUBWF.js.map → test-XNKTIP4Y.js.map} +0 -0
  537. /package/dist/cli-bundle/chunks/{test-all-2BWKY3GQ.js.map → test-all-APCBSXQI.js.map} +0 -0
  538. /package/dist/cli-bundle/chunks/{test-all-PM7UYN42.js.map → test-all-KIK3OYBY.js.map} +0 -0
  539. /package/dist/cli-bundle/chunks/{test-runs-H4TGWGRN.js.map → test-runs-5SLLV3XU.js.map} +0 -0
  540. /package/dist/cli-bundle/chunks/{test-runs-FK5E75AA.js.map → test-runs-L3WKLO67.js.map} +0 -0
  541. /package/dist/cli-bundle/chunks/{update-MTCFES6X.js.map → update-RQKI3AMW.js.map} +0 -0
  542. /package/dist/cli-bundle/chunks/{update-Y5WQVT5O.js.map → update-ZM7NJWHY.js.map} +0 -0
  543. /package/dist/cli-bundle/chunks/{update-many-JTKKSA7Y.js.map → update-many-GFCQG6ZQ.js.map} +0 -0
  544. /package/dist/cli-bundle/chunks/{update-many-6YAYYRLE.js.map → update-many-XGTJ7QIU.js.map} +0 -0
  545. /package/dist/cli-bundle/chunks/{upgrade-DTAHZ236.js.map → upgrade-KJ3JGELR.js.map} +0 -0
  546. /package/dist/cli-bundle/chunks/{upgrade-JUDU7YL4.js.map → upgrade-RBRQ7PQU.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/bootstrap-args.ts", "../../../../../../../../cli/commands/extension/shared.ts"],
4
- "sourcesContent": ["/**\n * @module cli/bootstrap-args\n *\n * Provides CLI runtime support for Bootstrap Args.\n */\nimport { resolveSubcommandFlagContractsForCommand, type CliFlagContract } from \"../sdk/cli-contracts.js\";\nimport { levenshteinDistanceWithinLimit } from \"../core/shared/levenshtein.js\";\n\nfunction parseBootstrapPathToken(\n token: string,\n next: string | undefined,\n): { consumed: number; pathValue?: string; preferred: boolean } | null {\n if (token === \"--path\" || token === \"--pm-path\") {\n if (typeof next === \"string\" && next.length > 0) {\n return {\n consumed: 2,\n pathValue: next,\n preferred: token === \"--pm-path\",\n };\n }\n return {\n consumed: 1,\n preferred: token === \"--pm-path\",\n };\n }\n\n const inlinePrefix = token.startsWith(\"--path=\")\n ? \"--path=\"\n : token.startsWith(\"--pm-path=\")\n ? \"--pm-path=\"\n : undefined;\n if (!inlinePrefix) {\n return null;\n }\n\n const value = token.slice(inlinePrefix.length);\n if (value.length > 0) {\n return {\n consumed: 1,\n pathValue: value,\n preferred: inlinePrefix === \"--pm-path=\",\n };\n }\n return {\n consumed: 1,\n preferred: inlinePrefix === \"--pm-path=\",\n };\n}\n\n/**\n * Documents the bootstrap global options payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapGlobalOptions {\n path?: string;\n noExtensions: boolean;\n noPager: boolean;\n json: boolean;\n quiet: boolean;\n}\n\n/**\n * Implements parse bootstrap global options for the public runtime surface of this module.\n */\nexport function parseBootstrapGlobalOptions(argv: string[]): BootstrapGlobalOptions {\n let legacyPathValue: string | undefined;\n let pmPathValue: string | undefined;\n let noExtensions = false;\n let noPager = false;\n let json = false;\n let quiet = false;\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n break;\n }\n if (token === \"--no-extensions\") {\n noExtensions = true;\n index += 1;\n continue;\n }\n if (token === \"--no-pager\") {\n noPager = true;\n index += 1;\n continue;\n }\n if (token === \"--json\") {\n json = true;\n index += 1;\n continue;\n }\n if (token === \"--quiet\") {\n quiet = true;\n index += 1;\n continue;\n }\n const parsedPath = parseBootstrapPathToken(token, argv[index + 1]);\n if (parsedPath) {\n if (parsedPath.pathValue !== undefined) {\n if (parsedPath.preferred) {\n pmPathValue = parsedPath.pathValue;\n } else {\n legacyPathValue = parsedPath.pathValue;\n }\n }\n index += parsedPath.consumed;\n continue;\n }\n index += 1;\n }\n return {\n path: pmPathValue ?? legacyPathValue,\n noExtensions,\n noPager,\n json,\n quiet,\n };\n}\n\n/**\n * Implements strip global bootstrap tokens for the public runtime surface of this module.\n */\nexport function stripGlobalBootstrapTokens(argv: string[]): string[] {\n const remaining: string[] = [];\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n break;\n }\n if (\n token === \"--json\" ||\n token === \"--quiet\" ||\n token === \"--no-extensions\" ||\n token === \"--no-pager\" ||\n token === \"--profile\" ||\n token === \"--id-only\" ||\n token === \"--explain\"\n ) {\n index += 1;\n continue;\n }\n if (token === \"--path\" || token === \"--pm-path\") {\n index += 2;\n continue;\n }\n if (token.startsWith(\"--path=\") || token.startsWith(\"--pm-path=\")) {\n index += 1;\n continue;\n }\n remaining.push(token);\n index += 1;\n }\n return remaining;\n}\n\n/**\n * Documents the bootstrap help request payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapHelpRequest {\n requested: boolean;\n commandPathTokens: string[];\n}\n\n/**\n * Implements parse bootstrap help request for the public runtime surface of this module.\n */\nexport function parseBootstrapHelpRequest(argv: string[]): BootstrapHelpRequest {\n const stripped = stripGlobalBootstrapTokens(argv);\n const first = stripped[0]?.trim().toLowerCase();\n if (first === \"help\") {\n const commandPathTokens: string[] = [];\n for (let index = 1; index < stripped.length; index += 1) {\n const token = stripped[index];\n if (token.startsWith(\"-\")) {\n break;\n }\n commandPathTokens.push(token.trim().toLowerCase());\n }\n return {\n requested: true,\n commandPathTokens,\n };\n }\n\n const helpFlagIndex = stripped.findIndex((token) => token === \"--help\" || token === \"-h\");\n if (helpFlagIndex < 0) {\n return {\n requested: false,\n commandPathTokens: [],\n };\n }\n\n const commandPathTokens: string[] = [];\n for (const token of stripped) {\n if (token.startsWith(\"-\")) {\n break;\n }\n commandPathTokens.push(token.trim().toLowerCase());\n }\n return {\n requested: true,\n commandPathTokens,\n };\n}\n\n/**\n * Index of the command token in argv — the first non-flag token, skipping the\n * value-consuming/global bootstrap flags. Returns undefined when there is none\n * (bare invocation, only global flags, or a leading `--`). Single source of truth\n * for command-position scanning shared by {@link parseBootstrapCommandName} and the\n * command-alias rewrite so their precedence rules can never drift apart.\n */\nfunction findCommandTokenIndex(argv: string[]): number | undefined {\n for (let index = 0; index < argv.length; index += 1) {\n const token = argv[index];\n if (token === \"--\") {\n return undefined;\n }\n if (token === \"--path\" || token === \"--pm-path\") {\n index += 1;\n continue;\n }\n if (\n token.startsWith(\"--path=\") ||\n token.startsWith(\"--pm-path=\") ||\n token === \"--json\" ||\n token === \"--quiet\" ||\n token === \"--no-extensions\" ||\n token === \"--no-pager\" ||\n token === \"--profile\" ||\n token === \"--id-only\" ||\n token === \"--explain\"\n ) {\n continue;\n }\n if (token.startsWith(\"-\")) {\n continue;\n }\n return index;\n }\n return undefined;\n}\n\n/**\n * Implements parse bootstrap command name for the public runtime surface of this module.\n */\nexport function parseBootstrapCommandName(argv: string[]): string | undefined {\n const index = findCommandTokenIndex(argv);\n return index === undefined ? undefined : argv[index].trim().toLowerCase();\n}\n\nfunction shouldDisablePagerForInvocation(argv: string[], bootstrapGlobal: BootstrapGlobalOptions): boolean {\n if (bootstrapGlobal.noPager) {\n return true;\n }\n if (process.stdout.isTTY === true) {\n return false;\n }\n const helpRequest = parseBootstrapHelpRequest(argv);\n return helpRequest.requested;\n}\n\n/**\n * Implements apply bootstrap pager policy for the public runtime surface of this module.\n */\nexport function applyBootstrapPagerPolicy(argv: string[]): void {\n const bootstrapGlobal = parseBootstrapGlobalOptions(argv);\n if (!shouldDisablePagerForInvocation(argv, bootstrapGlobal)) {\n return;\n }\n process.env.PAGER = \"cat\";\n process.env.MANPAGER = \"cat\";\n process.env.GIT_PAGER = \"cat\";\n if (typeof process.env.LESS !== \"string\" || process.env.LESS.trim().length === 0) {\n process.env.LESS = \"FRX\";\n }\n}\n\ntype ExtensionSubcommandAction =\n | \"init\"\n | \"install\"\n | \"uninstall\"\n | \"explore\"\n | \"manage\"\n | \"doctor\"\n | \"adopt\"\n | \"adopt-all\"\n | \"activate\"\n | \"deactivate\";\n\nconst EXTENSION_ACTION_SYNTAX_TOKENS = new Set<ExtensionSubcommandAction>([\n \"install\",\n \"uninstall\",\n \"explore\",\n \"manage\",\n \"doctor\",\n \"adopt\",\n \"adopt-all\",\n \"activate\",\n \"deactivate\",\n]);\n\n/**\n * Implements normalize legacy extension action syntax for the public runtime surface of this module.\n */\nexport function normalizeLegacyExtensionActionSyntax(argv: string[]): string[] {\n const extensionIndex = argv.findIndex((token) => token === \"extension\");\n if (extensionIndex < 0) {\n return [...argv];\n }\n const actionToken = argv[extensionIndex + 1];\n if (!actionToken || actionToken.startsWith(\"-\")) {\n return [...argv];\n }\n if (!EXTENSION_ACTION_SYNTAX_TOKENS.has(actionToken as ExtensionSubcommandAction)) {\n return [...argv];\n }\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return [...argv];\n }\n const forcedActionFlag = `--${actionToken}`;\n if (argv.includes(forcedActionFlag)) {\n return [...argv];\n }\n return [...argv.slice(0, extensionIndex + 1), forcedActionFlag, ...argv.slice(extensionIndex + 2)];\n}\n\ntype BootstrapNormalizationReason =\n | \"legacy_extension_action\"\n | \"command_alias\"\n | \"flag_alias\"\n | \"flag_typo\"\n | \"bare_key_value\"\n | \"list_merge\";\ntype BootstrapNormalizationConfidence = \"high\" | \"medium\";\n\n/**\n * Executable command aliases: a leading command token here is rewritten to its\n * canonical command BEFORE commander parses, so the alias actually runs instead of\n * merely being suggested. These are the highest-frequency aliases real agents type\n * (telemetry: `pm show <id>` alone is the single most common unknown-command) and\n * each target takes the same positional/flags as the alias (with `--comment`/\n * `--note`/`--learning` flag-aliased to `--add` on the target command). Keeping this\n * in one place means the alias is consistent across registration, commander dispatch,\n * telemetry, and error handling — all of which read the normalized argv.\n */\nexport const EXECUTABLE_COMMAND_ALIASES: Readonly<Record<string, string>> = {\n show: \"get\",\n view: \"get\",\n comment: \"comments\",\n note: \"notes\",\n learning: \"learnings\",\n};\n\n/**\n * Rewrite a leading command-alias token (e.g. `show` -> `get`) in place. Only the\n * command position is considered — the same token appearing later as an argument\n * (`pm get show`) is left untouched — and only when it is not preceded by `--` or a\n * value-consuming global flag, mirroring {@link parseBootstrapCommandName}.\n */\nfunction rewriteCommandAlias(argv: string[], trace: BootstrapNormalizationEvent[]): string[] {\n const index = findCommandTokenIndex(argv);\n if (index === undefined) {\n return argv;\n }\n const token = argv[index];\n const canonical = EXECUTABLE_COMMAND_ALIASES[token.trim().toLowerCase()];\n if (!canonical) {\n return argv;\n }\n const rewritten = [...argv];\n rewritten[index] = canonical;\n trace.push({ from: token, to: [canonical], reason: \"command_alias\", confidence: \"high\" });\n return rewritten;\n}\n\n/**\n * Documents the bootstrap normalization event payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapNormalizationEvent {\n from: string;\n to: string[];\n reason: BootstrapNormalizationReason;\n confidence: BootstrapNormalizationConfidence;\n}\n\n/**\n * Documents the bootstrap invocation normalization result payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapInvocationNormalizationResult {\n argv: string[];\n commandName: string | undefined;\n trace: BootstrapNormalizationEvent[];\n}\n\ninterface FlagLookup {\n canonicalByNormalized: Map<string, string | null>;\n canonicalByCompact: Map<string, string | null>;\n canonicalComparables: Array<{ canonicalFlag: string; comparable: string }>;\n listCanonicalFlags: Set<string>;\n}\n\nfunction normalizeFlagKeyToken(raw: string): string {\n const withoutPrefix = raw.replace(/^--?/, \"\");\n return withoutPrefix\n .replace(/_/g, \"-\")\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .toLowerCase();\n}\n\nfunction toComparableFlagKey(raw: string): string {\n return normalizeFlagKeyToken(raw).replace(/-/g, \"\");\n}\n\nfunction markUnambiguousFlag(\n map: Map<string, string | null>,\n key: string,\n canonicalFlag: string,\n): void {\n const existing = map.get(key);\n if (existing === undefined) {\n map.set(key, canonicalFlag);\n return;\n }\n if (existing !== canonicalFlag) {\n map.set(key, null);\n }\n}\n\nfunction collectLongFlagCandidates(contract: CliFlagContract): string[] {\n const candidates: string[] = [];\n const pushLongFlag = (value: string | undefined): void => {\n if (typeof value !== \"string\") {\n return;\n }\n if (!value.startsWith(\"--\")) {\n return;\n }\n candidates.push(value);\n };\n pushLongFlag(contract.flag);\n for (const alias of contract.aliases ?? []) {\n pushLongFlag(alias);\n }\n return candidates;\n}\n\nfunction buildFlagLookup(\n commandName: string | undefined,\n contractsOverride?: CliFlagContract[],\n): FlagLookup {\n const contracts = contractsOverride ?? resolveSubcommandFlagContractsForCommand(commandName);\n const canonicalByNormalized = new Map<string, string | null>();\n const canonicalByCompact = new Map<string, string | null>();\n const canonicalComparablesMap = new Map<string, string>();\n const listCanonicalFlags = new Set<string>();\n for (const contract of contracts) {\n const longCandidates = collectLongFlagCandidates(contract);\n if (longCandidates.length === 0) {\n continue;\n }\n const canonicalFlag = `--${normalizeFlagKeyToken(longCandidates[0])}`;\n for (const candidate of longCandidates) {\n markUnambiguousFlag(canonicalByNormalized, normalizeFlagKeyToken(candidate), canonicalFlag);\n markUnambiguousFlag(canonicalByCompact, toComparableFlagKey(candidate), canonicalFlag);\n }\n const comparable = toComparableFlagKey(canonicalFlag);\n if (!canonicalComparablesMap.has(canonicalFlag)) {\n canonicalComparablesMap.set(canonicalFlag, comparable);\n }\n if (contract.list === true) {\n listCanonicalFlags.add(canonicalFlag);\n }\n }\n return {\n canonicalByNormalized,\n canonicalByCompact,\n canonicalComparables: [...canonicalComparablesMap.entries()].map(([canonicalFlag, comparable]) => ({\n canonicalFlag,\n comparable,\n })),\n listCanonicalFlags,\n };\n}\n\nfunction resolveCanonicalFlag(\n rawKey: string,\n lookup: FlagLookup,\n): { flag: string; reason: \"flag_alias\" | \"flag_typo\"; confidence: BootstrapNormalizationConfidence } | null {\n const normalizedKey = normalizeFlagKeyToken(rawKey);\n const direct = lookup.canonicalByNormalized.get(normalizedKey);\n if (typeof direct === \"string\") {\n return {\n flag: direct,\n reason: \"flag_alias\",\n confidence: \"high\",\n };\n }\n const comparableKey = normalizedKey.replace(/-/g, \"\");\n const compactMatch = lookup.canonicalByCompact.get(comparableKey);\n if (typeof compactMatch === \"string\") {\n return {\n flag: compactMatch,\n reason: \"flag_alias\",\n confidence: \"high\",\n };\n }\n const maxDistance = comparableKey.length >= 8 ? 2 : 1;\n let bestDistance = Number.POSITIVE_INFINITY;\n let bestFlag: string | undefined;\n let tied = false;\n for (const candidate of lookup.canonicalComparables) {\n const distance = levenshteinDistanceWithinLimit(comparableKey, candidate.comparable, maxDistance);\n if (distance === null) {\n continue;\n }\n if (distance < bestDistance) {\n bestDistance = distance;\n bestFlag = candidate.canonicalFlag;\n tied = false;\n continue;\n }\n if (distance === bestDistance && bestFlag !== candidate.canonicalFlag) {\n tied = true;\n }\n }\n if (!bestFlag || tied || !Number.isFinite(bestDistance) || bestDistance <= 0) {\n return null;\n }\n return {\n flag: bestFlag,\n reason: \"flag_typo\",\n confidence: bestDistance >= 2 ? \"medium\" : \"high\",\n };\n}\n\n/**\n * Implements list alias plural keys for the public runtime surface of this module.\n */\nexport function listAliasPluralKeys(normalizedKey: string): string[] {\n const candidates = [`${normalizedKey}s`];\n if (normalizedKey.endsWith(\"y\") && normalizedKey.length > 1) {\n candidates.push(`${normalizedKey.slice(0, -1)}ies`);\n }\n return candidates;\n}\n\nfunction parseBareKeyValueToken(token: string): { key: string; value: string } | null {\n if (token.includes(\"://\")) {\n return null;\n }\n const match = token.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);\n if (!match) {\n return null;\n }\n const key = match[1];\n const value = match[3];\n if (value.length === 0) {\n return null;\n }\n return {\n key,\n value,\n };\n}\n\nfunction normalizeLongOptionToken(\n token: string,\n lookup: FlagLookup,\n): { tokens: string[]; event?: BootstrapNormalizationEvent } {\n if (!token.startsWith(\"--\")) {\n return { tokens: [token] };\n }\n const equalsIndex = token.indexOf(\"=\");\n const key = equalsIndex >= 0 ? token.slice(0, equalsIndex) : token;\n const inlineValue = equalsIndex >= 0 ? token.slice(equalsIndex + 1) : undefined;\n const resolution = resolveCanonicalFlag(key, lookup);\n if (!resolution) {\n return { tokens: [token] };\n }\n const normalizedToken = inlineValue === undefined ? resolution.flag : `${resolution.flag}=${inlineValue}`;\n if (normalizedToken === token) {\n return { tokens: [token] };\n }\n return {\n tokens: [normalizedToken],\n event: {\n from: token,\n to: [normalizedToken],\n reason: resolution.reason,\n confidence: resolution.confidence,\n },\n };\n}\n\n// Global option flags whose value may legitimately begin with \"--\" (commander\n// accepts such values). Their value token must not be reinterpreted as a list\n// flag during coalescing. `--pm-path <dir>` and its legacy `--path <dir>`\n// alias are the documented cases; other globals\n// (--json/--quiet/--no-extensions/--no-pager/--profile) are boolean.\nconst GLOBAL_VALUE_CONSUMING_FLAGS = new Set<string>([\"--pm-path\", \"--path\"]);\n\nfunction splitCanonicalListToken(token: string): { flag: string; inlineValue?: string } | null {\n if (!token.startsWith(\"--\")) {\n return null;\n }\n const equalsIndex = token.indexOf(\"=\");\n if (equalsIndex < 0) {\n return { flag: token };\n }\n return {\n flag: token.slice(0, equalsIndex),\n inlineValue: token.slice(equalsIndex + 1),\n };\n}\n\ninterface ListFlagSlot {\n outputIndex: number;\n originalTokens: string[];\n values: string[];\n occurrences: number;\n}\n\ninterface ListFlagOccurrence {\n originalTokens: string[];\n value: string | undefined;\n consumed: number;\n}\n\ninterface ValuedListFlagOccurrence {\n originalTokens: string[];\n value: string;\n}\n\nfunction copyValueConsumingFlag(argv: string[], index: number, result: (string | null)[]): number {\n result.push(argv[index]);\n const next = argv[index + 1];\n if (typeof next === \"string\" && next !== \"--\") {\n result.push(next);\n return index + 2;\n }\n return index + 1;\n}\n\nfunction readListFlagOccurrence(\n argv: string[],\n index: number,\n parsed: { flag: string; inlineValue?: string },\n multiValueListFlags: Set<string>,\n): ListFlagOccurrence {\n if (parsed.inlineValue !== undefined) {\n return {\n originalTokens: [argv[index]],\n value: parsed.inlineValue,\n consumed: 1,\n };\n }\n\n const values: string[] = [];\n let valueIndex = index + 1;\n while (\n valueIndex < argv.length &&\n argv[valueIndex] !== \"--\" &&\n !argv[valueIndex].startsWith(\"-\") &&\n (values.length === 0 || multiValueListFlags.has(parsed.flag))\n ) {\n values.push(argv[valueIndex]);\n valueIndex += 1;\n }\n\n const consumed = values.length === 0 ? 1 : 1 + values.length;\n return {\n originalTokens: argv.slice(index, index + consumed),\n value: values.length === 0 ? undefined : values.join(\",\"),\n consumed,\n };\n}\n\nfunction recordListFlagOccurrence(\n slots: Map<string, ListFlagSlot>,\n result: (string | null)[],\n flag: string,\n occurrence: ValuedListFlagOccurrence,\n): void {\n const existing = slots.get(flag);\n if (existing) {\n existing.values.push(occurrence.value);\n existing.occurrences += 1;\n return;\n }\n\n slots.set(flag, {\n outputIndex: result.length,\n originalTokens: occurrence.originalTokens,\n values: [occurrence.value],\n occurrences: 1,\n });\n // Reserve the anchor position; finalized after the walk so we know the full\n // merged value or can restore the original token form for single uses.\n result.push(null);\n}\n\nfunction buildListFlagCoalescingSplices(\n slots: Map<string, ListFlagSlot>,\n multiValueListFlags: Set<string>,\n): {\n events: BootstrapNormalizationEvent[];\n splices: Array<{ outputIndex: number; tokens: string[] }>;\n} {\n const events: BootstrapNormalizationEvent[] = [];\n const splices: Array<{ outputIndex: number; tokens: string[] }> = [];\n for (const [flag, slot] of slots) {\n const shouldMerge = slot.occurrences >= 2 || (multiValueListFlags.has(flag) && slot.originalTokens.length > 2);\n if (!shouldMerge) {\n splices.push({ outputIndex: slot.outputIndex, tokens: slot.originalTokens });\n continue;\n }\n const mergedToken = `${flag}=${slot.values.join(\",\")}`;\n splices.push({ outputIndex: slot.outputIndex, tokens: [mergedToken] });\n events.push({\n from: `${flag} (x${slot.occurrences})`,\n to: [mergedToken],\n reason: \"list_merge\",\n confidence: \"high\",\n });\n }\n return { events, splices };\n}\n\nfunction applyListFlagSplices(result: (string | null)[], splices: Array<{ outputIndex: number; tokens: string[] }>): void {\n splices.sort((a, b) => b.outputIndex - a.outputIndex);\n for (const splice of splices) {\n result.splice(splice.outputIndex, 1, ...splice.tokens);\n }\n}\n\n/**\n * Coalesce repeated occurrences of comma-separated list flags into a single\n * `--flag=v1,v2,v3` token anchored at the FIRST occurrence. Without this,\n * Commander treats these flags as scalars and silently keeps only the last\n * value (data loss). Both `--flag value` and `--flag=value` forms are merged;\n * a value-less occurrence is preserved untouched, and a `--` terminator stops\n * coalescing (remainder is passed through verbatim).\n *\n * `valueConsumingFlags` lists option flags (e.g. global `--path`) whose value\n * may itself begin with `--`. Their value token is emitted verbatim so a\n * list-flag-looking value (`--path --tags`) is never reinterpreted as a flag\n * nor allowed to swallow the following command/positional token.\n */\nexport function coalesceRepeatedListFlags(\n argv: string[],\n listFlags: Set<string>,\n valueConsumingFlags: Set<string> = new Set(),\n multiValueListFlags: Set<string> = new Set(),\n): { argv: string[]; events: BootstrapNormalizationEvent[] } {\n if (listFlags.size === 0) {\n return { argv: [...argv], events: [] };\n }\n\n const result: (string | null)[] = [];\n const slots = new Map<string, ListFlagSlot>();\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n result.push(...argv.slice(index));\n break;\n }\n // A value-consuming option in space form owns the next token as its value,\n // even when that value begins with \"--\". Emit both verbatim so the value is\n // never misread as a list-flag occurrence.\n if (valueConsumingFlags.has(token)) {\n index = copyValueConsumingFlag(argv, index, result);\n continue;\n }\n const parsed = splitCanonicalListToken(token);\n if (!parsed || !listFlags.has(parsed.flag)) {\n result.push(token);\n index += 1;\n continue;\n }\n\n const occurrence = readListFlagOccurrence(argv, index, parsed, multiValueListFlags);\n if (occurrence.value === undefined) {\n // Value-less occurrence: leave untouched, do not coalesce.\n result.push(token);\n index += occurrence.consumed;\n continue;\n }\n\n recordListFlagOccurrence(slots, result, parsed.flag, {\n originalTokens: occurrence.originalTokens,\n value: occurrence.value,\n });\n index += occurrence.consumed;\n }\n\n // Apply anchor splices from the end so earlier indices stay valid when a\n // single-occurrence anchor expands back into two tokens.\n const { events, splices } = buildListFlagCoalescingSplices(slots, multiValueListFlags);\n applyListFlagSplices(result, splices);\n\n return { argv: result as string[], events };\n}\n\n/**\n * Linked-test entry keys accepted in the two-token form `pm test <id> --add command\n * \"npm test -- parser\"` (GH-191). Only entry-identity keys are merged: `command`/`cmd`\n * name the shell command and `path` names the test file, so a single key=value entry is\n * meaningful for them. Other structured keys (scope, env_set, assertions, ...) cannot\n * form a valid standalone entry and are left for the normal parser to reject. `--remove`\n * matches existing entries by `command=`/`path=` only, so `cmd` is excluded there.\n * Key names mirror STRUCTURED_LINKED_TEST_KEYS in src/cli/commands/linked-test-entry.ts.\n */\nconst LINKED_TEST_TWO_TOKEN_KEYS_BY_FLAG: ReadonlyMap<string, ReadonlySet<string>> = new Map([\n [\"--add\", new Set([\"command\", \"cmd\", \"path\"])],\n [\"--remove\", new Set([\"command\", \"path\"])],\n]);\n\n/**\n * Sandbox-safe linked-test commands legitimately start with env assignments\n * (`PM_PATH=... PM_GLOBAL_PATH=... vitest run -- parser`), which look like bare\n * key=value settings tokens. When the two preceding tokens are a linked-test\n * flag plus a bare two-token key (`--add command <value>`), the value must be\n * left intact for mergeLinkedTestTwoTokenEntries instead of being rewritten\n * into a canonical flag (e.g. PM_PATH= -> --pm-path), which would silently\n * corrupt the command into `--add command --pm-path ...`.\n */\nfunction isLinkedTestTwoTokenValuePosition(commandName: string | undefined, emittedTokens: readonly string[]): boolean {\n if (commandName !== \"test\" || emittedTokens.length < 2) {\n return false;\n }\n const key = emittedTokens[emittedTokens.length - 1];\n const flag = emittedTokens[emittedTokens.length - 2];\n const keys = LINKED_TEST_TWO_TOKEN_KEYS_BY_FLAG.get(flag);\n return keys !== undefined && keys.has(key);\n}\n\n/**\n * Accept the two-token linked-test form `pm test <id> --add command \"npm test -- parser\"`\n * by merging the bare key token and its single quoted value into the documented\n * `--add command=...` shape. Without this merge Commander binds the bare key as the\n * option value and treats the quoted command as an excess positional, failing with\n * \"too many arguments\" (GH-191). The merge only fires when EXACTLY ONE non-flag token\n * follows the bare key, i.e. the value was quoted into one shell token — an unquoted\n * multi-token value stays ambiguous (it may swallow the item id), still fails fast, and\n * is routed to targeted quoting guidance by the commander error classifier instead.\n */\nexport function mergeLinkedTestTwoTokenEntries(\n argv: string[],\n commandName: string | undefined,\n trace: BootstrapNormalizationEvent[],\n): string[] {\n if (commandName !== \"test\") {\n return argv;\n }\n const result: string[] = [];\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n result.push(...argv.slice(index));\n return result;\n }\n const keys = LINKED_TEST_TWO_TOKEN_KEYS_BY_FLAG.get(token);\n const key = keys ? argv[index + 1] : undefined;\n if (!keys || typeof key !== \"string\" || !keys.has(key)) {\n result.push(token);\n index += 1;\n continue;\n }\n let runEnd = index + 2;\n while (runEnd < argv.length && !argv[runEnd].startsWith(\"-\")) {\n runEnd += 1;\n }\n if (runEnd - (index + 2) !== 1) {\n result.push(token);\n index += 1;\n continue;\n }\n const value = argv[index + 2];\n const mergedValue = `${key}=${value}`;\n result.push(token, mergedValue);\n trace.push({\n from: `${token} ${key} ${value}`,\n to: [token, mergedValue],\n reason: \"bare_key_value\",\n confidence: \"high\",\n });\n index += 3;\n }\n return result;\n}\n\n/**\n * Implements normalize bootstrap invocation for the public runtime surface of this module.\n */\nexport function normalizeBootstrapInvocation(argv: string[]): BootstrapInvocationNormalizationResult {\n const trace: BootstrapNormalizationEvent[] = [];\n const legacyNormalized = normalizeLegacyExtensionActionSyntax(argv);\n if (legacyNormalized.length !== argv.length || legacyNormalized.some((token, index) => token !== argv[index])) {\n trace.push({\n from: argv.join(\" \"),\n to: [...legacyNormalized],\n reason: \"legacy_extension_action\",\n confidence: \"high\",\n });\n }\n const aliasNormalized = rewriteCommandAlias(legacyNormalized, trace);\n const commandName = parseBootstrapCommandName(aliasNormalized);\n const commandPathName = parseBootstrapCommandPathName(aliasNormalized);\n const lookup = buildFlagLookup(commandPathName ?? commandName);\n const normalizedArgv: string[] = [];\n for (let index = 0; index < aliasNormalized.length; index += 1) {\n const token = aliasNormalized[index];\n if (token === \"--\") {\n normalizedArgv.push(...aliasNormalized.slice(index));\n break;\n }\n const previous = normalizedArgv[normalizedArgv.length - 1];\n if (token.startsWith(\"--\")) {\n const normalizedToken = normalizeLongOptionToken(token, lookup);\n normalizedArgv.push(...normalizedToken.tokens);\n if (normalizedToken.event) {\n trace.push(normalizedToken.event);\n }\n continue;\n }\n const bareKeyValue = parseBareKeyValueToken(token);\n if (\n bareKeyValue &&\n !(typeof previous === \"string\" && previous.startsWith(\"-\")) &&\n !isLinkedTestTwoTokenValuePosition(commandName, normalizedArgv)\n ) {\n const resolution = resolveCanonicalFlag(bareKeyValue.key, lookup);\n if (resolution) {\n const replacement = [resolution.flag, bareKeyValue.value];\n normalizedArgv.push(...replacement);\n trace.push({\n from: token,\n to: replacement,\n reason: \"bare_key_value\",\n confidence: resolution.confidence,\n });\n continue;\n }\n }\n normalizedArgv.push(token);\n }\n const linkedTestNormalized = mergeLinkedTestTwoTokenEntries(normalizedArgv, commandName, trace);\n const coalesced = coalesceRepeatedListFlags(\n linkedTestNormalized,\n lookup.listCanonicalFlags,\n GLOBAL_VALUE_CONSUMING_FLAGS,\n commandName === \"create\" ? new Set([\"--tags\"]) : new Set(),\n );\n for (const event of coalesced.events) {\n trace.push(event);\n }\n return {\n argv: coalesced.argv,\n commandName,\n trace,\n };\n}\n\nfunction parseBootstrapCommandPathName(argv: string[]): string | undefined {\n const stripped = stripGlobalBootstrapTokens(argv);\n const first = stripped[0]?.trim().toLowerCase();\n const second = stripped[1]?.trim().toLowerCase();\n if (\n (first === \"extension\" || first === \"package\" || first === \"packages\") &&\n typeof second === \"string\" &&\n second.length > 0 &&\n !second.startsWith(\"-\")\n ) {\n return `${first} ${second}`;\n }\n return first;\n}\n\n/**\n * Implements parse bootstrap type value for the public runtime surface of this module.\n */\nexport function parseBootstrapTypeValue(argv: string[]): string | undefined {\n for (let index = 0; index < argv.length; index += 1) {\n const token = argv[index];\n if (token === \"--type\") {\n const candidate = argv[index + 1];\n if (typeof candidate === \"string\" && candidate.trim().length > 0) {\n return candidate.trim();\n }\n continue;\n }\n if (token.startsWith(\"--type=\")) {\n const candidate = token.slice(\"--type=\".length).trim();\n if (candidate.length > 0) {\n return candidate;\n }\n }\n }\n return undefined;\n}\n\nexport const _testOnly = {\n buildFlagLookup,\n collectLongFlagCandidates,\n markUnambiguousFlag,\n normalizeLongOptionToken,\n resolveCanonicalFlag,\n};\n", "/**\n * @module cli/commands/extension/shared\n *\n * Implements extension package-management support for Shared.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathExists } from \"../../../core/fs/fs-utils.js\";\nimport { isPathWithinDirectory } from \"../../../core/fs/path-utils.js\";\nimport { EXIT_CODE } from \"../../../core/shared/constants.js\";\nimport { PmCliError } from \"../../../core/shared/errors.js\";\nimport type { ExtensionManifest } from \"../../../core/extensions/loader.js\";\n\nexport const DEFAULT_EXTENSION_PRIORITY = 100;\n\n/**\n * Documents the validated extension directory payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidatedExtensionDirectory {\n directory: string;\n manifest_path: string;\n entry_path: string;\n manifest: ExtensionManifest;\n}\n\n/**\n * Implements normalize string list for the public runtime surface of this module.\n */\nexport function normalizeStringList(values: readonly string[]): string[] {\n return [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((left, right) =>\n left.localeCompare(right),\n );\n}\n\n/**\n * Implements normalize extension name for match for the public runtime surface of this module.\n */\nexport function normalizeExtensionNameForMatch(value: string): string {\n return value.trim().toLowerCase();\n}\n\n/**\n * Implements normalize managed directory name for the public runtime surface of this module.\n */\nexport function normalizeManagedDirectoryName(name: string): string {\n const normalized = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (normalized.length === 0) {\n throw new PmCliError(\"Extension manifest name must resolve to a non-empty directory name.\", EXIT_CODE.USAGE);\n }\n if (normalized === \".\" || normalized === \"..\") {\n // Manifest-controlled input must resolve to a dedicated child directory, never\n // the extensions root itself or its parent (path-traversal guard).\n throw new PmCliError(\"Extension manifest name must not resolve to \\\".\\\" or \\\"..\\\".\", EXIT_CODE.USAGE);\n }\n return normalized;\n}\n\n/**\n * Implements parse extension manifest for the public runtime surface of this module.\n */\nexport function parseExtensionManifest(raw: unknown): ExtensionManifest | null {\n if (typeof raw !== \"object\" || raw === null) {\n return null;\n }\n const candidate = raw as Record<string, unknown>;\n if (typeof candidate.name !== \"string\" || candidate.name.trim().length === 0) {\n return null;\n }\n if (typeof candidate.version !== \"string\" || candidate.version.trim().length === 0) {\n return null;\n }\n if (typeof candidate.entry !== \"string\" || candidate.entry.trim().length === 0) {\n return null;\n }\n\n let priority = DEFAULT_EXTENSION_PRIORITY;\n if (candidate.priority !== undefined && candidate.priority !== null) {\n if (typeof candidate.priority !== \"number\" || !Number.isInteger(candidate.priority)) {\n return null;\n }\n priority = candidate.priority;\n }\n\n let capabilities: string[] = [];\n if (candidate.capabilities !== undefined && candidate.capabilities !== null) {\n if (!Array.isArray(candidate.capabilities) || candidate.capabilities.some((value) => typeof value !== \"string\")) {\n return null;\n }\n capabilities = normalizeStringList(candidate.capabilities.map((value) => String(value).toLowerCase()));\n }\n\n return {\n name: candidate.name.trim(),\n version: candidate.version.trim(),\n entry: candidate.entry.trim(),\n priority,\n capabilities,\n };\n}\n\n/**\n * Implements check whether canonical path within directory for the public runtime surface of this module.\n */\nexport async function isCanonicalPathWithinDirectory(directory: string, targetPath: string): Promise<boolean> {\n const [resolvedDirectory, resolvedTargetPath] = await Promise.all([fs.realpath(directory), fs.realpath(targetPath)]);\n return isPathWithinDirectory(resolvedDirectory, resolvedTargetPath);\n}\n\n/**\n * Implements validate extension directory for the public runtime surface of this module.\n */\nexport async function validateExtensionDirectory(directory: string): Promise<ValidatedExtensionDirectory> {\n const manifestPath = path.join(directory, \"manifest.json\");\n if (!(await pathExists(manifestPath))) {\n throw new PmCliError(`Extension manifest is missing at \"${manifestPath}\".`, EXIT_CODE.USAGE);\n }\n\n let parsedManifest: unknown;\n try {\n parsedManifest = JSON.parse(await fs.readFile(manifestPath, \"utf8\")) as unknown;\n } catch (error: unknown) {\n throw new PmCliError(\n `Failed to parse extension manifest at \"${manifestPath}\": ${formatManifestReadError(error)}`,\n EXIT_CODE.USAGE,\n );\n }\n\n const manifest = parseExtensionManifest(parsedManifest);\n if (!manifest) {\n throw new PmCliError(`Extension manifest at \"${manifestPath}\" is invalid.`, EXIT_CODE.USAGE);\n }\n\n const entryPath = path.resolve(directory, manifest.entry);\n if (!isPathWithinDirectory(directory, entryPath)) {\n throw new PmCliError(\n `Extension entry \"${manifest.entry}\" resolves outside extension directory \"${directory}\".`,\n EXIT_CODE.USAGE,\n );\n }\n if (!(await pathExists(entryPath))) {\n throw new PmCliError(`Extension entry file is missing at \"${entryPath}\".`, EXIT_CODE.USAGE);\n }\n if (!(await isCanonicalPathWithinDirectory(directory, entryPath))) {\n throw new PmCliError(\n `Extension entry \"${manifest.entry}\" resolves outside extension directory after symlink resolution.`,\n EXIT_CODE.USAGE,\n );\n }\n\n return {\n directory,\n manifest_path: manifestPath,\n entry_path: entryPath,\n manifest,\n };\n}\n\nfunction formatManifestReadError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport const _testOnlyExtensionShared = {\n formatManifestReadError,\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAQA,SAAS,wBACP,OACA,MAAwB;AAExB,MAAI,UAAU,YAAY,UAAU,aAAa;AAC/C,QAAI,OAAO,SAAS,YAAY,KAAK,SAAS,GAAG;AAC/C,aAAO;QACL,UAAU;QACV,WAAW;QACX,WAAW,UAAU;;IAEzB;AACA,WAAO;MACL,UAAU;MACV,WAAW,UAAU;;EAEzB;AAEA,QAAM,eAAe,MAAM,WAAW,SAAS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;EAEnB;AAEA,QAAM,WAAW,uBAAuB,cAAc;AACtD,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,WAAW,0BAA0B,YAAY,iBAAiB,UAAU,KAAK;EAC7F;AAEA,QAAM,YAAY,KAAK,QAAQ,WAAW,SAAS,KAAK;AACxD,MAAI,CAAC,sBAAsB,WAAW,SAAS,GAAG;AAChD,UAAM,IAAI,WACR,oBAAoB,SAAS,KAAK,2CAA2C,SAAS,MACtF,UAAU,KAAK;EAEnB;AACA,MAAI,CAAE,MAAM,WAAW,SAAS,GAAI;AAClC,UAAM,IAAI,WAAW,uCAAuC,SAAS,MAAM,UAAU,KAAK;EAC5F;AACA,MAAI,CAAE,MAAM,+BAA+B,WAAW,SAAS,GAAI;AACjE,UAAM,IAAI,WACR,oBAAoB,SAAS,KAAK,oEAClC,UAAU,KAAK;EAEnB;AAEA,SAAO;IACL;IACA,eAAe;IACf,YAAY;IACZ;;AAEJ;AAEA,SAAS,wBAAwB,OAAc;AAC7C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;",
4
+ "sourcesContent": ["/**\n * @module cli/bootstrap-args\n *\n * Provides CLI runtime support for Bootstrap Args.\n */\nimport { resolveSubcommandFlagContractsForCommand, type CliFlagContract } from \"../sdk/cli-contracts.js\";\nimport { levenshteinDistanceWithinLimit } from \"../core/shared/levenshtein.js\";\n\nfunction parseBootstrapPathToken(\n token: string,\n next: string | undefined,\n): { consumed: number; pathValue?: string; preferred: boolean } | null {\n if (token === \"--path\" || token === \"--pm-path\") {\n if (typeof next === \"string\" && next.length > 0) {\n return {\n consumed: 2,\n pathValue: next,\n preferred: token === \"--pm-path\",\n };\n }\n return {\n consumed: 1,\n preferred: token === \"--pm-path\",\n };\n }\n\n const inlinePrefix = token.startsWith(\"--path=\")\n ? \"--path=\"\n : token.startsWith(\"--pm-path=\")\n ? \"--pm-path=\"\n : undefined;\n if (!inlinePrefix) {\n return null;\n }\n\n const value = token.slice(inlinePrefix.length);\n if (value.length > 0) {\n return {\n consumed: 1,\n pathValue: value,\n preferred: inlinePrefix === \"--pm-path=\",\n };\n }\n return {\n consumed: 1,\n preferred: inlinePrefix === \"--pm-path=\",\n };\n}\n\n/**\n * Documents the bootstrap global options payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapGlobalOptions {\n path?: string;\n noExtensions: boolean;\n noPager: boolean;\n json: boolean;\n quiet: boolean;\n}\n\n/**\n * Implements parse bootstrap global options for the public runtime surface of this module.\n */\nexport function parseBootstrapGlobalOptions(argv: string[]): BootstrapGlobalOptions {\n let legacyPathValue: string | undefined;\n let pmPathValue: string | undefined;\n let noExtensions = false;\n let noPager = false;\n let json = false;\n let quiet = false;\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n break;\n }\n if (token === \"--no-extensions\") {\n noExtensions = true;\n index += 1;\n continue;\n }\n if (token === \"--no-pager\") {\n noPager = true;\n index += 1;\n continue;\n }\n if (token === \"--json\") {\n json = true;\n index += 1;\n continue;\n }\n if (token === \"--quiet\") {\n quiet = true;\n index += 1;\n continue;\n }\n const parsedPath = parseBootstrapPathToken(token, argv[index + 1]);\n if (parsedPath) {\n if (parsedPath.pathValue !== undefined) {\n if (parsedPath.preferred) {\n pmPathValue = parsedPath.pathValue;\n } else {\n legacyPathValue = parsedPath.pathValue;\n }\n }\n index += parsedPath.consumed;\n continue;\n }\n index += 1;\n }\n return {\n path: pmPathValue ?? legacyPathValue,\n noExtensions,\n noPager,\n json,\n quiet,\n };\n}\n\n/**\n * Implements strip global bootstrap tokens for the public runtime surface of this module.\n */\nexport function stripGlobalBootstrapTokens(argv: string[]): string[] {\n const remaining: string[] = [];\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n break;\n }\n if (\n token === \"--json\" ||\n token === \"--quiet\" ||\n token === \"--no-extensions\" ||\n token === \"--no-pager\" ||\n token === \"--profile\" ||\n token === \"--id-only\" ||\n token === \"--explain\"\n ) {\n index += 1;\n continue;\n }\n if (token === \"--path\" || token === \"--pm-path\") {\n index += 2;\n continue;\n }\n if (token.startsWith(\"--path=\") || token.startsWith(\"--pm-path=\")) {\n index += 1;\n continue;\n }\n remaining.push(token);\n index += 1;\n }\n return remaining;\n}\n\n/**\n * Documents the bootstrap help request payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapHelpRequest {\n requested: boolean;\n commandPathTokens: string[];\n}\n\n/**\n * Implements parse bootstrap help request for the public runtime surface of this module.\n */\nexport function parseBootstrapHelpRequest(argv: string[]): BootstrapHelpRequest {\n const stripped = stripGlobalBootstrapTokens(argv);\n const first = stripped[0]?.trim().toLowerCase();\n if (first === \"help\") {\n const commandPathTokens: string[] = [];\n for (let index = 1; index < stripped.length; index += 1) {\n const token = stripped[index];\n if (token.startsWith(\"-\")) {\n break;\n }\n commandPathTokens.push(token.trim().toLowerCase());\n }\n return {\n requested: true,\n commandPathTokens,\n };\n }\n\n const helpFlagIndex = stripped.findIndex((token) => token === \"--help\" || token === \"-h\");\n if (helpFlagIndex < 0) {\n return {\n requested: false,\n commandPathTokens: [],\n };\n }\n\n const commandPathTokens: string[] = [];\n for (const token of stripped) {\n if (token.startsWith(\"-\")) {\n break;\n }\n commandPathTokens.push(token.trim().toLowerCase());\n }\n return {\n requested: true,\n commandPathTokens,\n };\n}\n\n/**\n * Index of the command token in argv — the first non-flag token, skipping the\n * value-consuming/global bootstrap flags. Returns undefined when there is none\n * (bare invocation, only global flags, or a leading `--`). Single source of truth\n * for command-position scanning shared by {@link parseBootstrapCommandName} and the\n * command-alias rewrite so their precedence rules can never drift apart.\n */\nfunction findCommandTokenIndex(argv: string[]): number | undefined {\n for (let index = 0; index < argv.length; index += 1) {\n const token = argv[index];\n if (token === \"--\") {\n return undefined;\n }\n if (token === \"--path\" || token === \"--pm-path\") {\n index += 1;\n continue;\n }\n if (\n token.startsWith(\"--path=\") ||\n token.startsWith(\"--pm-path=\") ||\n token === \"--json\" ||\n token === \"--quiet\" ||\n token === \"--no-extensions\" ||\n token === \"--no-pager\" ||\n token === \"--profile\" ||\n token === \"--id-only\" ||\n token === \"--explain\"\n ) {\n continue;\n }\n if (token.startsWith(\"-\")) {\n continue;\n }\n return index;\n }\n return undefined;\n}\n\n/**\n * Implements parse bootstrap command name for the public runtime surface of this module.\n */\nexport function parseBootstrapCommandName(argv: string[]): string | undefined {\n const index = findCommandTokenIndex(argv);\n return index === undefined ? undefined : argv[index].trim().toLowerCase();\n}\n\nfunction shouldDisablePagerForInvocation(argv: string[], bootstrapGlobal: BootstrapGlobalOptions): boolean {\n if (bootstrapGlobal.noPager) {\n return true;\n }\n if (process.stdout.isTTY === true) {\n return false;\n }\n const helpRequest = parseBootstrapHelpRequest(argv);\n return helpRequest.requested;\n}\n\n/**\n * Implements apply bootstrap pager policy for the public runtime surface of this module.\n */\nexport function applyBootstrapPagerPolicy(argv: string[]): void {\n const bootstrapGlobal = parseBootstrapGlobalOptions(argv);\n if (!shouldDisablePagerForInvocation(argv, bootstrapGlobal)) {\n return;\n }\n process.env.PAGER = \"cat\";\n process.env.MANPAGER = \"cat\";\n process.env.GIT_PAGER = \"cat\";\n if (typeof process.env.LESS !== \"string\" || process.env.LESS.trim().length === 0) {\n process.env.LESS = \"FRX\";\n }\n}\n\ntype ExtensionSubcommandAction =\n | \"init\"\n | \"install\"\n | \"uninstall\"\n | \"explore\"\n | \"manage\"\n | \"doctor\"\n | \"adopt\"\n | \"adopt-all\"\n | \"activate\"\n | \"deactivate\";\n\nconst EXTENSION_ACTION_SYNTAX_TOKENS = new Set<ExtensionSubcommandAction>([\n \"install\",\n \"uninstall\",\n \"explore\",\n \"manage\",\n \"doctor\",\n \"adopt\",\n \"adopt-all\",\n \"activate\",\n \"deactivate\",\n]);\n\n/**\n * Implements normalize legacy extension action syntax for the public runtime surface of this module.\n */\nexport function normalizeLegacyExtensionActionSyntax(argv: string[]): string[] {\n const extensionIndex = argv.findIndex((token) => token === \"extension\");\n if (extensionIndex < 0) {\n return [...argv];\n }\n const actionToken = argv[extensionIndex + 1];\n if (!actionToken || actionToken.startsWith(\"-\")) {\n return [...argv];\n }\n if (!EXTENSION_ACTION_SYNTAX_TOKENS.has(actionToken as ExtensionSubcommandAction)) {\n return [...argv];\n }\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return [...argv];\n }\n const forcedActionFlag = `--${actionToken}`;\n if (argv.includes(forcedActionFlag)) {\n return [...argv];\n }\n return [...argv.slice(0, extensionIndex + 1), forcedActionFlag, ...argv.slice(extensionIndex + 2)];\n}\n\ntype BootstrapNormalizationReason =\n | \"legacy_extension_action\"\n | \"command_alias\"\n | \"flag_alias\"\n | \"flag_typo\"\n | \"bare_key_value\"\n | \"list_merge\";\ntype BootstrapNormalizationConfidence = \"high\" | \"medium\";\n\n/**\n * Executable command aliases: a leading command token here is rewritten to its\n * canonical command BEFORE commander parses, so the alias actually runs instead of\n * merely being suggested. These are the highest-frequency aliases real agents type\n * (telemetry: `pm show <id>` alone is the single most common unknown-command) and\n * each target takes the same positional/flags as the alias (with `--comment`/\n * `--note`/`--learning` flag-aliased to `--add` on the target command). Keeping this\n * in one place means the alias is consistent across registration, commander dispatch,\n * telemetry, and error handling — all of which read the normalized argv.\n */\nexport const EXECUTABLE_COMMAND_ALIASES: Readonly<Record<string, string>> = {\n show: \"get\",\n view: \"get\",\n comment: \"comments\",\n note: \"notes\",\n learning: \"learnings\",\n};\n\n/**\n * Rewrite a leading command-alias token (e.g. `show` -> `get`) in place. Only the\n * command position is considered — the same token appearing later as an argument\n * (`pm get show`) is left untouched — and only when it is not preceded by `--` or a\n * value-consuming global flag, mirroring {@link parseBootstrapCommandName}.\n */\nfunction rewriteCommandAlias(argv: string[], trace: BootstrapNormalizationEvent[]): string[] {\n const index = findCommandTokenIndex(argv);\n if (index === undefined) {\n return argv;\n }\n const token = argv[index];\n const canonical = EXECUTABLE_COMMAND_ALIASES[token.trim().toLowerCase()];\n if (!canonical) {\n return argv;\n }\n const rewritten = [...argv];\n rewritten[index] = canonical;\n trace.push({ from: token, to: [canonical], reason: \"command_alias\", confidence: \"high\" });\n return rewritten;\n}\n\n/**\n * Documents the bootstrap normalization event payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapNormalizationEvent {\n from: string;\n to: string[];\n reason: BootstrapNormalizationReason;\n confidence: BootstrapNormalizationConfidence;\n}\n\n/**\n * Documents the bootstrap invocation normalization result payload exchanged by command, SDK, and package integrations.\n */\nexport interface BootstrapInvocationNormalizationResult {\n argv: string[];\n commandName: string | undefined;\n trace: BootstrapNormalizationEvent[];\n}\n\ninterface FlagLookup {\n canonicalByNormalized: Map<string, string | null>;\n canonicalByCompact: Map<string, string | null>;\n canonicalComparables: Array<{ canonicalFlag: string; comparable: string }>;\n listCanonicalFlags: Set<string>;\n}\n\nfunction normalizeFlagKeyToken(raw: string): string {\n const withoutPrefix = raw.replace(/^--?/, \"\");\n return withoutPrefix\n .replace(/_/g, \"-\")\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .toLowerCase();\n}\n\nfunction toComparableFlagKey(raw: string): string {\n return normalizeFlagKeyToken(raw).replace(/-/g, \"\");\n}\n\nfunction markUnambiguousFlag(\n map: Map<string, string | null>,\n key: string,\n canonicalFlag: string,\n): void {\n const existing = map.get(key);\n if (existing === undefined) {\n map.set(key, canonicalFlag);\n return;\n }\n if (existing !== canonicalFlag) {\n map.set(key, null);\n }\n}\n\nfunction collectLongFlagCandidates(contract: CliFlagContract): string[] {\n const candidates: string[] = [];\n const pushLongFlag = (value: string | undefined): void => {\n if (typeof value !== \"string\") {\n return;\n }\n if (!value.startsWith(\"--\")) {\n return;\n }\n candidates.push(value);\n };\n pushLongFlag(contract.flag);\n for (const alias of contract.aliases ?? []) {\n pushLongFlag(alias);\n }\n return candidates;\n}\n\nfunction buildFlagLookup(\n commandName: string | undefined,\n contractsOverride?: CliFlagContract[],\n): FlagLookup {\n const contracts = contractsOverride ?? resolveSubcommandFlagContractsForCommand(commandName);\n const canonicalByNormalized = new Map<string, string | null>();\n const canonicalByCompact = new Map<string, string | null>();\n const canonicalComparablesMap = new Map<string, string>();\n const listCanonicalFlags = new Set<string>();\n for (const contract of contracts) {\n const longCandidates = collectLongFlagCandidates(contract);\n if (longCandidates.length === 0) {\n continue;\n }\n const canonicalFlag = `--${normalizeFlagKeyToken(longCandidates[0])}`;\n for (const candidate of longCandidates) {\n markUnambiguousFlag(canonicalByNormalized, normalizeFlagKeyToken(candidate), canonicalFlag);\n markUnambiguousFlag(canonicalByCompact, toComparableFlagKey(candidate), canonicalFlag);\n }\n const comparable = toComparableFlagKey(canonicalFlag);\n if (!canonicalComparablesMap.has(canonicalFlag)) {\n canonicalComparablesMap.set(canonicalFlag, comparable);\n }\n if (contract.list === true) {\n listCanonicalFlags.add(canonicalFlag);\n }\n }\n return {\n canonicalByNormalized,\n canonicalByCompact,\n canonicalComparables: [...canonicalComparablesMap.entries()].map(([canonicalFlag, comparable]) => ({\n canonicalFlag,\n comparable,\n })),\n listCanonicalFlags,\n };\n}\n\nfunction resolveCanonicalFlag(\n rawKey: string,\n lookup: FlagLookup,\n): { flag: string; reason: \"flag_alias\" | \"flag_typo\"; confidence: BootstrapNormalizationConfidence } | null {\n const normalizedKey = normalizeFlagKeyToken(rawKey);\n const direct = lookup.canonicalByNormalized.get(normalizedKey);\n if (typeof direct === \"string\") {\n return {\n flag: direct,\n reason: \"flag_alias\",\n confidence: \"high\",\n };\n }\n const comparableKey = normalizedKey.replace(/-/g, \"\");\n const compactMatch = lookup.canonicalByCompact.get(comparableKey);\n if (typeof compactMatch === \"string\") {\n return {\n flag: compactMatch,\n reason: \"flag_alias\",\n confidence: \"high\",\n };\n }\n const maxDistance = comparableKey.length >= 8 ? 2 : 1;\n let bestDistance = Number.POSITIVE_INFINITY;\n let bestFlag: string | undefined;\n let tied = false;\n for (const candidate of lookup.canonicalComparables) {\n const distance = levenshteinDistanceWithinLimit(comparableKey, candidate.comparable, maxDistance);\n if (distance === null) {\n continue;\n }\n if (distance < bestDistance) {\n bestDistance = distance;\n bestFlag = candidate.canonicalFlag;\n tied = false;\n continue;\n }\n if (distance === bestDistance && bestFlag !== candidate.canonicalFlag) {\n tied = true;\n }\n }\n if (!bestFlag || tied || !Number.isFinite(bestDistance) || bestDistance <= 0) {\n return null;\n }\n return {\n flag: bestFlag,\n reason: \"flag_typo\",\n confidence: bestDistance >= 2 ? \"medium\" : \"high\",\n };\n}\n\n/**\n * Implements list alias plural keys for the public runtime surface of this module.\n */\nexport function listAliasPluralKeys(normalizedKey: string): string[] {\n const candidates = [`${normalizedKey}s`];\n if (normalizedKey.endsWith(\"y\") && normalizedKey.length > 1) {\n candidates.push(`${normalizedKey.slice(0, -1)}ies`);\n }\n return candidates;\n}\n\nfunction parseBareKeyValueToken(token: string): { key: string; value: string } | null {\n if (token.includes(\"://\")) {\n return null;\n }\n const match = token.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);\n if (!match) {\n return null;\n }\n const key = match[1];\n const value = match[3];\n if (value.length === 0) {\n return null;\n }\n return {\n key,\n value,\n };\n}\n\nfunction normalizeLongOptionToken(\n token: string,\n lookup: FlagLookup,\n): { tokens: string[]; event?: BootstrapNormalizationEvent } {\n if (!token.startsWith(\"--\")) {\n return { tokens: [token] };\n }\n const equalsIndex = token.indexOf(\"=\");\n const key = equalsIndex >= 0 ? token.slice(0, equalsIndex) : token;\n const inlineValue = equalsIndex >= 0 ? token.slice(equalsIndex + 1) : undefined;\n const resolution = resolveCanonicalFlag(key, lookup);\n if (!resolution) {\n return { tokens: [token] };\n }\n const normalizedToken = inlineValue === undefined ? resolution.flag : `${resolution.flag}=${inlineValue}`;\n if (normalizedToken === token) {\n return { tokens: [token] };\n }\n return {\n tokens: [normalizedToken],\n event: {\n from: token,\n to: [normalizedToken],\n reason: resolution.reason,\n confidence: resolution.confidence,\n },\n };\n}\n\n// Global option flags whose value may legitimately begin with \"--\" (commander\n// accepts such values). Their value token must not be reinterpreted as a list\n// flag during coalescing. `--pm-path <dir>` and its legacy `--path <dir>`\n// alias are the documented cases; other globals\n// (--json/--quiet/--no-extensions/--no-pager/--profile) are boolean.\nconst GLOBAL_VALUE_CONSUMING_FLAGS = new Set<string>([\"--pm-path\", \"--path\"]);\n\nfunction splitCanonicalListToken(token: string): { flag: string; inlineValue?: string } | null {\n if (!token.startsWith(\"--\")) {\n return null;\n }\n const equalsIndex = token.indexOf(\"=\");\n if (equalsIndex < 0) {\n return { flag: token };\n }\n return {\n flag: token.slice(0, equalsIndex),\n inlineValue: token.slice(equalsIndex + 1),\n };\n}\n\ninterface ListFlagSlot {\n outputIndex: number;\n originalTokens: string[];\n values: string[];\n occurrences: number;\n}\n\ninterface ListFlagOccurrence {\n originalTokens: string[];\n value: string | undefined;\n consumed: number;\n}\n\ninterface ValuedListFlagOccurrence {\n originalTokens: string[];\n value: string;\n}\n\nfunction copyValueConsumingFlag(argv: string[], index: number, result: (string | null)[]): number {\n result.push(argv[index]);\n const next = argv[index + 1];\n if (typeof next === \"string\" && next !== \"--\") {\n result.push(next);\n return index + 2;\n }\n return index + 1;\n}\n\nfunction readListFlagOccurrence(\n argv: string[],\n index: number,\n parsed: { flag: string; inlineValue?: string },\n multiValueListFlags: Set<string>,\n): ListFlagOccurrence {\n if (parsed.inlineValue !== undefined) {\n return {\n originalTokens: [argv[index]],\n value: parsed.inlineValue,\n consumed: 1,\n };\n }\n\n const values: string[] = [];\n let valueIndex = index + 1;\n while (\n valueIndex < argv.length &&\n argv[valueIndex] !== \"--\" &&\n !argv[valueIndex].startsWith(\"-\") &&\n (values.length === 0 || multiValueListFlags.has(parsed.flag))\n ) {\n values.push(argv[valueIndex]);\n valueIndex += 1;\n }\n\n const consumed = values.length === 0 ? 1 : 1 + values.length;\n return {\n originalTokens: argv.slice(index, index + consumed),\n value: values.length === 0 ? undefined : values.join(\",\"),\n consumed,\n };\n}\n\nfunction recordListFlagOccurrence(\n slots: Map<string, ListFlagSlot>,\n result: (string | null)[],\n flag: string,\n occurrence: ValuedListFlagOccurrence,\n): void {\n const existing = slots.get(flag);\n if (existing) {\n existing.values.push(occurrence.value);\n existing.occurrences += 1;\n return;\n }\n\n slots.set(flag, {\n outputIndex: result.length,\n originalTokens: occurrence.originalTokens,\n values: [occurrence.value],\n occurrences: 1,\n });\n // Reserve the anchor position; finalized after the walk so we know the full\n // merged value or can restore the original token form for single uses.\n result.push(null);\n}\n\nfunction buildListFlagCoalescingSplices(\n slots: Map<string, ListFlagSlot>,\n multiValueListFlags: Set<string>,\n): {\n events: BootstrapNormalizationEvent[];\n splices: Array<{ outputIndex: number; tokens: string[] }>;\n} {\n const events: BootstrapNormalizationEvent[] = [];\n const splices: Array<{ outputIndex: number; tokens: string[] }> = [];\n for (const [flag, slot] of slots) {\n const shouldMerge = slot.occurrences >= 2 || (multiValueListFlags.has(flag) && slot.originalTokens.length > 2);\n if (!shouldMerge) {\n splices.push({ outputIndex: slot.outputIndex, tokens: slot.originalTokens });\n continue;\n }\n const mergedToken = `${flag}=${slot.values.join(\",\")}`;\n splices.push({ outputIndex: slot.outputIndex, tokens: [mergedToken] });\n events.push({\n from: `${flag} (x${slot.occurrences})`,\n to: [mergedToken],\n reason: \"list_merge\",\n confidence: \"high\",\n });\n }\n return { events, splices };\n}\n\nfunction applyListFlagSplices(result: (string | null)[], splices: Array<{ outputIndex: number; tokens: string[] }>): void {\n splices.sort((a, b) => b.outputIndex - a.outputIndex);\n for (const splice of splices) {\n result.splice(splice.outputIndex, 1, ...splice.tokens);\n }\n}\n\n/**\n * Coalesce repeated occurrences of comma-separated list flags into a single\n * `--flag=v1,v2,v3` token anchored at the FIRST occurrence. Without this,\n * Commander treats these flags as scalars and silently keeps only the last\n * value (data loss). Both `--flag value` and `--flag=value` forms are merged;\n * a value-less occurrence is preserved untouched, and a `--` terminator stops\n * coalescing (remainder is passed through verbatim).\n *\n * `valueConsumingFlags` lists option flags (e.g. global `--path`) whose value\n * may itself begin with `--`. Their value token is emitted verbatim so a\n * list-flag-looking value (`--path --tags`) is never reinterpreted as a flag\n * nor allowed to swallow the following command/positional token.\n */\nexport function coalesceRepeatedListFlags(\n argv: string[],\n listFlags: Set<string>,\n valueConsumingFlags: Set<string> = new Set(),\n multiValueListFlags: Set<string> = new Set(),\n): { argv: string[]; events: BootstrapNormalizationEvent[] } {\n if (listFlags.size === 0) {\n return { argv: [...argv], events: [] };\n }\n\n const result: (string | null)[] = [];\n const slots = new Map<string, ListFlagSlot>();\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n result.push(...argv.slice(index));\n break;\n }\n // A value-consuming option in space form owns the next token as its value,\n // even when that value begins with \"--\". Emit both verbatim so the value is\n // never misread as a list-flag occurrence.\n if (valueConsumingFlags.has(token)) {\n index = copyValueConsumingFlag(argv, index, result);\n continue;\n }\n const parsed = splitCanonicalListToken(token);\n if (!parsed || !listFlags.has(parsed.flag)) {\n result.push(token);\n index += 1;\n continue;\n }\n\n const occurrence = readListFlagOccurrence(argv, index, parsed, multiValueListFlags);\n if (occurrence.value === undefined) {\n // Value-less occurrence: leave untouched, do not coalesce.\n result.push(token);\n index += occurrence.consumed;\n continue;\n }\n\n recordListFlagOccurrence(slots, result, parsed.flag, {\n originalTokens: occurrence.originalTokens,\n value: occurrence.value,\n });\n index += occurrence.consumed;\n }\n\n // Apply anchor splices from the end so earlier indices stay valid when a\n // single-occurrence anchor expands back into two tokens.\n const { events, splices } = buildListFlagCoalescingSplices(slots, multiValueListFlags);\n applyListFlagSplices(result, splices);\n\n return { argv: result as string[], events };\n}\n\n/**\n * Linked-test entry keys accepted in the two-token form `pm test <id> --add command\n * \"npm test -- parser\"` (GH-191). Only entry-identity keys are merged: `command`/`cmd`\n * name the shell command and `path` names the test file, so a single key=value entry is\n * meaningful for them. Other structured keys (scope, env_set, assertions, ...) cannot\n * form a valid standalone entry and are left for the normal parser to reject. `--remove`\n * matches existing entries by `command=`/`path=` only, so `cmd` is excluded there.\n * Key names mirror STRUCTURED_LINKED_TEST_KEYS in src/cli/commands/linked-test-entry.ts.\n */\nconst LINKED_TEST_TWO_TOKEN_KEYS_BY_FLAG: ReadonlyMap<string, ReadonlySet<string>> = new Map([\n [\"--add\", new Set([\"command\", \"cmd\", \"path\"])],\n [\"--remove\", new Set([\"command\", \"path\"])],\n]);\n\n/**\n * Sandbox-safe linked-test commands legitimately start with env assignments\n * (`PM_PATH=... PM_GLOBAL_PATH=... vitest run -- parser`), which look like bare\n * key=value settings tokens. When the two preceding tokens are a linked-test\n * flag plus a bare two-token key (`--add command <value>`), the value must be\n * left intact for mergeLinkedTestTwoTokenEntries instead of being rewritten\n * into a canonical flag (e.g. PM_PATH= -> --pm-path), which would silently\n * corrupt the command into `--add command --pm-path ...`.\n */\nfunction isLinkedTestTwoTokenValuePosition(commandName: string | undefined, emittedTokens: readonly string[]): boolean {\n if (commandName !== \"test\" || emittedTokens.length < 2) {\n return false;\n }\n const key = emittedTokens[emittedTokens.length - 1];\n const flag = emittedTokens[emittedTokens.length - 2];\n const keys = LINKED_TEST_TWO_TOKEN_KEYS_BY_FLAG.get(flag);\n return keys !== undefined && keys.has(key);\n}\n\n/**\n * Accept the two-token linked-test form `pm test <id> --add command \"npm test -- parser\"`\n * by merging the bare key token and its single quoted value into the documented\n * `--add command=...` shape. Without this merge Commander binds the bare key as the\n * option value and treats the quoted command as an excess positional, failing with\n * \"too many arguments\" (GH-191). The merge only fires when EXACTLY ONE non-flag token\n * follows the bare key, i.e. the value was quoted into one shell token — an unquoted\n * multi-token value stays ambiguous (it may swallow the item id), still fails fast, and\n * is routed to targeted quoting guidance by the commander error classifier instead.\n */\nexport function mergeLinkedTestTwoTokenEntries(\n argv: string[],\n commandName: string | undefined,\n trace: BootstrapNormalizationEvent[],\n): string[] {\n if (commandName !== \"test\") {\n return argv;\n }\n const result: string[] = [];\n let index = 0;\n while (index < argv.length) {\n const token = argv[index];\n if (token === \"--\") {\n result.push(...argv.slice(index));\n return result;\n }\n const keys = LINKED_TEST_TWO_TOKEN_KEYS_BY_FLAG.get(token);\n const key = keys ? argv[index + 1] : undefined;\n if (!keys || typeof key !== \"string\" || !keys.has(key)) {\n result.push(token);\n index += 1;\n continue;\n }\n let runEnd = index + 2;\n while (runEnd < argv.length && !argv[runEnd].startsWith(\"-\")) {\n runEnd += 1;\n }\n if (runEnd - (index + 2) !== 1) {\n result.push(token);\n index += 1;\n continue;\n }\n const value = argv[index + 2];\n const mergedValue = `${key}=${value}`;\n result.push(token, mergedValue);\n trace.push({\n from: `${token} ${key} ${value}`,\n to: [token, mergedValue],\n reason: \"bare_key_value\",\n confidence: \"high\",\n });\n index += 3;\n }\n return result;\n}\n\n/**\n * Implements normalize bootstrap invocation for the public runtime surface of this module.\n */\nexport function normalizeBootstrapInvocation(argv: string[]): BootstrapInvocationNormalizationResult {\n const trace: BootstrapNormalizationEvent[] = [];\n const legacyNormalized = normalizeLegacyExtensionActionSyntax(argv);\n if (legacyNormalized.length !== argv.length || legacyNormalized.some((token, index) => token !== argv[index])) {\n trace.push({\n from: argv.join(\" \"),\n to: [...legacyNormalized],\n reason: \"legacy_extension_action\",\n confidence: \"high\",\n });\n }\n const aliasNormalized = rewriteCommandAlias(legacyNormalized, trace);\n const commandName = parseBootstrapCommandName(aliasNormalized);\n const commandPathName = parseBootstrapCommandPathName(aliasNormalized);\n const lookup = buildFlagLookup(commandPathName ?? commandName);\n const normalizedArgv: string[] = [];\n for (let index = 0; index < aliasNormalized.length; index += 1) {\n const token = aliasNormalized[index];\n if (token === \"--\") {\n normalizedArgv.push(...aliasNormalized.slice(index));\n break;\n }\n const previous = normalizedArgv[normalizedArgv.length - 1];\n if (token.startsWith(\"--\")) {\n const normalizedToken = normalizeLongOptionToken(token, lookup);\n normalizedArgv.push(...normalizedToken.tokens);\n if (normalizedToken.event) {\n trace.push(normalizedToken.event);\n }\n continue;\n }\n const bareKeyValue = parseBareKeyValueToken(token);\n if (\n bareKeyValue &&\n !(typeof previous === \"string\" && previous.startsWith(\"-\")) &&\n !isLinkedTestTwoTokenValuePosition(commandName, normalizedArgv)\n ) {\n const resolution = resolveCanonicalFlag(bareKeyValue.key, lookup);\n if (resolution) {\n const replacement = [resolution.flag, bareKeyValue.value];\n normalizedArgv.push(...replacement);\n trace.push({\n from: token,\n to: replacement,\n reason: \"bare_key_value\",\n confidence: resolution.confidence,\n });\n continue;\n }\n }\n normalizedArgv.push(token);\n }\n const linkedTestNormalized = mergeLinkedTestTwoTokenEntries(normalizedArgv, commandName, trace);\n const coalesced = coalesceRepeatedListFlags(\n linkedTestNormalized,\n lookup.listCanonicalFlags,\n GLOBAL_VALUE_CONSUMING_FLAGS,\n commandName === \"create\" ? new Set([\"--tags\"]) : new Set(),\n );\n for (const event of coalesced.events) {\n trace.push(event);\n }\n return {\n argv: coalesced.argv,\n commandName,\n trace,\n };\n}\n\nfunction parseBootstrapCommandPathName(argv: string[]): string | undefined {\n const stripped = stripGlobalBootstrapTokens(argv);\n const first = stripped[0]?.trim().toLowerCase();\n const second = stripped[1]?.trim().toLowerCase();\n if (\n (first === \"extension\" || first === \"package\" || first === \"packages\") &&\n typeof second === \"string\" &&\n second.length > 0 &&\n !second.startsWith(\"-\")\n ) {\n return `${first} ${second}`;\n }\n return first;\n}\n\n/**\n * Implements parse bootstrap type value for the public runtime surface of this module.\n */\nexport function parseBootstrapTypeValue(argv: string[]): string | undefined {\n for (let index = 0; index < argv.length; index += 1) {\n const token = argv[index];\n if (token === \"--type\") {\n const candidate = argv[index + 1];\n if (typeof candidate === \"string\" && candidate.trim().length > 0) {\n return candidate.trim();\n }\n continue;\n }\n if (token.startsWith(\"--type=\")) {\n const candidate = token.slice(\"--type=\".length).trim();\n if (candidate.length > 0) {\n return candidate;\n }\n }\n }\n return undefined;\n}\n\nexport const _testOnly = {\n buildFlagLookup,\n collectLongFlagCandidates,\n markUnambiguousFlag,\n normalizeLongOptionToken,\n resolveCanonicalFlag,\n};\n", "/**\n * @module cli/commands/extension/shared\n *\n * Implements extension package-management support for Shared.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathExists } from \"../../../core/fs/fs-utils.js\";\nimport { isPathWithinDirectory } from \"../../../core/fs/path-utils.js\";\nimport { EXIT_CODE } from \"../../../core/shared/constants.js\";\nimport { PmCliError } from \"../../../core/shared/errors.js\";\nimport type { ExtensionManifest } from \"../../../core/extensions/loader.js\";\n\nexport const DEFAULT_EXTENSION_PRIORITY = 100;\n\n/**\n * Documents the validated extension directory payload exchanged by command, SDK, and package integrations.\n */\nexport interface ValidatedExtensionDirectory {\n directory: string;\n manifest_path: string;\n entry_path: string;\n manifest: ExtensionManifest;\n}\n\n/**\n * Implements normalize string list for the public runtime surface of this module.\n */\nexport function normalizeStringList(values: readonly string[]): string[] {\n return [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((left, right) =>\n left.localeCompare(right),\n );\n}\n\n/**\n * Implements normalize extension name for match for the public runtime surface of this module.\n */\nexport function normalizeExtensionNameForMatch(value: string): string {\n return value.trim().toLowerCase();\n}\n\n/**\n * Implements normalize managed directory name for the public runtime surface of this module.\n */\nexport function normalizeManagedDirectoryName(name: string): string {\n const normalized = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n if (normalized.length === 0) {\n throw new PmCliError(\"Extension manifest name must resolve to a non-empty directory name.\", EXIT_CODE.USAGE);\n }\n if (normalized === \".\" || normalized === \"..\") {\n // Manifest-controlled input must resolve to a dedicated child directory, never\n // the extensions root itself or its parent (path-traversal guard).\n throw new PmCliError(\"Extension manifest name must not resolve to \\\".\\\" or \\\"..\\\".\", EXIT_CODE.USAGE);\n }\n return normalized;\n}\n\nfunction parseOptionalManifestPriority(value: unknown): number | null {\n if (value === undefined || value === null) {\n return DEFAULT_EXTENSION_PRIORITY;\n }\n return typeof value === \"number\" && Number.isInteger(value) ? value : null;\n}\n\nfunction parseOptionalManifestCapabilities(value: unknown): string[] | null {\n if (value === undefined || value === null) {\n return [];\n }\n if (!Array.isArray(value) || value.some((entry) => typeof entry !== \"string\")) {\n return null;\n }\n return normalizeStringList(value.map((entry) => String(entry).toLowerCase()));\n}\n\n/**\n * Implements parse extension manifest for the public runtime surface of this module.\n */\nexport function parseExtensionManifest(raw: unknown): ExtensionManifest | null {\n if (typeof raw !== \"object\" || raw === null) {\n return null;\n }\n const candidate = raw as Record<string, unknown>;\n if (typeof candidate.name !== \"string\" || candidate.name.trim().length === 0) {\n return null;\n }\n if (typeof candidate.version !== \"string\" || candidate.version.trim().length === 0) {\n return null;\n }\n if (typeof candidate.entry !== \"string\" || candidate.entry.trim().length === 0) {\n return null;\n }\n\n const priority = parseOptionalManifestPriority(candidate.priority);\n const capabilities = parseOptionalManifestCapabilities(candidate.capabilities);\n if (priority === null || capabilities === null) {\n return null;\n }\n\n return {\n name: candidate.name.trim(),\n version: candidate.version.trim(),\n entry: candidate.entry.trim(),\n priority,\n capabilities,\n };\n}\n\n/**\n * Implements check whether canonical path within directory for the public runtime surface of this module.\n */\nexport async function isCanonicalPathWithinDirectory(directory: string, targetPath: string): Promise<boolean> {\n const [resolvedDirectory, resolvedTargetPath] = await Promise.all([fs.realpath(directory), fs.realpath(targetPath)]);\n return isPathWithinDirectory(resolvedDirectory, resolvedTargetPath);\n}\n\n/**\n * Implements validate extension directory for the public runtime surface of this module.\n */\nexport async function validateExtensionDirectory(directory: string): Promise<ValidatedExtensionDirectory> {\n const manifestPath = path.join(directory, \"manifest.json\");\n if (!(await pathExists(manifestPath))) {\n throw new PmCliError(`Extension manifest is missing at \"${manifestPath}\".`, EXIT_CODE.USAGE);\n }\n\n let parsedManifest: unknown;\n try {\n parsedManifest = JSON.parse(await fs.readFile(manifestPath, \"utf8\")) as unknown;\n } catch (error: unknown) {\n throw new PmCliError(\n `Failed to parse extension manifest at \"${manifestPath}\": ${formatManifestReadError(error)}`,\n EXIT_CODE.USAGE,\n );\n }\n\n const manifest = parseExtensionManifest(parsedManifest);\n if (!manifest) {\n throw new PmCliError(`Extension manifest at \"${manifestPath}\" is invalid.`, EXIT_CODE.USAGE);\n }\n\n const entryPath = path.resolve(directory, manifest.entry);\n if (!isPathWithinDirectory(directory, entryPath)) {\n throw new PmCliError(\n `Extension entry \"${manifest.entry}\" resolves outside extension directory \"${directory}\".`,\n EXIT_CODE.USAGE,\n );\n }\n if (!(await pathExists(entryPath))) {\n throw new PmCliError(`Extension entry file is missing at \"${entryPath}\".`, EXIT_CODE.USAGE);\n }\n if (!(await isCanonicalPathWithinDirectory(directory, entryPath))) {\n throw new PmCliError(\n `Extension entry \"${manifest.entry}\" resolves outside extension directory after symlink resolution.`,\n EXIT_CODE.USAGE,\n );\n }\n\n return {\n directory,\n manifest_path: manifestPath,\n entry_path: entryPath,\n manifest,\n };\n}\n\nfunction formatManifestReadError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport const _testOnlyExtensionShared = {\n formatManifestReadError,\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAQA,SAAS,wBACP,OACA,MAAwB;AAExB,MAAI,UAAU,YAAY,UAAU,aAAa;AAC/C,QAAI,OAAO,SAAS,YAAY,KAAK,SAAS,GAAG;AAC/C,aAAO;QACL,UAAU;QACV,WAAW;QACX,WAAW,UAAU;;IAEzB;AACA,WAAO;MACL,UAAU;MACV,WAAW,UAAU;;EAEzB;AAEA,QAAM,eAAe,MAAM,WAAW,SAAS,IAC3C,YACA,MAAM,WAAW,YAAY,IAC3B,eACA;AACN,MAAI,CAAC,cAAc;AACjB,WAAO;EACT;AAEA,QAAM,QAAQ,MAAM,MAAM,aAAa,MAAM;AAC7C,MAAI,MAAM,SAAS,GAAG;AACpB,WAAO;MACL,UAAU;MACV,WAAW;MACX,WAAW,iBAAiB;;EAEhC;AACA,SAAO;IACL,UAAU;IACV,WAAW,iBAAiB;;AAEhC;AAgBM,SAAU,4BAA4B,MAAc;AACxD,MAAI;AACJ,MAAI;AACJ,MAAI,eAAe;AACnB,MAAI,UAAU;AACd,MAAI,OAAO;AACX,MAAI,QAAQ;AACZ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B;AACA,MAAI,CAAE,MAAM,WAAW,SAAS,GAAI;AAClC,UAAM,IAAI,WAAW,uCAAuC,SAAS,MAAM,UAAU,KAAK;EAC5F;AACA,MAAI,CAAE,MAAM,+BAA+B,WAAW,SAAS,GAAI;AACjE,UAAM,IAAI,WACR,oBAAoB,SAAS,KAAK,oEAClC,UAAU,KAAK;EAEnB;AAEA,SAAO;IACL;IACA,eAAe;IACf,YAAY;IACZ;;AAEJ;AAEA,SAAS,wBAAwB,OAAc;AAC7C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;",
6
6
  "names": ["commandPathTokens"]
7
7
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WW4E2DC3.js";
4
4
  import {
5
5
  readHistoryEntries
6
- } from "./chunk-A6VOGKBA.js";
6
+ } from "./chunk-EB4BBEZD.js";
7
7
  import {
8
8
  EMPTY_REPLAY_DOCUMENT,
9
9
  historyEntriesToRaw,
@@ -11,7 +11,7 @@ import {
11
11
  replayToItemDocument,
12
12
  tryApplyReplayPatch,
13
13
  verifyHistoryChain
14
- } from "./chunk-N2JSWVWG.js";
14
+ } from "./chunk-HL742IBM.js";
15
15
  import {
16
16
  acquireLock,
17
17
  createHistoryEntry,
@@ -19,14 +19,14 @@ import {
19
19
  normalizeItemId,
20
20
  normalizeRawItemId,
21
21
  readLocatedItem
22
- } from "./chunk-JXAUVO6X.js";
22
+ } from "./chunk-CN4OAA2G.js";
23
23
  import {
24
24
  canonicalDocument,
25
25
  serializeItemDocument
26
- } from "./chunk-IEEJQCZ4.js";
26
+ } from "./chunk-CQFZRLXQ.js";
27
27
  import {
28
28
  nowIso
29
- } from "./chunk-AIAIXG7I.js";
29
+ } from "./chunk-MZG6I2Q2.js";
30
30
  import {
31
31
  EXIT_CODE,
32
32
  PmCliError,
@@ -42,16 +42,17 @@ import {
42
42
  resolvePmRoot,
43
43
  runActiveOnWriteHooks,
44
44
  writeFileAtomic
45
- } from "./chunk-7NSPKJUS.js";
45
+ } from "./chunk-BDDYM4LH.js";
46
46
 
47
47
  // dist/cli/commands/history-redact.js
48
- import fs from "node:fs/promises";
48
+ import fs2 from "node:fs/promises";
49
49
 
50
50
  // dist/core/history/history-rewrite.js
51
+ import fs from "node:fs/promises";
51
52
  !(function() {
52
53
  try {
53
54
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
54
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "665cdb28-cf61-56a3-a037-708d2445359d");
55
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "f03392a5-662f-5a2d-97c6-7a51a575dd39");
55
56
  } catch (e2) {
56
57
  }
57
58
  })();
@@ -82,6 +83,23 @@ async function verifyHistoryRewriteNoDrift(params) {
82
83
  }
83
84
  return { historyRawUnderLock, locatedUnderLock, loadedItemUnderLock };
84
85
  }
86
+ async function writeHistoryRawWithRollback(params) {
87
+ const writeHistoryRaw = params.writeHistoryRaw ?? writeFileAtomic;
88
+ try {
89
+ await writeHistoryRaw(params.historyPath, params.nextHistoryRaw);
90
+ } catch (error) {
91
+ try {
92
+ if (params.historyRawUnderLock === null) {
93
+ await fs.rm(params.historyPath, { force: true });
94
+ } else {
95
+ await writeHistoryRaw(params.historyPath, params.historyRawUnderLock);
96
+ }
97
+ } catch (rollbackError) {
98
+ throw new AggregateError([error, rollbackError], `History rewrite failed and rollback also failed: ${String(error)}`);
99
+ }
100
+ throw error;
101
+ }
102
+ }
85
103
  async function executeHistoryRewrite(params) {
86
104
  const warnings = [...checkHistoryRewriteOwnership({
87
105
  itemDocument: params.itemDocument,
@@ -439,7 +457,7 @@ async function applyHistoryRedactRewrite(params) {
439
457
  await writeFileAtomic(params.nextItem.path, params.nextItem.raw);
440
458
  }
441
459
  if (params.currentItem.path && (!params.nextItem.path || params.nextItem.path !== params.currentItem.path)) {
442
- await fs.rm(params.currentItem.path, { force: true });
460
+ await fs2.rm(params.currentItem.path, { force: true });
443
461
  }
444
462
  await writeFileAtomic(params.subject.historyPath, historyEntriesToRaw(params.rewrittenEntries));
445
463
  } catch (error) {
@@ -455,14 +473,14 @@ async function applyHistoryRedactRewrite(params) {
455
473
  }
456
474
  async function rollbackHistoryRedactRewrite(historyPath, historyRawUnderLock, affectedItemPaths, itemSnapshots) {
457
475
  if (historyRawUnderLock === null) {
458
- await fs.rm(historyPath, { force: true });
476
+ await fs2.rm(historyPath, { force: true });
459
477
  } else {
460
478
  await writeFileAtomic(historyPath, historyRawUnderLock);
461
479
  }
462
480
  for (const itemPath of affectedItemPaths) {
463
481
  const snapshot = itemSnapshots.get(itemPath);
464
482
  if (snapshot === void 0) {
465
- await fs.rm(itemPath, { force: true });
483
+ await fs2.rm(itemPath, { force: true });
466
484
  } else {
467
485
  await writeFileAtomic(itemPath, snapshot);
468
486
  }
@@ -626,9 +644,10 @@ var _testOnly = {
626
644
  };
627
645
 
628
646
  export {
647
+ writeHistoryRawWithRollback,
629
648
  executeHistoryRewrite,
630
649
  resolveHistorySubject,
631
650
  runHistoryRedact,
632
651
  _testOnly
633
652
  };
634
- //# sourceMappingURL=chunk-UWKEJMZU.js.map
653
+ //# sourceMappingURL=chunk-4PJYRA3V.js.map