@unbrained/pm-cli 2026.11.22 → 2026.11.23

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 (892) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/after-command-context-usage.js +1 -1
  3. package/dist/cli/argv-utils.js +1 -1
  4. package/dist/cli/bootstrap-args.js +1 -1
  5. package/dist/cli/bundle-integrity.js +2 -2
  6. package/dist/cli/command-namespaces.js +1 -1
  7. package/dist/cli/commander-usage.js +11 -11
  8. package/dist/cli/commands/annotations/comments.js +1 -1
  9. package/dist/cli/commands/annotations/docs.js +1 -1
  10. package/dist/cli/commands/annotations/files.js +1 -1
  11. package/dist/cli/commands/annotations/learnings.js +1 -1
  12. package/dist/cli/commands/annotations/notes.js +1 -1
  13. package/dist/cli/commands/extension/describe.js +1 -1
  14. package/dist/cli/commands/extension/extension.js +1 -1
  15. package/dist/cli/commands/extension/scaffold.js +1 -1
  16. package/dist/cli/commands/extension/shared.js +1 -1
  17. package/dist/cli/commands/governance/gc.js +1 -1
  18. package/dist/cli/commands/governance/health.js +1 -1
  19. package/dist/cli/commands/governance/telemetry.js +1 -1
  20. package/dist/cli/commands/governance/validate.js +1 -1
  21. package/dist/cli/commands/history/activity.js +1 -1
  22. package/dist/cli/commands/history/history-compact.js +1 -1
  23. package/dist/cli/commands/history/history-redact.js +1 -1
  24. package/dist/cli/commands/history/history-repair.js +1 -1
  25. package/dist/cli/commands/history/history.js +1 -1
  26. package/dist/cli/commands/history/restore.js +1 -1
  27. package/dist/cli/commands/lifecycle/append.js +1 -1
  28. package/dist/cli/commands/lifecycle/claim.js +1 -1
  29. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  30. package/dist/cli/commands/lifecycle/close.js +1 -1
  31. package/dist/cli/commands/lifecycle/copy.js +1 -1
  32. package/dist/cli/commands/lifecycle/create.js +1 -1
  33. package/dist/cli/commands/lifecycle/delete.js +1 -1
  34. package/dist/cli/commands/lifecycle/focus.js +1 -1
  35. package/dist/cli/commands/lifecycle/plan.js +1 -1
  36. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  37. package/dist/cli/commands/lifecycle/update.js +1 -1
  38. package/dist/cli/commands/query/aggregate.js +1 -1
  39. package/dist/cli/commands/query/context.js +1 -1
  40. package/dist/cli/commands/query/deps.js +1 -1
  41. package/dist/cli/commands/query/duplicates.js +1 -1
  42. package/dist/cli/commands/query/eval.js +1 -1
  43. package/dist/cli/commands/query/get.js +1 -1
  44. package/dist/cli/commands/query/graph.js +1 -1
  45. package/dist/cli/commands/query/list.js +1 -1
  46. package/dist/cli/commands/query/next.js +1 -1
  47. package/dist/cli/commands/query/search.js +1 -1
  48. package/dist/cli/commands/query/stats.js +1 -1
  49. package/dist/cli/commands/test/test-all.js +1 -1
  50. package/dist/cli/commands/test/test-runs.js +1 -1
  51. package/dist/cli/commands/test/test.js +1 -1
  52. package/dist/cli/commands/workspace/config.js +1 -1
  53. package/dist/cli/commands/workspace/contracts.js +1 -1
  54. package/dist/cli/commands/workspace/init.js +1 -1
  55. package/dist/cli/commands/workspace/merge.js +1 -1
  56. package/dist/cli/commands/workspace/profile.js +1 -1
  57. package/dist/cli/commands/workspace/schema.js +1 -1
  58. package/dist/cli/commands/workspace/upgrade.js +1 -1
  59. package/dist/cli/context-intent-invocation.js +1 -1
  60. package/dist/cli/description-stdin.js +1 -1
  61. package/dist/cli/error-guidance.js +5 -5
  62. package/dist/cli/expected-revisions.js +1 -1
  63. package/dist/cli/extension-command-help.js +6 -6
  64. package/dist/cli/extension-recovery.js +1 -1
  65. package/dist/cli/help-content.js +5 -5
  66. package/dist/cli/help-json-payload.js +7 -7
  67. package/dist/cli/invocation-profile.js +2 -2
  68. package/dist/cli/main.js +5 -5
  69. package/dist/cli/migration-gates.js +1 -1
  70. package/dist/cli/option-values.js +1 -1
  71. package/dist/cli/preflight-warnings.js +3 -3
  72. package/dist/cli/public.js +1 -1
  73. package/dist/cli/register-annotations.js +1 -1
  74. package/dist/cli/register-assurance.js +1 -1
  75. package/dist/cli/register-files-lookup.js +1 -1
  76. package/dist/cli/register-history-activity.js +1 -1
  77. package/dist/cli/register-history-author.js +1 -1
  78. package/dist/cli/register-history-maintenance.js +2 -2
  79. package/dist/cli/register-list-query.js +10 -10
  80. package/dist/cli/register-mutation-options.js +0 -1
  81. package/dist/cli/register-mutation.js +6 -6
  82. package/dist/cli/register-operations.js +1 -1
  83. package/dist/cli/register-setup.js +1 -1
  84. package/dist/cli/register-structured-mutation.js +1 -1
  85. package/dist/cli/registration-helpers.js +1 -1
  86. package/dist/cli/runtime/activation.js +1 -1
  87. package/dist/cli/runtime/annotation-option-retry.js +1 -1
  88. package/dist/cli/runtime/close-fields-retry.js +1 -1
  89. package/dist/cli/runtime/field-route-retry.js +1 -1
  90. package/dist/cli/runtime/invocation-options.js +1 -1
  91. package/dist/cli/runtime/invocation-rewrites.js +1 -1
  92. package/dist/cli/runtime/projection-retry.js +1 -1
  93. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  94. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  95. package/dist/cli/runtime/selection.js +1 -1
  96. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  97. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  98. package/dist/cli/schema/registration.js +15 -15
  99. package/dist/cli/schema-registration-helpers.js +1 -1
  100. package/dist/cli/search-refresh.js +1 -1
  101. package/dist/cli/stats-analytics-json.js +1 -1
  102. package/dist/cli/telemetry-flush.js +1 -1
  103. package/dist/cli-bundle/bundle-manifest.json +1 -1
  104. package/dist/cli-bundle/chunks/chunk-2UQU7HRR.js +9 -0
  105. package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
  106. package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +3 -0
  107. package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
  108. package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +2 -0
  109. package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
  110. package/dist/cli-bundle/chunks/{chunk-B76TFRO2.js → chunk-AEOHUSUI.js} +101 -101
  111. package/dist/cli-bundle/chunks/chunk-BSRIVYTM.js +8 -0
  112. package/dist/cli-bundle/chunks/chunk-CFWLQFJM.js +71 -0
  113. package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
  114. package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +31 -0
  115. package/dist/cli-bundle/chunks/chunk-F2Z6XLZB.js +3 -0
  116. package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +2 -0
  117. package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +2 -0
  118. package/dist/cli-bundle/chunks/chunk-H7JEXRIN.js +6 -0
  119. package/dist/cli-bundle/chunks/chunk-J2PDAVBC.js +2 -0
  120. package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +2 -0
  121. package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +33 -0
  122. package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +115 -0
  123. package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +2 -0
  124. package/dist/cli-bundle/chunks/chunk-O7JHS64G.js +3 -0
  125. package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +2 -0
  126. package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +2 -0
  127. package/dist/cli-bundle/chunks/chunk-OPJF254V.js +9 -0
  128. package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
  129. package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +2 -0
  130. package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +2 -0
  131. package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
  132. package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +125 -0
  133. package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
  134. package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +8 -0
  135. package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
  136. package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
  137. package/dist/cli-bundle/chunks/{item-revision-4QBMZXKX.js → item-revision-FMD4KWBB.js} +2 -2
  138. package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +2 -0
  139. package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +2 -0
  140. package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +2 -0
  141. package/dist/cli-bundle/chunks/{register-list-query-RR5KACJ3.js → register-list-query-L4IBU64P.js} +11 -11
  142. package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +21 -0
  143. package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +2 -0
  144. package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +2 -0
  145. package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
  146. package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +2 -0
  147. package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +6 -0
  148. package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +2 -0
  149. package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
  150. package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
  151. package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
  152. package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
  153. package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +8 -0
  154. package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +2 -0
  155. package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
  156. package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +2 -0
  157. package/dist/cli-bundle/focused-chunks/chunk-IROZDIDX.js +3 -0
  158. package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +2 -0
  159. package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
  160. package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +26 -0
  161. package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +13 -0
  162. package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +2 -0
  163. package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +91 -0
  164. package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +2 -0
  165. package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +2 -0
  166. package/dist/cli-bundle/focused-chunks/chunk-QQIIMMFU.js +2 -0
  167. package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
  168. package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +8 -0
  169. package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +27 -0
  170. package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
  171. package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +44 -0
  172. package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +2 -0
  173. package/dist/cli-bundle/focused-chunks/chunk-Y2ESLKCF.js +8 -0
  174. package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +2 -0
  175. package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +102 -0
  176. package/dist/cli-bundle/focused-chunks/chunk-ZHWPCVQL.js +78 -0
  177. package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
  178. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
  179. package/dist/cli-bundle/focused-chunks/{item-revision-2O6MLPEX.js → item-revision-YDACCDVY.js} +2 -2
  180. package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +2 -0
  181. package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +2 -0
  182. package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +2 -0
  183. package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
  184. package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +2 -0
  185. package/dist/cli-bundle/main.js +27 -27
  186. package/dist/cli-bundle/sdk-authoring.js +1 -1
  187. package/dist/cli-bundle/sdk-contracts.js +5 -5
  188. package/dist/cli-bundle/sdk-core.js +1 -1
  189. package/dist/cli-bundle/sdk-governance.js +1 -1
  190. package/dist/cli-bundle/sdk-graph.js +1 -1
  191. package/dist/cli-bundle/sdk-merge.js +66 -66
  192. package/dist/cli-bundle/sdk-query.js +1 -1
  193. package/dist/cli-bundle/sdk-runtime.js +1 -1
  194. package/dist/cli-bundle/sdk-testing.js +1 -1
  195. package/dist/cli-bundle/sdk.js +12 -12
  196. package/dist/cli.js +1 -1
  197. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  198. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  199. package/dist/core/checkpoint/mutation-context.js +1 -1
  200. package/dist/core/config/nested-settings.js +1 -1
  201. package/dist/core/config/positional-value.js +1 -1
  202. package/dist/core/diagnostics/remediation.js +1 -1
  203. package/dist/core/extensions/activation-summary-markdown.js +2 -2
  204. package/dist/core/extensions/activation-summary.js +1 -1
  205. package/dist/core/extensions/activation-transaction.js +1 -1
  206. package/dist/core/extensions/capability-usage.js +1 -1
  207. package/dist/core/extensions/command-hook-context.js +1 -1
  208. package/dist/core/extensions/command-metadata-contract.js +1 -1
  209. package/dist/core/extensions/command-visibility-tier.js +1 -1
  210. package/dist/core/extensions/contribution-inventory.js +1 -1
  211. package/dist/core/extensions/exporter-output-contract.js +1 -1
  212. package/dist/core/extensions/extension-candidate.js +1 -1
  213. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  214. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  215. package/dist/core/extensions/extension-policy.js +1 -1
  216. package/dist/core/extensions/extension-registries.js +1 -1
  217. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  218. package/dist/core/extensions/extension-types.js +1 -1
  219. package/dist/core/extensions/flag-definition-validation.js +1 -1
  220. package/dist/core/extensions/flag-value-types.js +1 -1
  221. package/dist/core/extensions/index.js +1 -1
  222. package/dist/core/extensions/item-field-types.js +1 -1
  223. package/dist/core/extensions/item-fields.js +1 -1
  224. package/dist/core/extensions/loader.js +1 -1
  225. package/dist/core/extensions/manifest-parser.js +1 -1
  226. package/dist/core/extensions/manifest-schema.js +1 -1
  227. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  228. package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
  229. package/dist/core/extensions/mutation-actor.js +1 -1
  230. package/dist/core/extensions/preflight-ownership.js +1 -1
  231. package/dist/core/extensions/read-output-contract.js +1 -1
  232. package/dist/core/extensions/registration-contracts.js +1 -1
  233. package/dist/core/extensions/registration-validation.js +1 -1
  234. package/dist/core/extensions/registration-values.js +1 -1
  235. package/dist/core/extensions/reserved-host-flags.js +1 -1
  236. package/dist/core/extensions/runtime-registrations.js +1 -1
  237. package/dist/core/extensions/service-ownership.js +1 -1
  238. package/dist/core/extensions/version-compat.js +1 -1
  239. package/dist/core/extensions/version-diagnostics.js +1 -1
  240. package/dist/core/fs/atomic-create.js +1 -1
  241. package/dist/core/fs/file-glob.js +1 -1
  242. package/dist/core/fs/fs-utils.js +2 -2
  243. package/dist/core/fs/host-environment-errors.js +1 -1
  244. package/dist/core/fs/index.js +1 -1
  245. package/dist/core/fs/path-utils.js +1 -1
  246. package/dist/core/governance/content-fields.js +1 -1
  247. package/dist/core/governance/issue-codes.js +1 -1
  248. package/dist/core/governance/metadata-coverage.js +1 -1
  249. package/dist/core/history/bridge.js +1 -1
  250. package/dist/core/history/digest.js +1 -1
  251. package/dist/core/history/drift-cache.js +3 -3
  252. package/dist/core/history/drift-scan.js +1 -1
  253. package/dist/core/history/event-classification.js +1 -1
  254. package/dist/core/history/event-index.js +11 -11
  255. package/dist/core/history/history-compact-bulk.js +1 -1
  256. package/dist/core/history/history-diff.js +1 -1
  257. package/dist/core/history/history-rewrite.js +1 -1
  258. package/dist/core/history/history-storage-stats.js +1 -1
  259. package/dist/core/history/history-stream-policy.js +1 -1
  260. package/dist/core/history/history.js +2 -2
  261. package/dist/core/history/identity.js +1 -1
  262. package/dist/core/history/index.js +1 -1
  263. package/dist/core/history/operation-contract.js +1 -1
  264. package/dist/core/history/projection.js +1 -1
  265. package/dist/core/history/read.js +1 -1
  266. package/dist/core/history/replay.js +2 -2
  267. package/dist/core/history/stream-summary.js +2 -2
  268. package/dist/core/history/tombstone.js +1 -1
  269. package/dist/core/history/version-address.js +1 -1
  270. package/dist/core/history/workspace-history.js +2 -2
  271. package/dist/core/io/body-file.js +1 -1
  272. package/dist/core/io/bulk-ids-input.js +2 -2
  273. package/dist/core/item/actionability.js +1 -1
  274. package/dist/core/item/deferred-fields.js +1 -1
  275. package/dist/core/item/dependency-reference.js +1 -1
  276. package/dist/core/item/id.js +1 -1
  277. package/dist/core/item/index.js +1 -1
  278. package/dist/core/item/item-format-version.js +1 -1
  279. package/dist/core/item/item-format.js +7 -7
  280. package/dist/core/item/item-record.js +1 -1
  281. package/dist/core/item/item-type-definition.js +1 -1
  282. package/dist/core/item/literal-mutation-input.js +1 -1
  283. package/dist/core/item/parent-reference-policy.js +1 -1
  284. package/dist/core/item/parse.js +8 -8
  285. package/dist/core/item/plan-lifecycle.js +1 -1
  286. package/dist/core/item/priority.js +1 -1
  287. package/dist/core/item/sprint-release-format.js +1 -1
  288. package/dist/core/item/status-filter.js +1 -1
  289. package/dist/core/item/status.js +1 -1
  290. package/dist/core/item/toon-decode.js +1 -1
  291. package/dist/core/item/type-registry.js +1 -1
  292. package/dist/core/item/type-synonyms.js +1 -1
  293. package/dist/core/lock/index.js +1 -1
  294. package/dist/core/lock/lock-confinement.js +1 -1
  295. package/dist/core/lock/lock-gc.js +1 -1
  296. package/dist/core/lock/lock-owner.js +1 -1
  297. package/dist/core/lock/lock.js +4 -4
  298. package/dist/core/output/linked-test-projection.js +5 -5
  299. package/dist/core/output/mutation-projection.js +1 -1
  300. package/dist/core/output/output-control.js +1 -1
  301. package/dist/core/output/output.js +19 -19
  302. package/dist/core/output/query-summary.js +1 -1
  303. package/dist/core/output/tabular.js +3 -3
  304. package/dist/core/packages/manifest.js +1 -1
  305. package/dist/core/packages/root.js +1 -1
  306. package/dist/core/policy/workflow-policy-schema.js +1 -1
  307. package/dist/core/policy/workflow-policy-store.js +1 -1
  308. package/dist/core/policy/workflow-policy.js +1 -1
  309. package/dist/core/profile/profile-describe.js +1 -1
  310. package/dist/core/profile/profile-lint.d.ts +1 -1
  311. package/dist/core/profile/profile-lint.js +1 -1
  312. package/dist/core/profile/profile-plan.js +1 -1
  313. package/dist/core/profile/profile-presets.js +4 -4
  314. package/dist/core/reproducibility/context.js +1 -1
  315. package/dist/core/schema/fields-file.js +2 -2
  316. package/dist/core/schema/item-types-file.js +2 -2
  317. package/dist/core/schema/runtime-field-filters.js +1 -1
  318. package/dist/core/schema/runtime-field-values.js +1 -1
  319. package/dist/core/schema/runtime-schema.js +2 -2
  320. package/dist/core/schema/status-defs-file.js +2 -2
  321. package/dist/core/schema/status-token.js +1 -1
  322. package/dist/core/schema/type-inference.js +1 -1
  323. package/dist/core/schema/type-presets.js +1 -1
  324. package/dist/core/schema/type-workflows.js +1 -1
  325. package/dist/core/search/background-refresh.js +2 -2
  326. package/dist/core/search/bm25.js +1 -1
  327. package/dist/core/search/cache.js +2 -2
  328. package/dist/core/search/corpus.js +1 -1
  329. package/dist/core/search/embedding-batches.js +1 -1
  330. package/dist/core/search/eval-thresholds.js +1 -1
  331. package/dist/core/search/eval.js +1 -1
  332. package/dist/core/search/http-client.js +1 -1
  333. package/dist/core/search/providers.js +1 -1
  334. package/dist/core/search/relevance.js +1 -1
  335. package/dist/core/search/semantic-defaults.js +1 -1
  336. package/dist/core/search/staleness.js +1 -1
  337. package/dist/core/search/vector-stores.js +2 -2
  338. package/dist/core/search/vectorization-metadata.js +1 -1
  339. package/dist/core/sentry/helpers.js +1 -1
  340. package/dist/core/sentry/instrument.js +1 -1
  341. package/dist/core/sentry/sensitive-assignments.js +1 -1
  342. package/dist/core/session/session-state.js +1 -1
  343. package/dist/core/shared/agent-session-context.js +1 -1
  344. package/dist/core/shared/author.js +5 -5
  345. package/dist/core/shared/command-line.js +1 -1
  346. package/dist/core/shared/command-types.js +0 -1
  347. package/dist/core/shared/conflict-markers.js +1 -1
  348. package/dist/core/shared/constants.js +1 -1
  349. package/dist/core/shared/error-details.js +1 -1
  350. package/dist/core/shared/errors.js +1 -1
  351. package/dist/core/shared/html-entity-decode.js +1 -1
  352. package/dist/core/shared/index.js +1 -1
  353. package/dist/core/shared/item-metadata-contract.js +1 -1
  354. package/dist/core/shared/lazy-module.js +1 -1
  355. package/dist/core/shared/levenshtein.js +1 -1
  356. package/dist/core/shared/memo.js +1 -1
  357. package/dist/core/shared/numeric-parsers.js +1 -1
  358. package/dist/core/shared/option-alias-visibility.js +1 -1
  359. package/dist/core/shared/output-unicode.js +1 -1
  360. package/dist/core/shared/primitives.js +1 -1
  361. package/dist/core/shared/process-tree.js +2 -2
  362. package/dist/core/shared/secret-rules.js +5 -5
  363. package/dist/core/shared/serial-queue.js +1 -1
  364. package/dist/core/shared/serialization.js +1 -1
  365. package/dist/core/shared/split-comma-list.js +1 -1
  366. package/dist/core/shared/text-normalization.js +1 -1
  367. package/dist/core/shared/time.js +2 -2
  368. package/dist/core/shared/url-credentials.js +1 -1
  369. package/dist/core/store/index.js +1 -1
  370. package/dist/core/store/item-format-migration.js +1 -1
  371. package/dist/core/store/item-metadata-cache.js +1 -1
  372. package/dist/core/store/item-metadata-query-index.js +11 -11
  373. package/dist/core/store/item-metadata-read-work.js +1 -1
  374. package/dist/core/store/item-mutation-precondition.js +1 -1
  375. package/dist/core/store/item-store.js +1 -1
  376. package/dist/core/store/paths.js +1 -1
  377. package/dist/core/store/settings-concurrency.js +1 -1
  378. package/dist/core/store/settings-read-cache.js +1 -1
  379. package/dist/core/store/settings-sections.js +2 -2
  380. package/dist/core/store/settings-validator.js +1 -1
  381. package/dist/core/store/settings.d.ts +3 -1
  382. package/dist/core/store/settings.js +6 -6
  383. package/dist/core/store/sqlite-runtime.js +1 -1
  384. package/dist/core/store/tracker-preflight.js +1 -1
  385. package/dist/core/store/transaction-coordinator-scope.js +1 -1
  386. package/dist/core/telemetry/consent.js +3 -3
  387. package/dist/core/telemetry/observability.js +1 -1
  388. package/dist/core/telemetry/policy.js +1 -1
  389. package/dist/core/telemetry/read-sampling.js +2 -2
  390. package/dist/core/telemetry/runtime.js +9 -9
  391. package/dist/core/test/background-runs.js +4 -4
  392. package/dist/core/test/item-test-run-tracking.js +1 -1
  393. package/dist/core/test/run-selectors.js +1 -1
  394. package/dist/core/validate/estimate-defaults.js +1 -1
  395. package/dist/core/validate/fix-planning.js +1 -1
  396. package/dist/core/validate/linked-artifact-reference.js +1 -1
  397. package/dist/core/validate/missing-by-type.js +1 -1
  398. package/dist/core/validate/missing-link-owners.js +1 -1
  399. package/dist/core/validate/stale-file-classification.js +1 -1
  400. package/dist/mcp/http-server.js +5 -5
  401. package/dist/mcp/legacy-adapter.js +1 -1
  402. package/dist/mcp/runtime-capabilities.js +1 -1
  403. package/dist/mcp/server.js +4 -4
  404. package/dist/mcp/tool-definitions.js +1 -1
  405. package/dist/sdk/actionability.js +1 -1
  406. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  407. package/dist/sdk/agent/command-recovery.js +1 -1
  408. package/dist/sdk/agent/command-suggestions.js +1 -1
  409. package/dist/sdk/agent/create-option-policy.js +1 -1
  410. package/dist/sdk/agent/identity-config.js +1 -1
  411. package/dist/sdk/agent/item-addressing.js +1 -1
  412. package/dist/sdk/agent/linked-resource-recovery.js +1 -1
  413. package/dist/sdk/agent/refusal-closure-census.js +2 -2
  414. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  415. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  416. package/dist/sdk/agent-capability-contracts.js +3 -3
  417. package/dist/sdk/agent-session-context.js +1 -1
  418. package/dist/sdk/annotations.js +1 -1
  419. package/dist/sdk/author-attribution.js +1 -1
  420. package/dist/sdk/cli-bootstrap.js +1 -1
  421. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
  422. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  423. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  424. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  425. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  426. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  427. package/dist/sdk/cli-contracts/completeness.js +1 -1
  428. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  429. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  430. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
  431. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  432. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  433. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  434. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  435. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  436. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  437. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  438. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  439. package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
  440. package/dist/sdk/cli-contracts.js +1 -1
  441. package/dist/sdk/cli-program.js +1 -1
  442. package/dist/sdk/command-line.js +1 -1
  443. package/dist/sdk/comments.js +1 -1
  444. package/dist/sdk/compile-cache.js +1 -1
  445. package/dist/sdk/completion/bash.js +2 -2
  446. package/dist/sdk/completion/fish.js +72 -72
  447. package/dist/sdk/completion/shared.js +1 -1
  448. package/dist/sdk/completion/zsh.js +75 -75
  449. package/dist/sdk/completion.js +1 -1
  450. package/dist/sdk/config.js +1 -1
  451. package/dist/sdk/context/recency.js +1 -1
  452. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  453. package/dist/sdk/context/usage-egress.js +1 -1
  454. package/dist/sdk/context/usage-ledger.js +6 -6
  455. package/dist/sdk/context-intent-contracts.js +1 -1
  456. package/dist/sdk/context-intent-runtime.js +1 -1
  457. package/dist/sdk/context-packing.js +1 -1
  458. package/dist/sdk/context-relevance.js +1 -1
  459. package/dist/sdk/context-signal-store.js +2 -2
  460. package/dist/sdk/context-usage.js +1 -1
  461. package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
  462. package/dist/sdk/dependencies.js +1 -1
  463. package/dist/sdk/dependency-flag-validation.js +1 -1
  464. package/dist/sdk/dependency-provenance.js +1 -1
  465. package/dist/sdk/docs.js +1 -1
  466. package/dist/sdk/duplicates.js +1 -1
  467. package/dist/sdk/environment/host-environment-errors.js +1 -1
  468. package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
  469. package/dist/sdk/environment/source-context.js +1 -1
  470. package/dist/sdk/environment/tracker-preflight.js +1 -1
  471. package/dist/sdk/error-code-catalog.js +1 -1
  472. package/dist/sdk/error-runtime.js +1 -1
  473. package/dist/sdk/errors.js +1 -1
  474. package/dist/sdk/eval.js +1 -1
  475. package/dist/sdk/extension/author-manifest.js +1 -1
  476. package/dist/sdk/extension/bundled-catalog.js +1 -1
  477. package/dist/sdk/extension/command-options.js +1 -1
  478. package/dist/sdk/extension/concurrency.js +1 -1
  479. package/dist/sdk/extension/copy-scope.js +1 -1
  480. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  481. package/dist/sdk/extension/describe.js +3 -3
  482. package/dist/sdk/extension/doctor.js +1 -1
  483. package/dist/sdk/extension/install-plan.js +1 -1
  484. package/dist/sdk/extension/install-receipts.js +1 -1
  485. package/dist/sdk/extension/install-runtime.js +3 -3
  486. package/dist/sdk/extension/install-snapshot.js +1 -1
  487. package/dist/sdk/extension/install-sources.js +5 -5
  488. package/dist/sdk/extension/managed-state.js +2 -2
  489. package/dist/sdk/extension/managed-update-status.js +1 -1
  490. package/dist/sdk/extension/migrations.js +2 -2
  491. package/dist/sdk/extension/native-command-options.js +1 -1
  492. package/dist/sdk/extension/output-ownership.js +1 -1
  493. package/dist/sdk/extension/runtime-summary.js +1 -1
  494. package/dist/sdk/extension/scaffold.js +11 -11
  495. package/dist/sdk/extension/shared.js +1 -1
  496. package/dist/sdk/extension/source-resolution.js +1 -1
  497. package/dist/sdk/extension/static-inventory.js +1 -1
  498. package/dist/sdk/extension/update-check.js +1 -1
  499. package/dist/sdk/extension-command-context.js +2 -2
  500. package/dist/sdk/extension-contracts.js +1 -1
  501. package/dist/sdk/extension.js +1 -1
  502. package/dist/sdk/files.js +1 -1
  503. package/dist/sdk/flag-invocation-contracts.js +1 -1
  504. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  505. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  506. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  507. package/dist/sdk/generated-error-code-catalog.js +1 -1
  508. package/dist/sdk/governance/assurance-action-contracts.js +0 -1
  509. package/dist/sdk/governance/assurance-action.js +1 -1
  510. package/dist/sdk/governance/assurance-limits.js +1 -1
  511. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  512. package/dist/sdk/governance/assurance-presets.js +1 -1
  513. package/dist/sdk/governance/assurance-runtime.js +1 -1
  514. package/dist/sdk/governance/assurance.js +4 -4
  515. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  516. package/dist/sdk/governance/closure-timestamps.js +1 -1
  517. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  518. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  519. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  520. package/dist/sdk/governance/defect-recurrence.js +2 -2
  521. package/dist/sdk/governance/extension-host-version.js +1 -1
  522. package/dist/sdk/governance/gc.js +1 -1
  523. package/dist/sdk/governance/health/history-drift-remedies.js +1 -1
  524. package/dist/sdk/governance/health/projection.js +1 -1
  525. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  526. package/dist/sdk/governance/health.js +2 -2
  527. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  528. package/dist/sdk/governance/in-progress-work-health.js +1 -1
  529. package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
  530. package/dist/sdk/governance/linked-file-report.js +1 -1
  531. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  532. package/dist/sdk/governance/provenance-health.js +4 -4
  533. package/dist/sdk/governance/reindex.js +5 -5
  534. package/dist/sdk/governance/stale-work.js +1 -1
  535. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  536. package/dist/sdk/governance/storage-integrity.js +1 -1
  537. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  538. package/dist/sdk/governance/upgrade.js +2 -2
  539. package/dist/sdk/governance/validate-deferred-fields.js +1 -1
  540. package/dist/sdk/governance/validate-history-drift.js +1 -1
  541. package/dist/sdk/governance/validate-item-reader.js +1 -1
  542. package/dist/sdk/governance/validate-normalization.js +1 -1
  543. package/dist/sdk/governance/validate.js +1 -1
  544. package/dist/sdk/governance/workflow-completeness.js +1 -1
  545. package/dist/sdk/governance/workflow-policy.js +3 -3
  546. package/dist/sdk/governance/workspace-position.js +2 -2
  547. package/dist/sdk/graph/analytics.js +1 -1
  548. package/dist/sdk/graph/assembly.js +1 -1
  549. package/dist/sdk/graph/cache.js +1 -1
  550. package/dist/sdk/graph/cardinality-integrity.js +1 -1
  551. package/dist/sdk/graph/centrality.js +1 -1
  552. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  553. package/dist/sdk/graph/durable-cache.js +1 -1
  554. package/dist/sdk/graph/governance-contracts.js +1 -1
  555. package/dist/sdk/graph/governance.js +1 -1
  556. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  557. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  558. package/dist/sdk/graph/mutation-advisory.js +1 -1
  559. package/dist/sdk/graph/query-contracts.js +1 -1
  560. package/dist/sdk/graph/remediation.js +1 -1
  561. package/dist/sdk/graph/run.js +1 -1
  562. package/dist/sdk/graph/scheduling.js +1 -1
  563. package/dist/sdk/graph/traversal.js +1 -1
  564. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  565. package/dist/sdk/guide-topics.js +1 -1
  566. package/dist/sdk/guide.js +7 -7
  567. package/dist/sdk/history/append-only-repair.js +4 -4
  568. package/dist/sdk/history/attestation-command.js +2 -2
  569. package/dist/sdk/history/attestation-contract.js +1 -1
  570. package/dist/sdk/history/attestation-scan.js +1 -1
  571. package/dist/sdk/history/attestation.js +1 -1
  572. package/dist/sdk/history/maintenance.js +1 -1
  573. package/dist/sdk/history/reanchor-refusal.js +1 -1
  574. package/dist/sdk/history/reseed.js +1 -1
  575. package/dist/sdk/history/salvage.js +5 -5
  576. package/dist/sdk/history/subject.js +1 -1
  577. package/dist/sdk/history-analytics.js +1 -1
  578. package/dist/sdk/history-compact.js +1 -1
  579. package/dist/sdk/history-mcp.js +1 -1
  580. package/dist/sdk/history-provenance.js +1 -1
  581. package/dist/sdk/history-read.js +1 -1
  582. package/dist/sdk/history-redact.js +1 -1
  583. package/dist/sdk/history-repair.js +1 -1
  584. package/dist/sdk/improvement-ledger-validation.js +1 -1
  585. package/dist/sdk/improvement-ledger.js +2 -2
  586. package/dist/sdk/init-agent-guidance.js +10 -10
  587. package/dist/sdk/init.js +14 -14
  588. package/dist/sdk/invocation-author.js +1 -1
  589. package/dist/sdk/item-children.js +1 -1
  590. package/dist/sdk/item-metadata-index.js +1 -1
  591. package/dist/sdk/item-schedule.js +1 -1
  592. package/dist/sdk/item-transaction.js +1 -1
  593. package/dist/sdk/learnings.js +1 -1
  594. package/dist/sdk/lifecycle/append.js +3 -3
  595. package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
  596. package/dist/sdk/lifecycle/claim.js +1 -1
  597. package/dist/sdk/lifecycle/cli-input.js +1 -1
  598. package/dist/sdk/lifecycle/close-many.js +1 -1
  599. package/dist/sdk/lifecycle/close.js +1 -1
  600. package/dist/sdk/lifecycle/copy.js +1 -1
  601. package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
  602. package/dist/sdk/lifecycle/core-item-fields.js +1 -1
  603. package/dist/sdk/lifecycle/create-deferrals.js +1 -1
  604. package/dist/sdk/lifecycle/create.js +1 -1
  605. package/dist/sdk/lifecycle/delete.js +1 -1
  606. package/dist/sdk/lifecycle/dependency-removal.js +1 -1
  607. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  608. package/dist/sdk/lifecycle/focus.js +1 -1
  609. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  610. package/dist/sdk/lifecycle/item-revision.js +1 -1
  611. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  612. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  613. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  614. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  615. package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
  616. package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
  617. package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
  618. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  619. package/dist/sdk/lifecycle/plan.js +1 -1
  620. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  621. package/dist/sdk/lifecycle/release-handoff.js +1 -1
  622. package/dist/sdk/lifecycle/reopen.js +1 -1
  623. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
  624. package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
  625. package/dist/sdk/lifecycle/restore.js +1 -1
  626. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  627. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  628. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  629. package/dist/sdk/lifecycle/task-composition.js +1 -1
  630. package/dist/sdk/lifecycle/update-many.js +1 -1
  631. package/dist/sdk/lifecycle/update.js +2 -2
  632. package/dist/sdk/lifecycle/workflow-transition.js +1 -1
  633. package/dist/sdk/lifecycle-completion.js +1 -1
  634. package/dist/sdk/lifecycle-policy.js +1 -1
  635. package/dist/sdk/linked-artifacts.js +2 -2
  636. package/dist/sdk/mcp/apps.js +5 -5
  637. package/dist/sdk/mcp/authorization.js +1 -1
  638. package/dist/sdk/mcp/discovery.js +1 -1
  639. package/dist/sdk/mcp/executable.js +4 -4
  640. package/dist/sdk/mcp/interactions.js +1 -1
  641. package/dist/sdk/mcp/protocol.js +1 -1
  642. package/dist/sdk/mcp/skills.js +3 -3
  643. package/dist/sdk/mcp/subscriptions.js +1 -1
  644. package/dist/sdk/mcp/tasks.js +2 -2
  645. package/dist/sdk/mcp/transport.js +1 -1
  646. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  647. package/dist/sdk/merge/driver.js +7 -7
  648. package/dist/sdk/merge/history-scalar-rebase.js +1 -1
  649. package/dist/sdk/merge/ignored-artifacts.js +1 -1
  650. package/dist/sdk/merge/index.js +1 -1
  651. package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
  652. package/dist/sdk/merge/install.js +6 -6
  653. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  654. package/dist/sdk/merge/receipt-operation.js +1 -1
  655. package/dist/sdk/merge/receipt-schema.js +1 -1
  656. package/dist/sdk/merge/receipts.js +4 -4
  657. package/dist/sdk/merge/reconcile.js +1 -1
  658. package/dist/sdk/merge/settlement-hook.js +4 -4
  659. package/dist/sdk/merge/stage.js +1 -1
  660. package/dist/sdk/merge/three-way.js +9 -9
  661. package/dist/sdk/merge/worktree-config.js +2 -2
  662. package/dist/sdk/merge.js +1 -1
  663. package/dist/sdk/mutation-events.js +1 -1
  664. package/dist/sdk/mutation-guard.js +1 -1
  665. package/dist/sdk/notes.js +1 -1
  666. package/dist/sdk/output/fit-envelope.js +1 -1
  667. package/dist/sdk/output/list-envelope.js +1 -1
  668. package/dist/sdk/output/table-rows.js +1 -1
  669. package/dist/sdk/output-contracts.js +1 -1
  670. package/dist/sdk/output-projection.js +1 -1
  671. package/dist/sdk/output-token-accounting.js +1 -1
  672. package/dist/sdk/output.js +2 -2
  673. package/dist/sdk/ownership-source.js +1 -1
  674. package/dist/sdk/package-import-adapters.js +1 -1
  675. package/dist/sdk/package-migrations.js +1 -1
  676. package/dist/sdk/package-runtime-options.js +1 -1
  677. package/dist/sdk/pagination.js +1 -1
  678. package/dist/sdk/profile.js +5 -5
  679. package/dist/sdk/provenance.js +1 -1
  680. package/dist/sdk/public-surface.json +1 -1
  681. package/dist/sdk/query/activity.js +1 -1
  682. package/dist/sdk/query/aggregate.js +1 -1
  683. package/dist/sdk/query/calendar.js +4 -4
  684. package/dist/sdk/query/complete-list.js +1 -1
  685. package/dist/sdk/query/context.js +2 -2
  686. package/dist/sdk/query/declared-blockers.js +1 -1
  687. package/dist/sdk/query/duplicate-candidates.js +1 -1
  688. package/dist/sdk/query/get-facet-roots.js +1 -1
  689. package/dist/sdk/query/get.js +1 -1
  690. package/dist/sdk/query/history.js +1 -1
  691. package/dist/sdk/query/item-filter-options.js +0 -1
  692. package/dist/sdk/query/light-metadata.js +1 -1
  693. package/dist/sdk/query/list-filter-shared.js +1 -1
  694. package/dist/sdk/query/list.js +1 -1
  695. package/dist/sdk/query/multi-value-filters.js +1 -1
  696. package/dist/sdk/query/next-ranking-policy.js +1 -1
  697. package/dist/sdk/query/next-ready-budget.js +1 -1
  698. package/dist/sdk/query/next.js +2 -2
  699. package/dist/sdk/query/parsers.js +1 -1
  700. package/dist/sdk/query/projection-contracts.js +1 -1
  701. package/dist/sdk/query/search/corpus.js +2 -2
  702. package/dist/sdk/query/search/filters.js +1 -1
  703. package/dist/sdk/query/search/input.js +1 -1
  704. package/dist/sdk/query/search/lexical.js +1 -1
  705. package/dist/sdk/query/search/response.js +1 -1
  706. package/dist/sdk/query/search/semantic.js +3 -3
  707. package/dist/sdk/query/search/types.js +0 -1
  708. package/dist/sdk/query/search-contracts.js +1 -1
  709. package/dist/sdk/query/search-pagination.js +1 -1
  710. package/dist/sdk/query/search-rendering.js +1 -1
  711. package/dist/sdk/query/search.js +1 -1
  712. package/dist/sdk/query/window-pagination.js +1 -1
  713. package/dist/sdk/query/workspace-contracts.js +1 -1
  714. package/dist/sdk/read-output/continuation.js +1 -1
  715. package/dist/sdk/read-output/extension.js +1 -1
  716. package/dist/sdk/read-output/options.js +1 -1
  717. package/dist/sdk/read-output/positional-rows.js +1 -1
  718. package/dist/sdk/read-output/provenance.js +1 -1
  719. package/dist/sdk/read-output/session-result.js +0 -1
  720. package/dist/sdk/read-output/surfaces.js +1 -1
  721. package/dist/sdk/read-output/tail-retention.js +1 -1
  722. package/dist/sdk/read-output-budget.js +1 -1
  723. package/dist/sdk/read-output-contracts.js +1 -1
  724. package/dist/sdk/read-output-rows.js +1 -1
  725. package/dist/sdk/read-output-session.js +1 -1
  726. package/dist/sdk/relationship-analytics.js +1 -1
  727. package/dist/sdk/relationship-context.js +1 -1
  728. package/dist/sdk/relationship-history.js +6 -6
  729. package/dist/sdk/relationship-kinds/contract.js +1 -1
  730. package/dist/sdk/relationships.js +1 -1
  731. package/dist/sdk/reproducibility/process.js +1 -1
  732. package/dist/sdk/runtime/actions.js +1 -1
  733. package/dist/sdk/runtime/context.js +1 -1
  734. package/dist/sdk/runtime/mutation-admission.js +1 -1
  735. package/dist/sdk/runtime/mutation-value-validation.js +1 -1
  736. package/dist/sdk/runtime/schema-preview.js +1 -1
  737. package/dist/sdk/runtime/schema.js +1 -1
  738. package/dist/sdk/runtime-action-aliases.js +1 -1
  739. package/dist/sdk/runtime-extended-actions.js +1 -1
  740. package/dist/sdk/runtime-input.d.ts +2 -0
  741. package/dist/sdk/runtime-input.js +1 -1
  742. package/dist/sdk/runtime-primitives.js +1 -1
  743. package/dist/sdk/runtime-public-contracts.js +0 -1
  744. package/dist/sdk/runtime-stats-options.js +1 -1
  745. package/dist/sdk/runtime.d.ts +5 -3
  746. package/dist/sdk/runtime.js +1 -1
  747. package/dist/sdk/scheduling-shortcuts.js +1 -1
  748. package/dist/sdk/schema/field-option-collisions.js +2 -0
  749. package/dist/sdk/schema-migration.js +4 -4
  750. package/dist/sdk/schema.js +7 -7
  751. package/dist/sdk/search-refresh-worker.js +1 -1
  752. package/dist/sdk/similarity-scoring.js +1 -1
  753. package/dist/sdk/similarity.js +1 -1
  754. package/dist/sdk/start-task-status.js +1 -1
  755. package/dist/sdk/stats.js +1 -1
  756. package/dist/sdk/structured-mutations.js +1 -1
  757. package/dist/sdk/telemetry-flush.js +1 -1
  758. package/dist/sdk/telemetry.js +4 -4
  759. package/dist/sdk/templates.js +3 -3
  760. package/dist/sdk/test/batch.js +2 -2
  761. package/dist/sdk/test/command-args.js +1 -1
  762. package/dist/sdk/test/command-resolution.js +2 -2
  763. package/dist/sdk/test/entry.js +2 -2
  764. package/dist/sdk/test/execution-receipts.js +2 -2
  765. package/dist/sdk/test/execution.js +5 -5
  766. package/dist/sdk/test/json-path.js +1 -1
  767. package/dist/sdk/test/linked-command-detection.js +1 -1
  768. package/dist/sdk/test/measurements.js +1 -1
  769. package/dist/sdk/test/parsers.js +1 -1
  770. package/dist/sdk/test/prerequisites.js +1 -1
  771. package/dist/sdk/test/receipt-index-snapshot.js +1 -1
  772. package/dist/sdk/test/run-phases.js +1 -1
  773. package/dist/sdk/test/runs.js +1 -1
  774. package/dist/sdk/test/trust.js +2 -2
  775. package/dist/sdk/test/update.js +1 -1
  776. package/dist/sdk/test/workspace-snapshot.js +1 -1
  777. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  778. package/dist/sdk/traceability/source-traceability.js +2 -2
  779. package/dist/sdk/tracker-root-discovery.js +1 -1
  780. package/dist/sdk/transactions/item-finalization.js +1 -1
  781. package/dist/sdk/workspace-contracts-cache.js +1 -1
  782. package/dist/sdk/workspace-contracts.js +1 -1
  783. package/dist/sdk/workspace-memory.js +2 -2
  784. package/dist/sdk/workspace-snapshot.js +5 -5
  785. package/dist/sdk/workspace-transaction-gc.js +1 -1
  786. package/dist/sdk/workspace-transaction.js +2 -2
  787. package/dist/sdk/workspace.js +6 -6
  788. package/dist/types/index.js +1 -1
  789. package/dist/types.js +1 -1
  790. package/docs/COMMANDS.md +1 -1
  791. package/docs/EXTENSIONS.md +1 -1
  792. package/docs/SDK.md +74 -4
  793. package/marketplace.json +1 -1
  794. package/package.json +2 -1
  795. package/packages/pm-beads/package.json +1 -1
  796. package/packages/pm-calendar/package.json +1 -1
  797. package/packages/pm-command-kit/package.json +1 -1
  798. package/packages/pm-digital-twin/package.json +1 -1
  799. package/packages/pm-governance-audit/package.json +1 -1
  800. package/packages/pm-guide-shell/package.json +1 -1
  801. package/packages/pm-kanban/package.json +1 -1
  802. package/packages/pm-lifecycle-hooks/package.json +1 -1
  803. package/packages/pm-linked-test-adapters/package.json +1 -1
  804. package/packages/pm-search-advanced/package.json +1 -1
  805. package/packages/pm-templates/package.json +1 -1
  806. package/packages/pm-todos/package.json +1 -1
  807. package/packages/pm-vcs/package.json +1 -1
  808. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  809. package/plugins/pm-claude/package.json +1 -1
  810. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  811. package/plugins/pm-codex/package.json +1 -1
  812. package/plugins/pm-codex/plugin.json +1 -1
  813. package/runtime-dependencies.json +1 -1
  814. package/scripts/finalize-build.mjs +63 -24
  815. package/scripts/prepare-build-cache.mjs +28 -1
  816. package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +0 -9
  817. package/dist/cli-bundle/chunks/chunk-4TB5D6HL.js +0 -125
  818. package/dist/cli-bundle/chunks/chunk-5ZMVLWE3.js +0 -2
  819. package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +0 -33
  820. package/dist/cli-bundle/chunks/chunk-AR4NP5HI.js +0 -3
  821. package/dist/cli-bundle/chunks/chunk-B4PPFOPY.js +0 -3
  822. package/dist/cli-bundle/chunks/chunk-CAR2L5NW.js +0 -8
  823. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  824. package/dist/cli-bundle/chunks/chunk-EIGUKEV6.js +0 -2
  825. package/dist/cli-bundle/chunks/chunk-GTPCAJMZ.js +0 -8
  826. package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +0 -2
  827. package/dist/cli-bundle/chunks/chunk-HC2OPETM.js +0 -2
  828. package/dist/cli-bundle/chunks/chunk-HKUV74K3.js +0 -2
  829. package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +0 -115
  830. package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
  831. package/dist/cli-bundle/chunks/chunk-J2LABXBL.js +0 -2
  832. package/dist/cli-bundle/chunks/chunk-J52BEBSS.js +0 -2
  833. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
  834. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
  835. package/dist/cli-bundle/chunks/chunk-OJTMGDON.js +0 -31
  836. package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
  837. package/dist/cli-bundle/chunks/chunk-TC6XLIYO.js +0 -2
  838. package/dist/cli-bundle/chunks/chunk-U7EL3AYA.js +0 -3
  839. package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +0 -6
  840. package/dist/cli-bundle/chunks/chunk-X6MIWTTT.js +0 -2
  841. package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +0 -2
  842. package/dist/cli-bundle/chunks/chunk-XFHPKXAE.js +0 -71
  843. package/dist/cli-bundle/chunks/chunk-YHVLVSEZ.js +0 -9
  844. package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
  845. package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
  846. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
  847. package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
  848. package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +0 -2
  849. package/dist/cli-bundle/chunks/mutation-actor-FWLYWJ37.js +0 -2
  850. package/dist/cli-bundle/chunks/mutation-admission-7ZDCK3G2.js +0 -2
  851. package/dist/cli-bundle/chunks/register-mutation-57AJQWFV.js +0 -21
  852. package/dist/cli-bundle/chunks/register-operations-RKWST7CU.js +0 -2
  853. package/dist/cli-bundle/chunks/register-setup-CMI23PC5.js +0 -2
  854. package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
  855. package/dist/cli-bundle/chunks/stage-4KDVXC5Z.js +0 -2
  856. package/dist/cli-bundle/focused-chunks/chunk-2ZD7275J.js +0 -2
  857. package/dist/cli-bundle/focused-chunks/chunk-324AHXJO.js +0 -2
  858. package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
  859. package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
  860. package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +0 -91
  861. package/dist/cli-bundle/focused-chunks/chunk-4JZITIJB.js +0 -2
  862. package/dist/cli-bundle/focused-chunks/chunk-4KTFKSS3.js +0 -2
  863. package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +0 -78
  864. package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +0 -2
  865. package/dist/cli-bundle/focused-chunks/chunk-BRZV7BFV.js +0 -8
  866. package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
  867. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
  868. package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
  869. package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
  870. package/dist/cli-bundle/focused-chunks/chunk-HDEKFSOK.js +0 -2
  871. package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
  872. package/dist/cli-bundle/focused-chunks/chunk-IWOXAUDU.js +0 -2
  873. package/dist/cli-bundle/focused-chunks/chunk-ML3JHCC6.js +0 -6
  874. package/dist/cli-bundle/focused-chunks/chunk-OPGOOP25.js +0 -2
  875. package/dist/cli-bundle/focused-chunks/chunk-RE7ZWT7D.js +0 -27
  876. package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +0 -3
  877. package/dist/cli-bundle/focused-chunks/chunk-RQ252B6V.js +0 -8
  878. package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
  879. package/dist/cli-bundle/focused-chunks/chunk-URGHTTT3.js +0 -8
  880. package/dist/cli-bundle/focused-chunks/chunk-USPYKWQG.js +0 -13
  881. package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +0 -102
  882. package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +0 -44
  883. package/dist/cli-bundle/focused-chunks/chunk-WZWXGDYY.js +0 -26
  884. package/dist/cli-bundle/focused-chunks/chunk-YKSLZPLT.js +0 -2
  885. package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +0 -2
  886. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
  887. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
  888. package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +0 -2
  889. package/dist/cli-bundle/focused-chunks/mutation-actor-TCYDPUGG.js +0 -2
  890. package/dist/cli-bundle/focused-chunks/mutation-admission-LY73EJWM.js +0 -2
  891. package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
  892. package/dist/cli-bundle/focused-chunks/stage-DQ7RQQ52.js +0 -2
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7c06c702-29ea-5552-aadc-52dfc9c238ef")}catch{}})();import{withHostEnvironmentBoundary}from"../../core/fs/host-environment-errors.js";import fs from"node:fs/promises";import path from"node:path";import{getSettingsPath}from"../../core/store/paths.js";import{isErrnoCode}from"./install-runtime.js";import{pathExists}from"../../core/fs/fs-utils.js";import{PmCliError}from"../../core/shared/errors.js";import{EXIT_CODE}from"../../core/shared/constants.js";import{renderPmCommand}from"../command-line.js";import{areDirectoriesEquivalent}from"./install-sources.js";import{writeWorkspaceJsonWithHistory}from"../../core/history/workspace-history.js";import{readSettings}from"../../core/store/settings.js";import{clearSettingsReadCache}from"../../core/store/settings-read-cache.js";import{resolveAuthor}from"../../core/shared/author.js";import{resolveManagedExtensionStatePath}from"./managed-state.js";const readOptionalMetadataFile=async filePath=>fs.readFile(filePath).catch(error=>{if(isErrnoCode(error,"ENOENT"))return null;throw error}),captureExtensionInstallSnapshot=async(selectedRoot,settingsRoot,destinationDirectory,destinationExists,backupDirectory)=>withHostEnvironmentBoundary("extension_install_backup",async()=>{const managedStatePath=resolveManagedExtensionStatePath(selectedRoot),settingsPath=getSettingsPath(settingsRoot),[managedStateContents,settingsContents]=await Promise.all([readOptionalMetadataFile(managedStatePath),readOptionalMetadataFile(settingsPath)]);return destinationExists&&await fs.cp(destinationDirectory,backupDirectory,{recursive:!0,force:!0}),{backupDirectory,destinationDirectory,destinationExists,managedStatePath,managedStateContents,settingsPath,settingsContents}}),restoreExtensionInstallSnapshot=async snapshot=>withHostEnvironmentBoundary("extension_install_rollback",async()=>{await fs.rm(snapshot.destinationDirectory,{recursive:!0,force:!0}),snapshot.destinationExists&&await fs.cp(snapshot.backupDirectory,snapshot.destinationDirectory,{recursive:!0,force:!0});for(const[filePath,contents]of[[snapshot.managedStatePath,snapshot.managedStateContents],[snapshot.settingsPath,snapshot.settingsContents]])if(contents===null)await fs.rm(filePath,{force:!0});else if(filePath===snapshot.settingsPath){const settingsRoot=path.dirname(snapshot.settingsPath),settings=await readSettings(settingsRoot);try{await writeWorkspaceJsonWithHistory({pmRoot:settingsRoot,filePath,raw:contents.toString("utf8"),op:"extension:install:rollback",author:resolveAuthor(void 0,settings.author_default),lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms})}finally{clearSettingsReadCache(settingsRoot)}}else await fs.mkdir(path.dirname(filePath),{recursive:!0}),await fs.writeFile(filePath,contents)});async function withVerifiedExtensionInstall(options,install){const destinationExists=await pathExists(options.destinationDirectory),inPlace=await areDirectoriesEquivalent(options.sourceDirectory,options.destinationDirectory);await fs.mkdir(options.selectedRoot,{recursive:!0});const backupParent=path.join(path.dirname(options.selectedRoot),"runtime","extension-installs");await fs.mkdir(backupParent,{recursive:!0});const backupRoot=await fs.mkdtemp(path.join(backupParent,".pm-extension-install-backup-")),backupDirectory=path.join(backupRoot,"destination"),recoveryArgs=["package","install",backupDirectory,`--${options.scope}`],recoveryCommand=renderPmCommand(recoveryArgs);let retainBackup=!1;try{const snapshot=await captureExtensionInstallSnapshot(options.selectedRoot,options.settingsRoot,options.destinationDirectory,destinationExists,backupDirectory);let result;try{result=await install()}catch(error){try{await restoreExtensionInstallSnapshot(snapshot)}catch(rollbackError){retainBackup=!0;const wrapped=new PmCliError(`Extension install failed: ${String(error)}; rollback failed: ${String(rollbackError)}`,EXIT_CODE.GENERIC_FAILURE,{code:"extension_install_rollback_failed",original_code:error instanceof PmCliError?error.code:void 0,required:"Restore the previous package before retrying the replacement. Previous state was not preserved.",nextSteps:[destinationExists?recoveryCommand:"Repair the reported metadata write failure, then retry the original install."],...destinationExists?{recovery:{suggested_retry:recoveryCommand,suggested_retry_args:recoveryArgs}}:{}});throw Object.defineProperty(wrapped,"cause",{value:error,configurable:!0,writable:!0}),wrapped}throw error}if(result.ok)return result;if(!destinationExists||inPlace)return{...result,details:{...result.details,previous_state_preserved:!1}};try{await restoreExtensionInstallSnapshot(snapshot)}catch(error){return retainBackup=!0,{...result,details:{...result.details,previous_state_preserved:!1,rollback:{status:"failed",error:String(error),backup_directory:backupDirectory,recovery_command:recoveryCommand,recovery_args:recoveryArgs}}}}return{...result,details:{...result.details,overwritten:!1,settings_changed:!1,previous_state_preserved:!0,rollback:{status:"restored"}}}}finally{retainBackup||await fs.rm(backupRoot,{recursive:!0,force:!0}).catch(()=>{})}}export{captureExtensionInstallSnapshot,readOptionalMetadataFile,restoreExtensionInstallSnapshot,withVerifiedExtensionInstall};
1
+ import{withHostEnvironmentBoundary as w}from"../../core/fs/host-environment-errors.js";import a from"node:fs/promises";import l from"node:path";import{getSettingsPath as _}from"../../core/store/paths.js";import{isErrnoCode as E}from"./install-runtime.js";import{pathExists as x}from"../../core/fs/fs-utils.js";import{PmCliError as y}from"../../core/shared/errors.js";import{EXIT_CODE as b}from"../../core/shared/constants.js";import{renderPmCommand as P}from"../command-line.js";import{areDirectoriesEquivalent as S}from"./install-sources.js";import{writeWorkspaceJsonWithHistory as R}from"../../core/history/workspace-history.js";import{readSettings as C}from"../../core/store/settings.js";import{clearSettingsReadCache as D}from"../../core/store/settings-read-cache.js";import{resolveAuthor as I}from"../../core/shared/author.js";import{resolveManagedExtensionStatePath as j}from"./managed-state.js";const v=async t=>a.readFile(t).catch(e=>{if(E(e,"ENOENT"))return null;throw e}),F=async(t,e,r,n,i)=>w("extension_install_backup",async()=>{const d=j(t),c=_(e),[u,m]=await Promise.all([v(d),v(c)]);return n&&await a.cp(r,i,{recursive:!0,force:!0}),{backupDirectory:i,destinationDirectory:r,destinationExists:n,managedStatePath:d,managedStateContents:u,settingsPath:c,settingsContents:m}}),h=async t=>w("extension_install_rollback",async()=>{await a.rm(t.destinationDirectory,{recursive:!0,force:!0}),t.destinationExists&&await a.cp(t.backupDirectory,t.destinationDirectory,{recursive:!0,force:!0});for(const[e,r]of[[t.managedStatePath,t.managedStateContents],[t.settingsPath,t.settingsContents]])if(r===null)await a.rm(e,{force:!0});else if(e===t.settingsPath){const n=l.dirname(t.settingsPath),i=await C(n);try{await R({pmRoot:n,filePath:e,raw:r.toString("utf8"),op:"extension:install:rollback",author:I(void 0,i.author_default),lockTtlSeconds:i.locks.ttl_seconds,lockWaitMs:i.locks.wait_ms})}finally{D(n)}}else await a.mkdir(l.dirname(e),{recursive:!0}),await a.writeFile(e,r)});async function X(t,e){const r=await x(t.destinationDirectory),n=await S(t.sourceDirectory,t.destinationDirectory);await a.mkdir(t.selectedRoot,{recursive:!0});const i=l.join(l.dirname(t.selectedRoot),"runtime","extension-installs");await a.mkdir(i,{recursive:!0});const d=await a.mkdtemp(l.join(i,".pm-extension-install-backup-")),c=l.join(d,"destination"),u=["package","install",c,`--${t.scope}`],m=P(u);let f=!1;try{const p=await F(t.selectedRoot,t.settingsRoot,t.destinationDirectory,r,c);let o;try{o=await e()}catch(s){try{await h(p)}catch(k){f=!0;const g=new y(`Extension install failed: ${String(s)}; rollback failed: ${String(k)}`,b.GENERIC_FAILURE,{code:"extension_install_rollback_failed",original_code:s instanceof y?s.code:void 0,required:"Restore the previous package before retrying the replacement. Previous state was not preserved.",nextSteps:[r?m:"Repair the reported metadata write failure, then retry the original install."],...r?{recovery:{suggested_retry:m,suggested_retry_args:u}}:{}});throw Object.defineProperty(g,"cause",{value:s,configurable:!0,writable:!0}),g}throw s}if(o.ok)return o;if(!r||n)return{...o,details:{...o.details,previous_state_preserved:!1}};try{await h(p)}catch(s){return f=!0,{...o,details:{...o.details,previous_state_preserved:!1,rollback:{status:"failed",error:String(s),backup_directory:c,recovery_command:m,recovery_args:u}}}}return{...o,details:{...o.details,overwritten:!1,settings_changed:!1,previous_state_preserved:!0,rollback:{status:"restored"}}}}finally{f||await a.rm(d,{recursive:!0,force:!0}).catch(()=>{})}}export{F as captureExtensionInstallSnapshot,v as readOptionalMetadataFile,h as restoreExtensionInstallSnapshot,X as withVerifiedExtensionInstall};
2
2
  //# sourceMappingURL=install-snapshot.js.map
