@unbrained/pm-cli 2026.11.21 → 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 (943) hide show
  1. package/.agents/skills/pm-developer/SKILL.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/dist/cli/after-command-context-usage.js +1 -1
  4. package/dist/cli/argv-utils.js +1 -1
  5. package/dist/cli/bootstrap-args.js +1 -1
  6. package/dist/cli/bundle-integrity.js +2 -2
  7. package/dist/cli/command-namespaces.js +1 -1
  8. package/dist/cli/commander-usage.js +11 -11
  9. package/dist/cli/commands/annotations/comments.js +1 -1
  10. package/dist/cli/commands/annotations/docs.js +1 -1
  11. package/dist/cli/commands/annotations/files.js +1 -1
  12. package/dist/cli/commands/annotations/learnings.js +1 -1
  13. package/dist/cli/commands/annotations/notes.js +1 -1
  14. package/dist/cli/commands/extension/describe.js +1 -1
  15. package/dist/cli/commands/extension/extension.js +1 -1
  16. package/dist/cli/commands/extension/scaffold.js +1 -1
  17. package/dist/cli/commands/extension/shared.js +1 -1
  18. package/dist/cli/commands/governance/gc.js +1 -1
  19. package/dist/cli/commands/governance/health.js +1 -1
  20. package/dist/cli/commands/governance/telemetry.js +1 -1
  21. package/dist/cli/commands/governance/validate.js +1 -1
  22. package/dist/cli/commands/history/activity.js +1 -1
  23. package/dist/cli/commands/history/history-compact.js +1 -1
  24. package/dist/cli/commands/history/history-redact.js +1 -1
  25. package/dist/cli/commands/history/history-repair.js +1 -1
  26. package/dist/cli/commands/history/history.js +1 -1
  27. package/dist/cli/commands/history/restore.js +1 -1
  28. package/dist/cli/commands/lifecycle/append.js +1 -1
  29. package/dist/cli/commands/lifecycle/claim.js +1 -1
  30. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  31. package/dist/cli/commands/lifecycle/close.js +1 -1
  32. package/dist/cli/commands/lifecycle/copy.js +1 -1
  33. package/dist/cli/commands/lifecycle/create.js +1 -1
  34. package/dist/cli/commands/lifecycle/delete.js +1 -1
  35. package/dist/cli/commands/lifecycle/focus.js +1 -1
  36. package/dist/cli/commands/lifecycle/plan.js +1 -1
  37. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  38. package/dist/cli/commands/lifecycle/update.js +1 -1
  39. package/dist/cli/commands/query/aggregate.js +1 -1
  40. package/dist/cli/commands/query/context.js +1 -1
  41. package/dist/cli/commands/query/deps.js +1 -1
  42. package/dist/cli/commands/query/duplicates.js +1 -1
  43. package/dist/cli/commands/query/eval.js +1 -1
  44. package/dist/cli/commands/query/get.js +1 -1
  45. package/dist/cli/commands/query/graph.js +1 -1
  46. package/dist/cli/commands/query/list.js +1 -1
  47. package/dist/cli/commands/query/next.js +1 -1
  48. package/dist/cli/commands/query/search.js +1 -1
  49. package/dist/cli/commands/query/stats.js +1 -1
  50. package/dist/cli/commands/test/test-all.js +1 -1
  51. package/dist/cli/commands/test/test-runs.js +1 -1
  52. package/dist/cli/commands/test/test.js +1 -1
  53. package/dist/cli/commands/workspace/config.js +1 -1
  54. package/dist/cli/commands/workspace/contracts.js +1 -1
  55. package/dist/cli/commands/workspace/init.js +1 -1
  56. package/dist/cli/commands/workspace/merge.js +1 -1
  57. package/dist/cli/commands/workspace/profile.js +1 -1
  58. package/dist/cli/commands/workspace/schema.js +1 -1
  59. package/dist/cli/commands/workspace/upgrade.js +1 -1
  60. package/dist/cli/context-intent-invocation.js +1 -1
  61. package/dist/cli/description-stdin.js +1 -1
  62. package/dist/cli/error-guidance.js +5 -5
  63. package/dist/cli/expected-revisions.js +1 -1
  64. package/dist/cli/extension-command-help.js +6 -6
  65. package/dist/cli/extension-recovery.js +1 -1
  66. package/dist/cli/help-content.js +5 -5
  67. package/dist/cli/help-json-payload.js +7 -7
  68. package/dist/cli/invocation-profile.js +2 -2
  69. package/dist/cli/main.js +5 -5
  70. package/dist/cli/migration-gates.js +1 -1
  71. package/dist/cli/option-values.js +1 -1
  72. package/dist/cli/preflight-warnings.js +3 -3
  73. package/dist/cli/public.js +1 -1
  74. package/dist/cli/register-annotations.js +1 -1
  75. package/dist/cli/register-assurance.js +1 -1
  76. package/dist/cli/register-files-lookup.js +1 -1
  77. package/dist/cli/register-history-activity.js +1 -1
  78. package/dist/cli/register-history-author.js +1 -1
  79. package/dist/cli/register-history-maintenance.js +2 -2
  80. package/dist/cli/register-list-query.js +10 -10
  81. package/dist/cli/register-mutation-options.js +0 -1
  82. package/dist/cli/register-mutation.js +6 -6
  83. package/dist/cli/register-operations.js +1 -1
  84. package/dist/cli/register-setup.js +1 -1
  85. package/dist/cli/register-structured-mutation.js +1 -1
  86. package/dist/cli/registration-helpers.js +1 -1
  87. package/dist/cli/runtime/activation.js +1 -1
  88. package/dist/cli/runtime/annotation-option-retry.js +1 -1
  89. package/dist/cli/runtime/close-fields-retry.js +1 -1
  90. package/dist/cli/runtime/field-route-retry.js +1 -1
  91. package/dist/cli/runtime/invocation-options.js +1 -1
  92. package/dist/cli/runtime/invocation-rewrites.js +1 -1
  93. package/dist/cli/runtime/projection-retry.js +1 -1
  94. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  95. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  96. package/dist/cli/runtime/selection.js +1 -1
  97. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  98. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  99. package/dist/cli/schema/registration.js +15 -15
  100. package/dist/cli/schema-registration-helpers.js +1 -1
  101. package/dist/cli/search-refresh.js +1 -1
  102. package/dist/cli/stats-analytics-json.js +1 -1
  103. package/dist/cli/telemetry-flush.js +1 -1
  104. package/dist/cli-bundle/bundle-manifest.json +1 -1
  105. package/dist/cli-bundle/chunks/chunk-2UQU7HRR.js +9 -0
  106. package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
  107. package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +3 -0
  108. package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
  109. package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +2 -0
  110. package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
  111. package/dist/cli-bundle/chunks/chunk-AEOHUSUI.js +2289 -0
  112. package/dist/cli-bundle/chunks/chunk-BSRIVYTM.js +8 -0
  113. package/dist/cli-bundle/chunks/chunk-CFWLQFJM.js +71 -0
  114. package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
  115. package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +31 -0
  116. package/dist/cli-bundle/chunks/chunk-F2Z6XLZB.js +3 -0
  117. package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +2 -0
  118. package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +2 -0
  119. package/dist/cli-bundle/chunks/chunk-H7JEXRIN.js +6 -0
  120. package/dist/cli-bundle/chunks/chunk-J2PDAVBC.js +2 -0
  121. package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +2 -0
  122. package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +33 -0
  123. package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +115 -0
  124. package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +2 -0
  125. package/dist/cli-bundle/chunks/chunk-O7JHS64G.js +3 -0
  126. package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +2 -0
  127. package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +2 -0
  128. package/dist/cli-bundle/chunks/chunk-OPJF254V.js +9 -0
  129. package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
  130. package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +2 -0
  131. package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +2 -0
  132. package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
  133. package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +125 -0
  134. package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
  135. package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +8 -0
  136. package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
  137. package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
  138. package/dist/cli-bundle/chunks/{item-revision-R5SZPJZ5.js → item-revision-FMD4KWBB.js} +2 -2
  139. package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +2 -0
  140. package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +2 -0
  141. package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +2 -0
  142. package/dist/cli-bundle/chunks/{register-list-query-SPGPS3OS.js → register-list-query-L4IBU64P.js} +11 -11
  143. package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +21 -0
  144. package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +2 -0
  145. package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +2 -0
  146. package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
  147. package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +2 -0
  148. package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +6 -0
  149. package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +2 -0
  150. package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
  151. package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
  152. package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
  153. package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
  154. package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +8 -0
  155. package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +2 -0
  156. package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
  157. package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +2 -0
  158. package/dist/cli-bundle/focused-chunks/chunk-IROZDIDX.js +3 -0
  159. package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +2 -0
  160. package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
  161. package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +26 -0
  162. package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +13 -0
  163. package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +2 -0
  164. package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +91 -0
  165. package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +2 -0
  166. package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +2 -0
  167. package/dist/cli-bundle/focused-chunks/chunk-QQIIMMFU.js +2 -0
  168. package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
  169. package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +8 -0
  170. package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +27 -0
  171. package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
  172. package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +44 -0
  173. package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +2 -0
  174. package/dist/cli-bundle/focused-chunks/chunk-Y2ESLKCF.js +8 -0
  175. package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +2 -0
  176. package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +102 -0
  177. package/dist/cli-bundle/focused-chunks/chunk-ZHWPCVQL.js +78 -0
  178. package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
  179. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
  180. package/dist/cli-bundle/focused-chunks/{item-revision-3V3UIP5X.js → item-revision-YDACCDVY.js} +2 -2
  181. package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +2 -0
  182. package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +2 -0
  183. package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +2 -0
  184. package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
  185. package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +2 -0
  186. package/dist/cli-bundle/main.js +27 -27
  187. package/dist/cli-bundle/sdk-authoring.js +1 -1
  188. package/dist/cli-bundle/sdk-contracts.js +5 -5
  189. package/dist/cli-bundle/sdk-core.js +1 -1
  190. package/dist/cli-bundle/sdk-governance.js +1 -1
  191. package/dist/cli-bundle/sdk-graph.js +1 -1
  192. package/dist/cli-bundle/sdk-merge.js +72 -60
  193. package/dist/cli-bundle/sdk-query.js +1 -1
  194. package/dist/cli-bundle/sdk-runtime.js +1 -1
  195. package/dist/cli-bundle/sdk-testing.js +1 -1
  196. package/dist/cli-bundle/sdk.js +13 -13
  197. package/dist/cli.js +1 -1
  198. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  199. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  200. package/dist/core/checkpoint/mutation-context.js +1 -1
  201. package/dist/core/config/nested-settings.js +1 -1
  202. package/dist/core/config/positional-value.js +1 -1
  203. package/dist/core/diagnostics/remediation.js +1 -1
  204. package/dist/core/extensions/activation-summary-markdown.js +2 -2
  205. package/dist/core/extensions/activation-summary.js +1 -1
  206. package/dist/core/extensions/activation-transaction.js +1 -1
  207. package/dist/core/extensions/capability-usage.js +1 -1
  208. package/dist/core/extensions/command-hook-context.js +1 -1
  209. package/dist/core/extensions/command-metadata-contract.js +1 -1
  210. package/dist/core/extensions/command-visibility-tier.js +1 -1
  211. package/dist/core/extensions/contribution-inventory.js +1 -1
  212. package/dist/core/extensions/exporter-output-contract.js +1 -1
  213. package/dist/core/extensions/extension-candidate.js +1 -1
  214. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  215. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  216. package/dist/core/extensions/extension-policy.js +1 -1
  217. package/dist/core/extensions/extension-registries.js +1 -1
  218. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  219. package/dist/core/extensions/extension-types.js +1 -1
  220. package/dist/core/extensions/flag-definition-validation.js +1 -1
  221. package/dist/core/extensions/flag-value-types.js +1 -1
  222. package/dist/core/extensions/index.js +1 -1
  223. package/dist/core/extensions/item-field-types.js +1 -1
  224. package/dist/core/extensions/item-fields.js +1 -1
  225. package/dist/core/extensions/loader.js +1 -1
  226. package/dist/core/extensions/manifest-parser.js +1 -1
  227. package/dist/core/extensions/manifest-schema.js +1 -1
  228. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  229. package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
  230. package/dist/core/extensions/mutation-actor.js +1 -1
  231. package/dist/core/extensions/preflight-ownership.js +1 -1
  232. package/dist/core/extensions/read-output-contract.js +1 -1
  233. package/dist/core/extensions/registration-contracts.js +1 -1
  234. package/dist/core/extensions/registration-validation.js +1 -1
  235. package/dist/core/extensions/registration-values.js +1 -1
  236. package/dist/core/extensions/reserved-host-flags.js +1 -1
  237. package/dist/core/extensions/runtime-registrations.js +1 -1
  238. package/dist/core/extensions/service-ownership.js +1 -1
  239. package/dist/core/extensions/version-compat.js +1 -1
  240. package/dist/core/extensions/version-diagnostics.js +1 -1
  241. package/dist/core/fs/atomic-create.js +1 -1
  242. package/dist/core/fs/file-glob.js +1 -1
  243. package/dist/core/fs/fs-utils.js +2 -2
  244. package/dist/core/fs/host-environment-errors.js +1 -1
  245. package/dist/core/fs/index.js +1 -1
  246. package/dist/core/fs/path-utils.js +1 -1
  247. package/dist/core/governance/content-fields.js +1 -1
  248. package/dist/core/governance/issue-codes.js +1 -1
  249. package/dist/core/governance/metadata-coverage.js +1 -1
  250. package/dist/core/history/bridge.js +2 -0
  251. package/dist/core/history/digest.js +1 -1
  252. package/dist/core/history/drift-cache.js +3 -3
  253. package/dist/core/history/drift-scan.js +1 -1
  254. package/dist/core/history/event-classification.js +1 -1
  255. package/dist/core/history/event-index.js +11 -11
  256. package/dist/core/history/history-compact-bulk.js +1 -1
  257. package/dist/core/history/history-diff.js +1 -1
  258. package/dist/core/history/history-rewrite.js +1 -1
  259. package/dist/core/history/history-storage-stats.js +1 -1
  260. package/dist/core/history/history-stream-policy.js +1 -1
  261. package/dist/core/history/history.d.ts +12 -0
  262. package/dist/core/history/history.js +2 -2
  263. package/dist/core/history/identity.js +1 -1
  264. package/dist/core/history/index.js +1 -1
  265. package/dist/core/history/operation-contract.js +1 -1
  266. package/dist/core/history/projection.js +1 -1
  267. package/dist/core/history/read.d.ts +9 -0
  268. package/dist/core/history/read.js +1 -1
  269. package/dist/core/history/replay.d.ts +46 -5
  270. package/dist/core/history/replay.js +2 -2
  271. package/dist/core/history/stream-summary.js +2 -2
  272. package/dist/core/history/tombstone.js +1 -1
  273. package/dist/core/history/version-address.js +1 -1
  274. package/dist/core/history/workspace-history.js +2 -2
  275. package/dist/core/io/body-file.js +1 -1
  276. package/dist/core/io/bulk-ids-input.js +2 -2
  277. package/dist/core/item/actionability.js +1 -1
  278. package/dist/core/item/deferred-fields.js +1 -1
  279. package/dist/core/item/dependency-reference.js +1 -1
  280. package/dist/core/item/id.js +1 -1
  281. package/dist/core/item/index.js +1 -1
  282. package/dist/core/item/item-format-version.js +1 -1
  283. package/dist/core/item/item-format.js +7 -7
  284. package/dist/core/item/item-record.js +1 -1
  285. package/dist/core/item/item-type-definition.js +1 -1
  286. package/dist/core/item/literal-mutation-input.js +1 -1
  287. package/dist/core/item/parent-reference-policy.js +1 -1
  288. package/dist/core/item/parse.js +8 -8
  289. package/dist/core/item/plan-lifecycle.js +1 -1
  290. package/dist/core/item/priority.js +1 -1
  291. package/dist/core/item/sprint-release-format.js +1 -1
  292. package/dist/core/item/status-filter.js +1 -1
  293. package/dist/core/item/status.js +1 -1
  294. package/dist/core/item/toon-decode.js +1 -1
  295. package/dist/core/item/type-registry.js +1 -1
  296. package/dist/core/item/type-synonyms.js +1 -1
  297. package/dist/core/lock/index.js +1 -1
  298. package/dist/core/lock/lock-confinement.js +1 -1
  299. package/dist/core/lock/lock-gc.js +1 -1
  300. package/dist/core/lock/lock-owner.js +1 -1
  301. package/dist/core/lock/lock.js +4 -4
  302. package/dist/core/output/linked-test-projection.js +5 -5
  303. package/dist/core/output/mutation-projection.js +1 -1
  304. package/dist/core/output/output-control.js +1 -1
  305. package/dist/core/output/output.js +19 -19
  306. package/dist/core/output/query-summary.js +1 -1
  307. package/dist/core/output/tabular.js +3 -3
  308. package/dist/core/packages/manifest.js +1 -1
  309. package/dist/core/packages/root.js +1 -1
  310. package/dist/core/policy/workflow-policy-schema.js +1 -1
  311. package/dist/core/policy/workflow-policy-store.js +1 -1
  312. package/dist/core/policy/workflow-policy.js +1 -1
  313. package/dist/core/profile/profile-describe.js +1 -1
  314. package/dist/core/profile/profile-lint.d.ts +1 -1
  315. package/dist/core/profile/profile-lint.js +1 -1
  316. package/dist/core/profile/profile-plan.js +1 -1
  317. package/dist/core/profile/profile-presets.js +4 -4
  318. package/dist/core/reproducibility/context.js +1 -1
  319. package/dist/core/schema/fields-file.js +2 -2
  320. package/dist/core/schema/item-types-file.js +2 -2
  321. package/dist/core/schema/runtime-field-filters.js +1 -1
  322. package/dist/core/schema/runtime-field-values.js +1 -1
  323. package/dist/core/schema/runtime-schema.js +2 -2
  324. package/dist/core/schema/status-defs-file.js +2 -2
  325. package/dist/core/schema/status-token.js +1 -1
  326. package/dist/core/schema/type-inference.js +1 -1
  327. package/dist/core/schema/type-presets.js +1 -1
  328. package/dist/core/schema/type-workflows.js +1 -1
  329. package/dist/core/search/background-refresh.js +2 -2
  330. package/dist/core/search/bm25.js +1 -1
  331. package/dist/core/search/cache.js +2 -2
  332. package/dist/core/search/corpus.js +1 -1
  333. package/dist/core/search/embedding-batches.js +1 -1
  334. package/dist/core/search/eval-thresholds.js +1 -1
  335. package/dist/core/search/eval.js +1 -1
  336. package/dist/core/search/http-client.js +1 -1
  337. package/dist/core/search/providers.js +1 -1
  338. package/dist/core/search/relevance.js +1 -1
  339. package/dist/core/search/semantic-defaults.js +1 -1
  340. package/dist/core/search/staleness.js +1 -1
  341. package/dist/core/search/vector-stores.js +2 -2
  342. package/dist/core/search/vectorization-metadata.js +1 -1
  343. package/dist/core/sentry/helpers.js +1 -1
  344. package/dist/core/sentry/instrument.js +1 -1
  345. package/dist/core/sentry/sensitive-assignments.js +1 -1
  346. package/dist/core/session/session-state.js +1 -1
  347. package/dist/core/shared/agent-session-context.js +1 -1
  348. package/dist/core/shared/author.js +5 -5
  349. package/dist/core/shared/command-line.js +1 -1
  350. package/dist/core/shared/command-types.js +0 -1
  351. package/dist/core/shared/conflict-markers.js +1 -1
  352. package/dist/core/shared/constants.js +1 -1
  353. package/dist/core/shared/error-details.js +1 -1
  354. package/dist/core/shared/errors.js +1 -1
  355. package/dist/core/shared/html-entity-decode.js +1 -1
  356. package/dist/core/shared/index.js +1 -1
  357. package/dist/core/shared/item-metadata-contract.js +1 -1
  358. package/dist/core/shared/lazy-module.js +1 -1
  359. package/dist/core/shared/levenshtein.js +1 -1
  360. package/dist/core/shared/memo.js +1 -1
  361. package/dist/core/shared/numeric-parsers.js +1 -1
  362. package/dist/core/shared/option-alias-visibility.js +1 -1
  363. package/dist/core/shared/output-unicode.js +1 -1
  364. package/dist/core/shared/primitives.js +1 -1
  365. package/dist/core/shared/process-tree.js +2 -2
  366. package/dist/core/shared/secret-rules.js +5 -5
  367. package/dist/core/shared/serial-queue.js +1 -1
  368. package/dist/core/shared/serialization.js +1 -1
  369. package/dist/core/shared/split-comma-list.js +1 -1
  370. package/dist/core/shared/text-normalization.js +1 -1
  371. package/dist/core/shared/time.js +2 -2
  372. package/dist/core/shared/url-credentials.js +1 -1
  373. package/dist/core/store/index.js +1 -1
  374. package/dist/core/store/item-format-migration.js +1 -1
  375. package/dist/core/store/item-metadata-cache.js +1 -1
  376. package/dist/core/store/item-metadata-query-index.js +11 -11
  377. package/dist/core/store/item-metadata-read-work.js +1 -1
  378. package/dist/core/store/item-mutation-precondition.js +1 -1
  379. package/dist/core/store/item-store.js +1 -1
  380. package/dist/core/store/paths.js +1 -1
  381. package/dist/core/store/settings-concurrency.js +1 -1
  382. package/dist/core/store/settings-read-cache.js +1 -1
  383. package/dist/core/store/settings-sections.js +2 -2
  384. package/dist/core/store/settings-validator.js +1 -1
  385. package/dist/core/store/settings.d.ts +3 -1
  386. package/dist/core/store/settings.js +6 -6
  387. package/dist/core/store/sqlite-runtime.js +1 -1
  388. package/dist/core/store/tracker-preflight.js +1 -1
  389. package/dist/core/store/transaction-coordinator-scope.js +1 -1
  390. package/dist/core/telemetry/consent.js +3 -3
  391. package/dist/core/telemetry/observability.js +1 -1
  392. package/dist/core/telemetry/policy.js +1 -1
  393. package/dist/core/telemetry/read-sampling.js +2 -2
  394. package/dist/core/telemetry/runtime.js +9 -9
  395. package/dist/core/test/background-runs.js +4 -4
  396. package/dist/core/test/item-test-run-tracking.js +1 -1
  397. package/dist/core/test/run-selectors.js +1 -1
  398. package/dist/core/validate/estimate-defaults.js +1 -1
  399. package/dist/core/validate/fix-planning.js +1 -1
  400. package/dist/core/validate/linked-artifact-reference.js +1 -1
  401. package/dist/core/validate/missing-by-type.js +1 -1
  402. package/dist/core/validate/missing-link-owners.js +1 -1
  403. package/dist/core/validate/stale-file-classification.js +1 -1
  404. package/dist/mcp/http-server.js +5 -5
  405. package/dist/mcp/legacy-adapter.js +1 -1
  406. package/dist/mcp/runtime-capabilities.js +1 -1
  407. package/dist/mcp/server.js +4 -4
  408. package/dist/mcp/tool-definitions.js +1 -1
  409. package/dist/sdk/actionability.js +1 -1
  410. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  411. package/dist/sdk/agent/command-recovery.js +1 -1
  412. package/dist/sdk/agent/command-suggestions.js +1 -1
  413. package/dist/sdk/agent/create-option-policy.js +1 -1
  414. package/dist/sdk/agent/identity-config.js +1 -1
  415. package/dist/sdk/agent/item-addressing.js +1 -1
  416. package/dist/sdk/agent/linked-resource-recovery.js +1 -1
  417. package/dist/sdk/agent/refusal-closure-census.js +2 -2
  418. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  419. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  420. package/dist/sdk/agent-capability-contracts.js +3 -3
  421. package/dist/sdk/agent-session-context.js +1 -1
  422. package/dist/sdk/annotations.js +1 -1
  423. package/dist/sdk/author-attribution.js +1 -1
  424. package/dist/sdk/cli-bootstrap.js +1 -1
  425. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
  426. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  427. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  428. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  429. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  430. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  431. package/dist/sdk/cli-contracts/completeness.js +1 -1
  432. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  433. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  434. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
  435. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  436. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  437. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  438. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  439. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  440. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  441. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  442. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  443. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
  444. package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
  445. package/dist/sdk/cli-contracts.js +1 -1
  446. package/dist/sdk/cli-program.js +1 -1
  447. package/dist/sdk/command-line.js +1 -1
  448. package/dist/sdk/comments.js +1 -1
  449. package/dist/sdk/compile-cache.js +1 -1
  450. package/dist/sdk/completion/bash.js +2 -2
  451. package/dist/sdk/completion/fish.js +74 -73
  452. package/dist/sdk/completion/shared.js +1 -1
  453. package/dist/sdk/completion/zsh.js +77 -76
  454. package/dist/sdk/completion.js +1 -1
  455. package/dist/sdk/config.js +1 -1
  456. package/dist/sdk/context/recency.js +1 -1
  457. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  458. package/dist/sdk/context/usage-egress.js +1 -1
  459. package/dist/sdk/context/usage-ledger.js +6 -6
  460. package/dist/sdk/context-intent-contracts.js +1 -1
  461. package/dist/sdk/context-intent-runtime.js +1 -1
  462. package/dist/sdk/context-packing.js +1 -1
  463. package/dist/sdk/context-relevance.js +1 -1
  464. package/dist/sdk/context-signal-store.js +2 -2
  465. package/dist/sdk/context-usage.js +1 -1
  466. package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
  467. package/dist/sdk/dependencies.js +1 -1
  468. package/dist/sdk/dependency-flag-validation.js +1 -1
  469. package/dist/sdk/dependency-provenance.js +1 -1
  470. package/dist/sdk/docs.js +1 -1
  471. package/dist/sdk/duplicates.js +1 -1
  472. package/dist/sdk/environment/host-environment-errors.js +1 -1
  473. package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
  474. package/dist/sdk/environment/source-context.js +1 -1
  475. package/dist/sdk/environment/tracker-preflight.js +1 -1
  476. package/dist/sdk/error-code-catalog.js +1 -1
  477. package/dist/sdk/error-runtime.js +1 -1
  478. package/dist/sdk/errors.js +1 -1
  479. package/dist/sdk/eval.js +1 -1
  480. package/dist/sdk/extension/author-manifest.js +1 -1
  481. package/dist/sdk/extension/bundled-catalog.js +1 -1
  482. package/dist/sdk/extension/command-options.js +1 -1
  483. package/dist/sdk/extension/concurrency.js +1 -1
  484. package/dist/sdk/extension/copy-scope.js +1 -1
  485. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  486. package/dist/sdk/extension/describe.js +3 -3
  487. package/dist/sdk/extension/doctor.js +1 -1
  488. package/dist/sdk/extension/install-plan.js +1 -1
  489. package/dist/sdk/extension/install-receipts.js +1 -1
  490. package/dist/sdk/extension/install-runtime.js +3 -3
  491. package/dist/sdk/extension/install-snapshot.js +1 -1
  492. package/dist/sdk/extension/install-sources.js +5 -5
  493. package/dist/sdk/extension/managed-state.js +2 -2
  494. package/dist/sdk/extension/managed-update-status.js +1 -1
  495. package/dist/sdk/extension/migrations.js +2 -2
  496. package/dist/sdk/extension/native-command-options.js +1 -1
  497. package/dist/sdk/extension/output-ownership.js +1 -1
  498. package/dist/sdk/extension/runtime-summary.js +1 -1
  499. package/dist/sdk/extension/scaffold.js +11 -11
  500. package/dist/sdk/extension/shared.js +1 -1
  501. package/dist/sdk/extension/source-resolution.js +1 -1
  502. package/dist/sdk/extension/static-inventory.js +1 -1
  503. package/dist/sdk/extension/update-check.js +1 -1
  504. package/dist/sdk/extension-command-context.js +2 -2
  505. package/dist/sdk/extension-contracts.js +1 -1
  506. package/dist/sdk/extension.js +1 -1
  507. package/dist/sdk/files.js +1 -1
  508. package/dist/sdk/flag-invocation-contracts.js +1 -1
  509. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  510. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  511. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  512. package/dist/sdk/generated-error-code-catalog.js +1 -1
  513. package/dist/sdk/governance/assurance-action-contracts.js +0 -1
  514. package/dist/sdk/governance/assurance-action.js +1 -1
  515. package/dist/sdk/governance/assurance-limits.js +1 -1
  516. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  517. package/dist/sdk/governance/assurance-presets.js +1 -1
  518. package/dist/sdk/governance/assurance-runtime.js +1 -1
  519. package/dist/sdk/governance/assurance.js +4 -4
  520. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  521. package/dist/sdk/governance/closure-timestamps.js +1 -1
  522. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  523. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  524. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  525. package/dist/sdk/governance/defect-recurrence.js +2 -2
  526. package/dist/sdk/governance/extension-host-version.js +1 -1
  527. package/dist/sdk/governance/gc.js +1 -1
  528. package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
  529. package/dist/sdk/governance/health/projection.js +1 -1
  530. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  531. package/dist/sdk/governance/health.js +2 -2
  532. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  533. package/dist/sdk/governance/in-progress-work-health.js +1 -1
  534. package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
  535. package/dist/sdk/governance/linked-file-report.js +1 -1
  536. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  537. package/dist/sdk/governance/provenance-health.js +4 -4
  538. package/dist/sdk/governance/reindex.js +5 -5
  539. package/dist/sdk/governance/stale-work.js +1 -1
  540. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  541. package/dist/sdk/governance/storage-integrity.js +1 -1
  542. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  543. package/dist/sdk/governance/upgrade.js +2 -2
  544. package/dist/sdk/governance/validate-deferred-fields.js +1 -1
  545. package/dist/sdk/governance/validate-history-drift.js +1 -1
  546. package/dist/sdk/governance/validate-item-reader.js +1 -1
  547. package/dist/sdk/governance/validate-normalization.js +1 -1
  548. package/dist/sdk/governance/validate.js +1 -1
  549. package/dist/sdk/governance/workflow-completeness.js +1 -1
  550. package/dist/sdk/governance/workflow-policy.js +3 -3
  551. package/dist/sdk/governance/workspace-position.js +2 -2
  552. package/dist/sdk/graph/analytics.js +1 -1
  553. package/dist/sdk/graph/assembly.js +1 -1
  554. package/dist/sdk/graph/cache.js +1 -1
  555. package/dist/sdk/graph/cardinality-integrity.js +1 -1
  556. package/dist/sdk/graph/centrality.js +1 -1
  557. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  558. package/dist/sdk/graph/durable-cache.js +1 -1
  559. package/dist/sdk/graph/governance-contracts.js +1 -1
  560. package/dist/sdk/graph/governance.js +1 -1
  561. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  562. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  563. package/dist/sdk/graph/mutation-advisory.js +1 -1
  564. package/dist/sdk/graph/query-contracts.js +1 -1
  565. package/dist/sdk/graph/remediation.js +1 -1
  566. package/dist/sdk/graph/run.js +1 -1
  567. package/dist/sdk/graph/scheduling.js +1 -1
  568. package/dist/sdk/graph/traversal.js +1 -1
  569. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  570. package/dist/sdk/guide-topics.js +1 -1
  571. package/dist/sdk/guide.js +7 -7
  572. package/dist/sdk/history/append-only-repair.d.ts +30 -0
  573. package/dist/sdk/history/append-only-repair.js +6 -0
  574. package/dist/sdk/history/attestation-command.js +2 -2
  575. package/dist/sdk/history/attestation-contract.js +1 -1
  576. package/dist/sdk/history/attestation-scan.js +1 -1
  577. package/dist/sdk/history/attestation.js +1 -1
  578. package/dist/sdk/history/maintenance.d.ts +8 -2
  579. package/dist/sdk/history/maintenance.js +1 -1
  580. package/dist/sdk/history/reanchor-refusal.js +2 -0
  581. package/dist/sdk/history/reseed.d.ts +15 -0
  582. package/dist/sdk/history/reseed.js +2 -0
  583. package/dist/sdk/history/salvage.d.ts +19 -8
  584. package/dist/sdk/history/salvage.js +5 -3
  585. package/dist/sdk/history/subject.js +1 -1
  586. package/dist/sdk/history-analytics.js +1 -1
  587. package/dist/sdk/history-compact.js +1 -1
  588. package/dist/sdk/history-mcp.js +1 -1
  589. package/dist/sdk/history-provenance.js +1 -1
  590. package/dist/sdk/history-read.js +1 -1
  591. package/dist/sdk/history-redact.js +1 -1
  592. package/dist/sdk/history-repair.d.ts +8 -2
  593. package/dist/sdk/history-repair.js +1 -1
  594. package/dist/sdk/improvement-ledger-validation.js +1 -1
  595. package/dist/sdk/improvement-ledger.js +2 -2
  596. package/dist/sdk/index.d.ts +1 -1
  597. package/dist/sdk/init-agent-guidance.js +10 -10
  598. package/dist/sdk/init.js +14 -14
  599. package/dist/sdk/invocation-author.js +1 -1
  600. package/dist/sdk/item-children.js +1 -1
  601. package/dist/sdk/item-metadata-index.js +1 -1
  602. package/dist/sdk/item-schedule.js +1 -1
  603. package/dist/sdk/item-transaction.d.ts +33 -1
  604. package/dist/sdk/item-transaction.js +1 -1
  605. package/dist/sdk/learnings.js +1 -1
  606. package/dist/sdk/lifecycle/append.js +3 -3
  607. package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
  608. package/dist/sdk/lifecycle/claim.js +1 -1
  609. package/dist/sdk/lifecycle/cli-input.js +1 -1
  610. package/dist/sdk/lifecycle/close-many.js +1 -1
  611. package/dist/sdk/lifecycle/close.js +1 -1
  612. package/dist/sdk/lifecycle/copy.js +1 -1
  613. package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
  614. package/dist/sdk/lifecycle/core-item-fields.js +1 -1
  615. package/dist/sdk/lifecycle/create-deferrals.js +1 -1
  616. package/dist/sdk/lifecycle/create.js +1 -1
  617. package/dist/sdk/lifecycle/delete.js +1 -1
  618. package/dist/sdk/lifecycle/dependency-removal.js +1 -1
  619. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  620. package/dist/sdk/lifecycle/focus.js +1 -1
  621. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  622. package/dist/sdk/lifecycle/item-revision.js +1 -1
  623. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  624. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  625. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  626. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  627. package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
  628. package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
  629. package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
  630. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  631. package/dist/sdk/lifecycle/plan.js +1 -1
  632. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  633. package/dist/sdk/lifecycle/release-handoff.js +1 -1
  634. package/dist/sdk/lifecycle/reopen.js +1 -1
  635. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
  636. package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
  637. package/dist/sdk/lifecycle/restore.js +1 -1
  638. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  639. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  640. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  641. package/dist/sdk/lifecycle/task-composition.js +1 -1
  642. package/dist/sdk/lifecycle/update-many.js +1 -1
  643. package/dist/sdk/lifecycle/update.js +2 -2
  644. package/dist/sdk/lifecycle/workflow-transition.js +1 -1
  645. package/dist/sdk/lifecycle-completion.js +1 -1
  646. package/dist/sdk/lifecycle-policy.js +1 -1
  647. package/dist/sdk/linked-artifacts.js +2 -2
  648. package/dist/sdk/mcp/apps.js +5 -5
  649. package/dist/sdk/mcp/authorization.js +1 -1
  650. package/dist/sdk/mcp/discovery.js +1 -1
  651. package/dist/sdk/mcp/executable.js +4 -4
  652. package/dist/sdk/mcp/interactions.js +1 -1
  653. package/dist/sdk/mcp/protocol.js +1 -1
  654. package/dist/sdk/mcp/skills.js +3 -3
  655. package/dist/sdk/mcp/subscriptions.js +1 -1
  656. package/dist/sdk/mcp/tasks.js +2 -2
  657. package/dist/sdk/mcp/transport.js +1 -1
  658. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  659. package/dist/sdk/merge/driver.js +7 -7
  660. package/dist/sdk/merge/history-scalar-rebase.js +1 -1
  661. package/dist/sdk/merge/ignored-artifacts.js +1 -1
  662. package/dist/sdk/merge/index.js +1 -1
  663. package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
  664. package/dist/sdk/merge/install.js +6 -6
  665. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  666. package/dist/sdk/merge/receipt-operation.js +1 -1
  667. package/dist/sdk/merge/receipt-schema.js +1 -1
  668. package/dist/sdk/merge/receipts.js +4 -4
  669. package/dist/sdk/merge/reconcile.js +1 -1
  670. package/dist/sdk/merge/settlement-hook.js +4 -4
  671. package/dist/sdk/merge/stage.js +1 -1
  672. package/dist/sdk/merge/three-way.d.ts +22 -3
  673. package/dist/sdk/merge/three-way.js +9 -3
  674. package/dist/sdk/merge/worktree-config.js +2 -2
  675. package/dist/sdk/merge.js +1 -1
  676. package/dist/sdk/mutation-events.js +1 -1
  677. package/dist/sdk/mutation-guard.js +1 -1
  678. package/dist/sdk/notes.js +1 -1
  679. package/dist/sdk/output/fit-envelope.js +1 -1
  680. package/dist/sdk/output/list-envelope.js +1 -1
  681. package/dist/sdk/output/table-rows.js +1 -1
  682. package/dist/sdk/output-contracts.js +1 -1
  683. package/dist/sdk/output-projection.js +1 -1
  684. package/dist/sdk/output-token-accounting.js +1 -1
  685. package/dist/sdk/output.js +2 -2
  686. package/dist/sdk/ownership-source.js +1 -1
  687. package/dist/sdk/package-import-adapters.js +1 -1
  688. package/dist/sdk/package-migrations.js +1 -1
  689. package/dist/sdk/package-runtime-options.js +1 -1
  690. package/dist/sdk/pagination.js +1 -1
  691. package/dist/sdk/profile.js +5 -5
  692. package/dist/sdk/provenance.js +1 -1
  693. package/dist/sdk/public-surface.json +1 -1
  694. package/dist/sdk/query/activity.js +1 -1
  695. package/dist/sdk/query/aggregate.js +1 -1
  696. package/dist/sdk/query/calendar.js +4 -4
  697. package/dist/sdk/query/complete-list.js +1 -1
  698. package/dist/sdk/query/context.js +2 -2
  699. package/dist/sdk/query/declared-blockers.js +1 -1
  700. package/dist/sdk/query/duplicate-candidates.js +1 -1
  701. package/dist/sdk/query/get-facet-roots.js +1 -1
  702. package/dist/sdk/query/get.js +1 -1
  703. package/dist/sdk/query/history.js +1 -1
  704. package/dist/sdk/query/item-filter-options.js +0 -1
  705. package/dist/sdk/query/light-metadata.js +1 -1
  706. package/dist/sdk/query/list-filter-shared.js +1 -1
  707. package/dist/sdk/query/list.js +1 -1
  708. package/dist/sdk/query/multi-value-filters.js +1 -1
  709. package/dist/sdk/query/next-ranking-policy.js +1 -1
  710. package/dist/sdk/query/next-ready-budget.js +1 -1
  711. package/dist/sdk/query/next.js +2 -2
  712. package/dist/sdk/query/parsers.js +1 -1
  713. package/dist/sdk/query/projection-contracts.js +1 -1
  714. package/dist/sdk/query/search/corpus.js +2 -2
  715. package/dist/sdk/query/search/filters.js +1 -1
  716. package/dist/sdk/query/search/input.js +1 -1
  717. package/dist/sdk/query/search/lexical.js +1 -1
  718. package/dist/sdk/query/search/response.js +1 -1
  719. package/dist/sdk/query/search/semantic.js +3 -3
  720. package/dist/sdk/query/search/types.js +0 -1
  721. package/dist/sdk/query/search-contracts.js +1 -1
  722. package/dist/sdk/query/search-pagination.js +1 -1
  723. package/dist/sdk/query/search-rendering.js +1 -1
  724. package/dist/sdk/query/search.js +1 -1
  725. package/dist/sdk/query/window-pagination.js +1 -1
  726. package/dist/sdk/query/workspace-contracts.js +1 -1
  727. package/dist/sdk/read-output/continuation.js +1 -1
  728. package/dist/sdk/read-output/extension.js +1 -1
  729. package/dist/sdk/read-output/options.js +1 -1
  730. package/dist/sdk/read-output/positional-rows.js +1 -1
  731. package/dist/sdk/read-output/provenance.js +1 -1
  732. package/dist/sdk/read-output/session-result.js +0 -1
  733. package/dist/sdk/read-output/surfaces.js +1 -1
  734. package/dist/sdk/read-output/tail-retention.js +1 -1
  735. package/dist/sdk/read-output-budget.js +1 -1
  736. package/dist/sdk/read-output-contracts.js +1 -1
  737. package/dist/sdk/read-output-rows.js +1 -1
  738. package/dist/sdk/read-output-session.js +1 -1
  739. package/dist/sdk/relationship-analytics.js +1 -1
  740. package/dist/sdk/relationship-context.js +1 -1
  741. package/dist/sdk/relationship-history.js +6 -6
  742. package/dist/sdk/relationship-kinds/contract.js +1 -1
  743. package/dist/sdk/relationships.js +1 -1
  744. package/dist/sdk/reproducibility/process.js +1 -1
  745. package/dist/sdk/runtime/actions.js +1 -1
  746. package/dist/sdk/runtime/context.js +1 -1
  747. package/dist/sdk/runtime/mutation-admission.js +1 -1
  748. package/dist/sdk/runtime/mutation-value-validation.js +1 -1
  749. package/dist/sdk/runtime/schema-preview.js +1 -1
  750. package/dist/sdk/runtime/schema.js +1 -1
  751. package/dist/sdk/runtime-action-aliases.js +1 -1
  752. package/dist/sdk/runtime-extended-actions.js +1 -1
  753. package/dist/sdk/runtime-input.d.ts +8 -2
  754. package/dist/sdk/runtime-input.js +1 -1
  755. package/dist/sdk/runtime-primitives.d.ts +1 -1
  756. package/dist/sdk/runtime-primitives.js +1 -1
  757. package/dist/sdk/runtime-public-contracts.js +0 -1
  758. package/dist/sdk/runtime-stats-options.js +1 -1
  759. package/dist/sdk/runtime.d.ts +9 -0
  760. package/dist/sdk/runtime.js +1 -1
  761. package/dist/sdk/scheduling-shortcuts.js +1 -1
  762. package/dist/sdk/schema/field-option-collisions.js +2 -0
  763. package/dist/sdk/schema-migration.js +4 -4
  764. package/dist/sdk/schema.js +7 -7
  765. package/dist/sdk/search-refresh-worker.js +1 -1
  766. package/dist/sdk/similarity-scoring.js +1 -1
  767. package/dist/sdk/similarity.js +1 -1
  768. package/dist/sdk/start-task-status.js +1 -1
  769. package/dist/sdk/stats.js +1 -1
  770. package/dist/sdk/structured-mutations.d.ts +5 -5
  771. package/dist/sdk/structured-mutations.js +1 -1
  772. package/dist/sdk/telemetry-flush.js +1 -1
  773. package/dist/sdk/telemetry.js +4 -4
  774. package/dist/sdk/templates.js +3 -3
  775. package/dist/sdk/test/batch.js +2 -2
  776. package/dist/sdk/test/command-args.js +1 -1
  777. package/dist/sdk/test/command-resolution.js +2 -2
  778. package/dist/sdk/test/entry.js +2 -2
  779. package/dist/sdk/test/execution-receipts.js +2 -2
  780. package/dist/sdk/test/execution.js +5 -5
  781. package/dist/sdk/test/json-path.js +1 -1
  782. package/dist/sdk/test/linked-command-detection.js +1 -1
  783. package/dist/sdk/test/measurements.js +1 -1
  784. package/dist/sdk/test/parsers.js +1 -1
  785. package/dist/sdk/test/prerequisites.js +1 -1
  786. package/dist/sdk/test/receipt-index-snapshot.js +1 -1
  787. package/dist/sdk/test/run-phases.js +1 -1
  788. package/dist/sdk/test/runs.js +1 -1
  789. package/dist/sdk/test/trust.js +2 -2
  790. package/dist/sdk/test/update.js +1 -1
  791. package/dist/sdk/test/workspace-snapshot.js +1 -1
  792. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  793. package/dist/sdk/traceability/source-traceability.js +2 -2
  794. package/dist/sdk/tracker-root-discovery.js +1 -1
  795. package/dist/sdk/transactions/item-finalization.js +2 -0
  796. package/dist/sdk/workspace-contracts-cache.js +1 -1
  797. package/dist/sdk/workspace-contracts.js +1 -1
  798. package/dist/sdk/workspace-memory.js +2 -2
  799. package/dist/sdk/workspace-snapshot.js +5 -5
  800. package/dist/sdk/workspace-transaction-gc.js +1 -1
  801. package/dist/sdk/workspace-transaction.js +2 -2
  802. package/dist/sdk/workspace.js +6 -6
  803. package/dist/types/index.js +1 -1
  804. package/dist/types.d.ts +20 -0
  805. package/dist/types.js +1 -1
  806. package/docs/AGENT_GUIDE.md +1 -1
  807. package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
  808. package/docs/COMMANDS.md +7 -3
  809. package/docs/EXTENSIONS.md +1 -1
  810. package/docs/HISTORY_RECOVERY.md +229 -5
  811. package/docs/README.md +2 -2
  812. package/docs/SDK.md +174 -5
  813. package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
  814. package/marketplace.json +1 -1
  815. package/node_modules/tar/package.json +2 -3
  816. package/package.json +31 -2
  817. package/packages/pm-beads/package.json +1 -1
  818. package/packages/pm-calendar/package.json +1 -1
  819. package/packages/pm-command-kit/package.json +1 -1
  820. package/packages/pm-digital-twin/package.json +1 -1
  821. package/packages/pm-governance-audit/package.json +1 -1
  822. package/packages/pm-guide-shell/package.json +1 -1
  823. package/packages/pm-kanban/package.json +1 -1
  824. package/packages/pm-lifecycle-hooks/package.json +1 -1
  825. package/packages/pm-linked-test-adapters/package.json +1 -1
  826. package/packages/pm-search-advanced/package.json +1 -1
  827. package/packages/pm-templates/package.json +1 -1
  828. package/packages/pm-todos/package.json +1 -1
  829. package/packages/pm-vcs/package.json +1 -1
  830. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  831. package/plugins/pm-claude/package.json +1 -1
  832. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  833. package/plugins/pm-codex/package.json +1 -1
  834. package/plugins/pm-codex/plugin.json +1 -1
  835. package/runtime-dependencies.json +1 -1
  836. package/scripts/finalize-build.mjs +63 -24
  837. package/scripts/prepare-build-cache.mjs +28 -1
  838. package/dist/cli-bundle/chunks/chunk-2DXRTIC6.js +0 -21
  839. package/dist/cli-bundle/chunks/chunk-5647LU3A.js +0 -2287
  840. package/dist/cli-bundle/chunks/chunk-6QLEXRUG.js +0 -9
  841. package/dist/cli-bundle/chunks/chunk-AHQB7W2H.js +0 -3
  842. package/dist/cli-bundle/chunks/chunk-BKSVHOWI.js +0 -2
  843. package/dist/cli-bundle/chunks/chunk-CASX6SFI.js +0 -2
  844. package/dist/cli-bundle/chunks/chunk-CIKGG34F.js +0 -2
  845. package/dist/cli-bundle/chunks/chunk-D6ILFXZY.js +0 -2
  846. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  847. package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
  848. package/dist/cli-bundle/chunks/chunk-IUIOTAF6.js +0 -9
  849. package/dist/cli-bundle/chunks/chunk-JVGRFU5H.js +0 -3
  850. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
  851. package/dist/cli-bundle/chunks/chunk-KVBIMFUG.js +0 -6
  852. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
  853. package/dist/cli-bundle/chunks/chunk-NCFCBKIP.js +0 -2
  854. package/dist/cli-bundle/chunks/chunk-NT5AKFE5.js +0 -31
  855. package/dist/cli-bundle/chunks/chunk-PJXKA4QU.js +0 -125
  856. package/dist/cli-bundle/chunks/chunk-RMIRNYRG.js +0 -71
  857. package/dist/cli-bundle/chunks/chunk-RULHZRFN.js +0 -2
  858. package/dist/cli-bundle/chunks/chunk-S6HB3WL2.js +0 -2
  859. package/dist/cli-bundle/chunks/chunk-SA4BNP3Q.js +0 -2
  860. package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
  861. package/dist/cli-bundle/chunks/chunk-SRVTCYAU.js +0 -2
  862. package/dist/cli-bundle/chunks/chunk-WELSVDPU.js +0 -2
  863. package/dist/cli-bundle/chunks/chunk-XHJ3H5PL.js +0 -3
  864. package/dist/cli-bundle/chunks/chunk-XWHJIRNV.js +0 -8
  865. package/dist/cli-bundle/chunks/chunk-YJEBK7HU.js +0 -8
  866. package/dist/cli-bundle/chunks/chunk-YKJKQ7DM.js +0 -115
  867. package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
  868. package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
  869. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
  870. package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
  871. package/dist/cli-bundle/chunks/item-transaction-7DFCG73I.js +0 -2
  872. package/dist/cli-bundle/chunks/mutation-actor-3TG636XG.js +0 -2
  873. package/dist/cli-bundle/chunks/mutation-admission-LICSDNNO.js +0 -2
  874. package/dist/cli-bundle/chunks/register-mutation-WWVECKFQ.js +0 -21
  875. package/dist/cli-bundle/chunks/register-operations-L6HFJNWD.js +0 -2
  876. package/dist/cli-bundle/chunks/register-setup-K7UFG5TD.js +0 -2
  877. package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
  878. package/dist/cli-bundle/chunks/stage-57KH3KAC.js +0 -2
  879. package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
  880. package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
  881. package/dist/cli-bundle/focused-chunks/chunk-532WZV65.js +0 -2
  882. package/dist/cli-bundle/focused-chunks/chunk-7A4QWNZX.js +0 -8
  883. package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
  884. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
  885. package/dist/cli-bundle/focused-chunks/chunk-CU2BRAOX.js +0 -2
  886. package/dist/cli-bundle/focused-chunks/chunk-CWWKRI5P.js +0 -2
  887. package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
  888. package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
  889. package/dist/cli-bundle/focused-chunks/chunk-HGFNL5XI.js +0 -2
  890. package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
  891. package/dist/cli-bundle/focused-chunks/chunk-IQK5NPMG.js +0 -13
  892. package/dist/cli-bundle/focused-chunks/chunk-J63D6QST.js +0 -6
  893. package/dist/cli-bundle/focused-chunks/chunk-JMQJBZQ5.js +0 -2
  894. package/dist/cli-bundle/focused-chunks/chunk-LNHUE4VV.js +0 -2
  895. package/dist/cli-bundle/focused-chunks/chunk-MKM5NKD7.js +0 -8
  896. package/dist/cli-bundle/focused-chunks/chunk-NP72ZDXE.js +0 -2
  897. package/dist/cli-bundle/focused-chunks/chunk-OSLQD5VH.js +0 -102
  898. package/dist/cli-bundle/focused-chunks/chunk-QGKLRXP7.js +0 -2
  899. package/dist/cli-bundle/focused-chunks/chunk-QSJW6NSQ.js +0 -66
  900. package/dist/cli-bundle/focused-chunks/chunk-RPE6IX26.js +0 -2
  901. package/dist/cli-bundle/focused-chunks/chunk-SRDQSA6M.js +0 -91
  902. package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
  903. package/dist/cli-bundle/focused-chunks/chunk-UOC6257J.js +0 -26
  904. package/dist/cli-bundle/focused-chunks/chunk-URJ2E6AS.js +0 -3
  905. package/dist/cli-bundle/focused-chunks/chunk-WXMI4AV5.js +0 -8
  906. package/dist/cli-bundle/focused-chunks/chunk-XCJSHNXK.js +0 -27
  907. package/dist/cli-bundle/focused-chunks/chunk-XQQSSKJI.js +0 -44
  908. package/dist/cli-bundle/focused-chunks/chunk-YOAYY3HE.js +0 -2
  909. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
  910. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
  911. package/dist/cli-bundle/focused-chunks/item-transaction-HLBW7B3J.js +0 -2
  912. package/dist/cli-bundle/focused-chunks/mutation-actor-62HKR5IO.js +0 -2
  913. package/dist/cli-bundle/focused-chunks/mutation-admission-X4PF2SG3.js +0 -2
  914. package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
  915. package/dist/cli-bundle/focused-chunks/stage-O7T7CXBB.js +0 -2
  916. package/dist/sdk/agent/refusal-closure.js +0 -2
  917. package/dist/sdk/agent/refusal-reachability.js +0 -4
  918. package/dist/sdk/agent/task-transcript-contracts.js +0 -2
  919. package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
  920. package/dist/sdk/authoring.js +0 -2
  921. package/dist/sdk/compose.js +0 -2
  922. package/dist/sdk/contracts.js +0 -2
  923. package/dist/sdk/core-governance.js +0 -2
  924. package/dist/sdk/core.js +0 -2
  925. package/dist/sdk/corpus-shape.js +0 -2
  926. package/dist/sdk/define.js +0 -2
  927. package/dist/sdk/environment/agent-environment.js +0 -2
  928. package/dist/sdk/governance/artifact-ledgers.js +0 -2
  929. package/dist/sdk/governance/coverage-assurance.js +0 -2
  930. package/dist/sdk/governance/reliability.js +0 -2
  931. package/dist/sdk/governance.js +0 -2
  932. package/dist/sdk/graph/adapter.js +0 -2
  933. package/dist/sdk/graph/conformance.js +0 -2
  934. package/dist/sdk/graph/index.js +0 -2
  935. package/dist/sdk/graph.js +0 -2
  936. package/dist/sdk/index.js +0 -2
  937. package/dist/sdk/query.js +0 -2
  938. package/dist/sdk/relationship-migration.js +0 -2
  939. package/dist/sdk/testing.js +0 -8
  940. package/dist/sdk/workspace-recipe.js +0 -2
  941. package/docs/AGENT_PROVENANCE_ADR.md +0 -206
  942. package/docs/DEFECT_RECURRENCE.md +0 -257
  943. package/docs/PERFORMANCE.md +0 -204
