@unbrained/pm-cli 2026.10.15 → 2026.10.18

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 (275) hide show
  1. package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/AGENTS.md +1 -0
  4. package/CHANGELOG.md +45 -0
  5. package/dist/cli/extension-command-options.d.ts +3 -1
  6. package/dist/cli/extension-command-options.js +1 -1
  7. package/dist/cli/help-content.js +2 -2
  8. package/dist/cli/register-list-query.js +2 -2
  9. package/dist/cli/register-mutation.js +2 -2
  10. package/dist/cli/register-operations.js +1 -1
  11. package/dist/cli/register-structured-mutation.d.ts +0 -5
  12. package/dist/cli/register-structured-mutation.js +1 -1
  13. package/dist/cli/runtime/invocation-options.js +1 -1
  14. package/dist/cli-bundle/bundle-manifest.json +1 -1
  15. package/dist/cli-bundle/chunks/{chunk-7VHINXZP.js → chunk-4GA4MUTE.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-RJ5N44WY.js → chunk-4V6ONLI6.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-LNKLQYBG.js → chunk-6VZKYJW7.js} +2 -2
  18. package/dist/cli-bundle/chunks/chunk-7PATQWTH.js +20 -0
  19. package/dist/cli-bundle/chunks/chunk-7WIEAGDS.js +2 -0
  20. package/dist/cli-bundle/chunks/{chunk-52EZH2QQ.js → chunk-AETP4JEM.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-WBBW3WQX.js → chunk-FIJOSX2C.js} +28 -28
  22. package/dist/cli-bundle/chunks/chunk-LUKVNL72.js +2 -0
  23. package/dist/cli-bundle/chunks/{chunk-NC3QVGDD.js → chunk-OJ77ZQN3.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-PYRREEUB.js +30 -0
  25. package/dist/cli-bundle/chunks/chunk-RHQJ6VWC.js +237 -0
  26. package/dist/cli-bundle/chunks/{chunk-N56CAQBU.js → chunk-RNABUEFB.js} +52 -52
  27. package/dist/cli-bundle/chunks/chunk-TO6CIV4C.js +2 -0
  28. package/dist/cli-bundle/chunks/{chunk-JGKTOBVB.js → chunk-ZZED447K.js} +4 -4
  29. package/dist/cli-bundle/chunks/{register-list-query-FKKFQ66D.js → register-list-query-PUCVYYBD.js} +7 -7
  30. package/dist/cli-bundle/chunks/register-mutation-GGGVBXD5.js +20 -0
  31. package/dist/cli-bundle/chunks/{register-operations-GEQ2H7PS.js → register-operations-NRZ6Q4QE.js} +2 -2
  32. package/dist/cli-bundle/chunks/{register-setup-PSJTQBBO.js → register-setup-MV3P3YSF.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-2MPQUMTF.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-H3P77KVU.js → chunk-5UKCSZWT.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-4KQFMOM7.js → chunk-A4ZHHTEX.js} +5 -5
  36. package/dist/cli-bundle/focused-chunks/{chunk-5OO54BIV.js → chunk-B4YLP5ZB.js} +3 -3
  37. package/dist/cli-bundle/focused-chunks/chunk-BFEMT5U3.js +20 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-THYQR3ON.js → chunk-FW7CSSKL.js} +61 -61
  39. package/dist/cli-bundle/focused-chunks/{chunk-3RNUMVK4.js → chunk-HYPRPSYD.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-FQKPOZKS.js → chunk-IRVL4UXR.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-Q4VNCTR2.js → chunk-L55KQ2KT.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-52I2SNKJ.js → chunk-MASIOFPG.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-RJ3EIHDU.js +26 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-SEL4Z2OO.js +167 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-TYLG5VEB.js → chunk-TB7F4FCR.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-KIIFVULU.js → chunk-TZUIBG3P.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-N6FUKTZS.js → chunk-Z7YIFCNE.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-5KRACGBK.js → chunk-ZDBS2DCT.js} +3 -3
  49. package/dist/cli-bundle/main.js +27 -27
  50. package/dist/cli-bundle/sdk-authoring.js +1 -1
  51. package/dist/cli-bundle/sdk-contracts.js +2 -2
  52. package/dist/cli-bundle/sdk-core.js +23 -23
  53. package/dist/cli-bundle/sdk-governance.js +1 -1
  54. package/dist/cli-bundle/sdk-graph.js +1 -1
  55. package/dist/cli-bundle/sdk-merge.js +55 -54
  56. package/dist/cli-bundle/sdk-query.js +1 -1
  57. package/dist/cli-bundle/sdk-runtime.js +1 -1
  58. package/dist/cli-bundle/sdk-testing.js +1 -1
  59. package/dist/cli-bundle/sdk.js +7 -7
  60. package/dist/core/extensions/extension-types.d.ts +15 -0
  61. package/dist/core/extensions/extension-types.js +1 -1
  62. package/dist/core/extensions/flag-value-types.d.ts +16 -0
  63. package/dist/core/extensions/flag-value-types.js +1 -1
  64. package/dist/core/extensions/registration-contracts.js +1 -1
  65. package/dist/core/history/event-index.d.ts +8 -1
  66. package/dist/core/history/event-index.js +19 -18
  67. package/dist/core/item/item-format.js +3 -3
  68. package/dist/core/lock/lock.d.ts +8 -1
  69. package/dist/core/lock/lock.js +3 -3
  70. package/dist/core/output/mutation-projection.d.ts +0 -21
  71. package/dist/core/output/mutation-projection.js +1 -1
  72. package/dist/core/output/output.js +2 -2
  73. package/dist/core/schema/type-workflows.d.ts +1 -1
  74. package/dist/core/schema/type-workflows.js +1 -1
  75. package/dist/core/shared/text-normalization.d.ts +2 -0
  76. package/dist/core/shared/text-normalization.js +1 -1
  77. package/dist/core/store/item-mutation-precondition.d.ts +11 -0
  78. package/dist/core/store/item-mutation-precondition.js +2 -0
  79. package/dist/core/store/item-store.js +1 -1
  80. package/dist/core/store/paths.js +1 -1
  81. package/dist/core/telemetry/policy.d.ts +2 -0
  82. package/dist/core/telemetry/policy.js +1 -1
  83. package/dist/core/telemetry/runtime.d.ts +5 -3
  84. package/dist/core/telemetry/runtime.js +3 -3
  85. package/dist/mcp/server.js +1 -1
  86. package/dist/mcp/tool-definitions.js +1 -1
  87. package/dist/sdk/cli-contracts/agent-output-contracts.js +1 -1
  88. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  89. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  90. package/dist/sdk/cli-contracts/registration-helpers.d.ts +1 -1
  91. package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
  92. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  93. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  94. package/dist/sdk/context-intent-contracts.js +1 -1
  95. package/dist/sdk/core.d.ts +2 -1
  96. package/dist/sdk/core.js +1 -1
  97. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  98. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  99. package/dist/sdk/governance/health/projection.d.ts +37 -0
  100. package/dist/sdk/governance/health/projection.js +2 -0
  101. package/dist/sdk/governance/health.d.ts +7 -18
  102. package/dist/sdk/governance/health.js +2 -2
  103. package/dist/sdk/guide-topics.js +1 -1
  104. package/dist/sdk/index.d.ts +2 -1
  105. package/dist/sdk/index.js +1 -1
  106. package/dist/sdk/item-transaction.d.ts +72 -9
  107. package/dist/sdk/item-transaction.js +1 -1
  108. package/dist/sdk/lifecycle/claim.d.ts +15 -1
  109. package/dist/sdk/lifecycle/claim.js +1 -1
  110. package/dist/sdk/lifecycle/close.d.ts +2 -8
  111. package/dist/sdk/lifecycle/close.js +1 -1
  112. package/dist/sdk/lifecycle/core-item-fields.d.ts +6 -0
  113. package/dist/sdk/lifecycle/core-item-fields.js +2 -0
  114. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  115. package/dist/sdk/lifecycle/mutation-option-validation.d.ts +2 -0
  116. package/dist/sdk/lifecycle/mutation-option-validation.js +2 -0
  117. package/dist/sdk/lifecycle/release-handoff.d.ts +12 -0
  118. package/dist/sdk/lifecycle/release-handoff.js +2 -0
  119. package/dist/sdk/lifecycle/structured-mutation-plan.d.ts +33 -0
  120. package/dist/sdk/lifecycle/structured-mutation-plan.js +2 -0
  121. package/dist/sdk/lifecycle/task-composition.d.ts +2 -2
  122. package/dist/sdk/lifecycle/task-composition.js +1 -1
  123. package/dist/sdk/lifecycle/update.d.ts +3 -11
  124. package/dist/sdk/lifecycle/update.js +1 -1
  125. package/dist/sdk/lifecycle/workflow-transition.d.ts +13 -0
  126. package/dist/sdk/lifecycle/workflow-transition.js +2 -0
  127. package/dist/sdk/lifecycle-policy.d.ts +12 -2
  128. package/dist/sdk/lifecycle-policy.js +1 -1
  129. package/dist/sdk/mutation-events.js +1 -1
  130. package/dist/sdk/public-surface.json +1 -1
  131. package/dist/sdk/query/list.d.ts +2 -0
  132. package/dist/sdk/query/list.js +1 -1
  133. package/dist/sdk/read-output-budget.js +1 -1
  134. package/dist/sdk/runtime-input.js +1 -1
  135. package/dist/sdk/runtime-primitives.d.ts +1 -1
  136. package/dist/sdk/runtime-primitives.js +1 -1
  137. package/dist/sdk/runtime.d.ts +8 -8
  138. package/dist/sdk/runtime.js +1 -1
  139. package/dist/sdk/structured-mutations.d.ts +52 -1
  140. package/dist/sdk/structured-mutations.js +1 -1
  141. package/dist/sdk/workspace-transaction.js +2 -2
  142. package/dist/types.d.ts +2 -2
  143. package/dist/types.js +1 -1
  144. package/docs/AGENT_GUIDE.md +33 -4
  145. package/docs/CLOSE_EVIDENCE_RECOVERY.md +16 -7
  146. package/docs/COMMANDS.md +111 -10
  147. package/docs/CONFIGURATION.md +22 -1
  148. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +22 -3
  149. package/docs/ECOSYSTEM_PLANNING_REVIEW.md +5 -1
  150. package/docs/EXTENSIONS.md +1 -1
  151. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +10 -0
  152. package/docs/RELEASING.md +8 -1
  153. package/docs/SDK.md +114 -2
  154. package/docs/SDK_CONTEXT_COORDINATION.md +71 -7
  155. package/docs/SDK_STORAGE_LIFECYCLE.md +24 -2
  156. package/docs/TESTING.md +23 -0
  157. package/docs/examples/ci/github-actions-pm-extension-gate.yml +1 -1
  158. package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +1 -1
  159. package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +1 -1
  160. package/docs/generated/FLAG_LEXICON_BUDGETS.md +1 -1
  161. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +16 -3
  162. package/marketplace.json +1 -1
  163. package/node_modules/@opentelemetry/core/package.json +2 -1
  164. package/node_modules/@opentelemetry/instrumentation/package.json +2 -1
  165. package/node_modules/@opentelemetry/resources/package.json +2 -1
  166. package/node_modules/@opentelemetry/sdk-trace/package.json +2 -1
  167. package/node_modules/@opentelemetry/sdk-trace-base/package.json +2 -1
  168. package/node_modules/@sentry/core/build/cjs/client.js +5 -4
  169. package/node_modules/@sentry/core/build/cjs/tracing/ai/gen-ai-attributes.js +0 -4
  170. package/node_modules/@sentry/core/build/cjs/tracing/ai/utils.js +33 -23
  171. package/node_modules/@sentry/core/build/cjs/tracing/anthropic-ai/index.js +7 -6
  172. package/node_modules/@sentry/core/build/cjs/tracing/anthropic-ai/streaming.js +3 -1
  173. package/node_modules/@sentry/core/build/cjs/tracing/google-genai/index.js +13 -14
  174. package/node_modules/@sentry/core/build/cjs/tracing/google-genai/streaming.js +6 -1
  175. package/node_modules/@sentry/core/build/cjs/tracing/langchain/utils.js +71 -21
  176. package/node_modules/@sentry/core/build/cjs/tracing/langgraph/utils.js +23 -33
  177. package/node_modules/@sentry/core/build/cjs/tracing/openai/streaming.js +6 -0
  178. package/node_modules/@sentry/core/build/cjs/tracing/openai/utils.js +11 -0
  179. package/node_modules/@sentry/core/build/cjs/tracing/workers-ai/utils.js +1 -1
  180. package/node_modules/@sentry/core/build/cjs/utils/eventUtils.js +4 -0
  181. package/node_modules/@sentry/core/build/cjs/utils/prepareEvent.js +2 -2
  182. package/node_modules/@sentry/core/build/cjs/utils/version.js +1 -1
  183. package/node_modules/@sentry/core/build/esm/client.js +6 -5
  184. package/node_modules/@sentry/core/build/esm/package.json +1 -1
  185. package/node_modules/@sentry/core/build/esm/tracing/ai/gen-ai-attributes.js +1 -3
  186. package/node_modules/@sentry/core/build/esm/tracing/ai/utils.js +34 -24
  187. package/node_modules/@sentry/core/build/esm/tracing/anthropic-ai/index.js +8 -7
  188. package/node_modules/@sentry/core/build/esm/tracing/anthropic-ai/streaming.js +3 -1
  189. package/node_modules/@sentry/core/build/esm/tracing/google-genai/index.js +15 -16
  190. package/node_modules/@sentry/core/build/esm/tracing/google-genai/streaming.js +6 -1
  191. package/node_modules/@sentry/core/build/esm/tracing/langchain/utils.js +73 -24
  192. package/node_modules/@sentry/core/build/esm/tracing/langgraph/utils.js +24 -34
  193. package/node_modules/@sentry/core/build/esm/tracing/openai/streaming.js +6 -0
  194. package/node_modules/@sentry/core/build/esm/tracing/openai/utils.js +11 -0
  195. package/node_modules/@sentry/core/build/esm/tracing/workers-ai/utils.js +2 -2
  196. package/node_modules/@sentry/core/build/esm/utils/eventUtils.js +4 -1
  197. package/node_modules/@sentry/core/build/esm/utils/prepareEvent.js +2 -2
  198. package/node_modules/@sentry/core/build/esm/utils/version.js +1 -1
  199. package/node_modules/@sentry/core/build/types/tracing/ai/utils.d.ts +3 -7
  200. package/node_modules/@sentry/core/build/types/tracing/anthropic-ai/types.d.ts +2 -2
  201. package/node_modules/@sentry/core/build/types/tracing/langchain/types.d.ts +15 -0
  202. package/node_modules/@sentry/core/build/types/tracing/langchain/utils.d.ts +1 -0
  203. package/node_modules/@sentry/core/build/types/tracing/langgraph/utils.d.ts +2 -0
  204. package/node_modules/@sentry/core/build/types/tracing/openai/types.d.ts +2 -0
  205. package/node_modules/@sentry/core/build/types/utils/eventUtils.d.ts +2 -1
  206. package/node_modules/@sentry/core/build/types-ts3.8/tracing/ai/utils.d.ts +3 -7
  207. package/node_modules/@sentry/core/build/types-ts3.8/tracing/anthropic-ai/types.d.ts +2 -2
  208. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langchain/types.d.ts +15 -0
  209. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langchain/utils.d.ts +1 -0
  210. package/node_modules/@sentry/core/build/types-ts3.8/tracing/langgraph/utils.d.ts +2 -0
  211. package/node_modules/@sentry/core/build/types-ts3.8/tracing/openai/types.d.ts +2 -0
  212. package/node_modules/@sentry/core/build/types-ts3.8/utils/eventUtils.d.ts +2 -1
  213. package/node_modules/@sentry/core/package.json +1 -1
  214. package/node_modules/@sentry/node/build/esm/package.json +1 -1
  215. package/node_modules/@sentry/node/package.json +5 -5
  216. package/node_modules/@sentry/node-core/build/cjs/integrations/anr/index.js +1 -1
  217. package/node_modules/@sentry/node-core/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  218. package/node_modules/@sentry/node-core/build/esm/integrations/anr/index.js +1 -1
  219. package/node_modules/@sentry/node-core/build/esm/integrations/anr/worker-script.js +2 -2
  220. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  221. package/node_modules/@sentry/node-core/build/esm/integrations/local-variables/worker-script.js +1 -1
  222. package/node_modules/@sentry/node-core/build/esm/package.json +1 -1
  223. package/node_modules/@sentry/node-core/package.json +10 -4
  224. package/node_modules/@sentry/opentelemetry/build/esm/package.json +1 -1
  225. package/node_modules/@sentry/opentelemetry/package.json +5 -2
  226. package/node_modules/@sentry/server-utils/build/THIRD-PARTY-LICENSES.txt +55 -55
  227. package/node_modules/@sentry/server-utils/build/esm/package.json +1 -1
  228. package/node_modules/@sentry/server-utils/package.json +2 -2
  229. package/node_modules/@toon-format/toon/README.md +10 -41
  230. package/node_modules/@toon-format/toon/dist/index.d.mts +12 -36
  231. package/node_modules/@toon-format/toon/dist/index.mjs +134 -202
  232. package/node_modules/@toon-format/toon/package.json +2 -2
  233. package/node_modules/debug/package.json +3 -0
  234. package/node_modules/fdir/package.json +3 -0
  235. package/node_modules/has-flag/index.d.ts +39 -0
  236. package/node_modules/has-flag/index.js +8 -0
  237. package/node_modules/has-flag/license +9 -0
  238. package/node_modules/has-flag/package.json +46 -0
  239. package/node_modules/has-flag/readme.md +89 -0
  240. package/node_modules/supports-color/browser.js +5 -0
  241. package/node_modules/supports-color/index.js +135 -0
  242. package/node_modules/supports-color/license +9 -0
  243. package/node_modules/supports-color/package.json +53 -0
  244. package/node_modules/supports-color/readme.md +76 -0
  245. package/package.json +5 -4
  246. package/packages/pm-beads/package.json +1 -1
  247. package/packages/pm-calendar/package.json +1 -1
  248. package/packages/pm-command-kit/package.json +1 -1
  249. package/packages/pm-digital-twin/package.json +1 -1
  250. package/packages/pm-governance-audit/package.json +1 -1
  251. package/packages/pm-guide-shell/package.json +1 -1
  252. package/packages/pm-kanban/package.json +1 -1
  253. package/packages/pm-lifecycle-hooks/package.json +1 -1
  254. package/packages/pm-linked-test-adapters/package.json +1 -1
  255. package/packages/pm-search-advanced/package.json +1 -1
  256. package/packages/pm-templates/package.json +1 -1
  257. package/packages/pm-todos/package.json +1 -1
  258. package/packages/pm-vcs/package.json +1 -1
  259. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  260. package/plugins/pm-claude/package.json +1 -1
  261. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  262. package/plugins/pm-codex/package.json +1 -1
  263. package/plugins/pm-codex/plugin.json +1 -1
  264. package/runtime-dependencies.json +1 -1
  265. package/dist/cli-bundle/chunks/chunk-7OEGNA4X.js +0 -20
  266. package/dist/cli-bundle/chunks/chunk-EMEEHV2Y.js +0 -2
  267. package/dist/cli-bundle/chunks/chunk-JSUJWIHQ.js +0 -30
  268. package/dist/cli-bundle/chunks/chunk-VIMQCFCK.js +0 -2
  269. package/dist/cli-bundle/chunks/chunk-X2H6UR26.js +0 -236
  270. package/dist/cli-bundle/chunks/register-mutation-EWMMVZJB.js +0 -20
  271. package/dist/cli-bundle/focused-chunks/chunk-5TBAVZDR.js +0 -20
  272. package/dist/cli-bundle/focused-chunks/chunk-HTA3TNC3.js +0 -26
  273. package/dist/cli-bundle/focused-chunks/chunk-JKBH7YGX.js +0 -2
  274. package/dist/cli-bundle/focused-chunks/chunk-PDYE7QDX.js +0 -166
  275. package/docs/ecosystem-review-2026-09-28.json +0 -1
