@unbrained/pm-cli 2026.8.5 → 2026.8.7

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 (251) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +44 -0
  3. package/dist/cli/main.js +14 -37
  4. package/dist/cli/register-operations.js +11 -2
  5. package/dist/cli/register-setup.d.ts +1 -1
  6. package/dist/cli/register-setup.js +46 -20
  7. package/dist/cli/stats-analytics-json.d.ts +9 -0
  8. package/dist/cli/stats-analytics-json.js +69 -0
  9. package/dist/cli-bundle/bundle-manifest.json +403 -403
  10. package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
  11. package/dist/cli-bundle/chunks/{chunk-PMXJEU3F.js → chunk-2AXF3VSK.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-MHK6LIWE.js → chunk-2XS43CCV.js} +2 -2
  13. package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +8 -0
  14. package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
  15. package/dist/cli-bundle/chunks/{chunk-45G53IU4.js → chunk-4MTI7XOV.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-7C4PTJG6.js → chunk-6BX5UDCN.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-4YUBDMQM.js → chunk-6QPO7KLR.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-HWRRMBJO.js → chunk-7MXHZHSQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-3FTILRJ2.js → chunk-7ZPMJW4U.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-2WFXWAYX.js → chunk-AGYNSNCI.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
  22. package/dist/cli-bundle/chunks/{chunk-43HQQI6S.js → chunk-B4KLBBMN.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-VCKLFEUN.js → chunk-CALJHNBL.js} +12 -12
  24. package/dist/cli-bundle/chunks/{chunk-CSI3WS5I.js → chunk-CFIGP5LY.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-V3EUXXOF.js → chunk-CS6MRHG7.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-YSO3YFZ4.js → chunk-CUGNQQKH.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
  28. package/dist/cli-bundle/chunks/{chunk-BXQLRKWF.js → chunk-H5Y5YE6A.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-54FNT7U2.js → chunk-H5Y6UV6E.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-UP7DTVMD.js → chunk-H7KGWPDF.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-E2RKBKWB.js → chunk-HFSD77TQ.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-V3774P7D.js → chunk-HX2GTA6L.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-UZBWIUYD.js → chunk-J2IEKAVR.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-HNFD72UK.js → chunk-K44PYFXH.js} +2 -2
  35. package/dist/cli-bundle/chunks/{chunk-5ZBOIPGP.js → chunk-K4KGEEBT.js} +2 -2
  36. package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
  37. package/dist/cli-bundle/chunks/{chunk-OMXVBQ2N.js → chunk-KL6IEBV2.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-7A5OT5J2.js → chunk-KWQZDZSS.js} +2 -2
  39. package/dist/cli-bundle/chunks/{chunk-M72BKL5Q.js → chunk-KZ4X3DGU.js} +2 -2
  40. package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
  41. package/dist/cli-bundle/chunks/{chunk-VN5VITU3.js → chunk-ME2JJ4LA.js} +2 -2
  42. package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
  43. package/dist/cli-bundle/chunks/{chunk-A62CYISG.js → chunk-NG6OXIBR.js} +8 -8
  44. package/dist/cli-bundle/chunks/{chunk-42E7YPLG.js → chunk-NYIGHWQY.js} +2 -2
  45. package/dist/cli-bundle/chunks/{chunk-RKAVWO3O.js → chunk-NZ75GNSA.js} +2 -2
  46. package/dist/cli-bundle/chunks/{chunk-DXDREUXT.js → chunk-PCJWJNC2.js} +2 -2
  47. package/dist/cli-bundle/chunks/{chunk-ZYHOB3SN.js → chunk-PD3225AM.js} +2 -2
  48. package/dist/cli-bundle/chunks/{chunk-OTHLDSFP.js → chunk-PDEGKG7P.js} +2 -2
  49. package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
  50. package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +56 -0
  51. package/dist/cli-bundle/chunks/{chunk-L3AZOELJ.js → chunk-TPKN3S7S.js} +2 -2
  52. package/dist/cli-bundle/chunks/{chunk-LKDGK44W.js → chunk-TPXAXTCO.js} +2 -2
  53. package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
  54. package/dist/cli-bundle/chunks/{chunk-R546TPDE.js → chunk-UQLZQVFW.js} +2 -2
  55. package/dist/cli-bundle/chunks/{chunk-BPELKUQD.js → chunk-VT3Z5G7D.js} +2 -2
  56. package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +2 -0
  57. package/dist/cli-bundle/chunks/{chunk-4VN6GS4U.js → chunk-WSJEIGJF.js} +2 -2
  58. package/dist/cli-bundle/chunks/{chunk-UN66FZRO.js → chunk-WYNUU7ZW.js} +49 -46
  59. package/dist/cli-bundle/chunks/{chunk-NY4T3JWN.js → chunk-YGPNCCXZ.js} +2 -2
  60. package/dist/cli-bundle/chunks/close-CMY3BAUG.js +2 -0
  61. package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +2 -0
  62. package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +2 -0
  63. package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +2 -0
  64. package/dist/cli-bundle/chunks/{create-XLKTXTUF.js → create-I5DVV4YG.js} +2 -2
  65. package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
  66. package/dist/cli-bundle/chunks/{deps-ITTY3GIC.js → deps-S7UBCECS.js} +2 -2
  67. package/dist/cli-bundle/chunks/{docs-W4OSRTYR.js → docs-ZZNVBBYO.js} +2 -2
  68. package/dist/cli-bundle/chunks/{files-EOK4AZI4.js → files-27C337VT.js} +2 -2
  69. package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
  70. package/dist/cli-bundle/chunks/{history-compact-7UGTMLL3.js → history-compact-HJQK67CZ.js} +2 -2
  71. package/dist/cli-bundle/chunks/{history-redact-4DZRMD6Z.js → history-redact-PWC6PDWA.js} +2 -2
  72. package/dist/cli-bundle/chunks/{history-repair-UPOSZW5R.js → history-repair-N3CY4WBF.js} +2 -2
  73. package/dist/cli-bundle/chunks/{learnings-GMRNCBS3.js → learnings-4FH23XDT.js} +2 -2
  74. package/dist/cli-bundle/chunks/{profile-2MUUMHRE.js → profile-5Y5XXH5N.js} +2 -2
  75. package/dist/cli-bundle/chunks/{register-list-query-LR3SQ5ZF.js → register-list-query-FJZCJ67O.js} +2 -2
  76. package/dist/cli-bundle/chunks/{register-mutation-SUOHFVWM.js → register-mutation-YGYPW3BL.js} +3 -3
  77. package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +2 -0
  78. package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +2 -0
  79. package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
  80. package/dist/cli-bundle/chunks/{schema-FJ4EA3XF.js → schema-EQGKBYXJ.js} +2 -2
  81. package/dist/cli-bundle/chunks/update-QVTYOD6I.js +2 -0
  82. package/dist/cli-bundle/chunks/update-many-DJSBU525.js +2 -0
  83. package/dist/cli-bundle/focused-chunks/{chunk-MJ7HWSFK.js → chunk-2ECLECMK.js} +3 -3
  84. package/dist/cli-bundle/focused-chunks/{chunk-A7BJ5SS6.js → chunk-3K4XV2BF.js} +2 -2
  85. package/dist/cli-bundle/focused-chunks/{chunk-PIMMYG7Q.js → chunk-4EX25PXM.js} +2 -2
  86. package/dist/cli-bundle/focused-chunks/chunk-4VJQTS3P.js +2 -0
  87. package/dist/cli-bundle/focused-chunks/chunk-73JUDYXT.js +2 -0
  88. package/dist/cli-bundle/focused-chunks/{chunk-WVIVUWVL.js → chunk-CIXVQPB7.js} +2 -2
  89. package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +2 -0
  90. package/dist/cli-bundle/focused-chunks/{chunk-FGKY4MBE.js → chunk-DQ6FKGL3.js} +10 -10
  91. package/dist/cli-bundle/focused-chunks/{chunk-QVHKCI4T.js → chunk-HNL6IFGS.js} +2 -2
  92. package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
  93. package/dist/cli-bundle/focused-chunks/{chunk-G6ETT4QK.js → chunk-MHMTKV5V.js} +2 -2
  94. package/dist/cli-bundle/focused-chunks/{chunk-7J5TUBUJ.js → chunk-MOTJFQ3F.js} +22 -22
  95. package/dist/cli-bundle/focused-chunks/{chunk-UIL2M2NA.js → chunk-NBJKQP4S.js} +2 -2
  96. package/dist/cli-bundle/focused-chunks/{chunk-RUR5I3TK.js → chunk-QHRTT7WT.js} +2 -2
  97. package/dist/cli-bundle/focused-chunks/{chunk-B7LJWAZE.js → chunk-R2LEMEV5.js} +2 -2
  98. package/dist/cli-bundle/focused-chunks/{chunk-SV3O7TSH.js → chunk-RPNYG5MO.js} +2 -2
  99. package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +4 -0
  100. package/dist/cli-bundle/focused-chunks/chunk-TIKDBG4D.js +29 -0
  101. package/dist/cli-bundle/focused-chunks/{chunk-IPWSFADF.js → chunk-VZFU2R4M.js} +2 -2
  102. package/dist/cli-bundle/focused-chunks/{chunk-WEM2E2PE.js → chunk-YZEZAPJK.js} +2 -2
  103. package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
  104. package/dist/cli-bundle/main.js +13 -13
  105. package/dist/cli-bundle/sdk-authoring.js +1 -1
  106. package/dist/cli-bundle/sdk-contracts.js +1 -1
  107. package/dist/cli-bundle/sdk-core.js +29 -28
  108. package/dist/cli-bundle/sdk-governance.js +1 -1
  109. package/dist/cli-bundle/sdk-graph.js +1 -1
  110. package/dist/cli-bundle/sdk-merge.js +1 -1
  111. package/dist/cli-bundle/sdk-query.js +1 -1
  112. package/dist/cli-bundle/sdk-runtime.js +1 -1
  113. package/dist/cli-bundle/sdk-testing.js +1 -1
  114. package/dist/cli-bundle/sdk.js +1 -1
  115. package/dist/core/extensions/activation-summary.d.ts +4 -0
  116. package/dist/core/extensions/activation-summary.js +5 -2
  117. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  118. package/dist/core/extensions/contribution-inventory.js +35 -2
  119. package/dist/core/extensions/extension-hook-runtime.js +5 -3
  120. package/dist/core/extensions/extension-types.d.ts +18 -1
  121. package/dist/core/extensions/extension-types.js +2 -2
  122. package/dist/core/extensions/loader.js +5 -13
  123. package/dist/core/extensions/preflight-ownership.d.ts +5 -0
  124. package/dist/core/extensions/preflight-ownership.js +42 -0
  125. package/dist/core/extensions/reserved-host-flags.js +3 -2
  126. package/dist/core/history/workspace-history.d.ts +22 -2
  127. package/dist/core/history/workspace-history.js +60 -36
  128. package/dist/core/output/output.d.ts +2 -0
  129. package/dist/core/output/output.js +3 -2
  130. package/dist/core/shared/command-types.d.ts +2 -0
  131. package/dist/core/shared/command-types.js +2 -2
  132. package/dist/mcp/tool-definitions.js +6 -2
  133. package/dist/sdk/author-attribution.js +23 -7
  134. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  135. package/dist/sdk/cli-bootstrap.js +7 -2
  136. package/dist/sdk/cli-contracts/completeness.js +51 -4
  137. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  138. package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
  139. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  140. package/dist/sdk/cli-contracts/runtime-contracts.js +16 -9
  141. package/dist/sdk/cli-contracts/tool-parameter-tables.js +116 -10
  142. package/dist/sdk/cli-contracts/tool-schema.js +18 -2
  143. package/dist/sdk/cli-contracts.d.ts +1 -1
  144. package/dist/sdk/cli-contracts.js +3 -3
  145. package/dist/sdk/cli-program.js +3 -2
  146. package/dist/sdk/completion.js +5 -2
  147. package/dist/sdk/compose.d.ts +2 -2
  148. package/dist/sdk/compose.js +7 -2
  149. package/dist/sdk/contracts.d.ts +1 -0
  150. package/dist/sdk/contracts.js +2 -2
  151. package/dist/sdk/core.d.ts +3 -1
  152. package/dist/sdk/core.js +4 -3
  153. package/dist/sdk/define.d.ts +3 -1
  154. package/dist/sdk/define.js +3 -8
  155. package/dist/sdk/extension/install-sources.d.ts +43 -5
  156. package/dist/sdk/extension/install-sources.js +36 -2
  157. package/dist/sdk/extension/migrations.d.ts +114 -0
  158. package/dist/sdk/extension/migrations.js +175 -0
  159. package/dist/sdk/extension/scaffold.js +14 -9
  160. package/dist/sdk/extension/source-resolution.d.ts +50 -0
  161. package/dist/sdk/extension/source-resolution.js +66 -0
  162. package/dist/sdk/extension.d.ts +5 -1
  163. package/dist/sdk/extension.js +31 -35
  164. package/dist/sdk/generated-error-code-catalog.js +112 -2
  165. package/dist/sdk/governance/health.js +11 -2
  166. package/dist/sdk/history-analytics.d.ts +141 -0
  167. package/dist/sdk/history-analytics.js +283 -0
  168. package/dist/sdk/improvement-ledger-validation.d.ts +3 -0
  169. package/dist/sdk/improvement-ledger-validation.js +63 -0
  170. package/dist/sdk/improvement-ledger.d.ts +139 -0
  171. package/dist/sdk/improvement-ledger.js +261 -0
  172. package/dist/sdk/index.d.ts +11 -3
  173. package/dist/sdk/index.js +12 -4
  174. package/dist/sdk/lifecycle/plan.js +6 -3
  175. package/dist/sdk/merge/install.js +10 -2
  176. package/dist/sdk/package-migrations.d.ts +10 -0
  177. package/dist/sdk/package-migrations.js +21 -0
  178. package/dist/sdk/read-output-budget.js +24 -22
  179. package/dist/sdk/read-output-contracts.d.ts +10 -2
  180. package/dist/sdk/read-output-contracts.js +124 -65
  181. package/dist/sdk/read-output-rows.d.ts +29 -0
  182. package/dist/sdk/read-output-rows.js +100 -0
  183. package/dist/sdk/read-output-session.d.ts +69 -0
  184. package/dist/sdk/read-output-session.js +200 -0
  185. package/dist/sdk/runtime-input.d.ts +2 -0
  186. package/dist/sdk/runtime-input.js +14 -2
  187. package/dist/sdk/runtime-primitives.d.ts +1 -1
  188. package/dist/sdk/runtime-primitives.js +3 -3
  189. package/dist/sdk/runtime-stats-options.d.ts +9 -0
  190. package/dist/sdk/runtime-stats-options.js +38 -0
  191. package/dist/sdk/runtime.d.ts +3 -0
  192. package/dist/sdk/runtime.js +10 -27
  193. package/dist/sdk/stats.d.ts +40 -0
  194. package/dist/sdk/stats.js +112 -29
  195. package/docs/COMMANDS.md +9 -0
  196. package/docs/EXTENSIONS.md +2 -2
  197. package/docs/EXTENSION_LIFECYCLE.md +46 -0
  198. package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
  202. package/docs/RELEASING.md +33 -20
  203. package/docs/SDK.md +31 -3
  204. package/marketplace.json +2 -2
  205. package/package.json +5 -5
  206. package/packages/pm-beads/package.json +1 -1
  207. package/packages/pm-calendar/package.json +1 -1
  208. package/packages/pm-command-kit/package.json +1 -1
  209. package/packages/pm-digital-twin/package.json +1 -1
  210. package/packages/pm-governance-audit/package.json +1 -1
  211. package/packages/pm-guide-shell/package.json +1 -1
  212. package/packages/pm-kanban/package.json +1 -1
  213. package/packages/pm-lifecycle-hooks/package.json +1 -1
  214. package/packages/pm-linked-test-adapters/package.json +1 -1
  215. package/packages/pm-search-advanced/package.json +1 -1
  216. package/packages/pm-templates/package.json +1 -1
  217. package/packages/pm-todos/package.json +1 -1
  218. package/packages/pm-vcs/package.json +1 -1
  219. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  220. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  221. package/sdk/public-surface.json +566 -815
  222. package/dist/cli-bundle/chunks/append-VXXGOXSG.js +0 -2
  223. package/dist/cli-bundle/chunks/chunk-6MSQJOTG.js +0 -13
  224. package/dist/cli-bundle/chunks/chunk-EGJ4JTUG.js +0 -55
  225. package/dist/cli-bundle/chunks/chunk-FPBQHMFT.js +0 -8
  226. package/dist/cli-bundle/chunks/chunk-GE4KCSZP.js +0 -164
  227. package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +0 -2
  228. package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-Q35VBGOQ.js +0 -5
  230. package/dist/cli-bundle/chunks/chunk-SSF4PIUR.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +0 -20
  232. package/dist/cli-bundle/chunks/chunk-XCEZYMNI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-YEWNL576.js +0 -2
  234. package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +0 -2
  235. package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +0 -2
  236. package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +0 -2
  237. package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +0 -2
  238. package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +0 -2
  239. package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +0 -2
  240. package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +0 -2
  241. package/dist/cli-bundle/chunks/register-setup-O6AYP6NP.js +0 -2
  242. package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +0 -2
  243. package/dist/cli-bundle/chunks/update-YHV52CSS.js +0 -2
  244. package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +0 -2
  245. package/dist/cli-bundle/focused-chunks/chunk-BIMTMOS7.js +0 -4
  246. package/dist/cli-bundle/focused-chunks/chunk-GJ2TG2CW.js +0 -28
  247. package/dist/cli-bundle/focused-chunks/chunk-N5XU5UVK.js +0 -2
  248. package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +0 -2
  249. package/dist/cli-bundle/focused-chunks/chunk-VLYOEYML.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +0 -2
  251. package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +0 -2
@@ -4,7 +4,7 @@
4
4
  * Implements the pm completion command surface and its agent-facing runtime behavior.
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]="bba460dd-91d7-5444-b754-58c684a425fd")}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]="8acb405a-140e-532c-81c0-e8153ea30dc0")}catch(e){}}();
8
8
  import { EXIT_CODE, PmCliError } from "./runtime-primitives.js";