@@ -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]="99f2a736-ba4b-57e7-a671-08b30c4aa761")}catch{}})();import{unicodeSafePrefix}from"../shared/text-normalization.js";import{cloneMutationActor}from"./mutation-actor-snapshot.js";import{cloneCommandOptionsSnapshot,cloneContextSnapshot,cloneGlobalOptionsSnapshot,normalizeCommandName}from"./extension-runtime-helpers.js";import{stableValueEquals}from"../shared/serialization.js";import{EXIT_CODE}from"../shared/constants.js";import{PmCliError}from"../shared/errors.js";const DEFAULT_MUTATION_GUARD_TIMEOUT_MS=5e3;async function executeRegisteredHooks(entries,hookName,context){const warnings=[];for(const entry of entries)try{await entry.run(cloneContextSnapshot(context))}catch{warnings.push(`extension_hook_failed:${entry.layer}:${entry.name}:${hookName}`)}return warnings}async function runBeforeCommandHooks(hooks,context){return executeRegisteredHooks(hooks.beforeCommand,"beforeCommand",context)}function enforceMutationGuardDecision(decision,entry,operation){if(decision===void 0)return;if(typeof decision!="object"||decision===null||!("allow"in decision)||decision.allow!==!0&&decision.allow!==!1)throw new PmCliError(`Extension mutation guard ${entry.name} returned an invalid decision.`,EXIT_CODE.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${entry.layer}:${entry.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(decision.allow)return;const denial=decision,code=typeof denial.code=="string"?denial.code.trim():"",remediation=typeof denial.remediation=="string"?denial.remediation.trim():"";if(code.length===0||remediation.length===0)throw new PmCliError(`Extension mutation guard ${entry.name} returned an invalid denial.`,EXIT_CODE.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${entry.layer}:${entry.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});const message=typeof denial.message=="string"?denial.message.trim():"";throw new PmCliError(message||`Extension mutation guard ${entry.name} denied ${operation}.`,EXIT_CODE.CONFLICT,{code,reason:`${entry.layer}:${entry.name}`,nextSteps:[remediation]})}async function runBeforeMutationHooks(hooks,context){const overrides=[];for(const entry of hooks.beforeMutation??[])try{await evaluateMutationGuard(entry,context)}catch(error){if(context.compensation===void 0)throw error;overrides.push({guard:`${entry.layer}:${entry.name}`,code:error.code??"extension_mutation_guard_failed"})}return overrides}async function evaluateMutationGuard(entry,context){let decision,timeoutHandle;try{const guardPromise=Promise.resolve().then(()=>entry.run({pm_root:context.pm_root,operation:context.operation,before:context.before===null?null:cloneContextSnapshot(context.before),after:context.after===null?null:cloneContextSnapshot(context.after),changed_fields:[...context.changed_fields],actor:cloneMutationActor(context.actor),dry_run:context.dry_run,...context.compensation===void 0?{}:{compensation:Object.freeze({transaction_id:context.compensation.transaction_id,step_id:context.compensation.step_id})},sdk:context.sdk}));guardPromise.catch(()=>{}),decision=await Promise.race([guardPromise,new Promise((_,reject)=>{timeoutHandle=setTimeout(()=>{reject(new PmCliError(`Extension mutation guard ${entry.name} timed out before ${context.operation}.`,EXIT_CODE.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${entry.layer}:${entry.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},DEFAULT_MUTATION_GUARD_TIMEOUT_MS),timeoutHandle.unref?.()})]),enforceMutationGuardDecision(decision,entry,context.operation)}catch(error){throw error instanceof PmCliError?error:new PmCliError(`Extension mutation guard ${entry.name} failed before ${context.operation}.`,EXIT_CODE.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${entry.layer}:${entry.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(timeoutHandle)}}async function runAfterCommandHooks(hooks,context){return executeRegisteredHooks(hooks.afterCommand,"afterCommand",context)}async function runOnWriteHooks(hooks,context){return executeRegisteredHooks(hooks.onWrite,"onWrite",context)}async function runOnReadHooks(hooks,context){return executeRegisteredHooks(hooks.onRead,"onRead",context)}async function runOnIndexHooks(hooks,context){return executeRegisteredHooks(hooks.onIndex,"onIndex",context)}function describeHandlerError(error){let raw="";error instanceof Error&&typeof error.message=="string"?raw=error.message:typeof error=="string"?raw=error:typeof error=="object"&&error!==null&&typeof error.message=="string"&&(raw=error.message);const normalized=raw.replace(/\s+/gu," ").trim();if(normalized.length===0)return"";const maxLength=300;return normalized.length>maxLength?`${unicodeSafePrefix(normalized,maxLength-1)}\u2026`:normalized}function readHandlerStringField(value,field){if(typeof value!="object"||value===null||typeof value[field]!="string")return;const normalized=String(value[field]).replace(/\s+/gu," ").trim();return normalized.length>0?unicodeSafePrefix(normalized,300):void 0}function readHandlerResultExitCode(result){if(typeof result!="object"||result===null||!Object.hasOwn(result,"exit_code"))return;const exitCode=result.exit_code;if(typeof exitCode!="number"||!Number.isInteger(exitCode)||exitCode<1||exitCode>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return exitCode}async function runCommandHandler(commands,context){const command=normalizeCommandName(context.command);if(command.length===0)return{handled:!1,result:null,warnings:[]};const matched=[...commands.handlers].reverse().find(entry=>entry.command===command);if(!matched)return{handled:!1,result:null,warnings:[]};try{const result=await matched.run({command,args:cloneContextSnapshot(context.args),options:cloneContextSnapshot(context.options),global:cloneContextSnapshot(context.global),pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel,...context.sdk===void 0?{}:{sdk:context.sdk}});return{handled:!0,result,warnings:[],...Object.fromEntries([["exitCode",readHandlerResultExitCode(result)],["errorCode",readHandlerStringField(result,"code")],["remediation",readHandlerStringField(result,"remediation")]].filter(entry=>entry[1]!==void 0))}}catch(error){const exitCode=typeof error=="object"&&error!==null&&"exitCode"in error?error.exitCode:void 0;if(typeof exitCode=="number"&&Number.isFinite(exitCode))throw error;return Object.defineProperty({handled:!1,result:null,warnings:[`extension_command_handler_failed:${matched.layer}:${matched.name}:${matched.command}`],errorMessage:describeHandlerError(error),...Object.fromEntries([["errorCode",readHandlerStringField(error,"code")],["remediation",readHandlerStringField(error,"remediation")]].filter(entry=>entry[1]!==void 0))},"cause",{value:error,configurable:!0})}}async function runParserOverride(parsers,context){const command=normalizeCommandName(context.command);if(command.length===0)return{overridden:!1,context:{command,args:cloneContextSnapshot(context.args),options:cloneCommandOptionsSnapshot(context.options),global:cloneGlobalOptionsSnapshot(context.global),pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel},warnings:[]};const matched=[...parsers.overrides].reverse().find(entry=>entry.command===command);if(!matched)return{overridden:!1,context:{command,args:cloneContextSnapshot(context.args),options:cloneCommandOptionsSnapshot(context.options),global:cloneGlobalOptionsSnapshot(context.global),pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel},warnings:[]};try{const delta=await Promise.resolve(matched.run({command,args:cloneContextSnapshot(context.args),options:cloneCommandOptionsSnapshot(context.options),global:cloneGlobalOptionsSnapshot(context.global),pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel}))??{},nextArgs=Array.isArray(delta.args)?cloneContextSnapshot(delta.args):cloneContextSnapshot(context.args),nextOptions=delta.options?cloneCommandOptionsSnapshot(delta.options):cloneCommandOptionsSnapshot(context.options),nextGlobal=delta.global?cloneGlobalOptionsSnapshot(delta.global):cloneGlobalOptionsSnapshot(context.global);return{overridden:!0,context:{command,args:nextArgs,options:nextOptions,global:nextGlobal,pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel},warnings:[]}}catch{return{overridden:!1,context:{command,args:cloneContextSnapshot(context.args),options:cloneCommandOptionsSnapshot(context.options),global:cloneGlobalOptionsSnapshot(context.global),pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel},warnings:[`extension_parser_override_failed:${matched.layer}:${matched.name}:${matched.command}`]}}}async function runPreflightOverride(preflight,context){const baseContext={command:normalizeCommandName(context.command),args:cloneContextSnapshot(context.args),options:cloneCommandOptionsSnapshot(context.options),global:cloneGlobalOptionsSnapshot(context.global),pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel},baseDecision=cloneContextSnapshot(context.decision),matched=[...preflight.overrides].reverse().find(entry=>!entry.commands?.length||entry.commands.includes(baseContext.command));if(!matched)return{overridden:!1,context:baseContext,decision:baseDecision,warnings:[]};try{const delta=await Promise.resolve(matched.run({command:baseContext.command,args:cloneContextSnapshot(baseContext.args),options:cloneCommandOptionsSnapshot(baseContext.options),global:cloneGlobalOptionsSnapshot(baseContext.global),pm_root:baseContext.pm_root,source_workspace_root:baseContext.source_workspace_root,repo_root:baseContext.repo_root,pm_root_rel:baseContext.pm_root_rel,decision:cloneContextSnapshot(baseDecision)}))??{},nextContext={command:baseContext.command,args:Array.isArray(delta.args)?cloneContextSnapshot(delta.args):baseContext.args,options:delta.options?cloneCommandOptionsSnapshot(delta.options):baseContext.options,global:delta.global?cloneGlobalOptionsSnapshot(delta.global):baseContext.global,pm_root:baseContext.pm_root,source_workspace_root:baseContext.source_workspace_root,repo_root:baseContext.repo_root,pm_root_rel:baseContext.pm_root_rel},nextDecision={enforce_item_format_gate:typeof delta.enforce_item_format_gate=="boolean"?delta.enforce_item_format_gate:baseDecision.enforce_item_format_gate,run_preflight_item_format_sync:typeof delta.run_preflight_item_format_sync=="boolean"?delta.run_preflight_item_format_sync:baseDecision.run_preflight_item_format_sync,run_extension_migrations:typeof delta.run_extension_migrations=="boolean"?delta.run_extension_migrations:baseDecision.run_extension_migrations,enforce_mandatory_migration_gate:typeof delta.enforce_mandatory_migration_gate=="boolean"?delta.enforce_mandatory_migration_gate:baseDecision.enforce_mandatory_migration_gate};return{overridden:!0,context:nextContext,decision:nextDecision,warnings:[]}}catch{return{overridden:!1,context:baseContext,decision:baseDecision,warnings:[`extension_preflight_override_failed:${matched.layer}:${matched.name}`]}}}function resolveDefaultServiceResult(context){return{handled:!1,result:context.payload,warnings:[]}}function matchingServiceOverrides(services,service){return[...services.overrides].reverse().filter(entry=>entry.service===service)}function buildServiceOverrideContext(context){return{service:context.service,command:context.command?normalizeCommandName(context.command):void 0,args:context.args?cloneContextSnapshot(context.args):void 0,options:context.options?cloneCommandOptionsSnapshot(context.options):void 0,global:context.global?cloneGlobalOptionsSnapshot(context.global):void 0,pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel,payload:cloneContextSnapshot(context.payload)}}function isServiceOverrideDecision(value){if(typeof value!="object"||value===null||!Object.hasOwn(value,"handled"))return!1;const handled=value.handled;return handled===!0?Object.hasOwn(value,"result"):handled===!1&&Reflect.ownKeys(value).length===1}function resolveServiceOverrideValue(result,context){return isServiceOverrideDecision(result)?result.handled?{handled:!0,result:result.result}:{handled:!1,result:context.payload}:context.service==="output_format"&&result==null?{handled:!1,result:context.payload}:{handled:!0,result}}function isLegacyOutputPayloadEcho(result,context,serviceContext){return context.service==="output_format"&&typeof result=="object"&&result!==null&&stableValueEquals(result,serviceContext.payload)}function resolveMatchedServiceDecision(matched,decision,warnings){if(decision.handled){if(matched.passThrough===!0){warnings.push(`extension_service_pass_through_contract_violated:${matched.layer}:${matched.name}:${matched.service}`);return}return{handled:!0,result:decision.result,warnings}}}function runServiceOverrideSync(services,context){const matches=matchingServiceOverrides(services,context.service);if(matches.length===0)return resolveDefaultServiceResult(context);const warnings=[];for(const matched of matches)try{const serviceContext=buildServiceOverrideContext(context),result=matched.run(serviceContext);if(result instanceof Promise){warnings.push(`extension_service_override_async_unsupported:${matched.layer}:${matched.name}:${matched.service}`);continue}if(isLegacyOutputPayloadEcho(result,context,serviceContext)){warnings.push(`extension_output_format_payload_echo_deprecated:${matched.layer}:${matched.name}`);continue}const resolved=resolveMatchedServiceDecision(matched,resolveServiceOverrideValue(result,context),warnings);if(resolved)return resolved}catch{warnings.push(`extension_service_override_failed:${matched.layer}:${matched.name}:${matched.service}`)}return{handled:!1,result:context.payload,warnings}}async function runServiceOverride(services,context){const matches=matchingServiceOverrides(services,context.service);if(matches.length===0)return resolveDefaultServiceResult(context);const warnings=[];for(const matched of matches)try{const serviceContext=buildServiceOverrideContext(context),result=await Promise.resolve(matched.run(serviceContext));if(isLegacyOutputPayloadEcho(result,context,serviceContext)){warnings.push(`extension_output_format_payload_echo_deprecated:${matched.layer}:${matched.name}`);continue}const resolved=resolveMatchedServiceDecision(matched,resolveServiceOverrideValue(result,context),warnings);if(resolved)return resolved}catch{warnings.push(`extension_service_override_failed:${matched.layer}:${matched.name}:${matched.service}`)}return{handled:!1,result:context.payload,warnings}}function runCommandOverride(commands,context){const command=normalizeCommandName(context.command);if(command.length===0)return{overridden:!1,result:context.result,warnings:[]};const matched=[...commands.overrides].reverse().find(entry=>entry.command===command);if(!matched)return{overridden:!1,result:context.result,warnings:[]};try{const overrideOptions=cloneCommandOptionsSnapshot(context.options),overrideGlobal=cloneGlobalOptionsSnapshot(context.global),overrideResult=matched.run({command,args:cloneContextSnapshot(context.args),options:overrideOptions,global:overrideGlobal,pm_root:context.pm_root,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel,result:cloneContextSnapshot(context.result)});return overrideResult instanceof Promise?{overridden:!1,result:context.result,warnings:[`extension_command_override_async_unsupported:${matched.layer}:${matched.name}:${matched.command}`]}:{overridden:!0,result:overrideResult,warnings:[]}}catch{return{overridden:!1,result:context.result,warnings:[`extension_command_override_failed:${matched.layer}:${matched.name}:${matched.command}`]}}}function rendererOwnsContext(entry,command,result){if((entry.commands?.length??0)>0&&!entry.commands?.includes(command))return!1;if(entry.resultDiscriminator===void 0)return!0;try{return entry.resultDiscriminator(cloneContextSnapshot(result))}catch{return!1}}function runRendererOverride(renderers,context){const rendererCommand=typeof context.command=="string"?normalizeCommandName(context.command):"",matched=[...renderers.overrides].reverse().find(entry=>entry.format===context.format&&rendererOwnsContext(entry,rendererCommand,context.result));if(!matched)return{overridden:!1,rendered:null,warnings:[]};try{const rendererArgs=Array.isArray(context.args)?cloneContextSnapshot(context.args):[],rendererOptions=cloneCommandOptionsSnapshot(context.options),rendererGlobal=cloneGlobalOptionsSnapshot(context.global),rendererPmRoot=typeof context.pm_root=="string"?context.pm_root:"",rendered=matched.run({format:context.format,command:rendererCommand,args:rendererArgs,options:rendererOptions,global:rendererGlobal,pm_root:rendererPmRoot,source_workspace_root:context.source_workspace_root,repo_root:context.repo_root,pm_root_rel:context.pm_root_rel,result:cloneContextSnapshot(context.result)});return rendered==null?{overridden:!1,rendered:null,warnings:[]}:typeof rendered!="string"?{overridden:!1,rendered:null,warnings:[`extension_renderer_invalid_result:${matched.layer}:${matched.name}:${matched.format}`]}:{overridden:!0,rendered,warnings:[]}}catch{return{overridden:!1,rendered:null,warnings:[`extension_renderer_failed:${matched.layer}:${matched.name}:${matched.format}`]}}}export{runAfterCommandHooks,runBeforeCommandHooks,runBeforeMutationHooks,runCommandHandler,runCommandOverride,runOnIndexHooks,runOnReadHooks,runOnWriteHooks,runParserOverride,runPreflightOverride,runRendererOverride,runServiceOverride,runServiceOverrideSync};
1
+ import{unicodeSafePrefix as h}from"../shared/text-normalization.js";import{cloneMutationActor as O}from"./mutation-actor-snapshot.js";import{cloneCommandOptionsSnapshot as d,cloneContextSnapshot as t,cloneGlobalOptionsSnapshot as l,normalizeCommandName as m}from"./extension-runtime-helpers.js";import{stableValueEquals as k}from"../shared/serialization.js";import{EXIT_CODE as f}from"../shared/constants.js";import{PmCliError as _}from"../shared/errors.js";const S=5e3;async function p(r,e,n){const a=[];for(const o of r)try{await o.run(t(n))}catch{a.push(`extension_hook_failed:${o.layer}:${o.name}:${e}`)}return a}async function L(r,e){return p(r.beforeCommand,"beforeCommand",e)}function E(r,e,n){if(r===void 0)return;if(typeof r!="object"||r===null||!("allow"in r)||r.allow!==!0&&r.allow!==!1)throw new _(`Extension mutation guard ${e.name} returned an invalid decision.`,f.CONFLICT,{code:"extension_mutation_guard_invalid_decision",reason:`${e.layer}:${e.name}`,nextSteps:["Return { allow: true } or a structured denial from the guard."]});if(r.allow)return;const a=r,o=typeof a.code=="string"?a.code.trim():"",s=typeof a.remediation=="string"?a.remediation.trim():"";if(o.length===0||s.length===0)throw new _(`Extension mutation guard ${e.name} returned an invalid denial.`,f.CONFLICT,{code:"extension_mutation_guard_invalid_denial",reason:`${e.layer}:${e.name}`,nextSteps:["Return non-empty code and remediation fields from the guard."]});const i=typeof a.message=="string"?a.message.trim():"";throw new _(i||`Extension mutation guard ${e.name} denied ${n}.`,f.CONFLICT,{code:o,reason:`${e.layer}:${e.name}`,nextSteps:[s]})}async function G(r,e){const n=[];for(const a of r.beforeMutation??[])try{await P(a,e)}catch(o){if(e.compensation===void 0)throw o;n.push({guard:`${a.layer}:${a.name}`,code:o.code??"extension_mutation_guard_failed"})}return n}async function P(r,e){let n,a;try{const o=Promise.resolve().then(()=>r.run({pm_root:e.pm_root,operation:e.operation,before:e.before===null?null:t(e.before),after:e.after===null?null:t(e.after),changed_fields:[...e.changed_fields],actor:O(e.actor),dry_run:e.dry_run,...e.compensation===void 0?{}:{compensation:Object.freeze({transaction_id:e.compensation.transaction_id,step_id:e.compensation.step_id})},sdk:e.sdk}));o.catch(()=>{}),n=await Promise.race([o,new Promise((s,i)=>{a=setTimeout(()=>{i(new _(`Extension mutation guard ${r.name} timed out before ${e.operation}.`,f.CONFLICT,{code:"extension_mutation_guard_timed_out",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the stalled extension guard, then retry the mutation."]}))},S),a.unref?.()})]),E(n,r,e.operation)}catch(o){throw o instanceof _?o:new _(`Extension mutation guard ${r.name} failed before ${e.operation}.`,f.CONFLICT,{code:"extension_mutation_guard_failed",reason:`${r.layer}:${r.name}`,nextSteps:["Fix or disable the failing extension guard, then retry the mutation."]})}finally{clearTimeout(a)}}async function z(r,e){return p(r.afterCommand,"afterCommand",e)}async function U(r,e){return p(r.onWrite,"onWrite",e)}async function W(r,e){return p(r.onRead,"onRead",e)}async function B(r,e){return p(r.onIndex,"onIndex",e)}function T(r){let e="";r instanceof Error&&typeof r.message=="string"?e=r.message:typeof r=="string"?e=r:typeof r=="object"&&r!==null&&typeof r.message=="string"&&(e=r.message);const n=e.replace(/\s+/gu," ").trim();if(n.length===0)return"";const a=300;return n.length>a?`${h(n,a-1)}\u2026`:n}function g(r,e){if(typeof r!="object"||r===null||typeof r[e]!="string")return;const n=String(r[e]).replace(/\s+/gu," ").trim();return n.length>0?h(n,300):void 0}function j(r){if(typeof r!="object"||r===null||!Object.hasOwn(r,"exit_code"))return;const e=r.exit_code;if(typeof e!="number"||!Number.isInteger(e)||e<1||e>255)throw new TypeError("Extension command result exit_code must be an integer from 1 to 255.");return e}async function V(r,e){const n=m(e.command);if(n.length===0)return{handled:!1,result:null,warnings:[]};const a=[...r.handlers].reverse().find(o=>o.command===n);if(!a)return{handled:!1,result:null,warnings:[]};try{const o=await a.run({command:n,args:t(e.args),options:t(e.options),global:t(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,...e.sdk===void 0?{}:{sdk:e.sdk}});return{handled:!0,result:o,warnings:[],...Object.fromEntries([["exitCode",j(o)],["errorCode",g(o,"code")],["remediation",g(o,"remediation")]].filter(s=>s[1]!==void 0))}}catch(o){const s=typeof o=="object"&&o!==null&&"exitCode"in o?o.exitCode:void 0;if(typeof s=="number"&&Number.isFinite(s))throw o;return Object.defineProperty({handled:!1,result:null,warnings:[`extension_command_handler_failed:${a.layer}:${a.name}:${a.command}`],errorMessage:T(o),...Object.fromEntries([["errorCode",g(o,"code")],["remediation",g(o,"remediation")]].filter(i=>i[1]!==void 0))},"cause",{value:o,configurable:!0})}}async function q(r,e){const n=m(e.command);if(n.length===0)return{overridden:!1,context:{command:n,args:t(e.args),options:d(e.options),global:l(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel},warnings:[]};const a=[...r.overrides].reverse().find(o=>o.command===n);if(!a)return{overridden:!1,context:{command:n,args:t(e.args),options:d(e.options),global:l(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel},warnings:[]};try{const o=await Promise.resolve(a.run({command:n,args:t(e.args),options:d(e.options),global:l(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel}))??{},s=Array.isArray(o.args)?t(o.args):t(e.args),i=o.options?d(o.options):d(e.options),u=o.global?l(o.global):l(e.global);return{overridden:!0,context:{command:n,args:s,options:i,global:u,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel},warnings:[]}}catch{return{overridden:!1,context:{command:n,args:t(e.args),options:d(e.options),global:l(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel},warnings:[`extension_parser_override_failed:${a.layer}:${a.name}:${a.command}`]}}}async function K(r,e){const n={command:m(e.command),args:t(e.args),options:d(e.options),global:l(e.global),pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel},a=t(e.decision),o=[...r.overrides].reverse().find(s=>!s.commands?.length||s.commands.includes(n.command));if(!o)return{overridden:!1,context:n,decision:a,warnings:[]};try{const s=await Promise.resolve(o.run({command:n.command,args:t(n.args),options:d(n.options),global:l(n.global),pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,decision:t(a)}))??{},i={command:n.command,args:Array.isArray(s.args)?t(s.args):n.args,options:s.options?d(s.options):n.options,global:s.global?l(s.global):n.global,pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel},u={enforce_item_format_gate:typeof s.enforce_item_format_gate=="boolean"?s.enforce_item_format_gate:a.enforce_item_format_gate,run_preflight_item_format_sync:typeof s.run_preflight_item_format_sync=="boolean"?s.run_preflight_item_format_sync:a.run_preflight_item_format_sync,run_extension_migrations:typeof s.run_extension_migrations=="boolean"?s.run_extension_migrations:a.run_extension_migrations,enforce_mandatory_migration_gate:typeof s.enforce_mandatory_migration_gate=="boolean"?s.enforce_mandatory_migration_gate:a.enforce_mandatory_migration_gate};return{overridden:!0,context:i,decision:u,warnings:[]}}catch{return{overridden:!1,context:n,decision:a,warnings:[`extension_preflight_override_failed:${o.layer}:${o.name}`]}}}function y(r){return{handled:!1,result:r.payload,warnings:[]}}function v(r,e){return[...r.overrides].reverse().filter(n=>n.service===e)}function w(r){return{service:r.service,command:r.command?m(r.command):void 0,args:r.args?t(r.args):void 0,options:r.options?d(r.options):void 0,global:r.global?l(r.global):void 0,pm_root:r.pm_root,source_workspace_root:r.source_workspace_root,repo_root:r.repo_root,pm_root_rel:r.pm_root_rel,payload:t(r.payload)}}function A(r){if(typeof r!="object"||r===null||!Object.hasOwn(r,"handled"))return!1;const e=r.handled;return e===!0?Object.hasOwn(r,"result"):e===!1&&Reflect.ownKeys(r).length===1}function b(r,e){return A(r)?r.handled?{handled:!0,result:r.result}:{handled:!1,result:e.payload}:e.service==="output_format"&&r==null?{handled:!1,result:e.payload}:{handled:!0,result:r}}function $(r,e,n){return e.service==="output_format"&&typeof r=="object"&&r!==null&&k(r,n.payload)}function C(r,e,n){if(e.handled){if(r.passThrough===!0){n.push(`extension_service_pass_through_contract_violated:${r.layer}:${r.name}:${r.service}`);return}return{handled:!0,result:e.result,warnings:n}}}function X(r,e){const n=v(r,e.service);if(n.length===0)return y(e);const a=[];for(const o of n)try{const s=w(e),i=o.run(s);if(i instanceof Promise){a.push(`extension_service_override_async_unsupported:${o.layer}:${o.name}:${o.service}`);continue}if($(i,e,s)){a.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}const u=C(o,b(i,e),a);if(u)return u}catch{a.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:e.payload,warnings:a}}async function J(r,e){const n=v(r,e.service);if(n.length===0)return y(e);const a=[];for(const o of n)try{const s=w(e),i=await Promise.resolve(o.run(s));if($(i,e,s)){a.push(`extension_output_format_payload_echo_deprecated:${o.layer}:${o.name}`);continue}const u=C(o,b(i,e),a);if(u)return u}catch{a.push(`extension_service_override_failed:${o.layer}:${o.name}:${o.service}`)}return{handled:!1,result:e.payload,warnings:a}}function Q(r,e){const n=m(e.command);if(n.length===0)return{overridden:!1,result:e.result,warnings:[]};const a=[...r.overrides].reverse().find(o=>o.command===n);if(!a)return{overridden:!1,result:e.result,warnings:[]};try{const o=d(e.options),s=l(e.global),i=a.run({command:n,args:t(e.args),options:o,global:s,pm_root:e.pm_root,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,result:t(e.result)});return i instanceof Promise?{overridden:!1,result:e.result,warnings:[`extension_command_override_async_unsupported:${a.layer}:${a.name}:${a.command}`]}:{overridden:!0,result:i,warnings:[]}}catch{return{overridden:!1,result:e.result,warnings:[`extension_command_override_failed:${a.layer}:${a.name}:${a.command}`]}}}function R(r,e,n){if((r.commands?.length??0)>0&&!r.commands?.includes(e))return!1;if(r.resultDiscriminator===void 0)return!0;try{return r.resultDiscriminator(t(n))}catch{return!1}}function Y(r,e){const n=typeof e.command=="string"?m(e.command):"",a=[...r.overrides].reverse().find(o=>o.format===e.format&&R(o,n,e.result));if(!a)return{overridden:!1,rendered:null,warnings:[]};try{const o=Array.isArray(e.args)?t(e.args):[],s=d(e.options),i=l(e.global),u=typeof e.pm_root=="string"?e.pm_root:"",c=a.run({format:e.format,command:n,args:o,options:s,global:i,pm_root:u,source_workspace_root:e.source_workspace_root,repo_root:e.repo_root,pm_root_rel:e.pm_root_rel,result:t(e.result)});return c==null?{overridden:!1,rendered:null,warnings:[]}:typeof c!="string"?{overridden:!1,rendered:null,warnings:[`extension_renderer_invalid_result:${a.layer}:${a.name}:${a.format}`]}:{overridden:!0,rendered:c,warnings:[]}}catch{return{overridden:!1,rendered:null,warnings:[`extension_renderer_failed:${a.layer}:${a.name}:${a.format}`]}}}export{z as runAfterCommandHooks,L as runBeforeCommandHooks,G as runBeforeMutationHooks,V as runCommandHandler,Q as runCommandOverride,B as runOnIndexHooks,W as runOnReadHooks,U as runOnWriteHooks,q as runParserOverride,K as runPreflightOverride,Y as runRendererOverride,J as runServiceOverride,X as runServiceOverrideSync};
2
2
  //# sourceMappingURL=extension-hook-runtime.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]="bb1b4879-079c-50d4-afa5-e8a36ead2e5c")}catch{}})();import{KNOWN_EXTENSION_POLICY_MODES,KNOWN_EXTENSION_POLICY_SURFACES,KNOWN_EXTENSION_SANDBOX_PROFILES,KNOWN_EXTENSION_TRUST_MODES,KNOWN_PM_MAX_VERSION_EXCEEDED_MODES}from"./extension-types.js";import{isKnownExtensionCapability}from"./extension-capability-aliases.js";import{normalizeCommandName}from"./extension-runtime-helpers.js";function normalizePolicyName(value){return typeof value!="string"?"":value.trim().toLowerCase()}function normalizePolicyStringSet(values){return new Set((values??[]).map(value=>value.trim().toLowerCase()).filter(value=>value.length>0))}function normalizePolicySurfaceToken(value){const normalized=value.trim().toLowerCase();if(normalized.length===0)return"";const segments=normalized.split(/[.:/]/).map(segment=>segment.replace(/[\s_-]+/g,"")).filter(segment=>segment.length>0);return segments.length===0?"":segments.length===1?segments[0]:`${segments[0]}.${segments.slice(1).join("")}`}function normalizePolicySurfaceSet(values){return new Set((values??[]).map(value=>normalizePolicySurfaceToken(value)).filter(value=>value.length>0))}function normalizePolicyMode(value){const normalized=normalizePolicyName(value);return KNOWN_EXTENSION_POLICY_MODES.includes(normalized)?normalized:"off"}function normalizePolicyTrustMode(value){const normalized=normalizePolicyName(value);return KNOWN_EXTENSION_TRUST_MODES.includes(normalized)?normalized:"off"}function normalizePolicySandboxProfile(value){const normalized=normalizePolicyName(value);return KNOWN_EXTENSION_SANDBOX_PROFILES.includes(normalized)?normalized:"none"}function normalizePmMaxVersionExceededModeValue(value){if(typeof value!="string")return;const normalized=value.trim().toLowerCase();return KNOWN_PM_MAX_VERSION_EXCEEDED_MODES.includes(normalized)?normalized:void 0}function normalizePmMaxVersionExceededMode(value){if(typeof value=="string"){const mode=normalizePmMaxVersionExceededModeValue(value)??"block";return{global:mode,project:mode}}return typeof value=="object"&&value!==null&&!Array.isArray(value)?{global:normalizePmMaxVersionExceededModeValue(value.global)??"block",project:normalizePmMaxVersionExceededModeValue(value.project)??"block"}:{global:"block",project:"block"}}function serializePmMaxVersionExceededMode(mode){return mode.global===mode.project?mode.global:{global:mode.global,project:mode.project}}function toSortedList(values){return[...new Set(values)].sort((left,right)=>left.localeCompare(right))}function buildExtensionPolicyOverride(rawOverride){const name=normalizePolicyName(rawOverride.name);return name.length===0?null:{name,normalized:{name,disabled:rawOverride.disabled===!0,requireTrusted:rawOverride.require_trusted===!0,requireProvenance:rawOverride.require_provenance===!0,sandboxProfile:rawOverride.sandbox_profile!==void 0?normalizePolicySandboxProfile(rawOverride.sandbox_profile):void 0,allowedCapabilities:normalizePolicyStringSet(rawOverride.allowed_capabilities),blockedCapabilities:normalizePolicyStringSet(rawOverride.blocked_capabilities),allowedSurfaces:normalizePolicySurfaceSet(rawOverride.allowed_surfaces),blockedSurfaces:normalizePolicySurfaceSet(rawOverride.blocked_surfaces),allowedCommands:normalizePolicyStringSet(rawOverride.allowed_commands),blockedCommands:normalizePolicyStringSet(rawOverride.blocked_commands),allowedActions:normalizePolicyStringSet(rawOverride.allowed_actions),blockedActions:normalizePolicyStringSet(rawOverride.blocked_actions),allowedServices:normalizePolicyStringSet(rawOverride.allowed_services),blockedServices:normalizePolicyStringSet(rawOverride.blocked_services)}}}function collectExtensionPolicyOverrides(rawOverrides){const overridesByName=new Map;for(const rawOverride of rawOverrides??[]){const built=buildExtensionPolicyOverride(rawOverride);built&&overridesByName.set(built.name,built.normalized)}return overridesByName}function collectExtensionPolicyWarnings(normalized){const warnings=[],sortedOverrides=[...normalized.overridesByName.values()].sort((left,right)=>left.name.localeCompare(right.name));for(const capability of toSortedList([...normalized.allowedCapabilities,...normalized.blockedCapabilities]))isKnownExtensionCapability(capability)||warnings.push(`extension_policy_unknown_capability:${capability}`);for(const override of sortedOverrides)for(const capability of toSortedList([...override.allowedCapabilities,...override.blockedCapabilities]))isKnownExtensionCapability(capability)||warnings.push(`extension_policy_unknown_capability:${override.name}:${capability}`);const knownSurfaces=new Set(KNOWN_EXTENSION_POLICY_SURFACES);for(const surface of toSortedList([...normalized.allowedSurfaces,...normalized.blockedSurfaces]))knownSurfaces.has(surface)||warnings.push(`extension_policy_unknown_surface:${surface}`);for(const override of sortedOverrides)for(const surface of toSortedList([...override.allowedSurfaces,...override.blockedSurfaces]))knownSurfaces.has(surface)||warnings.push(`extension_policy_unknown_surface:${override.name}:${surface}`);return[...new Set(warnings)].sort((left,right)=>left.localeCompare(right))}function normalizeExtensionPolicy(settings){const policy=settings.extensions?.policy??{},allowedCapabilities=normalizePolicyStringSet(policy.allowed_capabilities),blockedCapabilities=normalizePolicyStringSet(policy.blocked_capabilities),allowedSurfaces=normalizePolicySurfaceSet(policy.allowed_surfaces),blockedSurfaces=normalizePolicySurfaceSet(policy.blocked_surfaces),overridesByName=collectExtensionPolicyOverrides(policy.extension_overrides);return{mode:normalizePolicyMode(policy.mode),trustMode:normalizePolicyTrustMode(policy.trust_mode),pmMaxVersionExceededMode:normalizePmMaxVersionExceededMode(policy.pm_max_version_exceeded_mode),requireProvenance:policy.require_provenance===!0,trustedExtensions:normalizePolicyStringSet(policy.trusted_extensions),defaultSandboxProfile:normalizePolicySandboxProfile(policy.default_sandbox_profile),allowedExtensions:normalizePolicyStringSet(policy.allowed_extensions),blockedExtensions:normalizePolicyStringSet(policy.blocked_extensions),allowedCapabilities,blockedCapabilities,allowedSurfaces,blockedSurfaces,allowedCommands:normalizePolicyStringSet(policy.allowed_commands),blockedCommands:normalizePolicyStringSet(policy.blocked_commands),allowedActions:normalizePolicyStringSet(policy.allowed_actions),blockedActions:normalizePolicyStringSet(policy.blocked_actions),allowedServices:normalizePolicyStringSet(policy.allowed_services),blockedServices:normalizePolicyStringSet(policy.blocked_services),overridesByName,warnings:collectExtensionPolicyWarnings({allowedCapabilities,blockedCapabilities,allowedSurfaces,blockedSurfaces,overridesByName})}}function serializeExtensionPolicy(policy){const overrides=[...policy.overridesByName.values()].sort((left,right)=>left.name.localeCompare(right.name)).map(override=>({name:override.name,...override.disabled?{disabled:!0}:{},...override.requireTrusted?{require_trusted:!0}:{},...override.requireProvenance?{require_provenance:!0}:{},...override.sandboxProfile?{sandbox_profile:override.sandboxProfile}:{},...override.allowedCapabilities.size>0?{allowed_capabilities:toSortedList(override.allowedCapabilities)}:{},...override.blockedCapabilities.size>0?{blocked_capabilities:toSortedList(override.blockedCapabilities)}:{},...override.allowedSurfaces.size>0?{allowed_surfaces:toSortedList(override.allowedSurfaces)}:{},...override.blockedSurfaces.size>0?{blocked_surfaces:toSortedList(override.blockedSurfaces)}:{},...override.allowedCommands.size>0?{allowed_commands:toSortedList(override.allowedCommands)}:{},...override.blockedCommands.size>0?{blocked_commands:toSortedList(override.blockedCommands)}:{},...override.allowedActions.size>0?{allowed_actions:toSortedList(override.allowedActions)}:{},...override.blockedActions.size>0?{blocked_actions:toSortedList(override.blockedActions)}:{},...override.allowedServices.size>0?{allowed_services:toSortedList(override.allowedServices)}:{},...override.blockedServices.size>0?{blocked_services:toSortedList(override.blockedServices)}:{}}));return{mode:policy.mode,trust_mode:policy.trustMode,pm_max_version_exceeded_mode:serializePmMaxVersionExceededMode(policy.pmMaxVersionExceededMode),require_provenance:policy.requireProvenance,trusted_extensions:toSortedList(policy.trustedExtensions),default_sandbox_profile:policy.defaultSandboxProfile,allowed_extensions:toSortedList(policy.allowedExtensions),blocked_extensions:toSortedList(policy.blockedExtensions),allowed_capabilities:toSortedList(policy.allowedCapabilities),blocked_capabilities:toSortedList(policy.blockedCapabilities),allowed_surfaces:toSortedList(policy.allowedSurfaces),blocked_surfaces:toSortedList(policy.blockedSurfaces),allowed_commands:toSortedList(policy.allowedCommands),blocked_commands:toSortedList(policy.blockedCommands),allowed_actions:toSortedList(policy.allowedActions),blocked_actions:toSortedList(policy.blockedActions),allowed_services:toSortedList(policy.allowedServices),blocked_services:toSortedList(policy.blockedServices),extension_overrides:overrides}}function hydrateExtensionPolicy(policy){const overridesByName=collectExtensionPolicyOverrides(policy.extension_overrides);return{mode:normalizePolicyMode(policy.mode),trustMode:normalizePolicyTrustMode(policy.trust_mode),pmMaxVersionExceededMode:normalizePmMaxVersionExceededMode(policy.pm_max_version_exceeded_mode),requireProvenance:policy.require_provenance===!0,trustedExtensions:normalizePolicyStringSet(policy.trusted_extensions),defaultSandboxProfile:normalizePolicySandboxProfile(policy.default_sandbox_profile),allowedExtensions:normalizePolicyStringSet(policy.allowed_extensions),blockedExtensions:normalizePolicyStringSet(policy.blocked_extensions),allowedCapabilities:normalizePolicyStringSet(policy.allowed_capabilities),blockedCapabilities:normalizePolicyStringSet(policy.blocked_capabilities),allowedSurfaces:normalizePolicySurfaceSet(policy.allowed_surfaces),blockedSurfaces:normalizePolicySurfaceSet(policy.blocked_surfaces),allowedCommands:normalizePolicyStringSet(policy.allowed_commands),blockedCommands:normalizePolicyStringSet(policy.blocked_commands),allowedActions:normalizePolicyStringSet(policy.allowed_actions),blockedActions:normalizePolicyStringSet(policy.blocked_actions),allowedServices:normalizePolicyStringSet(policy.allowed_services),blockedServices:normalizePolicyStringSet(policy.blocked_services),overridesByName,warnings:[]}}function resolvePolicyOverride(policy,extensionName){return policy.overridesByName.get(normalizePolicyName(extensionName))??null}function evaluatePolicySet(allowed,blocked,value,notAllowlistedReason,blockedReason){return blocked.has(value)?blockedReason:allowed.size>0&&!allowed.has(value)?notAllowlistedReason:null}function resolvePolicyCapabilityReason(policy,extension,capability){const normalizedCapability=capability.trim().toLowerCase(),override=resolvePolicyOverride(policy,extension.name),allowed=override&&override.allowedCapabilities.size>0?override.allowedCapabilities:policy.allowedCapabilities,blocked=new Set([...policy.blockedCapabilities,...override?override.blockedCapabilities:[]]);return evaluatePolicySet(allowed,blocked,normalizedCapability,"capability_not_allowlisted","capability_blocked")}function resolvePolicySurfaceReason(policy,extension,surface){const override=resolvePolicyOverride(policy,extension.name),allowed=override&&override.allowedSurfaces.size>0?override.allowedSurfaces:policy.allowedSurfaces,blocked=new Set([...policy.blockedSurfaces,...override?override.blockedSurfaces:[]]);return evaluatePolicySet(allowed,blocked,surface,"surface_not_allowlisted","surface_blocked")}function resolvePolicyCommandReason(policy,extension,command){const normalizedCommand=normalizeCommandName(command);if(normalizedCommand.length===0)return null;const override=resolvePolicyOverride(policy,extension.name),allowed=override&&override.allowedCommands.size>0?override.allowedCommands:policy.allowedCommands,blocked=new Set([...policy.blockedCommands,...override?override.blockedCommands:[]]);return evaluatePolicySet(allowed,blocked,normalizedCommand,"command_not_allowlisted","command_blocked")}function resolvePolicyActionReason(policy,extension,action){const normalizedAction=normalizePolicyName(action).replace(/\s+/g,"-");if(normalizedAction.length===0)return null;const override=resolvePolicyOverride(policy,extension.name),allowed=override&&override.allowedActions.size>0?override.allowedActions:policy.allowedActions,blocked=new Set([...policy.blockedActions,...override?override.blockedActions:[]]);return evaluatePolicySet(allowed,blocked,normalizedAction,"action_not_allowlisted","action_blocked")}function resolvePolicyServiceReason(policy,extension,service){const normalizedService=normalizePolicyName(service);if(normalizedService.length===0)return null;const override=resolvePolicyOverride(policy,extension.name),allowed=override&&override.allowedServices.size>0?override.allowedServices:policy.allowedServices,blocked=new Set([...policy.blockedServices,...override?override.blockedServices:[]]);return evaluatePolicySet(allowed,blocked,normalizedService,"service_not_allowlisted","service_blocked")}function resolvePolicyExtensionReason(policy,extension){const name=normalizePolicyName(extension.name);return resolvePolicyOverride(policy,extension.name)?.disabled===!0?"extension_override_disabled":evaluatePolicySet(policy.allowedExtensions,policy.blockedExtensions,name,"extension_not_allowlisted","extension_blocked")}function resolvePolicyTrustReason(policy,extension){if(policy.trustMode==="off")return null;const override=resolvePolicyOverride(policy,extension.name),name=normalizePolicyName(extension.name),trusted=extension.trusted===!0,provenanceVerified=extension.provenanceVerified===!0;return policy.trustedExtensions.size>0&&!policy.trustedExtensions.has(name)?"extension_not_trusted":(override?.requireTrusted===!0||policy.trustMode==="warn"||policy.trustMode==="enforce")&&!trusted?"extension_untrusted":(policy.requireProvenance||override?.requireProvenance===!0)&&!provenanceVerified?"provenance_missing_or_unverified":null}function resolvePolicySandboxReason(policy,extension){if(policy.mode==="off")return null;const profile=resolvePolicyOverride(policy,extension.name)?.sandboxProfile??extension.sandboxProfile??policy.defaultSandboxProfile;if(profile==="none")return null;const permissions=extension.permissions;if(!permissions)return"sandbox_permissions_missing";const hasPermission=name=>permissions[name]===!0;return profile==="restricted"?hasPermission("process_spawn")?"sandbox_restricted_disallows_process_spawn":hasPermission("env_write")?"sandbox_restricted_disallows_env_write":null:hasPermission("process_spawn")?"sandbox_strict_disallows_process_spawn":hasPermission("network")?"sandbox_strict_disallows_network":hasPermission("fs_write")?"sandbox_strict_disallows_fs_write":hasPermission("env_write")?"sandbox_strict_disallows_env_write":null}function buildPolicyWarning(mode,scope,extension,reason,details={}){const tokens=Object.entries(details).sort((left,right)=>left[0].localeCompare(right[0])).map(([key,value])=>`${key}=${value}`).join(":"),suffix=tokens.length>0?`:${tokens}`:"";return`extension_policy_${mode}_${scope}:${extension.layer}:${extension.name}:reason=${reason}${suffix}`}function evaluateExtensionPolicyForExtension(policy,extension){if(policy.mode==="off"&&policy.trustMode==="off")return{allowed:!0,warning:null};const violations=[],reason=resolvePolicyExtensionReason(policy,extension);reason&&violations.push({reason,scope:"extension",mode:policy.mode});const trustReason=resolvePolicyTrustReason(policy,extension);trustReason&&violations.push({reason:trustReason,scope:"trust",mode:policy.trustMode});const sandboxReason=resolvePolicySandboxReason(policy,extension);sandboxReason&&violations.push({reason:sandboxReason,scope:"extension",mode:policy.mode});const enforced=violations.find(violation=>violation.mode==="enforce");if(enforced)return{allowed:!1,warning:buildPolicyWarning("blocked",enforced.scope,extension,enforced.reason)};const warned=violations.find(violation=>violation.mode==="warn");return warned?{allowed:!0,warning:buildPolicyWarning("violation",warned.scope,extension,warned.reason)}:{allowed:!0,warning:null}}function evaluateExtensionPolicyForCapability(policy,extension,capability){if(policy.mode==="off")return{allowed:!0,warning:null};const reason=resolvePolicyCapabilityReason(policy,extension,capability);return reason?{allowed:policy.mode==="warn",warning:buildPolicyWarning(policy.mode==="warn"?"violation":"blocked","capability",extension,reason,{capability:capability.trim().toLowerCase()})}:{allowed:!0,warning:null}}function resolveRegistrationPolicyReason(policy,extension,surface,capability,detail){const capabilityReason=typeof capability=="string"?resolvePolicyCapabilityReason(policy,extension,capability):null,surfaceReason=resolvePolicySurfaceReason(policy,extension,surface),commandReason=detail.command?resolvePolicyCommandReason(policy,extension,detail.command):null,actionReason=detail.action?resolvePolicyActionReason(policy,extension,detail.action):null,serviceReason=detail.service?resolvePolicyServiceReason(policy,extension,detail.service):null;return capabilityReason??surfaceReason??commandReason??actionReason??serviceReason}function buildRegistrationPolicyWarningDetails(method,surface,capability,detail){const warningDetails={method:normalizePolicyName(method).replace(/\s+/g,"_"),surface};return capability&&(warningDetails.capability=capability),detail.command&&(warningDetails.command=normalizeCommandName(detail.command)),detail.action&&(warningDetails.action=normalizePolicyName(detail.action).replace(/\s+/g,"-")),detail.service&&(warningDetails.service=normalizePolicyName(detail.service)),warningDetails}function evaluateExtensionPolicyForRegistration(policy,extension,surface,method,capability,details){if(policy.mode==="off")return{allowed:!0,warning:null};const detail=details??{},reason=resolveRegistrationPolicyReason(policy,extension,surface,capability,detail);if(!reason)return{allowed:!0,warning:null};const warning=buildPolicyWarning(policy.mode==="warn"?"violation":"blocked","registration",extension,reason,buildRegistrationPolicyWarningDetails(method,surface,capability,detail));return{allowed:policy.mode==="warn",warning}}export{evaluateExtensionPolicyForCapability,evaluateExtensionPolicyForExtension,evaluateExtensionPolicyForRegistration,hydrateExtensionPolicy,normalizeExtensionPolicy,normalizePmMaxVersionExceededMode,normalizePolicySandboxProfile,serializeExtensionPolicy};
1
+ import{KNOWN_EXTENSION_POLICY_MODES as z,KNOWN_EXTENSION_POLICY_SURFACES as M,KNOWN_EXTENSION_SANDBOX_PROFILES as N,KNOWN_EXTENSION_TRUST_MODES as h,KNOWN_PM_MAX_VERSION_EXCEEDED_MODES as A}from"./extension-types.js";import{isKnownExtensionCapability as x}from"./extension-capability-aliases.js";import{normalizeCommandName as S}from"./extension-runtime-helpers.js";function d(e){return typeof e!="string"?"":e.trim().toLowerCase()}function r(e){return new Set((e??[]).map(o=>o.trim().toLowerCase()).filter(o=>o.length>0))}function R(e){const o=e.trim().toLowerCase();if(o.length===0)return"";const n=o.split(/[.:/]/).map(t=>t.replace(/[\s_-]+/g,"")).filter(t=>t.length>0);return n.length===0?"":n.length===1?n[0]:`${n[0]}.${n.slice(1).join("")}`}function m(e){return new Set((e??[]).map(o=>R(o)).filter(o=>o.length>0))}function C(e){const o=d(e);return z.includes(o)?o:"off"}function v(e){const o=d(e);return h.includes(o)?o:"off"}function w(e){const o=d(e);return N.includes(o)?o:"none"}function k(e){if(typeof e!="string")return;const o=e.trim().toLowerCase();return A.includes(o)?o:void 0}function p(e){if(typeof e=="string"){const o=k(e)??"block";return{global:o,project:o}}return typeof e=="object"&&e!==null&&!Array.isArray(e)?{global:k(e.global)??"block",project:k(e.project)??"block"}:{global:"block",project:"block"}}function q(e){return e.global===e.project?e.global:{global:e.global,project:e.project}}function l(e){return[...new Set(e)].sort((o,n)=>o.localeCompare(n))}function $(e){const o=d(e.name);return o.length===0?null:{name:o,normalized:{name:o,disabled:e.disabled===!0,requireTrusted:e.require_trusted===!0,requireProvenance:e.require_provenance===!0,sandboxProfile:e.sandbox_profile!==void 0?w(e.sandbox_profile):void 0,allowedCapabilities:r(e.allowed_capabilities),blockedCapabilities:r(e.blocked_capabilities),allowedSurfaces:m(e.allowed_surfaces),blockedSurfaces:m(e.blocked_surfaces),allowedCommands:r(e.allowed_commands),blockedCommands:r(e.blocked_commands),allowedActions:r(e.allowed_actions),blockedActions:r(e.blocked_actions),allowedServices:r(e.allowed_services),blockedServices:r(e.blocked_services)}}}function P(e){const o=new Map;for(const n of e??[]){const t=$(n);t&&o.set(t.name,t.normalized)}return o}function T(e){const o=[],n=[...e.overridesByName.values()].sort((s,a)=>s.name.localeCompare(a.name));for(const s of l([...e.allowedCapabilities,...e.blockedCapabilities]))x(s)||o.push(`extension_policy_unknown_capability:${s}`);for(const s of n)for(const a of l([...s.allowedCapabilities,...s.blockedCapabilities]))x(a)||o.push(`extension_policy_unknown_capability:${s.name}:${a}`);const t=new Set(M);for(const s of l([...e.allowedSurfaces,...e.blockedSurfaces]))t.has(s)||o.push(`extension_policy_unknown_surface:${s}`);for(const s of n)for(const a of l([...s.allowedSurfaces,...s.blockedSurfaces]))t.has(a)||o.push(`extension_policy_unknown_surface:${s.name}:${a}`);return[...new Set(o)].sort((s,a)=>s.localeCompare(a))}function Y(e){const o=e.extensions?.policy??{},n=r(o.allowed_capabilities),t=r(o.blocked_capabilities),s=m(o.allowed_surfaces),a=m(o.blocked_surfaces),i=P(o.extension_overrides);return{mode:C(o.mode),trustMode:v(o.trust_mode),pmMaxVersionExceededMode:p(o.pm_max_version_exceeded_mode),requireProvenance:o.require_provenance===!0,trustedExtensions:r(o.trusted_extensions),defaultSandboxProfile:w(o.default_sandbox_profile),allowedExtensions:r(o.allowed_extensions),blockedExtensions:r(o.blocked_extensions),allowedCapabilities:n,blockedCapabilities:t,allowedSurfaces:s,blockedSurfaces:a,allowedCommands:r(o.allowed_commands),blockedCommands:r(o.blocked_commands),allowedActions:r(o.allowed_actions),blockedActions:r(o.blocked_actions),allowedServices:r(o.allowed_services),blockedServices:r(o.blocked_services),overridesByName:i,warnings:T({allowedCapabilities:n,blockedCapabilities:t,allowedSurfaces:s,blockedSurfaces:a,overridesByName:i})}}function G(e){const o=[...e.overridesByName.values()].sort((n,t)=>n.name.localeCompare(t.name)).map(n=>({name:n.name,...n.disabled?{disabled:!0}:{},...n.requireTrusted?{require_trusted:!0}:{},...n.requireProvenance?{require_provenance:!0}:{},...n.sandboxProfile?{sandbox_profile:n.sandboxProfile}:{},...n.allowedCapabilities.size>0?{allowed_capabilities:l(n.allowedCapabilities)}:{},...n.blockedCapabilities.size>0?{blocked_capabilities:l(n.blockedCapabilities)}:{},...n.allowedSurfaces.size>0?{allowed_surfaces:l(n.allowedSurfaces)}:{},...n.blockedSurfaces.size>0?{blocked_surfaces:l(n.blockedSurfaces)}:{},...n.allowedCommands.size>0?{allowed_commands:l(n.allowedCommands)}:{},...n.blockedCommands.size>0?{blocked_commands:l(n.blockedCommands)}:{},...n.allowedActions.size>0?{allowed_actions:l(n.allowedActions)}:{},...n.blockedActions.size>0?{blocked_actions:l(n.blockedActions)}:{},...n.allowedServices.size>0?{allowed_services:l(n.allowedServices)}:{},...n.blockedServices.size>0?{blocked_services:l(n.blockedServices)}:{}}));return{mode:e.mode,trust_mode:e.trustMode,pm_max_version_exceeded_mode:q(e.pmMaxVersionExceededMode),require_provenance:e.requireProvenance,trusted_extensions:l(e.trustedExtensions),default_sandbox_profile:e.defaultSandboxProfile,allowed_extensions:l(e.allowedExtensions),blocked_extensions:l(e.blockedExtensions),allowed_capabilities:l(e.allowedCapabilities),blocked_capabilities:l(e.blockedCapabilities),allowed_surfaces:l(e.allowedSurfaces),blocked_surfaces:l(e.blockedSurfaces),allowed_commands:l(e.allowedCommands),blocked_commands:l(e.blockedCommands),allowed_actions:l(e.allowedActions),blocked_actions:l(e.blockedActions),allowed_services:l(e.allowedServices),blocked_services:l(e.blockedServices),extension_overrides:o}}function H(e){const o=P(e.extension_overrides);return{mode:C(e.mode),trustMode:v(e.trust_mode),pmMaxVersionExceededMode:p(e.pm_max_version_exceeded_mode),requireProvenance:e.require_provenance===!0,trustedExtensions:r(e.trusted_extensions),defaultSandboxProfile:w(e.default_sandbox_profile),allowedExtensions:r(e.allowed_extensions),blockedExtensions:r(e.blocked_extensions),allowedCapabilities:r(e.allowed_capabilities),blockedCapabilities:r(e.blocked_capabilities),allowedSurfaces:m(e.allowed_surfaces),blockedSurfaces:m(e.blocked_surfaces),allowedCommands:r(e.allowed_commands),blockedCommands:r(e.blocked_commands),allowedActions:r(e.allowed_actions),blockedActions:r(e.blocked_actions),allowedServices:r(e.allowed_services),blockedServices:r(e.blocked_services),overridesByName:o,warnings:[]}}function f(e,o){return e.overridesByName.get(d(o))??null}function _(e,o,n,t,s){return o.has(n)?s:e.size>0&&!e.has(n)?t:null}function g(e,o,n){const t=n.trim().toLowerCase(),s=f(e,o.name),a=s&&s.allowedCapabilities.size>0?s.allowedCapabilities:e.allowedCapabilities,i=new Set([...e.blockedCapabilities,...s?s.blockedCapabilities:[]]);return _(a,i,t,"capability_not_allowlisted","capability_blocked")}function j(e,o,n){const t=f(e,o.name),s=t&&t.allowedSurfaces.size>0?t.allowedSurfaces:e.allowedSurfaces,a=new Set([...e.blockedSurfaces,...t?t.blockedSurfaces:[]]);return _(s,a,n,"surface_not_allowlisted","surface_blocked")}function L(e,o,n){const t=S(n);if(t.length===0)return null;const s=f(e,o.name),a=s&&s.allowedCommands.size>0?s.allowedCommands:e.allowedCommands,i=new Set([...e.blockedCommands,...s?s.blockedCommands:[]]);return _(a,i,t,"command_not_allowlisted","command_blocked")}function V(e,o,n){const t=d(n).replace(/\s+/g,"-");if(t.length===0)return null;const s=f(e,o.name),a=s&&s.allowedActions.size>0?s.allowedActions:e.allowedActions,i=new Set([...e.blockedActions,...s?s.blockedActions:[]]);return _(a,i,t,"action_not_allowlisted","action_blocked")}function D(e,o,n){const t=d(n);if(t.length===0)return null;const s=f(e,o.name),a=s&&s.allowedServices.size>0?s.allowedServices:e.allowedServices,i=new Set([...e.blockedServices,...s?s.blockedServices:[]]);return _(a,i,t,"service_not_allowlisted","service_blocked")}function I(e,o){const n=d(o.name);return f(e,o.name)?.disabled===!0?"extension_override_disabled":_(e.allowedExtensions,e.blockedExtensions,n,"extension_not_allowlisted","extension_blocked")}function O(e,o){if(e.trustMode==="off")return null;const n=f(e,o.name),t=d(o.name),s=o.trusted===!0,a=o.provenanceVerified===!0;return e.trustedExtensions.size>0&&!e.trustedExtensions.has(t)?"extension_not_trusted":(n?.requireTrusted===!0||e.trustMode==="warn"||e.trustMode==="enforce")&&!s?"extension_untrusted":(e.requireProvenance||n?.requireProvenance===!0)&&!a?"provenance_missing_or_unverified":null}function W(e,o){if(e.mode==="off")return null;const t=f(e,o.name)?.sandboxProfile??o.sandboxProfile??e.defaultSandboxProfile;if(t==="none")return null;const s=o.permissions;if(!s)return"sandbox_permissions_missing";const a=i=>s[i]===!0;return t==="restricted"?a("process_spawn")?"sandbox_restricted_disallows_process_spawn":a("env_write")?"sandbox_restricted_disallows_env_write":null:a("process_spawn")?"sandbox_strict_disallows_process_spawn":a("network")?"sandbox_strict_disallows_network":a("fs_write")?"sandbox_strict_disallows_fs_write":a("env_write")?"sandbox_strict_disallows_env_write":null}function b(e,o,n,t,s={}){const a=Object.entries(s).sort((c,u)=>c[0].localeCompare(u[0])).map(([c,u])=>`${c}=${u}`).join(":"),i=a.length>0?`:${a}`:"";return`extension_policy_${e}_${o}:${n.layer}:${n.name}:reason=${t}${i}`}function J(e,o){if(e.mode==="off"&&e.trustMode==="off")return{allowed:!0,warning:null};const n=[],t=I(e,o);t&&n.push({reason:t,scope:"extension",mode:e.mode});const s=O(e,o);s&&n.push({reason:s,scope:"trust",mode:e.trustMode});const a=W(e,o);a&&n.push({reason:a,scope:"extension",mode:e.mode});const i=n.find(u=>u.mode==="enforce");if(i)return{allowed:!1,warning:b("blocked",i.scope,o,i.reason)};const c=n.find(u=>u.mode==="warn");return c?{allowed:!0,warning:b("violation",c.scope,o,c.reason)}:{allowed:!0,warning:null}}function Q(e,o,n){if(e.mode==="off")return{allowed:!0,warning:null};const t=g(e,o,n);return t?{allowed:e.mode==="warn",warning:b(e.mode==="warn"?"violation":"blocked","capability",o,t,{capability:n.trim().toLowerCase()})}:{allowed:!0,warning:null}}function B(e,o,n,t,s){const a=typeof t=="string"?g(e,o,t):null,i=j(e,o,n),c=s.command?L(e,o,s.command):null,u=s.action?V(e,o,s.action):null,E=s.service?D(e,o,s.service):null;return a??i??c??u??E}function X(e,o,n,t){const s={method:d(e).replace(/\s+/g,"_"),surface:o};return n&&(s.capability=n),t.command&&(s.command=S(t.command)),t.action&&(s.action=d(t.action).replace(/\s+/g,"-")),t.service&&(s.service=d(t.service)),s}function Z(e,o,n,t,s,a){if(e.mode==="off")return{allowed:!0,warning:null};const i=a??{},c=B(e,o,n,s,i);if(!c)return{allowed:!0,warning:null};const u=b(e.mode==="warn"?"violation":"blocked","registration",o,c,X(t,n,s,i));return{allowed:e.mode==="warn",warning:u}}export{Q as evaluateExtensionPolicyForCapability,J as evaluateExtensionPolicyForExtension,Z as evaluateExtensionPolicyForRegistration,H as hydrateExtensionPolicy,Y as normalizeExtensionPolicy,p as normalizePmMaxVersionExceededMode,w as normalizePolicySandboxProfile,G as serializeExtensionPolicy};
2
2
  //# sourceMappingURL=extension-policy.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]="01116a5e-62d1-591b-9fd0-84ac6e99f8d0")}catch{}})();function createEmptyExtensionHookRegistry(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function createEmptyExtensionCommandRegistry(){return{overrides:[],handlers:[]}}function createEmptyExtensionParserRegistry(){return{overrides:[]}}function createEmptyExtensionPreflightRegistry(){return{overrides:[]}}function createEmptyExtensionServiceRegistry(){return{overrides:[]}}function createEmptyExtensionRendererRegistry(){return{overrides:[]}}function createEmptyExtensionRegistrationRegistry(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}export{createEmptyExtensionCommandRegistry,createEmptyExtensionHookRegistry,createEmptyExtensionParserRegistry,createEmptyExtensionPreflightRegistry,createEmptyExtensionRegistrationRegistry,createEmptyExtensionRendererRegistry,createEmptyExtensionServiceRegistry};
1
+ function e(){return{beforeCommand:[],beforeMutation:[],afterCommand:[],onWrite:[],onRead:[],onIndex:[]}}function r(){return{overrides:[],handlers:[]}}function t(){return{overrides:[]}}function n(){return{overrides:[]}}function o(){return{overrides:[]}}function i(){return{overrides:[]}}function s(){return{commands:[],flags:[],item_fields:[],item_types:[],relationship_kinds:[],migrations:[],profiles:[],importers:[],exporters:[],search_providers:[],vector_store_adapters:[],assurance_providers:[]}}export{r as createEmptyExtensionCommandRegistry,e as createEmptyExtensionHookRegistry,t as createEmptyExtensionParserRegistry,n as createEmptyExtensionPreflightRegistry,s as createEmptyExtensionRegistrationRegistry,i as createEmptyExtensionRendererRegistry,o as createEmptyExtensionServiceRegistry};
2
2
  //# sourceMappingURL=extension-registries.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]="f8657910-1392-5fae-afda-614b96dc8320")}catch{}})();function normalizeCommandName(command){return command.trim().toLowerCase().split(/\s+/).filter(part=>part.length>0).join(" ")}function defaultGlobalOptions(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function cloneCommandOptionsSnapshot(options){return options?cloneContextSnapshot(options):{}}function cloneGlobalOptionsSnapshot(options){return options?cloneContextSnapshot(options):defaultGlobalOptions()}function cloneContextSnapshot(value){return structuredClone(value)}export{cloneCommandOptionsSnapshot,cloneContextSnapshot,cloneGlobalOptionsSnapshot,defaultGlobalOptions,normalizeCommandName};
1
+ function r(n){return n.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0).join(" ")}function o(){return{json:!1,quiet:!1,noExtensions:!1,profile:!1}}function l(n){return n?t(n):{}}function a(n){return n?t(n):o()}function t(n){return structuredClone(n)}export{l as cloneCommandOptionsSnapshot,t as cloneContextSnapshot,a as cloneGlobalOptionsSnapshot,o as defaultGlobalOptions,r as normalizeCommandName};
2
2
  //# sourceMappingURL=extension-runtime-helpers.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]="1c260d1a-70ec-5133-b017-bb0399aea52e")}catch{}})();const KNOWN_EXTENSION_CAPABILITIES=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],EXTENSION_CAPABILITY_CONTRACT_VERSION=2,EXTENSION_CAPABILITY_LEGACY_ALIASES=Object.freeze({migration:"schema",validation:"schema"}),EXTENSION_CAPABILITY_CONTRACT=Object.freeze({version:2,capabilities:[...KNOWN_EXTENSION_CAPABILITIES],legacy_aliases:{...EXTENSION_CAPABILITY_LEGACY_ALIASES}}),KNOWN_EXTENSION_POLICY_MODES=["off","warn","enforce"],KNOWN_EXTENSION_TRUST_MODES=["off","warn","enforce"],KNOWN_EXTENSION_SANDBOX_PROFILES=["none","restricted","strict"],KNOWN_PM_MAX_VERSION_EXCEEDED_MODES=["block","warn"],KNOWN_EXTENSION_POLICY_SURFACES=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],KNOWN_EXTENSION_SERVICE_NAMES=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function createDefaultExtensionGovernancePolicy(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}export{EXTENSION_CAPABILITY_CONTRACT,EXTENSION_CAPABILITY_CONTRACT_VERSION,EXTENSION_CAPABILITY_LEGACY_ALIASES,KNOWN_EXTENSION_CAPABILITIES,KNOWN_EXTENSION_POLICY_MODES,KNOWN_EXTENSION_POLICY_SURFACES,KNOWN_EXTENSION_SANDBOX_PROFILES,KNOWN_EXTENSION_SERVICE_NAMES,KNOWN_EXTENSION_TRUST_MODES,KNOWN_PM_MAX_VERSION_EXCEEDED_MODES,createDefaultExtensionGovernancePolicy};
1
+ const e=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],r=2,o=Object.freeze({migration:"schema",validation:"schema"}),s=Object.freeze({version:2,capabilities:[...e],legacy_aliases:{...o}}),t=["off","warn","enforce"],a=["off","warn","enforce"],c=["none","restricted","strict"],n=["block","warn"],i=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],_=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function d(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}export{s as EXTENSION_CAPABILITY_CONTRACT,r as EXTENSION_CAPABILITY_CONTRACT_VERSION,o as EXTENSION_CAPABILITY_LEGACY_ALIASES,e as KNOWN_EXTENSION_CAPABILITIES,t as KNOWN_EXTENSION_POLICY_MODES,i as KNOWN_EXTENSION_POLICY_SURFACES,c as KNOWN_EXTENSION_SANDBOX_PROFILES,_ as KNOWN_EXTENSION_SERVICE_NAMES,a as KNOWN_EXTENSION_TRUST_MODES,n as KNOWN_PM_MAX_VERSION_EXCEEDED_MODES,d as createDefaultExtensionGovernancePolicy};
2
2
  //# sourceMappingURL=extension-types.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]="81054684-60df-57c9-af9d-0996874c1024")}catch{}})();import{RESERVED_EXTENSION_HOST_FLAG_NAMES}from"./reserved-host-flags.js";const EXTENSION_LONG_FLAG_PATTERN=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function parseExtensionLongFlagToken(value){if(typeof value!="string")return null;const matched=EXTENSION_LONG_FLAG_PATTERN.exec(value.trim());if(!matched)return null;const placeholder=matched[2];return{name:matched[1],valueName:placeholder?placeholder.slice(1,-1):null,optional:placeholder?.startsWith("[")??!1}}function resolveExtensionLongFlagName(value){const parsed=parseExtensionLongFlagToken(value);return parsed?parsed.name:typeof value=="string"&&value.trim()||null}function validateExtensionLongFlagToken(value){if(typeof value!="string")return null;const token=value.trim(),hostToken=token.split(/[ =]/,1)[0];return RESERVED_EXTENSION_HOST_FLAG_NAMES.has(hostToken)||RESERVED_EXTENSION_HOST_FLAG_NAMES.has(`--${hostToken.slice(2).replaceAll("_","-")}`)?"host_owned_flag_collision":EXTENSION_LONG_FLAG_PATTERN.test(token)?null:"malformed_long_flag"}function findExtensionFlagTokenFailure(long,short){const reserved=[long,short].find(token2=>typeof token2=="string"&&RESERVED_EXTENSION_HOST_FLAG_NAMES.has(token2.trim().split(/[ =]/,1)[0]));if(typeof reserved=="string")return{token:reserved.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof long!="string")return null;const token=long.trim(),failure=validateExtensionLongFlagToken(token);return failure===null?null:{token,failure}}function describeExtensionLongFlagFailure(token,failure){return failure==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${token}"; read it from context.global instead`:`long flag "${token}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}export{EXTENSION_LONG_FLAG_PATTERN,describeExtensionLongFlagFailure,findExtensionFlagTokenFailure,parseExtensionLongFlagToken,resolveExtensionLongFlagName,validateExtensionLongFlagToken};
1
+ import{RESERVED_EXTENSION_HOST_FLAG_NAMES as o}from"./reserved-host-flags.js";const s=/^(--[a-z0-9][a-z0-9_-]*)(?:[ =](<[^<>]+>|\[[^[\]]+\]))?$/;function a(n){if(typeof n!="string")return null;const t=s.exec(n.trim());if(!t)return null;const e=t[2];return{name:t[1],valueName:e?e.slice(1,-1):null,optional:e?.startsWith("[")??!1}}function c(n){const t=a(n);return t?t.name:typeof n=="string"&&n.trim()||null}function f(n){if(typeof n!="string")return null;const t=n.trim(),e=t.split(/[ =]/,1)[0];return o.has(e)||o.has(`--${e.slice(2).replaceAll("_","-")}`)?"host_owned_flag_collision":s.test(t)?null:"malformed_long_flag"}function g(n,t){const e=[n,t].find(i=>typeof i=="string"&&o.has(i.trim().split(/[ =]/,1)[0]));if(typeof e=="string")return{token:e.trim().split(/[ =]/,1)[0],failure:"host_owned_flag_collision"};if(typeof n!="string")return null;const r=n.trim(),l=f(r);return l===null?null:{token:r,failure:l}}function p(n,t){return t==="host_owned_flag_collision"?`cannot shadow host-owned global flag "${n}"; read it from context.global instead`:`long flag "${n}" must start with a double-dash name such as "--my-flag" or "--my-flag <value>"`}export{s as EXTENSION_LONG_FLAG_PATTERN,p as describeExtensionLongFlagFailure,g as findExtensionFlagTokenFailure,a as parseExtensionLongFlagToken,c as resolveExtensionLongFlagName,f as validateExtensionLongFlagToken};
2
2
  //# sourceMappingURL=flag-definition-validation.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]="5c3049c3-1d5a-5e7e-a070-35340737a6ab")}catch{}})();import{parseExtensionLongFlagToken}from"./flag-definition-validation.js";const FLAG_VALUE_KIND_BY_ALIAS=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function resolveFlagValueKind(raw){if(typeof raw!="string")return null;const alias=raw.trim().toLowerCase();return Object.hasOwn(FLAG_VALUE_KIND_BY_ALIAS,alias)?FLAG_VALUE_KIND_BY_ALIAS[alias]:null}function hasExtensionFlagValueMetadata(definition,inlineName,declaredType){return!!(definition.value_name?.trim()||inlineName||declaredType||definition.required===!0||definition.list===!0||definition.repeatable===!0)}function declaredExtensionFlagType(definition){return(definition.value_type?.trim()||definition.type?.trim())?.toLowerCase()}function resolveExtensionFlagValueContract(definition){const declaredType=declaredExtensionFlagType(definition),valueType=resolveFlagValueKind(declaredType),inline=parseExtensionLongFlagToken(definition.long),declaredName=definition.value_name?.trim()||null,takesValue=!(valueType==="boolean"&&declaredType!=="bool")&&hasExtensionFlagValueMetadata(definition,inline?.valueName,declaredType),optionalValue=inline?.valueName?inline.optional:declaredType==="bool";return{value_type:valueType,value_arity:takesValue?optionalValue?"optional":"required":"none",value_name:takesValue?declaredName??inline?.valueName??"value":null}}function flattenFlagListValue(value){const entries=[],collect=input=>{if(Array.isArray(input)){for(const item of input)collect(item);return}if(typeof input=="string"){for(const part of input.split(",")){const trimmed=part.trim();trimmed.length>0&&entries.push(trimmed)}return}input!=null&&entries.push(input)};return collect(value),entries}function isFlagDefaultValueCoercible(value,kind){return kind==="string"?!0:kind==="number"?typeof value=="number"?Number.isFinite(value):typeof value=="string"&&value.trim().length>0&&Number.isFinite(Number(value)):typeof value=="boolean"?!0:typeof value=="string"&&["true","false","1","0"].includes(value.trim().toLowerCase())}function describeFlagScalarValueFailure(value,kind){return kind==="number"?typeof value=="number"&&Number.isFinite(value)?null:{kind,received:value,expected:"a finite number"}:typeof value=="boolean"?null:{kind,received:value,expected:"true, false, 1, or 0"}}export{describeFlagScalarValueFailure,flattenFlagListValue,isFlagDefaultValueCoercible,resolveExtensionFlagValueContract,resolveFlagValueKind};
1
+ import{parseExtensionLongFlagToken as i}from"./flag-definition-validation.js";const u=Object.freeze({string:"string",number:"number",int:"number",integer:"number",float:"number",boolean:"boolean",bool:"boolean"});function c(e){if(typeof e!="string")return null;const r=e.trim().toLowerCase();return Object.hasOwn(u,r)?u[r]:null}function m(e,r,n){return!!(e.value_name?.trim()||r||n||e.required===!0||e.list===!0||e.repeatable===!0)}function f(e){return(e.value_type?.trim()||e.type?.trim())?.toLowerCase()}function p(e){const r=f(e),n=c(r),t=i(e.long),o=e.value_name?.trim()||null,a=!(n==="boolean"&&r!=="bool")&&m(e,t?.valueName,r),s=t?.valueName?t.optional:r==="bool";return{value_type:n,value_arity:a?s?"optional":"required":"none",value_name:a?o??t?.valueName??"value":null}}function g(e){const r=[],n=t=>{if(Array.isArray(t)){for(const o of t)n(o);return}if(typeof t=="string"){for(const o of t.split(",")){const l=o.trim();l.length>0&&r.push(l)}return}t!=null&&r.push(t)};return n(e),r}function y(e,r){return r==="string"?!0:r==="number"?typeof e=="number"?Number.isFinite(e):typeof e=="string"&&e.trim().length>0&&Number.isFinite(Number(e)):typeof e=="boolean"?!0:typeof e=="string"&&["true","false","1","0"].includes(e.trim().toLowerCase())}function F(e,r){return r==="number"?typeof e=="number"&&Number.isFinite(e)?null:{kind:r,received:e,expected:"a finite number"}:typeof e=="boolean"?null:{kind:r,received:e,expected:"true, false, 1, or 0"}}export{F as describeFlagScalarValueFailure,g as flattenFlagListValue,y as isFlagDefaultValueCoercible,p as resolveExtensionFlagValueContract,c as resolveFlagValueKind};
2
2
  //# sourceMappingURL=flag-value-types.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]="67666bab-2e73-549c-bf95-ba505143a9b5")}catch{}})();import{existsSync}from"node:fs";import{AsyncLocalStorage}from"node:async_hooks";import path from"node:path";import{ownedTransactionCompensation}from"../store/item-mutation-precondition.js";import{runCommandHandler,runBeforeMutationHooks,runCommandOverride,runOnIndexHooks,runParserOverride,runPreflightOverride,runOnReadHooks,runRendererOverride,runServiceOverride,runServiceOverrideSync,runOnWriteHooks}from"./loader.js";let activeExtensionHooks=null,activeExtensionCommands=null,activeExtensionParsers=null,activeExtensionPreflight=null,activeExtensionServices=null,activeExtensionRenderers=null,activeExtensionRegistrations=null,activeCommandContext=null,activeCommandResult,activeAfterCommandAffectedItems=[];const isolatedExtensionRuntime=new AsyncLocalStorage;function runtimeState(){return isolatedExtensionRuntime.getStore()}function runWithIsolatedExtensionRuntime(run){return isolatedExtensionRuntime.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},run)}const AFTER_COMMAND_SNAPSHOT_OMITTED_FIELDS=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function findSourceRepositoryRoot(candidate){let cursor=path.resolve(candidate);for(;;){if(existsSync(path.join(cursor,".git")))return cursor;const parent=path.dirname(cursor);if(parent===cursor)return;cursor=parent}}function resolvePortableWorkspaceContext(pmRoot){const sourceCandidate=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),sourceWorkspaceRoot=findSourceRepositoryRoot(sourceCandidate)??path.resolve(sourceCandidate),repoRoot=findSourceRepositoryRoot(sourceWorkspaceRoot);if(!pmRoot)return{source_workspace_root:sourceWorkspaceRoot,...repoRoot?{repo_root:repoRoot}:{}};const relativePmRoot=path.relative(sourceWorkspaceRoot,path.resolve(pmRoot)),contained=relativePmRoot.length>0&&!relativePmRoot.startsWith(`..${path.sep}`)&&relativePmRoot!==".."&&!path.isAbsolute(relativePmRoot);return{source_workspace_root:sourceWorkspaceRoot,...repoRoot?{repo_root:repoRoot}:{},...contained?{pm_root_rel:relativePmRoot.split(path.sep).join("/")}:{}}}function setActiveExtensionHooks(hooks){const state=runtimeState();if(state){state.hooks=hooks;return}activeExtensionHooks=hooks}function setActiveExtensionCommands(commands){const state=runtimeState();if(state){state.commands=commands;return}activeExtensionCommands=commands}function setActiveExtensionParsers(parsers){const state=runtimeState();if(state){state.parsers=parsers;return}activeExtensionParsers=parsers}function setActiveExtensionPreflight(preflight){const state=runtimeState();if(state){state.preflight=preflight;return}activeExtensionPreflight=preflight}function setActiveExtensionServices(services){const state=runtimeState();if(state){state.services=services;return}activeExtensionServices=services}function setActiveExtensionRenderers(renderers){const state=runtimeState();if(state){state.renderers=renderers;return}activeExtensionRenderers=renderers}function setActiveExtensionRegistrations(registrations){const state=runtimeState();if(state){state.registrations=registrations;return}activeExtensionRegistrations=registrations}function getActiveExtensionRegistrations(){const state=runtimeState();return state?state.registrations:activeExtensionRegistrations}function resetActiveExtensionRuntimeState(){const state=runtimeState();if(state){state.hooks=null,state.commands=null,state.parsers=null,state.preflight=null,state.services=null,state.renderers=null,state.registrations=null,state.commandContext=null,state.commandResult=null,state.affectedItems=[];return}activeExtensionHooks=null,activeExtensionCommands=null,activeExtensionParsers=null,activeExtensionPreflight=null,activeExtensionServices=null,activeExtensionRenderers=null,activeExtensionRegistrations=null,activeCommandContext=null,activeCommandResult=null}function setActiveCommandContext(context){const resolved=context?{...context,...resolvePortableWorkspaceContext(context.pm_root)}:null,state=runtimeState();if(state){state.commandContext=resolved;return}activeCommandContext=resolved}function getActiveCommandContext(){const state=runtimeState(),context=state?state.commandContext:activeCommandContext;return context?{...context,args:[...context.args],options:context.options?{...context.options}:{},global:context.global?{...context.global}:void 0}:null}function isActiveCommandUnextended(command){const state=runtimeState()??{commandContext:activeCommandContext,hooks:activeExtensionHooks,commands:activeExtensionCommands,parsers:activeExtensionParsers,preflight:activeExtensionPreflight,services:activeExtensionServices,renderers:activeExtensionRenderers,registrations:activeExtensionRegistrations};return state.commandContext?.command!==command||[state.hooks,state.preflight,state.services,state.renderers].some(registry=>Object.values(registry??{}).some(entries=>entries.length>0))||[state.commands,state.parsers].some(registry=>Object.values(registry??{}).some(entries=>entries.some(entry=>entry.command===command)))?!1:!Object.entries(state.registrations??{}).some(([key,entries])=>["migrations","search_providers","vector_store_adapters","assurance_providers"].includes(key)&&entries.length>0)}function setActiveCommandResult(result){const state=runtimeState();if(state){state.commandResult=result;return}activeCommandResult=result}function getActiveCommandResult(){const state=runtimeState();return state?state.commandResult:activeCommandResult}function recordAfterCommandAffectedItem(item){if(!item)return;const state=runtimeState();state?state.affectedItems.push(item):activeAfterCommandAffectedItems.push(item)}function projectAfterCommandItemSnapshot(metadata,changedFields){if(!metadata||!metadata.id)return{};const snapshot={id:metadata.id,type:metadata.type,status:metadata.status};if(!Array.isArray(changedFields))return snapshot;const source=metadata;for(const field of changedFields){if(typeof field!="string")continue;const actualField=field.startsWith("unset:")?field.slice(6):field;actualField==="id"||actualField==="type"||actualField==="status"||AFTER_COMMAND_SNAPSHOT_OMITTED_FIELDS.has(actualField)||Object.hasOwn(source,actualField)&&source[actualField]!==void 0&&(snapshot[actualField]=source[actualField])}return snapshot}function consumeAfterCommandAffectedItems(){const state=runtimeState(),affectedItems=state?.affectedItems??activeAfterCommandAffectedItems;if(affectedItems.length===0)return;const affected=affectedItems;return state?state.affectedItems=[]:activeAfterCommandAffectedItems=[],affected}function clearActiveExtensionHooks(){const state=runtimeState();if(state){state.hooks=null,state.commands=null,state.parsers=null,state.preflight=null,state.services=null,state.renderers=null,state.registrations=null,state.commandContext=null,state.commandResult=void 0,state.affectedItems=[];return}activeExtensionHooks=null,activeExtensionCommands=null,activeExtensionParsers=null,activeExtensionPreflight=null,activeExtensionServices=null,activeExtensionRenderers=null,activeExtensionRegistrations=null,activeCommandContext=null,activeCommandResult=void 0,activeAfterCommandAffectedItems=[]}async function runActiveOnWriteHooks(context){const state=runtimeState(),hooks=state?state.hooks:activeExtensionHooks;return hooks?runOnWriteHooks(hooks,context):[]}const previewMutationGuards=new AsyncLocalStorage;function runWithPreviewMutationGuards(hooks,run){return!hooks||(hooks.beforeMutation?.length??0)===0?run():previewMutationGuards.run(hooks,run)}function getActiveExtensionHooks(){const state=runtimeState();return state?state.hooks:activeExtensionHooks}async function runActiveBeforeMutationHooks(input){const preview=previewMutationGuards.getStore(),hooks=preview??getActiveExtensionHooks();if(!hooks)return;const{resolveMutationActor}=await import("./mutation-actor.js"),isDryRun=preview!==void 0||input.dry_run===!0,compensation=isDryRun?void 0:ownedTransactionCompensation(input.pm_root,[input.before?.metadata.id,input.after?.metadata.id],input.operation),overrides=await runBeforeMutationHooks(hooks,{pm_root:input.pm_root,operation:input.operation,before:input.before,after:input.after,changed_fields:input.changed_fields,sdk:input.sdk,actor:resolveMutationActor(input.author),dry_run:isDryRun,...compensation===void 0?{}:{compensation:{transaction_id:compensation.transaction_id,step_id:compensation.step_id}}});compensation?.overrides.push(...overrides.map(override=>({source:"mutation_guard",...override})))}async function runActiveOnReadHooks(context){const state=runtimeState(),hooks=state?state.hooks:activeExtensionHooks;return hooks?runOnReadHooks(hooks,context):[]}function hasActiveOnWriteHooks(){const state=runtimeState();return((state?state.hooks:activeExtensionHooks)?.onWrite?.length??0)>0}function hasActiveOnReadHooks(){const state=runtimeState();return((state?state.hooks:activeExtensionHooks)?.onRead?.length??0)>0}async function runActiveOnIndexHooks(context){const state=runtimeState(),hooks=state?state.hooks:activeExtensionHooks;return hooks?runOnIndexHooks(hooks,context):[]}function runActiveCommandOverride(result){const state=runtimeState(),commands=state?state.commands:activeExtensionCommands,commandContext=state?state.commandContext:activeCommandContext;return!commands||!commandContext?{overridden:!1,result,warnings:[]}:runCommandOverride(commands,{command:commandContext.command,args:[...commandContext.args],options:commandContext.options?{...commandContext.options}:{},global:commandContext.global?{...commandContext.global}:void 0,pm_root:commandContext.pm_root,source_workspace_root:commandContext.source_workspace_root,repo_root:commandContext.repo_root,pm_root_rel:commandContext.pm_root_rel,result})}async function runActiveCommandHandler(context){const state=runtimeState(),commands=state?state.commands:activeExtensionCommands;return commands?runCommandHandler(commands,{...context,...resolvePortableWorkspaceContext(context.pm_root)}):{handled:!1,result:null,warnings:[]}}async function runActiveParserOverride(context){const state=runtimeState(),parsers=state?state.parsers:activeExtensionParsers;return parsers?runParserOverride(parsers,{...context,...resolvePortableWorkspaceContext(context.pm_root)}):{overridden:!1,context:{command:context.command,args:[...context.args],options:{...context.options},global:{...context.global},pm_root:context.pm_root},warnings:[]}}async function runActivePreflightOverride(context){const state=runtimeState(),preflight=state?state.preflight:activeExtensionPreflight;return preflight?runPreflightOverride(preflight,{...context,...resolvePortableWorkspaceContext(context.pm_root)}):{overridden:!1,context:{command:context.command,args:[...context.args],options:{...context.options},global:{...context.global},pm_root:context.pm_root},decision:{...context.decision},warnings:[]}}function runActiveRendererOverride(format,result){const state=runtimeState(),renderers=state?state.renderers:activeExtensionRenderers,commandContext=state?state.commandContext:activeCommandContext;return renderers?runRendererOverride(renderers,{format,command:commandContext?.command,args:commandContext?[...commandContext.args]:[],options:commandContext?.options?{...commandContext.options}:{},global:commandContext?.global?{...commandContext.global}:void 0,pm_root:commandContext?.pm_root,source_workspace_root:commandContext?.source_workspace_root,repo_root:commandContext?.repo_root,pm_root_rel:commandContext?.pm_root_rel,result}):{overridden:!1,rendered:null,warnings:[]}}function buildServiceContext(service,payload){const state=runtimeState(),commandContext=state?state.commandContext:activeCommandContext;return{service,command:commandContext?.command,args:commandContext?[...commandContext.args]:[],options:commandContext?.options?{...commandContext.options}:{},global:commandContext?.global?{...commandContext.global}:void 0,pm_root:commandContext?.pm_root,source_workspace_root:commandContext?.source_workspace_root,repo_root:commandContext?.repo_root,pm_root_rel:commandContext?.pm_root_rel,payload}}async function runActiveServiceOverride(service,payload){const state=runtimeState(),services=state?state.services:activeExtensionServices;return services?runServiceOverride(services,buildServiceContext(service,payload)):{handled:!1,result:payload,warnings:[]}}function runActiveServiceOverrideSync(service,payload){const state=runtimeState(),services=state?state.services:activeExtensionServices;return services?runServiceOverrideSync(services,buildServiceContext(service,payload)):{handled:!1,result:payload,warnings:[]}}export*from"./loader.js";export*from"./command-hook-context.js";import{createSerialQueue}from"../shared/serial-queue.js";import{EXTENSION_CAPABILITY_REGISTRATION_SURFACES,collectUsedExtensionCapabilities,reconcileExtensionCapabilityUsage}from"./capability-usage.js";export{EXTENSION_CAPABILITY_REGISTRATION_SURFACES,clearActiveExtensionHooks,collectUsedExtensionCapabilities,consumeAfterCommandAffectedItems,createSerialQueue,getActiveCommandContext,getActiveCommandResult,getActiveExtensionHooks,getActiveExtensionRegistrations,hasActiveOnReadHooks,hasActiveOnWriteHooks,isActiveCommandUnextended,projectAfterCommandItemSnapshot,reconcileExtensionCapabilityUsage,recordAfterCommandAffectedItem,resetActiveExtensionRuntimeState,resolvePortableWorkspaceContext,runActiveBeforeMutationHooks,runActiveCommandHandler,runActiveCommandOverride,runActiveOnIndexHooks,runActiveOnReadHooks,runActiveOnWriteHooks,runActiveParserOverride,runActivePreflightOverride,runActiveRendererOverride,runActiveServiceOverride,runActiveServiceOverrideSync,runWithIsolatedExtensionRuntime,runWithPreviewMutationGuards,setActiveCommandContext,setActiveCommandResult,setActiveExtensionCommands,setActiveExtensionHooks,setActiveExtensionParsers,setActiveExtensionPreflight,setActiveExtensionRegistrations,setActiveExtensionRenderers,setActiveExtensionServices};
1
+ import{existsSync as E}from"node:fs";import{AsyncLocalStorage as A}from"node:async_hooks";import a from"node:path";import{ownedTransactionCompensation as S}from"../store/item-mutation-precondition.js";import{runCommandHandler as w,runBeforeMutationHooks as I,runCommandOverride as y,runOnIndexHooks as H,runParserOverride as P,runPreflightOverride as W,runOnReadHooks as M,runRendererOverride as T,runServiceOverride as j,runServiceOverrideSync as N,runOnWriteHooks as U}from"./loader.js";let c=null,l=null,m=null,f=null,d=null,p=null,v=null,u=null,_,g=[];const C=new A;function s(){return C.getStore()}function X(e){return C.run({hooks:null,commands:null,parsers:null,preflight:null,services:null,renderers:null,registrations:null,commandContext:null,commandResult:void 0,affectedItems:[]},e)}const D=new Set(["body","comments","dependencies","docs","events","files","learnings","notes","reminders","test_runs","tests"]);function k(e){let t=a.resolve(e);for(;;){if(E(a.join(t,".git")))return t;const o=a.dirname(t);if(o===t)return;t=o}}function x(e){const t=process.env.PM_SOURCE_WORKSPACE_ROOT?.trim()||process.cwd(),o=k(t)??a.resolve(t),n=k(o);if(!e)return{source_workspace_root:o,...n?{repo_root:n}:{}};const r=a.relative(o,a.resolve(e)),i=r.length>0&&!r.startsWith(`..${a.sep}`)&&r!==".."&&!a.isAbsolute(r);return{source_workspace_root:o,...n?{repo_root:n}:{},...i?{pm_root_rel:r.split(a.sep).join("/")}:{}}}function Y(e){const t=s();if(t){t.hooks=e;return}c=e}function $(e){const t=s();if(t){t.commands=e;return}l=e}function q(e){const t=s();if(t){t.parsers=e;return}m=e}function z(e){const t=s();if(t){t.preflight=e;return}f=e}function J(e){const t=s();if(t){t.services=e;return}d=e}function V(e){const t=s();if(t){t.renderers=e;return}p=e}function Z(e){const t=s();if(t){t.registrations=e;return}v=e}function ee(){const e=s();return e?e.registrations:v}function te(){const e=s();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=null,e.affectedItems=[];return}c=null,l=null,m=null,f=null,d=null,p=null,v=null,u=null,_=null}function oe(e){const t=e?{...e,...x(e.pm_root)}:null,o=s();if(o){o.commandContext=t;return}u=t}function ne(){const e=s(),t=e?e.commandContext:u;return t?{...t,args:[...t.args],options:t.options?{...t.options}:{},global:t.global?{...t.global}:void 0}:null}function re(e){const t=s()??{commandContext:u,hooks:c,commands:l,parsers:m,preflight:f,services:d,renderers:p,registrations:v};return t.commandContext?.command!==e||[t.hooks,t.preflight,t.services,t.renderers].some(r=>Object.values(r??{}).some(i=>i.length>0))||[t.commands,t.parsers].some(r=>Object.values(r??{}).some(i=>i.some(h=>h.command===e)))?!1:!Object.entries(t.registrations??{}).some(([r,i])=>["migrations","search_providers","vector_store_adapters","assurance_providers"].includes(r)&&i.length>0)}function se(e){const t=s();if(t){t.commandResult=e;return}_=e}function ie(){const e=s();return e?e.commandResult:_}function ce(e){if(!e)return;const t=s();t?t.affectedItems.push(e):g.push(e)}function ae(e,t){if(!e||!e.id)return{};const o={id:e.id,type:e.type,status:e.status};if(!Array.isArray(t))return o;const n=e;for(const r of t){if(typeof r!="string")continue;const i=r.startsWith("unset:")?r.slice(6):r;i==="id"||i==="type"||i==="status"||D.has(i)||Object.hasOwn(n,i)&&n[i]!==void 0&&(o[i]=n[i])}return o}function ue(){const e=s(),t=e?.affectedItems??g;if(t.length===0)return;const o=t;return e?e.affectedItems=[]:g=[],o}function le(){const e=s();if(e){e.hooks=null,e.commands=null,e.parsers=null,e.preflight=null,e.services=null,e.renderers=null,e.registrations=null,e.commandContext=null,e.commandResult=void 0,e.affectedItems=[];return}c=null,l=null,m=null,f=null,d=null,p=null,v=null,u=null,_=void 0,g=[]}async function de(e){const t=s(),o=t?t.hooks:c;return o?U(o,e):[]}const O=new A;function me(e,t){return!e||(e.beforeMutation?.length??0)===0?t():O.run(e,t)}function B(){const e=s();return e?e.hooks:c}async function fe(e){const t=O.getStore(),o=t??B();if(!o)return;const{resolveMutationActor:n}=await import("./mutation-actor.js"),r=t!==void 0||e.dry_run===!0,i=r?void 0:S(e.pm_root,[e.before?.metadata.id,e.after?.metadata.id],e.operation),h=await I(o,{pm_root:e.pm_root,operation:e.operation,before:e.before,after:e.after,changed_fields:e.changed_fields,sdk:e.sdk,actor:n(e.author),dry_run:r,...i===void 0?{}:{compensation:{transaction_id:i.transaction_id,step_id:i.step_id}}});i?.overrides.push(...h.map(b=>({source:"mutation_guard",...b})))}async function pe(e){const t=s(),o=t?t.hooks:c;return o?M(o,e):[]}function ve(){const e=s();return((e?e.hooks:c)?.onWrite?.length??0)>0}function _e(){const e=s();return((e?e.hooks:c)?.onRead?.length??0)>0}async function ge(e){const t=s(),o=t?t.hooks:c;return o?H(o,e):[]}function xe(e){const t=s(),o=t?t.commands:l,n=t?t.commandContext:u;return!o||!n?{overridden:!1,result:e,warnings:[]}:y(o,{command:n.command,args:[...n.args],options:n.options?{...n.options}:{},global:n.global?{...n.global}:void 0,pm_root:n.pm_root,source_workspace_root:n.source_workspace_root,repo_root:n.repo_root,pm_root_rel:n.pm_root_rel,result:e})}async function he(e){const t=s(),o=t?t.commands:l;return o?w(o,{...e,...x(e.pm_root)}):{handled:!1,result:null,warnings:[]}}async function Ae(e){const t=s(),o=t?t.parsers:m;return o?P(o,{...e,...x(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},warnings:[]}}async function Ce(e){const t=s(),o=t?t.preflight:f;return o?W(o,{...e,...x(e.pm_root)}):{overridden:!1,context:{command:e.command,args:[...e.args],options:{...e.options},global:{...e.global},pm_root:e.pm_root},decision:{...e.decision},warnings:[]}}function ke(e,t){const o=s(),n=o?o.renderers:p,r=o?o.commandContext:u;return n?T(n,{format:e,command:r?.command,args:r?[...r.args]:[],options:r?.options?{...r.options}:{},global:r?.global?{...r.global}:void 0,pm_root:r?.pm_root,source_workspace_root:r?.source_workspace_root,repo_root:r?.repo_root,pm_root_rel:r?.pm_root_rel,result:t}):{overridden:!1,rendered:null,warnings:[]}}function R(e,t){const o=s(),n=o?o.commandContext:u;return{service:e,command:n?.command,args:n?[...n.args]:[],options:n?.options?{...n.options}:{},global:n?.global?{...n.global}:void 0,pm_root:n?.pm_root,source_workspace_root:n?.source_workspace_root,repo_root:n?.repo_root,pm_root_rel:n?.pm_root_rel,payload:t}}async function Oe(e,t){const o=s(),n=o?o.services:d;return n?j(n,R(e,t)):{handled:!1,result:t,warnings:[]}}function Re(e,t){const o=s(),n=o?o.services:d;return n?N(n,R(e,t)):{handled:!1,result:t,warnings:[]}}export*from"./loader.js";export*from"./command-hook-context.js";import{createSerialQueue as Ie}from"../shared/serial-queue.js";import{EXTENSION_CAPABILITY_REGISTRATION_SURFACES as He,collectUsedExtensionCapabilities as Pe,reconcileExtensionCapabilityUsage as We}from"./capability-usage.js";export{He as EXTENSION_CAPABILITY_REGISTRATION_SURFACES,le as clearActiveExtensionHooks,Pe as collectUsedExtensionCapabilities,ue as consumeAfterCommandAffectedItems,Ie as createSerialQueue,ne as getActiveCommandContext,ie as getActiveCommandResult,B as getActiveExtensionHooks,ee as getActiveExtensionRegistrations,_e as hasActiveOnReadHooks,ve as hasActiveOnWriteHooks,re as isActiveCommandUnextended,ae as projectAfterCommandItemSnapshot,We as reconcileExtensionCapabilityUsage,ce as recordAfterCommandAffectedItem,te as resetActiveExtensionRuntimeState,x as resolvePortableWorkspaceContext,fe as runActiveBeforeMutationHooks,he as runActiveCommandHandler,xe as runActiveCommandOverride,ge as runActiveOnIndexHooks,pe as runActiveOnReadHooks,de as runActiveOnWriteHooks,Ae as runActiveParserOverride,Ce as runActivePreflightOverride,ke as runActiveRendererOverride,Oe as runActiveServiceOverride,Re as runActiveServiceOverrideSync,X as runWithIsolatedExtensionRuntime,me as runWithPreviewMutationGuards,oe as setActiveCommandContext,se as setActiveCommandResult,$ as setActiveExtensionCommands,Y as setActiveExtensionHooks,q as setActiveExtensionParsers,z as setActiveExtensionPreflight,Z as setActiveExtensionRegistrations,V as setActiveExtensionRenderers,J as setActiveExtensionServices};
2
2
  //# sourceMappingURL=index.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]="47d10c23-88f8-5ba1-bcc2-458f339121a8")}catch{}})();import{levenshteinDistanceWithinLimit}from"../shared/levenshtein.js";import{RUNTIME_FIELD_TYPE_VALUES}from"../../types/index.js";const KNOWN_ITEM_FIELD_TYPES=RUNTIME_FIELD_TYPE_VALUES;function normalizeItemFieldType(value){const normalized=value.trim().toLowerCase();return KNOWN_ITEM_FIELD_TYPES.includes(normalized)?normalized:null}function suggestKnownItemFieldType(value){const normalized=value.trim().toLowerCase();if(normalized.length===0)return null;const limit=Math.max(1,Math.floor(normalized.length*.34));for(const candidate of KNOWN_ITEM_FIELD_TYPES)if(levenshteinDistanceWithinLimit(normalized,candidate,limit)!==null)return candidate;return null}export{KNOWN_ITEM_FIELD_TYPES,normalizeItemFieldType,suggestKnownItemFieldType};
1
+ import{levenshteinDistanceWithinLimit as i}from"../shared/levenshtein.js";import{RUNTIME_FIELD_TYPE_VALUES as l}from"../../types/index.js";const o=l;function u(n){const t=n.trim().toLowerCase();return o.includes(t)?t:null}function a(n){const t=n.trim().toLowerCase();if(t.length===0)return null;const r=Math.max(1,Math.floor(t.length*.34));for(const e of o)if(i(t,e,r)!==null)return e;return null}export{o as KNOWN_ITEM_FIELD_TYPES,u as normalizeItemFieldType,a as suggestKnownItemFieldType};
2
2
  //# sourceMappingURL=item-field-types.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]="4e02447f-3fb0-5f7c-9512-be2b348fd082")}catch{}})();import{normalizeItemFieldType}from"./item-field-types.js";import{EXIT_CODE,ITEM_METADATA_KEY_ORDER}from"../shared/constants.js";import{PmCliError}from"../shared/errors.js";const reservedItemFieldNames=new Set(ITEM_METADATA_KEY_ORDER),RESERVED_ITEM_FIELD_NAMES=Object.freeze({get size(){return reservedItemFieldNames.size},has(value){return reservedItemFieldNames.has(value)},entries(){return reservedItemFieldNames.entries()},keys(){return reservedItemFieldNames.keys()},values(){return reservedItemFieldNames.values()},forEach(callback,thisArg){reservedItemFieldNames.forEach(value=>callback.call(thisArg,value,value,RESERVED_ITEM_FIELD_NAMES))},[Symbol.iterator](){return reservedItemFieldNames.values()}});function normalizeFieldName(value){if(typeof value!="string")return null;const normalized=value.trim();return normalized.length>0?normalized:null}function normalizeFieldType(value){return typeof value!="string"?null:normalizeItemFieldType(value)}function cloneFieldValue(value){try{return structuredClone(value)}catch{return value}}function parseFieldAssignment(raw){const trimmed=raw.trim(),separatorIndex=trimmed.indexOf("=");if(separatorIndex<=0)throw new PmCliError(`--field entries must use name=value syntax, received: ${raw}`,EXIT_CODE.USAGE);const key=trimmed.slice(0,separatorIndex).trim(),value=trimmed.slice(separatorIndex+1);return{key,value}}function parseJsonFieldValue(raw,fieldName,expectedType){try{const parsed=JSON.parse(raw);if(expectedType==="array"&&Array.isArray(parsed)||expectedType==="object"&&typeof parsed=="object"&&parsed!==null&&!Array.isArray(parsed))return parsed}catch{}throw new PmCliError(`--field ${fieldName}=... must be valid JSON ${expectedType}`,EXIT_CODE.USAGE)}function coerceRegisteredFieldValue(fieldName,fieldType,raw){if(fieldType==="string")return raw;if(fieldType==="number"){const trimmed=raw.trim();if(trimmed.length===0)throw new PmCliError(`--field ${fieldName}=... must be a number`,EXIT_CODE.USAGE);const parsed=Number(trimmed);if(!Number.isFinite(parsed))throw new PmCliError(`--field ${fieldName}=... must be a number`,EXIT_CODE.USAGE);return parsed}if(fieldType==="boolean"){const normalized=raw.trim().toLowerCase();if(normalized==="true"||normalized==="1"||normalized==="yes")return!0;if(normalized==="false"||normalized==="0"||normalized==="no")return!1;throw new PmCliError(`--field ${fieldName}=... must be one of true|false|1|0|yes|no`,EXIT_CODE.USAGE)}return fieldType==="string_array"?raw.split(/[\n,|]/u).map(value=>value.trim()).filter(value=>value.length>0):parseJsonFieldValue(raw,fieldName,fieldType)}function collectRegisteredFieldDefinitions(registrations){const definitions=new Map;if(!registrations)return definitions;for(const registration of registrations.item_fields)for(const definition of registration.fields){const fieldName=normalizeFieldName(definition.name),fieldType=normalizeFieldType(definition.type);if(!fieldName||!fieldType)continue;const existing=definitions.get(fieldName);if(existing&&existing.type!==fieldType)throw new PmCliError(`Extension item field "${fieldName}" is declared with conflicting types: ${existing.type}, ${fieldType}`,EXIT_CODE.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});definitions.set(fieldName,{name:fieldName,type:fieldType})}return definitions}function assertNotReservedItemFieldName(fieldName){if(RESERVED_ITEM_FIELD_NAMES.has(fieldName))throw new PmCliError(`Extension item field "${fieldName}" collides with built-in item metadata "${fieldName}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...RESERVED_ITEM_FIELD_NAMES].sort((left,right)=>left.localeCompare(right)).join(", ")}.`,EXIT_CODE.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function collectRegisteredItemFieldNames(registrations){return[...collectRegisteredFieldDefinitions(registrations).keys()].sort((left,right)=>left.localeCompare(right))}function parseRegisteredItemFieldAssignments(rawFields,registrations,resolveCoreFieldRecovery,resolveSchemaFieldRecovery){if(!rawFields||rawFields.length===0)return{};const definitions=collectRegisteredFieldDefinitions(registrations),values={};for(const raw of rawFields){const{key,value}=parseFieldAssignment(raw),definition=definitions.get(key);if(!definition)throw unregisteredFieldRefusal(key,definitions,resolveCoreFieldRecovery,resolveSchemaFieldRecovery);assertNotReservedItemFieldName(definition.name),values[definition.name]=coerceRegisteredFieldValue(definition.name,definition.type,value)}return values}function unregisteredFieldRefusal(key,definitions,resolveCoreFieldRecovery,resolveSchemaFieldRecovery){if(RESERVED_ITEM_FIELD_NAMES.has(key)){const guidance=resolveCoreFieldRecovery?.(key)??{recovery:{provided_fields:[key]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new PmCliError(`--field ${key} is a core item field, not an extension field`,EXIT_CODE.USAGE,{code:"core_item_field_requires_dedicated_flag",field:key,...guidance})}const schemaGuidance=resolveSchemaFieldRecovery?.(key);if(schemaGuidance!==void 0){const flag=schemaGuidance.recovery?.suggested_flags?.[0];return new PmCliError(flag===void 0?`--field ${key} is a project-schema field, not an extension field`:`--field ${key} is a project-schema field; set it with its declared flag ${flag}`,EXIT_CODE.USAGE,{code:"project_schema_field_requires_declared_flag",field:key,changed:!1,...schemaGuidance})}const known=[...definitions.keys()].sort((left,right)=>left.localeCompare(right));return new PmCliError(`--field ${key} is not declared by an active extension item-field registration`,EXIT_CODE.USAGE,{code:"extension_item_field_unknown",field:key,recovery:{provided_fields:[key]},nextSteps:known.length>0?[`Use one of the declared fields: ${known.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function isValidFieldType(value,expectedType){return expectedType==="string"?typeof value=="string":expectedType==="number"?typeof value=="number"&&Number.isFinite(value):expectedType==="boolean"?typeof value=="boolean":expectedType==="array"?Array.isArray(value):expectedType==="string_array"?Array.isArray(value)&&value.every(entry=>typeof entry=="string"):typeof value=="object"&&value!==null&&!Array.isArray(value)}function isAllowedFieldValue(value,allowed){return!allowed||allowed.length===0?!0:allowed.some(candidate=>Object.is(candidate,value))}function applyRegisteredItemFieldDefaultsAndValidation(itemMetadata,registrations,options={}){if(registrations){collectRegisteredFieldDefinitions(registrations);for(const registration of registrations.item_fields)for(const definition of registration.fields){const fieldName=normalizeFieldName(definition.name);if(!fieldName)continue;assertNotReservedItemFieldName(fieldName),!(fieldName in itemMetadata)&&!options.skipDefaultFields?.has(fieldName)&&Object.prototype.hasOwnProperty.call(definition,"default")&&(itemMetadata[fieldName]=cloneFieldValue(definition.default));const currentValue=itemMetadata[fieldName];if(currentValue===void 0)continue;const expectedType=normalizeFieldType(definition.type);if(expectedType&&!isValidFieldType(currentValue,expectedType))throw new TypeError(`Item field "${fieldName}" must be of type ${expectedType}`);const allowedValues=Array.isArray(definition.values)?definition.values:void 0;if(!isAllowedFieldValue(currentValue,allowedValues))throw new TypeError(`Item field "${fieldName}" must match one of the configured allowed values`)}}}export{RESERVED_ITEM_FIELD_NAMES,applyRegisteredItemFieldDefaultsAndValidation,collectRegisteredItemFieldNames,parseRegisteredItemFieldAssignments};
1
+ import{normalizeItemFieldType as _}from"./item-field-types.js";import{EXIT_CODE as f,ITEM_METADATA_KEY_ORDER as A}from"../shared/constants.js";import{PmCliError as l}from"../shared/errors.js";const c=new Set(A),u=Object.freeze({get size(){return c.size},has(e){return c.has(e)},entries(){return c.entries()},keys(){return c.keys()},values(){return c.values()},forEach(e,t){c.forEach(n=>e.call(t,n,n,u))},[Symbol.iterator](){return c.values()}});function h(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function y(e){return typeof e!="string"?null:_(e)}function w(e){try{return structuredClone(e)}catch{return e}}function E(e){const t=e.trim(),n=t.indexOf("=");if(n<=0)throw new l(`--field entries must use name=value syntax, received: ${e}`,f.USAGE);const i=t.slice(0,n).trim(),r=t.slice(n+1);return{key:i,value:r}}function b(e,t,n){try{const i=JSON.parse(e);if(n==="array"&&Array.isArray(i)||n==="object"&&typeof i=="object"&&i!==null&&!Array.isArray(i))return i}catch{}throw new l(`--field ${t}=... must be valid JSON ${n}`,f.USAGE)}function x(e,t,n){if(t==="string")return n;if(t==="number"){const i=n.trim();if(i.length===0)throw new l(`--field ${e}=... must be a number`,f.USAGE);const r=Number(i);if(!Number.isFinite(r))throw new l(`--field ${e}=... must be a number`,f.USAGE);return r}if(t==="boolean"){const i=n.trim().toLowerCase();if(i==="true"||i==="1"||i==="yes")return!0;if(i==="false"||i==="0"||i==="no")return!1;throw new l(`--field ${e}=... must be one of true|false|1|0|yes|no`,f.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(i=>i.trim()).filter(i=>i.length>0):b(n,e,t)}function p(e){const t=new Map;if(!e)return t;for(const n of e.item_fields)for(const i of n.fields){const r=h(i.name),o=y(i.type);if(!r||!o)continue;const s=t.get(r);if(s&&s.type!==o)throw new l(`Extension item field "${r}" is declared with conflicting types: ${s.type}, ${o}`,f.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(r,{name:r,type:o})}return t}function g(e){if(u.has(e))throw new l(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...u].sort((t,n)=>t.localeCompare(n)).join(", ")}.`,f.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function U(e){return[...p(e).keys()].sort((t,n)=>t.localeCompare(n))}function j(e,t,n,i){if(!e||e.length===0)return{};const r=p(t),o={};for(const s of e){const{key:a,value:m}=E(s),d=r.get(a);if(!d)throw $(a,r,n,i);g(d.name),o[d.name]=x(d.name,d.type,m)}return o}function $(e,t,n,i){if(u.has(e)){const s=n?.(e)??{recovery:{provided_fields:[e]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new l(`--field ${e} is a core item field, not an extension field`,f.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}const r=i?.(e);if(r!==void 0){const s=r.recovery?.suggested_flags?.[0];return new l(s===void 0?`--field ${e} is a project-schema field, not an extension field`:`--field ${e} is a project-schema field; set it with its declared flag ${s}`,f.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...r})}const o=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new l(`--field ${e} is not declared by an active extension item-field registration`,f.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:o.length>0?[`Use one of the declared fields: ${o.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function S(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function F(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function G(e,t,n={}){if(t){p(t);for(const i of t.item_fields)for(const r of i.fields){const o=h(r.name);if(!o)continue;g(o),!(o in e)&&!n.skipDefaultFields?.has(o)&&Object.prototype.hasOwnProperty.call(r,"default")&&(e[o]=w(r.default));const s=e[o];if(s===void 0)continue;const a=y(r.type);if(a&&!S(s,a))throw new TypeError(`Item field "${o}" must be of type ${a}`);const m=Array.isArray(r.values)?r.values:void 0;if(!F(s,m))throw new TypeError(`Item field "${o}" must match one of the configured allowed values`)}}}export{u as RESERVED_ITEM_FIELD_NAMES,G as applyRegisteredItemFieldDefaultsAndValidation,U as collectRegisteredItemFieldNames,j as parseRegisteredItemFieldAssignments};
2
2
  //# sourceMappingURL=item-fields.js.map