@@ -0,0 +1,2 @@
1
+ import{a as he}from"./chunk-7WIEAGDS.js";import{Rb as je,Sb as Fe,Ub as V,Xb as Pe,Ya as z,Zb as Ge,_b as xe,a as ye,uc as qe}from"./chunk-FIJOSX2C.js";import{yc as De}from"./chunk-PYRREEUB.js";import{b as Oe,c as J}from"./chunk-RNABUEFB.js";import{Ag as Ee,Ai as Te,F as se,Gi as M,I as A,L as ce,Mk as Re,Oi as Ae,Q as de,Qi as O,R as u,Sk as ke,T as c,Va as x,X as G,Z as ue,Zg as Se,Zi as Ie,_ as I,cb as pe,fp as Ce,hc as me,ip as Ne,km as $e,mm as Ue,og as we,pd as fe,qd as q,qg as K,rg as ge,tb as le,ug as ve,wi as be,xg as _e,yg as E,yh as L,zj as Me}from"./chunk-RHQJ6VWC.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}catch{}})();import Xe from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var S=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...se,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function R(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return S.has(t)?t:e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function k(e,t,n){let i=e?.estimatedMinutes;if(!(i===void 0||typeof i=="string"))throw new c(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,u.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="78df5b0f-51cd-5c24-a1ee-a1d8433be5df")}catch{}})();var W=["op","id","reason","options","unique","match"],St=[...W,"ref"],Ke=[...St,"item"],bt="mutate-",Le="row-",Je=["schema_version","mutations"],Ze="[a-z][a-z0-9._-]{0,63}",ze=new RegExp(`^${Ze}$`,"u"),Qe=new RegExp(`(^|,)id=@(${Ze})(?=,|$)`,"gu"),Ve=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),$=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],et=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),Tt=new Set([...et,"completed_at","id"]),tt={create:Ce.map(e=>e.target),update:Ne.map(e=>e.target),close:Re.map(e=>Ve(e.flag)).filter(e=>e!=="reason"),release:ke.map(e=>Ve(e.flag))};function nt(e){let t=Xe.createHash("sha256").update(e).digest("hex");return`${bt}${t.slice(0,24)}`}function vi(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new c("createCompensation must be close or delete.",u.USAGE);t.createCompensation=n}for(let i of["lockTtlSeconds","lockWaitMs"]){let r=e[i];if(r===void 0)continue;let o=typeof r=="number"||typeof r=="string"&&r.trim().length>0?Number(r):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new c(`${i} must be a positive safe integer.`,u.USAGE);t[i]=o}return t}function f(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function U(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),i;for(let r of t){let o=me(e,r,n);o!==null&&(i===void 0||o<i.distance)&&(i={key:r,distance:o})}return i?.key}function b(e,t,n){let i=U(t,n);return new c(i===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${i}"?`,u.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[i===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${i}".`]})}function H(e,t){try{return JSON.parse(e)}catch(n){let i=n instanceof Error?n.message:String(n);throw new c(`${t} must be valid JSON: ${i}`,u.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function At(e,t){if(!f(e))throw new c(`Mutation ${t+1} must be an object.`,u.USAGE);for(let n of Object.keys(e))if(!W.includes(n))throw b(`mutation ${t+1}`,n,W);return e}function It(e,t,n,i){if(e===void 0)return;if(!f(e))throw new c(`Mutation ${n+1} options must be an object.`,u.USAGE);let r=[...tt[t],...ot(t,i)];for(let o of Object.keys(e))if(!r.includes(o))throw b(`mutation ${n+1} ${t} options`,o,r);return k(e,t,n),e}function We(e,t,n,i){if(e===void 0)return;let r=i==="unique"?"create":"update";if(t!==r)throw new c(`Mutation ${n+1} ${i} is only valid for ${r} operations.`,u.USAGE);let o=f(e)&&typeof e.key=="string"?e.key.trim():"";if(!f(e)||o.length===0||e.value===void 0||e.value===null)throw new c(`Mutation ${n+1} ${i} must be an object with a non-empty key and a value.`,u.USAGE);return{key:o,value:e.value}}function Mt(e,t,n){let i=At(e,t),{op:r,id:o,reason:a}=i;if(r!=="create"&&r!=="update"&&r!=="close"&&r!=="release")throw new c(`Mutation ${t+1} op must be create, update, close, or release.`,u.USAGE);let s=It(i.options,r,t,n),d=We(i.unique,r,t,"unique"),p=We(i.match,r,t,"match");if(typeof o!="string"||o.trim().length===0)throw new c(`Mutation ${t+1} requires a non-empty id.`,u.USAGE);let l=o.trim();if(r==="close"){if(typeof a!="string"||a.trim().length===0)throw new c(`Mutation ${t+1} close requires a non-empty reason.`,u.USAGE);return{op:r,id:l,reason:a.trim(),...s===void 0?{}:{options:s}}}if(r==="release")return{op:r,id:l,...s===void 0?{}:{options:s}};if(!f(s))throw new c(`Mutation ${t+1} ${r} requires an options object.`,u.USAGE);return{op:r,id:l,options:s,...d===void 0?{}:{unique:d},...p===void 0?{}:{match:p}}}function it(e,t={}){let n=H(e,"Mutation batch"),i=Array.isArray(n)?n:f(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(i===void 0||i.length===0)throw new c("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",u.USAGE);let r=t.runtimeFields??[];return i.map((o,a)=>{let s=Mt(o,a,r);return s.options!==void 0&&$e(s.options),s})}function Ot(e,t,n){let i=Xe.createHash("sha256").update(e).update("\0").update(t).digest("hex"),r=BigInt(`0x${i.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ae(n)}${r}`}function Be(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),i=t[n];if(i===void 0)throw new c(`Unknown mutation reference "${e}".`,u.USAGE);return i}function Ye(e,t){if(typeof e!="string")return e;let n=e.replace(Qe,(i,r,o)=>{let a=t[o];if(a===void 0)throw new c(`Unknown mutation reference "@${o}".`,u.USAGE);return`${r}id=${a}`});if(/(^|,)id=@/u.test(n))throw new c(`Malformed mutation reference in dependency "${e}".`,u.USAGE);return n}function Rt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(Qe)].map(t=>t[1]).filter(t=>t!==void 0)}function kt(e,t){let n=new Map;for(let[a,s]of e.entries()){let d=t[a];if(d===void 0)continue;let p=f(s.options)?s.options:{},l=Array.isArray(p.dep)?p.dep:p.dep===void 0?[]:[p.dep];n.set(d,[p.parent,p.blockedBy,...l].flatMap(Rt))}let i=new Set,r=new Set,o=a=>{if(i.has(a))throw new c(`Mutation reference cycle includes "@${a}".`,u.USAGE);if(!r.has(a)){i.add(a);for(let s of n.get(a))n.has(s)&&o(s);i.delete(a),r.add(a)}};for(let a of n.keys())o(a)}function $t(e){let t=e.split(/\r?\n/u).map((o,a)=>({line:o.trim(),number:a+1})).filter(o=>o.line.length>0);if(t.length<2)return null;let n=t.map(o=>{try{return{...o,ok:!0,value:JSON.parse(o.line)}}catch(a){return{...o,ok:!1,error:a}}}),i=n[0];if(!i.ok&&(i.line.startsWith("[")||i.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&f(o.value)))return null;let r=[];for(let o of n){if(!o.ok)throw new c(`Mutation document line ${o.number} must be one valid JSON object: ${he(o.error)}`,u.USAGE,{code:"stdin_json_invalid",required:"Provide one JSON object per line (JSON Lines), a JSON array, or a {schema_version, mutations} document.",why:"Structured mutation input must parse deterministically before any tracker write begins."});if(!f(o.value))throw new c(`Mutation document line ${o.number} must be a JSON object.`,u.USAGE);r.push(o.value)}return r}function Ut(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function Ct(e){let t;try{t=H(e,"Mutation document")}catch(n){let i=$t(e);if(i===null)throw n;return{schema_version:1,mutations:i}}return Array.isArray(t)?{schema_version:1,mutations:t}:f(t)&&!Ut(t)?{schema_version:1,mutations:[t]}:t}function Nt(e,t){let n=Object.hasOwn(e,"op")?Dt(e,t):jt(e,t);if(n.op==="create"&&n.id===void 0&&f(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new c(`Mutation ${t+1} item id must be a string.`,u.USAGE);n.id=n.item.id}return n}function Dt(e,t){for(let n of Object.keys(e))if(!Ke.includes(n))throw b(`mutation ${t+1}`,n,Ke);if(e.item!==void 0&&e.op!=="create")throw new c(`Mutation ${t+1} item documents are only valid for create operations.`,u.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new c(`Mutation ${t+1} must declare either item or options, not both.`,u.USAGE);return{...e}}function jt(e,t){let{ref:n,id:i,item:r,...o}=e,a=r!==void 0?r:o;if(r!==void 0&&Object.keys(o).length>0)throw new c(`Mutation ${t+1} must not mix item document keys with top-level fields.`,u.USAGE);if(!f(a))throw new c(`Mutation ${t+1} item document must be an object.`,u.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...i===void 0?{}:{id:i},item:a}}function Ft(e){let t=Ct(e);if(!f(t))throw new c("Mutation document must be a JSON array or object.",u.USAGE);for(let n of Object.keys(t))if(!Je.includes(n))throw b("mutation document",n,Je);if(t.schema_version!==void 0&&t.schema_version!==1)throw new c("Mutation document schema_version must be 1.",u.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new c("Mutation document requires a non-empty mutations array.",u.USAGE);return t.mutations.map((n,i)=>{if(!f(n))throw new c(`Mutation ${i+1} must be an object.`,u.USAGE);return Nt(n,i)})}function Pt(e,t,n){let i=new Set(Object.values(st(t,n,Object.create(null))));for(let r of t)r.op==="create"&&typeof r.id=="string"&&r.id.trim().length>0&&i.add(O(r.id,n.idPrefix));return{...e,existing:e.existing.filter(r=>!i.has(r.id))}}function Gt(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,i]of e.entries()){if(i.op!=="create"||i.ref!==void 0||typeof i.id=="string"&&i.id.trim().length>0)continue;let r=`${Le}${n+1}`;if(t.has(r))throw new c(`Mutation ${n+1} receives the synthesized ref "${r}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${Le}<n> aliases are reserved for rows without one.`,u.USAGE);i.ref=r}}function rt(e,t,n){let i=Qt(JSON.stringify(e),t,{},n);return delete i.stdinJson,delete i.documentAnnotationSnapshot,i}function ot(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>E(n))}function xt(e,t){for(let n of e)f(n.item)&&(n.options=rt(n.item,"create",t),delete n.item)}function at(e,t){return t.some(n=>n.metadata_key===e)?e:R(e)}function B(e,t,n){let i=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(f(e.item)){if(e.item[t]!==void 0)return e.item[t];if(at(i,n)===t&&e.item[i]!==void 0)return e.item[i]}let r=f(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&r[E(o)]!==void 0?r[E(o)]:r[t]!==void 0?r[t]:r[i]!==void 0?r[i]:(Array.isArray(r.field)?r.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function qt(e,t){return e<t?-1:+(e!==t)}function Y(e){return Array.isArray(e)?e.map(Y):f(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>qt(t,n)).map(([t,n])=>[t,Y(n)])):e}function g(e){return typeof e=="string"?e.trim():JSON.stringify(Y(e))}function Kt(e,t,n,i,r){let o=t.key.trim();if(o.length===0)throw new c("Upsert key must be a non-empty field name.",u.USAGE);let a=Lt(t.existing),s=new Map,d=new Set;for(let[p,l]of e.entries()){if(l.op!=="create")continue;let y=Jt(l,o,p,s,i),w=zt(a.get(y)??[],o,y);if(w===void 0){l.unique={key:o,value:B(l,o,i)};continue}let h=O(w,n);typeof l.ref=="string"&&(r[l.ref]=h),Vt(l,h,i,{key:o,value:B(l,o,i)}),d.add(p)}return d}function Lt(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let i=g(n.value);t.set(i,[...t.get(i)??[],n.id])}return t}function Jt(e,t,n,i,r){let o=B(e,t,r);if(o==null||o==="")throw new c(`Mutation ${n+1} is missing the upsert key "${t}".`,u.USAGE,{code:"upsert_key_missing",required:`Every create record must carry a non-empty "${t}" value when --upsert-key ${t} is set.`,why:"Keyed upsert identifies existing items by that field; a record without it cannot be matched or safely created."});let a=g(o),s=i.get(a);if(s!==void 0)throw new c(`Mutations ${s+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${t}".`,u.USAGE,{code:"upsert_key_duplicate",required:"Each record must carry a distinct upsert key value within one batch.",why:"Two records with the same key would race for the same existing item."});return i.set(a,n),a}function zt(e,t,n){if(e.length>1)throw new c(`Upsert key "${t}" value ${JSON.stringify(n)} matches ${e.length} existing items: ${e.join(", ")}.`,u.CONFLICT,{code:"upsert_key_ambiguous",required:"Resolve the duplicate existing items or choose a key that is unique per item.",why:"An ambiguous key cannot select one item to update without guessing."});return e[0]}function Vt(e,t,n,i){let r=new Set([...tt.update,...ot("update",n)]),o=f(e.item)?rt(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>r.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=i}function st(e,t,n){for(let[i,r]of e.entries())if(r.ref!==void 0){if(r.op!=="create")throw new c(`Mutation ${i+1} ref is only valid for create operations.`,u.USAGE);if(typeof r.ref!="string"||!ze.test(r.ref))throw new c(`Mutation ${i+1} ref must match ${ze.source}.`,u.USAGE);if(n[r.ref]!==void 0)throw new c(`Duplicate mutation ref "${r.ref}".`,u.USAGE);n[r.ref]=typeof r.id=="string"&&r.id.trim().length>0?O(r.id,t.idPrefix):Ot(t.transactionId,r.ref,t.idPrefix)}return n}function ct(e,t){let n=Ft(e);Gt(n);let i=n.map(l=>typeof l.ref=="string"?l.ref:void 0),r=Object.create(null),o=t.upsert===void 0?new Set:Kt(n,Pt(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],r);xt(n,t.runtimeFields??[]),st(n,t,r),kt(n,i);let a=n.map(l=>{let y={...l},w=typeof y.ref=="string"?y.ref:void 0;if(delete y.ref,w!==void 0?y.id=r[w]:y.id=Be(y.id,r),f(y.options)){let h={...y.options};for(let _ of["parent","blockedBy"])h[_]!==void 0&&(h[_]=Be(h[_],r));Array.isArray(h.dep)?h.dep=h.dep.map(_=>Ye(_,r)):h.dep!==void 0&&(h.dep=Ye(h.dep,r)),y.options=h}return y}),s=it(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),d=s.filter(l=>l.op==="create").map(l=>l.id);if(new Set(d).size!==d.length)throw new c("Duplicate resolved create id in mutation document.",u.USAGE);let p=s.map((l,y)=>{let w=i[y];return{index:y,...typeof w=="string"?{ref:w}:{},id:l.id,op:l.op,...o.has(y)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:r,rows:p}}function Wt(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let i=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(i)?JSON.stringify(i):i}`}).join(",")}function Bt(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(f))throw new c(`${n} must be an array of objects.`,u.USAGE);return e.map(i=>Wt(i,t))}}function Yt(e,t){return e==="tags"&&Array.isArray(t)&&t.every(n=>typeof n=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function He(e,t,n=!1){for(let[i,r,o]of De){let a=t[i],s=Bt(n&&["comments","notes","learnings"].includes(i)&&Array.isArray(a)?a.filter(d=>!f(d)||d.created_at===void 0):a,o,i);s!==void 0&&s.length>0&&(e[r]=s)}}function Ht(e,t){for(let n of Object.keys(e)){if(t){if(!$.includes(n))throw b("item envelope",n,$);continue}if(!S.has(n)&&U(n,[...S])===void 0&&U(n,$)==="item")throw b("item envelope",n,$)}}function Xt(e){let t=Object.hasOwn(e,"item");Ht(e,t);let n=t?e.item:e;if(!f(n))throw new c("Item document item must be an object.",u.USAGE);return{item:n,...t&&f(e.linked)?{linked:e.linked}:{}}}function Zt(e,t,n,i,r,o){if((i==="update"?Tt:et).has(t))return;let a=r.find(s=>s.metadata_key===t&&s.commands.includes(i));if(a!==void 0){let s=Ee(o,a);e[E(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!S.has(t)){if(U(t,[...S])!==void 0)throw b("item document",t,[...S]);let s=Array.isArray(e.field)?e.field:[];s.push(`${t}=${typeof n=="string"?n:JSON.stringify(n)}`),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(s,d)=>d.toUpperCase())]=Yt(t,n))}function Qt(e,t,n={},i=[]){let r=H(e,"Item document");if(!f(r))throw new c("Item document must be a JSON object.",u.USAGE);let{item:o,linked:a}=Xt(r),s={};for(let[d,p]of Object.entries(o)){let l=at(d,i);l!==d&&Object.hasOwn(o,l)||Zt(s,l,p,t,i,n)}if(He(s,o,t==="update"),a!==void 0&&He(s,a),t==="update"){let d=Object.fromEntries(["comments","notes","learnings"].filter(p=>Object.hasOwn(o,p)).map(p=>[p,o[p].filter(l=>f(l)&&l.created_at!==void 0)]));Object.keys(d).length>0&&(s.documentAnnotationSnapshot=d)}return{...s,...Object.fromEntries(Object.entries(n).filter(([,d])=>d!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0}}function _i(e){return it(JSON.stringify(e))}import ee from"node:crypto";import{constants as X}from"node:fs";import{cp as en,lstat as ut,mkdir as tn,mkdtemp as pt,open as nn,readdir as rn,realpath as lt,rm as mt,stat as te,writeFile as ft}from"node:fs/promises";import{tmpdir as yt}from"node:os";import m from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="03112259-10b6-53a9-8e6b-e541ac8c7d5d")}catch{}})();async function ne(e,t){if(!Te(e))return{schema:K(t.schema),typeDefinitionsFromFile:[]};let n=await mn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function ie(e,t,n,i){let r=x({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},q());return(await Me(e,t.item_format,r.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[i];return a==null?[]:[{id:o.id,value:a}]})}function ht(e){let t=new Map,n=async i=>{let r=await M(e),o=await ne(e,r),a=new Map;for(let s of await ie(e,r,o,i)){let d=g(s.value);a.set(d,[...a.get(d)??[],s.id])}return a};return{lookup(i){let r=t.get(i)??n(i);return t.set(i,r),r},async recordCreate(i){for(let[r,o]of t){let a=i[r];if(a==null)continue;let s=await o,d=g(a);s.set(d,[...s.get(d)??[],String(i.id)])}},invalidate(){t.clear()}}}async function on(e,t){let n=g(t.value),i=(await e.lookup(t.key)).get(n)??[];if(i.length!==0)throw new c(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${i.join(", ")}; the plan was resolved before it existed.`,u.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function an(e,t,n){let i=e.metadata[n.key],r=g(n.value);if(g(i)!==r)throw new c(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(r)}; the plan selected it before the key changed.`,u.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function dt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function j(e,t){let n={...e,...t};return e===void 0?n:Ue(e,n)}async function v(e,t){try{let n=(await z(t,{},{pmRoot:e})).item;return{id:n.id,closedAt:n.closed_at,updatedAt:n.updated_at,assignee:n.assignee,claimPrincipal:n.claim_principal}}catch(n){if(n instanceof c&&n.exitCode===u.NOT_FOUND)return;throw n}}function re(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),i=ee.createHash("sha256").update(le(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${i}`}function sn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function T(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}async function F(e,t,n,i){let r=await L(m.join(e,"history",`${t}.jsonl`),t),o=T(n,i,"apply"),a=T(n,i,"compensate");for(let s=r.length-1;s>=0;s-=1){let d=r[s].message;if(d===o)return!0;if(d===a)return!1}return!1}async function oe(e,t){let n=await v(e,t.id);if(n?.updatedAt===void 0)throw new c(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,u.NOT_FOUND);return{target_updated_at:n.updatedAt}}async function P(e,t,n,i){let r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i.target_updated_at:void 0;typeof r=="string"&&await v(e.pmRoot,t)!==void 0&&await xe(t,r,{force:!0,author:e.author,message:T(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot})}function wt(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);if(i===void 0)return{state:"pending"};if(i.closedAt!==void 0){let r=await L(m.join(e.pmRoot,"history",`${i.id}.jsonl`),i.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(r.filter(a=>a.op==="close").at(-1)?.patch.some(a=>a.op==="add"||a.op==="replace"?a.path==="/metadata/close_reason"&&a.value===o:!1)??!1)throw new c(`Created item ${i.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,u.CONFLICT,{code:"transaction_create_compensated",item_id:i.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${i.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:i.id,op:"create"}}},async apply(){t.unique!==void 0&&await on(e.uniqueIndex,t.unique);let i=(await je(j(t.options,{author:e.author,id:t.id}),{pmRoot:e.pmRoot})).item;return await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){let i=await v(e.pmRoot,t.id);if(i!==void 0){if(e.createCompensation==="delete"){await Ge(t.id,{force:!0,author:e.author,message:`Compensate interrupted bulk transaction ${e.transactionId}`},{pmRoot:e.pmRoot});return}i.closedAt===void 0&&await V(t.id,`Compensated: interrupted bulk transaction ${e.transactionId}`,{force:!0,author:e.author},{pmRoot:e.pmRoot})}}}}function cn(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);return i===void 0?{state:"pending"}:await F(e.pmRoot,i.id,e.transactionId,n)?{state:"applied",result:{id:i.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return oe(e.pmRoot,t)},async apply(){let i=()=>Fe(t.id,j(t.options,{author:e.author,message:T(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),r=t.match,o=(r===void 0?await i():await Ie({pmRoot:e.pmRoot,id:String((await z(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:a=>an(a,t.id,r)},i)).item;return e.uniqueIndex.invalidate(),{id:String(o.id),op:"update"}},async compensate(i){await P(e,t.id,n,i)}}}function dn(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);return i===void 0?{state:"pending"}:await F(e.pmRoot,i.id,e.transactionId,n)?{state:"applied",result:{id:i.id,op:"close"}}:i.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:i.id,op:"close"}}},async prepareCompensation(){return oe(e.pmRoot,t)},async apply(){let i=(await V(t.id,t.reason,j(t.options,{author:e.author,message:T(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"close"}},async compensate(i){await P(e,t.id,n,i)}}}function un(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);return i===void 0?{state:"pending"}:await F(e.pmRoot,i.id,e.transactionId,n)?{state:"applied",result:{id:i.id,op:"release"}}:i.assignee!==void 0||i.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:i.id,op:"release"}}},async prepareCompensation(){return oe(e.pmRoot,t)},async apply(){let i=(await Pe(t.id,j(t.options,{author:e.author,message:T(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"release"}},async compensate(i){await P(e,t.id,n,i)}}}function gt(e,t,n){let i=re(t,n);switch(t.op){case"create":return wt(e,t,i);case"update":return cn(e,t,i);case"close":return dn(e,t,i);case"release":return un(e,t,i)}}function pn(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(e.op==="create"&&e.unique!==void 0&&!dt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!dt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);k(e.options,e.op,t)}function vt(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,i]of e.entries()){if(pn(i,n),i.op!=="create"||i.unique===void 0)continue;let{key:r,value:o}=i.unique,a=t.get(r)??new Map,s=g(o),d=a.get(s);if(d!==void 0)throw new c(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${r}".`,u.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});a.set(s,n),t.set(r,a)}}async function Z(e,t,n){try{return await n()}catch(i){throw i instanceof c?new c(i.message,i.exitCode,{...i.context,transaction_operation:{index:t,op:e.op,id:e.id}}):i}}function _t(e,t,n,i){let r=m.relative(e,t);return["locks","runtime","search"].includes(r.split(m.sep)[0])?i.some(o=>r===o||r.startsWith(`${o}${m.sep}`)||o.startsWith(`${r}${m.sep}`)):r===""||n===void 0||n.some(o=>r===o||r.startsWith(`${o}${m.sep}`)||o.startsWith(`${r}${m.sep}`))}async function N(e){let t=await ut(e);if(t.isSymbolicLink())await te(e);else if(t.isDirectory()||t.isFile())return t;throw I()}async function ln(e){let t=await nn(e,X.O_RDONLY|X.O_NOFOLLOW|X.O_NONBLOCK);try{let n=await t.stat();if(!n.isFile())throw I();let i=ee.createHash("sha256");if(n.size>0)for await(let r of t.createReadStream({highWaterMark:64*1024,end:n.size-1,autoClose:!1}))i.update(r);return i.digest()}finally{await t.close()}}async function Q(e,t,n){let i=ee.createHash("sha256");async function r(o){for(let a of(await rn(o)).sort()){let s=m.join(o,a);_t(e,s,t,n)&&((await N(s)).isDirectory()?await r(s):(i.update(JSON.stringify(m.relative(e,s))),i.update(await ln(s))))}}return await r(e),i.digest("hex")}function C(){return new c("Tracker changed while preparing the transaction preview; retry against stable state.",u.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function ae(e){if(!G(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=m.resolve(t),i=n;for(;;)try{let r=await ut(i);return i!==n&&r.isDirectory()}catch(r){if(!G(r))return!1;let o=m.dirname(i);if(o===i)return!1;i=o}}async function D(e,t){let n=m.join(e,t);try{let i=e;for(let r of t.split(m.sep).slice(0,-1))i=m.join(i,r),await N(i);if(!(await N(n)).isFile())throw I();return await ue(n,I())}catch(i){if(await ae(i))return;throw i}}async function Et(e,t,n,i){let r=K(n);for(let[o,a]of Object.entries(r.files)){let s=m.relative(e,ge(e,a,we[o]));if(s===""||!m.resolve(e,s).startsWith(m.join(e,m.sep)))throw new c("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",u.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${o}`});r.files[o]=s;let d=await D(e,s);if(i?.set(s,d),d!==void 0){let p=m.join(t,s);await tn(m.dirname(p),{recursive:!0}),await ft(p,d)}}return ve(t,r)}async function mn(e,t){await te(e);let n=await pt(m.join(yt(),"pm-schema-plan-"));try{let i=await lt(e);return await Et(i,m.join(n,"configuration"),t)}catch(i){throw await ae(i)?C():i}finally{await mt(n,{recursive:!0,force:!0})}}async function fn(e,t,n){let i=new Map,r=await D(e,A);i.set(A,r);let o;try{o=JSON.parse(r??"null")}catch{o=null}let a=be(o),s=a.success?a.data:void 0,d=await Et(e,t,s?.schema,i),p=d.schema,l=m.relative(e,Se(e));i.set(l,await D(e,l));let y=x({...de,item_types:{definitions:[...s?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),w=pe(e)===e?[...ce.filter(Boolean),A,ye,"transactions",...y.folders,...i.keys()].map(_=>m.normalize(_)):void 0,h=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:p.files}});return{configuration:i,ownedPaths:w,stagedSettings:h,registryFolders:y.folders}}async function yn(e,t,n){await te(e);try{let i=await lt(e),r=await fn(i,m.join(m.dirname(t),"configuration"),n),o=[...r.configuration.keys(),...r.registryFolders].map(p=>m.normalize(p)),a=await Q(i,r.ownedPaths,o);await en(i,t,{recursive:!0,dereference:!1,filter:async p=>_t(i,p,r.ownedPaths,o)?(await N(p),!0):!1});let[s,d]=await Promise.all([Q(i,r.ownedPaths,o),Q(t,r.ownedPaths,o)]);if(a!==s||a!==d)throw C();for(let[p,l]of r.configuration)if(await D(t,p)!==l)throw C();r.stagedSettings!==void 0&&await ft(m.join(t,A),r.stagedSettings)}catch(i){throw await ae(i)?C():i}}async function Wi(e){let t=Oe(e),n=[...e.mutations];vt(n);let i=q(),r=await pt(m.join(yt(),"pm-transaction-preview-")),o=m.join(r,"tracker");try{await yn(t.pmRoot,o,i);let a=!1;return await qe({path:o,noExtensions:!0},async()=>{fe(i);let s={...t,pmRoot:o,createCompensation:"close",uniqueIndex:ht(o)},d=n.map((p,l)=>{let y=gt(s,p,l);return{...y,inspect:()=>Z(p,l,()=>y.inspect()),prepareCompensation:()=>Z(p,l,async()=>y.prepareCompensation?.()),apply:()=>Z(p,l,()=>y.apply())}});await J({...t,pmRoot:o,steps:d,onTransition:({transition:p})=>{p==="committed"&&(a=!0)}})}),{validated:a,state:a?"staged_snapshot":"replayed_committed_plan",unresolved_commit_constraints:["concurrent_tracker_changes","extension_mutation_guards_and_hooks"]}}finally{await mt(r,{recursive:!0,force:!0})}}async function hn(e){let t=[...e.mutations];vt(t);let n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={pmRoot:e.pmRoot,author:e.author,transactionId:e.transactionId,createCompensation:n,uniqueIndex:ht(e.pmRoot)},r=await J({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,steps:t.map((a,s)=>gt(i,a,s)),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[a,s]of t.entries()){let d=re(s,a),p=r.results[d];o[sn(s,a)]=p}return{transactionId:r.transactionId,status:"committed",recovered:r.recovered,results:o}}function wn(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function Bi(e){return hn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:wn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Yi={buildCreateStep:wt,bulkHistoryMarker:T,compensateByRestore:P,deriveStepId:re,isUpdateMarkerApplied:F,readItemSnapshot:v};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3c45eeb2-58f2-58f9-ad24-e439967b99ef")}catch{}})();async function rr(e){let t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new c("Upsert key must be a non-empty field name.",u.USAGE);let n=e.settings??await M(e.pmRoot),i=e.transactionId?.trim()??"",r=i.length>0?i:nt(e.input),o=await ne(e.pmRoot,n),a=_e(o.schema).definitions,s=(a.find(p=>p.metadata_key===t)??a.find(p=>p.key===t||E(p)===t))?.metadata_key??R(t),d=s===void 0?void 0:{key:s,existing:await ie(e.pmRoot,n,o,s)};return{...ct(e.input,{transactionId:r,idPrefix:n.id_prefix,runtimeFields:a,...d===void 0?{}:{upsert:d}}),transaction_id:r,transaction_id_source:i.length>0?"explicit":"derived",...d===void 0?{}:{upsert_key:d.key}}}export{nt as a,vi as b,it as c,g as d,ct as e,Qt as f,_i as g,ne as h,ie as i,mn as j,Wi as k,hn as l,wn as m,Bi as n,Yi as o,rr as p};
2
+ //# sourceMappingURL=chunk-TO6CIV4C.js.map