@unbrained/pm-cli 2026.6.24 → 2026.7.1

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 (744) hide show
  1. package/AGENTS.md +2 -0
  2. package/CHANGELOG.md +113 -1
  3. package/CONTRIBUTING.md +30 -0
  4. package/README.md +16 -3
  5. package/dist/cli/bootstrap-args.js +89 -79
  6. package/dist/cli/bootstrap-args.js.map +1 -1
  7. package/dist/cli/commander-usage.js +3 -3
  8. package/dist/cli/commander-usage.js.map +1 -1
  9. package/dist/cli/commands/aggregate.js +8 -7
  10. package/dist/cli/commands/aggregate.js.map +1 -1
  11. package/dist/cli/commands/calendar.js +63 -62
  12. package/dist/cli/commands/calendar.js.map +1 -1
  13. package/dist/cli/commands/close.d.ts +2 -4
  14. package/dist/cli/commands/close.js +5 -17
  15. package/dist/cli/commands/close.js.map +1 -1
  16. package/dist/cli/commands/completion.js +158 -9
  17. package/dist/cli/commands/completion.js.map +1 -1
  18. package/dist/cli/commands/config.d.ts +1 -1
  19. package/dist/cli/commands/config.js +2 -2
  20. package/dist/cli/commands/config.js.map +1 -1
  21. package/dist/cli/commands/context.d.ts +31 -4
  22. package/dist/cli/commands/context.js +33 -10
  23. package/dist/cli/commands/context.js.map +1 -1
  24. package/dist/cli/commands/contracts.js +48 -8
  25. package/dist/cli/commands/contracts.js.map +1 -1
  26. package/dist/cli/commands/create.d.ts +1 -6
  27. package/dist/cli/commands/create.js +491 -587
  28. package/dist/cli/commands/create.js.map +1 -1
  29. package/dist/cli/commands/extension/bundled-catalog.js +59 -46
  30. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
  31. package/dist/cli/commands/extension/describe.d.ts +15 -0
  32. package/dist/cli/commands/extension/describe.js +48 -2
  33. package/dist/cli/commands/extension/describe.js.map +1 -1
  34. package/dist/cli/commands/extension/doctor.js +129 -75
  35. package/dist/cli/commands/extension/doctor.js.map +1 -1
  36. package/dist/cli/commands/extension/install-sources.js +37 -7
  37. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  38. package/dist/cli/commands/extension/managed-state.js +101 -57
  39. package/dist/cli/commands/extension/managed-state.js.map +1 -1
  40. package/dist/cli/commands/extension/scaffold.d.ts +38 -8
  41. package/dist/cli/commands/extension/scaffold.js +1956 -242
  42. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  43. package/dist/cli/commands/extension.d.ts +28 -3
  44. package/dist/cli/commands/extension.js +1181 -880
  45. package/dist/cli/commands/extension.js.map +1 -1
  46. package/dist/cli/commands/index.d.ts +3 -1
  47. package/dist/cli/commands/index.js +5 -3
  48. package/dist/cli/commands/index.js.map +1 -1
  49. package/dist/cli/commands/item-filter-options.d.ts +63 -0
  50. package/dist/cli/commands/item-filter-options.js +10 -0
  51. package/dist/cli/commands/item-filter-options.js.map +1 -0
  52. package/dist/cli/commands/legacy-none-tokens.d.ts +14 -0
  53. package/dist/cli/commands/legacy-none-tokens.js +31 -2
  54. package/dist/cli/commands/legacy-none-tokens.js.map +1 -1
  55. package/dist/cli/commands/linked-artifacts.d.ts +7 -0
  56. package/dist/cli/commands/linked-artifacts.js +12 -2
  57. package/dist/cli/commands/linked-artifacts.js.map +1 -1
  58. package/dist/cli/commands/list-filter-shared.js +55 -48
  59. package/dist/cli/commands/list-filter-shared.js.map +1 -1
  60. package/dist/cli/commands/list.d.ts +16 -39
  61. package/dist/cli/commands/list.js +127 -118
  62. package/dist/cli/commands/list.js.map +1 -1
  63. package/dist/cli/commands/next.d.ts +98 -0
  64. package/dist/cli/commands/next.js +304 -0
  65. package/dist/cli/commands/next.js.map +1 -0
  66. package/dist/cli/commands/profile.d.ts +208 -0
  67. package/dist/cli/commands/profile.js +418 -0
  68. package/dist/cli/commands/profile.js.map +1 -0
  69. package/dist/cli/commands/repeatable-metadata-parsers.js +12 -13
  70. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -1
  71. package/dist/cli/commands/schema.d.ts +7 -0
  72. package/dist/cli/commands/schema.js +9 -3
  73. package/dist/cli/commands/schema.js.map +1 -1
  74. package/dist/cli/commands/search.d.ts +2 -39
  75. package/dist/cli/commands/search.js +196 -172
  76. package/dist/cli/commands/search.js.map +1 -1
  77. package/dist/cli/commands/shared-unset-fields.d.ts +30 -0
  78. package/dist/cli/commands/shared-unset-fields.js +161 -0
  79. package/dist/cli/commands/shared-unset-fields.js.map +1 -0
  80. package/dist/cli/commands/stats.js +15 -3
  81. package/dist/cli/commands/stats.js.map +1 -1
  82. package/dist/cli/commands/test.js +115 -125
  83. package/dist/cli/commands/test.js.map +1 -1
  84. package/dist/cli/commands/update.d.ts +1 -6
  85. package/dist/cli/commands/update.js +37 -232
  86. package/dist/cli/commands/update.js.map +1 -1
  87. package/dist/cli/commands/validate.js +20 -5
  88. package/dist/cli/commands/validate.js.map +1 -1
  89. package/dist/cli/extension-command-options.js +48 -21
  90. package/dist/cli/extension-command-options.js.map +1 -1
  91. package/dist/cli/help-content.js +26 -2
  92. package/dist/cli/help-content.js.map +1 -1
  93. package/dist/cli/help-json-payload.js +3 -3
  94. package/dist/cli/help-json-payload.js.map +1 -1
  95. package/dist/cli/main.js +27 -12
  96. package/dist/cli/main.js.map +1 -1
  97. package/dist/cli/register-list-query.js +42 -3
  98. package/dist/cli/register-list-query.js.map +1 -1
  99. package/dist/cli/register-mutation.js +86 -2
  100. package/dist/cli/register-mutation.js.map +1 -1
  101. package/dist/cli/register-setup.js +67 -6
  102. package/dist/cli/register-setup.js.map +1 -1
  103. package/dist/cli/registration-helpers.d.ts +9 -1
  104. package/dist/cli/registration-helpers.js +149 -123
  105. package/dist/cli/registration-helpers.js.map +1 -1
  106. package/dist/cli-bundle/chunks/activity-AW6XVFH6.js +16 -0
  107. package/dist/cli-bundle/chunks/{activity-N7RVTLBQ.js → activity-DBLQVIP6.js} +9 -11
  108. package/dist/cli-bundle/chunks/{aggregate-63NWNIBR.js → aggregate-JTEF4BP7.js} +17 -18
  109. package/dist/cli-bundle/chunks/aggregate-JTEF4BP7.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{aggregate-YHCYX2EV.js → aggregate-SDF7DUOD.js} +16 -17
  111. package/dist/cli-bundle/chunks/aggregate-SDF7DUOD.js.map +7 -0
  112. package/dist/cli-bundle/chunks/{append-VLQQDHMJ.js → append-LOVPGVPT.js} +8 -10
  113. package/dist/cli-bundle/chunks/{append-VLQQDHMJ.js.map → append-LOVPGVPT.js.map} +1 -1
  114. package/dist/cli-bundle/chunks/{append-PUKREFV5.js → append-QCFJSDFL.js} +10 -12
  115. package/dist/cli-bundle/chunks/{append-PUKREFV5.js.map → append-QCFJSDFL.js.map} +1 -1
  116. package/dist/cli-bundle/chunks/{chunk-ABYCA5VX.js → chunk-22WKIL3H.js} +9 -11
  117. package/dist/cli-bundle/chunks/{chunk-ABYCA5VX.js.map → chunk-22WKIL3H.js.map} +1 -1
  118. package/dist/cli-bundle/chunks/{chunk-A66VYUOV.js → chunk-2466X6E4.js} +9 -11
  119. package/dist/cli-bundle/chunks/{chunk-A66VYUOV.js.map → chunk-2466X6E4.js.map} +1 -1
  120. package/dist/cli-bundle/chunks/{chunk-F32L4HR6.js → chunk-27BXPBAY.js} +3 -3
  121. package/dist/cli-bundle/chunks/{schema-QO5I4FBL.js → chunk-2D4HATP2.js} +136 -66
  122. package/dist/cli-bundle/chunks/chunk-2D4HATP2.js.map +1 -0
  123. package/dist/cli-bundle/chunks/{chunk-J7I4C5ZB.js → chunk-3J6JRJ3I.js} +153 -125
  124. package/dist/cli-bundle/chunks/chunk-3J6JRJ3I.js.map +7 -0
  125. package/dist/cli-bundle/chunks/{chunk-OHDQNKJB.js → chunk-3K2M5OYU.js} +106 -34
  126. package/dist/cli-bundle/chunks/chunk-3K2M5OYU.js.map +7 -0
  127. package/dist/cli-bundle/chunks/{chunk-XVYKWZNL.js → chunk-3S2KT7NG.js} +127 -127
  128. package/dist/cli-bundle/chunks/chunk-3S2KT7NG.js.map +7 -0
  129. package/dist/cli-bundle/chunks/{chunk-5BBEWX6C.js → chunk-3VGN2UWE.js} +2 -2
  130. package/dist/cli-bundle/chunks/{chunk-N5B6WZC5.js → chunk-3XZCOZ5J.js} +115 -123
  131. package/dist/cli-bundle/chunks/chunk-3XZCOZ5J.js.map +1 -0
  132. package/dist/cli-bundle/chunks/chunk-4A3BJ675.js +799 -0
  133. package/dist/cli-bundle/chunks/chunk-4A3BJ675.js.map +1 -0
  134. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js +87 -0
  135. package/dist/cli-bundle/chunks/chunk-4BU75MF4.js.map +7 -0
  136. package/dist/cli-bundle/chunks/{chunk-HZF5RLKX.js → chunk-4DSGXSBL.js} +5 -7
  137. package/dist/cli-bundle/chunks/{chunk-HZF5RLKX.js.map → chunk-4DSGXSBL.js.map} +1 -1
  138. package/dist/cli-bundle/chunks/{chunk-JV27C7OZ.js → chunk-4DUVCVLZ.js} +4 -6
  139. package/dist/cli-bundle/chunks/{chunk-JV27C7OZ.js.map → chunk-4DUVCVLZ.js.map} +1 -1
  140. package/dist/cli-bundle/chunks/{chunk-IAP5KYBQ.js → chunk-4XOIEKSD.js} +563 -506
  141. package/dist/cli-bundle/chunks/chunk-4XOIEKSD.js.map +1 -0
  142. package/dist/cli-bundle/chunks/{context-5LB7UGKE.js → chunk-55SNVXRQ.js} +79 -82
  143. package/dist/cli-bundle/chunks/chunk-55SNVXRQ.js.map +7 -0
  144. package/dist/cli-bundle/chunks/{chunk-BFFO3AIB.js → chunk-5CGRF3L5.js} +128 -128
  145. package/dist/cli-bundle/chunks/chunk-5CGRF3L5.js.map +1 -0
  146. package/dist/cli-bundle/chunks/{chunk-JKL6HRMV.js → chunk-5QFDBI4F.js} +1260 -1046
  147. package/dist/cli-bundle/chunks/chunk-5QFDBI4F.js.map +7 -0
  148. package/dist/cli-bundle/chunks/{chunk-LU36E6GU.js → chunk-64HNBBFQ.js} +8 -12
  149. package/dist/cli-bundle/chunks/{chunk-LU36E6GU.js.map → chunk-64HNBBFQ.js.map} +1 -1
  150. package/dist/cli-bundle/chunks/chunk-6AQZPVHQ.js +2444 -0
  151. package/dist/cli-bundle/chunks/chunk-6AQZPVHQ.js.map +1 -0
  152. package/dist/cli-bundle/chunks/chunk-7M2HAZEB.js +17 -0
  153. package/dist/cli-bundle/chunks/chunk-7M2HAZEB.js.map +7 -0
  154. package/dist/cli-bundle/chunks/{chunk-VSAABFGQ.js → chunk-7R4QEMZZ.js} +1490 -734
  155. package/dist/cli-bundle/chunks/chunk-7R4QEMZZ.js.map +1 -0
  156. package/dist/cli-bundle/chunks/{chunk-M6TUBOGW.js → chunk-A7FPBAQS.js} +19 -12
  157. package/dist/cli-bundle/chunks/chunk-A7FPBAQS.js.map +1 -0
  158. package/dist/cli-bundle/chunks/{chunk-GQYJEEFX.js → chunk-AVEE5EHK.js} +53 -54
  159. package/dist/cli-bundle/chunks/chunk-AVEE5EHK.js.map +1 -0
  160. package/dist/cli-bundle/chunks/{chunk-FMWW2JDU.js → chunk-AXIDKKAT.js} +2 -2
  161. package/dist/cli-bundle/chunks/{chunk-TIM4OD74.js → chunk-BDTISOSD.js} +2 -2
  162. package/dist/cli-bundle/chunks/{chunk-C4C3EJCJ.js → chunk-BHO33VBQ.js} +509 -363
  163. package/dist/cli-bundle/chunks/chunk-BHO33VBQ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/{chunk-6W3Y65PL.js → chunk-BZCEN4JA.js} +198 -177
  165. package/dist/cli-bundle/chunks/chunk-BZCEN4JA.js.map +7 -0
  166. package/dist/cli-bundle/chunks/{chunk-RRP6D345.js → chunk-CF7RL6FR.js} +12 -16
  167. package/dist/cli-bundle/chunks/{chunk-RRP6D345.js.map → chunk-CF7RL6FR.js.map} +1 -1
  168. package/dist/cli-bundle/chunks/{chunk-HC2S36NB.js → chunk-CWFNTKQJ.js} +154 -126
  169. package/dist/cli-bundle/chunks/chunk-CWFNTKQJ.js.map +1 -0
  170. package/dist/cli-bundle/chunks/chunk-CZVISY5A.js +87 -0
  171. package/dist/cli-bundle/chunks/chunk-CZVISY5A.js.map +7 -0
  172. package/dist/cli-bundle/chunks/{chunk-CZIFFMZI.js → chunk-DDPTYJIM.js} +2 -2
  173. package/dist/cli-bundle/chunks/{chunk-AYPQUFCX.js → chunk-EJUDVUYZ.js} +3 -3
  174. package/dist/cli-bundle/chunks/{chunk-EOGBMLCE.js → chunk-EVMTBV6V.js} +3 -3
  175. package/dist/cli-bundle/chunks/{chunk-RAWA3Y7O.js → chunk-FFMQB7WR.js} +199 -178
  176. package/dist/cli-bundle/chunks/chunk-FFMQB7WR.js.map +1 -0
  177. package/dist/cli-bundle/chunks/{chunk-CG3KP6I5.js → chunk-G7I7DEZA.js} +4 -4
  178. package/dist/cli-bundle/chunks/{chunk-MEXZ5XUM.js → chunk-GJ326ZKX.js} +53 -54
  179. package/dist/cli-bundle/chunks/chunk-GJ326ZKX.js.map +7 -0
  180. package/dist/cli-bundle/chunks/chunk-HPPFYYOV.js +119 -0
  181. package/dist/cli-bundle/chunks/chunk-HPPFYYOV.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{chunk-OF7V47P3.js → chunk-HXTQJXWT.js} +2172 -2146
  183. package/dist/cli-bundle/chunks/chunk-HXTQJXWT.js.map +1 -0
  184. package/dist/cli-bundle/chunks/{chunk-F4BNR2IN.js → chunk-HYTGA6GI.js} +3 -3
  185. package/dist/cli-bundle/chunks/{chunk-2WCYE3IF.js → chunk-HZZEHPRG.js} +2 -2
  186. package/dist/cli-bundle/chunks/chunk-IBMFIKVS.js +14 -0
  187. package/dist/cli-bundle/chunks/chunk-IBMFIKVS.js.map +1 -0
  188. package/dist/cli-bundle/chunks/{chunk-YV2OSAMS.js → chunk-IJYK2T43.js} +2 -2
  189. package/dist/cli-bundle/chunks/{chunk-4XDGYFHL.js → chunk-IPYBJWTE.js} +10 -14
  190. package/dist/cli-bundle/chunks/{chunk-4XDGYFHL.js.map → chunk-IPYBJWTE.js.map} +1 -1
  191. package/dist/cli-bundle/chunks/{chunk-6EBNFQOR.js → chunk-IZBR4NRW.js} +10 -14
  192. package/dist/cli-bundle/chunks/{chunk-6EBNFQOR.js.map → chunk-IZBR4NRW.js.map} +1 -1
  193. package/dist/cli-bundle/chunks/{chunk-VFJYVXHL.js → chunk-JLM7BHI7.js} +7 -9
  194. package/dist/cli-bundle/chunks/{chunk-VFJYVXHL.js.map → chunk-JLM7BHI7.js.map} +1 -1
  195. package/dist/cli-bundle/chunks/{chunk-6EL7SW5C.js → chunk-JMP4E6D7.js} +114 -122
  196. package/dist/cli-bundle/chunks/chunk-JMP4E6D7.js.map +7 -0
  197. package/dist/cli-bundle/chunks/{chunk-QOUOMPHO.js → chunk-JPECA746.js} +2 -2
  198. package/dist/cli-bundle/chunks/{chunk-KJZOSF7J.js → chunk-JSU5P7VS.js} +100 -35
  199. package/dist/cli-bundle/chunks/chunk-JSU5P7VS.js.map +1 -0
  200. package/dist/cli-bundle/chunks/{context-55VEOYI3.js → chunk-JWXRETDF.js} +79 -82
  201. package/dist/cli-bundle/chunks/chunk-JWXRETDF.js.map +1 -0
  202. package/dist/cli-bundle/chunks/{chunk-OQ2E64FH.js → chunk-KNPEF7QG.js} +4 -4
  203. package/dist/cli-bundle/chunks/{chunk-3BKH2CL3.js → chunk-L5OEFZQG.js} +3 -3
  204. package/dist/cli-bundle/chunks/{chunk-DTABLLVE.js → chunk-LB6TP6MC.js} +5 -7
  205. package/dist/cli-bundle/chunks/{chunk-DTABLLVE.js.map → chunk-LB6TP6MC.js.map} +2 -2
  206. package/dist/cli-bundle/chunks/{chunk-TSI32UEL.js → chunk-MAUKX7JC.js} +6 -8
  207. package/dist/cli-bundle/chunks/{chunk-TSI32UEL.js.map → chunk-MAUKX7JC.js.map} +1 -1
  208. package/dist/cli-bundle/chunks/{chunk-SMXSDY7J.js → chunk-MDPEOIGN.js} +2221 -2172
  209. package/dist/cli-bundle/chunks/chunk-MDPEOIGN.js.map +7 -0
  210. package/dist/cli-bundle/chunks/{chunk-5S4ZGDB2.js → chunk-N74UMG5H.js} +2 -2
  211. package/dist/cli-bundle/chunks/{chunk-IXAZI443.js → chunk-NFDPYAIP.js} +2 -2
  212. package/dist/cli-bundle/chunks/{chunk-SKC4UTRP.js → chunk-NKZAN7BD.js} +3 -3
  213. package/dist/cli-bundle/chunks/chunk-NOLPZMSV.js +116 -0
  214. package/dist/cli-bundle/chunks/chunk-NOLPZMSV.js.map +1 -0
  215. package/dist/cli-bundle/chunks/{chunk-L7UXKP2I.js → chunk-NU2UEROZ.js} +1257 -1029
  216. package/dist/cli-bundle/chunks/chunk-NU2UEROZ.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-HBAEFWX3.js → chunk-NUHHPVVS.js} +65 -335
  218. package/dist/cli-bundle/chunks/chunk-NUHHPVVS.js.map +7 -0
  219. package/dist/cli-bundle/chunks/{chunk-JPJDP4VU.js → chunk-NWMZWYYB.js} +2 -2
  220. package/dist/cli-bundle/chunks/{chunk-MWMHZOZZ.js → chunk-OGXLACHC.js} +10 -14
  221. package/dist/cli-bundle/chunks/{chunk-MWMHZOZZ.js.map → chunk-OGXLACHC.js.map} +1 -1
  222. package/dist/cli-bundle/chunks/chunk-OKQ22KTH.js +379 -0
  223. package/dist/cli-bundle/chunks/chunk-OKQ22KTH.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-KKX4Z2SE.js → chunk-OTUHB4HS.js} +4 -4
  225. package/dist/cli-bundle/chunks/{chunk-ZLWRPBOW.js → chunk-QCWF6IYD.js} +510 -364
  226. package/dist/cli-bundle/chunks/chunk-QCWF6IYD.js.map +1 -0
  227. package/dist/cli-bundle/chunks/{chunk-PRVTGX64.js → chunk-RGEMWD6Q.js} +11 -23
  228. package/dist/cli-bundle/chunks/chunk-RGEMWD6Q.js.map +7 -0
  229. package/dist/cli-bundle/chunks/chunk-RH5ZBYFD.js +809 -0
  230. package/dist/cli-bundle/chunks/chunk-RH5ZBYFD.js.map +7 -0
  231. package/dist/cli-bundle/chunks/{chunk-ALQKV6U7.js → chunk-RLDHZHQS.js} +12 -16
  232. package/dist/cli-bundle/chunks/{chunk-ALQKV6U7.js.map → chunk-RLDHZHQS.js.map} +1 -1
  233. package/dist/cli-bundle/chunks/{schema-C6QA367T.js → chunk-RMMQ74TG.js} +144 -67
  234. package/dist/cli-bundle/chunks/chunk-RMMQ74TG.js.map +7 -0
  235. package/dist/cli-bundle/chunks/{chunk-EYPINTFR.js → chunk-RVUALSJF.js} +1516 -753
  236. package/dist/cli-bundle/chunks/chunk-RVUALSJF.js.map +7 -0
  237. package/dist/cli-bundle/chunks/chunk-SDR5J34Q.js +2468 -0
  238. package/dist/cli-bundle/chunks/chunk-SDR5J34Q.js.map +7 -0
  239. package/dist/cli-bundle/chunks/{chunk-WB5BYQMF.js → chunk-SLMUGTK3.js} +4 -4
  240. package/dist/cli-bundle/chunks/{chunk-SUREE24M.js → chunk-TP5Q5ZD3.js} +12 -24
  241. package/dist/cli-bundle/chunks/chunk-TP5Q5ZD3.js.map +1 -0
  242. package/dist/cli-bundle/chunks/{chunk-UACWNBL2.js → chunk-UYUYDGIB.js} +7 -9
  243. package/dist/cli-bundle/chunks/{chunk-UACWNBL2.js.map → chunk-UYUYDGIB.js.map} +1 -1
  244. package/dist/cli-bundle/chunks/{chunk-V4UYNSEM.js → chunk-UZIWVBE6.js} +6 -8
  245. package/dist/cli-bundle/chunks/{chunk-V4UYNSEM.js.map → chunk-UZIWVBE6.js.map} +1 -1
  246. package/dist/cli-bundle/chunks/{chunk-EWRSXOIZ.js → chunk-V3NOKJF2.js} +11 -13
  247. package/dist/cli-bundle/chunks/{chunk-EWRSXOIZ.js.map → chunk-V3NOKJF2.js.map} +1 -1
  248. package/dist/cli-bundle/chunks/{chunk-XXKV4UWE.js → chunk-VARHOHYV.js} +571 -507
  249. package/dist/cli-bundle/chunks/chunk-VARHOHYV.js.map +7 -0
  250. package/dist/cli-bundle/chunks/{chunk-AEACLRVH.js → chunk-VICZWYGZ.js} +18 -11
  251. package/dist/cli-bundle/chunks/chunk-VICZWYGZ.js.map +7 -0
  252. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js +84 -0
  253. package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js.map +1 -0
  254. package/dist/cli-bundle/chunks/chunk-VZDBVEZR.js +382 -0
  255. package/dist/cli-bundle/chunks/chunk-VZDBVEZR.js.map +7 -0
  256. package/dist/cli-bundle/chunks/{chunk-GDUMGZK3.js → chunk-W4ULYO7Z.js} +11 -13
  257. package/dist/cli-bundle/chunks/{chunk-GDUMGZK3.js.map → chunk-W4ULYO7Z.js.map} +1 -1
  258. package/dist/cli-bundle/chunks/{chunk-I6QMJ2XT.js → chunk-WYDHYJPO.js} +2 -2
  259. package/dist/cli-bundle/chunks/{chunk-ALKFCIIB.js → chunk-YITK2PJ6.js} +9 -11
  260. package/dist/cli-bundle/chunks/{chunk-ALKFCIIB.js.map → chunk-YITK2PJ6.js.map} +1 -1
  261. package/dist/cli-bundle/chunks/chunk-YJIEJRZB.js +84 -0
  262. package/dist/cli-bundle/chunks/chunk-YJIEJRZB.js.map +1 -0
  263. package/dist/cli-bundle/chunks/{chunk-LNEDHJNQ.js → chunk-ZETXE4SE.js} +66 -329
  264. package/dist/cli-bundle/chunks/chunk-ZETXE4SE.js.map +1 -0
  265. package/dist/cli-bundle/chunks/{chunk-KIEAK7YE.js → chunk-ZRP4VG5U.js} +2 -2
  266. package/dist/cli-bundle/chunks/{claim-FZZZCAY6.js → claim-EMQLYPRW.js} +10 -12
  267. package/dist/cli-bundle/chunks/{claim-FZZZCAY6.js.map → claim-EMQLYPRW.js.map} +1 -1
  268. package/dist/cli-bundle/chunks/{claim-XK5QBZE3.js → claim-T3GCKV7C.js} +8 -10
  269. package/dist/cli-bundle/chunks/{claim-XK5QBZE3.js.map → claim-T3GCKV7C.js.map} +1 -1
  270. package/dist/cli-bundle/chunks/close-E6ZZGCJY.js +14 -0
  271. package/dist/cli-bundle/chunks/{close-QHMVWM7M.js → close-TQYAAFJP.js} +7 -8
  272. package/dist/cli-bundle/chunks/{close-many-OIXJE2JZ.js → close-many-BG5QQIDQ.js} +16 -18
  273. package/dist/cli-bundle/chunks/{close-many-OIXJE2JZ.js.map → close-many-BG5QQIDQ.js.map} +1 -1
  274. package/dist/cli-bundle/chunks/{close-many-SUU5BS2C.js → close-many-LDRVEQY2.js} +18 -20
  275. package/dist/cli-bundle/chunks/{close-many-SUU5BS2C.js.map → close-many-LDRVEQY2.js.map} +1 -1
  276. package/dist/cli-bundle/chunks/{comments-5YM62D75.js → comments-QCKR2YY2.js} +11 -13
  277. package/dist/cli-bundle/chunks/{comments-5YM62D75.js.map → comments-QCKR2YY2.js.map} +1 -1
  278. package/dist/cli-bundle/chunks/{comments-RH3IBIRH.js → comments-YUXJRZPQ.js} +9 -11
  279. package/dist/cli-bundle/chunks/{comments-RH3IBIRH.js.map → comments-YUXJRZPQ.js.map} +1 -1
  280. package/dist/cli-bundle/chunks/{config-NCNNWF6R.js → config-DMSU64QO.js} +18 -387
  281. package/dist/cli-bundle/chunks/config-DMSU64QO.js.map +7 -0
  282. package/dist/cli-bundle/chunks/{config-SW3U7XP2.js → config-QH2DICD6.js} +18 -380
  283. package/dist/cli-bundle/chunks/config-QH2DICD6.js.map +1 -0
  284. package/dist/cli-bundle/chunks/context-B6275WPX.js +46 -0
  285. package/dist/cli-bundle/chunks/context-OCZ3FJ4Z.js +42 -0
  286. package/dist/cli-bundle/chunks/{contracts-SY6PDFIK.js → contracts-HN7ABKLP.js} +72 -15
  287. package/dist/cli-bundle/chunks/contracts-HN7ABKLP.js.map +7 -0
  288. package/dist/cli-bundle/chunks/{contracts-JXFGBOYT.js → contracts-W4FZVVD6.js} +72 -15
  289. package/dist/cli-bundle/chunks/contracts-W4FZVVD6.js.map +1 -0
  290. package/dist/cli-bundle/chunks/{copy-N3GE6FYS.js → copy-BTJOSKKT.js} +7 -11
  291. package/dist/cli-bundle/chunks/{copy-N3GE6FYS.js.map → copy-BTJOSKKT.js.map} +1 -1
  292. package/dist/cli-bundle/chunks/{copy-IEDBJOOX.js → copy-DEM4DATS.js} +9 -13
  293. package/dist/cli-bundle/chunks/{copy-IEDBJOOX.js.map → copy-DEM4DATS.js.map} +1 -1
  294. package/dist/cli-bundle/chunks/create-OH3BDGBB.js +28 -0
  295. package/dist/cli-bundle/chunks/{create-O4VONGPG.js → create-RLRJMRTM.js} +12 -14
  296. package/dist/cli-bundle/chunks/{delete-LPEIF7RU.js → delete-BHK7VB2Z.js} +5 -7
  297. package/dist/cli-bundle/chunks/{delete-LPEIF7RU.js.map → delete-BHK7VB2Z.js.map} +1 -1
  298. package/dist/cli-bundle/chunks/{delete-724EQ6OS.js → delete-LSVHAB4Y.js} +7 -9
  299. package/dist/cli-bundle/chunks/{delete-724EQ6OS.js.map → delete-LSVHAB4Y.js.map} +1 -1
  300. package/dist/cli-bundle/chunks/{deps-RSBU4SIU.js → deps-4UDFJRUA.js} +8 -11
  301. package/dist/cli-bundle/chunks/{deps-RSBU4SIU.js.map → deps-4UDFJRUA.js.map} +1 -1
  302. package/dist/cli-bundle/chunks/{deps-T3Y6Y7RT.js → deps-XHYXWEPT.js} +6 -9
  303. package/dist/cli-bundle/chunks/{deps-T3Y6Y7RT.js.map → deps-XHYXWEPT.js.map} +1 -1
  304. package/dist/cli-bundle/chunks/{docs-IFS7HZPP.js → docs-26S44RXU.js} +8 -9
  305. package/dist/cli-bundle/chunks/{docs-IFS7HZPP.js.map → docs-26S44RXU.js.map} +1 -1
  306. package/dist/cli-bundle/chunks/{docs-75ZLCO3G.js → docs-GYZNVS26.js} +10 -11
  307. package/dist/cli-bundle/chunks/{docs-75ZLCO3G.js.map → docs-GYZNVS26.js.map} +1 -1
  308. package/dist/cli-bundle/chunks/{eval-L2KD7W3M.js → eval-PGRVIJQU.js} +12 -14
  309. package/dist/cli-bundle/chunks/{eval-L2KD7W3M.js.map → eval-PGRVIJQU.js.map} +1 -1
  310. package/dist/cli-bundle/chunks/{eval-QGR7JCQO.js → eval-UYF3ZPVO.js} +10 -12
  311. package/dist/cli-bundle/chunks/{eval-QGR7JCQO.js.map → eval-UYF3ZPVO.js.map} +1 -1
  312. package/dist/cli-bundle/chunks/{extension-YQF4CPIR.js → extension-CPSLJQVE.js} +12 -7
  313. package/dist/cli-bundle/chunks/{extension-3JYWJ5K2.js → extension-CXJ6RELI.js} +12 -7
  314. package/dist/cli-bundle/chunks/{files-EPEJMJHQ.js → files-MBNICQFM.js} +9 -11
  315. package/dist/cli-bundle/chunks/{files-EPEJMJHQ.js.map → files-MBNICQFM.js.map} +1 -1
  316. package/dist/cli-bundle/chunks/{files-5BQWDRDT.js → files-NQHEXUZD.js} +11 -13
  317. package/dist/cli-bundle/chunks/{files-5BQWDRDT.js.map → files-NQHEXUZD.js.map} +1 -1
  318. package/dist/cli-bundle/chunks/{focus-RWGKD76E.js → focus-DWYIG7GU.js} +10 -14
  319. package/dist/cli-bundle/chunks/{focus-RWGKD76E.js.map → focus-DWYIG7GU.js.map} +1 -1
  320. package/dist/cli-bundle/chunks/{focus-DQVJAPOE.js → focus-XZW5423D.js} +8 -12
  321. package/dist/cli-bundle/chunks/{focus-DQVJAPOE.js.map → focus-XZW5423D.js.map} +1 -1
  322. package/dist/cli-bundle/chunks/{gc-BEJMQT64.js → gc-7GQYOS2G.js} +3 -3
  323. package/dist/cli-bundle/chunks/{gc-JEFQDJPA.js → gc-LPVMKJQJ.js} +3 -3
  324. package/dist/cli-bundle/chunks/{get-LQG6PEVG.js → get-A7MAOHCU.js} +10 -13
  325. package/dist/cli-bundle/chunks/{get-LQG6PEVG.js.map → get-A7MAOHCU.js.map} +1 -1
  326. package/dist/cli-bundle/chunks/{get-WVN75H42.js → get-DSDEKJ3L.js} +12 -15
  327. package/dist/cli-bundle/chunks/{get-WVN75H42.js.map → get-DSDEKJ3L.js.map} +1 -1
  328. package/dist/cli-bundle/chunks/{health-JJJOY7DJ.js → health-3IPFLKXB.js} +17 -17
  329. package/dist/cli-bundle/chunks/{health-P67NZ6TT.js → health-GZXGBZ36.js} +17 -17
  330. package/dist/cli-bundle/chunks/{history-RUKPKNY7.js → history-NERDJNUB.js} +8 -10
  331. package/dist/cli-bundle/chunks/history-WSZHY3PN.js +18 -0
  332. package/dist/cli-bundle/chunks/{history-compact-NQ7VPRVT.js → history-compact-2WRZ2WK4.js} +11 -14
  333. package/dist/cli-bundle/chunks/{history-compact-NQ7VPRVT.js.map → history-compact-2WRZ2WK4.js.map} +1 -1
  334. package/dist/cli-bundle/chunks/{history-compact-ZAOWR7GD.js → history-compact-HR7BB4LR.js} +13 -16
  335. package/dist/cli-bundle/chunks/{history-compact-ZAOWR7GD.js.map → history-compact-HR7BB4LR.js.map} +1 -1
  336. package/dist/cli-bundle/chunks/history-redact-MP6CH7U5.js +19 -0
  337. package/dist/cli-bundle/chunks/{history-redact-YY4XYVEP.js → history-redact-O3NBCNWC.js} +9 -11
  338. package/dist/cli-bundle/chunks/{history-repair-EHL4ODQY.js → history-repair-LCMOS45X.js} +11 -14
  339. package/dist/cli-bundle/chunks/{history-repair-EHL4ODQY.js.map → history-repair-LCMOS45X.js.map} +1 -1
  340. package/dist/cli-bundle/chunks/{history-repair-YSQH6SY6.js → history-repair-XA3LC4GA.js} +13 -16
  341. package/dist/cli-bundle/chunks/{history-repair-YSQH6SY6.js.map → history-repair-XA3LC4GA.js.map} +1 -1
  342. package/dist/cli-bundle/chunks/{init-HBFGYS66.js → init-64XDLQJB.js} +12 -11
  343. package/dist/cli-bundle/chunks/init-PAX32BJA.js +22 -0
  344. package/dist/cli-bundle/chunks/{learnings-KFQO7GEZ.js → learnings-JR6MA5TI.js} +9 -11
  345. package/dist/cli-bundle/chunks/{learnings-KFQO7GEZ.js.map → learnings-JR6MA5TI.js.map} +1 -1
  346. package/dist/cli-bundle/chunks/{learnings-J555ZFPD.js → learnings-LPKCSJX7.js} +11 -13
  347. package/dist/cli-bundle/chunks/{learnings-J555ZFPD.js.map → learnings-LPKCSJX7.js.map} +1 -1
  348. package/dist/cli-bundle/chunks/{list-C7R33MD5.js → list-DNBJVO3E.js} +10 -10
  349. package/dist/cli-bundle/chunks/{list-DSN6UNFB.js → list-G5Y65VF6.js} +10 -10
  350. package/dist/cli-bundle/chunks/next-BCERKDUR.js +277 -0
  351. package/dist/cli-bundle/chunks/next-BCERKDUR.js.map +7 -0
  352. package/dist/cli-bundle/chunks/next-FYTQF6HG.js +274 -0
  353. package/dist/cli-bundle/chunks/next-FYTQF6HG.js.map +1 -0
  354. package/dist/cli-bundle/chunks/{notes-V4VNIQL4.js → notes-2BMU3VVQ.js} +9 -11
  355. package/dist/cli-bundle/chunks/{notes-V4VNIQL4.js.map → notes-2BMU3VVQ.js.map} +1 -1
  356. package/dist/cli-bundle/chunks/{notes-VYJFN2A3.js → notes-6KTGO2OJ.js} +11 -13
  357. package/dist/cli-bundle/chunks/{notes-VYJFN2A3.js.map → notes-6KTGO2OJ.js.map} +1 -1
  358. package/dist/cli-bundle/chunks/{plan-RBHQ5PO7.js → plan-4WXEQCTN.js} +15 -18
  359. package/dist/cli-bundle/chunks/{plan-RBHQ5PO7.js.map → plan-4WXEQCTN.js.map} +1 -1
  360. package/dist/cli-bundle/chunks/{plan-DHRSVSHR.js → plan-RKZHQVXR.js} +17 -20
  361. package/dist/cli-bundle/chunks/{plan-DHRSVSHR.js.map → plan-RKZHQVXR.js.map} +1 -1
  362. package/dist/cli-bundle/chunks/profile-4OMM32CD.js +1235 -0
  363. package/dist/cli-bundle/chunks/profile-4OMM32CD.js.map +7 -0
  364. package/dist/cli-bundle/chunks/profile-QLER5ENE.js +1197 -0
  365. package/dist/cli-bundle/chunks/profile-QLER5ENE.js.map +1 -0
  366. package/dist/cli-bundle/chunks/{register-list-query-OM3E2KMY.js → register-list-query-7LV46VAU.js} +45 -21
  367. package/dist/cli-bundle/chunks/register-list-query-7LV46VAU.js.map +1 -0
  368. package/dist/cli-bundle/chunks/{register-list-query-CCMHGZTF.js → register-list-query-SNG5PGA4.js} +44 -20
  369. package/dist/cli-bundle/chunks/register-list-query-SNG5PGA4.js.map +7 -0
  370. package/dist/cli-bundle/chunks/{register-mutation-N3CDEGZU.js → register-mutation-ENNDUAZG.js} +106 -40
  371. package/dist/cli-bundle/chunks/register-mutation-ENNDUAZG.js.map +1 -0
  372. package/dist/cli-bundle/chunks/{register-mutation-UXTTWL6N.js → register-mutation-KK7PHYYU.js} +105 -39
  373. package/dist/cli-bundle/chunks/register-mutation-KK7PHYYU.js.map +7 -0
  374. package/dist/cli-bundle/chunks/{register-operations-UDIFMQKD.js → register-operations-C6OWLDSH.js} +32 -34
  375. package/dist/cli-bundle/chunks/{register-operations-UDIFMQKD.js.map → register-operations-C6OWLDSH.js.map} +1 -1
  376. package/dist/cli-bundle/chunks/{register-operations-R2FLOCRI.js → register-operations-HZ6XERQG.js} +30 -32
  377. package/dist/cli-bundle/chunks/{register-operations-R2FLOCRI.js.map → register-operations-HZ6XERQG.js.map} +1 -1
  378. package/dist/cli-bundle/chunks/{register-setup-G5LTSFYK.js → register-setup-P67EMBDJ.js} +68 -25
  379. package/dist/cli-bundle/chunks/register-setup-P67EMBDJ.js.map +1 -0
  380. package/dist/cli-bundle/chunks/{register-setup-TWHKICM2.js → register-setup-ZKJ53RS7.js} +67 -24
  381. package/dist/cli-bundle/chunks/register-setup-ZKJ53RS7.js.map +7 -0
  382. package/dist/cli-bundle/chunks/{restore-LL2WLEDG.js → restore-4MHZFJ2E.js} +9 -11
  383. package/dist/cli-bundle/chunks/restore-YALDGTQR.js +17 -0
  384. package/dist/cli-bundle/chunks/{scheduling-shortcuts-M4H2ZI64.js → scheduling-shortcuts-LB6DOLRL.js} +14 -16
  385. package/dist/cli-bundle/chunks/{scheduling-shortcuts-M4H2ZI64.js.map → scheduling-shortcuts-LB6DOLRL.js.map} +1 -1
  386. package/dist/cli-bundle/chunks/{scheduling-shortcuts-255GI3BU.js → scheduling-shortcuts-UTOYKLXQ.js} +12 -14
  387. package/dist/cli-bundle/chunks/{scheduling-shortcuts-255GI3BU.js.map → scheduling-shortcuts-UTOYKLXQ.js.map} +1 -1
  388. package/dist/cli-bundle/chunks/schema-73HR2OJW.js +75 -0
  389. package/dist/cli-bundle/chunks/schema-U6LJKSIR.js +71 -0
  390. package/dist/cli-bundle/chunks/{search-2EI6EAXH.js → search-AXPXKZER.js} +10 -12
  391. package/dist/cli-bundle/chunks/{search-QBFBLQRO.js → search-KILGT37L.js} +10 -12
  392. package/dist/cli-bundle/chunks/{stats-TKC6CAKB.js → stats-PSYVVTNZ.js} +21 -13
  393. package/dist/cli-bundle/chunks/stats-PSYVVTNZ.js.map +1 -0
  394. package/dist/cli-bundle/chunks/{stats-TCW2SZQG.js → stats-W5KNVJWQ.js} +20 -12
  395. package/dist/cli-bundle/chunks/stats-W5KNVJWQ.js.map +7 -0
  396. package/dist/cli-bundle/chunks/{telemetry-BT2VSWU2.js → telemetry-BZUF6H7G.js} +4 -4
  397. package/dist/cli-bundle/chunks/{telemetry-LQ6FRTUT.js → telemetry-GAHHQTOS.js} +4 -4
  398. package/dist/cli-bundle/chunks/test-ACD52Z3S.js +35 -0
  399. package/dist/cli-bundle/chunks/test-ACD52Z3S.js.map +7 -0
  400. package/dist/cli-bundle/chunks/{test-NV2DRPUS.js → test-PWDIZ255.js} +15 -16
  401. package/dist/cli-bundle/chunks/test-PWDIZ255.js.map +1 -0
  402. package/dist/cli-bundle/chunks/{test-all-DZ76VTPQ.js → test-all-L2MDDUCA.js} +20 -22
  403. package/dist/cli-bundle/chunks/{test-all-DZ76VTPQ.js.map → test-all-L2MDDUCA.js.map} +1 -1
  404. package/dist/cli-bundle/chunks/{test-all-REW67LXT.js → test-all-RBZ6DLU2.js} +18 -20
  405. package/dist/cli-bundle/chunks/{test-all-REW67LXT.js.map → test-all-RBZ6DLU2.js.map} +1 -1
  406. package/dist/cli-bundle/chunks/{test-runs-PX73DMMI.js → test-runs-PLRAZEFW.js} +5 -6
  407. package/dist/cli-bundle/chunks/test-runs-PLRAZEFW.js.map +7 -0
  408. package/dist/cli-bundle/chunks/{test-runs-FQ5WNQLP.js → test-runs-UXIXPDKU.js} +6 -7
  409. package/dist/cli-bundle/chunks/test-runs-UXIXPDKU.js.map +1 -0
  410. package/dist/cli-bundle/chunks/update-AMRSOIWP.js +24 -0
  411. package/dist/cli-bundle/chunks/update-AMRSOIWP.js.map +7 -0
  412. package/dist/cli-bundle/chunks/update-KFX2SIAC.js +28 -0
  413. package/dist/cli-bundle/chunks/update-KFX2SIAC.js.map +1 -0
  414. package/dist/cli-bundle/chunks/{update-many-Q5ZEI64S.js → update-many-RNSBX2TA.js} +35 -36
  415. package/dist/cli-bundle/chunks/{update-many-Q5ZEI64S.js.map → update-many-RNSBX2TA.js.map} +1 -1
  416. package/dist/cli-bundle/chunks/{update-many-2ILP6E4Y.js → update-many-Z5GJS5LC.js} +33 -34
  417. package/dist/cli-bundle/chunks/{update-many-2ILP6E4Y.js.map → update-many-Z5GJS5LC.js.map} +1 -1
  418. package/dist/cli-bundle/chunks/{upgrade-FOZKQTQF.js → upgrade-BRL6KCOJ.js} +13 -8
  419. package/dist/cli-bundle/chunks/{upgrade-FOZKQTQF.js.map → upgrade-BRL6KCOJ.js.map} +1 -1
  420. package/dist/cli-bundle/chunks/{upgrade-DHL74PQH.js → upgrade-HAK6JG2O.js} +11 -6
  421. package/dist/cli-bundle/chunks/{upgrade-DHL74PQH.js.map → upgrade-HAK6JG2O.js.map} +1 -1
  422. package/dist/cli-bundle/chunks/{validate-HYZNIB6W.js → validate-MTUVL5VC.js} +38 -28
  423. package/dist/cli-bundle/chunks/validate-MTUVL5VC.js.map +7 -0
  424. package/dist/cli-bundle/chunks/{validate-54SYJ7QW.js → validate-X5W76YJL.js} +39 -29
  425. package/dist/cli-bundle/chunks/validate-X5W76YJL.js.map +1 -0
  426. package/dist/cli-bundle/main.js +95 -724
  427. package/dist/cli-bundle/main.js.map +4 -4
  428. package/dist/core/config/positional-value.d.ts +2 -0
  429. package/dist/core/config/positional-value.js +2 -2
  430. package/dist/core/config/positional-value.js.map +1 -1
  431. package/dist/core/extensions/activation-summary-markdown.d.ts +71 -0
  432. package/dist/core/extensions/activation-summary-markdown.js +151 -0
  433. package/dist/core/extensions/activation-summary-markdown.js.map +1 -0
  434. package/dist/core/extensions/activation-summary.d.ts +2 -0
  435. package/dist/core/extensions/activation-summary.js +3 -2
  436. package/dist/core/extensions/activation-summary.js.map +1 -1
  437. package/dist/core/extensions/capability-usage.d.ts +1 -1
  438. package/dist/core/extensions/capability-usage.js +4 -3
  439. package/dist/core/extensions/capability-usage.js.map +1 -1
  440. package/dist/core/extensions/extension-policy.d.ts +18 -3
  441. package/dist/core/extensions/extension-policy.js +116 -106
  442. package/dist/core/extensions/extension-policy.js.map +1 -1
  443. package/dist/core/extensions/extension-registries.js +3 -2
  444. package/dist/core/extensions/extension-registries.js.map +1 -1
  445. package/dist/core/extensions/extension-types.d.ts +21 -1
  446. package/dist/core/extensions/extension-types.js +3 -2
  447. package/dist/core/extensions/extension-types.js.map +1 -1
  448. package/dist/core/extensions/loader.js +439 -232
  449. package/dist/core/extensions/loader.js.map +1 -1
  450. package/dist/core/fs/fs-utils.js +27 -2
  451. package/dist/core/fs/fs-utils.js.map +1 -1
  452. package/dist/core/item/actionability.d.ts +57 -0
  453. package/dist/core/item/actionability.js +178 -0
  454. package/dist/core/item/actionability.js.map +1 -0
  455. package/dist/core/item/item-format.js +523 -410
  456. package/dist/core/item/item-format.js.map +1 -1
  457. package/dist/core/item/type-registry.js +18 -45
  458. package/dist/core/item/type-registry.js.map +1 -1
  459. package/dist/core/profile/profile-describe.d.ts +64 -0
  460. package/dist/core/profile/profile-describe.js +83 -0
  461. package/dist/core/profile/profile-describe.js.map +1 -0
  462. package/dist/core/profile/profile-lint.d.ts +53 -0
  463. package/dist/core/profile/profile-lint.js +422 -0
  464. package/dist/core/profile/profile-lint.js.map +1 -0
  465. package/dist/core/profile/profile-plan.d.ts +145 -0
  466. package/dist/core/profile/profile-plan.js +0 -0
  467. package/dist/core/profile/profile-plan.js.map +1 -0
  468. package/dist/core/profile/profile-presets.d.ts +218 -0
  469. package/dist/core/profile/profile-presets.js +325 -0
  470. package/dist/core/profile/profile-presets.js.map +1 -0
  471. package/dist/core/schema/fields-file.js +25 -25
  472. package/dist/core/schema/fields-file.js.map +1 -1
  473. package/dist/core/schema/item-types-file.js +3 -3
  474. package/dist/core/schema/item-types-file.js.map +1 -1
  475. package/dist/core/schema/runtime-schema.js +4 -4
  476. package/dist/core/schema/runtime-schema.js.map +1 -1
  477. package/dist/core/schema/status-defs-file.js +3 -3
  478. package/dist/core/schema/status-defs-file.js.map +1 -1
  479. package/dist/core/shared/serialization.js +83 -62
  480. package/dist/core/shared/serialization.js.map +1 -1
  481. package/dist/core/store/item-store.d.ts +1 -0
  482. package/dist/core/store/item-store.js +16 -8
  483. package/dist/core/store/item-store.js.map +1 -1
  484. package/dist/core/store/paths.js +4 -32
  485. package/dist/core/store/paths.js.map +1 -1
  486. package/dist/core/store/settings.js +14 -14
  487. package/dist/core/store/settings.js.map +1 -1
  488. package/dist/core/telemetry/observability.js +50 -54
  489. package/dist/core/telemetry/observability.js.map +1 -1
  490. package/dist/core/telemetry/runtime.js +11 -2
  491. package/dist/core/telemetry/runtime.js.map +1 -1
  492. package/dist/core/test/background-runs.js +3 -2
  493. package/dist/core/test/background-runs.js.map +1 -1
  494. package/dist/core/validate/linked-artifact-reference.d.ts +24 -0
  495. package/dist/core/validate/linked-artifact-reference.js +41 -0
  496. package/dist/core/validate/linked-artifact-reference.js.map +1 -0
  497. package/dist/mcp/server.js +540 -420
  498. package/dist/mcp/server.js.map +1 -1
  499. package/dist/mcp/tool-definitions.js +33 -2
  500. package/dist/mcp/tool-definitions.js.map +1 -1
  501. package/dist/sdk/cli-contracts/commander-types.d.ts +1 -0
  502. package/dist/sdk/cli-contracts/commander-types.js +15 -2
  503. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  504. package/dist/sdk/cli-contracts/enum-contracts.d.ts +3 -3
  505. package/dist/sdk/cli-contracts/enum-contracts.js +6 -2
  506. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  507. package/dist/sdk/cli-contracts/flag-contracts.d.ts +149 -0
  508. package/dist/sdk/cli-contracts/flag-contracts.js +1514 -0
  509. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -0
  510. package/dist/sdk/cli-contracts/string-lists.d.ts +14 -0
  511. package/dist/sdk/cli-contracts/string-lists.js +20 -0
  512. package/dist/sdk/cli-contracts/string-lists.js.map +1 -0
  513. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -1
  514. package/dist/sdk/cli-contracts/tool-option-contracts.js +51 -109
  515. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  516. package/dist/sdk/cli-contracts/tool-parameter-tables.d.ts +17 -0
  517. package/dist/sdk/cli-contracts/tool-parameter-tables.js +54 -5
  518. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  519. package/dist/sdk/cli-contracts/tool-schema.d.ts +74 -0
  520. package/dist/sdk/cli-contracts/tool-schema.js +871 -0
  521. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -0
  522. package/dist/sdk/cli-contracts.d.ts +13 -193
  523. package/dist/sdk/cli-contracts.js +5 -2277
  524. package/dist/sdk/cli-contracts.js.map +1 -1
  525. package/dist/sdk/compose.d.ts +11 -5
  526. package/dist/sdk/compose.js +240 -124
  527. package/dist/sdk/compose.js.map +1 -1
  528. package/dist/sdk/define.d.ts +14 -0
  529. package/dist/sdk/define.js +17 -2
  530. package/dist/sdk/define.js.map +1 -1
  531. package/dist/sdk/index.d.ts +14 -3
  532. package/dist/sdk/index.js +14 -3
  533. package/dist/sdk/index.js.map +1 -1
  534. package/dist/sdk/testing.d.ts +82 -2
  535. package/dist/sdk/testing.js +74 -3
  536. package/dist/sdk/testing.js.map +1 -1
  537. package/docs/AGENT_GUIDE.md +2 -0
  538. package/docs/CLAUDE_CODE_PLUGIN.md +2 -2
  539. package/docs/COMMANDS.md +37 -0
  540. package/docs/EXTENSIONS.md +12 -13
  541. package/docs/RELEASING.md +8 -4
  542. package/docs/SDK.md +184 -17
  543. package/docs/TESTING.md +12 -0
  544. package/docs/examples/policy-restricted-extension/README.md +6 -0
  545. package/docs/examples/policy-restricted-extension/index.ts +40 -0
  546. package/docs/examples/policy-restricted-extension/manifest.json +2 -2
  547. package/docs/examples/starter-extension/README.md +14 -2
  548. package/docs/examples/starter-extension/{index.js → index.ts} +51 -6
  549. package/docs/examples/starter-extension/manifest.json +2 -2
  550. package/package.json +20 -7
  551. package/packages/pm-beads/extensions/beads/index.ts +3 -3
  552. package/packages/pm-beads/extensions/beads/manifest.json +2 -2
  553. package/packages/pm-beads/extensions/beads/runtime-loader.ts +19 -7
  554. package/packages/pm-beads/extensions/beads/runtime.ts +155 -37
  555. package/packages/pm-calendar/extensions/calendar/index.ts +3 -3
  556. package/packages/pm-calendar/extensions/calendar/manifest.json +2 -2
  557. package/packages/pm-calendar/extensions/calendar/runtime.ts +2 -2
  558. package/packages/pm-command-kit/extensions/command-kit/index.ts +1 -1
  559. package/packages/pm-command-kit/extensions/command-kit/manifest.json +2 -2
  560. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +2 -2
  561. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +2 -2
  562. package/packages/pm-governance-audit/extensions/governance-audit/runtime.ts +1 -1
  563. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +2 -2
  564. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +2 -2
  565. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +1 -1
  566. package/packages/pm-kanban/README.md +97 -0
  567. package/packages/pm-kanban/extensions/kanban/index.ts +191 -0
  568. package/packages/pm-kanban/extensions/kanban/manifest.json +19 -0
  569. package/packages/pm-kanban/package.json +57 -0
  570. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +1 -1
  571. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +2 -2
  572. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.ts +2 -2
  573. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +2 -2
  574. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.ts +1 -1
  575. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +2 -2
  576. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +2 -2
  577. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +1 -1
  578. package/packages/pm-templates/extensions/templates/index.ts +2 -2
  579. package/packages/pm-templates/extensions/templates/manifest.json +2 -2
  580. package/packages/pm-templates/extensions/templates/runtime.ts +1 -1
  581. package/packages/pm-todos/extensions/todos/index.ts +3 -3
  582. package/packages/pm-todos/extensions/todos/manifest.json +2 -2
  583. package/packages/pm-todos/extensions/todos/runtime-loader.ts +19 -7
  584. package/packages/pm-todos/extensions/todos/runtime.ts +177 -43
  585. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +2 -2
  586. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +2 -2
  587. package/scripts/bundle-cli.mjs +1 -1
  588. package/dist/cli-bundle/chunks/activity-54TXGJ2T.js +0 -18
  589. package/dist/cli-bundle/chunks/aggregate-63NWNIBR.js.map +0 -1
  590. package/dist/cli-bundle/chunks/aggregate-YHCYX2EV.js.map +0 -7
  591. package/dist/cli-bundle/chunks/chunk-6EL7SW5C.js.map +0 -7
  592. package/dist/cli-bundle/chunks/chunk-6W3Y65PL.js.map +0 -7
  593. package/dist/cli-bundle/chunks/chunk-AEACLRVH.js.map +0 -7
  594. package/dist/cli-bundle/chunks/chunk-B74BP6IS.js +0 -78
  595. package/dist/cli-bundle/chunks/chunk-B74BP6IS.js.map +0 -7
  596. package/dist/cli-bundle/chunks/chunk-BFFO3AIB.js.map +0 -1
  597. package/dist/cli-bundle/chunks/chunk-C4C3EJCJ.js.map +0 -7
  598. package/dist/cli-bundle/chunks/chunk-EYPINTFR.js.map +0 -7
  599. package/dist/cli-bundle/chunks/chunk-FBLT6WGK.js +0 -75
  600. package/dist/cli-bundle/chunks/chunk-FBLT6WGK.js.map +0 -1
  601. package/dist/cli-bundle/chunks/chunk-GQYJEEFX.js.map +0 -1
  602. package/dist/cli-bundle/chunks/chunk-HBAEFWX3.js.map +0 -7
  603. package/dist/cli-bundle/chunks/chunk-HC2S36NB.js.map +0 -1
  604. package/dist/cli-bundle/chunks/chunk-IAP5KYBQ.js.map +0 -1
  605. package/dist/cli-bundle/chunks/chunk-INPHFO33.js +0 -764
  606. package/dist/cli-bundle/chunks/chunk-INPHFO33.js.map +0 -7
  607. package/dist/cli-bundle/chunks/chunk-IOT6WRL5.js +0 -86
  608. package/dist/cli-bundle/chunks/chunk-IOT6WRL5.js.map +0 -7
  609. package/dist/cli-bundle/chunks/chunk-ISEKN64V.js +0 -35
  610. package/dist/cli-bundle/chunks/chunk-ISEKN64V.js.map +0 -7
  611. package/dist/cli-bundle/chunks/chunk-J3NMWFIN.js +0 -115
  612. package/dist/cli-bundle/chunks/chunk-J3NMWFIN.js.map +0 -1
  613. package/dist/cli-bundle/chunks/chunk-J7I4C5ZB.js.map +0 -7
  614. package/dist/cli-bundle/chunks/chunk-JKL6HRMV.js.map +0 -7
  615. package/dist/cli-bundle/chunks/chunk-KJZOSF7J.js.map +0 -1
  616. package/dist/cli-bundle/chunks/chunk-L7UXKP2I.js.map +0 -1
  617. package/dist/cli-bundle/chunks/chunk-LNEDHJNQ.js.map +0 -1
  618. package/dist/cli-bundle/chunks/chunk-M6TUBOGW.js.map +0 -1
  619. package/dist/cli-bundle/chunks/chunk-MEXZ5XUM.js.map +0 -7
  620. package/dist/cli-bundle/chunks/chunk-N5B6WZC5.js.map +0 -1
  621. package/dist/cli-bundle/chunks/chunk-NJ73ALW2.js +0 -761
  622. package/dist/cli-bundle/chunks/chunk-NJ73ALW2.js.map +0 -1
  623. package/dist/cli-bundle/chunks/chunk-NVXGVEFD.js +0 -83
  624. package/dist/cli-bundle/chunks/chunk-NVXGVEFD.js.map +0 -1
  625. package/dist/cli-bundle/chunks/chunk-OF7V47P3.js.map +0 -1
  626. package/dist/cli-bundle/chunks/chunk-OHDQNKJB.js.map +0 -7
  627. package/dist/cli-bundle/chunks/chunk-PEL2NLQE.js +0 -118
  628. package/dist/cli-bundle/chunks/chunk-PEL2NLQE.js.map +0 -7
  629. package/dist/cli-bundle/chunks/chunk-PRVTGX64.js.map +0 -7
  630. package/dist/cli-bundle/chunks/chunk-RAWA3Y7O.js.map +0 -1
  631. package/dist/cli-bundle/chunks/chunk-SMXSDY7J.js.map +0 -7
  632. package/dist/cli-bundle/chunks/chunk-SUREE24M.js.map +0 -1
  633. package/dist/cli-bundle/chunks/chunk-TKPP4GOO.js +0 -654
  634. package/dist/cli-bundle/chunks/chunk-TKPP4GOO.js.map +0 -1
  635. package/dist/cli-bundle/chunks/chunk-VSAABFGQ.js.map +0 -1
  636. package/dist/cli-bundle/chunks/chunk-W2VMLL5S.js +0 -32
  637. package/dist/cli-bundle/chunks/chunk-W2VMLL5S.js.map +0 -1
  638. package/dist/cli-bundle/chunks/chunk-XVYKWZNL.js.map +0 -7
  639. package/dist/cli-bundle/chunks/chunk-XXKV4UWE.js.map +0 -7
  640. package/dist/cli-bundle/chunks/chunk-ZLWRPBOW.js.map +0 -1
  641. package/dist/cli-bundle/chunks/chunk-ZV7IQ23N.js +0 -657
  642. package/dist/cli-bundle/chunks/chunk-ZV7IQ23N.js.map +0 -7
  643. package/dist/cli-bundle/chunks/close-JEBZXONN.js +0 -15
  644. package/dist/cli-bundle/chunks/config-NCNNWF6R.js.map +0 -7
  645. package/dist/cli-bundle/chunks/config-SW3U7XP2.js.map +0 -1
  646. package/dist/cli-bundle/chunks/context-55VEOYI3.js.map +0 -1
  647. package/dist/cli-bundle/chunks/context-5LB7UGKE.js.map +0 -7
  648. package/dist/cli-bundle/chunks/contracts-JXFGBOYT.js.map +0 -1
  649. package/dist/cli-bundle/chunks/contracts-SY6PDFIK.js.map +0 -7
  650. package/dist/cli-bundle/chunks/create-CLSCHGJJ.js +0 -30
  651. package/dist/cli-bundle/chunks/history-ALTM2RRP.js +0 -20
  652. package/dist/cli-bundle/chunks/history-redact-5YGLWUDH.js +0 -21
  653. package/dist/cli-bundle/chunks/init-C4CRHW22.js +0 -21
  654. package/dist/cli-bundle/chunks/register-list-query-CCMHGZTF.js.map +0 -7
  655. package/dist/cli-bundle/chunks/register-list-query-OM3E2KMY.js.map +0 -1
  656. package/dist/cli-bundle/chunks/register-mutation-N3CDEGZU.js.map +0 -1
  657. package/dist/cli-bundle/chunks/register-mutation-UXTTWL6N.js.map +0 -7
  658. package/dist/cli-bundle/chunks/register-setup-G5LTSFYK.js.map +0 -1
  659. package/dist/cli-bundle/chunks/register-setup-TWHKICM2.js.map +0 -7
  660. package/dist/cli-bundle/chunks/restore-LQHXBAY5.js +0 -19
  661. package/dist/cli-bundle/chunks/schema-C6QA367T.js.map +0 -7
  662. package/dist/cli-bundle/chunks/schema-QO5I4FBL.js.map +0 -1
  663. package/dist/cli-bundle/chunks/stats-TCW2SZQG.js.map +0 -7
  664. package/dist/cli-bundle/chunks/stats-TKC6CAKB.js.map +0 -1
  665. package/dist/cli-bundle/chunks/test-WA6RZGM2.js +0 -36
  666. package/dist/cli-bundle/chunks/test-runs-FQ5WNQLP.js.map +0 -1
  667. package/dist/cli-bundle/chunks/test-runs-PX73DMMI.js.map +0 -7
  668. package/dist/cli-bundle/chunks/update-BSKMQOYH.js +0 -28
  669. package/dist/cli-bundle/chunks/update-FIGYNQ2I.js +0 -24
  670. package/dist/cli-bundle/chunks/validate-54SYJ7QW.js.map +0 -1
  671. package/dist/cli-bundle/chunks/validate-HYZNIB6W.js.map +0 -7
  672. package/docs/examples/policy-restricted-extension/index.js +0 -21
  673. package/packages/pm-beads/extensions/beads/index.js +0 -64
  674. package/packages/pm-beads/extensions/beads/runtime-loader.js +0 -86
  675. package/packages/pm-beads/extensions/beads/runtime.js +0 -482
  676. package/packages/pm-calendar/extensions/calendar/index.js +0 -150
  677. package/packages/pm-calendar/extensions/calendar/runtime.js +0 -126
  678. package/packages/pm-command-kit/extensions/command-kit/index.js +0 -181
  679. package/packages/pm-governance-audit/extensions/governance-audit/index.js +0 -177
  680. package/packages/pm-governance-audit/extensions/governance-audit/runtime.js +0 -153
  681. package/packages/pm-guide-shell/extensions/guide-shell/index.js +0 -98
  682. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +0 -294
  683. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +0 -18
  684. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.js +0 -124
  685. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.js +0 -110
  686. package/packages/pm-search-advanced/extensions/search-advanced/index.js +0 -258
  687. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +0 -361
  688. package/packages/pm-templates/extensions/templates/index.js +0 -132
  689. package/packages/pm-templates/extensions/templates/runtime.js +0 -35
  690. package/packages/pm-todos/extensions/todos/index.js +0 -81
  691. package/packages/pm-todos/extensions/todos/runtime-loader.js +0 -86
  692. package/packages/pm-todos/extensions/todos/runtime.js +0 -545
  693. /package/dist/cli-bundle/chunks/{activity-54TXGJ2T.js.map → activity-AW6XVFH6.js.map} +0 -0
  694. /package/dist/cli-bundle/chunks/{activity-N7RVTLBQ.js.map → activity-DBLQVIP6.js.map} +0 -0
  695. /package/dist/cli-bundle/chunks/{chunk-F32L4HR6.js.map → chunk-27BXPBAY.js.map} +0 -0
  696. /package/dist/cli-bundle/chunks/{chunk-5BBEWX6C.js.map → chunk-3VGN2UWE.js.map} +0 -0
  697. /package/dist/cli-bundle/chunks/{chunk-FMWW2JDU.js.map → chunk-AXIDKKAT.js.map} +0 -0
  698. /package/dist/cli-bundle/chunks/{chunk-TIM4OD74.js.map → chunk-BDTISOSD.js.map} +0 -0
  699. /package/dist/cli-bundle/chunks/{chunk-CZIFFMZI.js.map → chunk-DDPTYJIM.js.map} +0 -0
  700. /package/dist/cli-bundle/chunks/{chunk-AYPQUFCX.js.map → chunk-EJUDVUYZ.js.map} +0 -0
  701. /package/dist/cli-bundle/chunks/{chunk-EOGBMLCE.js.map → chunk-EVMTBV6V.js.map} +0 -0
  702. /package/dist/cli-bundle/chunks/{chunk-CG3KP6I5.js.map → chunk-G7I7DEZA.js.map} +0 -0
  703. /package/dist/cli-bundle/chunks/{chunk-F4BNR2IN.js.map → chunk-HYTGA6GI.js.map} +0 -0
  704. /package/dist/cli-bundle/chunks/{chunk-2WCYE3IF.js.map → chunk-HZZEHPRG.js.map} +0 -0
  705. /package/dist/cli-bundle/chunks/{chunk-YV2OSAMS.js.map → chunk-IJYK2T43.js.map} +0 -0
  706. /package/dist/cli-bundle/chunks/{chunk-QOUOMPHO.js.map → chunk-JPECA746.js.map} +0 -0
  707. /package/dist/cli-bundle/chunks/{chunk-OQ2E64FH.js.map → chunk-KNPEF7QG.js.map} +0 -0
  708. /package/dist/cli-bundle/chunks/{chunk-3BKH2CL3.js.map → chunk-L5OEFZQG.js.map} +0 -0
  709. /package/dist/cli-bundle/chunks/{chunk-5S4ZGDB2.js.map → chunk-N74UMG5H.js.map} +0 -0
  710. /package/dist/cli-bundle/chunks/{chunk-IXAZI443.js.map → chunk-NFDPYAIP.js.map} +0 -0
  711. /package/dist/cli-bundle/chunks/{chunk-SKC4UTRP.js.map → chunk-NKZAN7BD.js.map} +0 -0
  712. /package/dist/cli-bundle/chunks/{chunk-JPJDP4VU.js.map → chunk-NWMZWYYB.js.map} +0 -0
  713. /package/dist/cli-bundle/chunks/{chunk-KKX4Z2SE.js.map → chunk-OTUHB4HS.js.map} +0 -0
  714. /package/dist/cli-bundle/chunks/{chunk-WB5BYQMF.js.map → chunk-SLMUGTK3.js.map} +0 -0
  715. /package/dist/cli-bundle/chunks/{chunk-I6QMJ2XT.js.map → chunk-WYDHYJPO.js.map} +0 -0
  716. /package/dist/cli-bundle/chunks/{chunk-KIEAK7YE.js.map → chunk-ZRP4VG5U.js.map} +0 -0
  717. /package/dist/cli-bundle/chunks/{close-JEBZXONN.js.map → close-E6ZZGCJY.js.map} +0 -0
  718. /package/dist/cli-bundle/chunks/{close-QHMVWM7M.js.map → close-TQYAAFJP.js.map} +0 -0
  719. /package/dist/cli-bundle/chunks/{create-O4VONGPG.js.map → context-B6275WPX.js.map} +0 -0
  720. /package/dist/cli-bundle/chunks/{create-CLSCHGJJ.js.map → context-OCZ3FJ4Z.js.map} +0 -0
  721. /package/dist/cli-bundle/chunks/{extension-YQF4CPIR.js.map → create-OH3BDGBB.js.map} +0 -0
  722. /package/dist/cli-bundle/chunks/{extension-3JYWJ5K2.js.map → create-RLRJMRTM.js.map} +0 -0
  723. /package/dist/cli-bundle/chunks/{history-ALTM2RRP.js.map → extension-CPSLJQVE.js.map} +0 -0
  724. /package/dist/cli-bundle/chunks/{history-RUKPKNY7.js.map → extension-CXJ6RELI.js.map} +0 -0
  725. /package/dist/cli-bundle/chunks/{gc-BEJMQT64.js.map → gc-7GQYOS2G.js.map} +0 -0
  726. /package/dist/cli-bundle/chunks/{gc-JEFQDJPA.js.map → gc-LPVMKJQJ.js.map} +0 -0
  727. /package/dist/cli-bundle/chunks/{health-JJJOY7DJ.js.map → health-3IPFLKXB.js.map} +0 -0
  728. /package/dist/cli-bundle/chunks/{health-P67NZ6TT.js.map → health-GZXGBZ36.js.map} +0 -0
  729. /package/dist/cli-bundle/chunks/{history-redact-YY4XYVEP.js.map → history-NERDJNUB.js.map} +0 -0
  730. /package/dist/cli-bundle/chunks/{history-redact-5YGLWUDH.js.map → history-WSZHY3PN.js.map} +0 -0
  731. /package/dist/cli-bundle/chunks/{init-C4CRHW22.js.map → history-redact-MP6CH7U5.js.map} +0 -0
  732. /package/dist/cli-bundle/chunks/{init-HBFGYS66.js.map → history-redact-O3NBCNWC.js.map} +0 -0
  733. /package/dist/cli-bundle/chunks/{list-C7R33MD5.js.map → init-64XDLQJB.js.map} +0 -0
  734. /package/dist/cli-bundle/chunks/{list-DSN6UNFB.js.map → init-PAX32BJA.js.map} +0 -0
  735. /package/dist/cli-bundle/chunks/{restore-LL2WLEDG.js.map → list-DNBJVO3E.js.map} +0 -0
  736. /package/dist/cli-bundle/chunks/{restore-LQHXBAY5.js.map → list-G5Y65VF6.js.map} +0 -0
  737. /package/dist/cli-bundle/chunks/{search-2EI6EAXH.js.map → restore-4MHZFJ2E.js.map} +0 -0
  738. /package/dist/cli-bundle/chunks/{search-QBFBLQRO.js.map → restore-YALDGTQR.js.map} +0 -0
  739. /package/dist/cli-bundle/chunks/{test-NV2DRPUS.js.map → schema-73HR2OJW.js.map} +0 -0
  740. /package/dist/cli-bundle/chunks/{test-WA6RZGM2.js.map → schema-U6LJKSIR.js.map} +0 -0
  741. /package/dist/cli-bundle/chunks/{update-BSKMQOYH.js.map → search-AXPXKZER.js.map} +0 -0
  742. /package/dist/cli-bundle/chunks/{update-FIGYNQ2I.js.map → search-KILGT37L.js.map} +0 -0
  743. /package/dist/cli-bundle/chunks/{telemetry-BT2VSWU2.js.map → telemetry-BZUF6H7G.js.map} +0 -0
  744. /package/dist/cli-bundle/chunks/{telemetry-LQ6FRTUT.js.map → telemetry-GAHHQTOS.js.map} +0 -0
