@unbrained/pm-cli 2026.11.10 → 2026.11.12

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 (190) hide show
  1. package/.agents/skills/pm-test-audit/SKILL.md +2 -1
  2. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +2 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/AGENTS.md +2 -2
  5. package/CHANGELOG.md +31 -0
  6. package/CONTRIBUTING.md +1 -1
  7. package/README.md +1 -1
  8. package/dist/cli/commander-usage.js +2 -2
  9. package/dist/cli/error-guidance.js +3 -3
  10. package/dist/cli/help-json-payload.js +1 -1
  11. package/dist/cli/main.js +4 -4
  12. package/dist/cli/register-mutation.js +2 -2
  13. package/dist/cli/register-operations.js +1 -1
  14. package/dist/cli/runtime/refusal-credential-redaction.js +2 -0
  15. package/dist/cli-bundle/bundle-manifest.json +1 -1
  16. package/dist/cli-bundle/chunks/{chunk-BSJSGDA3.js → chunk-2DUUL53Z.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-YSWD2NXB.js → chunk-2K6GJUW7.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-TBBWPEF5.js → chunk-3DWEBVIK.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-L4WWG2H6.js → chunk-5NGGI7JC.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-U7LILCUN.js → chunk-5NY6EQSX.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-X7NM5HVQ.js → chunk-6ESY4Y2B.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-CZETQYKO.js → chunk-A7L5IEYV.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-5CAMQHEW.js → chunk-EALO2FPM.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-7NAAW5EX.js → chunk-FJNHTBJ2.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-FOT5K5OM.js +124 -0
  26. package/dist/cli-bundle/chunks/{chunk-F7P2NZEG.js → chunk-GDS4DC5A.js} +47 -43
  27. package/dist/cli-bundle/chunks/{chunk-F6FBGLR7.js → chunk-GLPUIQDB.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-4FLAKTZW.js → chunk-KJL42AN5.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-FYD6LSJA.js → chunk-L3SA3354.js} +2 -2
  30. package/dist/cli-bundle/chunks/chunk-MR3CRLA7.js +2 -0
  31. package/dist/cli-bundle/chunks/{chunk-NZAFLDSH.js → chunk-OBTU2BHJ.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-4AASUCHO.js → chunk-OFIXSWJS.js} +2 -2
  33. package/dist/cli-bundle/chunks/chunk-PS2YAPXC.js +9 -0
  34. package/dist/cli-bundle/chunks/{chunk-WNEUWDUE.js → chunk-PZI6CR24.js} +46 -46
  35. package/dist/cli-bundle/chunks/{chunk-NNE63MSM.js → chunk-T4UC3ZKL.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-EHDGHFMJ.js → chunk-U7MZIX3D.js} +2 -2
  37. package/dist/cli-bundle/chunks/chunk-UTNPDAID.js +31 -0
  38. package/dist/cli-bundle/chunks/{chunk-OJ2KEDUX.js → chunk-UY7Z3ZHQ.js} +2 -2
  39. package/dist/cli-bundle/chunks/{item-revision-M7KXLQXF.js → item-revision-SYJT6TVZ.js} +2 -2
  40. package/dist/cli-bundle/chunks/item-transaction-YXZ27UC6.js +2 -0
  41. package/dist/cli-bundle/chunks/{mutation-admission-374UR7NI.js → mutation-admission-T57TAVWI.js} +2 -2
  42. package/dist/cli-bundle/chunks/{register-list-query-GSB7PP5P.js → register-list-query-5XZXTPNG.js} +2 -2
  43. package/dist/cli-bundle/chunks/register-mutation-V6WJFL77.js +20 -0
  44. package/dist/cli-bundle/chunks/register-operations-5RAWXY2F.js +2 -0
  45. package/dist/cli-bundle/chunks/{register-setup-QDZ2Y3CI.js → register-setup-HCKCSQWQ.js} +2 -2
  46. package/dist/cli-bundle/chunks/{stage-67WGPKPH.js → stage-VIDXGF3T.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-PAGW6A2X.js → chunk-3FN4ON2Z.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-5OCUNAQN.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-AIYJHVKV.js +44 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-QHGGO7SY.js → chunk-AXPRCCYM.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-BB2GMKRB.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-QCHCEFTO.js → chunk-BHYGUVAU.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-GAXO2UQX.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-3K2MYE7R.js → chunk-GB2N4OM7.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-HTMQDNVC.js → chunk-GBW2EAAG.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-ZBOCYFBE.js → chunk-HIKZYZ26.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-IPIFI4NT.js +3 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-KN7RBRRH.js +26 -0
  59. package/dist/cli-bundle/focused-chunks/{chunk-3DWNH72D.js → chunk-LAIN47EJ.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-2SQUWQP3.js → chunk-MK7UQEE5.js} +18 -18
  61. package/dist/cli-bundle/focused-chunks/{chunk-LY3JXL25.js → chunk-NP5C2TQM.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-RFMKS7VD.js → chunk-NSOXVVQX.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-WJHDUON5.js → chunk-NY65XTX7.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-67M7E2Z3.js → chunk-P6KYUJD4.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/chunk-RXY6BFRW.js +2 -0
  66. package/dist/cli-bundle/focused-chunks/{chunk-2Y4H4LIX.js → chunk-SPAEZKVA.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/chunk-TZO6L523.js +2 -0
  68. package/dist/cli-bundle/focused-chunks/{chunk-BE2GK2G7.js → chunk-VUNX6NBR.js} +53 -53
  69. package/dist/cli-bundle/focused-chunks/{item-revision-XC4ZJ7MY.js → item-revision-PWJNBW3F.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{item-transaction-CVGK4RJP.js → item-transaction-T6HXC3NS.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{mutation-admission-N27D5H64.js → mutation-admission-CLPOLSXZ.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{stage-KPK2UHVO.js → stage-EKYWEU2Y.js} +2 -2
  73. package/dist/cli-bundle/main.js +32 -32
  74. package/dist/cli-bundle/sdk-authoring.js +1 -1
  75. package/dist/cli-bundle/sdk-contracts.js +2 -2
  76. package/dist/cli-bundle/sdk-core.js +1 -1
  77. package/dist/cli-bundle/sdk-governance.js +1 -1
  78. package/dist/cli-bundle/sdk-graph.js +1 -1
  79. package/dist/cli-bundle/sdk-merge.js +57 -57
  80. package/dist/cli-bundle/sdk-query.js +1 -1
  81. package/dist/cli-bundle/sdk-runtime.js +1 -1
  82. package/dist/cli-bundle/sdk-testing.js +1 -1
  83. package/dist/cli-bundle/sdk.js +12 -12
  84. package/dist/core/item/parse.d.ts +13 -1
  85. package/dist/core/item/parse.js +4 -4
  86. package/dist/core/sentry/instrument.js +1 -1
  87. package/dist/core/shared/secret-rules.d.ts +18 -2
  88. package/dist/core/shared/secret-rules.js +4 -2
  89. package/dist/core/shared/url-credentials.d.ts +37 -0
  90. package/dist/core/shared/url-credentials.js +2 -0
  91. package/dist/core/telemetry/runtime.js +2 -2
  92. package/dist/sdk/agent/command-recovery.js +1 -1
  93. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  94. package/dist/sdk/cli-contracts/completeness.js +1 -1
  95. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  96. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  97. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  98. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  99. package/dist/sdk/command-line.d.ts +1 -1
  100. package/dist/sdk/command-line.js +1 -1
  101. package/dist/sdk/completion/bash.js +1 -1
  102. package/dist/sdk/completion/fish.js +3 -1
  103. package/dist/sdk/completion/zsh.js +3 -1
  104. package/dist/sdk/docs.d.ts +14 -2
  105. package/dist/sdk/docs.js +1 -1
  106. package/dist/sdk/files.d.ts +14 -2
  107. package/dist/sdk/files.js +1 -1
  108. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  109. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  110. package/dist/sdk/governance/boundary-fixtures.d.ts +25 -0
  111. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  112. package/dist/sdk/governance/defect-recurrence.d.ts +8 -1
  113. package/dist/sdk/governance/defect-recurrence.js +2 -2
  114. package/dist/sdk/guide-topics.js +1 -1
  115. package/dist/sdk/index.d.ts +1 -1
  116. package/dist/sdk/index.js +1 -1
  117. package/dist/sdk/lifecycle/dependency-removal.js +2 -0
  118. package/dist/sdk/lifecycle/item-revision.js +1 -1
  119. package/dist/sdk/lifecycle/start-blockers.d.ts +9 -0
  120. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  121. package/dist/sdk/lifecycle/update.d.ts +10 -4
  122. package/dist/sdk/lifecycle/update.js +2 -2
  123. package/dist/sdk/linked-artifacts.d.ts +73 -3
  124. package/dist/sdk/linked-artifacts.js +2 -2
  125. package/dist/sdk/public-surface.json +1 -1
  126. package/dist/sdk/runtime/actions.js +1 -1
  127. package/dist/sdk/test/command-args.js +1 -1
  128. package/dist/sdk/test/execution.d.ts +15 -3
  129. package/dist/sdk/test/execution.js +2 -2
  130. package/docs/AGENT_GUIDE.md +2 -2
  131. package/docs/AGENT_UX_CONTRACTS.md +7 -1
  132. package/docs/BUILD_AND_RELEASE_ACCEPTANCE.md +1 -1
  133. package/docs/CODEX_PLUGIN.md +2 -1
  134. package/docs/COMMANDS.md +16 -9
  135. package/docs/CONFIGURATION.md +16 -0
  136. package/docs/CORPUS_SHAPES.md +1 -1
  137. package/docs/DEFECT_RECURRENCE.md +20 -1
  138. package/docs/MUTATION_INTEGRITY.md +65 -0
  139. package/docs/ONBOARDING.md +1 -1
  140. package/docs/README.md +8 -8
  141. package/docs/SDK.md +46 -0
  142. package/docs/SDK_CONTEXT_INTEGRITY.md +2 -0
  143. package/docs/TESTING.md +1 -1
  144. package/docs/generated/FLAG_LEXICON_BUDGETS.md +6 -6
  145. package/marketplace.json +1 -1
  146. package/package.json +9 -1
  147. package/packages/pm-beads/package.json +1 -1
  148. package/packages/pm-calendar/package.json +1 -1
  149. package/packages/pm-command-kit/package.json +1 -1
  150. package/packages/pm-digital-twin/package.json +1 -1
  151. package/packages/pm-governance-audit/package.json +1 -1
  152. package/packages/pm-guide-shell/package.json +1 -1
  153. package/packages/pm-kanban/package.json +1 -1
  154. package/packages/pm-lifecycle-hooks/package.json +1 -1
  155. package/packages/pm-linked-test-adapters/package.json +1 -1
  156. package/packages/pm-search-advanced/package.json +1 -1
  157. package/packages/pm-templates/package.json +1 -1
  158. package/packages/pm-todos/package.json +1 -1
  159. package/packages/pm-vcs/package.json +1 -1
  160. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  161. package/plugins/pm-claude/package.json +1 -1
  162. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  163. package/plugins/pm-codex/package.json +1 -1
  164. package/plugins/pm-codex/plugin.json +1 -1
  165. package/runtime-dependencies.json +1 -1
  166. package/dist/cli-bundle/chunks/chunk-D727C4RO.js +0 -122
  167. package/dist/cli-bundle/chunks/chunk-T2MNRM3S.js +0 -9
  168. package/dist/cli-bundle/chunks/chunk-UFPLZ6LZ.js +0 -2
  169. package/dist/cli-bundle/chunks/chunk-UL64P6MR.js +0 -31
  170. package/dist/cli-bundle/chunks/item-transaction-4N5P34GO.js +0 -2
  171. package/dist/cli-bundle/chunks/register-mutation-ZBF6ITYK.js +0 -20
  172. package/dist/cli-bundle/chunks/register-operations-PWF6GOHE.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-56MIAFEN.js +0 -24
  174. package/dist/cli-bundle/focused-chunks/chunk-ALLOWZSH.js +0 -2
  175. package/dist/cli-bundle/focused-chunks/chunk-LWMPQRJT.js +0 -2
  176. package/dist/cli-bundle/focused-chunks/chunk-NZQYHPUN.js +0 -3
  177. package/dist/cli-bundle/focused-chunks/chunk-QK7FX4O5.js +0 -44
  178. package/dist/cli-bundle/focused-chunks/chunk-U7HWWEJ2.js +0 -2
  179. package/dist/cli-bundle/focused-chunks/chunk-UIZVD36C.js +0 -2
  180. package/dist/cli-bundle/focused-chunks/chunk-WK773UVA.js +0 -2
  181. package/docs/CHATGPT_CODEX_PLUGIN_IMPLEMENTATION.md +0 -776
  182. package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +0 -167
  183. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +0 -246
  184. package/docs/PR_REVIEW_LOOP.md +0 -96
  185. package/docs/RELEASE_LEDGER_RECONCILIATION.md +0 -148
  186. package/docs/RELEASE_RELIABILITY.md +0 -147
  187. package/docs/RELEASING.md +0 -805
  188. package/docs/performance/corpus-shape-comparison.json +0 -1
  189. package/docs/performance/latest-scale-report.json +0 -1
  190. package/docs/performance/scale-100k-report.json +0 -1
@@ -1,2 +0,0 @@
1
- import{b as ye}from"./chunk-4AASUCHO.js";import{$c as ge,Bd as g,Cd as v,Fc as pe,Gb as x,Gc as _e,Hb as k,Nb as he,gb as T,hb as re,ib as B,jb as se,kb as ce,nb as ae,ob as de,pb as le,qb as fe,rb as ue,sb as me,tb as N}from"./chunk-D727C4RO.js";import{Fa as X,Ha as J,N as V,Na as Q,Ta as Z,Ui as oe,W as Y,Wb as p,Xd as te,fi as ie,pd as ee,qe as I,re as b,uf as ne,za as j}from"./chunk-WNEUWDUE.js";import{A as u,C as l,z as W}from"./chunk-O4ZLEN4T.js";import{readdir as Pe}from"node:fs/promises";import H 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]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function D(e,t){return(t===void 0?void 0:J(e,t))?.execution_role??j[e.trim().toLowerCase()]??"agent"}var O="blocked_by",Ie="blocks",Ae=Object.freeze([O,Ie]),A="no-active-blocker";function a(e){return e.trim().toLowerCase()}function E(e,t){return t?`external:${e}`:`local:${a(e)}`}function _(e){let t=new Map,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(n.length>0&&a(n)!==A){let i=g(n);t.set(E(n,i),i?n:a(n))}for(let i of e.dependencies??[]){let o=typeof i.id=="string"?i.id.trim():"";if(p(i.kind)===O&&o.length>0&&a(o)!==A){let r=g(o)||v(i.source_kind);t.set(E(o,r),r?o:a(o))}}return[...t.values()].sort((i,o)=>i.localeCompare(o))}function C(e){let t=new Map;for(let n of e){let i=a(n.id);i.length!==0&&t.set(i,new Set(_(n)))}for(let n of e){let i=a(n.id);if(i.length!==0)for(let o of n.dependencies??[]){let r=p(o.kind)===Ie&&typeof o.id=="string"?a(o.id):"";if(r.length===0||r===A)continue;let s=t.get(r)??new Set;s.add(i),t.set(r,s)}}return new Map([...t].map(([n,i])=>[n,[...i].sort((o,r)=>o.localeCompare(r))]))}function ve(e,t){let n=a(e.id);return n.length>0?C(t).get(n)??_(e):_(e)}function L(e,t,n,i){let o=e,r=typeof o.id=="string"?i?.get(a(o.id))??ve(o,[...t.values()]):_(e),s=new Set((e.dependencies??[]).filter(c=>p(c.kind)===O&&v(c.source_kind)&&typeof c.id=="string"&&c.id.trim().length>0).map(c=>E(c.id.trim(),!0)));return r.map(c=>{if(g(c)||s.has(E(c,!0)))return{id:c,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let d=t.get(a(c));return d?{id:c,title:d.title,status:d.status,resolved:b(d.status,n)}:{id:c,title:null,status:null,resolved:!1}})}function M(e,t,n){return L(e,t,n)}function De(e,t){let n=new Map(e.map(s=>[a(s.id),s])),i=C(e),o=new Set([...we(t),...t.blocked_statuses]),r=new Set;for(let s of e){let c=I(s.status,t);o.has(c)&&(t.blocked_statuses.has(c)||L(s,n,t,i).some(d=>!d.resolved))&&r.add(a(s.id))}return r}function Oe(e,t,n={},i){let o=[...e.ready,...e.decisions,...e.gates];n.includeContainers===!0&&o.push(...e.containers.filter(s=>s.open_blockers.length===0&&!t.blocked_statuses.has(I(s.item.status,t))));let r={ready:[],decisions:[],gates:[]};for(let s of o){let c=D(s.item.type,i);c==="human"&&n.includeDecisions!==!0?r.decisions.push(s):c==="gate"&&n.includeGates!==!0?r.gates.push(s):r.ready.push(s)}return r}function we(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function Le(e,t,n){let i=[a(e)],o=new Set;for(;i.length>0;){let r=i.pop();if(!o.has(r)){o.add(r);for(let s of t.get(r)??[]){if(!b(s.status,n))return!0;i.push(a(s.id))}}}return!1}function Me(e){let t=new Map,n=new Map,i=new Map,o=C(e);for(let r of e){t.set(a(r.id),r);let s=typeof r.parent=="string"?r.parent.trim():"";if(s.length>0){let c=a(s),d=n.get(c)??[];d.push(r),n.set(c,d)}for(let c of o.get(a(r.id))){let d=a(c),m=i.get(d)??[];m.push(r.id),i.set(d,m)}}return{itemsById:t,childrenByParent:n,blockedByReverse:i,blockerIdsByItem:o}}function He(e,t,n,i){let{itemsById:o,childrenByParent:r,blockedByReverse:s,blockerIdsByItem:c}=Me(t),d=new Set([...we(n),...n.blocked_statuses]),m=new Set(t.filter(f=>!b(f.status,n)).map(f=>a(f.id))),F=[],K=[],S=[],G=[],U=[],q=0;for(let f of e){if(!d.has(I(f.status,n)))continue;q+=1;let z=L(f,o,n,c).filter(h=>!h.resolved),Te=(s.get(a(f.id))??[]).filter(h=>m.has(a(h))).sort((h,Ne)=>h.localeCompare(Ne)),y={item:f,open_blockers:z,unblocks:Te};if(Le(f.id,r,n)){S.push(y);continue}let Be=n.blocked_statuses.has(I(f.status,n));if(z.length===0&&!Be){let h=D(f.type,i);h==="human"?G.push(y):h==="gate"?U.push(y):F.push(y)}else K.push(y)}return{ready:F,blocked:K,containers:S,decisions:G,gates:U,active_count:q,container_count:S.length}}(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]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();(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]="e9b7731d-e6f5-51a8-970b-462c0b728a9c")}catch{}})();function $e(e,t){let n=new Map;for(let i of e){let o=i.external?i.id:t.get(i.id.toLowerCase())?.id??i.id;n.set(i.external?`external:${o}`:`local:${o.toLowerCase()}`,{...i,id:o})}return[...n.values()]}async function P(e,t){let n=H.basename(e),i=(await Pe(H.dirname(e)).catch(o=>{throw pe("Cannot verify the blocker's physical file identity",{exitCode:u.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:o})})).filter(o=>o.toLowerCase()===n.toLowerCase()).sort((o,r)=>+(r===n)-+(o===n)||o.localeCompare(r)).map(o=>H.parse(o).name)[0];if(i===void 0)throw new l(`Blocker canonical file disappeared during identity verification: ${t}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return i}async function ut(e){let t=_(e.metadata);if(t.length===0)return[];let n=new Map([e.metadata.blocked_by,...(e.metadata.dependencies??[]).filter(o=>p(o.kind)==="blocked_by").map(o=>o.id)].filter(o=>typeof o=="string").map(o=>[o.trim().toLowerCase(),o.trim()])),i=new Map;for(let o of t){if(g(o)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(o)||e.metadata.dependencies?.some(c=>c.id.trim()===o&&p(c.kind)==="blocked_by"&&v(c.source_kind)))continue;let r=await x(e.pmRoot,n.get(o),e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(r===null)continue;let s=await k(r,{schema:e.settings.schema});if(r.id=await P(r.itemPath,r.id),s.document.metadata.id!==r.id)throw new l(`Blocker identity differs from its canonical file: ${r.id}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});i.set(o.toLowerCase(),s.document.metadata)}return $e(M({blocked_by:e.metadata.blocked_by,dependencies:e.metadata.dependencies,updated_at:e.metadata.updated_at},i,te(e.settings.schema)),i)}(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]="2ad03a1e-c9fc-5f69-8391-97c1e845ba28")}catch{}})();var xe="item_revision_conflict",Fe=10,Ke=/^[0-9a-f]{64}$/u;function w(e,t){return new l(`Invalid expected revision ${JSON.stringify(e)}: ${t}.`,u.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function ke(e){let t=typeof e=="string"?e.trim().toLowerCase():"";if(!Ke.test(t))throw w(String(e),"the revision is not a 64-character hexadecimal item_hash");return t}function Ge(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw w(String(t),"expected a string");let n=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);if(n.length===0)throw w(t,"the value is empty");return n.map(i=>{let o=i.lastIndexOf("="),r=o===-1?void 0:i.slice(0,o).trim();if(r!==void 0&&r.length===0)throw w(i,"the item id before = is empty");let s=ke(o===-1?i:i.slice(o+1));return r===void 0?{itemHash:s}:{id:r,itemHash:s}})})}async function Ee(e,t){let n=await oe(e),i=X(n,ee()).type_to_folder,o=await x(e,t,n.id_prefix,n.item_format,i);if(o){let{document:r}=await k(o,{schema:n.schema});if(r.metadata.id!==await P(o.itemPath,o.id))throw new l(`Item file ${o.id} embeds the id ${r.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,u.CONFLICT,{code:"item_identity_conflict",item_id:o.id,required:`Repair ${o.id}'s identity first (pm validate reports it; pm restore ${o.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:r.metadata.id,document:r}}try{return{id:(await ye(e,t,n,i)).id,document:W}}catch{throw await he(e,t,n.id_prefix,i)}}function $(e){return Q(e.cwd??process.cwd(),e.pmRoot)}async function Bt(e,t={}){let n=await Ee($(t),e);return{id:n.id,item_hash:ie(n.document)}}async function Ce(e,t,n){let i=[];for(let o of t){let r=o.id??n;if(r===void 0||r.trim().length===0)throw new l("A bare expected revision needs an item to bind to.",u.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});i.push({id:(await Ee(e,r)).id,itemHash:o.itemHash})}return i}function Ue(e){return[...new Set(e.patch.map(t=>{let n=t.path.split("/");return String(n[1]==="metadata"?n[2]:n[1])}))].sort()}async function qe(e,t,n){let i;try{i=await ne(Z(e,t),t)}catch{return}let o=-1;for(let c=i.length-1;c>=0;c-=1){let d=i[c];if(d.after_hash===n){o=c+1;break}if(d.before_hash===n){o=c;break}}if(o===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let r=i.slice(o),s=r.slice(-Fe);return{expected_revision_recorded:!0,changes_since:s.map(c=>({ts:c.ts,op:c.op,author:c.author,fields:Ue(c)})),changes_since_omitted:r.length-s.length}}async function Nt(e,t){if(!R(e))return{};let n=await Re(e,t);return{error_code:xe,expected_revision:String(n.context.expected_revision),current_revision:String(n.context.current_revision),details:n.context.details}}function R(e){return _e(e)&&e.context.code===xe}function At(e){let t=e.find(n=>R(n));if(t!==void 0)throw t}function Dt(){return new l("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",u.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function ze(e,t){if(t===void 0||!R(e)||typeof e.context.item_id!="string"||ue(e))return e;let n=e.context.reason===de;if(!n&&e.context.reason!==ae)return e;let i=me(N(e,new l(e.message,e.exitCode,{...e.context,...le(e.context.item_id,n,t)})));return i.stack=e.stack,i}async function Re(e,t,n){if(!fe(e,t))return e;let i=ze(e,n);if(!R(i)||i.context.details!==void 0)return i;let o=i.context.item_id,r=i.context.expected_revision;if(typeof o!="string"||typeof r!="string")return i;let s;try{s=await qe(t,o,r)}catch{return i}if(s===void 0)return i;let c={expected_revision_recorded:s.expected_revision_recorded,changes_since:s.changes_since.map(m=>({ts:m.ts,op:m.op,author:m.author,fields:[...m.fields]})),changes_since_omitted:s.changes_since_omitted},d=N(i,new l(i.message,i.exitCode,{...i.context,details:c}));return d.stack=i.stack,d}async function Se(e,t,n){try{return{result:await re(e,t),...se(e)}}catch(i){throw e.pmRoot===void 0?i:await Re(i,e.pmRoot,n)}}function We(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",$(e)]}}async function Ot(e,t,n={}){return Se(await Ve(e,n),t,We(n))}async function Ve(e,t={}){let n=$(t),i=e.map(({id:r,itemHash:s})=>({id:r,itemHash:ke(s)})),o=T();return B(o,n,await Ce(n,i)),o}function Lt(e){let t=ce(e);return t===void 0||t.length>0}function Ye(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}var be=new Set(V);function je(e,t={}){let n=e.trim().replace(/\s+/gu,"-"),i=be.has(n)?n:e;if(be.has(i)&&(!ge(i)||i==="deps")&&!Y.has(i))throw Xe(i);if((i==="test"||i==="test-all")&&t.background===!0)throw new l(`--expect-hash cannot guard ${i} --background: the worker runs in another process.`,u.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${i} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function Xe(e){return new l(`--expect-hash guards item writes, and ${e} is not a mutation.`,u.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function Je(e,t){if(t.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let n=e,i=Array.isArray(n.warnings)?n.warnings:[];return{...n,warnings:[...i,...t.map(Ye)]}}async function Mt(e){let t=e.expectHash;if(t!==void 0&&typeof t!="string"&&!(Array.isArray(t)&&t.every(r=>typeof r=="string")))throw w(JSON.stringify(t)??String(t),"expected a string or an array of strings");let n=Ge(t);if(n.length===0)return e.run();je(e.action,{background:e.background===!0||e.options?.background===!0});let i=T();B(i,e.pmRoot,await Ce(e.pmRoot,n,e.defaultId));let o=await Se(i,e.run,e.invocation);return Je(o.result,o.unchecked)}export{D as a,Ae as b,_ as c,C as d,ve as e,M as f,De as g,Oe as h,He as i,ut as j,xe as k,Fe as l,ke as m,Ge as n,Bt as o,Ce as p,qe as q,Nt as r,R as s,At as t,Dt as u,ze as v,Re as w,Se as x,Ot as y,Ve as z,Lt as A,Ye as B,je as C,Xe as D,Mt as E};
2
- //# sourceMappingURL=chunk-UFPLZ6LZ.js.map