9
9
  import { listPmCommandsForTier } from "./agent-capability-contracts.js";
10
10
  import { SCAFFOLD_CAPABILITIES } from "./extension/scaffold.js";
@@ -787,6 +787,7 @@ _pm() {
787
787
  '--output-limit[Set the universal read row ceiling]:limit' \\
788
788
  '--output-budget[Set the universal estimated-token ceiling]:tokens' \\
789
789
  '--output-format[Select the universal read encoding]:(toon json)' \\
790
+ '--output-session[Carry cross-call read budget and served-item state]:state' \\
790
791
  '--no-changed-fields[Omit changed_fields array from mutation output]' \\
791
792
  '--pm-path[Explicit tracker storage path for this command]:path:_files -/' \\
792
793
  '--path[Compatibility alias for --pm-path]:path:_files -/' \\
@@ -1811,6 +1812,7 @@ complete -c pm -l output-include -d 'Retain comma-separated read fields or secti
1811
1812
  complete -c pm -l output-limit -d 'Set the universal read row ceiling' -r
1812
1813
  complete -c pm -l output-budget -d 'Set the universal estimated-token ceiling' -r
1813
1814
  complete -c pm -l output-format -d 'Select the universal read encoding' -r -a 'toon json'
1815
+ complete -c pm -l output-session -d 'Carry cross-call read budget and served-item state' -r
1814
1816
  complete -c pm -l no-changed-fields -d 'Omit changed_fields array from mutation output'
1815
1817
  complete -c pm -l id-only -d 'Print only id and status for single-item mutation output'
1816
1818
  complete -c pm -l pm-path -d 'Explicit tracker storage path for this command' -r
@@ -2484,6 +2486,7 @@ complete -c pm -n '__fish_seen_subcommand_from stats' -l by-assignee -d 'Lifecyc
2484
2486
  complete -c pm -n '__fish_seen_subcommand_from stats' -l by-tag -d 'Lifecycle-bucketed breakdown grouped by tag'
2485
2487
  complete -c pm -n '__fish_seen_subcommand_from stats' -l by-priority -d 'Lifecycle-bucketed breakdown grouped by priority'
2486
2488
  complete -c pm -n '__fish_seen_subcommand_from stats' -l tag-prefix -d 'With --by-tag: only count tags with this prefix' -r
2489
+ complete -c pm -n '__fish_seen_subcommand_from stats' -l analytics -d 'Improvement ledger/history analytics JSON' -r
2487
2490
 
2488
2491
  # append flags
2489
2492
  complete -c pm -n '__fish_seen_subcommand_from append' -s b -l body -d 'Item body' -r
@@ -2740,4 +2743,4 @@ export function runCompletion(shell, itemTypes = [], tags = [], eagerTagExpansio
2740
2743
  };
2741
2744
  }