@@ -1,6 +1,6 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fc993281-a2a0-59e8-9f4a-e520f1b94f3b")}catch{}})();import{execFile}from"node:child_process";import fs from"node:fs/promises";import os from"node:os";import path from"node:path";import{fileURLToPath}from"node:url";import{promisify}from"node:util";import npa from"npm-package-arg";import{extract as extractTar,list as listTar}from"tar";import{collectPackageExtensionDirectories}from"../../core/packages/manifest.js";import{resolvePmPackageRootFromModule}from"../../core/packages/root.js";import{pathExists}from"../../core/fs/fs-utils.js";import{isPathWithinDirectory}from"../../core/fs/path-utils.js";import{EXIT_CODE}from"../../core/shared/constants.js";import{PmCliError}from"../../core/shared/errors.js";import{listBundledPackageAliases}from"./bundled-catalog.js";const execFileAsync=promisify(execFile),PM_CLI_PACKAGE_NAME="@unbrained/pm-cli",LOCAL_PACKAGE_ARCHIVE_LIMITS={maxArchiveBytes:64*1024*1024,maxEntries:4096,maxExpandedBytes:256*1024*1024,maxEntryBytes:64*1024*1024};let bundledPackageAliasesCache;async function findInstalledNpmPackageCandidate(packageName,cwd=process.cwd()){const normalized=packageName.trim();if(!/^(@[^/\\\s]+\/[^/\\\s]+|[^@/\\\s][^/\\\s]*)$/u.test(normalized))return null;let current=path.resolve(cwd);for(;;){const directory=path.join(current,"node_modules",...normalized.split("/")),manifestPath=path.join(directory,"package.json");if(await pathExists(manifestPath))try{const manifest=JSON.parse(await fs.readFile(manifestPath,"utf8"));if(manifest.name===normalized)return{package:normalized,...typeof manifest.version=="string"?{version:manifest.version}:{},directory}}catch{return null}const parent=path.dirname(current);if(parent===current)return null;current=parent}}function parseGithubPathSpec(pathSpec,input,refOverride){const segments=pathSpec.split("/").map(segment=>segment.trim()).filter(segment=>segment.length>0);if(segments.length<2)return null;const owner=segments[0],repo=segments[1].replace(/\.git$/i,"");if(owner.length===0||repo.length===0)return null;const tail=segments.slice(2);let ref,subpath;return tail[0]==="tree"&&tail.length>=2?(ref=tail[1],subpath=tail.slice(2).join("/")):tail.length>0&&(subpath=tail.join("/")),typeof refOverride=="string"&&refOverride.trim().length>0&&(ref=refOverride.trim()),{kind:"github",input,owner,repo,repository:`https://github.com/${owner}/${repo}.git`,ref,subpath:subpath&&subpath.length>0?subpath:void 0}}function parseNpmInstallSource(normalizedInput,forceGithub,refOverride){const spec=normalizedInput.slice(4).trim();if(spec.length===0)throw new PmCliError('npm package source must include a package spec after "npm:".',EXIT_CODE.USAGE);if(forceGithub)throw new PmCliError('Options "--gh/--github" cannot be combined with npm: package sources.',EXIT_CODE.USAGE);if(refOverride)throw new PmCliError('Option "--ref" cannot be combined with npm: package sources.',EXIT_CODE.USAGE);return{kind:"npm",input:normalizedInput,spec}}function parseExtensionInstallSource(input,options={}){const normalizedInput=input.trim();if(normalizedInput.length===0)throw new PmCliError("Extension source is required for --install.",EXIT_CODE.USAGE);const refOverride=typeof options.ref=="string"&&options.ref.trim().length>0?options.ref.trim():void 0;if(normalizedInput.startsWith("npm:"))return parseNpmInstallSource(normalizedInput,options.forceGithub===!0,refOverride);const maybeGithubByUrl=(()=>{try{const parsed=new URL(normalizedInput);if(parsed.hostname!=="github.com")return null;const pathSpec=parsed.pathname.replace(/^\/+/,"");return parseGithubPathSpec(pathSpec,normalizedInput,refOverride)}catch{return null}})();if(maybeGithubByUrl)return maybeGithubByUrl;const strippedDomainInput=normalizedInput.startsWith("github.com/")?normalizedInput.slice(11):null;if(strippedDomainInput){const parsed=parseGithubPathSpec(strippedDomainInput,normalizedInput,refOverride);if(!parsed)throw new PmCliError(`Invalid GitHub source "${normalizedInput}".`,EXIT_CODE.USAGE);return parsed}if(options.forceGithub){const parsed=parseGithubPathSpec(normalizedInput,normalizedInput,refOverride);if(!parsed)throw new PmCliError(`Invalid GitHub shorthand "${normalizedInput}".`,EXIT_CODE.USAGE);return parsed}if(/^https?:\/\//i.test(normalizedInput))throw new PmCliError(`Unsupported extension source URL "${normalizedInput}". Supported remote source host: github.com.`,EXIT_CODE.USAGE);return{kind:"local",input:normalizedInput,absolute_path:path.resolve(process.cwd(),normalizedInput)}}async function runGitCommand(args,execRunner=execFileAsync,timeoutMs){try{return((await execRunner("git",args,{encoding:"utf8",timeout:timeoutMs})).stdout??"").trim()}catch(error){const stderr=typeof error=="object"&&error!==null&&"stderr"in error?String(error.stderr):"",message=stderr.trim().length>0?stderr.trim():error instanceof Error?error.message:String(error);throw new PmCliError(`Git command failed: git ${args.join(" ")}
2
- ${message}`,EXIT_CODE.GENERIC_FAILURE)}}function resolveNpmCommandName(platform=process.platform){return platform==="win32"?"npm.cmd":"npm"}function shouldRunNpmCommandInShell(platform=process.platform){return platform==="win32"}async function runNpmCommand(args,cwd,execRunner=execFileAsync,platform=process.platform,environment=process.env){const npmCommand=resolveNpmCommandName(platform),env=Object.fromEntries(Object.entries(environment).filter(([key])=>key.toLowerCase()!=="npm_config_allow_scripts"));env.NPM_CONFIG_ALLOW_SCRIPTS="";try{return((await execRunner(npmCommand,args,{cwd,encoding:"utf8",env,shell:shouldRunNpmCommandInShell(platform)})).stdout??"").trim()}catch(error){const stderr=typeof error=="object"&&error!==null&&"stderr"in error?String(error.stderr):"",message=stderr.trim().length>0?stderr.trim():error instanceof Error?error.message:String(error);throw new PmCliError(`npm command failed: ${npmCommand} ${args.join(" ")}
3
- ${message}`,EXIT_CODE.GENERIC_FAILURE)}}function npmPackageNameFromSpec(spec){const trimmed=spec.trim(),withoutAlias=trimmed.includes("@file:")?trimmed.slice(0,trimmed.lastIndexOf("@file:")):trimmed;return withoutAlias.startsWith("@")?withoutAlias.match(/^(@[^/@\s]+\/[^/@\s]+)/)?.[1]??withoutAlias:withoutAlias.match(/^([^/@\s]+)/)?.[1]??withoutAlias}function isNpmLocalFileAliasSpec(spec){const marker="@file:",markerIndex=spec.lastIndexOf(marker);return markerIndex>0&&spec.slice(0,markerIndex).trim().length>0&&spec.slice(markerIndex+marker.length).trim().length>0}function isNpmNotFoundError(error){const normalized=(error instanceof Error?error.message:String(error)).toLowerCase();return normalized.includes("npm err! code e404")||normalized.includes("404 not found")||normalized.includes("is not in this registry")}function isNpmPackNotFoundError(error){const normalized=(error instanceof Error?error.message:String(error)).toLowerCase();return isNpmNotFoundError(error)||normalized.includes("not found")}function isFirstPartyPmPackageName(packageName){const normalized=packageName.trim().toLowerCase();return normalized.startsWith("@unbrained/pm-")||normalized.startsWith("pm-")}function buildNpmNotFoundRecovery(spec){const packageName=npmPackageNameFromSpec(spec),isFirstPartyPackage=isFirstPartyPmPackageName(packageName),repoName=packageName.replace(/^.*\//,""),githubSource=isFirstPartyPackage?`github.com/unbraind/${repoName}`:void 0,nextBestCommand=githubSource?`pm package install --project ${githubSource}`:void 0;return{message:isFirstPartyPackage?`npm package "${spec}" was not found in the registry. If this is an unpublished first-party pm package, install its GitHub repository instead.`:`npm package "${spec}" was not found in the registry.`,context:{code:"npm_package_not_found",required:"Use an install source that exists, or publish the npm package before installing it with npm:<name>.",why:"Classifying npm 404s avoids repeated registry retries and gives agents a deterministic fallback path.",examples:nextBestCommand?[nextBestCommand,"pm package catalog --project --json"]:[`npm view ${packageName}`,"pm package catalog --project --json"],nextSteps:nextBestCommand?[`Try ${nextBestCommand} if the repository exists.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."]:[`Verify ${packageName} exists in the npm registry and that you have access to it.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."],recovery:{attempted_command:`pm install --project npm:${spec}`,normalized_args:["install","--project",`npm:${spec}`],...githubSource&&nextBestCommand?{fallback_candidates:[{source:githubSource,command:nextBestCommand,reason:"canonical first-party GitHub repository fallback for unpublished pm packages"}],next_best_command:nextBestCommand}:{}}}}}function wrapNpmPackResolutionError(spec,error){if(!isNpmPackNotFoundError(error))return null;const recovery=buildNpmNotFoundRecovery(spec);return new PmCliError(recovery.message,EXIT_CODE.NOT_FOUND,recovery.context)}async function resolveLocalNpmPackagePath(spec){if(path.isAbsolute(spec)||spec.startsWith(".")||spec.startsWith("..")){const absolutePath=path.resolve(process.cwd(),spec);return await pathExists(absolutePath)?absolutePath:null}try{const parsed=new URL(spec);if(parsed.protocol==="file:"){const absolutePath=fileURLToPath(parsed);return await pathExists(absolutePath)?absolutePath:null}}catch{}if(!/^[a-z][a-z0-9+.-]*:/i.test(spec)){const absolutePath=path.resolve(process.cwd(),spec);if(await pathExists(absolutePath))return absolutePath}return null}async function resolveNpmPackSpec(spec){const localPath=await resolveLocalNpmPackagePath(spec);if(localPath)return localPath;const localFileAlias=normalizeNpmLocalFileAliasSpec(spec);return localFileAlias!==spec?localFileAlias:(/^[a-z][a-z0-9+.-]*:/i.test(spec),spec)}function normalizeNpmLocalFileAliasSpec(spec,cwd=process.cwd()){const marker="@file:",markerIndex=spec.lastIndexOf(marker);if(!isNpmLocalFileAliasSpec(spec))return spec;const packageName=spec.slice(0,markerIndex),target=spec.slice(markerIndex+marker.length);if(target.startsWith("//")&&!target.startsWith("///"))return spec;if(!target.startsWith("/"))return`${packageName}@${path.resolve(cwd,target)}`;let decodedPath;try{decodedPath=decodeURIComponent(new URL(`file:${target}`).pathname)}catch{return spec}const nativePath=/^\/[A-Za-z]:/.test(decodedPath)?decodedPath.slice(1):decodedPath;return`${packageName}@${nativePath}`}function resolvePackedTarball(packDirectory,filename){const tarball=path.resolve(packDirectory,filename),relativeTarball=path.relative(packDirectory,tarball);if(relativeTarball.length===0||relativeTarball===".."||relativeTarball.startsWith(`..${path.sep}`)||path.isAbsolute(relativeTarball))throw new PmCliError("npm pack reported a package archive outside its isolated destination.",EXIT_CODE.GENERIC_FAILURE,{code:"npm_package_archive_unsafe",required:"Retry with a trusted npm client that writes its archive inside the requested pack destination.",why:"pm will not read a package-manager artifact outside the isolated directory created for this install."});return tarball}function decodePackedNpmCandidate(value,key){if(typeof value!="object"||value===null||Array.isArray(value))return;const record=value;if(!(typeof record.filename!="string"||record.filename.trim().length===0))return{...key===void 0?{}:{key},filename:record.filename,...typeof record.name=="string"?{name:record.name}:{},...typeof record.version=="string"?{version:record.version}:{}}}function collectPackedNpmCandidates(parsed){return(Array.isArray(parsed)?parsed.map(value=>({value})):typeof parsed=="object"&&parsed!==null?Object.entries(parsed).map(([key,value])=>({key,value})):[]).flatMap(({key,value})=>{const candidate=decodePackedNpmCandidate(value,key);return candidate?[candidate]:[]})}function selectPackedNpmCandidate(candidates,expectedPackage){const normalizedExpected=expectedPackage?.trim().toLowerCase(),matchingCandidates=normalizedExpected?candidates.filter(candidate=>{const normalizedName=candidate.name?.trim().toLowerCase();return normalizedName!==void 0?normalizedName===normalizedExpected:candidate.key?.trim().toLowerCase()===normalizedExpected}):[];if(matchingCandidates.length===1)return matchingCandidates[0];if(candidates.length!==1)return;const soleCandidate=candidates[0],soleIdentity=soleCandidate.name??soleCandidate.key;return normalizedExpected&&soleIdentity!==void 0&&soleIdentity.trim().toLowerCase()!==normalizedExpected?void 0:soleCandidate}function parsePackedNpmPackage(stdout,packDirectory,expectedPackage){let parsed;try{parsed=JSON.parse(stdout)}catch{const filename=stdout.split(/\r?\n/).map(line=>line.trim()).filter(line=>line.length>0).at(-1);if(!filename)throw new PmCliError("npm pack did not report a tarball filename.",EXIT_CODE.GENERIC_FAILURE);return{tarball:resolvePackedTarball(packDirectory,filename)}}const candidates=collectPackedNpmCandidates(parsed),selected=selectPackedNpmCandidate(candidates,expectedPackage);if(!selected)throw new PmCliError("npm pack --json returned an unsupported or ambiguous package receipt.",EXIT_CODE.GENERIC_FAILURE,{code:"npm_pack_json_shape_unsupported",required:"Use an npm client that returns an array of package receipts or an object keyed by package name, with exactly one requested package entry containing filename.",why:`Well-formed JSON contained ${candidates.length} usable package receipt(s), but pm could not select ${expectedPackage??"one package"} deterministically.`});return{tarball:resolvePackedTarball(packDirectory,selected.filename),package:selected.name??selected.key,version:selected.version}}async function resolveNpmSourceDirectory(source){return resolveNpmSourceDirectoryWithRunner(source,runNpmCommand)}async function resolveNpmSourceDirectoryWithRunner(source,npmRunner){const localPackageRoot=await resolveLocalNpmPackagePath(source.spec);if(localPackageRoot){if((await fs.stat(localPackageRoot)).isFile()&&isLocalPackageArchive(localPackageRoot))return extractLocalPackageArchive(localPackageRoot);const packageJsonPath=path.join(localPackageRoot,"package.json"),packageJson=await pathExists(packageJsonPath)?JSON.parse(await fs.readFile(packageJsonPath,"utf8")):{};return{directory:await resolvePackageExtensionDirectory(localPackageRoot,source.input),package:typeof packageJson.name=="string"?packageJson.name:void 0,version:typeof packageJson.version=="string"?packageJson.version:void 0,cleanup:async()=>{}}}const tempRoot=await fs.mkdtemp(path.join(os.tmpdir(),"pm-npm-package-source-")),packDirectory=path.join(tempRoot,"pack");await fs.mkdir(packDirectory,{recursive:!0});try{const packSpec=await resolveNpmPackSpec(source.spec),packStdout=await npmRunner(["pack",packSpec,"--json","--pack-destination",packDirectory]),packed=parsePackedNpmPackage(packStdout,packDirectory,isNpmLocalFileAliasSpec(source.spec)?void 0:npmPackageNameFromSpec(source.spec));if(!await pathExists(packed.tarball))throw new PmCliError("npm pack did not create its reported package archive.",EXIT_CODE.GENERIC_FAILURE,{code:"npm_package_archive_missing",required:"Retry the npm package install with a healthy registry and writable temporary directory.",why:"The package manager reported a tarball filename that was absent before validation, so pm cannot safely extract or install it."});const extracted=await extractLocalPackageArchive(packed.tarball);return{directory:extracted.directory,package:packed.package??extracted.package,version:packed.version??extracted.version,cleanup:async()=>{try{await extracted.cleanup()}finally{await fs.rm(tempRoot,{recursive:!0,force:!0})}}}}catch(error){throw await fs.rm(tempRoot,{recursive:!0,force:!0}),wrapNpmPackResolutionError(source.spec,error)||error}}function isLocalPackageArchive(candidate){const normalized=candidate.toLowerCase();return normalized.endsWith(".tgz")||normalized.endsWith(".tar.gz")}function failLocalPackageArchive(message){throw new PmCliError(message,EXIT_CODE.USAGE,{code:"local_package_archive_unsafe",required:"Use a bounded npm .tgz or .tar.gz archive with one package/ root and no links or escaping paths.",why:"Package archives are untrusted input and must be validated before any entry reaches the filesystem."})}function validateLocalPackageArchiveEntry(entry,limits,state){if(entry.meta)return;state.entries+=1,state.entries>limits.maxEntries&&failLocalPackageArchive(`Local package archive exceeds the ${limits.maxEntries} entry limit.`);const archivePath=entry.path,segments=archivePath.split("/");(archivePath.includes("\\")||archivePath.startsWith("/")||/^[A-Za-z]:/u.test(archivePath)||segments.some(segment=>segment===".."))&&failLocalPackageArchive(`Local package archive contains an escaping path: "${archivePath}".`),segments[0]!=="package"&&failLocalPackageArchive(`Local package archive entry "${archivePath}" is outside the required package/ root.`),(entry.type==="SymbolicLink"||entry.type==="Link")&&failLocalPackageArchive(`Local package archive link "${archivePath}" is not supported.`),entry.type!=="File"&&entry.type!=="OldFile"&&entry.type!=="Directory"&&failLocalPackageArchive(`Local package archive entry "${archivePath}" uses unsupported type "${entry.type}".`),entry.size>limits.maxEntryBytes&&failLocalPackageArchive(`Local package archive entry "${archivePath}" exceeds the ${limits.maxEntryBytes} byte entry limit.`),state.expandedBytes+=entry.size,state.expandedBytes>limits.maxExpandedBytes&&failLocalPackageArchive(`Local package archive exceeds the ${limits.maxExpandedBytes} expanded byte limit.`),archivePath==="package/package.json"&&(state.packageJsonEntries+=1)}async function extractLocalPackageArchive(archivePath,limits=LOCAL_PACKAGE_ARCHIVE_LIMITS){(await fs.stat(archivePath)).size>limits.maxArchiveBytes&&failLocalPackageArchive(`Local package archive exceeds the ${limits.maxArchiveBytes} archive byte limit.`);const tempRoot=await fs.mkdtemp(path.join(os.tmpdir(),"pm-local-package-archive-")),extractDirectory=path.join(tempRoot,"extract");await fs.mkdir(extractDirectory,{recursive:!0});const state={entries:0,expandedBytes:0,packageJsonEntries:0};let validationError;try{if(await listTar({file:archivePath,strict:!0,maxDecompressionRatio:100,onReadEntry:entry=>{if(validationError===void 0)try{validateLocalPackageArchiveEntry(entry,limits,state)}catch(error){validationError=error}}}),validationError!==void 0)throw validationError;state.packageJsonEntries!==1&&failLocalPackageArchive(`Local package archive must contain exactly one package/package.json entry; found ${state.packageJsonEntries}.`),await extractTar({file:archivePath,cwd:extractDirectory,strict:!0,preservePaths:!1,preserveOwner:!1,noMtime:!0,unlink:!0,maxDepth:64,maxDecompressionRatio:100});const packageRoot=path.join(extractDirectory,"package"),packageJsonPath=path.join(packageRoot,"package.json"),packageJson=JSON.parse(await fs.readFile(packageJsonPath,"utf8"));return await installNpmPackageRuntimeDependencies(packageRoot),{directory:await resolvePackageExtensionDirectory(packageRoot,archivePath),package:typeof packageJson.name=="string"?packageJson.name:void 0,version:typeof packageJson.version=="string"?packageJson.version:void 0,cleanup:async()=>{await fs.rm(tempRoot,{recursive:!0,force:!0})}}}catch(error){throw await fs.rm(tempRoot,{recursive:!0,force:!0}),error}}async function installNpmPackageRuntimeDependencies(packageRoot,npmRunner=runNpmCommand){const packageJsonPath=path.join(packageRoot,"package.json");if(!await pathExists(packageJsonPath))return;let parsed;try{parsed=JSON.parse(await fs.readFile(packageJsonPath,"utf8"))}catch{return}if(typeof parsed!="object"||parsed===null)return;const manifest=parsed,dependencySpecs=runtimeDependencyInstallSpecs(manifest),shouldLinkHostedPmCli=hasHostedPmCliDependency(manifest);if(dependencySpecs.length===0&&!shouldLinkHostedPmCli)return;const runtimeOnlyManifest={...parsed};delete runtimeOnlyManifest.devDependencies;const installManifest={...runtimeOnlyManifest};removeHostedPmCliDependency(installManifest),await fs.writeFile(packageJsonPath,`${JSON.stringify(installManifest,null,2)}
4
- `,"utf8");try{await Promise.all([fs.rm(path.join(packageRoot,"package-lock.json"),{force:!0}),fs.rm(path.join(packageRoot,"npm-shrinkwrap.json"),{force:!0})]),dependencySpecs.length>0&&await npmRunner(["install","--ignore-scripts","--no-audit","--fund=false","--package-lock=false","--no-save","--omit=peer","--"],packageRoot),shouldLinkHostedPmCli&&await linkHostedPmCliDependency(packageRoot)}finally{await fs.writeFile(packageJsonPath,`${JSON.stringify(runtimeOnlyManifest,null,2)}
5
- `,"utf8")}}function hasHostedPmCliDependency(manifest){for(const dependencyMap of[manifest.dependencies,manifest.optionalDependencies,manifest.peerDependencies])if(typeof dependencyMap=="object"&&dependencyMap!==null&&PM_CLI_PACKAGE_NAME in dependencyMap)return!0;return!1}function removeHostedPmCliDependency(manifest){for(const field of["dependencies","optionalDependencies","peerDependencies"]){const dependencyMap=manifest[field];if(typeof dependencyMap!="object"||dependencyMap===null)continue;const nextMap={...dependencyMap};delete nextMap[PM_CLI_PACKAGE_NAME],Object.keys(nextMap).length===0?delete manifest[field]:manifest[field]=nextMap}}async function linkHostedPmCliDependency(packageRoot){const hostPackageRoot=resolvePmPackageRootFromModule(import.meta.url,["../../.."]),[scope,packageName]=PM_CLI_PACKAGE_NAME.split("/"),scopedDirectory=path.join(packageRoot,"node_modules",scope),linkPath=path.join(scopedDirectory,packageName);await fs.mkdir(scopedDirectory,{recursive:!0}),await fs.rm(linkPath,{recursive:!0,force:!0}),await fs.symlink(hostPackageRoot,linkPath,resolveDirectorySymlinkType(process.platform))}function resolveDirectorySymlinkType(platform){return platform==="win32"?"junction":"dir"}function validateRuntimeDependencySpec(name,version){if(name.startsWith("-"))throw new PmCliError(`Extension runtime dependency name "${name}" is unsafe because npm could interpret it as a command-line option.`,EXIT_CODE.USAGE,{code:"extension_dependency_name_unsafe",required:"Use a valid npm package name that does not begin with a dash.",why:"Extension manifests are untrusted input and dependency names must never become npm options."});if([...version].some(character=>{const codePoint=character.charCodeAt(0);return codePoint<=31||codePoint===127||"&|;()`\"'".includes(character)}))throw new PmCliError(`Extension runtime dependency "${name}" has an unsafe version specifier.`,EXIT_CODE.USAGE,{code:"extension_dependency_version_unsafe",required:"Use an npm version, range, dist-tag, URL, or file specifier without shell metacharacters.",why:"npm.cmd requires a command shell on Windows, so untrusted shell metacharacters cannot be forwarded."});try{npa.resolve(name,version)}catch{throw new PmCliError(`Extension runtime dependency "${name}@${version}" is not a valid npm dependency specifier.`,EXIT_CODE.USAGE,{code:"extension_dependency_spec_invalid",required:"Use a valid npm package name and npm-supported version, range, dist-tag, URL, or file specifier.",why:"Only grammar-validated dependency specs may be written to the isolated runtime install manifest."})}return`${name}@${version}`}function runtimeDependencyInstallSpecs(manifest){const specs=new Map;for(const dependencyMap of[manifest.dependencies,manifest.optionalDependencies,manifest.peerDependencies])if(!(typeof dependencyMap!="object"||dependencyMap===null))for(const[name,version]of Object.entries(dependencyMap)){if(name===PM_CLI_PACKAGE_NAME||typeof version!="string"||version.trim().length===0||specs.has(name))continue;const normalizedVersion=version.trim();specs.set(name,validateRuntimeDependencySpec(name,normalizedVersion))}return[...specs.values()]}async function resolvePackageExtensionDirectory(packageRoot,sourceLabel){const discovered=await collectPackageExtensionDirectories(packageRoot);if(discovered.length===1)return discovered[0];if(discovered.length>1){const choices=discovered.map(entry=>path.relative(packageRoot,entry).replaceAll(path.sep,"/")).sort((left,right)=>left.localeCompare(right));throw new PmCliError(`Package source "${sourceLabel}" contains multiple extension manifests. Provide an explicit extension path. Candidates: ${choices.join(", ")}`,EXIT_CODE.USAGE)}throw new PmCliError(`Unable to locate a pm extension manifest in package source "${sourceLabel}". Package installs currently activate only extension resources, so add package.json pm.extensions or an extensions/ directory. Metadata-only resources like pm.docs/pm.examples are catalog metadata and do not activate commands.`,EXIT_CODE.USAGE)}async function resolveGithubSourceDirectory(cloneDirectory,source){const candidatePaths=[];source.subpath&&(candidatePaths.push(source.subpath),candidatePaths.push(path.posix.join(".agents/pm/extensions",source.subpath)),candidatePaths.push(path.posix.join(".custom/pm-extensions",source.subpath)),candidatePaths.push(path.posix.join(".custom/pm-extension",source.subpath)));for(const candidate of candidatePaths){const absolute=path.resolve(cloneDirectory,candidate);if(isPathWithinDirectory(cloneDirectory,absolute)&&await pathExists(path.join(absolute,"manifest.json")))return{directory:absolute,resolved_subpath:candidate}}if(await pathExists(path.join(cloneDirectory,"manifest.json")))return{directory:cloneDirectory,resolved_subpath:"."};const discoveredDirectory=await resolvePackageExtensionDirectory(cloneDirectory,source.input);return{directory:discoveredDirectory,resolved_subpath:path.relative(cloneDirectory,discoveredDirectory).replaceAll(path.sep,"/")}}function looksLikeBarePackageName(input){const trimmed=input.trim();return trimmed.length===0||trimmed.startsWith(".")||trimmed.startsWith("~")?!1:trimmed.startsWith("@")?trimmed.split("/").length===2:!trimmed.includes("/")&&!trimmed.includes("\\")}async function buildLocalSourceNotFoundError(source){const baseMessage=`Local extension source does not exist: "${source.absolute_path}".`,input=source.input.trim();if(!looksLikeBarePackageName(input))return new PmCliError(baseMessage,EXIT_CODE.NOT_FOUND);let bundledAliases=[];try{const envPackageRoot=process.env.PM_CLI_PACKAGE_ROOT,cacheKey=typeof envPackageRoot=="string"&&envPackageRoot.trim().length>0?path.resolve(envPackageRoot.trim()):"";bundledPackageAliasesCache?.key!==cacheKey&&(bundledPackageAliasesCache={key:cacheKey,aliases:await listBundledPackageAliases()}),bundledAliases=bundledPackageAliasesCache.aliases}catch{}const nextSteps=[`Retry with pm package install npm:${input} if the package is published to npm.`,`Or inspect bundled packages with pm package catalog --project --json before installing by alias. Known aliases (blank means none found): ${bundledAliases.join(", ")}`];return new PmCliError(`${baseMessage} "${input}" did not match a local directory, bundled package alias, or bundled package name; if you meant an npm package, install it as "npm:${input}".`,EXIT_CODE.NOT_FOUND,{code:"local_source_not_found_bare_name",required:`Use "npm:${input}" for npm registry packages, a bundled catalog alias, or an existing local directory path.`,why:"Bare names resolve as local paths only after bundled aliases, so unmatched names need an explicit npm: source.",examples:[`pm package install npm:${input}`,"pm package catalog --project --json"],nextSteps,recovery:{attempted_command:`pm install ${input}`,normalized_args:["install",input],next_best_command:`pm package install npm:${input}`}})}async function resolveInstallSource(source){if(source.kind==="local"){let localStats;try{localStats=await fs.stat(source.absolute_path)}catch{throw await buildLocalSourceNotFoundError(source)}if(localStats.isFile()&&isLocalPackageArchive(source.absolute_path)){const resolved=await extractLocalPackageArchive(source.absolute_path);return{source,directory:resolved.directory,source_root:path.dirname(resolved.directory),resolved_subpath:path.relative(path.dirname(resolved.directory),resolved.directory).replaceAll(path.sep,"/"),npm_package:resolved.package,npm_version:resolved.version,cleanup:resolved.cleanup}}if(!localStats.isDirectory())throw new PmCliError(`Local extension source must be a directory or npm .tgz/.tar.gz archive: "${source.absolute_path}".`,EXIT_CODE.USAGE);const directory=await resolvePackageExtensionDirectory(source.absolute_path,source.input);return{source,directory,source_root:source.absolute_path}}if(source.kind==="npm"){const resolved=await resolveNpmSourceDirectory(source);return{source,directory:resolved.directory,source_root:path.dirname(resolved.directory),cleanup:resolved.cleanup,resolved_subpath:path.relative(path.dirname(resolved.directory),resolved.directory).replaceAll(path.sep,"/"),npm_package:resolved.package,npm_version:resolved.version}}const cloneDirectory=await fs.mkdtemp(path.join(os.tmpdir(),"pm-extension-source-")),cloneArgs=["clone","--depth","1"];source.ref&&cloneArgs.push("--branch",source.ref),cloneArgs.push(source.repository,cloneDirectory);try{await runGitCommand(cloneArgs);const commit=await runGitCommand(["-C",cloneDirectory,"rev-parse","HEAD"]),resolved=await resolveGithubSourceDirectory(cloneDirectory,source);return{source,directory:resolved.directory,source_root:cloneDirectory,resolved_subpath:resolved.resolved_subpath,commit,cleanup:async()=>{await fs.rm(cloneDirectory,{recursive:!0,force:!0})}}}catch(error){throw await fs.rm(cloneDirectory,{recursive:!0,force:!0}),error}}async function areDirectoriesEquivalent(left,right){if(!await pathExists(left)||!await pathExists(right))return!1;const[leftRealPath,rightRealPath]=await Promise.all([fs.realpath(left),fs.realpath(right)]);return leftRealPath===rightRealPath}const _testOnlyInstallSources={extractLocalPackageArchive,validateLocalPackageArchiveEntry,installNpmPackageRuntimeDependencies,npmPackageNameFromSpec,parsePackedNpmPackage,resolveNpmSourceDirectoryWithRunner,resolveNpmSourceDirectory,resolveNpmPackSpec,findInstalledNpmPackageCandidate,resolvePackageExtensionDirectory,runtimeDependencyInstallSpecs,hasHostedPmCliDependency,removeHostedPmCliDependency,linkHostedPmCliDependency,resolveDirectorySymlinkType,runNpmCommand};export{_testOnlyInstallSources,areDirectoriesEquivalent,buildNpmNotFoundRecovery,findInstalledNpmPackageCandidate,isNpmNotFoundError,isNpmPackNotFoundError,normalizeNpmLocalFileAliasSpec,parseExtensionInstallSource,resolveInstallSource,resolveNpmCommandName,runGitCommand,shouldRunNpmCommandInShell,wrapNpmPackResolutionError};
1
+ import{execFile as J}from"node:child_process";import l from"node:fs/promises";import k from"node:os";import c from"node:path";import{fileURLToPath as M}from"node:url";import{promisify as q}from"node:util";import T from"npm-package-arg";import{extract as H,list as K}from"tar";import{collectPackageExtensionDirectories as V}from"../../core/packages/manifest.js";import{resolvePmPackageRootFromModule as Z}from"../../core/packages/root.js";import{pathExists as m}from"../../core/fs/fs-utils.js";import{isPathWithinDirectory as X}from"../../core/fs/path-utils.js";import{EXIT_CODE as p}from"../../core/shared/constants.js";import{PmCliError as d}from"../../core/shared/errors.js";import{listBundledPackageAliases as Q}from"./bundled-catalog.js";const E=q(J),y="@unbrained/pm-cli",Y={maxArchiveBytes:64*1024*1024,maxEntries:4096,maxExpandedBytes:256*1024*1024,maxEntryBytes:64*1024*1024};let v;async function ee(e,n=process.cwd()){const t=e.trim();if(!/^(@[^/\\\s]+\/[^/\\\s]+|[^@/\\\s][^/\\\s]*)$/u.test(t))return null;let a=c.resolve(n);for(;;){const i=c.join(a,"node_modules",...t.split("/")),r=c.join(i,"package.json");if(await m(r))try{const s=JSON.parse(await l.readFile(r,"utf8"));if(s.name===t)return{package:t,...typeof s.version=="string"?{version:s.version}:{},directory:i}}catch{return null}const o=c.dirname(a);if(o===a)return null;a=o}}function b(e,n,t){const a=e.split("/").map(f=>f.trim()).filter(f=>f.length>0);if(a.length<2)return null;const i=a[0],r=a[1].replace(/\.git$/i,"");if(i.length===0||r.length===0)return null;const o=a.slice(2);let s,u;return o[0]==="tree"&&o.length>=2?(s=o[1],u=o.slice(2).join("/")):o.length>0&&(u=o.join("/")),typeof t=="string"&&t.trim().length>0&&(s=t.trim()),{kind:"github",input:n,owner:i,repo:r,repository:`https://github.com/${i}/${r}.git`,ref:s,subpath:u&&u.length>0?u:void 0}}function te(e,n,t){const a=e.slice(4).trim();if(a.length===0)throw new d('npm package source must include a package spec after "npm:".',p.USAGE);if(n)throw new d('Options "--gh/--github" cannot be combined with npm: package sources.',p.USAGE);if(t)throw new d('Option "--ref" cannot be combined with npm: package sources.',p.USAGE);return{kind:"npm",input:e,spec:a}}function Le(e,n={}){const t=e.trim();if(t.length===0)throw new d("Extension source is required for --install.",p.USAGE);const a=typeof n.ref=="string"&&n.ref.trim().length>0?n.ref.trim():void 0;if(t.startsWith("npm:"))return te(t,n.forceGithub===!0,a);const i=(()=>{try{const o=new URL(t);if(o.hostname!=="github.com")return null;const s=o.pathname.replace(/^\/+/,"");return b(s,t,a)}catch{return null}})();if(i)return i;const r=t.startsWith("github.com/")?t.slice(11):null;if(r){const o=b(r,t,a);if(!o)throw new d(`Invalid GitHub source "${t}".`,p.USAGE);return o}if(n.forceGithub){const o=b(t,t,a);if(!o)throw new d(`Invalid GitHub shorthand "${t}".`,p.USAGE);return o}if(/^https?:\/\//i.test(t))throw new d(`Unsupported extension source URL "${t}". Supported remote source host: github.com.`,p.USAGE);return{kind:"local",input:t,absolute_path:c.resolve(process.cwd(),t)}}async function j(e,n=E,t){try{return((await n("git",e,{encoding:"utf8",timeout:t})).stdout??"").trim()}catch(a){const i=typeof a=="object"&&a!==null&&"stderr"in a?String(a.stderr):"",r=i.trim().length>0?i.trim():a instanceof Error?a.message:String(a);throw new d(`Git command failed: git ${e.join(" ")}
2
+ ${r}`,p.GENERIC_FAILURE)}}function ne(e=process.platform){return e==="win32"?"npm.cmd":"npm"}function ae(e=process.platform){return e==="win32"}async function x(e,n,t=E,a=process.platform,i=process.env){const r=ne(a),o=Object.fromEntries(Object.entries(i).filter(([s])=>s.toLowerCase()!=="npm_config_allow_scripts"));o.NPM_CONFIG_ALLOW_SCRIPTS="";try{return((await t(r,e,{cwd:n,encoding:"utf8",env:o,shell:ae(a)})).stdout??"").trim()}catch(s){const u=typeof s=="object"&&s!==null&&"stderr"in s?String(s.stderr):"",f=u.trim().length>0?u.trim():s instanceof Error?s.message:String(s);throw new d(`npm command failed: ${r} ${e.join(" ")}
3
+ ${f}`,p.GENERIC_FAILURE)}}function _(e){const n=e.trim(),t=n.includes("@file:")?n.slice(0,n.lastIndexOf("@file:")):n;return t.startsWith("@")?t.match(/^(@[^/@\s]+\/[^/@\s]+)/)?.[1]??t:t.match(/^([^/@\s]+)/)?.[1]??t}function P(e){const n="@file:",t=e.lastIndexOf(n);return t>0&&e.slice(0,t).trim().length>0&&e.slice(t+n.length).trim().length>0}function re(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes("npm err! code e404")||t.includes("404 not found")||t.includes("is not in this registry")}function ie(e){const t=(e instanceof Error?e.message:String(e)).toLowerCase();return re(e)||t.includes("not found")}function oe(e){const n=e.trim().toLowerCase();return n.startsWith("@unbrained/pm-")||n.startsWith("pm-")}function se(e){const n=_(e),t=oe(n),a=n.replace(/^.*\//,""),i=t?`github.com/unbraind/${a}`:void 0,r=i?`pm package install --project ${i}`:void 0;return{message:t?`npm package "${e}" was not found in the registry. If this is an unpublished first-party pm package, install its GitHub repository instead.`:`npm package "${e}" was not found in the registry.`,context:{code:"npm_package_not_found",required:"Use an install source that exists, or publish the npm package before installing it with npm:<name>.",why:"Classifying npm 404s avoids repeated registry retries and gives agents a deterministic fallback path.",examples:r?[r,"pm package catalog --project --json"]:[`npm view ${n}`,"pm package catalog --project --json"],nextSteps:r?[`Try ${r} if the repository exists.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."]:[`Verify ${n} exists in the npm registry and that you have access to it.`,"Use pm package catalog --project --json to inspect bundled package aliases before installing."],recovery:{attempted_command:`pm install --project npm:${e}`,normalized_args:["install","--project",`npm:${e}`],...i&&r?{fallback_candidates:[{source:i,command:r,reason:"canonical first-party GitHub repository fallback for unpublished pm packages"}],next_best_command:r}:{}}}}}function ce(e,n){if(!ie(n))return null;const t=se(e);return new d(t.message,p.NOT_FOUND,t.context)}async function S(e){if(c.isAbsolute(e)||e.startsWith(".")||e.startsWith("..")){const n=c.resolve(process.cwd(),e);return await m(n)?n:null}try{const n=new URL(e);if(n.protocol==="file:"){const t=M(n);return await m(t)?t:null}}catch{}if(!/^[a-z][a-z0-9+.-]*:/i.test(e)){const n=c.resolve(process.cwd(),e);if(await m(n))return n}return null}async function $(e){const n=await S(e);if(n)return n;const t=le(e);return t!==e?t:(/^[a-z][a-z0-9+.-]*:/i.test(e),e)}function le(e,n=process.cwd()){const t="@file:",a=e.lastIndexOf(t);if(!P(e))return e;const i=e.slice(0,a),r=e.slice(a+t.length);if(r.startsWith("//")&&!r.startsWith("///"))return e;if(!r.startsWith("/"))return`${i}@${c.resolve(n,r)}`;let o;try{o=decodeURIComponent(new URL(`file:${r}`).pathname)}catch{return e}const s=/^\/[A-Za-z]:/.test(o)?o.slice(1):o;return`${i}@${s}`}function A(e,n){const t=c.resolve(e,n),a=c.relative(e,t);if(a.length===0||a===".."||a.startsWith(`..${c.sep}`)||c.isAbsolute(a))throw new d("npm pack reported a package archive outside its isolated destination.",p.GENERIC_FAILURE,{code:"npm_package_archive_unsafe",required:"Retry with a trusted npm client that writes its archive inside the requested pack destination.",why:"pm will not read a package-manager artifact outside the isolated directory created for this install."});return t}function pe(e,n){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(!(typeof t.filename!="string"||t.filename.trim().length===0))return{...n===void 0?{}:{key:n},filename:t.filename,...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{}}}function de(e){return(Array.isArray(e)?e.map(t=>({value:t})):typeof e=="object"&&e!==null?Object.entries(e).map(([t,a])=>({key:t,value:a})):[]).flatMap(({key:t,value:a})=>{const i=pe(a,t);return i?[i]:[]})}function ue(e,n){const t=n?.trim().toLowerCase(),a=t?e.filter(o=>{const s=o.name?.trim().toLowerCase();return s!==void 0?s===t:o.key?.trim().toLowerCase()===t}):[];if(a.length===1)return a[0];if(e.length!==1)return;const i=e[0],r=i.name??i.key;return t&&r!==void 0&&r.trim().toLowerCase()!==t?void 0:i}function N(e,n,t){let a;try{a=JSON.parse(e)}catch{const o=e.split(/\r?\n/).map(s=>s.trim()).filter(s=>s.length>0).at(-1);if(!o)throw new d("npm pack did not report a tarball filename.",p.GENERIC_FAILURE);return{tarball:A(n,o)}}const i=de(a),r=ue(i,t);if(!r)throw new d("npm pack --json returned an unsupported or ambiguous package receipt.",p.GENERIC_FAILURE,{code:"npm_pack_json_shape_unsupported",required:"Use an npm client that returns an array of package receipts or an object keyed by package name, with exactly one requested package entry containing filename.",why:`Well-formed JSON contained ${i.length} usable package receipt(s), but pm could not select ${t??"one package"} deterministically.`});return{tarball:A(n,r.filename),package:r.name??r.key,version:r.version}}async function C(e){return L(e,x)}async function L(e,n){const t=await S(e.spec);if(t){if((await l.stat(t)).isFile()&&U(t))return w(t);const o=c.join(t,"package.json"),s=await m(o)?JSON.parse(await l.readFile(o,"utf8")):{};return{directory:await g(t,e.input),package:typeof s.name=="string"?s.name:void 0,version:typeof s.version=="string"?s.version:void 0,cleanup:async()=>{}}}const a=await l.mkdtemp(c.join(k.tmpdir(),"pm-npm-package-source-")),i=c.join(a,"pack");await l.mkdir(i,{recursive:!0});try{const r=await $(e.spec),o=await n(["pack",r,"--json","--pack-destination",i]),s=N(o,i,P(e.spec)?void 0:_(e.spec));if(!await m(s.tarball))throw new d("npm pack did not create its reported package archive.",p.GENERIC_FAILURE,{code:"npm_package_archive_missing",required:"Retry the npm package install with a healthy registry and writable temporary directory.",why:"The package manager reported a tarball filename that was absent before validation, so pm cannot safely extract or install it."});const u=await w(s.tarball);return{directory:u.directory,package:s.package??u.package,version:s.version??u.version,cleanup:async()=>{try{await u.cleanup()}finally{await l.rm(a,{recursive:!0,force:!0})}}}}catch(r){await l.rm(a,{recursive:!0,force:!0});const o=ce(e.spec,r);throw o||r}}function U(e){const n=e.toLowerCase();return n.endsWith(".tgz")||n.endsWith(".tar.gz")}function h(e){throw new d(e,p.USAGE,{code:"local_package_archive_unsafe",required:"Use a bounded npm .tgz or .tar.gz archive with one package/ root and no links or escaping paths.",why:"Package archives are untrusted input and must be validated before any entry reaches the filesystem."})}function R(e,n,t){if(e.meta)return;t.entries+=1,t.entries>n.maxEntries&&h(`Local package archive exceeds the ${n.maxEntries} entry limit.`);const a=e.path,i=a.split("/");(a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||i.some(r=>r===".."))&&h(`Local package archive contains an escaping path: "${a}".`),i[0]!=="package"&&h(`Local package archive entry "${a}" is outside the required package/ root.`),(e.type==="SymbolicLink"||e.type==="Link")&&h(`Local package archive link "${a}" is not supported.`),e.type!=="File"&&e.type!=="OldFile"&&e.type!=="Directory"&&h(`Local package archive entry "${a}" uses unsupported type "${e.type}".`),e.size>n.maxEntryBytes&&h(`Local package archive entry "${a}" exceeds the ${n.maxEntryBytes} byte entry limit.`),t.expandedBytes+=e.size,t.expandedBytes>n.maxExpandedBytes&&h(`Local package archive exceeds the ${n.maxExpandedBytes} expanded byte limit.`),a==="package/package.json"&&(t.packageJsonEntries+=1)}async function w(e,n=Y){(await l.stat(e)).size>n.maxArchiveBytes&&h(`Local package archive exceeds the ${n.maxArchiveBytes} archive byte limit.`);const a=await l.mkdtemp(c.join(k.tmpdir(),"pm-local-package-archive-")),i=c.join(a,"extract");await l.mkdir(i,{recursive:!0});const r={entries:0,expandedBytes:0,packageJsonEntries:0};let o;try{if(await K({file:e,strict:!0,maxDecompressionRatio:100,onReadEntry:W=>{if(o===void 0)try{R(W,n,r)}catch(B){o=B}}}),o!==void 0)throw o;r.packageJsonEntries!==1&&h(`Local package archive must contain exactly one package/package.json entry; found ${r.packageJsonEntries}.`),await H({file:e,cwd:i,strict:!0,preservePaths:!1,preserveOwner:!1,noMtime:!0,unlink:!0,maxDepth:64,maxDecompressionRatio:100});const s=c.join(i,"package"),u=c.join(s,"package.json"),f=JSON.parse(await l.readFile(u,"utf8"));return await I(s),{directory:await g(s,e),package:typeof f.name=="string"?f.name:void 0,version:typeof f.version=="string"?f.version:void 0,cleanup:async()=>{await l.rm(a,{recursive:!0,force:!0})}}}catch(s){throw await l.rm(a,{recursive:!0,force:!0}),s}}async function I(e,n=x){const t=c.join(e,"package.json");if(!await m(t))return;let a;try{a=JSON.parse(await l.readFile(t,"utf8"))}catch{return}if(typeof a!="object"||a===null)return;const i=a,r=z(i),o=O(i);if(r.length===0&&!o)return;const s={...a};delete s.devDependencies;const u={...s};G(u),await l.writeFile(t,`${JSON.stringify(u,null,2)}
4
+ `,"utf8");try{await Promise.all([l.rm(c.join(e,"package-lock.json"),{force:!0}),l.rm(c.join(e,"npm-shrinkwrap.json"),{force:!0})]),r.length>0&&await n(["install","--ignore-scripts","--no-audit","--fund=false","--package-lock=false","--no-save","--omit=peer","--"],e),o&&await F(e)}finally{await l.writeFile(t,`${JSON.stringify(s,null,2)}
5
+ `,"utf8")}}function O(e){for(const n of[e.dependencies,e.optionalDependencies,e.peerDependencies])if(typeof n=="object"&&n!==null&&y in n)return!0;return!1}function G(e){for(const n of["dependencies","optionalDependencies","peerDependencies"]){const t=e[n];if(typeof t!="object"||t===null)continue;const a={...t};delete a[y],Object.keys(a).length===0?delete e[n]:e[n]=a}}async function F(e){const n=Z(import.meta.url,["../../.."]),[t,a]=y.split("/"),i=c.join(e,"node_modules",t),r=c.join(i,a);await l.mkdir(i,{recursive:!0}),await l.rm(r,{recursive:!0,force:!0}),await l.symlink(n,r,D(process.platform))}function D(e){return e==="win32"?"junction":"dir"}function me(e,n){if(e.startsWith("-"))throw new d(`Extension runtime dependency name "${e}" is unsafe because npm could interpret it as a command-line option.`,p.USAGE,{code:"extension_dependency_name_unsafe",required:"Use a valid npm package name that does not begin with a dash.",why:"Extension manifests are untrusted input and dependency names must never become npm options."});if([...n].some(a=>{const i=a.charCodeAt(0);return i<=31||i===127||"&|;()`\"'".includes(a)}))throw new d(`Extension runtime dependency "${e}" has an unsafe version specifier.`,p.USAGE,{code:"extension_dependency_version_unsafe",required:"Use an npm version, range, dist-tag, URL, or file specifier without shell metacharacters.",why:"npm.cmd requires a command shell on Windows, so untrusted shell metacharacters cannot be forwarded."});try{T.resolve(e,n)}catch{throw new d(`Extension runtime dependency "${e}@${n}" is not a valid npm dependency specifier.`,p.USAGE,{code:"extension_dependency_spec_invalid",required:"Use a valid npm package name and npm-supported version, range, dist-tag, URL, or file specifier.",why:"Only grammar-validated dependency specs may be written to the isolated runtime install manifest."})}return`${e}@${n}`}function z(e){const n=new Map;for(const t of[e.dependencies,e.optionalDependencies,e.peerDependencies])if(!(typeof t!="object"||t===null))for(const[a,i]of Object.entries(t)){if(a===y||typeof i!="string"||i.trim().length===0||n.has(a))continue;const r=i.trim();n.set(a,me(a,r))}return[...n.values()]}async function g(e,n){const t=await V(e);if(t.length===1)return t[0];if(t.length>1){const a=t.map(i=>c.relative(e,i).replaceAll(c.sep,"/")).sort((i,r)=>i.localeCompare(r));throw new d(`Package source "${n}" contains multiple extension manifests. Provide an explicit extension path. Candidates: ${a.join(", ")}`,p.USAGE)}throw new d(`Unable to locate a pm extension manifest in package source "${n}". Package installs currently activate only extension resources, so add package.json pm.extensions or an extensions/ directory. Metadata-only resources like pm.docs/pm.examples are catalog metadata and do not activate commands.`,p.USAGE)}async function fe(e,n){const t=[];n.subpath&&(t.push(n.subpath),t.push(c.posix.join(".agents/pm/extensions",n.subpath)),t.push(c.posix.join(".custom/pm-extensions",n.subpath)),t.push(c.posix.join(".custom/pm-extension",n.subpath)));for(const i of t){const r=c.resolve(e,i);if(X(e,r)&&await m(c.join(r,"manifest.json")))return{directory:r,resolved_subpath:i}}if(await m(c.join(e,"manifest.json")))return{directory:e,resolved_subpath:"."};const a=await g(e,n.input);return{directory:a,resolved_subpath:c.relative(e,a).replaceAll(c.sep,"/")}}function he(e){const n=e.trim();return n.length===0||n.startsWith(".")||n.startsWith("~")?!1:n.startsWith("@")?n.split("/").length===2:!n.includes("/")&&!n.includes("\\")}async function ge(e){const n=`Local extension source does not exist: "${e.absolute_path}".`,t=e.input.trim();if(!he(t))return new d(n,p.NOT_FOUND);let a=[];try{const r=process.env.PM_CLI_PACKAGE_ROOT,o=typeof r=="string"&&r.trim().length>0?c.resolve(r.trim()):"";v?.key!==o&&(v={key:o,aliases:await Q()}),a=v.aliases}catch{}const i=[`Retry with pm package install npm:${t} if the package is published to npm.`,`Or inspect bundled packages with pm package catalog --project --json before installing by alias. Known aliases (blank means none found): ${a.join(", ")}`];return new d(`${n} "${t}" did not match a local directory, bundled package alias, or bundled package name; if you meant an npm package, install it as "npm:${t}".`,p.NOT_FOUND,{code:"local_source_not_found_bare_name",required:`Use "npm:${t}" for npm registry packages, a bundled catalog alias, or an existing local directory path.`,why:"Bare names resolve as local paths only after bundled aliases, so unmatched names need an explicit npm: source.",examples:[`pm package install npm:${t}`,"pm package catalog --project --json"],nextSteps:i,recovery:{attempted_command:`pm install ${t}`,normalized_args:["install",t],next_best_command:`pm package install npm:${t}`}})}async function Ue(e){if(e.kind==="local"){let a;try{a=await l.stat(e.absolute_path)}catch{throw await ge(e)}if(a.isFile()&&U(e.absolute_path)){const r=await w(e.absolute_path);return{source:e,directory:r.directory,source_root:c.dirname(r.directory),resolved_subpath:c.relative(c.dirname(r.directory),r.directory).replaceAll(c.sep,"/"),npm_package:r.package,npm_version:r.version,cleanup:r.cleanup}}if(!a.isDirectory())throw new d(`Local extension source must be a directory or npm .tgz/.tar.gz archive: "${e.absolute_path}".`,p.USAGE);const i=await g(e.absolute_path,e.input);return{source:e,directory:i,source_root:e.absolute_path}}if(e.kind==="npm"){const a=await C(e);return{source:e,directory:a.directory,source_root:c.dirname(a.directory),cleanup:a.cleanup,resolved_subpath:c.relative(c.dirname(a.directory),a.directory).replaceAll(c.sep,"/"),npm_package:a.package,npm_version:a.version}}const n=await l.mkdtemp(c.join(k.tmpdir(),"pm-extension-source-")),t=["clone","--depth","1"];e.ref&&t.push("--branch",e.ref),t.push(e.repository,n);try{await j(t);const a=await j(["-C",n,"rev-parse","HEAD"]),i=await fe(n,e);return{source:e,directory:i.directory,source_root:n,resolved_subpath:i.resolved_subpath,commit:a,cleanup:async()=>{await l.rm(n,{recursive:!0,force:!0})}}}catch(a){throw await l.rm(n,{recursive:!0,force:!0}),a}}async function Re(e,n){if(!await m(e)||!await m(n))return!1;const[t,a]=await Promise.all([l.realpath(e),l.realpath(n)]);return t===a}const Ie={extractLocalPackageArchive:w,validateLocalPackageArchiveEntry:R,installNpmPackageRuntimeDependencies:I,npmPackageNameFromSpec:_,parsePackedNpmPackage:N,resolveNpmSourceDirectoryWithRunner:L,resolveNpmSourceDirectory:C,resolveNpmPackSpec:$,findInstalledNpmPackageCandidate:ee,resolvePackageExtensionDirectory:g,runtimeDependencyInstallSpecs:z,hasHostedPmCliDependency:O,removeHostedPmCliDependency:G,linkHostedPmCliDependency:F,resolveDirectorySymlinkType:D,runNpmCommand:x};export{Ie as _testOnlyInstallSources,Re as areDirectoriesEquivalent,se as buildNpmNotFoundRecovery,ee as findInstalledNpmPackageCandidate,re as isNpmNotFoundError,ie as isNpmPackNotFoundError,le as normalizeNpmLocalFileAliasSpec,Le as parseExtensionInstallSource,Ue as resolveInstallSource,ne as resolveNpmCommandName,j as runGitCommand,ae as shouldRunNpmCommandInShell,ce as wrapNpmPackResolutionError};
6
6
  //# sourceMappingURL=install-sources.js.map
