@unbrained/pm-cli 2026.10.30 → 2026.11.1

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 (262) hide show
  1. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/AGENTS.md +3 -3
  4. package/CHANGELOG.md +41 -0
  5. package/README.md +1 -1
  6. package/dist/cli/commander-usage.js +2 -2
  7. package/dist/cli/error-guidance.d.ts +45 -5
  8. package/dist/cli/error-guidance.js +5 -3
  9. package/dist/cli/extension-command-help.d.ts +1 -0
  10. package/dist/cli/extension-command-help.js +2 -2
  11. package/dist/cli/main.d.ts +1 -5
  12. package/dist/cli/main.js +5 -5
  13. package/dist/cli/migration-gates.d.ts +1 -1
  14. package/dist/cli/migration-gates.js +1 -1
  15. package/dist/cli/preflight-warnings.d.ts +11 -0
  16. package/dist/cli/preflight-warnings.js +4 -0
  17. package/dist/cli/register-mutation.js +2 -2
  18. package/dist/cli/register-operations.d.ts +3 -3
  19. package/dist/cli/register-operations.js +1 -1
  20. package/dist/cli-bundle/bundle-manifest.json +1 -1
  21. package/dist/cli-bundle/chunks/chunk-2GK2IVU5.js +8 -0
  22. package/dist/cli-bundle/chunks/chunk-5KW4WUAK.js +6 -0
  23. package/dist/cli-bundle/chunks/chunk-5WVE7XBS.js +114 -0
  24. package/dist/cli-bundle/chunks/chunk-6PKWKVS6.js +8 -0
  25. package/dist/cli-bundle/chunks/chunk-E74BORFX.js +128 -0
  26. package/dist/cli-bundle/chunks/chunk-F3ECOBKA.js +2 -0
  27. package/dist/cli-bundle/chunks/chunk-ICT6E4IW.js +2 -0
  28. package/dist/cli-bundle/chunks/chunk-MP2DQJH2.js +3 -0
  29. package/dist/cli-bundle/chunks/{chunk-LWW4F4G2.js → chunk-MRUA2Z43.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-UUQX3PFD.js → chunk-MTRIGD7M.js} +76 -76
  31. package/dist/cli-bundle/chunks/{chunk-S2U7ECUJ.js → chunk-N45IXPCA.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-MVL27TAH.js → chunk-NILQ2ZMV.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-GRABKNFL.js → chunk-O56O7NIE.js} +2 -2
  34. package/dist/cli-bundle/chunks/chunk-O6TFUV6M.js +31 -0
  35. package/dist/cli-bundle/chunks/{chunk-TH5KPAN4.js → chunk-SBVX5CMV.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-Y6NC3X3E.js → chunk-TMPO4CTZ.js} +3 -3
  37. package/dist/cli-bundle/chunks/chunk-TYERATXH.js +2 -0
  38. package/dist/cli-bundle/chunks/{chunk-EHBGHX55.js → chunk-UEEG47TU.js} +2 -2
  39. package/dist/cli-bundle/chunks/chunk-UUN3WNMQ.js +20 -0
  40. package/dist/cli-bundle/chunks/chunk-WFBYKDB2.js +2 -0
  41. package/dist/cli-bundle/chunks/{chunk-RZQNFHXO.js → chunk-WX25MU4N.js} +3 -3
  42. package/dist/cli-bundle/chunks/{chunk-4BQD5SW2.js → chunk-Y7CKVU56.js} +30 -30
  43. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-LHLE7PSG.js → indexed-receipt-blobs-KGMJVFH2.js} +2 -2
  44. package/dist/cli-bundle/chunks/item-transaction-Q5S5YLEJ.js +2 -0
  45. package/dist/cli-bundle/chunks/{mutation-admission-TRGAVS7N.js → mutation-admission-BOOCJPCU.js} +2 -2
  46. package/dist/cli-bundle/chunks/{register-list-query-BH4F6M7Z.js → register-list-query-23OX36Q3.js} +3 -3
  47. package/dist/cli-bundle/chunks/register-mutation-JPJ5YNDX.js +20 -0
  48. package/dist/cli-bundle/chunks/register-operations-IGR7ERY5.js +2 -0
  49. package/dist/cli-bundle/chunks/{register-setup-QPWSVHFZ.js → register-setup-BMIFKZZP.js} +2 -2
  50. package/dist/cli-bundle/chunks/{settlement-hook-MN3Y7LVX.js → settlement-hook-YWSWFOZY.js} +2 -2
  51. package/dist/cli-bundle/chunks/{stage-RTB6RAAO.js → stage-ON7CYYPM.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-POJPJX64.js → chunk-2Y77HWIX.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-SAT7IAEB.js → chunk-3NYWMUX3.js} +3 -3
  54. package/dist/cli-bundle/focused-chunks/chunk-3Z53POXU.js +2 -0
  55. package/dist/cli-bundle/focused-chunks/chunk-5TWS5KOM.js +26 -0
  56. package/dist/cli-bundle/focused-chunks/chunk-5WCQFH6D.js +12 -0
  57. package/dist/cli-bundle/focused-chunks/{chunk-S23ZUASN.js → chunk-6GMYW42K.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-YQUZL2CK.js → chunk-6OKPYCLU.js} +5 -5
  59. package/dist/cli-bundle/focused-chunks/chunk-7WJDRZOR.js +22 -0
  60. package/dist/cli-bundle/focused-chunks/{chunk-3SRX77ES.js → chunk-AL7SOFUL.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/chunk-CIQ6YWCW.js +26 -0
  62. package/dist/cli-bundle/focused-chunks/{chunk-RKPUQDWF.js → chunk-DFUTCKUF.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-RYEZSZJ7.js → chunk-GE755ODZ.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/chunk-JCR32IAO.js +91 -0
  65. package/dist/cli-bundle/focused-chunks/{chunk-BPE6JTKL.js → chunk-JLXGRDTG.js} +3 -3
  66. package/dist/cli-bundle/focused-chunks/chunk-LVA76N27.js +6 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-YU7QOYYV.js → chunk-M22TI7LP.js} +3 -3
  68. package/dist/cli-bundle/focused-chunks/chunk-PAT6QF63.js +2 -0
  69. package/dist/cli-bundle/focused-chunks/{chunk-VFWCSQAG.js → chunk-RPUDOJVB.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/chunk-SXZM4PSS.js +44 -0
  71. package/dist/cli-bundle/focused-chunks/chunk-UQIBGLDR.js +2 -0
  72. package/dist/cli-bundle/focused-chunks/{chunk-RGQEJFXO.js → chunk-VFQAZLKO.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{chunk-BCIUAEWX.js → chunk-VS2ZFPXD.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/{chunk-FRFNGMAK.js → chunk-WX2RVS2Y.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/chunk-Z7GIVH6B.js +3 -0
  76. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-VK2363JB.js → indexed-receipt-blobs-KHWT44EK.js} +2 -2
  77. package/dist/cli-bundle/focused-chunks/item-transaction-7VLPA2SU.js +2 -0
  78. package/dist/cli-bundle/focused-chunks/{mutation-admission-7VUODEPJ.js → mutation-admission-2DH27R5Y.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/{settlement-hook-OK6A7PG2.js → settlement-hook-SJV52ZTV.js} +2 -2
  80. package/dist/cli-bundle/focused-chunks/{stage-S5RP5SZH.js → stage-FYOBWQA7.js} +2 -2
  81. package/dist/cli-bundle/main.js +26 -22
  82. package/dist/cli-bundle/sdk-authoring.js +1 -1
  83. package/dist/cli-bundle/sdk-contracts.js +4 -4
  84. package/dist/cli-bundle/sdk-core.js +1 -1
  85. package/dist/cli-bundle/sdk-governance.js +1 -1
  86. package/dist/cli-bundle/sdk-graph.js +1 -1
  87. package/dist/cli-bundle/sdk-merge.js +57 -57
  88. package/dist/cli-bundle/sdk-query.js +1 -1
  89. package/dist/cli-bundle/sdk-runtime.js +1 -1
  90. package/dist/cli-bundle/sdk-testing.js +1 -1
  91. package/dist/cli-bundle/sdk.js +11 -11
  92. package/dist/core/config/nested-settings.js +1 -1
  93. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  94. package/dist/core/extensions/extension-types.d.ts +4 -0
  95. package/dist/core/extensions/extension-types.js +1 -1
  96. package/dist/core/extensions/loader.js +1 -1
  97. package/dist/core/lock/lock.js +4 -4
  98. package/dist/core/output/mutation-projection.js +1 -1
  99. package/dist/core/output/output.js +3 -3
  100. package/dist/core/schema/fields-file.js +1 -1
  101. package/dist/core/sentry/helpers.d.ts +6 -0
  102. package/dist/core/sentry/helpers.js +1 -1
  103. package/dist/core/sentry/instrument.d.ts +1 -1
  104. package/dist/core/sentry/instrument.js +1 -1
  105. package/dist/core/shared/constants.js +1 -1
  106. package/dist/core/shared/errors.d.ts +6 -0
  107. package/dist/core/shared/errors.js +1 -1
  108. package/dist/core/shared/output-unicode.d.ts +10 -0
  109. package/dist/core/shared/output-unicode.js +2 -0
  110. package/dist/core/store/settings-validator.d.ts +1 -0
  111. package/dist/core/store/settings-validator.js +1 -1
  112. package/dist/core/store/settings.js +1 -1
  113. package/dist/core/telemetry/policy.d.ts +8 -0
  114. package/dist/core/telemetry/policy.js +1 -1
  115. package/dist/core/telemetry/runtime.js +3 -3
  116. package/dist/sdk/agent/command-recovery.d.ts +15 -0
  117. package/dist/sdk/agent/command-recovery.js +1 -1
  118. package/dist/sdk/cli-bootstrap.js +1 -1
  119. package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +28 -0
  120. package/dist/sdk/cli-contracts/agent-output-contracts.js +2 -2
  121. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  122. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  123. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  124. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  125. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  126. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  127. package/dist/sdk/cli-contracts.d.ts +1 -1
  128. package/dist/sdk/cli-contracts.js +1 -1
  129. package/dist/sdk/completion/fish.js +4 -4
  130. package/dist/sdk/completion/zsh.js +3 -3
  131. package/dist/sdk/config.d.ts +1 -0
  132. package/dist/sdk/config.js +1 -1
  133. package/dist/sdk/context-intent-contracts.d.ts +17 -0
  134. package/dist/sdk/context-intent-contracts.js +1 -1
  135. package/dist/sdk/core.d.ts +2 -1
  136. package/dist/sdk/core.js +1 -1
  137. package/dist/sdk/error-runtime.d.ts +9 -0
  138. package/dist/sdk/error-runtime.js +1 -1
  139. package/dist/sdk/errors.js +1 -1
  140. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  141. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  142. package/dist/sdk/index.d.ts +3 -3
  143. package/dist/sdk/index.js +1 -1
  144. package/dist/sdk/init-agent-guidance.js +2 -2
  145. package/dist/sdk/lifecycle/claim.d.ts +27 -0
  146. package/dist/sdk/lifecycle/claim.js +1 -1
  147. package/dist/sdk/lifecycle/close.js +1 -1
  148. package/dist/sdk/lifecycle/create.js +1 -1
  149. package/dist/sdk/lifecycle/mcp-actions.d.ts +1 -1
  150. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  151. package/dist/sdk/lifecycle/plan.d.ts +2 -3
  152. package/dist/sdk/lifecycle/plan.js +1 -1
  153. package/dist/sdk/lifecycle/repeated-terminal-state.d.ts +45 -0
  154. package/dist/sdk/lifecycle/repeated-terminal-state.js +2 -0
  155. package/dist/sdk/lifecycle/shared-unset-fields.d.ts +9 -0
  156. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  157. package/dist/sdk/lifecycle/task-composition.js +1 -1
  158. package/dist/sdk/lifecycle/update-many.d.ts +0 -1
  159. package/dist/sdk/lifecycle/update-many.js +1 -1
  160. package/dist/sdk/lifecycle/update.d.ts +29 -1
  161. package/dist/sdk/lifecycle/update.js +2 -2
  162. package/dist/sdk/output/list-envelope.d.ts +8 -0
  163. package/dist/sdk/output/list-envelope.js +1 -1
  164. package/dist/sdk/output/table-rows.d.ts +7 -1
  165. package/dist/sdk/output/table-rows.js +1 -1
  166. package/dist/sdk/output.d.ts +2 -1
  167. package/dist/sdk/output.js +2 -2
  168. package/dist/sdk/ownership-source.d.ts +18 -0
  169. package/dist/sdk/ownership-source.js +1 -1
  170. package/dist/sdk/public-surface.json +1 -1
  171. package/dist/sdk/query/context.js +2 -2
  172. package/dist/sdk/query/get.d.ts +1 -1
  173. package/dist/sdk/query/get.js +1 -1
  174. package/dist/sdk/query/next-ranking-policy.d.ts +35 -0
  175. package/dist/sdk/query/next-ranking-policy.js +2 -0
  176. package/dist/sdk/query/next.d.ts +12 -2
  177. package/dist/sdk/query/next.js +2 -2
  178. package/dist/sdk/query/projection-contracts.d.ts +4 -0
  179. package/dist/sdk/query/projection-contracts.js +1 -1
  180. package/dist/sdk/read-output/surfaces.d.ts +27 -0
  181. package/dist/sdk/read-output/surfaces.js +2 -0
  182. package/dist/sdk/read-output-contracts.js +1 -1
  183. package/dist/sdk/runtime/actions.js +1 -1
  184. package/dist/sdk/runtime-input.js +1 -1
  185. package/dist/sdk/runtime-primitives.d.ts +1 -0
  186. package/dist/sdk/runtime-primitives.js +1 -1
  187. package/dist/sdk/runtime-public-contracts.d.ts +2 -0
  188. package/dist/sdk/runtime.d.ts +2 -2
  189. package/dist/sdk/runtime.js +1 -1
  190. package/dist/sdk/start-task-status.d.ts +1 -1
  191. package/dist/sdk/start-task-status.js +1 -1
  192. package/dist/sdk/test/execution-receipts.d.ts +25 -0
  193. package/dist/sdk/test/execution-receipts.js +2 -2
  194. package/dist/sdk/test/execution.d.ts +5 -0
  195. package/dist/sdk/test/execution.js +2 -2
  196. package/dist/types.d.ts +2 -0
  197. package/dist/types.js +1 -1
  198. package/docs/AGENT_GUIDE.md +4 -4
  199. package/docs/AGENT_OUTPUT_ENCODINGS.md +12 -0
  200. package/docs/AGENT_UX_CONTRACTS.md +2 -1
  201. package/docs/COMMANDS.md +59 -5
  202. package/docs/COMMAND_NAMESPACES.md +1 -1
  203. package/docs/CONFIGURATION.md +48 -1
  204. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +26 -0
  205. package/docs/LIFECYCLE_COMMANDS.md +19 -4
  206. package/docs/PACKED_FIRST_RUN.md +2 -1
  207. package/docs/READ_OUTPUT_CONTRACTS.md +24 -6
  208. package/docs/SDK.md +82 -3
  209. package/docs/SDK_ACTION_CONFORMANCE.md +21 -0
  210. package/docs/TESTING.md +38 -2
  211. package/docs/agent-task-token-baseline.json +1 -1
  212. package/docs/agent-task-transcripts.json +1 -1
  213. package/marketplace.json +1 -1
  214. package/package.json +1 -1
  215. package/packages/pm-beads/package.json +1 -1
  216. package/packages/pm-calendar/extensions/calendar/index.ts +1 -0
  217. package/packages/pm-calendar/package.json +1 -1
  218. package/packages/pm-command-kit/package.json +1 -1
  219. package/packages/pm-digital-twin/package.json +1 -1
  220. package/packages/pm-governance-audit/package.json +1 -1
  221. package/packages/pm-guide-shell/package.json +1 -1
  222. package/packages/pm-kanban/package.json +1 -1
  223. package/packages/pm-lifecycle-hooks/package.json +1 -1
  224. package/packages/pm-linked-test-adapters/package.json +1 -1
  225. package/packages/pm-search-advanced/package.json +1 -1
  226. package/packages/pm-templates/package.json +1 -1
  227. package/packages/pm-todos/package.json +1 -1
  228. package/packages/pm-vcs/package.json +1 -1
  229. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  230. package/plugins/pm-claude/package.json +1 -1
  231. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  232. package/plugins/pm-codex/package.json +1 -1
  233. package/plugins/pm-codex/plugin.json +1 -1
  234. package/runtime-dependencies.json +1 -1
  235. package/dist/cli-bundle/chunks/chunk-34MP7WKK.js +0 -6
  236. package/dist/cli-bundle/chunks/chunk-3KMYHYJV.js +0 -2
  237. package/dist/cli-bundle/chunks/chunk-42BHHNTL.js +0 -128
  238. package/dist/cli-bundle/chunks/chunk-I5O3XZOA.js +0 -2
  239. package/dist/cli-bundle/chunks/chunk-LEIVUGDH.js +0 -8
  240. package/dist/cli-bundle/chunks/chunk-OH7WPD42.js +0 -114
  241. package/dist/cli-bundle/chunks/chunk-OOD2A7AF.js +0 -20
  242. package/dist/cli-bundle/chunks/chunk-Q5V7P6NM.js +0 -2
  243. package/dist/cli-bundle/chunks/chunk-QLPFYBXN.js +0 -2
  244. package/dist/cli-bundle/chunks/chunk-SA5NYLPE.js +0 -8
  245. package/dist/cli-bundle/chunks/chunk-VHLAVTJN.js +0 -31
  246. package/dist/cli-bundle/chunks/chunk-XAOVJG52.js +0 -3
  247. package/dist/cli-bundle/chunks/chunk-XPQ4RTSF.js +0 -2
  248. package/dist/cli-bundle/chunks/item-transaction-WIOBZW4E.js +0 -2
  249. package/dist/cli-bundle/chunks/register-mutation-5V2NANIS.js +0 -20
  250. package/dist/cli-bundle/chunks/register-operations-XSFRMUFX.js +0 -2
  251. package/dist/cli-bundle/focused-chunks/chunk-2V6NMNYN.js +0 -26
  252. package/dist/cli-bundle/focused-chunks/chunk-ASHGXMX4.js +0 -3
  253. package/dist/cli-bundle/focused-chunks/chunk-CKBN2D42.js +0 -12
  254. package/dist/cli-bundle/focused-chunks/chunk-I642DXOT.js +0 -22
  255. package/dist/cli-bundle/focused-chunks/chunk-K7DKG5HM.js +0 -91
  256. package/dist/cli-bundle/focused-chunks/chunk-NMQBXU7N.js +0 -44
  257. package/dist/cli-bundle/focused-chunks/chunk-PGM3ENGZ.js +0 -2
  258. package/dist/cli-bundle/focused-chunks/chunk-QFNV4JTA.js +0 -6
  259. package/dist/cli-bundle/focused-chunks/chunk-QVJCQMZY.js +0 -26
  260. package/dist/cli-bundle/focused-chunks/chunk-R2TPPPVU.js +0 -2
  261. package/dist/cli-bundle/focused-chunks/chunk-VJVJ2ZX2.js +0 -2
  262. package/dist/cli-bundle/focused-chunks/item-transaction-ZFDKJIP7.js +0 -2
@@ -1,4 +1,4 @@
1
- import{A as h,C as u,G as p}from"./chunk-RZQNFHXO.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
1
+ import{A as h,C as u,G as p}from"./chunk-WX25MU4N.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
2
2
  `)}function O(n,e,t){let i=e.replace(/[\\*?[\]#! \t]/gu,"\\$&"),o=[...new Set([e,i])].flatMap(s=>R.flatMap(c=>[`${s}/${c}`,`!${s}/${c}`])),a=[],r=!1;for(let s of n)o.some(c=>s.startsWith(c))?(r||a.push(...t),r=!0):a.push(s);return r||a.push(...t),a}function P(n){let e=[],t=-1,i=0,o=0;for(let a of n.split(`
3
3
  `)){let r=a.endsWith("\r")?a.slice(0,-1):a;r===d?(t=o,i=o+a.length+1):r===f&&t>=0&&(e.push({index:t,end:o+r.length,lines:n.slice(i,o).split(/\r?\n/u).filter(s=>s.length>0)}),t=-1),o+=a.length+1}return e}function v(n,e){let t=n.includes(`\r
4
4
  `)?`\r
@@ -6,4 +6,4 @@ import{A as h,C as u,G as p}from"./chunk-RZQNFHXO.js";import{readFile as b,realp
6
6
  `,i=G(e).split(`
7
7
  `).slice(1,-1),o=P(n),a=o.flatMap(c=>c.lines),r=[d,...O(a,e,i),f].join(t);if(o.length===0){let c=n.length===0?"":n.endsWith(`
8
8
  `)?t:`${t}${t}`;return`${n}${c}${r}${t}`}let s=n;for(let[c,g]of[...o.entries()].reverse())s=`${s.slice(0,g.index)}${c===0?r:""}${s.slice(g.end)}`;return s}async function S(n,e={}){let t=l.join(n,".gitignore"),i=E;if(e.pmRoot!==void 0){let r=I(l.relative(await m(n),await m(e.pmRoot)));if(k(r))return{path:t,changed:!1};i=r}let o="";try{o=await w(()=>b(t,"utf8"))}catch(r){if(!(r instanceof Error&&"code"in r&&p(r)))throw r}let a=v(o,i);return a===o?{path:t,changed:!1}:(await w(()=>$(t,a,"utf8")),{path:t,changed:!0})}export{d as a,f as b,R as c,k as d,G as e,S as f};
9
- //# sourceMappingURL=chunk-TH5KPAN4.js.map
9
+ //# sourceMappingURL=chunk-SBVX5CMV.js.map
@@ -1,3 +1,3 @@
1
- import{Ff as c,Gf as _,If as f,Kf as p,qf as d}from"./chunk-OH7WPD42.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="8467eccc-684d-56cc-8b18-5f2e940abb42")}catch{}})();var m="not-a-declared-intent",i="not-a-declared-field";function g(){let e={get:["pm-domain"],search:["Domain query"]},r=[...new Set(d.map(({command:o})=>o))].map(o=>{let a=d.filter(n=>n.command===o),s=a[0],u=e[s.command]??[];return{probe_id:`${s.command}-invalid-intent`,command:s.command,flag:"--for",rejected_value:m,refusal_args:[s.command,...u,"--for",m],allowed_values:a.map(({intent:n})=>n).sort(),suggested_retry_args:[s.command,...u,"--for",s.intent],error_code:"unknown_context_intent"}}),t=_(),l=Object.keys(c).map(o=>({probe_id:`${o}-invalid-field`,command:o,flag:"--fields",rejected_value:i,refusal_args:[o,"--fields",i],allowed_values:t,suggested_retry_args:[o,"--fields","id,title,status"],error_code:"unknown_field_projection"}));return[...r,...l,{probe_id:"get-invalid-field",command:"get",flag:"--fields",rejected_value:i,refusal_args:["get","pm-domain","--fields",i],allowed_values:f(),suggested_retry_args:["get","pm-domain","--fields","id,title,status"],error_code:"unknown_field_projection"},{probe_id:"list-mutually-exclusive-projection",command:"list",flag:"--projection",rejected_value:"--brief+--full",refusal_args:["list","--brief","--full"],allowed_values:[],suggested_retry_args:["list","--brief"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"get-mutually-exclusive-projection",command:"get",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["get","pm-domain","--full","--fields","id"],allowed_values:[],suggested_retry_args:["get","pm-domain","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-mutually-exclusive-projection",command:"search",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["search","Domain query","--full","--fields","id"],allowed_values:[],suggested_retry_args:["search","Domain query","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"package-upgrade-mutually-exclusive-modes",command:"package upgrade",flag:"--cli-only/--packages-only",rejected_value:"--cli-only+--packages-only",refusal_args:["package","upgrade","--cli-only","--packages-only","--dry-run"],allowed_values:[],suggested_retry_args:["package","upgrade","--packages-only","--dry-run"],error_code:"package_upgrade_modes_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-invalid-field",command:"search",flag:"--fields",rejected_value:i,refusal_args:["search","Domain query","--fields",i],allowed_values:p(),suggested_retry_args:["search","Domain query","--fields","id,title,status,score"],error_code:"unknown_field_projection"}].sort((o,a)=>o.probe_id.localeCompare(a.probe_id))}function v(e,r){let t=g().find(a=>a.command===e&&a.flag===r);if(!t)return"No stable core values are declared.";let l=t.allowed_values.filter(a=>!a.startsWith("item.")),o=r==="--fields"?" item.<field> aliases and configured runtime metadata fields are also accepted.":" Configured package and workspace intents may extend this domain.";return`Allowed core values: ${l.join("|")}.${o}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="6279da21-92a5-57fe-bc0e-15a02111ab41")}catch{}})();function y(e){return e.map((r,t)=>{if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError(`NDJSON row ${t} must be a non-null object.`);let l=JSON.stringify(r);if(l===void 0)throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);let o=JSON.parse(l);if(typeof o!="object"||o===null||Array.isArray(o))throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);return l}).join(`
2
- `)}function x(e,r){if(r.count!==e.length)throw new TypeError(`NDJSON trailer count ${r.count} does not match ${e.length} ${e.length===1?"row":"rows"}.`);for(let[t,l]of e.entries())if(typeof l=="object"&&l!==null&&!Array.isArray(l)&&Reflect.get(l,"record_type")==="pm.stream.trailer")throw new TypeError(`NDJSON row ${t} uses reserved record_type pm.stream.trailer`);return y([...e,{...r,record_type:"pm.stream.trailer"}])}export{g as a,v as b,y as c,x as d};
3
- //# sourceMappingURL=chunk-Y6NC3X3E.js.map
1
+ import{Ch as _,Eh as p,ih as d,xh as c,yh as f}from"./chunk-5WVE7XBS.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="8467eccc-684d-56cc-8b18-5f2e940abb42")}catch{}})();var m="not-a-declared-intent",i="not-a-declared-field";function g(){let e={get:["pm-domain"],search:["Domain query"]},r=[...new Set(d.map(({command:o})=>o))].map(o=>{let a=d.filter(n=>n.command===o),s=a[0],u=e[s.command]??[];return{probe_id:`${s.command}-invalid-intent`,command:s.command,flag:"--for",rejected_value:m,refusal_args:[s.command,...u,"--for",m],allowed_values:a.map(({intent:n})=>n).sort(),suggested_retry_args:[s.command,...u,"--for",s.intent],error_code:"unknown_context_intent"}}),t=f(),l=Object.keys(c).map(o=>({probe_id:`${o}-invalid-field`,command:o,flag:"--fields",rejected_value:i,refusal_args:[o,"--fields",i],allowed_values:t,suggested_retry_args:[o,"--fields","id,title,status"],error_code:"unknown_field_projection"}));return[...r,...l,{probe_id:"get-invalid-field",command:"get",flag:"--fields",rejected_value:i,refusal_args:["get","pm-domain","--fields",i],allowed_values:_(),suggested_retry_args:["get","pm-domain","--fields","id,title,status"],error_code:"unknown_field_projection"},{probe_id:"list-mutually-exclusive-projection",command:"list",flag:"--projection",rejected_value:"--brief+--full",refusal_args:["list","--brief","--full"],allowed_values:[],suggested_retry_args:["list","--brief"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"get-mutually-exclusive-projection",command:"get",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["get","pm-domain","--full","--fields","id"],allowed_values:[],suggested_retry_args:["get","pm-domain","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-mutually-exclusive-projection",command:"search",flag:"--projection",rejected_value:"--full+--fields",refusal_args:["search","Domain query","--full","--fields","id"],allowed_values:[],suggested_retry_args:["search","Domain query","--full"],error_code:"projection_options_mutually_exclusive",allowed_values_required:!1},{probe_id:"package-upgrade-mutually-exclusive-modes",command:"package upgrade",flag:"--cli-only/--packages-only",rejected_value:"--cli-only+--packages-only",refusal_args:["package","upgrade","--cli-only","--packages-only","--dry-run"],allowed_values:[],suggested_retry_args:["package","upgrade","--packages-only","--dry-run"],error_code:"package_upgrade_modes_mutually_exclusive",allowed_values_required:!1},{probe_id:"search-invalid-field",command:"search",flag:"--fields",rejected_value:i,refusal_args:["search","Domain query","--fields",i],allowed_values:p(),suggested_retry_args:["search","Domain query","--fields","id,title,status,score"],error_code:"unknown_field_projection"}].sort((o,a)=>o.probe_id.localeCompare(a.probe_id))}function v(e,r){let t=g().find(a=>a.command===e&&a.flag===r);if(!t)return"No stable core values are declared.";let l=t.allowed_values.filter(a=>!a.startsWith("item.")),o=r==="--fields"?" item.<field> aliases and configured runtime metadata fields are also accepted.":" Configured package and workspace intents may extend this domain.";return`Allowed core values: ${l.join("|")}.${o}`}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="9febe44f-931d-5442-95e6-2793cb571972")}catch{}})();function y(e){return e.map((r,t)=>{if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError(`NDJSON row ${t} must be a non-null object.`);let l=JSON.stringify(r);if(l===void 0)throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);let o=JSON.parse(l);if(typeof o!="object"||o===null||Array.isArray(o))throw new TypeError(`NDJSON row ${t} must serialize to a non-null object.`);return l}).join(`
2
+ `)}function R(e,r){if(r.count!==e.length)throw new TypeError(`NDJSON trailer count ${r.count} does not match ${e.length} ${e.length===1?"row":"rows"}.`);for(let[t,l]of e.entries())if(typeof l=="object"&&l!==null&&!Array.isArray(l)&&Reflect.get(l,"record_type")==="pm.stream.trailer")throw new TypeError(`NDJSON row ${t} uses reserved record_type pm.stream.trailer`);return y([...e,{...r,record_type:"pm.stream.trailer"}])}export{g as a,v as b,y as c,R as d};
3
+ //# sourceMappingURL=chunk-TMPO4CTZ.js.map
@@ -0,0 +1,2 @@
1
+ import{$b as He,Sb as ze,Tb as Be,Vb as ne,Yb as Ve,Za as te,_b as Ye,a as xe,vc as Xe}from"./chunk-MTRIGD7M.js";import{u as We}from"./chunk-5KW4WUAK.js";import{ac as Je}from"./chunk-O6TFUV6M.js";import{b as N,c as Q,d as Ge,e as ee,f as qe}from"./chunk-Y7CKVU56.js";import{$a as C,Oa as Z,_d as Ke,ba as Ne,d as be,da as I,df as U,ee as Le,gc as Pe,gf as j,p as Ee,pb as Fe,q as Oe,r as W}from"./chunk-E74BORFX.js";import{$h as X,Ci as Ue,Ea as B,Gi as je,Ke as Ce,Md as Me,Mi as De,Na as Te,Od as Y,Pd as Re,Qb as $e,Sd as Ie,Wd as O,Wh as R,Yd as H,a as Se,jf as A,kd as ke,ld as V}from"./chunk-5WVE7XBS.js";import{A as u,C as d,G as z,I as Ae,J as k,l as ge,q as $,t as ve,y as _e}from"./chunk-WX25MU4N.js";import ue from"node:crypto";import{constants as se}from"node:fs";import{cp as mn,lstat as vt,mkdir as fn,mkdtemp as _t,open as hn,readdir as yn,realpath as St,rm as bt,stat as pe,writeFile as Et}from"node:fs/promises";import{tmpdir as Ot}from"node:os";import l from"node:path";import ct 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 b=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...ge,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function Ze(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return b.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 D(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new d(`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]="9261d364-cb6c-5442-9ad0-41d0aefa8184")}catch{}})();var re=["op","id","reason","options","unique","match"],Ct=[...re,"ref"],Qe=[...Ct,"item"],Nt="mutate-",et="row-",tt=["schema_version","mutations"],dt="[a-z][a-z0-9._-]{0,63}",nt=new RegExp(`^${dt}$`,"u"),ut=new RegExp(`(^|,)id=@(${dt})(?=,|$)`,"gu"),rt=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),F=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],pt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),Ut=new Set([...pt,"completed_at","id"]),lt={create:U.map(e=>e.target),update:j.map(e=>e.target),close:Ke.map(e=>rt(e.flag)).filter(e=>e!=="reason"),release:Le.map(e=>rt(e.flag))};function tr(e){let t=ct.createHash("sha256").update(e).digest("hex");return`${Nt}${t.slice(0,24)}`}function nr(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new d("createCompensation must be close or delete.",u.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let i=e[r];if(i===void 0)continue;let o=typeof i=="number"||typeof i=="string"&&i.trim().length>0?Number(i):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new d(`${r} must be a positive safe integer.`,u.USAGE);t[r]=o}return t}function w(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function P(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let i of t){let o=$e(e,i,n);o!==null&&(r===void 0||o<r.distance)&&(r={key:i,distance:o})}return r?.key}function E(e,t,n){let r=P(t,n);return new d(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,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:[r===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${r}".`]})}function ae(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new d(`${t} must be valid JSON: ${r}`,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 jt(e,t){if(!w(e))throw new d(`Mutation ${t+1} must be an object.`,u.USAGE);for(let n of Object.keys(e))if(!re.includes(n))throw E(`mutation ${t+1}`,n,re);return e}function Dt(e,t,n,r){if(e===void 0)return;if(!w(e))throw new d(`Mutation ${n+1} options must be an object.`,u.USAGE);let i=[...lt[t],...ht(t,r)];for(let o of Object.keys(e))if(!i.includes(o))throw E(`mutation ${n+1} ${t} options`,o,i);return D(e,t,n),e}function it(e,t,n,r){if(e===void 0)return;let i=r==="unique"?"create":"update";if(t!==i)throw new d(`Mutation ${n+1} ${r} is only valid for ${i} operations.`,u.USAGE);let o=w(e)&&typeof e.key=="string"?e.key.trim():"";if(!w(e)||o.length===0||e.value===void 0||e.value===null)throw new d(`Mutation ${n+1} ${r} must be an object with a non-empty key and a value.`,u.USAGE);return{key:o,value:e.value}}function Ft(e,t,n){let r=jt(e,t),{op:i,id:o,reason:a}=r;if(i!=="create"&&i!=="update"&&i!=="close"&&i!=="release")throw new d(`Mutation ${t+1} op must be create, update, close, or release.`,u.USAGE);let s=Dt(r.options,i,t,n),c=it(r.unique,i,t,"unique"),m=it(r.match,i,t,"match");if(typeof o!="string"||o.trim().length===0)throw new d(`Mutation ${t+1} requires a non-empty id.`,u.USAGE);let p=o.trim();if(i==="close"){if(typeof a!="string"||a.trim().length===0)throw new d(`Mutation ${t+1} close requires a non-empty reason.`,u.USAGE);return{op:i,id:p,reason:a.trim(),...s===void 0?{}:{options:s}}}if(i==="release")return{op:i,id:p,...s===void 0?{}:{options:s}};if(!w(s))throw new d(`Mutation ${t+1} ${i} requires an options object.`,u.USAGE);return{op:i,id:p,options:s,...c===void 0?{}:{unique:c},...m===void 0?{}:{match:m}}}function mt(e,t={}){let n=ae(e,"Mutation batch"),r=Array.isArray(n)?n:w(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(r===void 0||r.length===0)throw new d("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",u.USAGE);let i=t.runtimeFields??[];return r.map((o,a)=>{let s=Ft(o,a,i);return s.options!==void 0&&Ee(s.options),s})}function Pt(e,t,n){let r=ct.createHash("sha256").update(e).update("\0").update(t).digest("hex"),i=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ne(n)}${i}`}function ot(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new d(`Unknown mutation reference "${e}".`,u.USAGE);return r}function at(e,t){if(typeof e!="string")return e;let n=e.replace(ut,(r,i,o)=>{let a=t[o];if(a===void 0)throw new d(`Unknown mutation reference "@${o}".`,u.USAGE);return`${i}id=${a}`});if(/(^|,)id=@/u.test(n))throw new d(`Malformed mutation reference in dependency "${e}".`,u.USAGE);return n}function xt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(ut)].map(t=>t[1]).filter(t=>t!==void 0)}function Gt(e,t){let n=new Map;for(let[a,s]of e.entries()){let c=t[a];if(c===void 0)continue;let m=w(s.options)?s.options:{},p=Array.isArray(m.dep)?m.dep:m.dep===void 0?[]:[m.dep];n.set(c,[m.parent,m.blockedBy,...p].flatMap(xt))}let r=new Set,i=new Set,o=a=>{if(r.has(a))throw new d(`Mutation reference cycle includes "@${a}".`,u.USAGE);if(!i.has(a)){r.add(a);for(let s of n.get(a))n.has(s)&&o(s);r.delete(a),i.add(a)}};for(let a of n.keys())o(a)}function qt(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}}}),r=n[0];if(!r.ok&&(r.line.startsWith("[")||r.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&w(o.value)))return null;let i=[];for(let o of n){if(!o.ok)throw new d(`Mutation document line ${o.number} must be one valid JSON object: ${Pe(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(!w(o.value))throw new d(`Mutation document line ${o.number} must be a JSON object.`,u.USAGE);i.push(o.value)}return i}function Kt(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function Lt(e){let t;try{t=ae(e,"Mutation document")}catch(n){let r=qt(e);if(r===null)throw n;return{schema_version:1,mutations:r}}return Array.isArray(t)?{schema_version:1,mutations:t}:w(t)&&!Kt(t)?{schema_version:1,mutations:[t]}:t}function Jt(e,t){let n=Object.hasOwn(e,"op")?Wt(e,t):zt(e,t);if(n.op==="create"&&n.id===void 0&&w(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new d(`Mutation ${t+1} item id must be a string.`,u.USAGE);n.id=n.item.id}return n}function Wt(e,t){for(let n of Object.keys(e))if(!Qe.includes(n))throw E(`mutation ${t+1}`,n,Qe);if(e.item!==void 0&&e.op!=="create")throw new d(`Mutation ${t+1} item documents are only valid for create operations.`,u.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new d(`Mutation ${t+1} must declare either item or options, not both.`,u.USAGE);return{...e}}function zt(e,t){let{ref:n,id:r,item:i,...o}=e,a=i!==void 0?i:o;if(i!==void 0&&Object.keys(o).length>0)throw new d(`Mutation ${t+1} must not mix item document keys with top-level fields.`,u.USAGE);if(!w(a))throw new d(`Mutation ${t+1} item document must be an object.`,u.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...r===void 0?{}:{id:r},item:a}}function Bt(e){let t=Lt(e);if(!w(t))throw new d("Mutation document must be a JSON array or object.",u.USAGE);for(let n of Object.keys(t))if(!tt.includes(n))throw E("mutation document",n,tt);if(t.schema_version!==void 0&&t.schema_version!==1)throw new d("Mutation document schema_version must be 1.",u.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new d("Mutation document requires a non-empty mutations array.",u.USAGE);return t.mutations.map((n,r)=>{if(!w(n))throw new d(`Mutation ${r+1} must be an object.`,u.USAGE);return Jt(n,r)})}function Vt(e,t,n){let r=new Set(Object.values(wt(t,n,Object.create(null))));for(let i of t)i.op==="create"&&typeof i.id=="string"&&i.id.trim().length>0&&r.add(I(i.id,n.idPrefix));return{...e,existing:e.existing.filter(i=>!r.has(i.id))}}function Yt(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,r]of e.entries()){if(r.op!=="create"||r.ref!==void 0||typeof r.id=="string"&&r.id.trim().length>0)continue;let i=`${et}${n+1}`;if(t.has(i))throw new d(`Mutation ${n+1} receives the synthesized ref "${i}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${et}<n> aliases are reserved for rows without one.`,u.USAGE);r.ref=i}}function ft(e,t,n){let r=ln(JSON.stringify(e),t,{},n);return delete r.stdinJson,delete r.documentAnnotationSnapshot,r}function ht(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>O(n))}function Ht(e,t){for(let n of e)w(n.item)&&(n.options=ft(n.item,"create",t),delete n.item)}function yt(e,t){return t.some(n=>n.metadata_key===e)?e:Ze(e)}function ie(e,t,n){let r=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(w(e.item)){if(e.item[t]!==void 0)return e.item[t];if(yt(r,n)===t&&e.item[r]!==void 0)return e.item[r]}let i=w(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&i[O(o)]!==void 0?i[O(o)]:i[t]!==void 0?i[t]:i[r]!==void 0?i[r]:(Array.isArray(i.field)?i.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function Xt(e,t){return e<t?-1:+(e!==t)}function oe(e){return Array.isArray(e)?e.map(oe):w(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>Xt(t,n)).map(([t,n])=>[t,oe(n)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(oe(e))}function Zt(e,t,n,r,i){let o=t.key.trim();if(o.length===0)throw new d("Upsert key must be a non-empty field name.",u.USAGE);let a=Qt(t.existing),s=new Map,c=new Set;for(let[m,p]of e.entries()){if(p.op!=="create")continue;let h=en(p,o,m,s,r),f=tn(a.get(h)??[],o,h);if(f===void 0){p.unique={key:o,value:ie(p,o,r)};continue}let y=I(f,n);typeof p.ref=="string"&&(i[p.ref]=y),nn(p,y,r,{key:o,value:ie(p,o,r)}),c.add(m)}return c}function Qt(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let r=_(n.value);t.set(r,[...t.get(r)??[],n.id])}return t}function en(e,t,n,r,i){let o=ie(e,t,i);if(o==null||o==="")throw new d(`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=_(o),s=r.get(a);if(s!==void 0)throw new d(`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 r.set(a,n),a}function tn(e,t,n){if(e.length>1)throw new d(`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 nn(e,t,n,r){let i=new Set([...lt.update,...ht("update",n)]),o=w(e.item)?ft(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>i.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=r}function wt(e,t,n){for(let[r,i]of e.entries())if(i.ref!==void 0){if(i.op!=="create")throw new d(`Mutation ${r+1} ref is only valid for create operations.`,u.USAGE);if(typeof i.ref!="string"||!nt.test(i.ref))throw new d(`Mutation ${r+1} ref must match ${nt.source}.`,u.USAGE);if(n[i.ref]!==void 0)throw new d(`Duplicate mutation ref "${i.ref}".`,u.USAGE);n[i.ref]=typeof i.id=="string"&&i.id.trim().length>0?I(i.id,t.idPrefix):Pt(t.transactionId,i.ref,t.idPrefix)}return n}function rr(e,t){let n=Bt(e);Yt(n);let r=n.map(p=>typeof p.ref=="string"?p.ref:void 0),i=Object.create(null),o=t.upsert===void 0?new Set:Zt(n,Vt(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],i);Ht(n,t.runtimeFields??[]),wt(n,t,i),Gt(n,r);let a=n.map(p=>{let h={...p},f=typeof h.ref=="string"?h.ref:void 0;if(delete h.ref,f!==void 0?h.id=i[f]:h.id=ot(h.id,i),w(h.options)){let y={...h.options};for(let g of["parent","blockedBy"])y[g]!==void 0&&(y[g]=ot(y[g],i));Array.isArray(y.dep)?y.dep=y.dep.map(g=>at(g,i)):y.dep!==void 0&&(y.dep=at(y.dep,i)),h.options=y}return h}),s=mt(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),c=s.filter(p=>p.op==="create").map(p=>p.id);if(new Set(c).size!==c.length)throw new d("Duplicate resolved create id in mutation document.",u.USAGE);let m=s.map((p,h)=>{let f=r[h];return{index:h,...typeof f=="string"?{ref:f}:{},id:p.id,op:p.op,...o.has(h)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:i,rows:m}}function rn(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let r=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(r)?JSON.stringify(r):r}`}).join(",")}function on(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(w))throw new d(`${n} must be an array of objects.`,u.USAGE);return e.map(r=>rn(r,t))}}function an(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 st(e,t,n=!1){for(let[r,i,o]of Je){let a=t[r],s=on(n&&["comments","notes","learnings"].includes(r)&&Array.isArray(a)?a.filter(c=>!w(c)||c.created_at===void 0):a,o,r);s!==void 0&&s.length>0&&(e[i]=s)}}function sn(e,t){for(let n of Object.keys(e)){if(t){if(!F.includes(n))throw E("item envelope",n,F);continue}if(!b.has(n)&&P(n,[...b])===void 0&&P(n,F)==="item")throw E("item envelope",n,F)}}function cn(e){let t=Object.hasOwn(e,"item");sn(e,t);let n=t?e.item:e;if(!w(n))throw new d("Item document item must be an object.",u.USAGE);return{item:n,...t&&w(e.linked)?{linked:e.linked}:{}}}function dn(e,t,n,r,i,o){if((r==="update"?Ut:pt).has(t))return;let a=i.find(s=>s.metadata_key===t&&s.commands.includes(r));if(a!==void 0){let s=H(o,a);e[O(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!b.has(t)){if(P(t,[...b])!==void 0)throw E("item document",t,[...b]);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,c)=>c.toUpperCase())]=an(t,n))}function un(e,t,n){let r=new Set(Object.entries(e).filter(([,o])=>o!==void 0).map(([o])=>o)),i=t==="create"?U:j;for(let{target:o,keys:a}of i)a.some(s=>r.has(s))&&r.add(o);for(let o of n)H(e,o)!==void 0&&r.add(O(o));return r}function pn(e,t,n){let r=t==="create"?U:j;for(let{target:i}of r)i!=="field"&&n.has(i)&&delete e[i]}function ln(e,t,n={},r=[]){let i=ae(e,"Item document");if(!w(i))throw new d("Item document must be a JSON object.",u.USAGE);let{item:o,linked:a}=cn(i),s={};for(let[h,f]of Object.entries(o)){let y=yt(h,r);y!==h&&Object.hasOwn(o,y)||dn(s,y,f,t,r,n)}st(s,o,t==="update"),a!==void 0&&st(s,a);let c=un(n,t,r);if(pn(s,t,c),t==="update"){let h=Object.fromEntries(["comments","notes","learnings"].filter(f=>Object.hasOwn(o,f)&&!c.has(f.slice(0,-1))).map(f=>[f,o[f].filter(y=>w(y)&&y.created_at!==void 0)]));Object.keys(h).length>0&&(s.documentAnnotationSnapshot=h)}let m={...s,...Object.fromEntries(Object.entries(n).filter(([,h])=>h!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0},p=Object.keys(s).filter(h=>!c.has(h));return Oe(be(m,p),p)}function ir(e){return mt(JSON.stringify(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]="49806fc6-ff49-5b67-9b3f-c182ace00c20")}catch{}})();async function wn(e,t){if(!je(e))return{schema:Y(t.schema),typeDefinitionsFromFile:[]};let n=await Mn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function gn(e,t,n,r){let i=B({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},V());return(await Fe(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function le(e){let t=new Map,n=async r=>{let i=await De(e),o=await wn(e,i),a=new Map;for(let s of await gn(e,i,o,r)){let c=_(s.value);a.set(c,[...a.get(c)??[],s.id])}return a};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,o]of t){let a=r[i];if(a==null)continue;let s=await o,c=_(a);s.set(c,[...s.get(c)??[],String(r.id)])}},invalidate(){t.clear()}}}async function vn(e,t){let n=_(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new d(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.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 _n(e,t,n){let r=e.metadata[n.key],i=_(n.value);if(_(r)!==i)throw new d(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; 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 gt(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 K(e,t){let n={...e,...t};return e===void 0?n:W(e,n)}async function S(e,t){try{let n=(await te(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 d&&n.exitCode===u.NOT_FOUND)return;throw n}}function me(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ue.createHash("sha256").update(Se(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function Sn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function v(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}async function M(e,t,n,r){let i=await A(l.join(e,"history",`${t}.jsonl`),t),o=v(n,r,"apply"),a=v(n,r,"compensate");for(let s=i.length-1;s>=0;s-=1){let c=i[s].message;if(c===o)return!0;if(c===a)return!1}return!1}async function fe(e,t){let n=await S(e,t.id);if(n?.updatedAt===void 0)throw new d(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,u.NOT_FOUND);let r=await A(l.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new d(`Bulk ${t.op} target ${t.id} has no restorable history`,u.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(Z(r)+r.length),target_history_hash:R(r),target_history_length:r.length}}function T(e,t,n){return new d(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,u.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function At(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function bn(e,t,n){let{expectedHistory:r,length:i,version:o}=t;if(R(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||R(e.slice(0,i))!==r||o!==String(Z(e)+i))throw T(n,n.itemId,n.stepId);let a=v(n.transactionId,n.stepId,"apply"),s=e.slice(i),c=f=>f.message===a||f.context?.item_transaction_step===a,m=v(n.transactionId,n.stepId,"compensate");if(s.filter(f=>c(f)||f.message===m).at(-1)?.message===m)return!1;let p=s.filter(c);if(p.length===0)return!1;let h=e.at(-1).after_hash===p.at(-1).after_hash&&s.every(f=>At(f,n.transactionId));if(p.length!==s.length&&!h)throw T(n,n.itemId,n.stepId);return!0}async function L(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let o=i.target_updated_at,a=await S(e.pmRoot,t);if(a===void 0)return;let s=await A(l.join(e.pmRoot,"history",`${a.id}.jsonl`),a.id),c=i.target_history_hash;if(typeof c=="string"){if(!bn(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:a.id,stepId:n}))return}else{if(a.updatedAt===o)return;if(!await M(e.pmRoot,a.id,e.transactionId,n))throw T(e,a.id,n)}let m=()=>He(t,typeof i.target_version=="string"?i.target_version:o,{force:!0,author:e.author,message:v(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await C({pmRoot:e.pmRoot,id:a.id,validate:p=>{if(X(p)!==s.at(-1).after_hash)throw T(e,a.id,n)}},m)}function Tt(e,t,n){return{id:n,async inspect(){let r=await S(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await A(l.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.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 d(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,u.CONFLICT,{code:"transaction_create_compensated",item_id:r.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 ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await vn(e.uniqueIndex,t.unique);let r=await ze(K(t.options,{author:e.author,id:t.id,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await En(e,t.id,n)}}}async function En(e,t,n){let r=await S(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let i=await A(l.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),o=v(e.transactionId,n,"apply"),a=v(e.transactionId,n,"compensate"),s=i.filter(c=>c.message===o||c.message===a).at(-1);if(s?.message!==a){if(s===void 0||!i.every(c=>At(c,e.transactionId)))throw T(e,r.id,n);await C({pmRoot:e.pmRoot,id:r.id,validate:c=>{if(X(c)!==i.at(-1).after_hash)throw T(e,r.id,n)}},async()=>{let c={force:!0,author:e.author,message:a};e.createCompensation==="delete"?await Ye(t,c,{pmRoot:e.pmRoot}):await ne(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,c,{pmRoot:e.pmRoot})})}}function On(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await S(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return fe(e.pmRoot,t)},async apply(){let r=()=>Be(t.id,K(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,o=i,a=(await C({pmRoot:e.pmRoot,id:String((await te(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{o!==void 0&&_n(s,t.id,o)},committed:s=>{i!==void 0&&(o={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:v(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await L(e,t.id,n,r)}}}function An(e,t,n){return{id:n,async inspect(){let r=await S(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return fe(e.pmRoot,t)},async apply(){let r=(await ne(t.id,t.reason,K(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"close"}},async compensate(r){await L(e,t.id,n,r)}}}function Tn(e,t,n){return{id:n,async inspect(){let r=await S(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return fe(e.pmRoot,t)},async apply(){let r=(await Ve(t.id,K(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"release"}},async compensate(r){await L(e,t.id,n,r)}}}function he(e,t,n){let r=me(t,n);switch(t.op){case"create":return Tt(e,t,r);case"update":return On(e,t,r);case"close":return An(e,t,r);case"release":return Tn(e,t,r)}}function $n(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&&!gt(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&&!gt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);D(e.options,e.op,t)}function $t(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if($n(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:o}=r.unique,a=t.get(i)??new Map,s=_(o),c=a.get(s);if(c!==void 0)throw new d(`Bulk create mutations ${c+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,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(i,a)}}function kt(e){let t=[...e];return $t(t),t.map(n=>{let r=structuredClone(n);return n.options!==void 0&&r.options!==void 0&&W(n.options,r.options),r})}function Mt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:Mt(r,i)})}async function ce(e,t,n){try{return await n()}catch(r){throw r instanceof d?new d(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function Rt(e,t,n,r){let i=l.relative(e,t),o=i.split(l.sep);return o[0]==="extensions"&&o[2]==="node_modules"&&!r.some(a=>i===a||i.startsWith(`${a}${l.sep}`)||a.startsWith(`${i}${l.sep}`))?!1:["locks","runtime","search"].includes(i.split(l.sep)[0])?r.some(a=>i===a||i.startsWith(`${a}${l.sep}`)||a.startsWith(`${i}${l.sep}`)):i===""||n===void 0||n.some(a=>i===a||i.startsWith(`${a}${l.sep}`)||a.startsWith(`${i}${l.sep}`))}async function G(e,t){let n=await vt(t);if(n.isSymbolicLink())await pe(t);else if(n.isDirectory()||n.isFile())return n;throw k(l.relative(e,t))}async function kn(e,t){let n=await hn(t,se.O_RDONLY|se.O_NOFOLLOW|se.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw k(l.relative(e,t));let i=ue.createHash("sha256");if(r.size>0)for await(let o of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(o);return i.digest()}finally{await n.close()}}async function de(e,t,n){let r=ue.createHash("sha256");async function i(o){for(let a of(await yn(o)).sort()){let s=l.join(o,a);Rt(e,s,t,n)&&((await G(e,s)).isDirectory()?await i(s):(r.update(JSON.stringify(l.relative(e,s))),r.update(await kn(e,s))))}}return await i(e),r.digest("hex")}function x(){return new d("Tracker changed while preparing the transaction preview; retry against stable state.",u.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function ye(e){if(!z(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=l.resolve(t),r=n;for(;;)try{let i=await vt(r);return r!==n&&i.isDirectory()}catch(i){if(!z(i))return!1;let o=l.dirname(r);if(o===r)return!1;r=o}}async function q(e,t){let n=l.join(e,t);try{let r=e;for(let i of t.split(l.sep).slice(0,-1))r=l.join(r,i),await G(e,r);if(!(await G(e,n)).isFile())throw k(t);return await Ae(n,k(t))}catch(r){if(await ye(r))return;throw r}}async function It(e,t,n,r){let i=Y(n);for(let[o,a]of Object.entries(i.files)){let s=l.relative(e,Re(e,a,Me[o]));if(s===""||!l.resolve(e,s).startsWith(l.join(e,l.sep)))throw new d("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}`});i.files[o]=s;let c=await q(e,s);if(r?.set(s,c),c!==void 0){let m=l.join(t,s);await fn(l.dirname(m),{recursive:!0}),await Et(m,c)}}return Ie(t,i)}async function Mn(e,t){await pe(e);let n=await _t(l.join(Ot(),"pm-schema-plan-"));try{let r=await St(e);return await It(r,l.join(n,"configuration"),t)}catch(r){throw await ye(r)?x():r}finally{await bt(n,{recursive:!0,force:!0})}}async function Rn(e,t,n){let r=new Map,i=await q(e,$);r.set($,i);let o;try{o=JSON.parse(i??"null")}catch{o=null}let a=Ue(o),s=a.success?a.data:void 0,c=await It(e,t,s?.schema,r),m=c.schema,p=l.relative(e,Ce(e));r.set(p,await q(e,p));let h=B({..._e,item_types:{definitions:[...s?.item_types?.definitions??[],...c.type_definitions_from_file??[]]}},n),f=Te(e)===e?[...ve.filter(Boolean),$,xe,"transactions",...h.folders,...r.keys()].map(g=>l.normalize(g)):void 0,y=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:m.files}});return{configuration:r,ownedPaths:f,stagedSettings:y,registryFolders:h.folders}}async function In(e,t,n){await pe(e);try{let r=await St(e),i=await Rn(r,l.join(l.dirname(t),"configuration"),n),o=[...i.configuration.keys(),...i.registryFolders].map(m=>l.normalize(m)),a=await de(r,i.ownedPaths,o);await mn(r,t,{recursive:!0,dereference:!1,filter:async m=>Rt(r,m,i.ownedPaths,o)?(await G(r,m),!0):!1});let[s,c]=await Promise.all([de(r,i.ownedPaths,o),de(t,i.ownedPaths,o)]);if(a!==s||a!==c)throw x();for(let[m,p]of i.configuration)if(await q(t,m)!==p)throw x();i.stagedSettings!==void 0&&await Et(l.join(t,$),i.stagedSettings)}catch(r){throw await ye(r)?x():r}}async function Ur(e){let t=N(e),n=kt(e.mutations),r=V(),i=await _t(l.join(Ot(),"pm-transaction-preview-")),o=l.join(i,"tracker");try{await In(t.pmRoot,o,r);let a=!1,s=[],c=[],m=new Set;return await Xe({path:o,noExtensions:!0},async()=>{ke(r);let p={...t,pmRoot:o,createCompensation:"close",uniqueIndex:le(o)},h=n.map((f,y)=>{let g=he({...p,onCreateWarnings:(J,we)=>{we.length>0&&s.push({index:y,id:J,op:"create",warnings:we})}},f,y);return{...g,inspect:()=>ce(f,y,()=>g.inspect()),prepareCompensation:()=>ce(f,y,async()=>g.prepareCompensation?.()),apply:()=>ce(f,y,async()=>{let J=await g.apply();return m.add(y),J})}});if(await Q({...t,pmRoot:o,steps:h,onTransition:({transition:f})=>{f==="committed"&&(a=!0)}}),a)for(let[f,y]of n.entries()){let g=(await We(y.id,{path:o},{full:!0})).item;c.push({index:f,id:String(g.id),op:y.op,execution:m.has(f)?"applied":"adopted",item:g,commit_time_fields:Mt(g)})}}),{records:c,validated:a,state:a?"staged_snapshot":"replayed_committed_plan",warnings:s,unresolved_commit_constraints:["concurrent_tracker_changes","extension_mutation_guards_and_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await bt(i,{recursive:!0,force:!0})}}async function Cn(e){let t=N(e),n=kt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:le(t.pmRoot)},o=await Q({...t,steps:n.map((s,c)=>he(i,s,c)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),a={};for(let[s,c]of n.entries()){let m=me(c,s),p=o.results[m];a[Sn(c,s)]=p}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:a}}function Nn(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 jr(e){return Cn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Nn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Dr={buildCreateStep:Tt,bulkHistoryMarker:v,compensateByRestore:L,deriveStepId:me,isUpdateMarkerApplied:M,readItemSnapshot:S};async function Fr(e,t){let n=await Ge(e,t);return n===void 0?void 0:{journal:n,planDigest:ee(n)}}function Un(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new d("Transaction has no supported item recovery plan",u.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let r=n.mutations;$t(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:le(e.pmRoot)};return r.map((o,a)=>he(i,o,a))}async function Pr(e){let t=N(e),n=await qe({...e,...t,resolveSteps:r=>Un({...e,...t},r)});return{journal:n,planDigest:ee(n)}}export{Ze as a,tr as b,nr as c,mt as d,_ as e,rr as f,ln as g,ir as h,wn as i,gn as j,Mn as k,Ur as l,Cn as m,Nn as n,jr as o,Dr as p,Fr as q,Pr as r};
2
+ //# sourceMappingURL=chunk-TYERATXH.js.map
@@ -1,2 +1,2 @@
1
- import{ga as p,ha as i,ia as v,ja as _}from"./chunk-4BQD5SW2.js";import{za as h}from"./chunk-OH7WPD42.js";import u from"node:fs/promises";import c 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]="846100a9-4314-5f7c-b892-fa16e09bee5b")}catch{}})();function f(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function y(e){return e!=="invalid"&&e!=="unreadable"}function j(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid settings object");let r=t.extensions;if(r===void 0)return{enabled:[],disabled:[]};if(typeof r!="object"||r===null||Array.isArray(r))throw new SyntaxError("Invalid extensions settings");let n=r;if(n.enabled!==void 0&&(!Array.isArray(n.enabled)||!n.enabled.every(a=>typeof a=="string"))||n.disabled!==void 0&&(!Array.isArray(n.disabled)||!n.disabled.every(a=>typeof a=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:n.enabled??[],disabled:n.disabled??[]}}async function S(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}try{return{status:"ok",...j(t)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function A(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){if(f(r))try{if((await u.stat(c.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(n){if(f(n))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}try{let r=JSON.parse(t),n=_(r);if(!n||typeof r!="object"||r===null||!Array.isArray(r.entries)||n.entries.length!==r.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:n.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function I(e){try{return{directories:(await u.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}}catch(t){return f(t)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function D(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}try{let r=v(JSON.parse(t));return r?{manifest:r}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function M(e){let t=e.manifest?.name??e.directory,r=new Set(p(e.settings.enabled)),n=new Set(p(e.settings.disabled)),a=!y(e.settings.status)||!e.manifest?null:!n.has(t)&&(r.size===0||r.has(t)),o=y(e.managed.status)?e.managed.entries.some(d=>i(d.name)===i(t)||i(d.directory)===i(e.directory)):null;return{name:t,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?a===!1?"inactive":"installed":"malformed_manifest",configured_enabled:a,managed:o,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}async function R(e){let t=e.scope??"project",r=t==="global"?h(e.cwd??process.cwd()):e.pmRoot,n=c.join(r,"extensions"),a=await S(c.join(r,"settings.json")),o=await A(c.join(n,".managed-extensions.json")),d=await I(n),l=[];for(let s of[a,o,d])s.error&&l.push(s.error);let m=e.name?.trim(),b=[];for(let s of d.directories){let x=c.join(n,s,"manifest.json"),g=await D(x);g.error&&l.push(g.error);let w=M({directory:s,scope:t,manifest:g.manifest,settings:a,managed:o});m&&![w.name,s].some(E=>i(E)===i(m))||b.push(w)}return m&&b.length===0&&l.every(s=>s.code!=="extensions_unreadable")&&b.push({name:m,directory:null,scope:t,installed:!1,status:"absent",configured_enabled:y(a.status)?!1:null,managed:y(o.status)?!1:null,runtime_active:null}),{scope:t,complete:l.length===0,settings_status:a.status,managed_state_status:o.status,extensions:b,errors:l}}export{R as a};
2
- //# sourceMappingURL=chunk-EHBGHX55.js.map
1
+ import{ga as p,ha as i,ia as v,ja as _}from"./chunk-Y7CKVU56.js";import{Oa as h}from"./chunk-5WVE7XBS.js";import u from"node:fs/promises";import c 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]="846100a9-4314-5f7c-b892-fa16e09bee5b")}catch{}})();function f(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function y(e){return e!=="invalid"&&e!=="unreadable"}function j(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid settings object");let r=t.extensions;if(r===void 0)return{enabled:[],disabled:[]};if(typeof r!="object"||r===null||Array.isArray(r))throw new SyntaxError("Invalid extensions settings");let n=r;if(n.enabled!==void 0&&(!Array.isArray(n.enabled)||!n.enabled.every(a=>typeof a=="string"))||n.disabled!==void 0&&(!Array.isArray(n.disabled)||!n.disabled.every(a=>typeof a=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:n.enabled??[],disabled:n.disabled??[]}}async function S(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}try{return{status:"ok",...j(t)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function A(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){if(f(r))try{if((await u.stat(c.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(n){if(f(n))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}try{let r=JSON.parse(t),n=_(r);if(!n||typeof r!="object"||r===null||!Array.isArray(r.entries)||n.entries.length!==r.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:n.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function I(e){try{return{directories:(await u.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}}catch(t){return f(t)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function D(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}try{let r=v(JSON.parse(t));return r?{manifest:r}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function M(e){let t=e.manifest?.name??e.directory,r=new Set(p(e.settings.enabled)),n=new Set(p(e.settings.disabled)),a=!y(e.settings.status)||!e.manifest?null:!n.has(t)&&(r.size===0||r.has(t)),o=y(e.managed.status)?e.managed.entries.some(d=>i(d.name)===i(t)||i(d.directory)===i(e.directory)):null;return{name:t,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?a===!1?"inactive":"installed":"malformed_manifest",configured_enabled:a,managed:o,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}async function R(e){let t=e.scope??"project",r=t==="global"?h(e.cwd??process.cwd()):e.pmRoot,n=c.join(r,"extensions"),a=await S(c.join(r,"settings.json")),o=await A(c.join(n,".managed-extensions.json")),d=await I(n),l=[];for(let s of[a,o,d])s.error&&l.push(s.error);let m=e.name?.trim(),b=[];for(let s of d.directories){let x=c.join(n,s,"manifest.json"),g=await D(x);g.error&&l.push(g.error);let w=M({directory:s,scope:t,manifest:g.manifest,settings:a,managed:o});m&&![w.name,s].some(E=>i(E)===i(m))||b.push(w)}return m&&b.length===0&&l.every(s=>s.code!=="extensions_unreadable")&&b.push({name:m,directory:null,scope:t,installed:!1,status:"absent",configured_enabled:y(a.status)?!1:null,managed:y(o.status)?!1:null,runtime_active:null}),{scope:t,complete:l.length===0,settings_status:a.status,managed_state_status:o.status,extensions:b,errors:l}}export{R as a};
2
+ //# sourceMappingURL=chunk-UEEG47TU.js.map