2742
2745
  //# sourceMappingURL=completion.js.map
2743
- //# debugId=bba460dd-91d7-5444-b754-58c684a425fd
2746
+ //# debugId=8acb405a-140e-532c-81c0-e8153ea30dc0
@@ -25,7 +25,7 @@
25
25
  * declarative (`composeExtension`) authoring styles live together. Both are
26
26
  * re-exported from the SDK barrel, so the public API is unchanged.
27
27
  */
28
- import type { AfterCommandHook, BeforeCommandHook, BeforeMutationHook, CommandDefinition, CommandOverride, ExtensionApi, ExtensionCapability, ExtensionManifest, ExtensionServiceName, Exporter, FlagDefinition, ImportExportRegistrationOptions, Importer, OnIndexHook, OnReadHook, OnWriteHook, OutputRendererFormat, ParserOverride, PreflightOverride, RendererOverride, ScopedRendererOverrideDefinition, SchemaFieldDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SearchProviderDefinition, ServiceOverride, VectorStoreAdapterDefinition } from "../core/extensions/loader.js";
28
+ import type { AfterCommandHook, BeforeCommandHook, BeforeMutationHook, CommandDefinition, CommandOverride, ExtensionApi, ExtensionCapability, ExtensionManifest, ExtensionServiceName, Exporter, FlagDefinition, ImportExportRegistrationOptions, Importer, OnIndexHook, OnReadHook, OnWriteHook, OutputRendererFormat, ParserOverride, PreflightOverride, ScopedPreflightOverrideDefinition, RendererOverride, ScopedRendererOverrideDefinition, SchemaFieldDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SearchProviderDefinition, ServiceOverride, VectorStoreAdapterDefinition } from "../core/extensions/loader.js";
29
29
  import type { ExtensionActivationSummary } from "../core/extensions/activation-summary.js";