@@ -1,3 +1,3 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="054bae8c-464f-5791-a78a-063588565393")}catch{}})();import{isFileMissingError}from"../../core/fs/fs-utils.js";import fs from"node:fs/promises";import path from"node:path";import{EXIT_CODE}from"../../core/shared/constants.js";import{PmCliError}from"../../core/shared/errors.js";import{nowIso}from"../../core/shared/time.js";import{normalizeExtensionContributionInventory}from"../../core/extensions/contribution-inventory.js";import{normalizeExtensionNameForMatch,normalizeStringList}from"./shared.js";const MANAGED_EXTENSION_STATE_FILENAME=".managed-extensions.json",MANAGED_EXTENSION_STATE_VERSION=1;function resolveManagedExtensionStatePath(extensionsRoot){return path.join(extensionsRoot,MANAGED_EXTENSION_STATE_FILENAME)}function createEmptyManagedExtensionState(){return{version:MANAGED_EXTENSION_STATE_VERSION,updated_at:nowIso(),entries:[]}}function sortManagedEntries(entries){return[...entries].sort((left,right)=>{const byScope=left.scope.localeCompare(right.scope);if(byScope!==0)return byScope;const byName=left.name.localeCompare(right.name);return byName!==0?byName:left.directory.localeCompare(right.directory)})}function managedExtensionSourcesEquivalent(left,right){return left.kind!==right.kind||left.input!==right.input||left.location!==right.location?!1:left.kind==="npm"&&right.kind==="npm"?left.package===right.package&&left.version===right.version:left.kind==="github"&&right.kind==="github"?left.repository===right.repository&&left.ref===right.ref&&left.subpath===right.subpath&&left.commit===right.commit:left.kind==="builtin"&&right.kind==="builtin"?left.name===right.name:!0}function optionalString(value){return typeof value=="string"?value:void 0}const TIMED_OUT_UPDATE_ERROR=/^(?:npm_registry|github_remote)_lookup_timed_out$/u;function stableUpdateError(source,value){const error=optionalString(value);return error===void 0||source.kind!=="github"||error.trim().length===0||/^[a-z0-9_]+$/u.test(error.trim())?error:"github_remote_lookup_failed"}function isTimedOutUpdateError(error){return typeof error=="string"&&TIMED_OUT_UPDATE_ERROR.test(error.trim())}function optionalTimeoutBudget(error,value){return isTimedOutUpdateError(error)&&typeof value=="number"&&Number.isSafeInteger(value)&&value>0?{update_check_timeout_ms:value}:{}}function hasRequiredManagedRecordFields(entry){return typeof entry.name=="string"&&entry.name.trim().length>0&&typeof entry.directory=="string"&&entry.directory.trim().length>0&&(entry.scope==="project"||entry.scope==="global")&&typeof entry.manifest_version=="string"&&typeof entry.manifest_entry=="string"&&Array.isArray(entry.capabilities)&&entry.capabilities.every(value=>typeof value=="string")&&typeof entry.installed_at=="string"&&typeof entry.updated_at=="string"}function normalizeManagedSource(raw){if(typeof raw!="object"||raw===null)return null;const source=raw;return source.kind!=="local"&&source.kind!=="github"&&source.kind!=="npm"&&source.kind!=="builtin"||typeof source.input!="string"||typeof source.location!="string"?null:{kind:source.kind,input:source.input,location:source.location,name:optionalString(source.name),package:optionalString(source.package),version:optionalString(source.version),repository:optionalString(source.repository),owner:optionalString(source.owner),repo:optionalString(source.repo),ref:optionalString(source.ref),subpath:optionalString(source.subpath),commit:optionalString(source.commit)}}function normalizeManagedRecord(raw){if(typeof raw!="object"||raw===null)return null;const entry=raw;if(!hasRequiredManagedRecordFields(entry))return null;const source=normalizeManagedSource(entry.source);if(!source)return null;const contributions=normalizeExtensionContributionInventory(entry.contributions);return contributions===null?null:{name:entry.name.trim(),directory:entry.directory.trim(),scope:entry.scope,manifest_version:entry.manifest_version,manifest_entry:entry.manifest_entry,capabilities:normalizeStringList(entry.capabilities),contributions,installed_at:entry.installed_at,updated_at:entry.updated_at,source,last_update_check_at:optionalString(entry.last_update_check_at),last_update_remote_commit:optionalString(entry.last_update_remote_commit),last_update_remote_version:optionalString(entry.last_update_remote_version),update_available:isTimedOutUpdateError(entry.update_error)?null:typeof entry.update_available=="boolean"||entry.update_available===null?entry.update_available:void 0,update_error:stableUpdateError(source,entry.update_error),...optionalTimeoutBudget(entry.update_error,entry.update_check_timeout_ms)}}function normalizeManagedState(raw){if(typeof raw!="object"||raw===null)return null;const candidate=raw;if(candidate.version!==MANAGED_EXTENSION_STATE_VERSION||!Array.isArray(candidate.entries))return null;const entries=[];for(const rawEntry of candidate.entries){const record=normalizeManagedRecord(rawEntry);record&&entries.push(record)}return{version:MANAGED_EXTENSION_STATE_VERSION,updated_at:optionalString(candidate.updated_at)??nowIso(),entries:sortManagedEntries(entries)}}async function readManagedExtensionState(extensionsRoot){const statePath=resolveManagedExtensionStatePath(extensionsRoot),fallback=createEmptyManagedExtensionState();try{const raw=await fs.readFile(statePath,"utf8"),parsed=JSON.parse(raw),normalized=normalizeManagedState(parsed);if(!normalized)throw new PmCliError(`Managed extension state file "${statePath}" has an invalid schema. Repair or remove it before mutating extension state.`,EXIT_CODE.GENERIC_FAILURE);return{path:statePath,state:normalized,warnings:[]}}catch(error){if(error instanceof PmCliError)throw error;if(typeof error=="object"&&error!==null&&"code"in error&&isFileMissingError(error))return{path:statePath,state:fallback,warnings:[]};throw new PmCliError(`Managed extension state file "${statePath}" could not be read. Repair or remove it before mutating extension state.`,EXIT_CODE.GENERIC_FAILURE)}}async function writeManagedExtensionState(extensionsRoot,state){const statePath=resolveManagedExtensionStatePath(extensionsRoot),normalized={version:MANAGED_EXTENSION_STATE_VERSION,updated_at:nowIso(),entries:sortManagedEntries(state.entries)};await fs.mkdir(extensionsRoot,{recursive:!0}),await fs.writeFile(statePath,`${JSON.stringify(normalized,null,2)}
2
- `,"utf8")}function upsertManagedEntry(state,entry){const updatedEntries=state.entries.filter(candidate=>normalizeExtensionNameForMatch(candidate.name)!==normalizeExtensionNameForMatch(entry.name)&&normalizeExtensionNameForMatch(candidate.directory)!==normalizeExtensionNameForMatch(entry.directory));return updatedEntries.push(entry),{...state,updated_at:nowIso(),entries:sortManagedEntries(updatedEntries)}}async function persistManagedContributionInventory(extensionsRoot,state,extensionName,contributions){const entry=state.entries.find(candidate=>normalizeExtensionNameForMatch(candidate.name)===normalizeExtensionNameForMatch(extensionName));if(!entry)return state;const updated=upsertManagedEntry(state,{...entry,contributions});return await writeManagedExtensionState(extensionsRoot,updated),updated}export{createEmptyManagedExtensionState,managedExtensionSourcesEquivalent,normalizeManagedState,persistManagedContributionInventory,readManagedExtensionState,resolveManagedExtensionStatePath,sortManagedEntries,upsertManagedEntry,writeManagedExtensionState};
1
+ import{isFileMissingError as y}from"../../core/fs/fs-utils.js";import c from"node:fs/promises";import E from"node:path";import{EXIT_CODE as l}from"../../core/shared/constants.js";import{PmCliError as d}from"../../core/shared/errors.js";import{nowIso as u}from"../../core/shared/time.js";import{normalizeExtensionContributionInventory as g}from"../../core/extensions/contribution-inventory.js";import{normalizeExtensionNameForMatch as a,normalizeStringList as k}from"./shared.js";const v=".managed-extensions.json",p=1;function f(t){return E.join(t,v)}function x(){return{version:p,updated_at:u(),entries:[]}}function m(t){return[...t].sort((e,n)=>{const r=e.scope.localeCompare(n.scope);if(r!==0)return r;const i=e.name.localeCompare(n.name);return i!==0?i:e.directory.localeCompare(n.directory)})}function $(t,e){return t.kind!==e.kind||t.input!==e.input||t.location!==e.location?!1:t.kind==="npm"&&e.kind==="npm"?t.package===e.package&&t.version===e.version:t.kind==="github"&&e.kind==="github"?t.repository===e.repository&&t.ref===e.ref&&t.subpath===e.subpath&&t.commit===e.commit:t.kind==="builtin"&&e.kind==="builtin"?t.name===e.name:!0}function o(t){return typeof t=="string"?t:void 0}const h=/^(?:npm_registry|github_remote)_lookup_timed_out$/u;function M(t,e){const n=o(e);return n===void 0||t.kind!=="github"||n.trim().length===0||/^[a-z0-9_]+$/u.test(n.trim())?n:"github_remote_lookup_failed"}function _(t){return typeof t=="string"&&h.test(t.trim())}function S(t,e){return _(t)&&typeof e=="number"&&Number.isSafeInteger(e)&&e>0?{update_check_timeout_ms:e}:{}}function N(t){return typeof t.name=="string"&&t.name.trim().length>0&&typeof t.directory=="string"&&t.directory.trim().length>0&&(t.scope==="project"||t.scope==="global")&&typeof t.manifest_version=="string"&&typeof t.manifest_entry=="string"&&Array.isArray(t.capabilities)&&t.capabilities.every(e=>typeof e=="string")&&typeof t.installed_at=="string"&&typeof t.updated_at=="string"}function A(t){if(typeof t!="object"||t===null)return null;const e=t;return e.kind!=="local"&&e.kind!=="github"&&e.kind!=="npm"&&e.kind!=="builtin"||typeof e.input!="string"||typeof e.location!="string"?null:{kind:e.kind,input:e.input,location:e.location,name:o(e.name),package:o(e.package),version:o(e.version),repository:o(e.repository),owner:o(e.owner),repo:o(e.repo),ref:o(e.ref),subpath:o(e.subpath),commit:o(e.commit)}}function I(t){if(typeof t!="object"||t===null)return null;const e=t;if(!N(e))return null;const n=A(e.source);if(!n)return null;const r=g(e.contributions);return r===null?null:{name:e.name.trim(),directory:e.directory.trim(),scope:e.scope,manifest_version:e.manifest_version,manifest_entry:e.manifest_entry,capabilities:k(e.capabilities),contributions:r,installed_at:e.installed_at,updated_at:e.updated_at,source:n,last_update_check_at:o(e.last_update_check_at),last_update_remote_commit:o(e.last_update_remote_commit),last_update_remote_version:o(e.last_update_remote_version),update_available:_(e.update_error)?null:typeof e.update_available=="boolean"||e.update_available===null?e.update_available:void 0,update_error:M(n,e.update_error),...S(e.update_error,e.update_check_timeout_ms)}}function w(t){if(typeof t!="object"||t===null)return null;const e=t;if(e.version!==p||!Array.isArray(e.entries))return null;const n=[];for(const r of e.entries){const i=I(r);i&&n.push(i)}return{version:p,updated_at:o(e.updated_at)??u(),entries:m(n)}}async function G(t){const e=f(t),n=x();try{const r=await c.readFile(e,"utf8"),i=JSON.parse(r),s=w(i);if(!s)throw new d(`Managed extension state file "${e}" has an invalid schema. Repair or remove it before mutating extension state.`,l.GENERIC_FAILURE);return{path:e,state:s,warnings:[]}}catch(r){if(r instanceof d)throw r;if(typeof r=="object"&&r!==null&&"code"in r&&y(r))return{path:e,state:n,warnings:[]};throw new d(`Managed extension state file "${e}" could not be read. Repair or remove it before mutating extension state.`,l.GENERIC_FAILURE)}}async function R(t,e){const n=f(t),r={version:p,updated_at:u(),entries:m(e.entries)};await c.mkdir(t,{recursive:!0}),await c.writeFile(n,`${JSON.stringify(r,null,2)}
2
+ `,"utf8")}function T(t,e){const n=t.entries.filter(r=>a(r.name)!==a(e.name)&&a(r.directory)!==a(e.directory));return n.push(e),{...t,updated_at:u(),entries:m(n)}}async function L(t,e,n,r){const i=e.entries.find(b=>a(b.name)===a(n));if(!i)return e;const s=T(e,{...i,contributions:r});return await R(t,s),s}export{x as createEmptyManagedExtensionState,$ as managedExtensionSourcesEquivalent,w as normalizeManagedState,L as persistManagedContributionInventory,G as readManagedExtensionState,f as resolveManagedExtensionStatePath,m as sortManagedEntries,T as upsertManagedEntry,R as writeManagedExtensionState};
3
3
  //# sourceMappingURL=managed-state.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4f307be2-a113-558f-be2e-8b8f209285a5")}catch{}})();import{mapWithFixedConcurrency}from"./concurrency.js";import{sortManagedEntries}from"./managed-state.js";import{checkGithubUpdate,checkNpmUpdate,resolveExtensionUpdateCheckTimeoutMs,updateCheckTeardown}from"./update-check.js";const MANAGED_UPDATE_CHECK_CONCURRENCY=4;function createPermits(limit){let free=limit;const waiters=[];return{acquire:()=>free>0?(free-=1,Promise.resolve()):new Promise(resolve=>waiters.push(resolve)),release:()=>{const next=waiters.shift();next?next():free+=1}}}function withUpdateCheckTimeout(entry,timeoutMs){const{update_check_timeout_ms:_previous,...rest}=entry;return timeoutMs===void 0?rest:{...rest,update_check_timeout_ms:timeoutMs}}async function refreshManagedExtensionUpdates(state,offline=!1,timeoutMs=resolveExtensionUpdateCheckTimeoutMs(),holdPermitsThroughTeardown=!0){const providers=createPermits(MANAGED_UPDATE_CHECK_CONCURRENCY),entries=await mapWithFixedConcurrency(state.entries,MANAGED_UPDATE_CHECK_CONCURRENCY,async entry=>{if(!["github","npm"].includes(entry.source.kind))return entry;if(offline)return withUpdateCheckTimeout({...entry,last_update_check_at:void 0,last_update_remote_commit:void 0,last_update_remote_version:void 0,update_available:null,update_error:void 0},void 0);await providers.acquire();const updateStatus=entry.source.kind==="github"?await checkGithubUpdate(entry.source,void 0,timeoutMs):await checkNpmUpdate(entry.source,void 0,timeoutMs);return holdPermitsThroughTeardown?updateCheckTeardown(updateStatus).then(providers.release):providers.release(),withUpdateCheckTimeout({...entry,last_update_check_at:updateStatus.checked_at,last_update_remote_commit:"remote_commit"in updateStatus?updateStatus.remote_commit:void 0,last_update_remote_version:"remote_version"in updateStatus?updateStatus.remote_version:void 0,update_available:updateStatus.available,update_error:updateStatus.error},updateStatus.timeout_ms)});return{...state,entries:sortManagedEntries(entries)}}export{refreshManagedExtensionUpdates};