@@ -4,19 +4,22 @@
4
4
  * Implements extension package-management support for Scaffold.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9eecdd82-fe71-5803-9186-a33244c4722d")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9cc4cb5f-313d-5e8c-8c63-545a7a8d2a03")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
+ import { EXECUTABLE_COMMAND_ALIASES } from "../../bootstrap-args.js";
10
11
  import { pathExists } from "../../../core/fs/fs-utils.js";
11
12
  import { EXIT_CODE } from "../../../core/shared/constants.js";
12
13
  import { PmCliError } from "../../../core/shared/errors.js";
14
+ import { PM_CORE_COMMAND_NAMES } from "../../../sdk/cli-contracts.js";
13
15
  import { normalizeManagedDirectoryName } from "./shared.js";
14
- // Safe compatibility floor emitted into scaffolded manifests. Mirrors the
15
- // first-party package manifests (pm-nf2q): every current 2026.5.x CLI
16
- // satisfies it, and it models the field for external authors. manifest_version
17
- // tracks the manifest schema generation (currently 1).
16
+ // Safe compatibility floor emitted into scaffolded manifests. The current
17
+ // starters are loaded as TypeScript and use the SDK define*/testing helpers; the
18
+ // first released host that supports that full generated contract is v2026.6.24.
19
+ // manifest_version tracks the manifest schema generation (currently 1).
18
20
  const SCAFFOLD_MANIFEST_VERSION = 1;