30
30
  import type { ProjectProfileRegistrationInput } from "../core/profile/profile-presets.js";
31
31
  import type { PmMaxVersionExceededMode } from "../core/extensions/extension-types.js";
@@ -137,7 +137,7 @@ export interface ExtensionBlueprint {
137
137
  /** Service overrides keyed by service name, registered via `api.registerService(service, override)`. */
138
138
  services?: Partial<Record<ExtensionServiceName, ServiceOverride>>;
139
139
  /** Preflight overrides registered via `api.registerPreflight(override)`. */
140
- preflights?: PreflightOverride[];
140
+ preflights?: Array<PreflightOverride | ScopedPreflightOverrideDefinition>;
141
141
  /** Custom item types registered in a single `api.registerItemTypes(types)` call. */
142
142
  itemTypes?: SchemaItemTypeDefinition[];
143
143
  /** Custom item-metadata fields registered in a single `api.registerItemFields(fields)` call. */
@@ -1,5 +1,5 @@
1
1
 
2
- !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]="60463c2e-f904-5199-87b0-8a17f0e2ee0f")}catch(e){}}();
2
+ !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]="142a413a-35a6-5861-9063-0c196a176eaa")}catch(e){}}();
3
3
  import { normalizeKnownExtensionCapability, resolveLegacyExtensionCapabilityAlias, } from "../core/extensions/extension-capability-aliases.js";
4
4
  import { normalizeCommandName } from "../core/extensions/extension-runtime-helpers.js";
5
5
  import { RESERVED_ITEM_FIELD_NAMES } from "../core/extensions/item-fields.js";
@@ -531,6 +531,11 @@ function collectBlueprintSurfaceSummary(blueprint, importers, exporters) {
531
531
  renderer_overrides: sortUnique(Object.keys(blueprint.renderers ?? {}).map((format) => String(format).trim().toLowerCase())),
532
532
  ...collectBlueprintRendererOwnership(blueprint.renderers),
533
533
  preflight_overrides: (blueprint.preflights ?? []).length,
534
+ preflight_ownership: (blueprint.preflights ?? []).map((preflight) => ({
535
+ commands: [
536
+ ...(preflight.commands ?? []),
537
+ ],
538
+ })),
534
539
  };
535
540
  }