1
+ import{mapWithFixedConcurrency as c}from"./concurrency.js";import{sortManagedEntries as _}from"./managed-state.js";import{checkGithubUpdate as m,checkNpmUpdate as p,resolveExtensionUpdateCheckTimeoutMs as f,updateCheckTeardown as l}from"./update-check.js";const u=4;function h(n){let r=n;const a=[];return{acquire:()=>r>0?(r-=1,Promise.resolve()):new Promise(e=>a.push(e)),release:()=>{const e=a.shift();e?e():r+=1}}}function s(n,r){const{update_check_timeout_ms:a,...e}=n;return r===void 0?e:{...e,update_check_timeout_ms:r}}async function w(n,r=!1,a=f(),e=!0){const o=h(u),d=await c(n.entries,u,async i=>{if(!["github","npm"].includes(i.source.kind))return i;if(r)return s({...i,last_update_check_at:void 0,last_update_remote_commit:void 0,last_update_remote_version:void 0,update_available:null,update_error:void 0},void 0);await o.acquire();const t=i.source.kind==="github"?await m(i.source,void 0,a):await p(i.source,void 0,a);return e?l(t).then(o.release):o.release(),s({...i,last_update_check_at:t.checked_at,last_update_remote_commit:"remote_commit"in t?t.remote_commit:void 0,last_update_remote_version:"remote_version"in t?t.remote_version:void 0,update_available:t.available,update_error:t.error},t.timeout_ms)});return{...n,entries:_(d)}}export{w as refreshManagedExtensionUpdates};
2
2
  //# sourceMappingURL=managed-update-status.js.map