19
- const SCAFFOLD_PM_MIN_VERSION = "2026.5.0";
21
+ export const SCAFFOLD_PM_MIN_VERSION = "2026.6.24";
22
+ const SCAFFOLD_NODE_ENGINE = ">=22.18.0";
20
23
  const SCAFFOLD_DECLARED_PERMISSIONS = {
21
24
  fs_read: false,
22
25
  fs_write: false,
@@ -25,22 +28,48 @@ const SCAFFOLD_DECLARED_PERMISSIONS = {
25
28
  env_write: false,
26
29
  process_spawn: false,
27
30
  };
31
+ const RESERVED_SCAFFOLD_COMMAND_ROOTS = new Set([
32
+ ...PM_CORE_COMMAND_NAMES.map((commandName) => commandName.split("-")[0].toLowerCase()),
33
+ ...Object.keys(EXECUTABLE_COMMAND_ALIASES).map((alias) => alias.toLowerCase()),
34
+ // "scaffold" is a Commander command that currently lives outside both
35
+ // PM_CORE_COMMAND_NAMES and EXECUTABLE_COMMAND_ALIASES.
36
+ "scaffold",
37
+ ]);
28
38
  // TypeScript dev-dependency floor for scaffolded packages, matching the CLI's own
29
39
  // toolchain so generated packages compile against the same compiler generation.
30
40
  const SCAFFOLD_TYPESCRIPT_VERSION = "^6.0.0";
31
41
  // `@types/node` floor for scaffolded packages: the colocated `index.test.ts`
32
42
  // imports `node:test`/`node:assert`, which need Node's ambient type definitions
33
- // to compile. Pinned to the engines floor (Node >=20), matching the CLI itself.
34
- const SCAFFOLD_TYPES_NODE_VERSION = "^20.0.0";
35
- // Strict NodeNext tsconfig emitted into every scaffold (ADR pm-2c28: extensions
36
- // are authored fully in TypeScript). It compiles `index.ts` (and the colocated
37
- // `index.test.ts`) in place to the `./index.js` entry the manifest loads, so the
38
- // authored source is type-checked against the SDK contracts while the loader keeps
39
- // importing plain compiled JavaScript. NodeNext resolution matches the explicit
40
- // `.js` import specifiers the emitted ESM uses. No `outDir` is set on purpose:
41
- // tsc auto-excludes its `outDir`, and an in-package `outDir` would exclude the
42
- // whole package root, leaving the `*.ts` inputs unmatched (TS18003). Emitting
43
- // beside the source mirrors the first-party `packages/pm-*` layout.
43
+ // to type-check. Pinned to the engines floor (Node >=22.18), matching the CLI
44
+ // itself the version where Node strips TypeScript types on load by default.
45
+ const SCAFFOLD_TYPES_NODE_VERSION = "^22.0.0";
46
+ const SAMPLE_HARNESS_CLEANUP_LINES = [
47
+ "type StarterHarness = Awaited<ReturnType<typeof createExtensionTestHarness>>;",
48
+ "",
49
+ "async function deactivateIfNeeded(ext: StarterHarness, deactivated: boolean): Promise<void> {",
50
+ " if (!deactivated) {",
51
+ " try {",
52
+ " await ext.deactivate();",
53
+ " } catch {",
54
+ " // Preserve the original assertion error; cleanup is best effort.",
55
+ " }",
56
+ " }",
57
+ "}",
58
+ "",
59
+ ];
60
+ const SAMPLE_HARNESS_FINALLY_LINES = [
61
+ " } finally {",
62
+ " await deactivateIfNeeded(ext, deactivated);",
63
+ " }",
64
+ ];
65
+ // Strict NodeNext tsconfig emitted into every scaffold (ADR pm-2c28 / pm-m1uz:
66
+ // extensions are authored AND loaded as TypeScript). It is a type-check-only
67
+ // config (`noEmit`): there is no compile step — pm loads the `./index.ts`
68
+ // manifest entry directly via Node's native type stripping (Node >=22.18), so
69
+ // no `.js` is emitted or committed. `allowImportingTsExtensions` lets the
70
+ // colocated `index.test.ts` import the sibling `./index.ts` entry with its real
71
+ // extension, exactly as Node resolves it at load time. NodeNext resolution keeps
72
+ // the module graph identical to the runtime loader.
44
73
  const SCAFFOLD_TSCONFIG = {
45
74
  compilerOptions: {
46
75
  target: "ES2022",
@@ -49,50 +78,101 @@ const SCAFFOLD_TSCONFIG = {
49
78
  strict: true,
50
79
  esModuleInterop: true,
51
80
  skipLibCheck: true,
52
- declaration: false,
81
+ noEmit: true,
82
+ allowImportingTsExtensions: true,
53
83
  // `node:test`/`node:assert` in the colocated test (and Node globals) resolve
54
84
  // from `@types/node`; name it explicitly so it is loaded regardless of how the
55
85
  // package manager lays out `node_modules/@types`.
56
86
  types: ["node"],
57
87
  },
58
88
  // Recursive so a package that grows into subdirectory `*.ts` modules still
59
- // type-checks and compiles them; tsc excludes `node_modules` by default.
89
+ // type-checks; tsc excludes `node_modules` by default.
60
90
  include: ["**/*.ts"],
61
91
  };
62
92
  /**
63
93
  * Capability shapes the package/extension scaffolder can target via the
64
- * `--capability` selector. `commands` emits the default command-only starter;
65
- * `hooks` additionally wires an `after_command` lifecycle reactor, `search`
66
- * wires an in-memory provider/adapter pair, and `importers` wires importer and
67
- * exporter command primitives so authors can customize project context movement
68
- * without starting from a blank extension.
94
+ * `--capability` selector one per SDK extension capability, so every
95
+ * registration surface has a runnable starter. `commands` emits the default
96
+ * command-only starter; `hooks` additionally wires an `after_command` lifecycle
97
+ * reactor; `search` wires an in-memory provider/adapter pair; `importers` wires
98
+ * importer and exporter command primitives so authors can customize project
99
+ * context movement; `schema` registers a custom item type, item field, and
100
+ * migration so authors can model their own project domain; `profile` registers a
101
+ * complete project-profile archetype (item types, statuses, fields, a workflow,
102
+ * config, a template, and package recommendations) via `api.registerProfile` so
103
+ * `pm profile apply` can tailor a tracker in one shot; `renderers` overrides how
104
+ * a command's output is serialized for a format; `parser` rewrites a command's
105
+ * parsed options before its handler runs; `preflight` adjusts pm's pre-run
106
+ * migration/format gate decision; and `services` overrides a built-in pm service
107
+ * (e.g. output formatting) — without starting from a blank extension.
69
108
  */
70
- export const SCAFFOLD_CAPABILITIES = ["commands", "hooks", "search", "importers"];
109
+ export const SCAFFOLD_CAPABILITIES = [
110
+ "commands",
111
+ "hooks",
112
+ "search",
113
+ "importers",
114
+ "schema",
115
+ "profile",
116
+ "renderers",
117
+ "parser",
118
+ "preflight",
119
+ "services",
120
+ ];
71
121
  const SCAFFOLD_MANIFEST_CAPABILITIES = {
72
122
  commands: ["commands"],
73
123
  hooks: ["commands", "hooks"],
74
124
  search: ["commands", "search"],
75
125
  importers: ["commands", "schema", "importers"],
126
+ schema: ["commands", "schema"],
127
+ // A profile registration IS a schema+config bundle, so the loader gate requires
128
+ // the `schema` capability (no separate `profile` capability) — same grant as the
129
+ // schema starter, mirroring the bundled pm-kanban exemplar.
130
+ profile: ["commands", "schema"],
131
+ renderers: ["commands", "renderers"],
132
+ // The parser starter declares `--shout`/`--upper` command flags so the
133
+ // override is runnable through `pm <command> --shout`; flag metadata is
134
+ // schema-governed, so the manifest also declares `schema`.
135
+ parser: ["commands", "parser", "schema"],
136
+ preflight: ["commands", "preflight"],
137
+ services: ["commands", "services"],
76
138
  };
77
139
  const SAMPLE_TEST_CAPABILITIES_LITERAL = {
78
140
  commands: '["commands"]',
79
141
  hooks: '["commands", "hooks"]',
80
142
  search: '["commands", "search"]',
81
143
  importers: '["commands", "schema", "importers"]',
144
+ schema: '["commands", "schema"]',
145
+ profile: '["commands", "schema"]',
146
+ renderers: '["commands", "renderers"]',
147
+ parser: '["commands", "parser", "schema"]',
148
+ preflight: '["commands", "preflight"]',
149
+ services: '["commands", "services"]',
82
150
  };
83
151
  const ENTRYPOINT_BULLETS = {
84
- commands: "- `index.ts`: starter command registration plus a `deactivate` teardown stub (compiled to `index.js`).",
85
- hooks: "- `index.ts`: starter command registration, an `after_command` lifecycle hook, and a `deactivate` teardown stub (compiled to `index.js`).",
86
- search: "- `index.ts`: starter command registration, a search provider, a vector-store adapter, and a `deactivate` teardown stub (compiled to `index.js`).",
87
- importers: "- `index.ts`: starter command registration, importer/exporter command registrations, and a `deactivate` teardown stub (compiled to `index.js`).",
152
+ commands: "- `index.ts`: the TypeScript manifest entry — starter command registration plus a `deactivate` teardown stub.",
153
+ hooks: "- `index.ts`: the TypeScript manifest entry — starter command registration, an `after_command` lifecycle hook, and a `deactivate` teardown stub.",
154
+ search: "- `index.ts`: the TypeScript manifest entry — starter command registration, a search provider, a vector-store adapter, and a `deactivate` teardown stub.",
155
+ importers: "- `index.ts`: the TypeScript manifest entry — starter command registration, importer/exporter command registrations, and a `deactivate` teardown stub.",
156
+ schema: "- `index.ts`: the TypeScript manifest entry — starter command registration, a custom item type, a custom item field, a schema migration, and a `deactivate` teardown stub.",
157
+ profile: "- `index.ts`: the TypeScript manifest entry — starter command registration, a project profile (item types, statuses, fields, a workflow, config, a template, and package recommendations) registered via `api.registerProfile`, and a `deactivate` teardown stub.",
158
+ renderers: "- `index.ts`: the TypeScript manifest entry — starter command registration, a `toon` output renderer override, and a `deactivate` teardown stub.",
159
+ parser: "- `index.ts`: the TypeScript manifest entry — starter command registration, a parser override that rewrites the command's parsed options, and a `deactivate` teardown stub.",
160
+ preflight: "- `index.ts`: the TypeScript manifest entry — starter command registration, a preflight override over pm's pre-run gate decision, and a `deactivate` teardown stub.",
161
+ services: "- `index.ts`: the TypeScript manifest entry — starter command registration, an `output_format` service override, and a `deactivate` teardown stub.",
88
162
  };
89
163
  const SAMPLE_TEST_BULLETS = {
90
164
  commands: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, and teardown via the SDK testing helpers.",
91
165
  hooks: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, the after_command hook, and teardown via the SDK testing helpers.",
92
166
  search: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, search provider/vector adapter invocation, and teardown via the SDK testing helpers.",
93
167
  importers: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, importer/exporter invocation, and teardown via the SDK testing helpers.",
168
+ schema: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, item type/field/migration registration, migration invocation, and teardown via the SDK testing helpers.",
169
+ profile: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, project-profile registration (asserting the bundled archetype dimensions), and teardown via the SDK testing helpers.",
170
+ renderers: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, renderer override registration and invocation (including format pass-through), and teardown via the SDK testing helpers.",
171
+ parser: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, parser override registration and the option rewrite it produces, and teardown via the SDK testing helpers.",
172
+ preflight: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, preflight override registration and the gate decision it returns, and teardown via the SDK testing helpers.",
173
+ services: "- `index.test.ts`: sample `node:test` suite covering activation, command invocation, service override registration and invocation (including command pass-through), and teardown via the SDK testing helpers.",
94
174
  };
95
- const TSCONFIG_BULLET = "- `tsconfig.json`: strict TypeScript config that compiles `index.ts` to the `./index.js` entry.";
175
+ const TSCONFIG_BULLET = "- `tsconfig.json`: strict type-check-only TypeScript config (`noEmit`) for the `.ts` source the loader runs directly.";
96
176
  const PACKAGE_CAPABILITY_README_SECTIONS = {
97
177
  commands: [],
98
178
  hooks: [
@@ -125,6 +205,73 @@ const PACKAGE_CAPABILITY_README_SECTIONS = {
125
205
  "capability grants both registrations, and `schema` grants the example",
126
206
  "command flag metadata.",
127
207
  ],
208
+ schema: [
209
+ "",
210
+ "## Custom Schema",
211
+ "`index.ts` models a project domain by registering a custom item type, a",
212
+ "custom item field, and a schema migration through `api.registerItemTypes`,",
213
+ "`api.registerItemFields`, and `api.registerMigration`. This is how a package",
214
+ "turns pm into a domain-specific tracker — `project management = context",
215
+ "management`. Replace the sample type/field/migration with your own domain",
216
+ "model; the `schema` capability in `manifest.json` grants all three",
217
+ "registrations. Once installed, the custom type is usable everywhere, e.g.",
218
+ "`pm create <type> \"<title>\"` and `pm list --type <type>`.",
219
+ ],
220
+ profile: [
221
+ "",
222
+ "## Project Profile",
223
+ "`index.ts` registers a complete project-profile archetype through",
224
+ "`api.registerProfile`. A profile is the broadest customization primitive pm",
225
+ "has — one declarative bundle of item types, custom statuses, fields, a per-type",
226
+ "workflow, config knobs, create templates, and package recommendations. Once the",
227
+ "package is installed the profile resolves by name through `pm profile list`,",
228
+ "`pm profile show <name>`, and `pm profile apply <name>`, which stages every",
229
+ "dimension idempotently — exactly like a core archetype (agile/ops/research),",
230
+ "with no consumer code required. Replace the sample archetype with your own",
231
+ "domain; the `schema` capability in `manifest.json` grants the registration (a",
232
+ "profile is a schema+config bundle, so it needs no separate capability).",
233
+ ],
234
+ renderers: [
235
+ "",
236
+ "## Output Renderer",
237
+ "`index.ts` registers a `toon` output renderer override through",
238
+ "`api.registerRenderer`. Renderer overrides run for every command's output in",
239
+ "that format, so this starter scopes itself to THIS package's own command and",
240
+ "returns `null` (pass-through to pm's default renderer) for everything else.",
241
+ "Return a string to take over rendering. Replace the sample serialization with",
242
+ "your own; the `renderers` capability in `manifest.json` grants the",
243
+ "registration.",
244
+ ],
245
+ parser: [
246
+ "",
247
+ "## Parser Override",
248
+ "`index.ts` registers a parser override for the starter command through",
249
+ "`api.registerParser`. pm runs it on the command's parsed options BEFORE the",
250
+ "handler, merging the delta you return. This starter rewrites a deprecated",
251
+ "`--shout` alias to the canonical `--upper` flag; replace it with your",
252
+ "command's real normalization. The `parser` capability in `manifest.json`",
253
+ "grants the registration.",
254
+ ],
255
+ preflight: [
256
+ "",
257
+ "## Preflight Override",
258
+ "`index.ts` registers a preflight override through `api.registerPreflight`. pm",
259
+ "calls it before every command to compute the migration/format gate decision —",
260
+ "the last registered override wins. Return only the decision keys you want to",
261
+ "change; this starter echoes the current decision unchanged (a safe no-op) so",
262
+ "installing the package does not alter gate behavior. The `preflight`",
263
+ "capability in `manifest.json` grants the registration.",
264
+ ],
265
+ services: [
266
+ "",
267
+ "## Service Override",
268
+ "`index.ts` overrides the built-in `output_format` service through",
269
+ "`api.registerService`. The service renders a command's structured result;",
270
+ "returning the payload unchanged passes through to pm's default formatting.",
271
+ "This starter scopes itself to THIS package's own command and passes every",
272
+ "other command through, so it never disrupts unrelated output. The `services`",
273
+ "capability in `manifest.json` grants the registration.",
274
+ ],
128
275
  };
129
276
  const EXTENSION_CAPABILITY_README_SECTIONS = {
130
277
  commands: [],
@@ -154,7 +301,298 @@ const EXTENSION_CAPABILITY_README_SECTIONS = {
154
301
  "payloads with your domain adapter. The `importers` capability grants both",
155
302
  "registrations, and `schema` grants the example command flag metadata.",
156
303
  ],
304
+ schema: [
305
+ "",
306
+ "## Custom Schema",
307
+ "`index.ts` models a project domain by registering a custom item type, a",
308
+ "custom item field, and a schema migration through `api.registerItemTypes`,",
309
+ "`api.registerItemFields`, and `api.registerMigration`. Replace the sample",
310
+ "type/field/migration with your own domain model; the `schema` capability in",
311
+ "`manifest.json` grants all three registrations. Once installed, the custom",
312
+ 'type is usable everywhere, e.g. `pm create <type> "<title>"`.',
313
+ ],
314
+ profile: [
315
+ "",
316
+ "## Project Profile",
317
+ "`index.ts` registers a complete project-profile archetype through",
318
+ "`api.registerProfile` — one declarative bundle of item types, custom statuses,",
319
+ "fields, a per-type workflow, config knobs, create templates, and package",
320
+ "recommendations. Once installed the profile resolves by name through",
321
+ "`pm profile list`, `pm profile show <name>`, and `pm profile apply <name>`,",
322
+ "which stages every dimension idempotently like a core archetype. Replace the",
323
+ "sample archetype with your own domain; the `schema` capability in",
324
+ "`manifest.json` grants the registration.",
325
+ ],
326
+ renderers: [
327
+ "",
328
+ "## Output Renderer",
329
+ "`index.ts` registers a `toon` output renderer override through",
330
+ "`api.registerRenderer`. Renderer overrides run for every command's output in",
331
+ "that format, so this starter scopes itself to its own command and returns",
332
+ "`null` (pass-through to pm's default renderer) for everything else. Replace",
333
+ "the sample serialization with your own; the `renderers` capability in",
334
+ "`manifest.json` grants the registration.",
335
+ ],
336
+ parser: [
337
+ "",
338
+ "## Parser Override",
339
+ "`index.ts` registers a parser override for the starter command through",
340
+ "`api.registerParser`. pm runs it on the command's parsed options BEFORE the",
341
+ "handler, merging the delta you return. This starter rewrites a deprecated",
342
+ "`--shout` alias to the canonical `--upper` flag; replace it with your own",
343
+ "normalization. The `parser` capability in `manifest.json` grants the",
344
+ "registration.",
345
+ ],
346
+ preflight: [
347
+ "",
348
+ "## Preflight Override",
349
+ "`index.ts` registers a preflight override through `api.registerPreflight`. pm",
350
+ "calls it before every command to compute the migration/format gate decision —",
351
+ "the last registered override wins. This starter echoes the current decision",
352
+ "unchanged (a safe no-op); return only the decision keys you want to change.",
353
+ "The `preflight` capability in `manifest.json` grants the registration.",
354
+ ],
355
+ services: [
356
+ "",
357
+ "## Service Override",
358
+ "`index.ts` overrides the built-in `output_format` service through",
359
+ "`api.registerService`. Returning the payload unchanged passes through to pm's",
360
+ "default formatting, so this starter scopes itself to its own command and",
361
+ "passes every other command through. The `services` capability in",
362
+ "`manifest.json` grants the registration.",
363
+ ],
364
+ };
365
+ // README activation explainer for command-bearing starters (commands/hooks/
366
+ // search/importers): they declare `activation.commands` so pm loads them lazily.
367
+ const LAZY_ACTIVATION_README_SECTION = {
368
+ package: [
369
+ "",
370
+ "## Lazy Activation",
371
+ "`manifest.json` declares `activation.commands`: the exact command paths this",
372
+ "package's `activate` registers. pm imports and activates the package lazily —",
373
+ "only when an invoked command path matches one of these entries — so unrelated",
374
+ "commands (`pm list`, `pm search`, ...) never pay to load it. Keep this list in",
375
+ "sync with the registrations in `index.ts`: add an entry when you register a new",
376
+ "command, importer, or exporter, and remove one you drop. An omitted or stale",
377
+ "entry means the matching command will not dispatch from the CLI. Globally-scoped",
378
+ "surfaces (hooks, parser/preflight/renderer overrides, and search providers for",
379
+ "built-in search commands) still activate regardless of this list.",
380
+ ],
381
+ extension: [
382
+ "",
383
+ "## Lazy Activation",
384
+ "`manifest.json` declares `activation.commands`: the exact command paths this",
385
+ "extension's `activate` registers. pm imports and activates the extension lazily —",
386
+ "only when an invoked command path matches one of these entries — so unrelated",
387
+ "commands never pay to load it. Keep this list in sync with the registrations in",
388
+ "`index.ts`: an omitted or stale entry means the matching command will not dispatch",
389
+ "from the CLI. Globally-scoped surfaces (hooks, parser/preflight/renderer overrides,",
390
+ "and search providers for built-in search commands) still activate regardless.",
391
+ ],
392
+ };
393
+ // README activation explainer for the `schema` starter: it contributes a GLOBAL
394
+ // custom item type/field, so it intentionally omits `activation.commands` and
395
+ // relies on pm's conservative activation tier (see buildScaffoldActivationCommands).
396
+ const SCHEMA_ACTIVATION_README_SECTION = {
397
+ package: [
398
+ "",
399
+ "## Activation",
400
+ "This package contributes a GLOBAL custom item type and field, so `manifest.json`",
401
+ "intentionally declares no `activation.commands`. pm activates the package",
402
+ "conservatively — for every command — so the custom type is present wherever it is",
403
+ "used: `pm create <type>`, `pm list --type <type>`, `pm validate`, and so on.",
404
+ "Declaring narrow `activation.commands` here would gate activation to only those",
405
+ "commands and silently leave the custom type unregistered for `pm create`. If you",
406
+ "drop the schema registrations and keep only command/hook/search/importer surfaces,",
407
+ "add `activation.commands` back so pm can load the package lazily.",
408
+ ],
409
+ extension: [
410
+ "",
411
+ "## Activation",
412
+ "This extension contributes a GLOBAL custom item type and field, so `manifest.json`",
413
+ "intentionally declares no `activation.commands`. pm activates the extension",
414
+ "conservatively — for every command — so the custom type is present wherever it is",
415
+ "used: `pm create <type>`, `pm list --type <type>`, `pm validate`, and so on.",
416
+ "Declaring narrow `activation.commands` here would gate activation to only those",
417
+ "commands and silently leave the custom type unregistered for `pm create`.",
418
+ ],
419
+ };
420
+ // README activation explainer for the `profile` starter: the contributed profile
421
+ // is resolved by the built-in `pm profile list/show/apply` commands (which the
422
+ // package does not own), so it intentionally omits `activation.commands` and relies
423
+ // on pm's conservative activation tier (granted by the `schema` capability).
424
+ const PROFILE_ACTIVATION_README_SECTION = {
425
+ package: [
426
+ "",
427
+ "## Activation",
428
+ "This package contributes a project profile resolved by the built-in",
429
+ "`pm profile list`, `pm profile show <name>`, and `pm profile apply <name>`",
430
+ "commands — commands the package does not own — so `manifest.json` intentionally",
431
+ "declares no `activation.commands`. pm activates the package conservatively (for",
432
+ "every command, granted by the `schema` capability) so the profile is present",
433
+ "whenever `pm profile` runs. Declaring narrow `activation.commands` here would",
434
+ "gate activation to only the listed commands and silently leave the profile",
435
+ "unregistered for `pm profile`.",
436
+ ],
437
+ extension: [
438
+ "",
439
+ "## Activation",
440
+ "This extension contributes a project profile resolved by the built-in",
441
+ "`pm profile list`, `pm profile show <name>`, and `pm profile apply <name>`",
442
+ "commands, so `manifest.json` intentionally declares no `activation.commands`. pm",
443
+ "activates the extension conservatively (for every command, granted by the",
444
+ "`schema` capability) so the profile is present whenever `pm profile` runs.",
445
+ "Declaring narrow `activation.commands` here would silently leave the profile",
446
+ "unregistered for `pm profile`.",
447
+ ],
157
448
  };
449
+ /**
450
+ * Build the README "Included Files" bullet describing `manifest.json` for the
451
+ * chosen capability and vocabulary. The `schema` and `profile` starters omit
452
+ * `activation.commands` (see {@link buildScaffoldActivationCommands}), so their
453
+ * bullet explains the global-contribution tradeoff instead of referencing a field
454
+ * they deliberately lack.
455
+ */
456
+ function buildScaffoldManifestBullet(capability, vocabulary) {
457
+ if (capability === "schema") {
458
+ return `- \`manifest.json\`: ${vocabulary} metadata and capabilities (no \`activation.commands\` — the custom item type activates for every command).`;
459
+ }
460
+ if (capability === "profile") {
461
+ return `- \`manifest.json\`: ${vocabulary} metadata and capabilities (no \`activation.commands\` — the contributed profile resolves through \`pm profile\` for every command).`;
462
+ }
463
+ return `- \`manifest.json\`: ${vocabulary} metadata, capabilities, and \`activation.commands\` (the command paths that lazily activate this ${vocabulary}).`;
464
+ }
465
+ /**
466
+ * Select the README activation section for the chosen capability and vocabulary:
467
+ * the `schema` and `profile` starters explain conservative activation (they omit
468
+ * `activation.commands`); every other capability documents lazy activation.
469
+ */
470
+ function buildScaffoldActivationReadmeSection(capability, vocabulary) {
471
+ if (capability === "schema") {
472
+ return SCHEMA_ACTIVATION_README_SECTION[vocabulary];
473
+ }
474
+ if (capability === "profile") {
475
+ return PROFILE_ACTIVATION_README_SECTION[vocabulary];
476
+ }
477
+ return LAZY_ACTIVATION_README_SECTION[vocabulary];
478
+ }
479
+ /**
480
+ * Builds the starter command path from the normalized package/extension name.
481
+ * Names that start with a built-in pm command or executable alias are prefixed
482
+ * with `starter` so the generated command dispatches to the package instead of
483
+ * being consumed by core command parsing.
484
+ */
485
+ export function buildScaffoldCommandName(extensionName) {
486
+ const commandWords = extensionName
487
+ .replace(/-/g, " ")
488
+ .trim()
489
+ .split(/\s+/)
490
+ .filter((word) => word.length > 0);
491
+ if (commandWords.length === 0) {
492
+ return "starter ping";
493
+ }
494
+ const firstWordLower = commandWords[0].toLowerCase();
495
+ let leadingStarterWords = 0;
496
+ while (commandWords[leadingStarterWords]?.toLowerCase() === "starter") {
497
+ leadingStarterWords += 1;
498
+ }
499
+ const nextStarterWord = commandWords[leadingStarterWords]?.toLowerCase();
500
+ const starterRootCollision = leadingStarterWords > 0 &&
501
+ (leadingStarterWords === commandWords.length || (nextStarterWord !== undefined && RESERVED_SCAFFOLD_COMMAND_ROOTS.has(nextStarterWord)));
502
+ const reservedRoot = RESERVED_SCAFFOLD_COMMAND_ROOTS.has(firstWordLower) || starterRootCollision;
503
+ const resolvedWords = reservedRoot ? ["starter", ...commandWords] : commandWords;
504
+ return `${resolvedWords.join(" ")} ping`;
505
+ }
506
+ /**
507
+ * Build the project-profile archetype object literal the `profile` starter
508
+ * registers — a complete {@link ProjectProfileDefinition} derived from the package
509
+ * name: one custom item type, a custom status, a custom field, a per-type workflow,
510
+ * offline search config, a create template, and an advisory package recommendation.
511
+ *
512
+ * Returned as the lines BETWEEN the object braces at a two-space base indent. Both
513
+ * authoring styles read from this single source so they never drift: the imperative
514
+ * {@link buildActivateBodyLines} wraps them in `api.registerProfile({ ... })`
515
+ * (re-indenting by the `activate` body offset) and the declarative
516
+ * {@link buildDeclarativeBlueprintSurface} wraps them in
517
+ * `defineProjectProfile({ ... })`.
518
+ */
519
+ function buildProfileArchetypeFieldLines(extensionName) {
520
+ const typeName = extensionName;
521
+ const typeFolder = `${extensionName}s`;
522
+ // De-hyphenate for a short alias; omit a redundant self-alias for single-word names.
523
+ const typeAlias = extensionName.replace(/-/g, "");
524
+ const typeAliases = typeAlias === typeName ? [] : [typeAlias];
525
+ const fieldKey = `${extensionName.replace(/-/g, "_")}_owner`;
526
+ const statusId = "reviewing";
527
+ return [
528
+ ` name: ${JSON.stringify(extensionName)},`,
529
+ ` title: ${JSON.stringify(`${extensionName} archetype`)},`,
530
+ ' summary: "Starter project profile. Replace these dimensions with your own archetype.",',
531
+ " // Item types the profile upserts into the project schema when applied.",
532
+ " types: [",
533
+ " {",
534
+ ` name: ${JSON.stringify(typeName)},`,
535
+ ` folder: ${JSON.stringify(typeFolder)},`,
536
+ ` aliases: ${JSON.stringify(typeAliases)},`,
537
+ ` description: ${JSON.stringify(`A ${extensionName} work item that flows to done.`)},`,
538
+ " },",
539
+ " ],",
540
+ " // Custom statuses upserted into the project status set.",
541
+ " statuses: [",
542
+ " {",
543
+ ` id: ${JSON.stringify(statusId)},`,
544
+ ' roles: ["active"],',
545
+ ' aliases: ["in-review"],',
546
+ ' description: "Work is implementation-complete and awaiting review.",',
547
+ " },",
548
+ " ],",
549
+ " // Custom front-matter fields the archetype tracks.",
550
+ " fields: [",
551
+ " {",
552
+ ` key: ${JSON.stringify(fieldKey)},`,
553
+ ' type: "string",',
554
+ ' commands: ["create", "update", "list"],',
555
+ ' description: "Stakeholder accountable for the item.",',
556
+ " },",
557
+ " ],",
558
+ " // Per-type workflow transition allow-list staged into settings.",
559
+ " workflows: [",
560
+ " {",
561
+ ` type: ${JSON.stringify(typeName)},`,
562
+ " allowed_transitions: [",
563
+ ' ["open", "in_progress"],',
564
+ ` ["in_progress", ${JSON.stringify(statusId)}],`,
565
+ ` [${JSON.stringify(statusId)}, "in_progress"],`,
566
+ ` [${JSON.stringify(statusId)}, "closed"],`,
567
+ ' ["in_progress", "blocked"],',
568
+ ' ["blocked", "in_progress"],',
569
+ " ],",
570
+ " },",
571
+ " ],",
572
+ " // Nested-settings knobs staged when the profile is applied.",
573
+ " config: [",
574
+ ' { key: "search_provider", value: "bm25", summary: "Offline BM25 lexical search needs no embedding service." },',
575
+ ' { key: "search_max_results", value: "20", summary: "Result cap tuned for quick triage." },',
576
+ " ],",
577
+ " // Create templates staged into <pmRoot>/templates.",
578
+ " templates: [",
579
+ " {",
580
+ ` name: ${JSON.stringify(extensionName)},`,
581
+ " options: {",
582
+ ` type: ${JSON.stringify(typeName)},`,
583
+ ' priority: "2",',
584
+ ` tags: ${JSON.stringify(extensionName)},`,
585
+ ' acceptanceCriteria: "Item delivers the stated outcome with tests and docs updated.",',
586
+ ' body: "## Context\\n\\n## Acceptance\\n- [ ] \\n",',
587
+ " },",
588
+ " },",
589
+ " ],",
590
+ " // Advisory package recommendations (never auto-installed).",
591
+ " packages: [",
592
+ ' { spec: "templates", reason: "Reusable create templates for recurring item shapes." },',
593
+ " ],",
594
+ ];
595
+ }
158
596
  /**
159
597
  * Build the `activate` body lines for the starter entrypoint. The base body
160
598
  * always registers the starter command; capability-specific variants append
@@ -218,6 +656,77 @@ function buildActivateBodyLines(extensionName, commandName, capability) {
218
656
  " });",
219
657
  ];
220
658
  }
659
+ if (capability === "schema") {
660
+ const itemTypeName = extensionName;
661
+ const itemTypeFolder = `${extensionName}s`;
662
+ // De-hyphenate for a short alias (e.g. "my-tracker" -> "mytracker"). For a
663
+ // single-word name the de-hyphenated form equals the type name, so omit the
664
+ // alias rather than register a redundant self-alias in the starter.
665
+ const itemTypeAlias = extensionName.replace(/-/g, "");
666
+ const itemTypeAliases = itemTypeAlias === itemTypeName ? [] : [itemTypeAlias];
667
+ const fieldName = `${extensionName.replace(/-/g, "_")}_note`;
668
+ const migrationId = `${extensionName}-0001-init`;
669
+ return [
670
+ ...commandLines,
671
+ "",
672
+ " // Schema registrations let a package model its own project domain — the",
673
+ " // heart of \"project management = context management\". Item types and fields",
674
+ " // are GLOBAL contributions: built-in commands like `pm create <type>` and",
675
+ " // `pm list --type <type>` must see them, so this package declares no",
676
+ " // `activation.commands` and pm activates it conservatively for every command.",
677
+ " // The `schema` capability in manifest.json grants all three registrations.",
678
+ " api.registerItemFields([",
679
+ " {",
680
+ ` name: ${JSON.stringify(fieldName)},`,
681
+ ' type: "string",',
682
+ " optional: true,",
683
+ " },",
684
+ " ]);",
685
+ "",
686
+ " api.registerItemTypes([",
687
+ " {",
688
+ ` name: ${JSON.stringify(itemTypeName)},`,
689
+ " // Replace with your domain's canonical plural folder name.",
690
+ ` folder: ${JSON.stringify(itemTypeFolder)},`,
691
+ ` aliases: ${JSON.stringify(itemTypeAliases)},`,
692
+ " // Add field names here to force them at `pm create` time.",
693
+ " required_create_fields: [],",
694
+ " },",
695
+ " ]);",
696
+ "",
697
+ " // Migrations let a package evolve stored items as its schema changes. pm",
698
+ " // runs each migration ONCE through the preflight gate (not once per item),",
699
+ " // passing a context that identifies the migration itself: `context.id` is",
700
+ " // the migration id (not an item id), alongside `context.pm_root` — iterate",
701
+ " // the corpus yourself from there. This starter is a deterministic no-op so",
702
+ " // package tests can invoke it without touching the corpus; replace the body",
703
+ " // with your real rewrite.",
704
+ " api.registerMigration({",
705
+ ` id: ${JSON.stringify(migrationId)},`,
706
+ ` description: ${JSON.stringify(`Initialize ${extensionName} schema state.`)},`,
707
+ " mandatory: false,",
708
+ " run: async (context) => ({ migrated: true, id: context.id }),",
709
+ " });",
710
+ ];
711
+ }
712
+ if (capability === "profile") {
713
+ return [
714
+ ...commandLines,
715
+ "",
716
+ " // A project profile is the broadest customization primitive pm has: one",
717
+ " // declarative bundle of item types, custom statuses, fields, a per-type",
718
+ " // workflow, config knobs, create templates, and package recommendations. Once",
719
+ " // this package is installed the profile resolves by name through `pm profile",
720
+ " // list`, `pm profile show`, and `pm profile apply`, which stages every dimension",
721
+ " // idempotently like a core archetype. A profile registration is a schema+config",
722
+ " // bundle, so the `schema` capability in manifest.json grants it.",
723
+ " api.registerProfile({",
724
+ // The archetype field lines are all non-empty, so re-indent each by the
725
+ // `activate` body offset (object braces sit at two spaces, fields at four).
726
+ ...buildProfileArchetypeFieldLines(extensionName).map((line) => ` ${line}`),
727
+ " });",
728
+ ];
729
+ }
221
730
  if (capability === "importers") {
222
731
  return [
223
732
  ...commandLines,
@@ -269,6 +778,106 @@ function buildActivateBodyLines(extensionName, commandName, capability) {
269
778
  " );",
270
779
  ];
271
780
  }
781
+ if (capability === "renderers") {
782
+ return [
783
+ ...commandLines,
784
+ "",
785
+ " // Renderer overrides customize how pm serializes a command's structured",
786
+ " // result for an output format (\"toon\" or \"json\"). pm runs this override for",
787
+ " // EVERY command's output in that format, so it scopes itself to THIS",
788
+ " // package's own command and returns null — pass-through to pm's default",
789
+ " // renderer — for everything else. Return a string to take over rendering.",
790
+ " // The `renderers` capability in manifest.json grants the registration.",
791
+ ' api.registerRenderer("toon", (context) => {',
792
+ ` if (context.command !== ${JSON.stringify(commandName)}) {`,
793
+ " return null;",
794
+ " }",
795
+ ` return ${JSON.stringify(`${extensionName}: `)} + JSON.stringify(context.result);`,
796
+ " });",
797
+ ];
798
+ }
799
+ if (capability === "parser") {
800
+ return [
801
+ // The parser starter declares its own flags so the override is runnable end
802
+ // to end through `pm <command> --shout`: the command defines the deprecated
803
+ // `--shout` alias and canonical `--upper` flag, the parser rewrites one to
804
+ // the other, and the handler surfaces the normalized value. Flag metadata
805
+ // needs the `schema` capability (declared in manifest.json).
806
+ " api.registerCommand({",
807
+ ` name: ${JSON.stringify(commandName)},`,
808
+ ' description: "Starter scaffold command. Replace with your own behavior.",',
809
+ " flags: [",
810
+ " {",
811
+ ' long: "--shout",',
812
+ ' value_type: "boolean",',
813
+ ' description: "Deprecated alias for --upper; the parser override rewrites it.",',
814
+ " },",
815
+ " {",
816
+ ' long: "--upper",',
817
+ ' value_type: "boolean",',
818
+ ' description: "Echo the canonical flag the parser override produces.",',
819
+ " },",
820
+ " ],",
821
+ " run: async (context) => ({",
822
+ " ok: true,",
823
+ ` source: ${JSON.stringify(extensionName)},`,
824
+ " command: context.command,",
825
+ " // Surfaces the normalized option so `--shout`/`--upper` is observable.",
826
+ " upper: context.options.upper === true,",
827
+ ' message: "Starter extension scaffold is active.",',
828
+ " }),",
829
+ " });",
830
+ "",
831
+ " // Parser overrides preprocess a command's parsed options BEFORE its handler",
832
+ " // runs, returning a delta — only the keys you set are merged over the parsed",
833
+ " // input. This override is scoped to THIS package's own command. Here it",
834
+ " // rewrites the deprecated `--shout` boolean alias to the canonical `--upper`",
835
+ " // flag; replace it with your command's real normalization. The `parser`",
836
+ " // capability in manifest.json grants the registration.",
837
+ ` api.registerParser(${JSON.stringify(commandName)}, (context) => {`,
838
+ " const options = { ...context.options };",
839
+ " if (options.shout === true) {",
840
+ " options.upper = true;",
841
+ " }",
842
+ " delete options.shout;",
843
+ " return { options };",
844
+ " });",
845
+ ];
846
+ }
847
+ if (capability === "preflight") {
848
+ return [
849
+ ...commandLines,
850
+ "",
851
+ " // Preflight overrides adjust pm's pre-run gate decision (extension",
852
+ " // migrations + item-format checks) before EVERY command — the last",
853
+ " // registered override wins. Return a delta of the keys you want to change",
854
+ " // (enforce_item_format_gate, run_preflight_item_format_sync,",
855
+ " // run_extension_migrations, enforce_mandatory_migration_gate); returning",
856
+ " // context.decision unchanged is a safe no-op so installing the package does",
857
+ " // not alter gate behavior — replace it with your policy, e.g.",
858
+ " // `{ run_extension_migrations: false }`. The `preflight` capability in",
859
+ " // manifest.json grants the registration.",
860
+ " api.registerPreflight((context) => context.decision);",
861
+ ];
862
+ }
863
+ if (capability === "services") {
864
+ return [
865
+ ...commandLines,
866
+ "",
867
+ " // Service overrides replace a built-in pm service. The `output_format`",
868
+ " // service renders a command's structured result; returning the payload",
869
+ " // unchanged passes through to pm's default formatting. This override scopes",
870
+ " // itself to THIS package's own command and passes every other command",
871
+ " // through, so it never disrupts unrelated output. The `services` capability",
872
+ " // in manifest.json grants the registration.",
873
+ ' api.registerService("output_format", (context) => {',
874
+ ` if (context.command !== ${JSON.stringify(commandName)}) {`,
875
+ " return context.payload;",
876
+ " }",
877
+ ` return { rendered_by: ${JSON.stringify(extensionName)}, payload: context.payload };`,
878
+ " });",
879
+ ];
880
+ }
272
881
  return [
273
882
  ...commandLines,
274
883
  "",
@@ -289,61 +898,69 @@ function buildActivateBodyLines(extensionName, commandName, capability) {
289
898
  }
290
899
  /**
291
900
  * Build the colocated `node:test` sample suite (`index.test.ts`) for the chosen
292
- * capability. Authored in TypeScript and run through `npm test` (`tsc && node
293
- * --test`), it imports the compiled `./index.js` entry under NodeNext resolution.
294
- * Every variant covers activation, command invocation, and teardown via the SDK
295
- * testing helpers; the `hooks` variant adds a test that asserts the
296
- * `after_command` hook is registered and fires cleanly through the public SDK
297
- * testing helper `runRegisteredHookForTest`.
901
+ * capability. Authored in TypeScript and run through the generated package's
902
+ * `npm test` script (typecheck first, then `node --test`, which strips types on
903
+ * Node >=22.18), it imports the `./index.ts` manifest entry directly under
904
+ * NodeNext resolution.
905
+ * Every variant covers activation, command invocation, and teardown via
906
+ * `createExtensionTestHarness`; capability variants add tests that use the
907
+ * harness-bound `assert*`/`run*` helpers and deactivate in `finally`.
298
908
  */
299
909
  function buildSampleTestSource(extensionName, commandName, capability) {
300
910
  const hooksEnabled = capability === "hooks";
301
911
  const searchEnabled = capability === "search";
302
912
  const importersEnabled = capability === "importers";
913
+ const schemaEnabled = capability === "schema";
914
+ const profileEnabled = capability === "profile";
915
+ const renderersEnabled = capability === "renderers";
916
+ const parserEnabled = capability === "parser";
917
+ const preflightEnabled = capability === "preflight";
918
+ const servicesEnabled = capability === "services";
303
919
  const capabilitiesLiteral = SAMPLE_TEST_CAPABILITIES_LITERAL[capability];
304
920
  const searchProviderName = `${extensionName}-search`;
305
921
  const vectorAdapterName = `${extensionName}-vector`;
306
922
  const adapterName = `${extensionName.replace(/-/g, " ")} items`;
923
+ const itemTypeName = extensionName;
924
+ const itemTypeFolder = `${extensionName}s`;
925
+ const fieldName = `${extensionName.replace(/-/g, "_")}_note`;
926
+ const migrationId = `${extensionName}-0001-init`;
307
927
  const importNames = [
308
- " activateExtensionForTest,",
309
928
  " assertExtensionDeactivated,",
310
- " assertRegisteredCommandContract,",
311
- ...(hooksEnabled ? [" assertRegisteredHook,"] : []),
312
- ...(searchEnabled ? [" assertRegisteredSearchProvider,", " assertRegisteredVectorStoreAdapter,"] : []),
313
- ...(importersEnabled ? [" assertRegisteredImporter,", " assertRegisteredExporter,"] : []),
314
- " deactivateExtensionForTest,",
315
- " runRegisteredCommandForTest,",
316
- ...(hooksEnabled ? [" runRegisteredHookForTest,"] : []),
317
- ...(searchEnabled ? [" runRegisteredSearchProviderForTest,", " runRegisteredVectorStoreAdapterForTest,"] : []),
318
- ...(importersEnabled ? [" runRegisteredImporterForTest,", " runRegisteredExporterForTest,"] : []),
929
+ " createExtensionTestHarness,",
319
930
  ];
320
931
  const hookTestLines = hooksEnabled
321
932
  ? [
322
933
  `test(${JSON.stringify(`${extensionName} reacts to commands via its after_command hook`)}, async () => {`,
323
- " const activation = await activateExtensionForTest(extension, {",
934
+ " const ext = await createExtensionTestHarness(extension, {",
324
935
  ` name: ${JSON.stringify(extensionName)},`,
325
936
  ` capabilities: ${capabilitiesLiteral},`,
326
937
  " });",
327
- " // assertRegisteredHook throws unless an after_command hook is registered,",
328
- " // so reaching the next line already proves the hook is wired.",
329
- " assertRegisteredHook(activation.hooks, {",
330
- ' kind: "after_command",',
331
- ` extensionName: ${JSON.stringify(extensionName)},`,
332
- " });",
333
- " // runRegisteredHookForTest fires the hook through pm's real runner with a",
334
- " // synthetic context and returns the warnings it produced; a clean hook",
335
- " // returns none. Replace the context/assertions as your hook grows.",
336
- " const warnings = await runRegisteredHookForTest(activation.hooks, {",
337
- ' kind: "after_command",',
338
- " context: {",
339
- ` command: ${JSON.stringify(commandName)},`,
340
- " args: [],",
341
- ' pm_root: "",',
342
- " ok: true,",
343
- " affected: [],",
344
- " },",
345
- " });",
346
- " assert.deepEqual(warnings, []);",
938
+ " let deactivated = false;",
939
+ " try {",
940
+ " // assertHook throws unless an after_command hook is registered, so",
941
+ " // reaching the next line already proves the hook is wired.",
942
+ " ext.assertHook({",
943
+ ' kind: "after_command",',
944
+ ` extensionName: ${JSON.stringify(extensionName)},`,
945
+ " });",
946
+ " // runHook fires the hook through pm's real runner with a synthetic",
947
+ " // context and returns the warnings it produced; a clean hook returns none.",
948
+ " // Replace the context/assertions as your hook grows.",
949
+ " const warnings = await ext.runHook({",
950
+ ' kind: "after_command",',
951
+ " context: {",
952
+ ` command: ${JSON.stringify(commandName)},`,
953
+ " args: [],",
954
+ ' pm_root: "",',
955
+ " ok: true,",
956
+ " affected: [],",
957
+ " },",
958
+ " });",
959
+ " assert.deepEqual(warnings, []);",
960
+ " const teardown = await ext.deactivate();",
961
+ " assertExtensionDeactivated(teardown);",
962
+ " deactivated = true;",
963
+ ...SAMPLE_HARNESS_FINALLY_LINES,
347
964
  "});",
348
965
  "",
349
966
  ]
@@ -351,51 +968,51 @@ function buildSampleTestSource(extensionName, commandName, capability) {
351
968
  const searchTestLines = searchEnabled
352
969
  ? [
353
970
  `test(${JSON.stringify(`${extensionName} registers and invokes search primitives`)}, async () => {`,
354
- " const activation = await activateExtensionForTest(extension, {",
971
+ " const ext = await createExtensionTestHarness(extension, {",
355
972
  ` name: ${JSON.stringify(extensionName)},`,
356
973
  ` capabilities: ${capabilitiesLiteral},`,
357
974
  " });",
358
- " assertRegisteredSearchProvider(activation.registrations, {",
359
- ` provider: ${JSON.stringify(searchProviderName)},`,
360
- ` extensionName: ${JSON.stringify(extensionName)},`,
361
- " });",
362
- " assertRegisteredVectorStoreAdapter(activation.registrations, {",
363
- ` adapter: ${JSON.stringify(vectorAdapterName)},`,
364
- ` extensionName: ${JSON.stringify(extensionName)},`,
365
- " });",
975
+ " let deactivated = false;",
976
+ " try {",
977
+ ` ext.assertSearchProvider({ provider: ${JSON.stringify(searchProviderName)}, extensionName: ${JSON.stringify(extensionName)} });`,
978
+ ` ext.assertVectorStoreAdapter({ adapter: ${JSON.stringify(vectorAdapterName)}, extensionName: ${JSON.stringify(extensionName)} });`,
366
979
  "",
367
- " // The starter provider reads only document title/id, so `settings` is a",
368
- " // minimal typed stub and `documents` carry just the fields it inspects.",
369
- " const query = await runRegisteredSearchProviderForTest(activation.registrations, {",
370
- ` provider: ${JSON.stringify(searchProviderName)},`,
371
- ' operation: "query",',
372
- " context: {",
373
- ' query: "sync",',
374
- ' mode: "semantic",',
375
- ' tokens: ["sync"],',
376
- " options: {},",
377
- " settings: {} as PmSettings,",
378
- " documents: [",
379
- ' { metadata: { id: "pm-1", title: "Sync external context" }, body: "" },',
380
- ' { metadata: { id: "pm-2", title: "Unrelated task" }, body: "" },',
381
- " ] as ItemDocument[],",
382
- " },",
383
- " });",
384
- ' assert.deepEqual(query, { hits: [{ id: "pm-1", score: 1, matched_fields: ["title"] }] });',
980
+ " // The starter provider reads only document title/id, so `settings` is a",
981
+ " // minimal typed stub and `documents` carry just the fields it inspects.",
982
+ " const query = await ext.runSearchProvider({",
983
+ ` provider: ${JSON.stringify(searchProviderName)},`,
984
+ ' operation: "query",',
985
+ " context: {",
986
+ ' query: "sync",',
987
+ ' mode: "semantic",',
988
+ ' tokens: ["sync"],',
989
+ " options: {},",
990
+ " settings: {} as PmSettings,",
991
+ " documents: [",
992
+ ' { metadata: { id: "pm-1", title: "Sync external context" }, body: "" },',
993
+ ' { metadata: { id: "pm-2", title: "Unrelated task" }, body: "" },',
994
+ " ] as ItemDocument[],",
995
+ " },",
996
+ " });",
997
+ ' assert.deepEqual(query, { hits: [{ id: "pm-1", score: 1, matched_fields: ["title"] }] });',
385
998
  "",
386
- " const embedding = await runRegisteredSearchProviderForTest(activation.registrations, {",
387
- ` provider: ${JSON.stringify(searchProviderName)},`,
388
- ' operation: "embed",',
389
- ' context: { input: "abc", settings: {} as PmSettings, model: "starter-model" },',
390
- " });",
391
- " assert.deepEqual(embedding, [3]);",
999
+ " const embedding = await ext.runSearchProvider({",
1000
+ ` provider: ${JSON.stringify(searchProviderName)},`,
1001
+ ' operation: "embed",',
1002
+ ' context: { input: "abc", settings: {} as PmSettings, model: "starter-model" },',
1003
+ " });",
1004
+ " assert.deepEqual(embedding, [3]);",
392
1005
  "",
393
- " const vectorHits = await runRegisteredVectorStoreAdapterForTest(activation.registrations, {",
394
- ` adapter: ${JSON.stringify(vectorAdapterName)},`,
395
- ' operation: "query",',
396
- " context: { vector: [0.1, 0.2], limit: 2, settings: {} as PmSettings },",
397
- " });",
398
- ' assert.deepEqual(vectorHits, [{ id: "starter-vector-hit", score: 2 }]);',
1006
+ " const vectorHits = await ext.runVectorStoreAdapter({",
1007
+ ` adapter: ${JSON.stringify(vectorAdapterName)},`,
1008
+ ' operation: "query",',
1009
+ " context: { vector: [0.1, 0.2], limit: 2, settings: {} as PmSettings },",
1010
+ " });",
1011
+ ' assert.deepEqual(vectorHits, [{ id: "starter-vector-hit", score: 2 }]);',
1012
+ " const teardown = await ext.deactivate();",
1013
+ " assertExtensionDeactivated(teardown);",
1014
+ " deactivated = true;",
1015
+ ...SAMPLE_HARNESS_FINALLY_LINES,
399
1016
  "});",
400
1017
  "",
401
1018
  ]
@@ -403,34 +1020,254 @@ function buildSampleTestSource(extensionName, commandName, capability) {
403
1020
  const importerTestLines = importersEnabled
404
1021
  ? [
405
1022
  `test(${JSON.stringify(`${extensionName} registers and invokes import/export primitives`)}, async () => {`,
406
- " const activation = await activateExtensionForTest(extension, {",
1023
+ " const ext = await createExtensionTestHarness(extension, {",
1024
+ ` name: ${JSON.stringify(extensionName)},`,
1025
+ ` capabilities: ${capabilitiesLiteral},`,
1026
+ " });",
1027
+ " let deactivated = false;",
1028
+ " try {",
1029
+ ` ext.assertImporter({ importer: ${JSON.stringify(adapterName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1030
+ ` ext.assertExporter({ exporter: ${JSON.stringify(adapterName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1031
+ "",
1032
+ " const imported = await ext.runImporter({",
1033
+ ` importer: ${JSON.stringify(adapterName)},`,
1034
+ ' options: { source: "tickets" },',
1035
+ ' args: ["batch-1"],',
1036
+ " });",
1037
+ " assert.equal(imported.handled, true);",
1038
+ ' assert.deepEqual(imported.result, { imported: 1, source: "tickets", args: ["batch-1"] });',
1039
+ "",
1040
+ " const exported = await ext.runExporter({",
1041
+ ` exporter: ${JSON.stringify(adapterName)},`,
1042
+ ' options: { destination: "archive" },',
1043
+ ' args: ["done"],',
1044
+ " });",
1045
+ " assert.equal(exported.handled, true);",
1046
+ ' assert.deepEqual(exported.result, { exported: true, destination: "archive", args: ["done"] });',
1047
+ " const teardown = await ext.deactivate();",
1048
+ " assertExtensionDeactivated(teardown);",
1049
+ " deactivated = true;",
1050
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1051
+ "});",
1052
+ "",
1053
+ ]
1054
+ : [];
1055
+ const schemaTestLines = schemaEnabled
1056
+ ? [
1057
+ `test(${JSON.stringify(`${extensionName} registers and runs its custom schema`)}, async () => {`,
1058
+ " const ext = await createExtensionTestHarness(extension, {",
407
1059
  ` name: ${JSON.stringify(extensionName)},`,
408
1060
  ` capabilities: ${capabilitiesLiteral},`,
409
1061
  " });",
410
- " assertRegisteredImporter(activation.registrations, {",
411
- ` importer: ${JSON.stringify(adapterName)},`,
412
- ` extensionName: ${JSON.stringify(extensionName)},`,
1062
+ " let deactivated = false;",
1063
+ " try {",
1064
+ " // assertItemType/Field/Migration throw unless the registration is",
1065
+ " // present, so reaching each next line already proves the wiring; assert on",
1066
+ " // the returned definitions to demonstrate inspecting registered metadata.",
1067
+ ` const itemType = ext.assertItemType({ itemType: ${JSON.stringify(itemTypeName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1068
+ ` assert.equal(itemType.itemType.folder, ${JSON.stringify(itemTypeFolder)});`,
1069
+ ` const itemField = ext.assertItemField({ field: ${JSON.stringify(fieldName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1070
+ ' assert.equal(itemField.field.type, "string");',
1071
+ ` ext.assertMigration({ migration: ${JSON.stringify(migrationId)}, extensionName: ${JSON.stringify(extensionName)}, mandatory: false });`,
1072
+ "",
1073
+ " // runMigration invokes the migration through pm's real runner with a",
1074
+ " // synthetic context and returns its result. Replace the context/assertions",
1075
+ " // as your migration grows.",
1076
+ ` const migrated = await ext.runMigration({ migration: ${JSON.stringify(migrationId)} });`,
1077
+ ` assert.deepEqual(migrated, { migrated: true, id: ${JSON.stringify(migrationId)} });`,
1078
+ " const teardown = await ext.deactivate();",
1079
+ " assertExtensionDeactivated(teardown);",
1080
+ " deactivated = true;",
1081
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1082
+ "});",
1083
+ "",
1084
+ ]
1085
+ : [];
1086
+ const profileTestLines = profileEnabled
1087
+ ? [
1088
+ `test(${JSON.stringify(`${extensionName} registers its project profile`)}, async () => {`,
1089
+ " const ext = await createExtensionTestHarness(extension, {",
1090
+ ` name: ${JSON.stringify(extensionName)},`,
1091
+ ` capabilities: ${capabilitiesLiteral},`,
413
1092
  " });",
414
- " assertRegisteredExporter(activation.registrations, {",
415
- ` exporter: ${JSON.stringify(adapterName)},`,
416
- ` extensionName: ${JSON.stringify(extensionName)},`,
1093
+ " let deactivated = false;",
1094
+ " try {",
1095
+ " // assertProfile throws unless the profile is registered, so reaching the next",
1096
+ " // line already proves the wiring; assert on the returned definition to inspect",
1097
+ " // the bundled archetype dimensions.",
1098
+ ` const { profile } = ext.assertProfile({ profile: ${JSON.stringify(extensionName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1099
+ ` assert.equal(profile.title, ${JSON.stringify(`${extensionName} archetype`)});`,
1100
+ " assert.equal(profile.types.length, 1);",
1101
+ " assert.equal(profile.workflows.length, 1);",
1102
+ " const teardown = await ext.deactivate();",
1103
+ " assertExtensionDeactivated(teardown);",
1104
+ " deactivated = true;",
1105
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1106
+ "});",
1107
+ "",
1108
+ ]
1109
+ : [];
1110
+ const rendererTestLines = renderersEnabled
1111
+ ? [
1112
+ `test(${JSON.stringify(`${extensionName} registers and invokes its renderer override`)}, async () => {`,
1113
+ " const ext = await createExtensionTestHarness(extension, {",
1114
+ ` name: ${JSON.stringify(extensionName)},`,
1115
+ ` capabilities: ${capabilitiesLiteral},`,
417
1116
  " });",
1117
+ " let deactivated = false;",
1118
+ " try {",
1119
+ " // assertRendererOverride throws unless a renderer is registered for the",
1120
+ " // format, so reaching the next line already proves the wiring.",
1121
+ ` const override = ext.assertRendererOverride({ format: "toon", extensionName: ${JSON.stringify(extensionName)} });`,
1122
+ ' assert.equal(override.format, "toon");',
1123
+ "",
1124
+ " // runRendererOverride renders through pm's real runner. The override",
1125
+ " // customizes only THIS package's command output and returns a string the",
1126
+ " // host uses verbatim. Replace the assertions as it grows.",
1127
+ " const rendered = await ext.runRendererOverride({",
1128
+ ' format: "toon",',
1129
+ ` command: ${JSON.stringify(commandName)},`,
1130
+ " result: { ok: true },",
1131
+ " });",
1132
+ " assert.equal(rendered.overridden, true);",
1133
+ ` assert.equal(rendered.rendered, ${JSON.stringify(`${extensionName}: `)} + JSON.stringify({ ok: true }));`,
1134
+ "",
1135
+ " // Output for any other command passes through to pm's default renderer.",
1136
+ " const passthrough = await ext.runRendererOverride({",
1137
+ ' format: "toon",',
1138
+ ' command: "list",',
1139
+ " result: { ok: true },",
1140
+ " });",
1141
+ " assert.equal(passthrough.overridden, false);",
1142
+ " const teardown = await ext.deactivate();",
1143
+ " assertExtensionDeactivated(teardown);",
1144
+ " deactivated = true;",
1145
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1146
+ "});",
418
1147
  "",
419
- " const imported = await runRegisteredImporterForTest(activation, {",
420
- ` importer: ${JSON.stringify(adapterName)},`,
421
- ' options: { source: "tickets" },',
422
- ' args: ["batch-1"],',
1148
+ ]
1149
+ : [];
1150
+ const parserTestLines = parserEnabled
1151
+ ? [
1152
+ `test(${JSON.stringify(`${extensionName} rewrites command options via its parser override`)}, async () => {`,
1153
+ " const ext = await createExtensionTestHarness(extension, {",
1154
+ ` name: ${JSON.stringify(extensionName)},`,
1155
+ ` capabilities: ${capabilitiesLiteral},`,
423
1156
  " });",
424
- " assert.equal(imported.handled, true);",
425
- ' assert.deepEqual(imported.result, { imported: 1, source: "tickets", args: ["batch-1"] });',
1157
+ " let deactivated = false;",
1158
+ " try {",
1159
+ " // assertParserOverride throws unless a parser is registered for the",
1160
+ " // command, so reaching the next line already proves the wiring.",
1161
+ ` ext.assertParserOverride({ command: ${JSON.stringify(commandName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1162
+ "",
1163
+ " // runParserOverride runs the override through pm's real parser runner and",
1164
+ " // returns the rewritten context. The starter rewrites the deprecated",
1165
+ " // `shout` alias to the canonical `upper` flag.",
1166
+ " const result = await ext.runParserOverride({",
1167
+ ` command: ${JSON.stringify(commandName)},`,
1168
+ " args: [],",
1169
+ " options: { shout: true },",
1170
+ " global: {},",
1171
+ ' pm_root: "",',
1172
+ " });",
1173
+ " assert.equal(result.overridden, true);",
1174
+ " assert.deepEqual(result.context.options, { upper: true });",
1175
+ "",
1176
+ " // End to end: feed the rewritten options into the command handler to",
1177
+ " // prove `pm <command> --shout` surfaces the normalized `upper` flag in",
1178
+ " // the result.",
1179
+ ` const invocation = await ext.runCommand({ command: ${JSON.stringify(commandName)}, options: result.context.options });`,
1180
+ " assert.equal(invocation.handled, true);",
1181
+ " assert.deepEqual(invocation.result, {",
1182
+ " ok: true,",
1183
+ ` source: ${JSON.stringify(extensionName)},`,
1184
+ ` command: ${JSON.stringify(commandName)},`,
1185
+ " upper: true,",
1186
+ ' message: "Starter extension scaffold is active.",',
1187
+ " });",
1188
+ " const teardown = await ext.deactivate();",
1189
+ " assertExtensionDeactivated(teardown);",
1190
+ " deactivated = true;",
1191
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1192
+ "});",
426
1193
  "",
427
- " const exported = await runRegisteredExporterForTest(activation, {",
428
- ` exporter: ${JSON.stringify(adapterName)},`,
429
- ' options: { destination: "archive" },',
430
- ' args: ["done"],',
1194
+ ]
1195
+ : [];
1196
+ const preflightTestLines = preflightEnabled
1197
+ ? [
1198
+ `test(${JSON.stringify(`${extensionName} returns a preflight gate decision via its override`)}, async () => {`,
1199
+ " const ext = await createExtensionTestHarness(extension, {",
1200
+ ` name: ${JSON.stringify(extensionName)},`,
1201
+ ` capabilities: ${capabilitiesLiteral},`,
431
1202
  " });",
432
- " assert.equal(exported.handled, true);",
433
- ' assert.deepEqual(exported.result, { exported: true, destination: "archive", args: ["done"] });',
1203
+ " let deactivated = false;",
1204
+ " try {",
1205
+ " // assertPreflightOverride throws unless a preflight override is",
1206
+ " // registered, so reaching the next line already proves the wiring.",
1207
+ ` ext.assertPreflightOverride({ extensionName: ${JSON.stringify(extensionName)} });`,
1208
+ "",
1209
+ " // runPreflightOverride runs the override through pm's real runner with a",
1210
+ " // synthetic gate decision. The starter echoes the decision unchanged;",
1211
+ " // replace the values/assertions with your real policy.",
1212
+ " const decision = {",
1213
+ " enforce_item_format_gate: true,",
1214
+ " run_preflight_item_format_sync: false,",
1215
+ " run_extension_migrations: true,",
1216
+ " enforce_mandatory_migration_gate: false,",
1217
+ " };",
1218
+ " const result = await ext.runPreflightOverride({",
1219
+ ` command: ${JSON.stringify(commandName)},`,
1220
+ " args: [],",
1221
+ " options: {},",
1222
+ " global: {},",
1223
+ ' pm_root: "",',
1224
+ " decision,",
1225
+ " });",
1226
+ " assert.equal(result.overridden, true);",
1227
+ " assert.deepEqual(result.decision, decision);",
1228
+ " const teardown = await ext.deactivate();",
1229
+ " assertExtensionDeactivated(teardown);",
1230
+ " deactivated = true;",
1231
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1232
+ "});",
1233
+ "",
1234
+ ]
1235
+ : [];
1236
+ const serviceTestLines = servicesEnabled
1237
+ ? [
1238
+ `test(${JSON.stringify(`${extensionName} customizes command output via its service override`)}, async () => {`,
1239
+ " const ext = await createExtensionTestHarness(extension, {",
1240
+ ` name: ${JSON.stringify(extensionName)},`,
1241
+ ` capabilities: ${capabilitiesLiteral},`,
1242
+ " });",
1243
+ " let deactivated = false;",
1244
+ " try {",
1245
+ " // assertServiceOverride throws unless a service override is registered",
1246
+ " // for the service, so reaching the next line proves the wiring.",
1247
+ ` ext.assertServiceOverride({ service: "output_format", extensionName: ${JSON.stringify(extensionName)} });`,
1248
+ "",
1249
+ " // runServiceOverride runs the override through pm's real service runner.",
1250
+ " // The override customizes only THIS package's command output (handled),",
1251
+ " // passing every other command through (not handled).",
1252
+ " const handled = await ext.runServiceOverride({",
1253
+ ' service: "output_format",',
1254
+ ` command: ${JSON.stringify(commandName)},`,
1255
+ " payload: { ok: true },",
1256
+ " });",
1257
+ " assert.equal(handled.handled, true);",
1258
+ ` assert.deepEqual(handled.result, { rendered_by: ${JSON.stringify(extensionName)}, payload: { ok: true } });`,
1259
+ "",
1260
+ " // Output for any other command passes through to pm's default formatter.",
1261
+ " const passthrough = await ext.runServiceOverride({",
1262
+ ' service: "output_format",',
1263
+ ' command: "list",',
1264
+ " payload: { ok: true },",
1265
+ " });",
1266
+ " assert.equal(passthrough.handled, false);",
1267
+ " const teardown = await ext.deactivate();",
1268
+ " assertExtensionDeactivated(teardown);",
1269
+ " deactivated = true;",
1270
+ ...SAMPLE_HARNESS_FINALLY_LINES,
434
1271
  "});",
435
1272
  "",
436
1273
  ]
@@ -444,50 +1281,68 @@ function buildSampleTestSource(extensionName, commandName, capability) {
444
1281
  // The search sample's synthetic query/vector contexts reference these SDK types
445
1282
  // for their typed-stub fixtures; other capabilities need no extra type imports.
446
1283
  ...(searchEnabled ? ['import type { ItemDocument, PmSettings } from "@unbrained/pm-cli/sdk";'] : []),
447
- 'import extension from "./index.js";',
1284
+ 'import extension from "./index.ts";',
448
1285
  "",
1286
+ ...SAMPLE_HARNESS_CLEANUP_LINES,
449
1287
  `test(${JSON.stringify(`${extensionName} registers its starter command`)}, async () => {`,
450
1288
  " // `capabilities` mirrors manifest.json so the in-memory activation grants",
451
1289
  " // the capabilities the entrypoint relies on.",
452
- " const activation = await activateExtensionForTest(extension, {",
1290
+ " const ext = await createExtensionTestHarness(extension, {",
453
1291
  ` name: ${JSON.stringify(extensionName)},`,
454
1292
  ` capabilities: ${capabilitiesLiteral},`,
455
1293
  " });",
456
- " // assertRegisteredCommandContract throws if the command is not",
457
- " // registered, so reaching here already proves the wiring; assert on the",
458
- " // returned definition to demonstrate inspecting registered metadata.",
459
- " const registered = assertRegisteredCommandContract(activation.registrations, {",
460
- ` command: ${JSON.stringify(commandName)},`,
461
- ` extensionName: ${JSON.stringify(extensionName)},`,
462
- " });",
463
- ' assert.equal(typeof registered.command.description, "string");',
1294
+ " let deactivated = false;",
1295
+ " try {",
1296
+ " // assertCommandContract is bound to the right activation registry and throws",
1297
+ " // if the command is not registered, so reaching here already proves the",
1298
+ " // wiring; assert on the returned definition to inspect metadata.",
1299
+ " const registered = ext.assertCommandContract({",
1300
+ ` command: ${JSON.stringify(commandName)},`,
1301
+ ` extensionName: ${JSON.stringify(extensionName)},`,
1302
+ " });",
1303
+ ' assert.equal(typeof registered.command.description, "string");',
464
1304
  "",
465
- " // runRegisteredCommandForTest invokes the handler through pm's real",
466
- " // dispatch engine, so this asserts behavior - not just that the command",
467
- " // is wired. Replace these assertions as you flesh out your command.",
468
- " const invocation = await runRegisteredCommandForTest(activation.commands, {",
469
- ` command: ${JSON.stringify(commandName)},`,
470
- " });",
471
- " assert.equal(invocation.handled, true);",
472
- " // The handler result is typed `unknown`, so deep-equality on the whole",
473
- " // structured payload keeps the assertion type-safe without a cast.",
474
- " assert.deepEqual(invocation.result, {",
475
- " ok: true,",
476
- ` source: ${JSON.stringify(extensionName)},`,
477
- ` command: ${JSON.stringify(commandName)},`,
478
- ' message: "Starter extension scaffold is active.",',
479
- " });",
1305
+ " // runCommand invokes the handler through pm's real dispatch engine, so this",
1306
+ " // asserts behavior - not just that the command is wired. Replace these",
1307
+ " // assertions as you flesh out your command.",
1308
+ " const invocation = await ext.runCommand({",
1309
+ ` command: ${JSON.stringify(commandName)},`,
1310
+ " });",
1311
+ " assert.equal(invocation.handled, true);",
1312
+ " // The handler result is typed `unknown`, so deep-equality on the whole",
1313
+ " // structured payload keeps the assertion type-safe without a cast.",
1314
+ " assert.deepEqual(invocation.result, {",
1315
+ " ok: true,",
1316
+ ` source: ${JSON.stringify(extensionName)},`,
1317
+ ` command: ${JSON.stringify(commandName)},`,
1318
+ // The parser starter's command surfaces the normalized `upper` flag, which
1319
+ // defaults to false when the command is invoked without `--shout`/`--upper`.
1320
+ ...(parserEnabled ? [" upper: false,"] : []),
1321
+ ' message: "Starter extension scaffold is active.",',
1322
+ " });",
1323
+ " const teardown = await ext.deactivate();",
1324
+ " assertExtensionDeactivated(teardown);",
1325
+ " deactivated = true;",
1326
+ ...SAMPLE_HARNESS_FINALLY_LINES,
480
1327
  "});",
481
1328
  "",
482
1329
  ...hookTestLines,
483
1330
  ...searchTestLines,
484
1331
  ...importerTestLines,
1332
+ ...schemaTestLines,
1333
+ ...profileTestLines,
1334
+ ...rendererTestLines,
1335
+ ...parserTestLines,
1336
+ ...preflightTestLines,
1337
+ ...serviceTestLines,
485
1338
  `test(${JSON.stringify(`${extensionName} tears down cleanly via deactivate`)}, async () => {`,
486
- " // deactivateExtensionForTest runs pm's real teardown engine over the",
487
- " // module, so this proves your `deactivate` hook runs without throwing.",
488
- " const teardown = await deactivateExtensionForTest(extension, {",
1339
+ " // createExtensionTestHarness binds teardown to the same name/layer used for",
1340
+ " // activation, so this proves your `deactivate` hook runs without throwing.",
1341
+ " const ext = await createExtensionTestHarness(extension, {",
489
1342
  ` name: ${JSON.stringify(extensionName)},`,
1343
+ ` capabilities: ${capabilitiesLiteral},`,
490
1344
  " });",
1345
+ " const teardown = await ext.deactivate();",
491
1346
  " // assertExtensionDeactivated throws unless exactly one extension tore down",
492
1347
  " // with no failures, so reaching the next line already proves teardown ran.",
493
1348
  " assertExtensionDeactivated(teardown);",
@@ -496,28 +1351,886 @@ function buildSampleTestSource(extensionName, commandName, capability) {
496
1351
  "",
497
1352
  ].join("\n");
498
1353
  }
1354
+ /**
1355
+ * Build the manifest `activation.commands` list for the chosen capability: the
1356
+ * exact command paths the starter `activate` registers.
1357
+ *
1358
+ * pm uses this list for lazy activation — it imports and activates the package
1359
+ * only when an invoked command path matches one of these entries — so it must
1360
+ * stay in sync with the registrations in {@link buildActivateBodyLines}. Every
1361
+ * first-party bundled package declares the same field; emitting it keeps
1362
+ * generated packages on that convention so they get precise, lazy, correct
1363
+ * activation instead of falling back to capability heuristics (which cannot
1364
+ * enumerate the contributed commands). The `importers` variant additionally
1365
+ * registers paired import/export command handlers under the adapter name.
1366
+ *
1367
+ * The `schema` and `profile` variants are the deliberate exceptions: each returns
1368
+ * an empty list so the manifest omits `activation.commands`. Custom item types and
1369
+ * fields are GLOBAL schema contributions that built-in commands (`pm create
1370
+ * <type>`, `pm list --type <type>`, `pm validate`) must see, and a contributed
1371
+ * project profile is resolved by the built-in `pm profile list/show/apply` commands
1372
+ * — commands the package does not own and cannot enumerate. Declaring narrow
1373
+ * `activation.commands` there would gate activation to only the listed commands and
1374
+ * silently leave the custom type or profile unregistered for those built-ins;
1375
+ * omitting it lets pm's conservative activation tier (which covers `schema`) load
1376
+ * the package for every command.
1377
+ */
1378
+ function buildScaffoldActivationCommands(extensionName, commandName, capability) {
1379
+ if (capability === "schema" || capability === "profile") {
1380
+ return [];
1381
+ }
1382
+ if (capability === "importers") {
1383
+ const adapterName = `${extensionName.replace(/-/g, " ")} items`;
1384
+ return [commandName, `${adapterName} import`, `${adapterName} export`];
1385
+ }
1386
+ return [commandName];
1387
+ }
1388
+ // One-line surface phrase per capability, listing the registration surfaces the
1389
+ // declarative blueprint populates beyond the always-present starter command. Used
1390
+ // to keep the generated README's entrypoint bullet accurate per capability.
1391
+ const DECLARATIVE_ENTRYPOINT_SURFACE_PHRASE = {
1392
+ commands: "starter command",
1393
+ hooks: "starter command and after_command hook",
1394
+ search: "starter command, search provider, and vector-store adapter",
1395
+ importers: "starter command, importer, and exporter",
1396
+ schema: "starter command, custom item type, item field, and migration",
1397
+ profile: "starter command and project profile",
1398
+ renderers: "starter command and toon renderer override",
1399
+ parser: "starter command and parser override",
1400
+ preflight: "starter command and preflight override",
1401
+ services: "starter command and output_format service override",
1402
+ };
1403
+ // The `ExtensionBlueprint` fields each capability populates, rendered as inline
1404
+ // code in the README's Declarative Authoring section so authors can see which
1405
+ // blueprint surface maps to the capability they scaffolded.
1406
+ const DECLARATIVE_CAPABILITY_BLUEPRINT_FIELDS = {
1407
+ commands: "`commands`",
1408
+ hooks: "`commands` and `hooks.afterCommand`",
1409
+ search: "`commands`, `searchProviders`, and `vectorStoreAdapters`",
1410
+ importers: "`commands`, `importers`, and `exporters`",
1411
+ schema: "`commands`, `itemTypes`, `itemFields`, and `migrations`",
1412
+ profile: "`commands` and `profiles`",
1413
+ renderers: "`commands` and `renderers`",
1414
+ parser: "`commands` and `parsers`",
1415
+ preflight: "`commands` and `preflights`",
1416
+ services: "`commands` and `services`",
1417
+ };
1418
+ /**
1419
+ * Build the `defineCommand` starter-command definition for the declarative
1420
+ * entrypoint. Mirrors the imperative {@link buildActivateBodyLines} command body
1421
+ * (same name/description/run result), and for the `parser` capability declares the
1422
+ * `--shout`/`--upper` flags and surfaces the normalized `upper` option so the
1423
+ * override is runnable end to end through `pm <command> --shout`.
1424
+ */
1425
+ function buildDeclarativePingCommandLines(extensionName, commandName, capability) {
1426
+ const parserEnabled = capability === "parser";
1427
+ return [
1428
+ "// The starter command, authored with the `defineCommand` builder so its literal",
1429
+ "// name is preserved and the handler `context` is inferred. Exporting it lets you",
1430
+ "// unit-test the definition in isolation, apart from the blueprint.",
1431
+ "export const pingCommand = defineCommand({",
1432
+ ` name: ${JSON.stringify(commandName)},`,
1433
+ ' description: "Starter scaffold command. Replace with your own behavior.",',
1434
+ ...(parserEnabled
1435
+ ? [
1436
+ " flags: [",
1437
+ " {",
1438
+ ' long: "--shout",',
1439
+ ' value_type: "boolean",',
1440
+ ' description: "Deprecated alias for --upper; the parser override rewrites it.",',
1441
+ " },",
1442
+ " {",
1443
+ ' long: "--upper",',
1444
+ ' value_type: "boolean",',
1445
+ ' description: "Echo the canonical flag the parser override produces.",',
1446
+ " },",
1447
+ " ],",
1448
+ ]
1449
+ : []),
1450
+ " run: async (context) => ({",
1451
+ " ok: true,",
1452
+ ` source: ${JSON.stringify(extensionName)},`,
1453
+ " command: context.command,",
1454
+ ...(parserEnabled ? [" upper: context.options.upper === true,"] : []),
1455
+ ' message: "Starter extension scaffold is active.",',
1456
+ " }),",
1457
+ "});",
1458
+ ];
1459
+ }
1460
+ /**
1461
+ * Build the {@link DeclarativeBlueprintSurface} for a capability: the starter
1462
+ * command plus the capability's `define*`-authored registration definitions and
1463
+ * the `ExtensionBlueprint` fields that collect them.
1464
+ *
1465
+ * Blueprint fields are emitted in {@link composeExtension}'s registration order so
1466
+ * the generated `activate` wires them deterministically. Each surface mirrors the
1467
+ * imperative {@link buildActivateBodyLines} registration (same names, same handler
1468
+ * behavior) so a package scaffolded in either style installs and dispatches
1469
+ * identically — the manifest, derived capabilities, and registered surfaces match.
1470
+ */
1471
+ function buildDeclarativeBlueprintSurface(extensionName, commandName, capability) {
1472
+ const builderImports = [];
1473
+ const definitions = [...buildDeclarativePingCommandLines(extensionName, commandName, capability)];
1474
+ const blueprintFields = [" commands: [pingCommand],"];
1475
+ const searchProviderName = `${extensionName}-search`;
1476
+ const vectorAdapterName = `${extensionName}-vector`;
1477
+ const adapterName = `${extensionName.replace(/-/g, " ")} items`;
1478
+ const itemTypeName = extensionName;
1479
+ const itemTypeFolder = `${extensionName}s`;
1480
+ // De-hyphenate for a short alias; omit a redundant self-alias for single-word names.
1481
+ const itemTypeAlias = extensionName.replace(/-/g, "");
1482
+ const itemTypeAliases = itemTypeAlias === itemTypeName ? [] : [itemTypeAlias];
1483
+ const fieldName = `${extensionName.replace(/-/g, "_")}_note`;
1484
+ const migrationId = `${extensionName}-0001-init`;
1485
+ switch (capability) {
1486
+ case "commands":
1487
+ break;
1488
+ case "hooks":
1489
+ builderImports.push("defineAfterCommandHook");
1490
+ definitions.push("", "// after_command hooks fire once pm finishes a command, receiving the items it", "// mutated. React here - sync to an external system, emit telemetry, or refresh", '// derived context ("project management = context management"). This starter is a', "// documented no-op on the success path; replace the body with your own reaction.", "export const afterCommandHook = defineAfterCommandHook((context) => {", " if (!context.ok) {", " return;", " }", " // `context.affected` lists the items pm mutated (id, status, changed_fields):", " // for (const item of context.affected ?? []) { /* ...item.id... */ }", "});");
1491
+ blueprintFields.push(" hooks: { afterCommand: [afterCommandHook] },");
1492
+ break;
1493
+ case "search":
1494
+ builderImports.push("defineSearchProvider", "defineVectorStoreAdapter");
1495
+ definitions.push("", "// Search providers let packages customize how pm ranks and retrieves project", "// context. This starter is deterministic and dependency-free: replace the scoring", "// with your domain retrieval, embedding, or rerank logic as the package grows.", "export const searchProvider = defineSearchProvider({", ` name: ${JSON.stringify(searchProviderName)},`, " query: async (context) => {", " const needle = context.query.toLowerCase();", " const hits = context.documents", " .filter((document) => {", ' const title = String(document.metadata.title ?? "").toLowerCase();', " return title.includes(needle);", " })", " .map((document) => ({", " id: document.metadata.id,", " score: 1,", ' matched_fields: ["title"],', " }));", " return { hits };", " },", " embed: async (context) => [context.input.length],", "});", "", "// Vector-store adapters let packages own semantic index storage. This starter", "// returns a stable in-memory hit so generated tests can exercise the adapter", "// without external services.", "export const vectorStoreAdapter = defineVectorStoreAdapter({", ` name: ${JSON.stringify(vectorAdapterName)},`, ' query: async (context) => [{ id: "starter-vector-hit", score: context.limit }],', " upsert: async (context) => ({ upserted: context.points.length }),", " delete: async (context) => ({ deleted: context.ids.length }),", "});");
1496
+ blueprintFields.push(" searchProviders: [searchProvider],", " vectorStoreAdapters: [vectorStoreAdapter],");
1497
+ break;
1498
+ case "importers":
1499
+ builderImports.push("defineExporter", "defineImporter");
1500
+ definitions.push("", "// Importers/exporters are the bridge between pm's context graph and another", "// project-management system. Keep the starter deterministic so package tests can", "// run without touching the network or filesystem; replace these payloads with", "// your adapter's real mapping as the package grows.", "export const importer = defineImporter(async (context) => ({", " imported: 1,", ' source: context.options.source ?? "starter",', " args: context.args,", "}));", "", "export const exporter = defineExporter(async (context) => ({", " exported: true,", ' destination: context.options.destination ?? "stdout",', " args: context.args,", "}));");
1501
+ blueprintFields.push(" importers: [", " {", ` name: ${JSON.stringify(adapterName)},`, " importer,", " options: {", ` action: ${JSON.stringify(`${adapterName} import`)},`, ' description: "Import starter records into pm context.",', " flags: [", " {", ' long: "--source",', ' value_name: "name",', ' value_type: "string",', ' description: "Source name or path to import from.",', " },", " ],", " },", " },", " ],", " exporters: [", " {", ` name: ${JSON.stringify(adapterName)},`, " exporter,", " options: {", ` action: ${JSON.stringify(`${adapterName} export`)},`, ' description: "Export pm context into starter records.",', " flags: [", " {", ' long: "--destination",', ' value_name: "name",', ' value_type: "string",', ' description: "Destination name or path to export to.",', " },", " ],", " },", " },", " ],");
1502
+ break;
1503
+ case "schema":
1504
+ builderImports.push("defineItemField", "defineItemType", "defineMigration");
1505
+ definitions.push("", "// Schema registrations let a package model its own project domain - the heart of", '// "project management = context management". Item types and fields are GLOBAL', "// contributions, so this package declares no `activation.commands` and pm", "// activates it conservatively for every command.", "export const noteField = defineItemField({", ` name: ${JSON.stringify(fieldName)},`, ' type: "string",', " optional: true,", "});", "", "export const itemType = defineItemType({", ` name: ${JSON.stringify(itemTypeName)},`, " // Replace with your domain's canonical plural folder name.", ` folder: ${JSON.stringify(itemTypeFolder)},`, ` aliases: ${JSON.stringify(itemTypeAliases)},`, " // Add field names here to force them at `pm create` time.", " required_create_fields: [],", "});", "", "// Migrations let a package evolve stored items as its schema changes. pm runs each", "// migration ONCE through the preflight gate (not once per item), passing a context", "// that identifies the migration itself: `context.id` is the migration id (not an", "// item id), alongside `context.pm_root`. This starter is a deterministic no-op so", "// package tests can invoke it without touching the corpus; replace the body with", "// your real rewrite.", "export const initMigration = defineMigration({", ` id: ${JSON.stringify(migrationId)},`, ` description: ${JSON.stringify(`Initialize ${extensionName} schema state.`)},`, " mandatory: false,", " run: async (context) => ({ migrated: true, id: context.id }),", "});");
1506
+ blueprintFields.push(" itemTypes: [itemType],", " itemFields: [noteField],", " migrations: [initMigration],");
1507
+ break;
1508
+ case "profile":
1509
+ builderImports.push("defineProjectProfile");
1510
+ definitions.push("", "// A project profile is the broadest customization primitive pm has: one", "// declarative bundle of item types, custom statuses, fields, a per-type workflow,", "// config knobs, create templates, and package recommendations. Once installed it", "// resolves by name through `pm profile list/show/apply`, which stages every", "// dimension idempotently like a core archetype. A profile registration is a", "// schema+config bundle, so the `schema` capability grants it.", "export const starterProfile = defineProjectProfile({", ...buildProfileArchetypeFieldLines(extensionName), "});");
1511
+ blueprintFields.push(" profiles: [starterProfile],");
1512
+ break;
1513
+ case "renderers":
1514
+ builderImports.push("defineRendererOverride");
1515
+ definitions.push("", "// Renderer overrides customize how pm serializes a command's structured result", '// for an output format ("toon" or "json"). pm runs this override for EVERY', "// command's output in that format, so it scopes itself to THIS package's own", "// command and returns null - pass-through to pm's default renderer - for", "// everything else. Return a string to take over rendering.", "export const toonRenderer = defineRendererOverride((context) => {", ` if (context.command !== ${JSON.stringify(commandName)}) {`, " return null;", " }", ` return ${JSON.stringify(`${extensionName}: `)} + JSON.stringify(context.result);`, "});");
1516
+ blueprintFields.push(" renderers: { toon: toonRenderer },");
1517
+ break;
1518
+ case "parser":
1519
+ builderImports.push("defineParserOverride");
1520
+ definitions.push("", "// Parser overrides preprocess a command's parsed options BEFORE its handler runs,", "// returning a delta - only the keys you set are merged over the parsed input. This", "// override is scoped to THIS package's own command; here it rewrites the deprecated", "// `--shout` boolean alias to the canonical `--upper` flag.", "export const pingParser = defineParserOverride((context) => {", " const options = { ...context.options };", " if (options.shout === true) {", " options.upper = true;", " }", " delete options.shout;", " return { options };", "});");
1521
+ blueprintFields.push(` parsers: { ${JSON.stringify(commandName)}: pingParser },`);
1522
+ break;
1523
+ case "preflight":
1524
+ builderImports.push("definePreflightOverride");
1525
+ definitions.push("", "// Preflight overrides adjust pm's pre-run gate decision (extension migrations +", "// item-format checks) before EVERY command - the last registered override wins.", "// Return a delta of the keys you want to change (enforce_item_format_gate,", "// run_preflight_item_format_sync, run_extension_migrations,", "// enforce_mandatory_migration_gate); returning context.decision unchanged is a", "// safe no-op - replace it with your policy, e.g. { run_extension_migrations: false }.", "export const preflightOverride = definePreflightOverride((context) => context.decision);");
1526
+ blueprintFields.push(" preflights: [preflightOverride],");
1527
+ break;
1528
+ case "services":
1529
+ builderImports.push("defineServiceOverride");
1530
+ definitions.push("", "// Service overrides replace a built-in pm service. The `output_format` service", "// renders a command's structured result; returning the payload unchanged passes", "// through to pm's default formatting. This override scopes itself to THIS", "// package's own command and passes every other command through.", "export const outputService = defineServiceOverride((context) => {", ` if (context.command !== ${JSON.stringify(commandName)}) {`, " return context.payload;", " }", ` return { rendered_by: ${JSON.stringify(extensionName)}, payload: context.payload };`, "});");
1531
+ blueprintFields.push(" services: { output_format: outputService },");
1532
+ break;
1533
+ }
1534
+ return { builderImports, definitions, blueprintFields };
1535
+ }
1536
+ /**
1537
+ * Build the declarative (`composeExtension`) variant of the starter `index.ts` for
1538
+ * the chosen capability.
1539
+ *
1540
+ * Where {@link buildActivateBodyLines} emits an imperative `activate` that calls
1541
+ * `api.register*` directly, this emits the SDK's flagship declarative loop: the
1542
+ * capability's surfaces are authored with the `define*` builders (via the shared
1543
+ * {@link buildDeclarativeBlueprintSurface}), collected into an `ExtensionBlueprint`
1544
+ * by `defineExtensionBlueprint`, and turned into the runtime module by
1545
+ * `composeExtension` (which generates the `activate` that registers every blueprint
1546
+ * surface in order). Every definition, the blueprint, and the module are exported
1547
+ * so the colocated test can preflight the blueprint and exercise the module — see
1548
+ * {@link buildDeclarativeSampleTestSource}.
1549
+ *
1550
+ * It is package-mode by construction: `composeExtension` is a runtime SDK *value*
1551
+ * import, so it belongs in package-mode authoring where the SDK is a linked
1552
+ * dependency, not in the import-free extension-only starters.
1553
+ * {@link scaffoldExtensionProject} enforces that constraint before this is reached.
1554
+ */
1555
+ function buildDeclarativeEntrypoint(extensionName, commandName, capability) {
1556
+ const surface = buildDeclarativeBlueprintSurface(extensionName, commandName, capability);
1557
+ // `composeExtension`/`defineCommand`/`defineExtensionBlueprint` are always needed;
1558
+ // sort the full set so the import line is stable and idiomatic per capability.
1559
+ const builderImports = [
1560
+ "composeExtension",
1561
+ "defineCommand",
1562
+ "defineExtensionBlueprint",
1563
+ ...surface.builderImports,
1564
+ ].sort((left, right) => left.localeCompare(right));
1565
+ return [
1566
+ `import { ${builderImports.join(", ")} } from "@unbrained/pm-cli/sdk";`,
1567
+ "",
1568
+ ...surface.definitions,
1569
+ "",
1570
+ "// Declarative authoring: describe WHAT the package registers as a blueprint and",
1571
+ "// let `composeExtension` generate the `activate` that wires every surface in order,",
1572
+ "// instead of hand-writing each `api.register*` call. `defineExtensionBlueprint`",
1573
+ "// contract-checks the blueprint where it is authored. Keep `manifest.json`'s",
1574
+ "// `capabilities` equal to the set this blueprint derives.",
1575
+ "export const blueprint = defineExtensionBlueprint({",
1576
+ ...surface.blueprintFields,
1577
+ " // `deactivate` is the teardown counterpart to the generated `activate`: pm runs",
1578
+ " // it on host shutdown/reload to release anything the package opened (timers,",
1579
+ " // connections, caches). This starter holds none, so it stays a no-op.",
1580
+ " deactivate: () => {},",
1581
+ "});",
1582
+ "",
1583
+ "// `composeExtension(blueprint)` is the package's default export — the runtime",
1584
+ "// `ExtensionModule` pm loads. Guard the blueprint with `assertExtensionPreflight`",
1585
+ "// in index.test.ts before publishing.",
1586
+ "export default composeExtension(blueprint);",
1587
+ "",
1588
+ ].join("\n");
1589
+ }
1590
+ /**
1591
+ * Build the capability-specific `node:test` block for the declarative starter:
1592
+ * a dedicated test that activates the composed module through
1593
+ * {@link ExtensionTestHarness} and asserts + invokes the capability's surface
1594
+ * (hook, search provider/adapter, importer/exporter, schema, renderer, parser,
1595
+ * preflight, or service override). Returns `[]` for the `commands` capability,
1596
+ * whose only surface — the starter command — is already covered by the base test.
1597
+ *
1598
+ * Each block mirrors the imperative {@link buildSampleTestSource} capability test
1599
+ * but reaches it through the harness's bound `assert*`/`run*` helpers instead of
1600
+ * the standalone helpers, so the declarative starter never threads
1601
+ * `activation.registrations` / `activation.parsers` / ... by hand.
1602
+ */
1603
+ function buildDeclarativeCapabilityTestBlock(extensionName, commandName, capability, capabilitiesLiteral) {
1604
+ if (capability === "commands") {
1605
+ return [];
1606
+ }
1607
+ const searchProviderName = `${extensionName}-search`;
1608
+ const vectorAdapterName = `${extensionName}-vector`;
1609
+ const adapterName = `${extensionName.replace(/-/g, " ")} items`;
1610
+ const itemTypeName = extensionName;
1611
+ const itemTypeFolder = `${extensionName}s`;
1612
+ const fieldName = `${extensionName.replace(/-/g, "_")}_note`;
1613
+ const migrationId = `${extensionName}-0001-init`;
1614
+ const harness = [
1615
+ " const ext = await createExtensionTestHarness(extension, {",
1616
+ ` name: ${JSON.stringify(extensionName)},`,
1617
+ ` capabilities: ${capabilitiesLiteral},`,
1618
+ " });",
1619
+ ];
1620
+ const withHarnessCleanup = (body) => [
1621
+ ...harness,
1622
+ " let deactivated = false;",
1623
+ " try {",
1624
+ ...body.map((line) => (line === "" ? line : ` ${line}`)),
1625
+ " const teardown = await ext.deactivate();",
1626
+ " assertExtensionDeactivated(teardown);",
1627
+ " deactivated = true;",
1628
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1629
+ ];
1630
+ switch (capability) {
1631
+ case "hooks":
1632
+ return [
1633
+ `test(${JSON.stringify(`${extensionName} reacts to commands via its after_command hook`)}, async () => {`,
1634
+ ...withHarnessCleanup([
1635
+ " // assertHook throws unless an after_command hook is registered, so reaching the",
1636
+ " // next line already proves the hook is wired.",
1637
+ ` ext.assertHook({ kind: "after_command", extensionName: ${JSON.stringify(extensionName)} });`,
1638
+ " // runHook fires the hook through pm's real runner with a synthetic context and",
1639
+ " // returns the warnings it produced; a clean hook returns none.",
1640
+ " const warnings = await ext.runHook({",
1641
+ ' kind: "after_command",',
1642
+ " context: {",
1643
+ ` command: ${JSON.stringify(commandName)},`,
1644
+ " args: [],",
1645
+ ' pm_root: "",',
1646
+ " ok: true,",
1647
+ " affected: [],",
1648
+ " },",
1649
+ " });",
1650
+ " assert.deepEqual(warnings, []);",
1651
+ ]),
1652
+ "});",
1653
+ "",
1654
+ ];
1655
+ case "search":
1656
+ return [
1657
+ `test(${JSON.stringify(`${extensionName} registers and invokes search primitives`)}, async () => {`,
1658
+ ...withHarnessCleanup([
1659
+ ` ext.assertSearchProvider({ provider: ${JSON.stringify(searchProviderName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1660
+ ` ext.assertVectorStoreAdapter({ adapter: ${JSON.stringify(vectorAdapterName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1661
+ "",
1662
+ " // The starter provider reads only document title/id, so `settings` is a minimal",
1663
+ " // typed stub and `documents` carry just the fields it inspects.",
1664
+ " const query = await ext.runSearchProvider({",
1665
+ ` provider: ${JSON.stringify(searchProviderName)},`,
1666
+ ' operation: "query",',
1667
+ " context: {",
1668
+ ' query: "sync",',
1669
+ ' mode: "semantic",',
1670
+ ' tokens: ["sync"],',
1671
+ " options: {},",
1672
+ " settings: {} as PmSettings,",
1673
+ " documents: [",
1674
+ ' { metadata: { id: "pm-1", title: "Sync external context" }, body: "" },',
1675
+ ' { metadata: { id: "pm-2", title: "Unrelated task" }, body: "" },',
1676
+ " ] as ItemDocument[],",
1677
+ " },",
1678
+ " });",
1679
+ ' assert.deepEqual(query, { hits: [{ id: "pm-1", score: 1, matched_fields: ["title"] }] });',
1680
+ "",
1681
+ " const embedding = await ext.runSearchProvider({",
1682
+ ` provider: ${JSON.stringify(searchProviderName)},`,
1683
+ ' operation: "embed",',
1684
+ ' context: { input: "abc", settings: {} as PmSettings, model: "starter-model" },',
1685
+ " });",
1686
+ " assert.deepEqual(embedding, [3]);",
1687
+ "",
1688
+ " const vectorHits = await ext.runVectorStoreAdapter({",
1689
+ ` adapter: ${JSON.stringify(vectorAdapterName)},`,
1690
+ ' operation: "query",',
1691
+ " context: { vector: [0.1, 0.2], limit: 2, settings: {} as PmSettings },",
1692
+ " });",
1693
+ ' assert.deepEqual(vectorHits, [{ id: "starter-vector-hit", score: 2 }]);',
1694
+ ]),
1695
+ "});",
1696
+ "",
1697
+ ];
1698
+ case "importers":
1699
+ return [
1700
+ `test(${JSON.stringify(`${extensionName} registers and invokes import/export primitives`)}, async () => {`,
1701
+ ...withHarnessCleanup([
1702
+ ` ext.assertImporter({ importer: ${JSON.stringify(adapterName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1703
+ ` ext.assertExporter({ exporter: ${JSON.stringify(adapterName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1704
+ "",
1705
+ " const imported = await ext.runImporter({",
1706
+ ` importer: ${JSON.stringify(adapterName)},`,
1707
+ ' options: { source: "tickets" },',
1708
+ ' args: ["batch-1"],',
1709
+ " });",
1710
+ " assert.equal(imported.handled, true);",
1711
+ ' assert.deepEqual(imported.result, { imported: 1, source: "tickets", args: ["batch-1"] });',
1712
+ "",
1713
+ " const exported = await ext.runExporter({",
1714
+ ` exporter: ${JSON.stringify(adapterName)},`,
1715
+ ' options: { destination: "archive" },',
1716
+ ' args: ["done"],',
1717
+ " });",
1718
+ " assert.equal(exported.handled, true);",
1719
+ ' assert.deepEqual(exported.result, { exported: true, destination: "archive", args: ["done"] });',
1720
+ ]),
1721
+ "});",
1722
+ "",
1723
+ ];
1724
+ case "schema":
1725
+ return [
1726
+ `test(${JSON.stringify(`${extensionName} registers and runs its custom schema`)}, async () => {`,
1727
+ ...withHarnessCleanup([
1728
+ " // assertItemType/Field/Migration throw unless the registration is present, so",
1729
+ " // reaching each next line already proves the wiring; assert on the returned",
1730
+ " // definitions to demonstrate inspecting registered metadata.",
1731
+ ` const itemType = ext.assertItemType({ itemType: ${JSON.stringify(itemTypeName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1732
+ ` assert.equal(itemType.itemType.folder, ${JSON.stringify(itemTypeFolder)});`,
1733
+ ` const itemField = ext.assertItemField({ field: ${JSON.stringify(fieldName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1734
+ ' assert.equal(itemField.field.type, "string");',
1735
+ ` ext.assertMigration({ migration: ${JSON.stringify(migrationId)}, extensionName: ${JSON.stringify(extensionName)}, mandatory: false });`,
1736
+ "",
1737
+ " // runMigration invokes the migration through pm's real runner with a synthetic",
1738
+ " // context and returns its result.",
1739
+ ` const migrated = await ext.runMigration({ migration: ${JSON.stringify(migrationId)} });`,
1740
+ ` assert.deepEqual(migrated, { migrated: true, id: ${JSON.stringify(migrationId)} });`,
1741
+ ]),
1742
+ "});",
1743
+ "",
1744
+ ];
1745
+ case "profile":
1746
+ return [
1747
+ `test(${JSON.stringify(`${extensionName} registers its project profile`)}, async () => {`,
1748
+ ...withHarnessCleanup([
1749
+ " // assertProfile throws unless the profile is registered, so reaching the next",
1750
+ " // line already proves the wiring; assert on the returned definition to inspect",
1751
+ " // the bundled archetype dimensions.",
1752
+ ` const { profile } = ext.assertProfile({ profile: ${JSON.stringify(extensionName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1753
+ ` assert.equal(profile.title, ${JSON.stringify(`${extensionName} archetype`)});`,
1754
+ " assert.equal(profile.types.length, 1);",
1755
+ " assert.equal(profile.workflows.length, 1);",
1756
+ ]),
1757
+ "});",
1758
+ "",
1759
+ ];
1760
+ case "renderers":
1761
+ return [
1762
+ `test(${JSON.stringify(`${extensionName} registers and invokes its renderer override`)}, async () => {`,
1763
+ ...withHarnessCleanup([
1764
+ " // assertRendererOverride throws unless a renderer is registered for the format,",
1765
+ " // so reaching the next line already proves the wiring.",
1766
+ ` const override = ext.assertRendererOverride({ format: "toon", extensionName: ${JSON.stringify(extensionName)} });`,
1767
+ ' assert.equal(override.format, "toon");',
1768
+ "",
1769
+ " // runRendererOverride renders through pm's real runner. The override customizes",
1770
+ " // only THIS package's command output and returns a string the host uses verbatim.",
1771
+ " const rendered = await ext.runRendererOverride({",
1772
+ ' format: "toon",',
1773
+ ` command: ${JSON.stringify(commandName)},`,
1774
+ " result: { ok: true },",
1775
+ " });",
1776
+ " assert.equal(rendered.overridden, true);",
1777
+ ` assert.equal(rendered.rendered, ${JSON.stringify(`${extensionName}: `)} + JSON.stringify({ ok: true }));`,
1778
+ "",
1779
+ " // Output for any other command passes through to pm's default renderer.",
1780
+ " const passthrough = await ext.runRendererOverride({",
1781
+ ' format: "toon",',
1782
+ ' command: "list",',
1783
+ " result: { ok: true },",
1784
+ " });",
1785
+ " assert.equal(passthrough.overridden, false);",
1786
+ ]),
1787
+ "});",
1788
+ "",
1789
+ ];
1790
+ case "parser":
1791
+ return [
1792
+ `test(${JSON.stringify(`${extensionName} rewrites command options via its parser override`)}, async () => {`,
1793
+ ...withHarnessCleanup([
1794
+ " // assertParserOverride throws unless a parser is registered for the command, so",
1795
+ " // reaching the next line already proves the wiring.",
1796
+ ` ext.assertParserOverride({ command: ${JSON.stringify(commandName)}, extensionName: ${JSON.stringify(extensionName)} });`,
1797
+ "",
1798
+ " // runParserOverride runs the override through pm's real parser runner and returns",
1799
+ " // the rewritten context. The starter rewrites the deprecated `shout` alias to the",
1800
+ " // canonical `upper` flag.",
1801
+ " const result = await ext.runParserOverride({",
1802
+ ` command: ${JSON.stringify(commandName)},`,
1803
+ " args: [],",
1804
+ " options: { shout: true },",
1805
+ " global: {},",
1806
+ ' pm_root: "",',
1807
+ " });",
1808
+ " assert.equal(result.overridden, true);",
1809
+ " assert.deepEqual(result.context.options, { upper: true });",
1810
+ "",
1811
+ " // End to end: feed the rewritten options into the command handler to prove",
1812
+ " // `pm <command> --shout` surfaces the normalized `upper` flag in the result.",
1813
+ ` const invocation = await ext.runCommand({ command: ${JSON.stringify(commandName)}, options: result.context.options });`,
1814
+ " assert.equal(invocation.handled, true);",
1815
+ " assert.deepEqual(invocation.result, {",
1816
+ " ok: true,",
1817
+ ` source: ${JSON.stringify(extensionName)},`,
1818
+ ` command: ${JSON.stringify(commandName)},`,
1819
+ " upper: true,",
1820
+ ' message: "Starter extension scaffold is active.",',
1821
+ " });",
1822
+ ]),
1823
+ "});",
1824
+ "",
1825
+ ];
1826
+ case "preflight":
1827
+ return [
1828
+ `test(${JSON.stringify(`${extensionName} returns a preflight gate decision via its override`)}, async () => {`,
1829
+ ...withHarnessCleanup([
1830
+ " // assertPreflightOverride throws unless a preflight override is registered, so",
1831
+ " // reaching the next line already proves the wiring.",
1832
+ ` ext.assertPreflightOverride({ extensionName: ${JSON.stringify(extensionName)} });`,
1833
+ "",
1834
+ " // runPreflightOverride runs the override through pm's real runner with a synthetic",
1835
+ " // gate decision. The starter echoes the decision unchanged; replace the",
1836
+ " // values/assertions with your real policy.",
1837
+ " const decision = {",
1838
+ " enforce_item_format_gate: true,",
1839
+ " run_preflight_item_format_sync: false,",
1840
+ " run_extension_migrations: true,",
1841
+ " enforce_mandatory_migration_gate: false,",
1842
+ " };",
1843
+ " const result = await ext.runPreflightOverride({",
1844
+ ` command: ${JSON.stringify(commandName)},`,
1845
+ " args: [],",
1846
+ " options: {},",
1847
+ " global: {},",
1848
+ ' pm_root: "",',
1849
+ " decision,",
1850
+ " });",
1851
+ " assert.equal(result.overridden, true);",
1852
+ " assert.deepEqual(result.decision, decision);",
1853
+ ]),
1854
+ "});",
1855
+ "",
1856
+ ];
1857
+ case "services":
1858
+ return [
1859
+ `test(${JSON.stringify(`${extensionName} customizes command output via its service override`)}, async () => {`,
1860
+ ...withHarnessCleanup([
1861
+ " // assertServiceOverride throws unless a service override is registered for the",
1862
+ " // service, so reaching the next line proves the wiring.",
1863
+ ` ext.assertServiceOverride({ service: "output_format", extensionName: ${JSON.stringify(extensionName)} });`,
1864
+ "",
1865
+ " // runServiceOverride runs the override through pm's real service runner. The",
1866
+ " // override customizes only THIS package's command output (handled), passing every",
1867
+ " // other command through (not handled).",
1868
+ " const handled = await ext.runServiceOverride({",
1869
+ ' service: "output_format",',
1870
+ ` command: ${JSON.stringify(commandName)},`,
1871
+ " payload: { ok: true },",
1872
+ " });",
1873
+ " assert.equal(handled.handled, true);",
1874
+ ` assert.deepEqual(handled.result, { rendered_by: ${JSON.stringify(extensionName)}, payload: { ok: true } });`,
1875
+ "",
1876
+ " // Output for any other command passes through to pm's default formatter.",
1877
+ " const passthrough = await ext.runServiceOverride({",
1878
+ ' service: "output_format",',
1879
+ ' command: "list",',
1880
+ " payload: { ok: true },",
1881
+ " });",
1882
+ " assert.equal(passthrough.handled, false);",
1883
+ ]),
1884
+ "});",
1885
+ "",
1886
+ ];
1887
+ }
1888
+ }
1889
+ /**
1890
+ * Build the declarative variant of the colocated `node:test` suite
1891
+ * (`index.test.ts`) for the chosen capability's `composeExtension` starter.
1892
+ *
1893
+ * Like {@link buildSampleTestSource}, this uses the harness-bound runtime
1894
+ * helpers; it also exercises the author-time capstone the declarative loop
1895
+ * unlocks:
1896
+ * `assertExtensionPreflight(blueprint, { identity, target })` (lint + manifest
1897
+ * synthesis + version-compat in one call) over the exported `blueprint`, and the
1898
+ * ergonomic runtime `createExtensionTestHarness(module)` whose `assert*`/`run*`/
1899
+ * `deactivate` methods are pre-bound to the right activation sub-registry. The base
1900
+ * suite covers preflight, the starter command, and teardown; for non-`commands`
1901
+ * capabilities {@link buildDeclarativeCapabilityTestBlock} adds a dedicated test for
1902
+ * the capability's surface. The `identity`/`target` versions are pinned to the
1903
+ * scaffolded `pm_min_version` so the synthesized manifest is trivially compatible
1904
+ * and the suite stays deterministic; an author edits them as the package matures.
1905
+ */
1906
+ function buildDeclarativeSampleTestSource(extensionName, commandName, capability) {
1907
+ const parserEnabled = capability === "parser";
1908
+ // The preflight report's capability set is DERIVED from the blueprint and SORTED,
1909
+ // so assert against the sorted manifest capabilities (a set match in canonical
1910
+ // order); the harness `capabilities` grant uses the same literal.
1911
+ const capabilitiesLiteral = JSON.stringify([...SCAFFOLD_MANIFEST_CAPABILITIES[capability]].sort());
1912
+ return [
1913
+ 'import assert from "node:assert/strict";',
1914
+ 'import { test } from "node:test";',
1915
+ 'import { assertExtensionDeactivated, assertExtensionPreflight, createExtensionTestHarness } from "@unbrained/pm-cli/sdk/testing";',
1916
+ // The search sample's synthetic query/vector contexts reference these SDK types
1917
+ // for their typed-stub fixtures; other capabilities need no extra type imports.
1918
+ ...(capability === "search" ? ['import type { ItemDocument, PmSettings } from "@unbrained/pm-cli/sdk";'] : []),
1919
+ 'import extension, { blueprint } from "./index.ts";',
1920
+ "",
1921
+ ...SAMPLE_HARNESS_CLEANUP_LINES,
1922
+ `test(${JSON.stringify(`${extensionName} passes author-time preflight`)}, () => {`,
1923
+ " // assertExtensionPreflight is the author-time capstone: it lints the blueprint,",
1924
+ " // synthesizes the least-privilege manifest from `identity`, and checks the version",
1925
+ " // bounds against `target` in one call, throwing on any blocking finding. It returns",
1926
+ " // the full report so you can inspect the derived data.",
1927
+ " const report = assertExtensionPreflight(blueprint, {",
1928
+ " identity: {",
1929
+ ` name: ${JSON.stringify(extensionName)},`,
1930
+ ' version: "0.1.0",',
1931
+ ' entry: "./index.ts",',
1932
+ " priority: 0,",
1933
+ ` pm_min_version: ${JSON.stringify(SCAFFOLD_PM_MIN_VERSION)},`,
1934
+ " },",
1935
+ ` target: { pmVersion: ${JSON.stringify(SCAFFOLD_PM_MIN_VERSION)} },`,
1936
+ " });",
1937
+ " // The capability set is DERIVED from the blueprint, never hand-synced. Keep",
1938
+ " // manifest.json's `capabilities` equal to this list (set match, sorted).",
1939
+ ` assert.deepEqual(report.capabilities, ${capabilitiesLiteral});`,
1940
+ ` assert.deepEqual(report.manifest?.capabilities, ${capabilitiesLiteral});`,
1941
+ "});",
1942
+ "",
1943
+ `test(${JSON.stringify(`${extensionName} registers and runs its starter command`)}, async () => {`,
1944
+ " // createExtensionTestHarness activates the composed module once and binds the",
1945
+ " // assert*/run*/deactivate helpers to the right activation sub-registry, so you",
1946
+ " // never thread activation.registrations vs activation.commands by hand.",
1947
+ " // `capabilities` mirrors manifest.json so the in-memory activation grants what the",
1948
+ " // blueprint needs.",
1949
+ " const ext = await createExtensionTestHarness(extension, {",
1950
+ ` name: ${JSON.stringify(extensionName)},`,
1951
+ ` capabilities: ${capabilitiesLiteral},`,
1952
+ " });",
1953
+ " let deactivated = false;",
1954
+ " try {",
1955
+ " // assertCommandContract throws unless the command is registered, so reaching",
1956
+ " // the next line already proves the wiring; assert on the returned definition",
1957
+ " // to demonstrate inspecting registered metadata.",
1958
+ ` const registered = ext.assertCommandContract({ command: ${JSON.stringify(commandName)} });`,
1959
+ ' assert.equal(typeof registered.command.description, "string");',
1960
+ "",
1961
+ " // runCommand invokes the handler through pm's real dispatch engine, so this",
1962
+ " // asserts behavior - not just that the command is wired. Replace these",
1963
+ " // assertions as you flesh out your command.",
1964
+ ` const invocation = await ext.runCommand({ command: ${JSON.stringify(commandName)} });`,
1965
+ " assert.equal(invocation.handled, true);",
1966
+ " assert.deepEqual(invocation.result, {",
1967
+ " ok: true,",
1968
+ ` source: ${JSON.stringify(extensionName)},`,
1969
+ ` command: ${JSON.stringify(commandName)},`,
1970
+ // The parser starter's command surfaces the normalized `upper` flag, false when
1971
+ // the command is invoked without `--shout`/`--upper`.
1972
+ ...(parserEnabled ? [" upper: false,"] : []),
1973
+ ' message: "Starter extension scaffold is active.",',
1974
+ " });",
1975
+ " // deactivate runs pm's real teardown engine over the module; exactly one",
1976
+ " // extension tears down with no failures.",
1977
+ " const teardown = await ext.deactivate();",
1978
+ " assertExtensionDeactivated(teardown);",
1979
+ " deactivated = true;",
1980
+ ...SAMPLE_HARNESS_FINALLY_LINES,
1981
+ "});",
1982
+ "",
1983
+ ...buildDeclarativeCapabilityTestBlock(extensionName, commandName, capability, capabilitiesLiteral),
1984
+ ].join("\n");
1985
+ }
1986
+ /**
1987
+ * Build the README for the declarative (`composeExtension`) package starter for
1988
+ * the chosen capability.
1989
+ *
1990
+ * It documents the same metadata/validation sections as the imperative package
1991
+ * README but frames the entrypoint around the declarative loop and the author-time
1992
+ * preflight test, so the generated docs match the generated `index.ts`/
1993
+ * `index.test.ts`. The included-files bullets, the Declarative Authoring blueprint
1994
+ * fields, and the activation section are capability-aware: the `schema` starter
1995
+ * contributes a global item type (so it omits `activation.commands`), while every
1996
+ * other capability declares the command paths that lazily activate the package.
1997
+ */
1998
+ function buildDeclarativePackageReadme(packageName, commandName, capability) {
1999
+ // The schema/profile starters omit `activation.commands` (their surface is a
2000
+ // global contribution), so describe the manifest accurately and use the
2001
+ // conservative-activation section.
2002
+ const manifestBullet = buildScaffoldManifestBullet(capability, "package");
2003
+ const activationSection = buildScaffoldActivationReadmeSection(capability, "package");
2004
+ return [
2005
+ `# ${packageName}`,
2006
+ "",
2007
+ "Generated by `pm package init --declarative`.",
2008
+ "",
2009
+ "## Included Files",
2010
+ "- `package.json`: package metadata, `typecheck`/`test` scripts, and `pm` resource manifest.",
2011
+ manifestBullet,
2012
+ `- \`index.ts\`: the TypeScript manifest entry — a \`defineExtensionBlueprint\` blueprint (${DECLARATIVE_ENTRYPOINT_SURFACE_PHRASE[capability]}) composed into the runtime module by \`composeExtension\`, plus a \`deactivate\` teardown stub.`,
2013
+ "- `index.test.ts`: sample `node:test` suite covering author-time preflight (`assertExtensionPreflight`) and runtime surface invocation/teardown via `createExtensionTestHarness`.",
2014
+ TSCONFIG_BULLET,
2015
+ "- `.gitignore`: ignores `node_modules/`, logs, and the TypeScript build cache.",
2016
+ "",
2017
+ "## Quick Start",
2018
+ "This package is authored AND loaded as TypeScript: the manifest `entry` is",
2019
+ "`./index.ts` and pm imports it directly via Node's native type stripping",
2020
+ "(Node >=22.18), so there is no build step — install and run:",
2021
+ "```bash",
2022
+ "npm install",
2023
+ "pm install --project <package-path>",
2024
+ `pm ${commandName}`,
2025
+ "pm package doctor --project --detail summary",
2026
+ "```",
2027
+ "",
2028
+ "## Declarative Authoring",
2029
+ "`index.ts` uses the SDK's declarative authoring loop instead of an imperative",
2030
+ "`activate` body. You describe WHAT the package registers as an",
2031
+ "`ExtensionBlueprint` and `composeExtension` generates the `activate` that wires",
2032
+ "every surface in order:",
2033
+ "- The `define*` builders author each surface with literal-type preservation and",
2034
+ " contextual handler inference (`defineCommand`, `defineSearchProvider`,",
2035
+ " `defineItemType`, `defineParserOverride`, ...).",
2036
+ `- \`defineExtensionBlueprint({ ... })\` collects the definitions into the blueprint;`,
2037
+ ` this starter populates ${DECLARATIVE_CAPABILITY_BLUEPRINT_FIELDS[capability]}. Add more`,
2038
+ " fields as the package grows.",
2039
+ "- `composeExtension(blueprint)` is the default export — the runtime module pm",
2040
+ " loads. Its generated `activate` requires exactly the capabilities the blueprint",
2041
+ " derives, so `manifest.json`'s `capabilities` never drift.",
2042
+ "",
2043
+ "## Validate the Package",
2044
+ "`npm install` pulls the peer SDK and TypeScript. `npm test` is the default",
2045
+ "validation gate: it type-checks the package, then runs the colocated sample:",
2046
+ "```bash",
2047
+ "npm install",
2048
+ "npm test",
2049
+ "```",
2050
+ "`index.test.ts` exercises both authoring capstones: `assertExtensionPreflight`",
2051
+ "(the author-time lint + manifest synthesis + version-compatibility check over the",
2052
+ "exported `blueprint`) and `createExtensionTestHarness` (the runtime fixture whose",
2053
+ "`assert*`/`run*`/`deactivate` methods bind to the right activation sub-registry).",
2054
+ "`npm run typecheck` is available when you only want the SDK contract check.",
2055
+ "`npm run test:runtime` runs just `node --test`, which strips types on load and",
2056
+ "executes `index.test.ts` directly against the `@unbrained/pm-cli/sdk/testing`",
2057
+ "helpers - no compile step and no extra test runner required.",
2058
+ ...activationSection,
2059
+ "",
2060
+ "## Compatibility Bounds",
2061
+ "`manifest.json` cannot hold comments, so the version-compatibility fields are documented here:",
2062
+ `- \`manifest_version\` (integer): manifest schema generation. Leave at \`${SCAFFOLD_MANIFEST_VERSION}\` unless you adopt a newer manifest schema.`,
2063
+ `- \`pm_min_version\` (string): lowest pm CLI version that may load this package. Scaffolded as \`${SCAFFOLD_PM_MIN_VERSION}\`. The loader blocks the package on older CLIs.`,
2064
+ "- `pm_max_version` (string, optional): highest pm CLI version that may load this package. Add it to block CLIs that are newer than the version you have validated against. The loader blocks the package when the CLI exceeds this bound.",
2065
+ "",
2066
+ "## Policy Metadata",
2067
+ "The starter command is pure compute, so `manifest.json` declares `trusted: true`, `sandbox_profile: \"strict\"`, and all six permission keys as `false`. Keep that least-privilege shape for pure packages; relax only the specific permission your package actually needs and verify with `pm package doctor --project --detail deep --trace`.",
2068
+ "",
2069
+ "## Notes",
2070
+ "- Author in `index.ts`; pm loads it directly (no build), so edits take effect on the next install/reload — there is no `.js` to regenerate.",
2071
+ "- Move larger runtimes into sibling or subdirectory `*.ts` modules and import them with their real `.ts` extension; `tsconfig.json` type-checks every `*.ts` in the package (recursively).",
2072
+ "- Use `@unbrained/pm-cli/sdk` as the public SDK import for richer package runtimes.",
2073
+ "",
2074
+ ].join("\n");
2075
+ }
2076
+ /**
2077
+ * Project the {@link ScaffoldSnippetNames} for `extensionName`, omitting a
2078
+ * redundant self-alias when the de-hyphenated form already equals the type name.
2079
+ */
2080
+ function buildScaffoldSnippetNames(extensionName) {
2081
+ const itemTypeName = extensionName;
2082
+ const itemTypeAlias = extensionName.replace(/-/g, "");
2083
+ return {
2084
+ searchProviderName: `${extensionName}-search`,
2085
+ vectorAdapterName: `${extensionName}-vector`,
2086
+ adapterName: `${extensionName.replace(/-/g, " ")} items`,
2087
+ itemTypeName,
2088
+ itemTypeFolder: `${extensionName}s`,
2089
+ itemTypeAliases: itemTypeAlias === itemTypeName ? [] : [itemTypeAlias],
2090
+ fieldName: `${extensionName.replace(/-/g, "_")}_note`,
2091
+ migrationId: `${extensionName}-0001-init`,
2092
+ };
2093
+ }
2094
+ /**
2095
+ * Build the comma-separated `define*` builder import list for the README
2096
+ * snippet, including only the builders the chosen capability demonstrates.
2097
+ */
2098
+ function buildDefineBuilderImports(capability) {
2099
+ return [
2100
+ "defineCommand",
2101
+ ...(capability === "hooks" ? ["defineAfterCommandHook"] : []),
2102
+ ...(capability === "search" ? ["defineSearchProvider", "defineVectorStoreAdapter"] : []),
2103
+ ...(capability === "importers" ? ["defineImporter", "defineExporter"] : []),
2104
+ ...(capability === "schema" ? ["defineItemType", "defineItemField", "defineMigration"] : []),
2105
+ ...(capability === "profile" ? ["defineProjectProfile"] : []),
2106
+ ...(capability === "renderers" ? ["defineRendererOverride"] : []),
2107
+ ...(capability === "parser" ? ["defineParserOverride"] : []),
2108
+ ...(capability === "preflight" ? ["definePreflightOverride"] : []),
2109
+ ...(capability === "services" ? ["defineServiceOverride"] : []),
2110
+ ].join(", ");
2111
+ }
2112
+ /**
2113
+ * Build the exported `define*` declarations for the README snippet: the base
2114
+ * `pingCommand` (with parser flags for the parser capability) plus the one
2115
+ * capability-specific export the chosen capability demonstrates.
2116
+ */
2117
+ function buildDefineBuilderExports(extensionName, commandName, capability, names) {
2118
+ const lines = [
2119
+ "export const pingCommand = defineCommand({",
2120
+ ` name: ${JSON.stringify(commandName)},`,
2121
+ ' description: "Starter scaffold command. Replace with your own behavior.",',
2122
+ // The parser starter's command declares the flags its override normalizes so
2123
+ // the demo is runnable through `pm <command> --shout`, and surfaces the
2124
+ // canonical `upper` flag in the result.
2125
+ ...(capability === "parser"
2126
+ ? [
2127
+ " flags: [",
2128
+ ' { long: "--shout", value_type: "boolean", description: "Deprecated alias for --upper." },',
2129
+ ' { long: "--upper", value_type: "boolean", description: "Canonical flag the parser produces." },',
2130
+ " ],",
2131
+ " run: (context) => ({ ok: true, command: context.command, upper: context.options.upper === true }),",
2132
+ ]
2133
+ : [" run: (context) => ({ ok: true, command: context.command }),"]),
2134
+ "});",
2135
+ ];
2136
+ if (capability === "hooks") {
2137
+ lines.push("", "export const afterCommandHook = defineAfterCommandHook((context) => {", " if (!context.ok) return;", " // React to context.affected here as your package grows.", "});");
2138
+ }
2139
+ if (capability === "search") {
2140
+ lines.push("", "export const searchProvider = defineSearchProvider({", ` name: ${JSON.stringify(names.searchProviderName)},`, " query: async (context) => ({", " hits: context.documents", " .filter((document) => String(document.metadata.title ?? \"\").toLowerCase().includes(context.query.toLowerCase()))", " .map((document) => ({ id: document.metadata.id, score: 1, matched_fields: [\"title\"] })),", " }),", " embed: async (context) => [context.input.length],", "});", "", "export const vectorStoreAdapter = defineVectorStoreAdapter({", ` name: ${JSON.stringify(names.vectorAdapterName)},`, " query: async (context) => [{ id: \"starter-vector-hit\", score: context.limit }],", " upsert: async (context) => ({ upserted: context.points.length }),", " delete: async (context) => ({ deleted: context.ids.length }),", "});");
2141
+ }
2142
+ if (capability === "importers") {
2143
+ lines.push("", "export const importer = defineImporter(async (context) => ({", " imported: 1,", " source: context.options.source ?? \"starter\",", " args: context.args,", "}));", "", "export const exporter = defineExporter(async (context) => ({", " exported: true,", " destination: context.options.destination ?? \"stdout\",", " args: context.args,", "}));");
2144
+ }
2145
+ if (capability === "schema") {
2146
+ lines.push("", `export const noteField = defineItemField({ name: ${JSON.stringify(names.fieldName)}, type: "string", optional: true });`, "", "export const itemType = defineItemType({", ` name: ${JSON.stringify(names.itemTypeName)},`, ` folder: ${JSON.stringify(names.itemTypeFolder)},`, ` aliases: ${JSON.stringify(names.itemTypeAliases)},`, " required_create_fields: [],", "});", "", "export const initMigration = defineMigration({", ` id: ${JSON.stringify(names.migrationId)},`, ` description: ${JSON.stringify(`Initialize ${extensionName} schema state.`)},`, " mandatory: false,", " run: async (context) => ({ migrated: true, id: context.id }),", "});");
2147
+ }
2148
+ if (capability === "profile") {
2149
+ // Abbreviated illustration; the generated index.ts populates every archetype
2150
+ // dimension (types, statuses, fields, workflow, config, template, packages).
2151
+ lines.push("", "export const starterProfile = defineProjectProfile({", ` name: ${JSON.stringify(extensionName)},`, ` title: ${JSON.stringify(`${extensionName} archetype`)},`, ' summary: "Starter project profile. Replace these dimensions with your own archetype.",', " types: [", ` { name: ${JSON.stringify(names.itemTypeName)}, folder: ${JSON.stringify(names.itemTypeFolder)} },`, " ],", " // ...plus statuses, fields, workflows, config, templates, and packages.", "});");
2152
+ }
2153
+ if (capability === "renderers") {
2154
+ lines.push("", "export const toonRenderer = defineRendererOverride((context) => {", ` if (context.command !== ${JSON.stringify(commandName)}) return null;`, ` return ${JSON.stringify(`${extensionName}: `)} + JSON.stringify(context.result);`, "});");
2155
+ }
2156
+ if (capability === "parser") {
2157
+ lines.push("", "export const pingParser = defineParserOverride((context) => {", " const options = { ...context.options };", " if (options.shout === true) options.upper = true;", " delete options.shout;", " return { options };", "});");
2158
+ }
2159
+ if (capability === "preflight") {
2160
+ lines.push("", "// Return a delta of the gate-decision keys you want to change; returning", "// context.decision unchanged is a safe no-op (e.g. { run_extension_migrations: false }).", "export const preflightOverride = definePreflightOverride((context) => context.decision);");
2161
+ }
2162
+ if (capability === "services") {
2163
+ lines.push("", "export const outputService = defineServiceOverride((context) => {", ` if (context.command !== ${JSON.stringify(commandName)}) return context.payload;`, ` return { rendered_by: ${JSON.stringify(extensionName)}, payload: context.payload };`, "});");
2164
+ }
2165
+ return lines;
2166
+ }
2167
+ /**
2168
+ * Build the `activate` body registrations for the README snippet: one
2169
+ * `api.register*`/`api.hooks.*` call wiring the capability-specific exports
2170
+ * produced by {@link buildDefineBuilderExports}.
2171
+ */
2172
+ function buildDefineBuilderActivate(commandName, capability, names) {
2173
+ const lines = [];
2174
+ if (capability === "renderers") {
2175
+ lines.push(' api.registerRenderer("toon", toonRenderer);');
2176
+ }
2177
+ if (capability === "parser") {
2178
+ lines.push(` api.registerParser(${JSON.stringify(commandName)}, pingParser);`);
2179
+ }
2180
+ if (capability === "preflight") {
2181
+ lines.push(" api.registerPreflight(preflightOverride);");
2182
+ }
2183
+ if (capability === "services") {
2184
+ lines.push(' api.registerService("output_format", outputService);');
2185
+ }
2186
+ if (capability === "hooks") {
2187
+ lines.push(" api.hooks.afterCommand(afterCommandHook);");
2188
+ }
2189
+ if (capability === "search") {
2190
+ lines.push(" api.registerSearchProvider(searchProvider);", " api.registerVectorStoreAdapter(vectorStoreAdapter);");
2191
+ }
2192
+ if (capability === "schema") {
2193
+ lines.push(" api.registerItemFields([noteField]);", " api.registerItemTypes([itemType]);", " api.registerMigration(initMigration);");
2194
+ }
2195
+ if (capability === "profile") {
2196
+ lines.push(" api.registerProfile(starterProfile);");
2197
+ }
2198
+ if (capability === "importers") {
2199
+ lines.push(` api.registerImporter(${JSON.stringify(names.adapterName)}, importer, {`, ` action: ${JSON.stringify(`${names.adapterName} import`)},`, ' description: "Import starter records into pm context.",', " flags: [", " {", ' long: "--source",', ' value_name: "name",', ' value_type: "string",', ' description: "Source name or path to import from.",', " },", " ],", " });", ` api.registerExporter(${JSON.stringify(names.adapterName)}, exporter, {`, ` action: ${JSON.stringify(`${names.adapterName} export`)},`, ' description: "Export pm context into starter records.",', " flags: [", " {", ' long: "--destination",', ' value_name: "name",', ' value_type: "string",', ' description: "Destination name or path to export to.",', " },", " ],", " });");
2200
+ }
2201
+ return lines;
2202
+ }
499
2203
  /**
500
2204
  * Implements build starter extension scaffold files for the public runtime surface of this module.
501
2205
  */
502
- export function buildStarterExtensionScaffoldFiles(extensionName, commandName, vocabulary, capability = "commands") {
2206
+ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, vocabulary, capability = "commands", declarative = false) {
503
2207
  const packageName = `pm-${extensionName}`;
504
2208
  const capabilities = SCAFFOLD_MANIFEST_CAPABILITIES[capability];
2209
+ const activationCommands = buildScaffoldActivationCommands(extensionName, commandName, capability);
505
2210
  const manifest = `${JSON.stringify({
506
2211
  name: extensionName,
507
2212
  version: "0.1.0",
508
- entry: "./index.js",
2213
+ entry: "./index.ts",
509
2214
  manifest_version: SCAFFOLD_MANIFEST_VERSION,
510
2215
  pm_min_version: SCAFFOLD_PM_MIN_VERSION,
511
2216
  trusted: true,
512
2217
  sandbox_profile: "strict",
513
2218
  permissions: { ...SCAFFOLD_DECLARED_PERMISSIONS },
514
2219
  capabilities,
2220
+ // Declares the exact command paths `activate` registers so pm activates
2221
+ // this package lazily — only when an invoked command matches — mirroring
2222
+ // every first-party bundled package. Keep it in sync with the entrypoint.
2223
+ // The schema and profile starters omit this field (empty list) so their
2224
+ // global contribution — a custom item type/field, or a project profile
2225
+ // resolved by `pm profile` — stays available to built-in commands (see
2226
+ // buildScaffoldActivationCommands).
2227
+ ...(activationCommands.length > 0 ? { activation: { commands: activationCommands } } : {}),
515
2228
  }, null, 2)}\n`;
516
- // The entrypoint is authored fully in TypeScript (ADR pm-2c28): the `import
517
- // type` is erased at compile time, so the typed `ExtensionApi` parameter is
518
- // checked against the SDK contract at author time while the emitted ./index.js
519
- // stays import-light. `npm run build` (tsc) compiles this index.ts to the
520
- // ./index.js the manifest entry loads.
2229
+ // The entrypoint is authored AND loaded as TypeScript (ADR pm-2c28 / pm-m1uz):
2230
+ // the manifest `entry` points at `./index.ts` and pm imports it directly via
2231
+ // Node's native type stripping (Node >=22.18) there is no compile step and no
2232
+ // `.js` artifact. The typed `ExtensionApi` parameter is checked against the SDK
2233
+ // contract at author time (`npm run typecheck`).
521
2234
  const entrypoint = [
522
2235
  'import type { ExtensionApi } from "@unbrained/pm-cli/sdk";',
523
2236
  "",
@@ -541,6 +2254,10 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
541
2254
  // README bullet describing what index.ts wires, kept in sync with the chosen
542
2255
  // capability so the generated docs match the generated code.
543
2256
  const entrypointBullet = ENTRYPOINT_BULLETS[capability];
2257
+ // The schema/profile starters omit `activation.commands` (their surface is a
2258
+ // global contribution), so describe the manifest accurately instead of
2259
+ // referencing a field they deliberately lack.
2260
+ const manifestBullet = buildScaffoldManifestBullet(capability, vocabulary);
544
2261
  if (vocabulary === "package") {
545
2262
  const packageJson = `${JSON.stringify({
546
2263
  name: packageName,
@@ -548,16 +2265,24 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
548
2265
  private: true,
549
2266
  type: "module",
550
2267
  keywords: ["pm-package"],
551
- // `build` compiles index.ts to the ./index.js the manifest loads; `test`
552
- // compiles first (Node's `node --test` runs the emitted *.test.js, not the
553
- // TypeScript source) then runs the colocated sample against the peer SDK
554
- // testing helpers no third-party test runner required.
2268
+ engines: {
2269
+ node: SCAFFOLD_NODE_ENGINE,
2270
+ },
2271
+ // There is no build step: pm loads the `./index.ts` manifest entry
2272
+ // directly via Node's native type stripping (Node >=22.18). `typecheck`
2273
+ // validates the source against the SDK contracts (`tsc --noEmit`), and
2274
+ // `test` is the self-validating author gate: typecheck first, then run
2275
+ // the colocated sample with Node's built-in runner (which strips types
2276
+ // on load) against the peer SDK testing helpers — no third-party test
2277
+ // runner or compile output required. `test:runtime` remains available
2278
+ // for tight loops after a separate `npm run typecheck`.
555
2279
  scripts: {
556
- build: "tsc",
557
- test: "tsc && node --test",
2280
+ typecheck: "tsc --noEmit",
2281
+ "test:runtime": "node --test",
2282
+ test: "npm run typecheck && npm run test:runtime",
558
2283
  },
559
2284
  peerDependencies: {
560
- "@unbrained/pm-cli": "*",
2285
+ "@unbrained/pm-cli": `>=${SCAFFOLD_PM_MIN_VERSION}`,
561
2286
  },
562
2287
  devDependencies: {
563
2288
  "@types/node": SCAFFOLD_TYPES_NODE_VERSION,
@@ -582,94 +2307,69 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
582
2307
  // capability, the after_command lifecycle hook).
583
2308
  const sampleTest = buildSampleTestSource(extensionName, commandName, capability);
584
2309
  const sampleTestBullet = SAMPLE_TEST_BULLETS[capability];
585
- // Ignore compiled TypeScript output wherever tsc emits it. Authors can add
586
- // sibling or subdirectory modules, and tsc writes each .js next to its source.
2310
+ // The package commits only TypeScript source pm loads the `.ts` entry
2311
+ // directly, so there is no compiled output to ignore. Keep dependencies and
2312
+ // the tsc incremental cache out of version control.
587
2313
  const gitignore = [
588
2314
  "node_modules/",
589
2315
  "*.log",
590
- "",
591
- "# Compiled TypeScript output (npm run build)",
592
- "*.js",
593
- "*.test.js",
594
- "*.js.map",
595
- "*.d.ts",
596
- "*.d.ts.map",
2316
+ "*.tsbuildinfo",
597
2317
  "",
598
2318
  ].join("\n");
599
- const searchProviderName = `${extensionName}-search`;
600
- const vectorAdapterName = `${extensionName}-vector`;
601
- const adapterName = `${extensionName.replace(/-/g, " ")} items`;
602
- const defineBuilderImports = [
603
- "defineCommand",
604
- ...(capability === "hooks" ? ["defineAfterCommandHook"] : []),
605
- ...(capability === "search" ? ["defineSearchProvider", "defineVectorStoreAdapter"] : []),
606
- ...(capability === "importers" ? ["defineImporter", "defineExporter"] : []),
607
- ].join(", ");
2319
+ const names = buildScaffoldSnippetNames(extensionName);
2320
+ const defineBuilderImports = buildDefineBuilderImports(capability);
608
2321
  const defineBuilderSnippet = [
609
2322
  "```ts",
610
2323
  `import { ${defineBuilderImports} } from "@unbrained/pm-cli/sdk";`,
611
2324
  'import type { ExtensionApi } from "@unbrained/pm-cli/sdk";',
612
2325
  "",
613
- "export const pingCommand = defineCommand({",
614
- ` name: ${JSON.stringify(commandName)},`,
615
- ' description: "Starter scaffold command. Replace with your own behavior.",',
616
- " run: (context) => ({ ok: true, command: context.command }),",
617
- "});",
2326
+ ...buildDefineBuilderExports(extensionName, commandName, capability, names),
2327
+ "",
2328
+ "export function activate(api: ExtensionApi): void {",
2329
+ " api.registerCommand(pingCommand);",
2330
+ ...buildDefineBuilderActivate(commandName, capability, names),
2331
+ "}",
2332
+ "",
2333
+ "export function deactivate(): void {}",
2334
+ "",
2335
+ "export default { activate, deactivate };",
2336
+ "```",
618
2337
  ];
619
- if (capability === "hooks") {
620
- defineBuilderSnippet.push("", "export const afterCommandHook = defineAfterCommandHook((context) => {", " if (!context.ok) return;", " // React to context.affected here as your package grows.", "});");
621
- }
622
- if (capability === "search") {
623
- defineBuilderSnippet.push("", "export const searchProvider = defineSearchProvider({", ` name: ${JSON.stringify(searchProviderName)},`, " query: async (context) => ({", " hits: context.documents", " .filter((document) => String(document.metadata.title ?? \"\").toLowerCase().includes(context.query.toLowerCase()))", " .map((document) => ({ id: document.metadata.id, score: 1, matched_fields: [\"title\"] })),", " }),", " embed: async (context) => [context.input.length],", "});", "", "export const vectorStoreAdapter = defineVectorStoreAdapter({", ` name: ${JSON.stringify(vectorAdapterName)},`, " query: async (context) => [{ id: \"starter-vector-hit\", score: context.limit }],", " upsert: async (context) => ({ upserted: context.points.length }),", " delete: async (context) => ({ deleted: context.ids.length }),", "});");
624
- }
625
- if (capability === "importers") {
626
- defineBuilderSnippet.push("", "export const importer = defineImporter(async (context) => ({", " imported: 1,", " source: context.options.source ?? \"starter\",", " args: context.args,", "}));", "", "export const exporter = defineExporter(async (context) => ({", " exported: true,", " destination: context.options.destination ?? \"stdout\",", " args: context.args,", "}));");
627
- }
628
- defineBuilderSnippet.push("", "export function activate(api: ExtensionApi): void {", " api.registerCommand(pingCommand);");
629
- if (capability === "hooks") {
630
- defineBuilderSnippet.push(" api.hooks.afterCommand(afterCommandHook);");
631
- }
632
- if (capability === "search") {
633
- defineBuilderSnippet.push(" api.registerSearchProvider(searchProvider);", " api.registerVectorStoreAdapter(vectorStoreAdapter);");
634
- }
635
- if (capability === "importers") {
636
- defineBuilderSnippet.push(` api.registerImporter(${JSON.stringify(adapterName)}, importer, {`, ` action: ${JSON.stringify(`${adapterName} import`)},`, ' description: "Import starter records into pm context.",', " flags: [", " {", ' long: "--source",', ' value_name: "name",', ' value_type: "string",', ' description: "Source name or path to import from.",', " },", " ],", " });", ` api.registerExporter(${JSON.stringify(adapterName)}, exporter, {`, ` action: ${JSON.stringify(`${adapterName} export`)},`, ' description: "Export pm context into starter records.",', " flags: [", " {", ' long: "--destination",', ' value_name: "name",', ' value_type: "string",', ' description: "Destination name or path to export to.",', " },", " ],", " });");
637
- }
638
- defineBuilderSnippet.push("}", "", "export function deactivate(): void {}", "", "export default { activate, deactivate };", "```");
639
2338
  const packageReadme = [
640
2339
  `# ${packageName}`,
641
2340
  "",
642
2341
  "Generated by `pm package init`.",
643
2342
  "",
644
2343
  "## Included Files",
645
- "- `package.json`: package metadata, `build`/`test` scripts, and `pm` resource manifest.",
646
- "- `manifest.json`: extension metadata and capabilities.",
2344
+ "- `package.json`: package metadata, `typecheck`/`test` scripts, and `pm` resource manifest.",
2345
+ manifestBullet,
647
2346
  entrypointBullet,
648
2347
  sampleTestBullet,
649
2348
  TSCONFIG_BULLET,
650
- "- `.gitignore`: ignores `node_modules/`, logs, and compiled JavaScript/declaration output.",
2349
+ "- `.gitignore`: ignores `node_modules/`, logs, and the TypeScript build cache.",
651
2350
  "",
652
2351
  "## Quick Start",
653
- "This package is authored in TypeScript; build it once so the manifest's",
654
- "`./index.js` entry exists, then install it:",
2352
+ "This package is authored AND loaded as TypeScript: the manifest `entry` is",
2353
+ "`./index.ts` and pm imports it directly via Node's native type stripping",
2354
+ "(Node >=22.18), so there is no build step — install and run:",
655
2355
  "```bash",
656
2356
  "npm install",
657
- "npm run build",
658
2357
  "pm install --project <package-path>",
659
2358
  `pm ${commandName}`,
660
2359
  "pm package doctor --project --detail summary",
661
2360
  "```",
662
2361
  "",
663
2362
  "## Validate the Package",
664
- "`npm install` pulls the peer SDK and TypeScript; `npm test` compiles and runs",
665
- "the colocated sample test:",
2363
+ "`npm install` pulls the peer SDK and TypeScript. `npm test` is the default",
2364
+ "validation gate: it type-checks the package, then runs the colocated sample:",
666
2365
  "```bash",
667
2366
  "npm install",
668
2367
  "npm test",
669
2368
  "```",
670
- "`npm test` runs `tsc && node --test`: it compiles `index.ts`/`index.test.ts`",
671
- "then executes the emitted `index.test.js` against the",
672
- "`@unbrained/pm-cli/sdk/testing` helpers - no extra test runner required.",
2369
+ "`npm run typecheck` is available when you only want the SDK contract check.",
2370
+ "`npm run test:runtime` runs just `node --test`, which strips types on load and",
2371
+ "executes `index.test.ts` directly against the `@unbrained/pm-cli/sdk/testing`",
2372
+ "helpers - no compile step and no extra test runner required.",
673
2373
  "",
674
2374
  "## Authoring With define* Builders",
675
2375
  "`index.ts` is authored fully in TypeScript so every registration is checked",
@@ -680,6 +2380,7 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
680
2380
  "The builders return their argument unchanged; runtime validation still lives",
681
2381
  "in `api.register*`, and behavior validation lives in `sdk/testing`.",
682
2382
  ...PACKAGE_CAPABILITY_README_SECTIONS[capability],
2383
+ ...buildScaffoldActivationReadmeSection(capability, "package"),
683
2384
  "",
684
2385
  "## Compatibility Bounds",
685
2386
  "`manifest.json` cannot hold comments, so the version-compatibility fields are documented here:",
@@ -691,20 +2392,24 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
691
2392
  "The starter command is pure compute, so `manifest.json` declares `trusted: true`, `sandbox_profile: \"strict\"`, and all six permission keys as `false`. Keep that least-privilege shape for pure packages; relax only the specific permission your package actually needs and verify with `pm package doctor --project --detail deep --trace`.",
692
2393
  "",
693
2394
  "## Notes",
694
- "- Author in `index.ts`; `npm run build` (tsc) emits the `./index.js` the manifest loads, so rebuild after editing before installing or reloading.",
695
- "- Move larger runtimes into sibling or subdirectory `*.ts` modules and import them; `tsconfig.json` compiles every `*.ts` in the package (recursively).",
2395
+ "- Author in `index.ts`; pm loads it directly (no build), so edits take effect on the next install/reload there is no `.js` to regenerate.",
2396
+ "- Move larger runtimes into sibling or subdirectory `*.ts` modules and import them with their real `.ts` extension; `tsconfig.json` type-checks every `*.ts` in the package (recursively).",
696
2397
  "- Add capabilities to the extension manifest only when the entrypoint uses the matching SDK API.",
697
2398
  "- Use `@unbrained/pm-cli/sdk` as the public SDK import for richer package runtimes.",
698
2399
  "",
699
2400
  ].join("\n");
2401
+ // The declarative starter swaps the imperative entrypoint/test/README for the
2402
+ // `composeExtension` blueprint form (package-mode, any capability, enforced by
2403
+ // scaffoldExtensionProject). package.json, manifest.json, tsconfig.json, and
2404
+ // .gitignore are identical to the imperative starter for the same capability.
700
2405
  return {
701
2406
  "package.json": packageJson,
702
2407
  "manifest.json": manifest,
703
- "index.ts": entrypoint,
704
- "index.test.ts": sampleTest,
2408
+ "index.ts": declarative ? buildDeclarativeEntrypoint(extensionName, commandName, capability) : entrypoint,
2409
+ "index.test.ts": declarative ? buildDeclarativeSampleTestSource(extensionName, commandName, capability) : sampleTest,
705
2410
  "tsconfig.json": tsconfig,
706
2411
  ".gitignore": gitignore,
707
- "README.md": packageReadme,
2412
+ "README.md": declarative ? buildDeclarativePackageReadme(packageName, commandName, capability) : packageReadme,
708
2413
  };
709
2414
  }
710
2415
  const readme = [
@@ -713,23 +2418,24 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
713
2418
  "Generated by `pm extension init`.",
714
2419
  "",
715
2420
  "## Included Files",
716
- "- `manifest.json`: extension metadata and capabilities.",
2421
+ manifestBullet,
717
2422
  entrypointBullet,
718
2423
  TSCONFIG_BULLET,
719
2424
  "",
720
2425
  "## Quick Start",
721
- "This extension is authored in TypeScript; compile `index.ts` to the manifest's",
722
- "`./index.js` entry, then install it. The SDK types resolve once",
723
- "`@unbrained/pm-cli` is available to the compiler (install it, Node types, and TypeScript, or",
724
- "build from a project that already depends on the CLI):",
2426
+ "This extension is authored AND loaded as TypeScript: the manifest `entry` is",
2427
+ "`./index.ts` and pm imports it directly via Node's native type stripping",
2428
+ "(Node >=22.18), so there is no compile step. Install the dev dependencies for",
2429
+ "type-checking, then install and run the extension:",
725
2430
  "```bash",
726
2431
  "npm install -D typescript @types/node @unbrained/pm-cli",
727
- "npx tsc",
2432
+ "npx tsc --noEmit",
728
2433
  "pm extension --install --project <scaffold-path>",
729
2434
  `pm ${commandName}`,
730
2435
  "pm extension --doctor --project --detail summary",
731
2436
  "```",
732
2437
  ...EXTENSION_CAPABILITY_README_SECTIONS[capability],
2438
+ ...buildScaffoldActivationReadmeSection(capability, "extension"),
733
2439
  "",
734
2440
  "## Compatibility Bounds",
735
2441
  "`manifest.json` cannot hold comments, so the version-compatibility fields are documented here:",
@@ -740,9 +2446,8 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
740
2446
  "## Policy Metadata",
741
2447
  "The starter command is pure compute, so `manifest.json` declares `trusted: true`, `sandbox_profile: \"strict\"`, and all six permission keys as `false`. Keep that least-privilege shape for pure extensions; relax only the specific permission your extension actually needs and verify with `pm extension --doctor --project --detail deep --trace`.",
742
2448
  "",
743
- "## Notes",
744
- "- This scaffold uses TypeScript ESM source compiled to ESM output, so it works in package scopes with `type: module`.",
745
- "- Author in `index.ts` and recompile to `index.js` (the manifest entry) after editing capabilities or command behavior.",
2449
+ "- This scaffold is TypeScript ESM source loaded directly by pm (no compile), so it works in package scopes with `type: module`.",
2450
+ "- Author in `index.ts` (the manifest entry); edits take effect on the next install/reload there is no `.js` to regenerate.",
746
2451
  "- Release any resources `activate` opens (timers, connections, caches) in the `deactivate` teardown hook.",
747
2452
  "",
748
2453
  ].join("\n");
@@ -756,20 +2461,28 @@ export function buildStarterExtensionScaffoldFiles(extensionName, commandName, v
756
2461
  /**
757
2462
  * Implements scaffold extension project for the public runtime surface of this module.
758
2463
  */
759
- export async function scaffoldExtensionProject(target, vocabulary = "extension", capability = "commands") {
2464
+ export async function scaffoldExtensionProject(target, vocabulary = "extension", capability = "commands", declarative = false) {
760
2465
  const normalizedCapability = capability.trim().toLowerCase();
761
2466
  if (!SCAFFOLD_CAPABILITIES.includes(normalizedCapability)) {
762
2467
  throw new PmCliError(`Unknown scaffold capability "${capability}". Supported capabilities: ${SCAFFOLD_CAPABILITIES.join(", ")}.`, EXIT_CODE.USAGE);
763
2468
  }
764
2469
  const resolvedCapability = normalizedCapability;
2470
+ // The declarative (`composeExtension` blueprint) starter is package-mode only.
2471
+ // `composeExtension` is a runtime SDK *value* import, so it belongs in
2472
+ // package-mode authoring where the SDK is a linked dependency — not in the
2473
+ // import-free extension-only starters that must load without it. Every capability
2474
+ // emits its blueprint form (see buildDeclarativeBlueprintSurface).
2475
+ if (declarative && vocabulary !== "package") {
2476
+ throw new PmCliError("--declarative scaffolds a package-mode blueprint starter (composeExtension is a runtime SDK import). Use `pm package init`, not `pm extension init`.", EXIT_CODE.USAGE);
2477
+ }
2478
+ const style = declarative ? "declarative" : "imperative";
765
2479
  const normalizedTarget = target.trim();
766
2480
  const targetPath = path.resolve(process.cwd(), normalizedTarget);
767
2481
  const extensionName = normalizeManagedDirectoryName(path.basename(targetPath));
768
- // Hyphenated top-level command groups can surface in help but fail dispatch in
769
- // Commander, so generated starters use space-separated command words while the
770
- // manifest and package identity keep their normalized directory names.
771
- const commandName = `${extensionName.replace(/-/g, " ")} ping`;
772
- const scaffoldFiles = buildStarterExtensionScaffoldFiles(extensionName, commandName, vocabulary, resolvedCapability);
2482
+ // Hyphenated names become space-separated command words; reserved roots get a
2483
+ // `starter` prefix so core commands and aliases cannot intercept dispatch.
2484
+ const commandName = buildScaffoldCommandName(extensionName);
2485
+ const scaffoldFiles = buildStarterExtensionScaffoldFiles(extensionName, commandName, vocabulary, resolvedCapability, declarative);
773
2486
  let createdDirectory = false;
774
2487
  if (await pathExists(targetPath)) {
775
2488
  const existingTargetStats = await fs.stat(targetPath);
@@ -812,10 +2525,11 @@ export async function scaffoldExtensionProject(target, vocabulary = "extension",
812
2525
  extension_name: extensionName,
813
2526
  command_name: commandName,
814
2527
  capability: resolvedCapability,
2528
+ style,
815
2529
  target_path: targetPath,
816
2530
  created_directory: createdDirectory,
817
2531
  files,
818
2532
  };
819
2533
  }
820
2534
  //# sourceMappingURL=scaffold.js.map
821
- //# debugId=9eecdd82-fe71-5803-9186-a33244c4722d
2535
+ //# debugId=9cc4cb5f-313d-5e8c-8c63-545a7a8d2a03