536
541
  /**
@@ -1052,4 +1057,4 @@ export function preflightExtension(blueprint, options = {}) {
1052
1057
  };
1053
1058
  }
1054
1059
  //# sourceMappingURL=compose.js.map
1055
- //# debugId=60463c2e-f904-5199-87b0-8a17f0e2ee0f
1060
+ //# debugId=142a413a-35a6-5861-9063-0c196a176eaa
@@ -11,3 +11,4 @@ export * from "./flag-invocation-contracts.js";
11
11
  export * from "./output-token-accounting.js";
12
12
  export * from "./output-contracts.js";
13
13
  export * from "./read-output-contracts.js";
14
+ export type { PmReadOutputSessionReceipt, PmReadOutputSessionState, } from "./read-output-session.js";
@@ -4,7 +4,7 @@
4
4
  * Exposes command and action contract data without loading SDK runtime code.
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]="2962656f-386f-59a0-8dc1-411ae382dddb")}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]="8c442738-13e6-5bf5-b60d-1439c3255f1a")}catch(e){}}();
8
8
  export * from "./cli-contracts.js";
9
9
  export * from "./context-intent-contracts.js";
10
10
  export * from "./error-code-catalog.js";
@@ -14,4 +14,4 @@ export * from "./output-token-accounting.js";
14
14
  export * from "./output-contracts.js";
15
15
  export * from "./read-output-contracts.js";
16
16
  //# sourceMappingURL=contracts.js.map
17
- //# debugId=2962656f-386f-59a0-8dc1-411ae382dddb
17
+ //# debugId=8c442738-13e6-5bf5-b60d-1439c3255f1a
@@ -6,6 +6,8 @@
6
6
  export { BASELINE_ITEM_FORMAT_VERSION, BUILTIN_ITEM_TYPE_VALUES, CONFIDENCE_TEXT_VALUES, CURRENT_ITEM_FORMAT_VERSION, DEPENDENCY_KIND_VALUES, EXIT_CODE, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, PM_CLI_EXPECTED_ERROR_NAME, PmCliError, PmClient, RISK_VALUES, STATUS_VALUES, canonicalDocument, classifyItemFormatVersion, createPmCliExpectedError, effectiveItemFormatVersion, emptyImportedDocument, isPmCliExpectedError, normalizeItemFormatVersion, normalizeItemId, normalizeStatusInput, nowIso, runAction, serializeItemDocument, aggregate, append, claim, claimNext, close, comments, context, copy, create, deleteItem, deps, docs, files, filesDiscover, focus, get, graph, learnings, list, next, notes, release, restore, search, update, type AggregateOptions, type AggregateResult, type AggregateRow, type AppendCommandOptions, type AppendResult, type ClaimNextOptions, type ClaimResult, type CloseResult, type CommentsCommandOptions, type CommentsResult, type ContextOptions, type ContextResult, type CopyResult, type CreateResult, type Dependency, type DeleteResult, type DepsCommandOptions, type DepsResult, type DocsCommandOptions, type DocsResult, type FilesCommandOptions, type FilesDiscoverOptions, type FilesDiscoverResult, type FilesResult, type FocusResult, type GetOptions, type GetResult, type ItemFormatVersionScanEntry, type ItemFormatVersionScanResult, type ItemFormatVersionStatus, type LearningsCommandOptions, type LearningsResult, type ListOptions, type ListResult, type NextOptions, type NextResult, type NotesCommandOptions, type NotesResult, type PmActionInput, type PmActionName, type PmActionOptions, type PmClientOptions, type ReleaseResult, type RestoreResult, type SearchOptions, type SearchResult, type UpdateResult, } from "./runtime.js";
7
7
  export * from "./core-governance.js";
8
8
  export * from "./agent-session-context.js";
9
- export { PM_READ_OUTPUT_DIMENSIONS, PM_READ_OUTPUT_OPTION_FLAGS, PM_READ_OUTPUT_SURFACE_CONTRACTS, applyReadOutputDimensions, isReadOutputBudgetExceeded, resolveReadOutputDimensions, resolveReadOutputEncoding, resolveReadOutputSurface, validateReadOutputOptions, } from "./read-output-contracts.js";
9
+ export { PM_READ_OUTPUT_DIMENSIONS, PM_READ_OUTPUT_OPTION_FLAGS, PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS, PM_READ_OUTPUT_SURFACE_CONTRACTS, applyReadOutputDimensions, isReadOutputBudgetExceeded, resolveReadOutputDimensions, resolveReadOutputEncoding, resolveReadOutputSurface, validateReadOutputOptions, } from "./read-output-contracts.js";
10
+ export { applyReadOutputSessionReferences, attachReadOutputSessionReceipt, parseReadOutputSession, readOutputSessionRemainingTokens, } from "./read-output-session.js";
10
11
  export type { PmReadOutputBudgetExceeded, PmReadOutputDimension, PmReadOutputLegacyAlias, PmReadOutputOptions, PmReadOutputReceipt, PmReadOutputResult, PmReadOutputResultFor, PmReadOutputSurface, PmReadOutputSurfaceContract, } from "./read-output-contracts.js";
12
+ export type { PmReadOutputSessionReceipt, PmReadOutputSessionReference, PmReadOutputSessionState, } from "./read-output-session.js";
11
13
  export type { ItemDocument, ItemMetadata, ItemStatus, ItemType, PmSettings, } from "../types/index.js";
package/dist/sdk/core.js CHANGED
@@ -4,10 +4,11 @@
4
4
  * Provides the stable item lifecycle client and universal project data types.
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]="d70db3d9-b094-52fd-8f0f-47eed9f6e7f0")}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]="54d31df7-e708-585d-9fb2-3c5ddfcc6138")}catch(e){}}();
8
8
  export { BASELINE_ITEM_FORMAT_VERSION, BUILTIN_ITEM_TYPE_VALUES, CONFIDENCE_TEXT_VALUES, CURRENT_ITEM_FORMAT_VERSION, DEPENDENCY_KIND_VALUES, EXIT_CODE, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, PM_CLI_EXPECTED_ERROR_NAME, PmCliError, PmClient, RISK_VALUES, STATUS_VALUES, canonicalDocument, classifyItemFormatVersion, createPmCliExpectedError, effectiveItemFormatVersion, emptyImportedDocument, isPmCliExpectedError, normalizeItemFormatVersion, normalizeItemId, normalizeStatusInput, nowIso, runAction, serializeItemDocument, aggregate, append, claim, claimNext, close, comments, context, copy, create, deleteItem, deps, docs, files, filesDiscover, focus, get, graph, learnings, list, next, notes, release, restore, search, update, } from "./runtime.js";
9
9
  export * from "./core-governance.js";
10
10
  export * from "./agent-session-context.js";
11
- export { PM_READ_OUTPUT_DIMENSIONS, PM_READ_OUTPUT_OPTION_FLAGS, PM_READ_OUTPUT_SURFACE_CONTRACTS, applyReadOutputDimensions, isReadOutputBudgetExceeded, resolveReadOutputDimensions, resolveReadOutputEncoding, resolveReadOutputSurface, validateReadOutputOptions, } from "./read-output-contracts.js";
11
+ export { PM_READ_OUTPUT_DIMENSIONS, PM_READ_OUTPUT_OPTION_FLAGS, PM_READ_OUTPUT_COMPOSITION_OPTION_FLAGS, PM_READ_OUTPUT_SURFACE_CONTRACTS, applyReadOutputDimensions, isReadOutputBudgetExceeded, resolveReadOutputDimensions, resolveReadOutputEncoding, resolveReadOutputSurface, validateReadOutputOptions, } from "./read-output-contracts.js";
12
+ export { applyReadOutputSessionReferences, attachReadOutputSessionReceipt, parseReadOutputSession, readOutputSessionRemainingTokens, } from "./read-output-session.js";
12
13
  //# sourceMappingURL=core.js.map
13
- //# debugId=d70db3d9-b094-52fd-8f0f-47eed9f6e7f0
14
+ //# debugId=54d31df7-e708-585d-9fb2-3c5ddfcc6138
@@ -32,7 +32,7 @@
32
32
  * non-generic signature lets TypeScript type the handler parameter from the
33
33
  * declared function type.
34
34
  */
35
- import type { AfterCommandHook, BeforeCommandHook, BeforeMutationHook, CommandDefinition, CommandOverride, Exporter, ExtensionManifest, FlagDefinition, Importer, OnIndexHook, OnReadHook, OnWriteHook, ParserOverride, PreflightOverride, RendererOverride, ScopedRendererOverrideDefinition, SchemaFieldDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SearchProviderDefinition, ServiceOverride, ServiceOverrideDecision, VectorStoreAdapterDefinition } from "../core/extensions/loader.js";
35
+ import type { AfterCommandHook, BeforeCommandHook, BeforeMutationHook, CommandDefinition, CommandOverride, Exporter, ExtensionManifest, FlagDefinition, Importer, OnIndexHook, OnReadHook, OnWriteHook, ParserOverride, PreflightOverride, ScopedPreflightOverrideDefinition, RendererOverride, ScopedRendererOverrideDefinition, SchemaFieldDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SearchProviderDefinition, ServiceOverride, ServiceOverrideDecision, VectorStoreAdapterDefinition } from "../core/extensions/loader.js";
36
36
  import type { ProjectProfileDefinition } from "../core/profile/profile-presets.js";
37
37
  type ExactDefinition<TDefinition, TContract> = TDefinition & Record<Exclude<keyof TDefinition, keyof TContract>, never>;
38
38
  type FlagAuthoringDefinition = Pick<FlagDefinition, "long" | "short" | "value_name" | "description" | "required" | "enabled" | "visible" | "value_type" | "type" | "list" | "default">;
@@ -145,6 +145,8 @@ export declare function defineParserOverride(override: ParserOverride): ParserOv
145
145
  * package's pre-run validation override is checked at the definition site.
146
146
  */
147
147
  export declare function definePreflightOverride(override: PreflightOverride): PreflightOverride;
148
+ /** Type a scoped preflight definition while preserving literal command ownership. */
149
+ export declare function definePreflightOverride<TDefinition extends ScopedPreflightOverrideDefinition>(override: ExactDefinition<TDefinition, ScopedPreflightOverrideDefinition>): TDefinition;
148
150
  /**
149
151
  * Type a service-override handler for `api.registerService(service, override)`.
150
152
  *
@@ -9,7 +9,7 @@
9
9
  * to keep `capabilities` matched to the surfaces the extension actually registers.
10
10
  */
11
11
 
12
- !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]="9212673f-1a9f-50b8-92a2-4fd30ce54351")}catch(e){}}();
12
+ !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]="7fc669d4-1db2-5636-8304-2c111a684726")}catch(e){}}();
13
13
  export function defineExtensionManifest(manifest) {
14
14
  return manifest;
15
15
  }
