@unbrained/pm-cli 2026.8.22 → 2026.8.24

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 (229) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +42 -1
  3. package/dist/cli/description-stdin.js +5 -4
  4. package/dist/cli/error-guidance.d.ts +13 -0
  5. package/dist/cli/error-guidance.js +62 -6
  6. package/dist/cli/extension-command-help.d.ts +5 -0
  7. package/dist/cli/extension-command-help.js +6 -2
  8. package/dist/cli/help-content.d.ts +5 -0
  9. package/dist/cli/help-content.js +56 -3
  10. package/dist/cli/help-json-payload.d.ts +5 -2
  11. package/dist/cli/help-json-payload.js +57 -17
  12. package/dist/cli/main.d.ts +3 -0
  13. package/dist/cli/main.js +39 -5
  14. package/dist/cli/register-annotations.js +5 -5
  15. package/dist/cli/register-mutation.js +77 -31
  16. package/dist/cli/register-operations.d.ts +73 -0
  17. package/dist/cli/register-operations.js +39 -14
  18. package/dist/cli/register-setup.js +3 -3
  19. package/dist/cli/schema-registration-helpers.d.ts +8 -1
  20. package/dist/cli/schema-registration-helpers.js +14 -5
  21. package/dist/cli-bundle/bundle-manifest.json +155 -155
  22. package/dist/cli-bundle/chunks/chunk-AGUL3HUT.js +3 -0
  23. package/dist/cli-bundle/chunks/{chunk-WG4STC36.js → chunk-DJNJBWAQ.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-MYYI3ZOA.js → chunk-I5Q7QSZX.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-IW72J5FW.js +2 -0
  26. package/dist/cli-bundle/chunks/{chunk-BWX4SK46.js → chunk-L22NP5MA.js} +66 -66
  27. package/dist/cli-bundle/chunks/chunk-MKE6MD2K.js +36 -0
  28. package/dist/cli-bundle/chunks/{chunk-MZTZQTMS.js → chunk-NXBFO63A.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-TEQDR5KI.js +202 -0
  30. package/dist/cli-bundle/chunks/chunk-X7WWQDYQ.js +2 -0
  31. package/dist/cli-bundle/chunks/chunk-YOLLRCLY.js +13 -0
  32. package/dist/cli-bundle/chunks/{chunk-U6GQ4VMV.js → chunk-ZAVCS2GH.js} +4 -4
  33. package/dist/cli-bundle/chunks/{register-list-query-HZKBQNWW.js → register-list-query-37A4P6O4.js} +2 -2
  34. package/dist/cli-bundle/chunks/register-mutation-TBJDHYIT.js +20 -0
  35. package/dist/cli-bundle/chunks/register-operations-WRZNEBUM.js +2 -0
  36. package/dist/cli-bundle/chunks/{register-setup-QK4OTOXN.js → register-setup-H4PDLACD.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-GMYPD4FX.js → chunk-4WP7LNE3.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-6MUTDXMP.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-6Z24ZMU3.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-2ARQGDDW.js → chunk-BFA6KKCI.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-CWCN5RLO.js +26 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-FCTT4CZU.js +5 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-GJR6YEMR.js +156 -0
  44. package/dist/cli-bundle/focused-chunks/{chunk-2POVTNLY.js → chunk-IMWTYKII.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-D6RBZEJJ.js → chunk-IZNRRCU3.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-PMGJUFNQ.js → chunk-MNPECIRL.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-A2BC5PQL.js → chunk-O4ZXNJMT.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-Q63PSLO4.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-QBP5FSBX.js +4 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-R6SR45XU.js → chunk-QV5UP27O.js} +48 -47
  51. package/dist/cli-bundle/focused-chunks/chunk-RASVBJX5.js +8 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-E2EWYPY6.js → chunk-RPRLENVA.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-TOFVXBWA.js +19 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-6S2MO3Q3.js → chunk-WZLSSGEU.js} +2 -2
  55. package/dist/cli-bundle/main.js +18 -17
  56. package/dist/cli-bundle/sdk-authoring.js +1 -1
  57. package/dist/cli-bundle/sdk-contracts.js +2 -2
  58. package/dist/cli-bundle/sdk-core.js +41 -41
  59. package/dist/cli-bundle/sdk-governance.js +1 -1
  60. package/dist/cli-bundle/sdk-graph.js +1 -1
  61. package/dist/cli-bundle/sdk-merge.js +33 -32
  62. package/dist/cli-bundle/sdk-query.js +1 -1
  63. package/dist/cli-bundle/sdk-runtime.js +1 -1
  64. package/dist/cli-bundle/sdk-testing.js +1 -1
  65. package/dist/cli-bundle/sdk.js +6 -5
  66. package/dist/core/config/nested-settings.js +8 -2
  67. package/dist/core/config/positional-value.d.ts +1 -1
  68. package/dist/core/config/positional-value.js +5 -2
  69. package/dist/core/extensions/command-metadata-contract.d.ts +10 -0
  70. package/dist/core/extensions/command-metadata-contract.js +23 -0
  71. package/dist/core/extensions/command-visibility-tier.js +12 -2
  72. package/dist/core/extensions/extension-types.d.ts +6 -0
  73. package/dist/core/extensions/extension-types.js +2 -2
  74. package/dist/core/extensions/loader.js +4 -3
  75. package/dist/core/history/history.js +3 -3
  76. package/dist/core/io/body-file.js +7 -2
  77. package/dist/core/io/bulk-ids-input.d.ts +24 -0
  78. package/dist/core/io/bulk-ids-input.js +113 -0
  79. package/dist/core/item/item-format.js +66 -12
  80. package/dist/core/item/parse.d.ts +22 -2
  81. package/dist/core/item/parse.js +97 -4
  82. package/dist/core/reproducibility/context.d.ts +4 -0
  83. package/dist/core/reproducibility/context.js +14 -8
  84. package/dist/core/shared/author.d.ts +55 -1
  85. package/dist/core/shared/author.js +333 -16
  86. package/dist/core/shared/constants.js +3 -2
  87. package/dist/core/store/settings-validator.d.ts +1 -0
  88. package/dist/core/store/settings-validator.js +6 -3
  89. package/dist/core/store/settings.js +5 -2
  90. package/dist/mcp/server.d.ts +4 -3
  91. package/dist/mcp/server.js +44 -16
  92. package/dist/sdk/agent/identity-config.d.ts +63 -0
  93. package/dist/sdk/agent/identity-config.js +107 -0
  94. package/dist/sdk/agent/refusal-closure-census.d.ts +66 -0
  95. package/dist/sdk/agent/refusal-closure-census.js +144 -0
  96. package/dist/sdk/agent/refusal-corpus-contracts.d.ts +76 -0
  97. package/dist/sdk/agent/refusal-corpus-contracts.js +194 -0
  98. package/dist/sdk/agent-capability-contracts.d.ts +34 -1
  99. package/dist/sdk/agent-capability-contracts.js +104 -6
  100. package/dist/sdk/annotations.d.ts +2 -0
  101. package/dist/sdk/annotations.js +25 -7
  102. package/dist/sdk/cli-contracts/agent-output-contracts.js +6 -4
  103. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -0
  104. package/dist/sdk/cli-contracts/enum-contracts.js +9 -2
  105. package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
  106. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +4 -4
  107. package/dist/sdk/cli-contracts/registration-helpers.js +5 -2
  108. package/dist/sdk/cli-contracts/tool-parameter-tables.js +58 -2
  109. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  110. package/dist/sdk/cli-contracts/tool-schema.js +14 -3
  111. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +4 -1
  112. package/dist/sdk/cli-contracts/typed-action-inputs.js +2 -2
  113. package/dist/sdk/cli-contracts.d.ts +3 -3
  114. package/dist/sdk/cli-contracts.js +4 -4
  115. package/dist/sdk/comments.js +15 -7
  116. package/dist/sdk/config.d.ts +6 -1
  117. package/dist/sdk/config.js +119 -14
  118. package/dist/sdk/context-intent-contracts.js +4 -2
  119. package/dist/sdk/core-governance.d.ts +1 -1
  120. package/dist/sdk/core-governance.js +3 -3
  121. package/dist/sdk/extension/scaffold.js +11 -5
  122. package/dist/sdk/flag-invocation-contracts.d.ts +2 -0
  123. package/dist/sdk/flag-invocation-contracts.js +30 -3
  124. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +83 -2
  125. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +87 -2
  126. package/dist/sdk/governance/assurance-action.js +30 -10
  127. package/dist/sdk/governance/validate.d.ts +2 -2
  128. package/dist/sdk/governance/validate.js +39 -14
  129. package/dist/sdk/guide-topics.d.ts +0 -5
  130. package/dist/sdk/guide-topics.js +28 -2
  131. package/dist/sdk/history-compact.d.ts +2 -1
  132. package/dist/sdk/history-compact.js +24 -5
  133. package/dist/sdk/history-mcp.js +11 -10
  134. package/dist/sdk/index.d.ts +8 -2
  135. package/dist/sdk/index.js +9 -3
  136. package/dist/sdk/item-transaction.js +19 -12
  137. package/dist/sdk/lifecycle/append.js +4 -4
  138. package/dist/sdk/lifecycle/close-many.js +16 -7
  139. package/dist/sdk/lifecycle/create.js +33 -22
  140. package/dist/sdk/lifecycle/plan.js +24 -6
  141. package/dist/sdk/lifecycle/update-many.js +15 -8
  142. package/dist/sdk/lifecycle/update.d.ts +2 -0
  143. package/dist/sdk/lifecycle/update.js +37 -25
  144. package/dist/sdk/merge/three-way.js +105 -26
  145. package/dist/sdk/read-output-budget.d.ts +21 -0
  146. package/dist/sdk/read-output-budget.js +39 -2
  147. package/dist/sdk/read-output-contracts.d.ts +5 -3
  148. package/dist/sdk/read-output-contracts.js +20 -12
  149. package/dist/sdk/reproducibility/process.d.ts +19 -0
  150. package/dist/sdk/reproducibility/process.js +88 -0
  151. package/dist/sdk/runtime-extended-actions.js +5 -3
  152. package/dist/sdk/runtime-input.d.ts +4 -0
  153. package/dist/sdk/runtime-input.js +98 -23
  154. package/dist/sdk/runtime-primitives.d.ts +3 -2
  155. package/dist/sdk/runtime-primitives.js +5 -4
  156. package/dist/sdk/runtime.js +11 -23
  157. package/dist/sdk/scheduling-shortcuts.js +5 -3
  158. package/dist/sdk/structured-mutations.js +10 -3
  159. package/dist/sdk/test/batch.d.ts +6 -0
  160. package/dist/sdk/test/batch.js +15 -3
  161. package/dist/sdk/test/entry.d.ts +1 -1
  162. package/dist/sdk/test/entry.js +3 -2
  163. package/dist/sdk/test/execution.d.ts +28 -3
  164. package/dist/sdk/test/execution.js +193 -34
  165. package/dist/sdk/test/parsers.d.ts +6 -0
  166. package/dist/sdk/test/parsers.js +21 -2
  167. package/dist/sdk/test/trust.d.ts +33 -0
  168. package/dist/sdk/test/trust.js +207 -0
  169. package/dist/sdk/workspace-contracts.d.ts +3 -0
  170. package/dist/sdk/workspace-contracts.js +3 -2
  171. package/dist/types.d.ts +23 -0
  172. package/dist/types.js +2 -2
  173. package/docs/AGENT_PROVENANCE_ADR.md +41 -5
  174. package/docs/CONFIGURATION.md +4 -0
  175. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +19 -2
  176. package/docs/MERGE_SAFETY.md +15 -1
  177. package/docs/README.md +2 -0
  178. package/docs/READ_OUTPUT_CONTRACTS.md +11 -1
  179. package/docs/RELEASING.md +40 -21
  180. package/docs/REPRODUCIBLE_WORKSPACES.md +42 -8
  181. package/docs/SCRIPTING.md +62 -3
  182. package/docs/SDK.md +17 -0
  183. package/docs/SDK_AGENT_SESSION_CONTEXT.md +6 -4
  184. package/docs/SDK_EVIDENCE_TRACEABILITY.md +1 -1
  185. package/docs/TESTING.md +75 -8
  186. package/docs/agent-task-token-baseline.json +2 -2
  187. package/docs/generated/AGENT_CAPABILITY_ROUTING.md +17 -0
  188. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -1
  189. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  190. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +355 -0
  191. package/marketplace.json +2 -2
  192. package/package.json +2 -2
  193. package/packages/pm-beads/package.json +1 -1
  194. package/packages/pm-calendar/package.json +1 -1
  195. package/packages/pm-command-kit/README.md +9 -11
  196. package/packages/pm-command-kit/extensions/command-kit/index.ts +3 -1
  197. package/packages/pm-command-kit/package.json +1 -1
  198. package/packages/pm-digital-twin/package.json +1 -1
  199. package/packages/pm-governance-audit/package.json +1 -1
  200. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +10 -0
  201. package/packages/pm-guide-shell/package.json +1 -1
  202. package/packages/pm-kanban/package.json +1 -1
  203. package/packages/pm-lifecycle-hooks/package.json +1 -1
  204. package/packages/pm-linked-test-adapters/package.json +1 -1
  205. package/packages/pm-search-advanced/package.json +1 -1
  206. package/packages/pm-templates/package.json +1 -1
  207. package/packages/pm-todos/package.json +1 -1
  208. package/packages/pm-vcs/package.json +1 -1
  209. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  210. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  211. package/scripts/generate-agent-capability-surfaces.mjs +27 -1
  212. package/sdk/public-surface.json +642 -28
  213. package/dist/cli-bundle/chunks/chunk-EMWDM5FI.js +0 -13
  214. package/dist/cli-bundle/chunks/chunk-HYG6LRL4.js +0 -200
  215. package/dist/cli-bundle/chunks/chunk-QI2CT3IX.js +0 -2
  216. package/dist/cli-bundle/chunks/chunk-SMWXHMVB.js +0 -35
  217. package/dist/cli-bundle/chunks/chunk-VMMIL3SI.js +0 -2
  218. package/dist/cli-bundle/chunks/chunk-YBPJAOQQ.js +0 -3
  219. package/dist/cli-bundle/chunks/register-mutation-HTKEEGRD.js +0 -20
  220. package/dist/cli-bundle/chunks/register-operations-6EMRWJJY.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-2AZT5WXZ.js +0 -2
  222. package/dist/cli-bundle/focused-chunks/chunk-3LKU6PTJ.js +0 -4
  223. package/dist/cli-bundle/focused-chunks/chunk-5SHSBMX2.js +0 -2
  224. package/dist/cli-bundle/focused-chunks/chunk-C4S4A4JJ.js +0 -5
  225. package/dist/cli-bundle/focused-chunks/chunk-L5LDSRO2.js +0 -155
  226. package/dist/cli-bundle/focused-chunks/chunk-MB37AYN6.js +0 -26
  227. package/dist/cli-bundle/focused-chunks/chunk-MCOR37QK.js +0 -2
  228. package/dist/cli-bundle/focused-chunks/chunk-PH2OXXVZ.js +0 -18
  229. package/dist/cli-bundle/focused-chunks/chunk-WZE4LIPW.js +0 -8
@@ -1,2 +0,0 @@
1
- import{cc as z,dc as K,fc as S,ic as B,jb as P,kc as F,lc as L}from"./chunk-BWX4SK46.js";import{b as x}from"./chunk-U6GQ4VMV.js";import{Bj as D,C as c,E as d,Ej as G,Mb as k,Ng as C,Pg as U,Yd as N,aa as $,al as j,gl as v,r as O}from"./chunk-HYG6LRL4.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]="687855bf-7432-5691-a809-1f0406b5d8a8")}catch{}})();import ie 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]="07876c03-63a8-5c69-9c6c-c3446076a382")}catch{}})();var b=["op","id","reason","options"],J=[...b,"ref"],W=["schema_version","mutations"],Q="[a-z][a-z0-9._-]{0,63}",Y=new RegExp(`^${Q}$`,"u"),ee=new RegExp(`(^|,)id=@(${Q})(?=,|$)`,"gu"),q=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),E=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],te=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),se=new Set([...te,"completed_at","id"]),_=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...O,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]),V={create:D.map(e=>e.target),update:G.map(e=>e.target),close:j.map(e=>q(e.flag)).filter(e=>e!=="reason"),release:v.map(e=>q(e.flag))};function lt(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new d("createCompensation must be close or delete.",c.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let o=e[r];if(o===void 0)continue;let i=typeof o=="number"||typeof o=="string"&&o.trim().length>0?Number(o):Number.NaN;if(!Number.isSafeInteger(i)||i<=0)throw new d(`${r} must be a positive safe integer.`,c.USAGE);t[r]=i}return t}function p(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function g(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let o of t){let i=$(e,o,n);i!==null&&(r===void 0||i<r.distance)&&(r={key:o,distance:i})}return r?.key}function y(e,t,n){let r=g(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}"?`,c.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 R(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}`,c.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 ae(e,t){if(!p(e))throw new d(`Mutation ${t+1} must be an object.`,c.USAGE);for(let n of Object.keys(e))if(!b.includes(n))throw y(`mutation ${t+1}`,n,b);return e}function ce(e,t,n){if(e!==void 0){if(!p(e))throw new d(`Mutation ${n+1} options must be an object.`,c.USAGE);for(let r of Object.keys(e))if(!V[t].includes(r))throw y(`mutation ${n+1} ${t} options`,r,V[t]);return e}}function de(e,t){let n=ae(e,t),{op:r,id:o,reason:i}=n;if(r!=="create"&&r!=="update"&&r!=="close"&&r!=="release")throw new d(`Mutation ${t+1} op must be create, update, close, or release.`,c.USAGE);let s=ce(n.options,r,t);if(typeof o!="string"||o.trim().length===0)throw new d(`Mutation ${t+1} requires a non-empty id.`,c.USAGE);let a=o.trim();if(r==="close"){if(typeof i!="string"||i.trim().length===0)throw new d(`Mutation ${t+1} close requires a non-empty reason.`,c.USAGE);return{op:r,id:a,reason:i.trim(),...s===void 0?{}:{options:s}}}if(r==="release")return{op:r,id:a,...s===void 0?{}:{options:s}};if(!p(s))throw new d(`Mutation ${t+1} ${r} requires an options object.`,c.USAGE);return{op:r,id:a,options:s}}function ne(e){let t=R(e,"Mutation batch"),n=Array.isArray(t)?t:p(t)&&Array.isArray(t.mutations)?t.mutations:void 0;if(n===void 0||n.length===0)throw new d("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",c.USAGE);return n.map((r,o)=>de(r,o))}function ue(e,t,n){let r=ie.createHash("sha256").update(e).update("\0").update(t).digest("hex"),o=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${C(n)}${o}`}function H(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}".`,c.USAGE);return r}function X(e,t){if(typeof e!="string")return e;let n=e.replace(ee,(r,o,i)=>{let s=t[i];if(s===void 0)throw new d(`Unknown mutation reference "@${i}".`,c.USAGE);return`${o}id=${s}`});if(/(^|,)id=@/u.test(n))throw new d(`Malformed mutation reference in dependency "${e}".`,c.USAGE);return n}function pe(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(ee)].map(t=>t[1]).filter(t=>t!==void 0)}function fe(e){let t=new Map;for(let i of e){if(i.op!=="create"||typeof i.ref!="string")continue;let s=p(i.options)?i.options:{},a=Array.isArray(s.dep)?s.dep:s.dep===void 0?[]:[s.dep];t.set(i.ref,[s.parent,s.blockedBy,...a].flatMap(pe))}let n=new Set,r=new Set,o=i=>{if(n.has(i))throw new d(`Mutation reference cycle includes "@${i}".`,c.USAGE);if(!r.has(i)){n.add(i);for(let s of t.get(i))t.has(s)&&o(s);n.delete(i),r.add(i)}};for(let i of t.keys())o(i)}function le(e){let t=R(e,"Mutation document"),n=Array.isArray(t)?{schema_version:1,mutations:t}:t;if(!p(n))throw new d("Mutation document must be a JSON array or object.",c.USAGE);for(let r of Object.keys(n))if(!W.includes(r))throw y("mutation document",r,W);if(n.schema_version!==void 0&&n.schema_version!==1)throw new d("Mutation document schema_version must be 1.",c.USAGE);if(!Array.isArray(n.mutations)||n.mutations.length===0)throw new d("Mutation document requires a non-empty mutations array.",c.USAGE);return n.mutations.map((r,o)=>{if(!p(r))throw new d(`Mutation ${o+1} must be an object.`,c.USAGE);for(let i of Object.keys(r))if(!J.includes(i))throw y(`mutation ${o+1}`,i,J);return{...r}})}function me(e,t){let n=Object.create(null);for(let[r,o]of e.entries())if(o.ref!==void 0){if(o.op!=="create")throw new d(`Mutation ${r+1} ref is only valid for create operations.`,c.USAGE);if(typeof o.ref!="string"||!Y.test(o.ref))throw new d(`Mutation ${r+1} ref must match ${Y.source}.`,c.USAGE);if(n[o.ref]!==void 0)throw new d(`Duplicate mutation ref "${o.ref}".`,c.USAGE);n[o.ref]=typeof o.id=="string"&&o.id.trim().length>0?U(o.id,t.idPrefix):ue(t.transactionId,o.ref,t.idPrefix)}return n}function mt(e,t){let n=le(e),r=me(n,t);fe(n);let o=n.map(a=>{let u={...a},m=typeof u.ref=="string"?u.ref:void 0;if(delete u.ref,m!==void 0?u.id=r[m]:u.id=H(u.id,r),p(u.options)){let f={...u.options};for(let w of["parent","blockedBy"])f[w]!==void 0&&(f[w]=H(f[w],r));Array.isArray(f.dep)?f.dep=f.dep.map(w=>X(w,r)):f.dep!==void 0&&(f.dep=X(f.dep,r)),u.options=f}return u}),i=ne(JSON.stringify(o)),s=i.filter(a=>a.op==="create").map(a=>a.id);if(new Set(s).size!==s.length)throw new d("Duplicate resolved create id in mutation document.",c.USAGE);return{schema_version:1,mutations:i,references:r}}function re(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 ye(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(p))throw new d(`${n} must be an array of objects.`,c.USAGE);return e.map(r=>re(r,t))}}function he(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 Z(e,t,n=!1){let r=[["dependencies","dep",["id","kind","created_at","author","source_kind"]],["comments","comment",["text","created_at","author"]],["notes","note",["text","created_at","author"]],["learnings","learning",["text","created_at","author"]],["files","file",["path","scope","note"]],["tests","test",["command","scope","timeout_seconds"]],["docs","doc",["path","scope","note"]],["reminders","reminder",["at","text","created_at"]],["events","event",["start_at","end_at","title","location"]],["type_options","typeOption",["key","value"]]];for(let[o,i,s]of r){let a=t[o],u=ye(n&&["comments","notes","learnings"].includes(o)&&Array.isArray(a)?a.filter(m=>!p(m)||m.created_at===void 0):a,s,o);u!==void 0&&u.length>0&&(e[i]=u)}}function we(e,t){for(let n of Object.keys(e)){if(t){if(!E.includes(n))throw y("item envelope",n,E);continue}if(!_.has(n)&&g(n,[..._])===void 0&&g(n,E)==="item")throw y("item envelope",n,E)}}function _e(e){let t=Object.hasOwn(e,"item");we(e,t);let n=t?e.item:e;if(!p(n))throw new d("Item document item must be an object.",c.USAGE);return{item:n,...t&&p(e.linked)?{linked:e.linked}:{}}}function Ee(e,t,n,r){if(!(r==="update"?se:te).has(t)){if(!_.has(t)){if(g(t,[..._])!==void 0)throw y("item document",t,[..._]);let s=Array.isArray(e.field)?e.field:[];s.push(re({key:t,value:typeof n=="string"?n:JSON.stringify(n)},["key","value"])),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(i,s)=>s.toUpperCase())]=he(t,n))}}function yt(e,t,n={}){let r=R(e,"Item document");if(!p(r))throw new d("Item document must be a JSON object.",c.USAGE);let{item:o,linked:i}=_e(r),s={};for(let[a,u]of Object.entries(o))Ee(s,a,u,t);return Z(s,o,t==="update"),i!==void 0&&Z(s,i),{...s,...Object.fromEntries(Object.entries(n).filter(([,a])=>a!==void 0)),stdinJson:void 0}}function ht(e){return ne(JSON.stringify(e))}import ge from"node:crypto";import Ae 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]="ed638747-7a72-5332-87fc-c82088457b91")}catch{}})();async function l(e,t){try{let r=(await P(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(n){if(n instanceof d&&n.exitCode===c.NOT_FOUND)return;throw n}}function I(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ge.createHash("sha256").update(k(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function Te(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function h(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}async function A(e,t,n,r){let o=await N(Ae.join(e,"history",`${t}.jsonl`),t),i=h(n,r,"apply"),s=h(n,r,"compensate");for(let a=o.length-1;a>=0;a-=1){let u=o[a].message;if(u===i)return!0;if(u===s)return!1}return!1}async function M(e,t){let n=await l(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`,c.NOT_FOUND);return{target_updated_at:n.updatedAt}}async function T(e,t,n,r){let o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r.target_updated_at:void 0;typeof o=="string"&&await l(e.pmRoot,t)!==void 0&&await L(t,o,{force:!0,author:e.author,message:h(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot})}function oe(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"create"}}},async apply(){let o=(await z({...t.options,author:e.author,id:t.id},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"create"}},async compensate(){let r=await l(e.pmRoot,t.id);if(r!==void 0){if(e.createCompensation==="delete"){await F(t.id,{force:!0,author:e.author,message:`Compensate interrupted bulk transaction ${e.transactionId}`},{pmRoot:e.pmRoot});return}r.closedAt===void 0&&await S(t.id,`Compensated: interrupted bulk transaction ${e.transactionId}`,{force:!0,author:e.author},{pmRoot:e.pmRoot})}}}}function Se(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await K(t.id,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"update"}},async compensate(r){await T(e,t.id,n,r)}}}function be(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(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 M(e.pmRoot,t)},async apply(){let o=(await S(t.id,t.reason,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"close"}},async compensate(r){await T(e,t.id,n,r)}}}function Re(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(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 M(e.pmRoot,t)},async apply(){let o=(await B(t.id,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"release"}},async compensate(r){await T(e,t.id,n,r)}}}function Ie(e,t,n){let r=I(t,n);switch(t.op){case"create":return oe(e,t,r);case"update":return Se(e,t,r);case"close":return be(e,t,r);case"release":return Re(e,t,r)}}function Me(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`)}async function Oe(e){let t=[...e.mutations];if(t.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");for(let[s,a]of t.entries())Me(a,s);let n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let r={pmRoot:e.pmRoot,author:e.author,transactionId:e.transactionId,createCompensation:n},o=await x({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,steps:t.map((s,a)=>Ie(r,s,a)),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),i={};for(let[s,a]of t.entries()){let u=I(a,s),m=o.results[u];i[Te(a,s)]=m}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:i}}function $e(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 It(e){return Oe({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:$e(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Mt={buildCreateStep:oe,bulkHistoryMarker:h,compensateByRestore:T,deriveStepId:I,isUpdateMarkerApplied:A,readItemSnapshot:l};export{lt as a,ne as b,mt as c,yt as d,ht as e,Oe as f,$e as g,It as h,Mt as i};
2
- //# sourceMappingURL=chunk-QI2CT3IX.js.map