@@ -1,3 +1,3 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7be00b26-4a56-5399-94f6-f2f67cc5c1e6")}catch{}})();import fs from"node:fs/promises";import path from"node:path";import{pathExists}from"../../core/fs/fs-utils.js";import{activateExtensions,loadExtensions}from"../../core/extensions/index.js";import{writeWorkspaceJsonWithHistory}from"../../core/history/workspace-history.js";import{readSettings}from"../../core/store/settings.js";function resolveExtensionMigrationStatePath(pmRoot){return path.join(pmRoot,"extension-migrations.json")}function migrationId(migration,index){const id=migration.definition.id;return typeof id=="string"&&id.trim().length>0?id.trim():`migration-${String(index+1).padStart(3,"0")}`}function migrationKey(migration,id){return`${migration.layer}:${migration.name}:${id}`}async function readExtensionMigrationState(pmRoot){const statePath=resolveExtensionMigrationStatePath(pmRoot);if(!await pathExists(statePath))return{version:1,updated_at:"",entries:[]};const parsed=JSON.parse(await fs.readFile(statePath,"utf8"));return{version:1,updated_at:typeof parsed.updated_at=="string"?parsed.updated_at:"",entries:Array.isArray(parsed.entries)?parsed.entries.filter(entry=>typeof entry?.key=="string"&&(entry.status==="applied"||entry.status==="failed")):[]}}async function applyStoredExtensionMigrationState(pmRoot,migrations){const state=await readExtensionMigrationState(pmRoot),byKey=new Map(state.entries.map(entry=>[entry.key,entry]));return migrations.forEach((migration,index)=>{const id=migrationId(migration,index),entry=byKey.get(migrationKey(migration,id));entry&&(migration.definition.status=entry.status,entry.status==="failed"?migration.definition.reason=entry.error:(delete migration.definition.reason,delete migration.definition.error,delete migration.definition.message))}),state}async function runExtensionMigrations(options){const state=await applyStoredExtensionMigrationState(options.pmRoot,options.migrations),stateByKey=new Map(state.entries.map(entry=>[entry.key,entry])),receipts=[];let changed=!1;const scopedMigrations=options.migrations.map((migration,index)=>({migration,index})).filter(({migration})=>options.scope===void 0||migration.layer===options.scope);for(const{migration,index}of scopedMigrations){const id=migrationId(migration,index),key=migrationKey(migration,id),stored=stateByKey.get(key),declaredStatus=String(migration.definition.status??"pending").toLowerCase(),before=stored?.status??(declaredStatus==="applied"||declaredStatus==="failed"?declaredStatus:"pending");if(before==="applied"){receipts.push({key,layer:migration.layer,extension:migration.name,id,before,outcome:"skipped"});continue}if(options.dryRun===!0){receipts.push({key,layer:migration.layer,extension:migration.name,id,before,outcome:"pending"});continue}const run=migration.runtime_definition?.run??migration.definition.run;if(typeof run!="function"){receipts.push({key,layer:migration.layer,extension:migration.name,id,before,outcome:"pending"});continue}const attemptedAt=new Date().toISOString();try{await Promise.resolve(run({id,command:"migration",layer:migration.layer,extension:migration.name,pm_root:options.pmRoot,status:before}));const entry={key,layer:migration.layer,extension:migration.name,id,status:"applied",attempted_at:attemptedAt};stateByKey.set(key,entry),migration.definition.status="applied",delete migration.definition.reason,delete migration.definition.error,delete migration.definition.message,receipts.push({key,layer:migration.layer,extension:migration.name,id,before,outcome:"applied"}),changed=!0}catch(error){const message=error instanceof Error?error.message:String(error),entry={key,layer:migration.layer,extension:migration.name,id,status:"failed",attempted_at:attemptedAt,error:message};stateByKey.set(key,entry),migration.definition.status="failed",migration.definition.reason=message,receipts.push({key,layer:migration.layer,extension:migration.name,id,before,outcome:"failed",error:message}),changed=!0}}if(changed){const settings=await readSettings(options.pmRoot),nextState={version:1,updated_at:new Date().toISOString(),entries:[...stateByKey.values()].sort((left,right)=>left.key.localeCompare(right.key))};await writeWorkspaceJsonWithHistory({pmRoot:options.pmRoot,filePath:resolveExtensionMigrationStatePath(options.pmRoot),raw:`${JSON.stringify(nextState,null,2)}
2
- `,op:"extension_migrations_apply",author:options.author,lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms})}const pendingCount=receipts.filter(receipt=>receipt.outcome==="pending").length,appliedCount=receipts.filter(receipt=>receipt.outcome==="applied").length,skippedCount=receipts.filter(receipt=>receipt.outcome==="skipped").length,failedCount=receipts.filter(receipt=>receipt.outcome==="failed").length;return{ok:failedCount===0,dry_run:options.dryRun===!0,state_path:resolveExtensionMigrationStatePath(options.pmRoot),total:receipts.length,pending_count:pendingCount,applied_count:appliedCount,skipped_count:skippedCount,failed_count:failedCount,migrations:receipts}}async function runExtensionMigrateAction(context){const settings=await readSettings(context.resolvedRoots.settings_root),loaded=await loadExtensions({pmRoot:context.resolvedRoots.pm_root,settings,cwd:process.cwd(),noExtensions:context.global.noExtensions===!0}),activated=await activateExtensions(loaded);context.warnings.push(...loaded.warnings,...activated.warnings);const migration=await runExtensionMigrations({pmRoot:context.resolvedRoots.pm_root,migrations:activated.registrations.migrations,author:typeof context.global.author=="string"&&context.global.author.trim().length>0?context.global.author.trim():"pm-extension-migration",dryRun:context.options.dryRun===!0,...context.scope==="global"?{scope:"global"}:{}});return context.withResult({migration,load_failure_count:loaded.failed.length,activation_failure_count:activated.failed.length},migration.ok)}export{applyStoredExtensionMigrationState,readExtensionMigrationState,resolveExtensionMigrationStatePath,runExtensionMigrateAction,runExtensionMigrations};
1
+ import M from"node:fs/promises";import b from"node:path";import{pathExists as C}from"../../core/fs/fs-utils.js";import{activateExtensions as $,loadExtensions as A}from"../../core/extensions/index.js";import{writeWorkspaceJsonWithHistory as O}from"../../core/history/workspace-history.js";import{readSettings as x}from"../../core/store/settings.js";function y(e){return b.join(e,"extension-migrations.json")}function S(e,a){const o=e.definition.id;return typeof o=="string"&&o.trim().length>0?o.trim():`migration-${String(a+1).padStart(3,"0")}`}function k(e,a){return`${e.layer}:${e.name}:${a}`}async function P(e){const a=y(e);if(!await C(a))return{version:1,updated_at:"",entries:[]};const o=JSON.parse(await M.readFile(a,"utf8"));return{version:1,updated_at:typeof o.updated_at=="string"?o.updated_at:"",entries:Array.isArray(o.entries)?o.entries.filter(n=>typeof n?.key=="string"&&(n.status==="applied"||n.status==="failed")):[]}}async function I(e,a){const o=await P(e),n=new Map(o.entries.map(i=>[i.key,i]));return a.forEach((i,c)=>{const f=S(i,c),l=n.get(k(i,f));l&&(i.definition.status=l.status,l.status==="failed"?i.definition.reason=l.error:(delete i.definition.reason,delete i.definition.error,delete i.definition.message))}),o}async function J(e){const a=await I(e.pmRoot,e.migrations),o=new Map(a.entries.map(t=>[t.key,t])),n=[];let i=!1;const c=e.migrations.map((t,u)=>({migration:t,index:u})).filter(({migration:t})=>e.scope===void 0||t.layer===e.scope);for(const{migration:t,index:u}of c){const s=S(t,u),r=k(t,s),v=o.get(r),m=String(t.definition.status??"pending").toLowerCase(),d=v?.status??(m==="applied"||m==="failed"?m:"pending");if(d==="applied"){n.push({key:r,layer:t.layer,extension:t.name,id:s,before:d,outcome:"skipped"});continue}if(e.dryRun===!0){n.push({key:r,layer:t.layer,extension:t.name,id:s,before:d,outcome:"pending"});continue}const _=t.runtime_definition?.run??t.definition.run;if(typeof _!="function"){n.push({key:r,layer:t.layer,extension:t.name,id:s,before:d,outcome:"pending"});continue}const w=new Date().toISOString();try{await Promise.resolve(_({id:s,command:"migration",layer:t.layer,extension:t.name,pm_root:e.pmRoot,status:d}));const p={key:r,layer:t.layer,extension:t.name,id:s,status:"applied",attempted_at:w};o.set(r,p),t.definition.status="applied",delete t.definition.reason,delete t.definition.error,delete t.definition.message,n.push({key:r,layer:t.layer,extension:t.name,id:s,before:d,outcome:"applied"}),i=!0}catch(p){const g=p instanceof Error?p.message:String(p),E={key:r,layer:t.layer,extension:t.name,id:s,status:"failed",attempted_at:w,error:g};o.set(r,E),t.definition.status="failed",t.definition.reason=g,n.push({key:r,layer:t.layer,extension:t.name,id:s,before:d,outcome:"failed",error:g}),i=!0}}if(i){const t=await x(e.pmRoot),u={version:1,updated_at:new Date().toISOString(),entries:[...o.values()].sort((s,r)=>s.key.localeCompare(r.key))};await O({pmRoot:e.pmRoot,filePath:y(e.pmRoot),raw:`${JSON.stringify(u,null,2)}
2
+ `,op:"extension_migrations_apply",author:e.author,lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms})}const f=n.filter(t=>t.outcome==="pending").length,l=n.filter(t=>t.outcome==="applied").length,R=n.filter(t=>t.outcome==="skipped").length,h=n.filter(t=>t.outcome==="failed").length;return{ok:h===0,dry_run:e.dryRun===!0,state_path:y(e.pmRoot),total:n.length,pending_count:f,applied_count:l,skipped_count:R,failed_count:h,migrations:n}}async function F(e){const a=await x(e.resolvedRoots.settings_root),o=await A({pmRoot:e.resolvedRoots.pm_root,settings:a,cwd:process.cwd(),noExtensions:e.global.noExtensions===!0}),n=await $(o);e.warnings.push(...o.warnings,...n.warnings);const i=await J({pmRoot:e.resolvedRoots.pm_root,migrations:n.registrations.migrations,author:typeof e.global.author=="string"&&e.global.author.trim().length>0?e.global.author.trim():"pm-extension-migration",dryRun:e.options.dryRun===!0,...e.scope==="global"?{scope:"global"}:{}});return e.withResult({migration:i,load_failure_count:o.failed.length,activation_failure_count:n.failed.length},i.ok)}export{I as applyStoredExtensionMigrationState,P as readExtensionMigrationState,y as resolveExtensionMigrationStatePath,F as runExtensionMigrateAction,J as runExtensionMigrations};
3
3
  //# sourceMappingURL=migrations.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1956081d-53b1-5f2c-887a-6aac3325b764")}catch{}})();import{isCoreCommandPath}from"../cli-contracts/runtime-contracts.js";function resolveDirectExtensionOptionPolicy(commandPath){return{undeclaredKeys:isCoreCommandPath(commandPath)?"pass":"refuse"}}export{resolveDirectExtensionOptionPolicy};
1
+ import{isCoreCommandPath as o}from"../cli-contracts/runtime-contracts.js";function n(e){return{undeclaredKeys:o(e)?"pass":"refuse"}}export{n as resolveDirectExtensionOptionPolicy};
2
2
  //# sourceMappingURL=native-command-options.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f2cac210-bba0-5c7f-867b-8b59f8d36e11")}catch{}})();import{normalizeExtensionNameForMatch}from"./shared.js";function collectGlobalOutputOverrideDoctorWarnings(activationResult,loadResult){const commandScopedOwners=new Set((loadResult?.loaded??[]).flatMap(entry=>(entry.activation?.commands?.length??0)>0?[`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`]:[])),serviceWarnings=activationResult.services.overrides.filter(entry=>entry.service==="output_format").filter(entry=>entry.passThrough!==!0).filter(entry=>!commandScopedOwners.has(`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`)).map(entry=>`extension_output_service_override_global:${entry.service}:${entry.layer}:${entry.name}`),rendererWarnings=activationResult.renderers.overrides.filter(entry=>(entry.commands?.length??0)===0&&entry.resultDiscriminator===void 0).map(entry=>`extension_output_renderer_override_global:${entry.format}:${entry.layer}:${entry.name}`);return[...new Set([...serviceWarnings,...rendererWarnings])].sort((left,right)=>left.localeCompare(right))}export{collectGlobalOutputOverrideDoctorWarnings};
1
+ import{normalizeExtensionNameForMatch as o}from"./shared.js";function m(r,a){const n=new Set((a?.loaded??[]).flatMap(e=>(e.activation?.commands?.length??0)>0?[`${e.layer}:${o(e.name)}`]:[])),i=r.services.overrides.filter(e=>e.service==="output_format").filter(e=>e.passThrough!==!0).filter(e=>!n.has(`${e.layer}:${o(e.name)}`)).map(e=>`extension_output_service_override_global:${e.service}:${e.layer}:${e.name}`),t=r.renderers.overrides.filter(e=>(e.commands?.length??0)===0&&e.resultDiscriminator===void 0).map(e=>`extension_output_renderer_override_global:${e.format}:${e.layer}:${e.name}`);return[...new Set([...i,...t])].sort((e,s)=>e.localeCompare(s))}export{m as collectGlobalOutputOverrideDoctorWarnings};
2
2
  //# sourceMappingURL=output-ownership.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="accde468-de04-51b6-81ad-5c5ea218a87b")}catch{}})();import{normalizeExtensionNameForMatch}from"./shared.js";function summarizeRuntimeCommandPathsForExtension(extensionName,installed){const normalizedName=normalizeExtensionNameForMatch(extensionName),entry=installed.find(candidate=>normalizeExtensionNameForMatch(candidate.name)===normalizedName);return{command_paths:[...entry?.command_paths??[]].sort((left,right)=>left.localeCompare(right)),action_paths:[...entry?.action_paths??[]].sort((left,right)=>left.localeCompare(right))}}export{summarizeRuntimeCommandPathsForExtension};
1
+ import{normalizeExtensionNameForMatch as t}from"./shared.js";function i(m,e){const r=t(m),n=e.find(o=>t(o.name)===r);return{command_paths:[...n?.command_paths??[]].sort((o,a)=>o.localeCompare(a)),action_paths:[...n?.action_paths??[]].sort((o,a)=>o.localeCompare(a))}}export{i as summarizeRuntimeCommandPathsForExtension};
2
2
  //# sourceMappingURL=runtime-summary.js.map