@@ -119,12 +119,7 @@ export function defineCommandOverride(override) {
119
119
  export function defineParserOverride(override) {
120
120
  return override;
121
121
  }
122
- /**
123
- * Type a preflight-override handler for `api.registerPreflight(override)`.
124
- *
125
- * Contextually types the `context` parameter and the returned gate decision so a
126
- * package's pre-run validation override is checked at the definition site.
127
- */
122
+ /** Implement the preflight authoring identity for callbacks and scoped definitions. */
128
123
  export function definePreflightOverride(override) {
129
124
  return override;
130
125
  }
@@ -223,4 +218,4 @@ export function defineOnIndexHook(hook) {
223
218
  return hook;
224
219
  }
225
220
  //# sourceMappingURL=define.js.map
226
- //# debugId=9212673f-1a9f-50b8-92a2-4fd30ce54351
221
+ //# debugId=7fc669d4-1db2-5636-8304-2c111a684726
@@ -13,36 +13,73 @@ interface LocalPackageArchiveLimits {
13
13
  maxExpandedBytes: number;
14
14
  maxEntryBytes: number;
15
15
  }
16
- interface LocalInstallSource {
16
+ /** Parsed filesystem install source. */
17
+ export interface LocalInstallSource {
18
+ /** Discriminator for a filesystem source. */
17
19
  kind: "local";
20
+ /** Exact caller-provided source text. */
18
21
  input: string;
22
+ /** Absolute normalized source path. */
19
23
  absolute_path: string;
20
24
  }
21
- interface GithubInstallSource {
25
+ /** Parsed GitHub repository install source. */
26
+ export interface GithubInstallSource {
27
+ /** Discriminator for a GitHub repository source. */
22
28
  kind: "github";
29
+ /** Exact caller-provided source text. */
23
30
  input: string;
31
+ /** Repository owner. */
24
32
  owner: string;
33
+ /** Repository name without a `.git` suffix. */
25
34
  repo: string;
35
+ /** Cloneable HTTPS repository URL. */
26
36
  repository: string;
37
+ /** Optional Git ref selected by the caller or URL. */
27
38
  ref?: string;
39
+ /** Optional repository-relative package directory. */
28
40
  subpath?: string;
29
41
  }
30
- interface NpmInstallSource {
42
+ /** Parsed npm registry or package-spec install source. */
43
+ export interface NpmInstallSource {
44
+ /** Discriminator for an npm package source. */
31
45
  kind: "npm";
46
+ /** Exact caller-provided source text. */
32
47
  input: string;
48
+ /** Validated npm package specification. */
33
49
  spec: string;
34
50
  }
35
- type InstallSource = LocalInstallSource | GithubInstallSource | NpmInstallSource;
36
- interface ResolvedInstallSource {
51
+ /** Parsed extension install source accepted by the resolver. */
52
+ export type InstallSource = LocalInstallSource | GithubInstallSource | NpmInstallSource;
53
+ /** Materialized install source ready for extension validation. */
54
+ export interface ResolvedInstallSource {
55
+ /** Parsed source that produced this directory. */
37
56
  source: InstallSource;
57
+ /** Absolute extension or package directory ready for validation. */
38
58
  directory: string;
59
+ /** Root unpacked or cloned source directory when different from `directory`. */
39
60
  source_root?: string;
61
+ /** Repository subpath selected after clone. */
40
62
  resolved_subpath?: string;
63
+ /** Resolved Git commit when the source is a repository. */
41
64
  commit?: string;
65
+ /** Canonical npm package name when the source is a registry package. */
42
66
  npm_package?: string;
67
+ /** Resolved npm package version. */
43
68
  npm_version?: string;
69
+ /** Releases temporary source material created during resolution. */
44
70
  cleanup?: () => Promise<void>;
45
71
  }
72
+ /** Installed npm package that competes with a bare bundled install target. */
73
+ export interface InstalledNpmPackageCandidate {
74
+ /** Package identity read from its package.json. */
75
+ package: string;
76
+ /** Installed package version when declared. */
77
+ version?: string;
78
+ /** Absolute package root selected by Node-style ancestor lookup. */
79
+ directory: string;
80
+ }
81
+ /** Resolve an already-installed npm package without executing package code. */
82
+ export declare function findInstalledNpmPackageCandidate(packageName: string, cwd?: string): Promise<InstalledNpmPackageCandidate | null>;
46
83
  /** Implements parse extension install source for the public runtime surface of this module. */
47
84
  export declare function parseExtensionInstallSource(input: string, options?: {
48
85
  forceGithub?: boolean;
@@ -128,6 +165,7 @@ export declare const _testOnlyInstallSources: {
128
165
  resolveNpmSourceDirectoryWithRunner: typeof resolveNpmSourceDirectoryWithRunner;
129
166
  resolveNpmSourceDirectory: typeof resolveNpmSourceDirectory;
130
167
  resolveNpmPackSpec: typeof resolveNpmPackSpec;
168
+ findInstalledNpmPackageCandidate: typeof findInstalledNpmPackageCandidate;
131
169
  resolvePackageExtensionDirectory: typeof resolvePackageExtensionDirectory;
132
170
  runtimeDependencyInstallSpecs: typeof runtimeDependencyInstallSpecs;
133
171
  hasHostedPmCliDependency: typeof hasHostedPmCliDependency;
@@ -4,7 +4,7 @@
4
4
  * Implements extension package-management support for Install Sources.
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]="0c87e77d-e7c5-5f0c-aad6-b047e33ccb25")}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]="8994c8e2-8e3a-5e00-a3ca-7bd553c045d7")}catch(e){}}();
8
8
  import { execFile } from "node:child_process";
9
9
  import fs from "node:fs/promises";
10
10
  import os from "node:os";
@@ -29,6 +29,39 @@ const LOCAL_PACKAGE_ARCHIVE_LIMITS = {
29
29
  maxEntryBytes: 64 * 1024 * 1024,
30
30
  };
31
31
  let bundledPackageAliasesCache;
32
+ /** Resolve an already-installed npm package without executing package code. */
33
+ export async function findInstalledNpmPackageCandidate(packageName, cwd = process.cwd()) {
34
+ const normalized = packageName.trim();
35
+ if (!/^(@[^/\\\s]+\/[^/\\\s]+|[^@/\\\s][^/\\\s]*)$/u.test(normalized)) {
36
+ return null;
37
+ }
38
+ let current = path.resolve(cwd);
39
+ while (true) {
40
+ const directory = path.join(current, "node_modules", ...normalized.split("/"));
41
+ const manifestPath = path.join(directory, "package.json");
42
+ if (await pathExists(manifestPath)) {
43
+ try {
44
+ const manifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
45
+ if (manifest.name === normalized) {
46
+ return {
47
+ package: normalized,
48
+ ...(typeof manifest.version === "string"
49
+ ? { version: manifest.version }
50
+ : {}),
51
+ directory,
52
+ };
53
+ }
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ }
59
+ const parent = path.dirname(current);
60
+ if (parent === current)
61
+ return null;
62
+ current = parent;
63
+ }
64
+ }
32
65
  function parseGithubPathSpec(pathSpec, input, refOverride) {
33
66
  const segments = pathSpec
34
67
  .split("/")
@@ -916,6 +949,7 @@ export const _testOnlyInstallSources = {
916
949
  resolveNpmSourceDirectoryWithRunner,
917
950
  resolveNpmSourceDirectory,
918
951
  resolveNpmPackSpec,
952
+ findInstalledNpmPackageCandidate,
919
953
  resolvePackageExtensionDirectory,
920
954
  runtimeDependencyInstallSpecs,
921
955
  hasHostedPmCliDependency,
@@ -925,4 +959,4 @@ export const _testOnlyInstallSources = {
925
959
  runNpmCommand,
926
960
  };
927
961
  //# sourceMappingURL=install-sources.js.map
928
- //# debugId=0c87e77d-e7c5-5f0c-aad6-b047e33ccb25
962
+ //# debugId=8994c8e2-8e3a-5e00-a3ca-7bd553c045d7
@@ -0,0 +1,114 @@
1
+ import type { RegisteredExtensionSchemaMigrationDefinition } from "../../core/extensions/extension-types.js";
2
+ import type { ExtensionCommandResult, ExtensionScope } from "../extension.js";
3
+ /** Durable lifecycle state of one extension migration in one workspace. */
4
+ export type ExtensionMigrationOutcomeStatus = "applied" | "failed";
5
+ /** One durable extension-migration outcome. */
6
+ export interface ExtensionMigrationStateEntry {
7
+ /** Stable layer/name/id identity. */
8
+ key: string;
9
+ /** Extension installation layer. */
10
+ layer: "global" | "project";
11
+ /** Owning extension name. */
12
+ extension: string;
13
+ /** Migration identifier declared by the extension. */
14
+ id: string;
15
+ /** Last durable outcome. */
16
+ status: ExtensionMigrationOutcomeStatus;
17
+ /** ISO timestamp for the last attempt. */
18
+ attempted_at: string;
19
+ /** Failure text retained only for failed outcomes. */
20
+ error?: string;
21
+ }
22
+ /** Versioned workspace state for extension migrations. */
23
+ export interface ExtensionMigrationState {
24
+ /** Storage schema version. */
25
+ version: 1;
26
+ /** Last state change timestamp. */
27
+ updated_at: string;
28
+ /** Deterministically sorted outcomes. */
29
+ entries: ExtensionMigrationStateEntry[];
30
+ }
31
+ /** Planned or executed row returned for one registered migration. */
32
+ export interface ExtensionMigrationReceipt {
33
+ /** Stable layer/name/id identity. */
34
+ key: string;
35
+ /** Extension installation layer. */
36
+ layer: "global" | "project";
37
+ /** Owning extension name. */
38
+ extension: string;
39
+ /** Migration identifier. */
40
+ id: string;
41
+ /** State observed before this invocation. */
42
+ before: "pending" | ExtensionMigrationOutcomeStatus;
43
+ /** Invocation outcome. */
44
+ outcome: "pending" | "applied" | "skipped" | "failed";
45
+ /** Failure text for failed execution. */
46
+ error?: string;
47
+ }
48
+ /** Structured plan/application envelope for extension migrations. */
49
+ export interface ExtensionMigrationRunResult {
50
+ /** Whether the invocation executed no failing migration. */
51
+ ok: boolean;
52
+ /** Whether execution was suppressed. */
53
+ dry_run: boolean;
54
+ /** Durable state path. */
55
+ state_path: string;
56
+ /** Total registered migrations in scope. */
57
+ total: number;
58
+ /** Pending rows in the returned receipt. */
59
+ pending_count: number;
60
+ /** Applied rows in the returned receipt. */
61
+ applied_count: number;
62
+ /** Already-applied rows skipped idempotently. */
63
+ skipped_count: number;
64
+ /** Failed rows in the returned receipt. */
65
+ failed_count: number;
66
+ /** Deterministically ordered per-migration receipts. */
67
+ migrations: ExtensionMigrationReceipt[];
68
+ }
69
+ /** Options for planning or applying active extension migrations. */
70
+ export interface RunExtensionMigrationsOptions {
71
+ /** Tracker root that owns durable migration state. */
72
+ pmRoot: string;
73
+ /** Active runtime registrations. */
74
+ migrations: RegisteredExtensionSchemaMigrationDefinition[];
75
+ /** Audit author written to workspace history. */
76
+ author: string;
77
+ /** Report pending work without invoking extension code. */
78
+ dryRun?: boolean;
79
+ /** Limit execution and receipts to one installation layer. */
80
+ scope?: "global" | "project";
81
+ }
82
+ /** Minimal lifecycle context required by the migration action dispatcher. */
83
+ export interface ExtensionMigrationActionContext {
84
+ /** Selected package scope. */
85
+ scope: ExtensionScope;
86
+ /** Tracker and settings roots for the invocation. */
87
+ resolvedRoots: {
88
+ pm_root: string;
89
+ settings_root: string;
90
+ };
91
+ /** Mutable warning collection shared with the lifecycle result. */
92
+ warnings: string[];
93
+ /** Migration-specific command options. */
94
+ options: {
95
+ dryRun?: boolean;
96
+ };
97
+ /** Relevant global runtime options. */
98
+ global: {
99
+ noExtensions?: boolean;
100
+ author?: string;
101
+ };
102
+ /** Construct the standard extension lifecycle result envelope. */
103
+ withResult: (details: Record<string, unknown>, ok?: boolean) => ExtensionCommandResult;
104
+ }
105
+ /** Return the durable workspace path for extension migration state. */
106
+ export declare function resolveExtensionMigrationStatePath(pmRoot: string): string;
107
+ /** Read durable extension migration outcomes, degrading absent state to empty. */
108
+ export declare function readExtensionMigrationState(pmRoot: string): Promise<ExtensionMigrationState>;
109
+ /** Overlay durable outcomes onto freshly activated migration definitions. */
110
+ export declare function applyStoredExtensionMigrationState(pmRoot: string, migrations: RegisteredExtensionSchemaMigrationDefinition[]): Promise<ExtensionMigrationState>;
111
+ /** Plan or apply active extension migrations with durable idempotency receipts. */
112
+ export declare function runExtensionMigrations(options: RunExtensionMigrationsOptions): Promise<ExtensionMigrationRunResult>;
113
+ /** Load active registrations and execute the extension lifecycle migrate action. */
114
+ export declare function runExtensionMigrateAction(context: ExtensionMigrationActionContext): Promise<ExtensionCommandResult>;
@@ -0,0 +1,175 @@
1
+ /**
2
+ * @module sdk/extension/migrations
3
+ *
4
+ * Provides durable planning and execution for extension-owned schema migrations.
5
+ */
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]="56290db9-933c-590d-8b9f-df62ff45e515")}catch(e){}}();
8
+ import fs from "node:fs/promises";
9
+ import path from "node:path";
10
+ import { pathExists } from "../../core/fs/fs-utils.js";
11
+ import { activateExtensions, loadExtensions } from "../../core/extensions/index.js";
12
+ import { writeWorkspaceJsonWithHistory } from "../../core/history/workspace-history.js";
13
+ import { readSettings } from "../../core/store/settings.js";
14
+ /** Return the durable workspace path for extension migration state. */
15
+ export function resolveExtensionMigrationStatePath(pmRoot) {
16
+ return path.join(pmRoot, "extension-migrations.json");
17
+ }
18
+ function migrationId(migration, index) {
19
+ const id = migration.definition.id;
20
+ return typeof id === "string" && id.trim().length > 0
21
+ ? id.trim()
22
+ : `migration-${String(index + 1).padStart(3, "0")}`;
23
+ }
24
+ function migrationKey(migration, id) {
25
+ return `${migration.layer}:${migration.name}:${id}`;
26
+ }
27
+ /** Read durable extension migration outcomes, degrading absent state to empty. */
28
+ export async function readExtensionMigrationState(pmRoot) {
29
+ const statePath = resolveExtensionMigrationStatePath(pmRoot);
30
+ if (!(await pathExists(statePath))) {
31
+ return { version: 1, updated_at: "", entries: [] };
32
+ }
33
+ const parsed = JSON.parse(await fs.readFile(statePath, "utf8"));
34
+ return {
35
+ version: 1,
36
+ updated_at: typeof parsed.updated_at === "string" ? parsed.updated_at : "",
37
+ entries: Array.isArray(parsed.entries)
38
+ ? parsed.entries.filter((entry) => typeof entry?.key === "string" &&
39
+ (entry.status === "applied" || entry.status === "failed"))
40
+ : [],
41
+ };
42
+ }
43
+ /** Overlay durable outcomes onto freshly activated migration definitions. */
44
+ export async function applyStoredExtensionMigrationState(pmRoot, migrations) {
45
+ const state = await readExtensionMigrationState(pmRoot);
46
+ const byKey = new Map(state.entries.map((entry) => [entry.key, entry]));
47
+ migrations.forEach((migration, index) => {
48
+ const id = migrationId(migration, index);
49
+ const entry = byKey.get(migrationKey(migration, id));
50
+ if (!entry)
51
+ return;
52
+ migration.definition.status = entry.status;
53
+ if (entry.status === "failed") {
54
+ migration.definition.reason = entry.error;
55
+ }
56
+ else {
57
+ delete migration.definition.reason;
58
+ delete migration.definition.error;
59
+ delete migration.definition.message;
60
+ }
61
+ });
62
+ return state;
63
+ }
64
+ /** Plan or apply active extension migrations with durable idempotency receipts. */
65
+ export async function runExtensionMigrations(options) {
66
+ const state = await applyStoredExtensionMigrationState(options.pmRoot, options.migrations);
67
+ const stateByKey = new Map(state.entries.map((entry) => [entry.key, entry]));
68
+ const receipts = [];
69
+ let changed = false;
70
+ const scopedMigrations = options.migrations
71
+ .map((migration, index) => ({ migration, index }))
72
+ .filter(({ migration }) => options.scope === undefined || migration.layer === options.scope);
73
+ for (const { migration, index } of scopedMigrations) {
74
+ const id = migrationId(migration, index);
75
+ const key = migrationKey(migration, id);
76
+ const stored = stateByKey.get(key);
77
+ const declaredStatus = String(migration.definition.status ?? "pending").toLowerCase();
78
+ const before = stored?.status ?? (declaredStatus === "applied" || declaredStatus === "failed" ? declaredStatus : "pending");
79
+ if (before === "applied") {
80
+ receipts.push({ key, layer: migration.layer, extension: migration.name, id, before, outcome: "skipped" });
81
+ continue;
82
+ }
83
+ if (options.dryRun === true) {
84
+ receipts.push({ key, layer: migration.layer, extension: migration.name, id, before, outcome: "pending" });
85
+ continue;
86
+ }
87
+ const run = migration.runtime_definition?.run ?? migration.definition.run;
88
+ if (typeof run !== "function") {
89
+ receipts.push({ key, layer: migration.layer, extension: migration.name, id, before, outcome: "pending" });
90
+ continue;
91
+ }
92
+ const attemptedAt = new Date().toISOString();
93
+ try {
94
+ await Promise.resolve(run({ id, command: "migration", layer: migration.layer, extension: migration.name, pm_root: options.pmRoot, status: before }));
95
+ const entry = { key, layer: migration.layer, extension: migration.name, id, status: "applied", attempted_at: attemptedAt };
96
+ stateByKey.set(key, entry);
97
+ migration.definition.status = "applied";
98
+ delete migration.definition.reason;
99
+ delete migration.definition.error;
100
+ delete migration.definition.message;
101
+ receipts.push({ key, layer: migration.layer, extension: migration.name, id, before, outcome: "applied" });
102
+ changed = true;
103
+ }
104
+ catch (error) {
105
+ const message = error instanceof Error ? error.message : String(error);
106
+ const entry = { key, layer: migration.layer, extension: migration.name, id, status: "failed", attempted_at: attemptedAt, error: message };
107
+ stateByKey.set(key, entry);
108
+ migration.definition.status = "failed";
109
+ migration.definition.reason = message;
110
+ receipts.push({ key, layer: migration.layer, extension: migration.name, id, before, outcome: "failed", error: message });
111
+ changed = true;
112
+ }
113
+ }
114
+ if (changed) {
115
+ const settings = await readSettings(options.pmRoot);
116
+ const nextState = {
117
+ version: 1,
118
+ updated_at: new Date().toISOString(),
119
+ entries: [...stateByKey.values()].sort((left, right) => left.key.localeCompare(right.key)),
120
+ };
121
+ await writeWorkspaceJsonWithHistory({
122
+ pmRoot: options.pmRoot,
123
+ filePath: resolveExtensionMigrationStatePath(options.pmRoot),
124
+ raw: `${JSON.stringify(nextState, null, 2)}\n`,
125
+ op: "extension_migrations_apply",
126
+ author: options.author,
127
+ lockTtlSeconds: settings.locks.ttl_seconds,
128
+ lockWaitMs: settings.locks.wait_ms,
129
+ });
130
+ }
131
+ const pendingCount = receipts.filter((receipt) => receipt.outcome === "pending").length;
132
+ const appliedCount = receipts.filter((receipt) => receipt.outcome === "applied").length;
133
+ const skippedCount = receipts.filter((receipt) => receipt.outcome === "skipped").length;
134
+ const failedCount = receipts.filter((receipt) => receipt.outcome === "failed").length;
135
+ return {
136
+ ok: failedCount === 0,
137
+ dry_run: options.dryRun === true,
138
+ state_path: resolveExtensionMigrationStatePath(options.pmRoot),
139
+ total: receipts.length,
140
+ pending_count: pendingCount,
141
+ applied_count: appliedCount,
142
+ skipped_count: skippedCount,
143
+ failed_count: failedCount,
144
+ migrations: receipts,
145
+ };
146
+ }
147
+ /** Load active registrations and execute the extension lifecycle migrate action. */
148
+ export async function runExtensionMigrateAction(context) {
149
+ const settings = await readSettings(context.resolvedRoots.settings_root);
150
+ const loaded = await loadExtensions({
151
+ pmRoot: context.resolvedRoots.pm_root,
152
+ settings,
153
+ cwd: process.cwd(),
154
+ noExtensions: context.global.noExtensions === true,
155
+ });
156
+ const activated = await activateExtensions(loaded);
157
+ context.warnings.push(...loaded.warnings, ...activated.warnings);
158
+ const migration = await runExtensionMigrations({
159
+ pmRoot: context.resolvedRoots.pm_root,
160
+ migrations: activated.registrations.migrations,
161
+ author: typeof context.global.author === "string" &&
162
+ context.global.author.trim().length > 0
163
+ ? context.global.author.trim()
164
+ : "pm-extension-migration",
165
+ dryRun: context.options.dryRun === true,
166
+ ...(context.scope === "global" ? { scope: "global" } : {}),
167
+ });
168
+ return context.withResult({
169
+ migration,
170
+ load_failure_count: loaded.failed.length,
171
+ activation_failure_count: activated.failed.length,
172
+ }, migration.ok);
173
+ }
174
+ //# sourceMappingURL=migrations.js.map
175
+ //# debugId=56290db9-933c-590d-8b9f-df62ff45e515