@unbrained/pm-cli 2026.6.24 → 2026.6.30

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