@unbrained/pm-cli 2026.9.1 → 2026.9.2

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 (49) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +10 -0
  3. package/dist/cli-bundle/bundle-manifest.json +59 -59
  4. package/dist/cli-bundle/chunks/{chunk-2MC2LCXZ.js → chunk-FZ4Z2J4F.js} +2 -2
  5. package/dist/cli-bundle/chunks/{chunk-6XIIGE7U.js → chunk-T6H5BZCP.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-U45JXJCC.js → chunk-UDW64J2W.js} +2 -2
  7. package/dist/cli-bundle/chunks/chunk-ZLJIFSOE.js +35 -0
  8. package/dist/cli-bundle/chunks/{register-mutation-2MVLRS3J.js → register-mutation-WFQ7MJTX.js} +2 -2
  9. package/dist/cli-bundle/chunks/{register-operations-WCIDXBU3.js → register-operations-JVTI7JPP.js} +2 -2
  10. package/dist/cli-bundle/focused-chunks/{chunk-FWPLDEXF.js → chunk-242AXYB2.js} +2 -2
  11. package/dist/cli-bundle/focused-chunks/{chunk-Y6JJIX6I.js → chunk-O67VDLOT.js} +48 -48
  12. package/dist/cli-bundle/main.js +2 -2
  13. package/dist/cli-bundle/sdk-contracts.js +1 -1
  14. package/dist/cli-bundle/sdk-core.js +1 -1
  15. package/dist/cli-bundle/sdk-governance.js +1 -1
  16. package/dist/cli-bundle/sdk-merge.js +32 -32
  17. package/dist/cli-bundle/sdk-runtime.js +1 -1
  18. package/dist/cli-bundle/sdk-testing.js +1 -1
  19. package/dist/cli-bundle/sdk.js +1 -1
  20. package/dist/core/diagnostics/remediation.js +9 -4
  21. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +14 -2
  22. package/dist/sdk/governance/health.js +77 -11
  23. package/dist/sdk/governance/validate.js +4 -2
  24. package/dist/sdk/merge/index.d.ts +1 -1
  25. package/dist/sdk/merge/index.js +2 -2
  26. package/dist/sdk/merge/receipts.d.ts +24 -0
  27. package/dist/sdk/merge/receipts.js +122 -30
  28. package/docs/CONTEXT_RECOVERY_PRIMITIVES.md +11 -2
  29. package/docs/MERGE_SAFETY.md +16 -2
  30. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  31. package/marketplace.json +2 -2
  32. package/package.json +1 -1
  33. package/packages/pm-beads/package.json +1 -1
  34. package/packages/pm-calendar/package.json +1 -1
  35. package/packages/pm-command-kit/package.json +1 -1
  36. package/packages/pm-digital-twin/package.json +1 -1
  37. package/packages/pm-governance-audit/package.json +1 -1
  38. package/packages/pm-guide-shell/package.json +1 -1
  39. package/packages/pm-kanban/package.json +1 -1
  40. package/packages/pm-lifecycle-hooks/package.json +1 -1
  41. package/packages/pm-linked-test-adapters/package.json +1 -1
  42. package/packages/pm-search-advanced/package.json +1 -1
  43. package/packages/pm-templates/package.json +1 -1
  44. package/packages/pm-todos/package.json +1 -1
  45. package/packages/pm-vcs/package.json +1 -1
  46. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  47. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  48. package/sdk/public-surface.json +29 -6
  49. package/dist/cli-bundle/chunks/chunk-ALKKAUFN.js +0 -35
@@ -1,4 +1,4 @@
1
- import{n as Bm,o as Co,p as Jm,q as Xm,r as na,s as xo,t as Qm,u as ra,v as Oo,y as gu,z as yu}from"./focused-chunks/chunk-KB5OFSFD.js";import{a as ku,f as Su,h as Bt,m as Cu,o as Ru,r as Iu,s as xu,t as Ou,x as Pu}from"./focused-chunks/chunk-FWPLDEXF.js";import{$ as Da,$a as Ua,Aa as af,Ba as cf,Ca as df,Da as lf,Ea as mf,Fa as Pn,H as ar,I as w,J as $p,Ja as dr,K as Dp,Ka as uf,L as Me,La as pf,Lb as Pf,M as Up,Ma as ff,Mb as $f,N as Pa,Na as _f,Nb as Df,O as Gp,Oa as ds,Ob as Uf,P as La,Pa as hf,Q as as,Qa as ls,R as Na,S as Yt,T as Fa,Ta as gf,U as ke,V as Ma,W as $e,Wa as yf,X as jp,Xa as ms,Y as qp,Ya as lv,Z as $a,Za as bf,_ as Kp,_a as wf,a as ua,ab as vf,b as gp,bb as kf,cb as Sf,db as Ef,eb as Af,fb as Tf,gb as lr,ha as zp,hb as Ga,i as Pp,ib as ja,j as Lp,ja as cr,jb as us,ka as Bp,kb as qa,la as cs,lb as Cf,ma as Vp,mb as Ka,na as Hp,nb as ps,oa as Wp,ob as Ln,pa as Yp,pb as za,qa as Jp,qb as Ba,ra as Xp,rb as Rf,sa as Qp,sb as If,ta as Zp,tb as xf,ua as ef,ub as Nn,va as tf,vb as Va,wa as nf,wb as Of,xa as rf,ya as of,za as sf,zb as fs}from"./focused-chunks/chunk-Y6JJIX6I.js";import{e as qm,g as Km,h as zm,k as Vm,q as Ym}from"./focused-chunks/chunk-4O4CJAR6.js";import{b as bu,c as Po,e as wu,f as vu,g as Hw}from"./focused-chunks/chunk-SVXJYD6G.js";import{H as ma,L as hu,a as Ll,b as Nl,c as Fl,d as Ml,f as $l}from"./focused-chunks/chunk-BEVHCEWG.js";import{a as fp,b as _p,c as gs}from"./focused-chunks/chunk-PF3E6Q36.js";import{P as Mp,b as hp,j as Fp}from"./focused-chunks/chunk-S4U5CN5Q.js";import{$a as Xa,G as ct,I as Ha,Qa as Ja,Va as pr,Xa as Mf,c as Aa,e as Ta,g as pp,k as Tp,l as Cp,m as Rp,n as Ip,o as xp,ob as fr,p as Op,pb as Qa,q as mr,ta as mv,ua as Wa,v as _s,va as Ya,w as Nf,wa as hs,x as ur,xa as uv,y as Ff,ya as pv}from"./focused-chunks/chunk-7VATS5QY.js";import{a as Lu,b as Nu,c as Fu}from"./focused-chunks/chunk-MEASX544.js";import{$a as Fn,A as yp,B as ve,D as at,E as bp,F as Qo,G as Ot,H as de,I as In,J as Zo,K as es,N as ts,O as ns,Oa as On,P as wp,Pa as Sp,Q as rs,Qa as Oa,R as os,Ra as Ep,S as xn,T as xa,U as ss,Va as Ap,W as vp,X as kp,Xa as ys,Y as or,a as ap,b as Ko,c as Ca,d as cp,e as dp,f as lp,g as mp,h as up,i as zo,j as Bo,k as Vo,l as Ho,p as Wo,q as xt,r as Cn,s as Yo,t as Rn,u as Jo,v as oe,w as Xo,x as Ra,y as Ke,z as Ia}from"./focused-chunks/chunk-MKHG3T76.js";import{c as Um,f as Gm,g as jm,i as To,j as Tt,k as Zm,l as eu,m as tu}from"./focused-chunks/chunk-2FEZ5SKM.js";import{$ as um,A as to,Aa as Pm,B as Vl,Ba as uo,C as Hl,Ca as Lm,D as Wl,Da as Nm,E as no,Ea as Fm,F as Yl,Fa as po,G as Jl,Ga as fo,H as Xl,Ha as _o,I as ro,Ia as ho,J as oo,Ja as Zn,K as Ql,Ka as go,L as so,La as Mm,Ma as er,N as Zl,Na as yo,O as Xn,Oa as bo,P as em,Pa as wo,Q as tm,Qa as vo,R as nm,Ra as $m,S as rm,Sa as At,T as om,Ta as ko,U as sm,Ua as So,V as im,Va as Eo,W as am,Wa as Ao,X as cm,Y as dm,Z as lm,Za as Dm,_ as mm,aa as pm,ab as N,ba as fm,ca as Qn,d as Zi,da as _m,e as Dl,ea as hm,fa as io,ga as ao,h as Ul,ha as gm,i as ea,ia as ym,j as zt,ja as bm,ka as wm,l as Gl,la as vm,ma as km,na as Sm,oa as Em,q as ta,qa as Am,ra as Tm,s as Qr,sa as Cm,t as Zr,ta as Rm,u as eo,ua as Im,v as jl,va as xm,w as ql,wa as co,x as Kl,xa as lo,y as zl,ya as mo,z as Bl,za as Om}from"./focused-chunks/chunk-JEFKLWMM.js";import{c as Lf}from"./focused-chunks/chunk-RMRCQPWU.js";import{Ab as U,Ba as Wu,Bb as H,Db as ce,Eb as op,F as Mo,Fb as qo,G as Du,Gb as it,H as Uu,Hb as sp,I as wn,Ib as ne,J as tr,Ja as qe,Jb as ip,K as Qw,Ka as Rt,Kb as xe,L as Zw,M as ev,Ma as jo,Mb as Np,N as tv,Na as En,Nb as sr,O as nv,Ob as ir,P as rv,Pa as Ht,Pb as Pt,Q as ov,Qa as Yu,R as sv,Ra as nr,S as iv,T as $o,U as av,Ub as is,V as cv,Va as ka,W as dv,X as vn,Xa as Ju,Y as C,Ya as Wt,Z as k,_a as Sa,a as Mu,aa as kn,bb as Xu,c as $u,ca as te,cb as Qu,da as be,db as Je,e as pa,f as fa,fb as Zu,g as _a,ga as Gu,gb as ep,h as ha,ha as Do,hb as T,i as ga,ia as ju,ib as Ie,j as ya,ja as qu,jb as tp,k as ba,ka as Ku,kb as np,l as I,la as zu,lb as It,m as yn,ma as Bu,mb as Ea,n as Vt,nb as we,o as Y,oa as Q,ob as rr,p as No,q as bn,qa as ee,ra as Uo,sa as wa,t as Fo,ta as Go,ua as je,ub as An,v as Ge,va as Ye,w as Ww,wa as Sn,wb as Tn,x as Yw,xa as Vu,y as Jw,ya as Hu,yb as rp,z as Xw,za as va,zb as R}from"./focused-chunks/chunk-T2LXXSOD.js";import{C as Xi,D as Wn,E as ye,H as O,Ha as Jr,I as he,Ia as Pl,J as Hr,Ja as Xr,K as _n,L as Yn,M as gl,Ma as ot,N as E,O as yl,Oa as Ro,P as nt,Pa as st,Q as ae,Qa as Ct,R as Kt,Ra as Hm,T as Re,Ta as $,U as Wr,Ua as Io,Va as We,Xa as Wm,_ as hn,aa as bl,ca as Qi,da as wl,fa as vl,h as St,ha as Yr,i as Br,j as Vr,ja as kl,ka as Sl,ma as El,na as Al,oa as Tl,pa as Cl,qa as Rl,r as P,ra as Il,s as qt,sa as xl,t as Et,u as q,v as _e,x as fn}from"./focused-chunks/chunk-QDFJIRKN.js";import{b as Lo,h as Eu,i as Au,l as gn,p as Tu}from"./focused-chunks/chunk-6GCRSLPG.js";import{$a as Uw,A as ul,B as pl,C as fl,D as _l,E as zi,F as Bi,Fa as Nw,G as Vi,Ga as Fw,H as Hi,Ha as Mw,I as Wi,Ia as $w,J as Yi,Ka as uu,L as zr,Oa as pu,R as Ji,T as hl,Ta as aa,W as kt,Y as d,Z as l,_a as Dw,aa as V,ba as rt,ca as Ol,ea as Jn,ia as nu,ja as ru,jb as Gw,ka as ou,l as jr,la as su,lb as jw,m as dl,ma as iu,mb as qw,n as qr,na as au,nb as ca,o as Ki,oa,ob as da,pa as cu,pb as la,qb as fu,ra as du,s as jt,sa as lu,sb as _u,t as tt,tb as Kw,u as un,v as pn,va as sa,vb as zw,w as Kr,wa as mu,wb as Bw,xa as ia,xb as Vw,y as ll,z as ml}from"./focused-chunks/chunk-Z2USIBR2.js";import{AsyncLocalStorage as pM}from"node:async_hooks";(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]="27dd77f6-e53d-55b7-be15-db0e60eaec4e")}catch{}})();function Gf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fv(e){return e.brief===!0?"brief":typeof e.fields=="string"&&e.fields.trim().length>0||Array.isArray(e.fields)&&e.fields.length>0?"fields":e.compact===!0?"compact":"full"}function Za(e,t){let n=fv(t),r=n==="brief"?n:Gf(e.projection)&&typeof e.projection.mode=="string"?e.projection.mode:n;return{...e,query_summary:{filters:Gf(e.filters)?e.filters:{},projection:r}}}(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]="6ede8efb-54ec-5b13-a1bf-216b525acc12")}catch{}})();async function jf(e,t){let n=E(t??process.cwd(),e),r=await T(n);return ce(n,r.item_format,O(r,null).type_to_folder,void 0,r.schema)}(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]="10052b6f-216f-5b50-81ec-ee373cc13d17")}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]="7c898a52-eba4-5626-8207-5ffefd4990ba")}catch{}})();var _v=new Map;function ec(){_v.clear()}(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]="1ff4005f-be23-5dcf-9834-dbd7d083b76d")}catch{}})();var hv={"list-all":{action:"list",options:{excludeTerminal:!1}},"list-draft":{action:"list",options:{status:"draft",excludeTerminal:!1}},"list-open":{action:"list",options:{status:"open",excludeTerminal:!1}},"list-in-progress":{action:"list",options:{status:"in_progress",excludeTerminal:!1}},"list-blocked":{action:"list",options:{status:"blocked",excludeTerminal:!1}},"list-closed":{action:"list",options:{status:"closed",excludeTerminal:!1}},"list-canceled":{action:"list",options:{status:"canceled",excludeTerminal:!1}}};function qf(e){return Object.fromEntries(du.map(t=>[`${e}-${t}`,{action:e,options:{[t==="adopt-all"?"adoptAll":t]:!0,...e==="package"?{vocabulary:"package"}:{}}}]))}var Kf={ctx:{action:"context"},...hv,...qf("extension"),...qf("package"),...Object.fromEntries(lu.map(e=>[`package-${e}`,{action: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]="41012e87-ed61-56b2-8505-8f786b3952b2")}catch{}})();var tc="PmCliError";function gv(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=d.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function zf(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new l(e,gv(t.exitCode??d.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function bs(e){if(!(e instanceof Error)||e.name!==tc)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}(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]="ff13ec2a-64a8-5512-973f-5447be945978")}catch{}})();function nc(e){let t=vl();for(let n of e)t.register(n);return t}function Bf(e,t){return{client:t,isItemNotFoundError:n=>bs(n)&&n.exitCode===d.NOT_FOUND,getItemAt:(n,r)=>pp(n,r,{pmRoot:e}),openRelationshipEventStore:n=>_p.open({pmRoot:e,nodes:n.nodes,registry:nc(n.definitions),...n.relativePath===void 0?{}:{relativePath:n.relativePath}}),createRelationshipGraph:n=>new Sl(n.nodes,n.edges,nc(n.definitions)),analyzeRelationshipImpact:(n,r,o)=>hp(n,r,o),validateRelationshipEvents:n=>{let r=new fp(n.nodes,{registry:nc(n.definitions)});return n.events.map(o=>r.append({...o,expectedVersion:r.version}))},commitWorkspaceTransaction:n=>gp({...n,pmRoot:e})}}import{readFile as yv}from"node:fs/promises";import bv 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]="1a7548f2-93a0-5dfc-9d9a-c5aef4656c7c")}catch{}})();var rc="context-intents.json";function ws(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wv(e,t,n){if(!ws(e))throw new TypeError(`${t} context intent at index ${String(n)} must be an object`);let r=e.included_field_groups;if(typeof e.command!="string"||typeof e.intent!="string"||typeof e.description!="string"||!Array.isArray(r)||!r.every(o=>typeof o=="string")||typeof e.token_budget!="number")throw new TypeError(`${t} context intent at index ${String(n)} has an invalid contract shape`);return{command:e.command,intent:e.intent,description:e.description,included_field_groups:r,token_budget:e.token_budget}}function Vf(e,t){let n=Array.isArray(e)?e:ws(e)&&Array.isArray(e.intents)?e.intents:void 0;if(!n)throw new TypeError(`${t} context intents must be an array or an object with an intents array`);return n.map((r,o)=>wv(r,t,o))}async function vv(e){let t=bv.join(e,rc),n;try{n=await yv(t,"utf8")}catch(o){if(qt(o))return[];throw await rp(e),o}let r;try{r=JSON.parse(n)}catch(o){let s=o instanceof Error?o.message:String(o);throw new TypeError(`Invalid ${rc}: ${s}`,{cause:o})}return Vf(r,rc)}function kv(e){if(!ws(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return ws(n)?n.contextIntents??n.context_intents:void 0}function Sv(e){return e.flatMap(t=>{let n=kv(t.module);return n===void 0?[]:Vf(n,`package ${t.name}`)})}async function Ev(e){let t=await vv(e.pmRoot),n=Sv(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function oc(e,t){let n=await Ev(e);return await Au(n,t)}(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]="b4b1f63b-12f9-574c-8e92-a5cc9c6178c1")}catch{}})();async function Hf(e,t,n){if(t.body===void 0)throw new l("Missing required --body text",d.USAGE);let r=Ot(),o=E(process.cwd(),n.path);await R(o);let s=await T(o),i=C(t.author,s.author_default),c=(await r.resolveValue(t.body,"--body",bp(t,"body"))).trim();if(c.length===0)throw new l("--body text cannot be empty; append requires non-blank content and empty appends would only rewrite updated_at.",d.USAGE,{code:"append_empty_body",required:"Provide non-empty body text positionally, via --body, or with - for stdin.",examples:['pm append pm-a1b2 --body "Progress note"',"pm append pm-a1b2 --body -"]});let m=await ne({pmRoot:o,settings:s,id:e,op:"append",author:i,message:t.message,force:t.force,mutate(u){let p=u.body.trim().length>0?`
1
+ import{n as Bm,o as Co,p as Jm,q as Xm,r as na,s as xo,t as Qm,u as ra,v as Oo,y as gu,z as yu}from"./focused-chunks/chunk-KB5OFSFD.js";import{a as ku,f as Su,h as Bt,m as Cu,o as Ru,r as Iu,s as xu,t as Ou,x as Pu}from"./focused-chunks/chunk-242AXYB2.js";import{$ as Da,$a as Ua,Aa as af,Ba as cf,Ca as df,Da as lf,Ea as mf,Fa as Pn,H as ar,I as w,J as $p,Ja as dr,K as Dp,Ka as uf,L as Me,La as pf,Lb as Pf,M as Up,Ma as ff,Mb as $f,N as Pa,Na as _f,Nb as Df,O as Gp,Oa as ds,Ob as Uf,P as La,Pa as hf,Q as as,Qa as ls,R as Na,S as Yt,T as Fa,Ta as gf,U as ke,V as Ma,W as $e,Wa as yf,X as jp,Xa as ms,Y as qp,Ya as lv,Z as $a,Za as bf,_ as Kp,_a as wf,a as ua,ab as vf,b as gp,bb as kf,cb as Sf,db as Ef,eb as Af,fb as Tf,gb as lr,ha as zp,hb as Ga,i as Pp,ib as ja,j as Lp,ja as cr,jb as us,ka as Bp,kb as qa,la as cs,lb as Cf,ma as Vp,mb as Ka,na as Hp,nb as ps,oa as Wp,ob as Ln,pa as Yp,pb as za,qa as Jp,qb as Ba,ra as Xp,rb as Rf,sa as Qp,sb as If,ta as Zp,tb as xf,ua as ef,ub as Nn,va as tf,vb as Va,wa as nf,wb as Of,xa as rf,ya as of,za as sf,zb as fs}from"./focused-chunks/chunk-O67VDLOT.js";import{e as qm,g as Km,h as zm,k as Vm,q as Ym}from"./focused-chunks/chunk-4O4CJAR6.js";import{b as bu,c as Po,e as wu,f as vu,g as Hw}from"./focused-chunks/chunk-SVXJYD6G.js";import{H as ma,L as hu,a as Ll,b as Nl,c as Fl,d as Ml,f as $l}from"./focused-chunks/chunk-BEVHCEWG.js";import{a as fp,b as _p,c as gs}from"./focused-chunks/chunk-PF3E6Q36.js";import{P as Mp,b as hp,j as Fp}from"./focused-chunks/chunk-S4U5CN5Q.js";import{$a as Xa,G as ct,I as Ha,Qa as Ja,Va as pr,Xa as Mf,c as Aa,e as Ta,g as pp,k as Tp,l as Cp,m as Rp,n as Ip,o as xp,ob as fr,p as Op,pb as Qa,q as mr,ta as mv,ua as Wa,v as _s,va as Ya,w as Nf,wa as hs,x as ur,xa as uv,y as Ff,ya as pv}from"./focused-chunks/chunk-7VATS5QY.js";import{a as Lu,b as Nu,c as Fu}from"./focused-chunks/chunk-MEASX544.js";import{$a as Fn,A as yp,B as ve,D as at,E as bp,F as Qo,G as Ot,H as de,I as In,J as Zo,K as es,N as ts,O as ns,Oa as On,P as wp,Pa as Sp,Q as rs,Qa as Oa,R as os,Ra as Ep,S as xn,T as xa,U as ss,Va as Ap,W as vp,X as kp,Xa as ys,Y as or,a as ap,b as Ko,c as Ca,d as cp,e as dp,f as lp,g as mp,h as up,i as zo,j as Bo,k as Vo,l as Ho,p as Wo,q as xt,r as Cn,s as Yo,t as Rn,u as Jo,v as oe,w as Xo,x as Ra,y as Ke,z as Ia}from"./focused-chunks/chunk-MKHG3T76.js";import{c as Um,f as Gm,g as jm,i as To,j as Tt,k as Zm,l as eu,m as tu}from"./focused-chunks/chunk-2FEZ5SKM.js";import{$ as um,A as to,Aa as Pm,B as Vl,Ba as uo,C as Hl,Ca as Lm,D as Wl,Da as Nm,E as no,Ea as Fm,F as Yl,Fa as po,G as Jl,Ga as fo,H as Xl,Ha as _o,I as ro,Ia as ho,J as oo,Ja as Zn,K as Ql,Ka as go,L as so,La as Mm,Ma as er,N as Zl,Na as yo,O as Xn,Oa as bo,P as em,Pa as wo,Q as tm,Qa as vo,R as nm,Ra as $m,S as rm,Sa as At,T as om,Ta as ko,U as sm,Ua as So,V as im,Va as Eo,W as am,Wa as Ao,X as cm,Y as dm,Z as lm,Za as Dm,_ as mm,aa as pm,ab as N,ba as fm,ca as Qn,d as Zi,da as _m,e as Dl,ea as hm,fa as io,ga as ao,h as Ul,ha as gm,i as ea,ia as ym,j as zt,ja as bm,ka as wm,l as Gl,la as vm,ma as km,na as Sm,oa as Em,q as ta,qa as Am,ra as Tm,s as Qr,sa as Cm,t as Zr,ta as Rm,u as eo,ua as Im,v as jl,va as xm,w as ql,wa as co,x as Kl,xa as lo,y as zl,ya as mo,z as Bl,za as Om}from"./focused-chunks/chunk-JEFKLWMM.js";import{c as Lf}from"./focused-chunks/chunk-RMRCQPWU.js";import{Ab as U,Ba as Wu,Bb as H,Db as ce,Eb as op,F as Mo,Fb as qo,G as Du,Gb as it,H as Uu,Hb as sp,I as wn,Ib as ne,J as tr,Ja as qe,Jb as ip,K as Qw,Ka as Rt,Kb as xe,L as Zw,M as ev,Ma as jo,Mb as Np,N as tv,Na as En,Nb as sr,O as nv,Ob as ir,P as rv,Pa as Ht,Pb as Pt,Q as ov,Qa as Yu,R as sv,Ra as nr,S as iv,T as $o,U as av,Ub as is,V as cv,Va as ka,W as dv,X as vn,Xa as Ju,Y as C,Ya as Wt,Z as k,_a as Sa,a as Mu,aa as kn,bb as Xu,c as $u,ca as te,cb as Qu,da as be,db as Je,e as pa,f as fa,fb as Zu,g as _a,ga as Gu,gb as ep,h as ha,ha as Do,hb as T,i as ga,ia as ju,ib as Ie,j as ya,ja as qu,jb as tp,k as ba,ka as Ku,kb as np,l as I,la as zu,lb as It,m as yn,ma as Bu,mb as Ea,n as Vt,nb as we,o as Y,oa as Q,ob as rr,p as No,q as bn,qa as ee,ra as Uo,sa as wa,t as Fo,ta as Go,ua as je,ub as An,v as Ge,va as Ye,w as Ww,wa as Sn,wb as Tn,x as Yw,xa as Vu,y as Jw,ya as Hu,yb as rp,z as Xw,za as va,zb as R}from"./focused-chunks/chunk-T2LXXSOD.js";import{C as Xi,D as Wn,E as ye,H as O,Ha as Jr,I as he,Ia as Pl,J as Hr,Ja as Xr,K as _n,L as Yn,M as gl,Ma as ot,N as E,O as yl,Oa as Ro,P as nt,Pa as st,Q as ae,Qa as Ct,R as Kt,Ra as Hm,T as Re,Ta as $,U as Wr,Ua as Io,Va as We,Xa as Wm,_ as hn,aa as bl,ca as Qi,da as wl,fa as vl,h as St,ha as Yr,i as Br,j as Vr,ja as kl,ka as Sl,ma as El,na as Al,oa as Tl,pa as Cl,qa as Rl,r as P,ra as Il,s as qt,sa as xl,t as Et,u as q,v as _e,x as fn}from"./focused-chunks/chunk-QDFJIRKN.js";import{b as Lo,h as Eu,i as Au,l as gn,p as Tu}from"./focused-chunks/chunk-6GCRSLPG.js";import{$a as Uw,A as ul,B as pl,C as fl,D as _l,E as zi,F as Bi,Fa as Nw,G as Vi,Ga as Fw,H as Hi,Ha as Mw,I as Wi,Ia as $w,J as Yi,Ka as uu,L as zr,Oa as pu,R as Ji,T as hl,Ta as aa,W as kt,Y as d,Z as l,_a as Dw,aa as V,ba as rt,ca as Ol,ea as Jn,ia as nu,ja as ru,jb as Gw,ka as ou,l as jr,la as su,lb as jw,m as dl,ma as iu,mb as qw,n as qr,na as au,nb as ca,o as Ki,oa,ob as da,pa as cu,pb as la,qb as fu,ra as du,s as jt,sa as lu,sb as _u,t as tt,tb as Kw,u as un,v as pn,va as sa,vb as zw,w as Kr,wa as mu,wb as Bw,xa as ia,xb as Vw,y as ll,z as ml}from"./focused-chunks/chunk-Z2USIBR2.js";import{AsyncLocalStorage as pM}from"node:async_hooks";(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]="27dd77f6-e53d-55b7-be15-db0e60eaec4e")}catch{}})();function Gf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fv(e){return e.brief===!0?"brief":typeof e.fields=="string"&&e.fields.trim().length>0||Array.isArray(e.fields)&&e.fields.length>0?"fields":e.compact===!0?"compact":"full"}function Za(e,t){let n=fv(t),r=n==="brief"?n:Gf(e.projection)&&typeof e.projection.mode=="string"?e.projection.mode:n;return{...e,query_summary:{filters:Gf(e.filters)?e.filters:{},projection:r}}}(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]="6ede8efb-54ec-5b13-a1bf-216b525acc12")}catch{}})();async function jf(e,t){let n=E(t??process.cwd(),e),r=await T(n);return ce(n,r.item_format,O(r,null).type_to_folder,void 0,r.schema)}(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]="10052b6f-216f-5b50-81ec-ee373cc13d17")}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]="7c898a52-eba4-5626-8207-5ffefd4990ba")}catch{}})();var _v=new Map;function ec(){_v.clear()}(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]="1ff4005f-be23-5dcf-9834-dbd7d083b76d")}catch{}})();var hv={"list-all":{action:"list",options:{excludeTerminal:!1}},"list-draft":{action:"list",options:{status:"draft",excludeTerminal:!1}},"list-open":{action:"list",options:{status:"open",excludeTerminal:!1}},"list-in-progress":{action:"list",options:{status:"in_progress",excludeTerminal:!1}},"list-blocked":{action:"list",options:{status:"blocked",excludeTerminal:!1}},"list-closed":{action:"list",options:{status:"closed",excludeTerminal:!1}},"list-canceled":{action:"list",options:{status:"canceled",excludeTerminal:!1}}};function qf(e){return Object.fromEntries(du.map(t=>[`${e}-${t}`,{action:e,options:{[t==="adopt-all"?"adoptAll":t]:!0,...e==="package"?{vocabulary:"package"}:{}}}]))}var Kf={ctx:{action:"context"},...hv,...qf("extension"),...qf("package"),...Object.fromEntries(lu.map(e=>[`package-${e}`,{action: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]="41012e87-ed61-56b2-8505-8f786b3952b2")}catch{}})();var tc="PmCliError";function gv(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=d.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function zf(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new l(e,gv(t.exitCode??d.USAGE),t.context??{});return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function bs(e){if(!(e instanceof Error)||e.name!==tc)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)}(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]="ff13ec2a-64a8-5512-973f-5447be945978")}catch{}})();function nc(e){let t=vl();for(let n of e)t.register(n);return t}function Bf(e,t){return{client:t,isItemNotFoundError:n=>bs(n)&&n.exitCode===d.NOT_FOUND,getItemAt:(n,r)=>pp(n,r,{pmRoot:e}),openRelationshipEventStore:n=>_p.open({pmRoot:e,nodes:n.nodes,registry:nc(n.definitions),...n.relativePath===void 0?{}:{relativePath:n.relativePath}}),createRelationshipGraph:n=>new Sl(n.nodes,n.edges,nc(n.definitions)),analyzeRelationshipImpact:(n,r,o)=>hp(n,r,o),validateRelationshipEvents:n=>{let r=new fp(n.nodes,{registry:nc(n.definitions)});return n.events.map(o=>r.append({...o,expectedVersion:r.version}))},commitWorkspaceTransaction:n=>gp({...n,pmRoot:e})}}import{readFile as yv}from"node:fs/promises";import bv 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]="1a7548f2-93a0-5dfc-9d9a-c5aef4656c7c")}catch{}})();var rc="context-intents.json";function ws(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wv(e,t,n){if(!ws(e))throw new TypeError(`${t} context intent at index ${String(n)} must be an object`);let r=e.included_field_groups;if(typeof e.command!="string"||typeof e.intent!="string"||typeof e.description!="string"||!Array.isArray(r)||!r.every(o=>typeof o=="string")||typeof e.token_budget!="number")throw new TypeError(`${t} context intent at index ${String(n)} has an invalid contract shape`);return{command:e.command,intent:e.intent,description:e.description,included_field_groups:r,token_budget:e.token_budget}}function Vf(e,t){let n=Array.isArray(e)?e:ws(e)&&Array.isArray(e.intents)?e.intents:void 0;if(!n)throw new TypeError(`${t} context intents must be an array or an object with an intents array`);return n.map((r,o)=>wv(r,t,o))}async function vv(e){let t=bv.join(e,rc),n;try{n=await yv(t,"utf8")}catch(o){if(qt(o))return[];throw await rp(e),o}let r;try{r=JSON.parse(n)}catch(o){let s=o instanceof Error?o.message:String(o);throw new TypeError(`Invalid ${rc}: ${s}`,{cause:o})}return Vf(r,rc)}function kv(e){if(!ws(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return ws(n)?n.contextIntents??n.context_intents:void 0}function Sv(e){return e.flatMap(t=>{let n=kv(t.module);return n===void 0?[]:Vf(n,`package ${t.name}`)})}async function Ev(e){let t=await vv(e.pmRoot),n=Sv(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function oc(e,t){let n=await Ev(e);return await Au(n,t)}(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]="b4b1f63b-12f9-574c-8e92-a5cc9c6178c1")}catch{}})();async function Hf(e,t,n){if(t.body===void 0)throw new l("Missing required --body text",d.USAGE);let r=Ot(),o=E(process.cwd(),n.path);await R(o);let s=await T(o),i=C(t.author,s.author_default),c=(await r.resolveValue(t.body,"--body",bp(t,"body"))).trim();if(c.length===0)throw new l("--body text cannot be empty; append requires non-blank content and empty appends would only rewrite updated_at.",d.USAGE,{code:"append_empty_body",required:"Provide non-empty body text positionally, via --body, or with - for stdin.",examples:['pm append pm-a1b2 --body "Progress note"',"pm append pm-a1b2 --body -"]});let m=await ne({pmRoot:o,settings:s,id:e,op:"append",author:i,message:t.message,force:t.force,mutate(u){let p=u.body.trim().length>0?`
2
2
 
3
3
  `:"";return u.body=`${u.body.trimEnd()}${p}${c}
4
4
  `,{changedFields:["body"]}}});return{item:m.item,appended:c,changed_fields:m.changedFields}}import{readFile as Av}from"node:fs/promises";(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]="6d20a21c-ac67-5712-9f63-b10ffc0e2c64")}catch{}})();function ks(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,ve(e,t)}function Wf(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new l(`Structured context events are append-only and cannot be ${t}.`,d.USAGE,{code:"structured_event_immutable"})}function sc(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function Jt(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Mn(e,t={}){let n=e.trim();if(!n)return"";let r=/^(?:[-*+]\s*)?text\s*[:=]/i.exec(n);if(t.stripPlainTextPrefix===!0&&r&&!n.startsWith("```"))return n.slice(r[0].length).trim()||n;if(!(/^(?:[-*+]\s*)?text\s*[:=]/im.test(n)||n.startsWith("```")))return n;try{let s=oe(n,"--add");return Object.keys(s).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:s.text?.trim()||n}catch{return n}}function ic(e){return typeof e=="object"&&e!==null&&"code"in e}function gr(e,t){if(!at(e))throw new l(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,d.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function Tv(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new l(`Specify ${t} text using only one input source: --add, --stdin, or --file`,d.USAGE);let r=Ot(),o=at(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",o)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return gr(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let s=e.file.trim();if(!s)throw new l("--file path cannot be empty",d.USAGE);if(s==="-")return gr(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await Av(s,"utf8"),emptyFlag:"--file"}}catch(i){if(ic(i)&&qt(i))throw new l(`--file path not found: ${s}. Use --file - to read stdin.`,d.USAGE);let a=i instanceof Error?i.message:String(i);throw new l(`Failed to read --file path "${s}": ${a}. Use --file - to read stdin.`,d.USAGE)}}async function Ss(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new l("Specify only one of --edit or --delete",d.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new l("--delete cannot be combined with replacement text",d.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new l("--delete must be a positive integer",d.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new l("--edit must be a positive integer",d.USAGE);let n=await Tv(e,t);if(e.edit!==void 0){if(!n)throw new l("--edit requires replacement text from --add, --stdin, or --file",d.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function hr(e,t){throw e instanceof l&&e.exitCode===d.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new l(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function Jf(e){return e==="comments"?"--stdin":"--add -"}function Cv(e,t){if((t.input.emptyFlag??"--add")!=="--add")return;let r=e.trim();if(!/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(r))return;let o=Jf(t.collectionKey),s=t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`;throw new l(`--add value "${r}" looks like an option, not annotation text. Use ${o} to read stdin, or use text=${r} for literal dash-leading text.`,d.USAGE,{code:"annotation_flag_like_value",required:`Use ${o} for stdin input, pass plain text, or use text=${r} when the text really starts with "-".`,examples:[`${s} ${o}`,`${s} --add text=${r}`]})}function Rv(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new l(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,d.USAGE,{code:"annotation_if_absent_without_append",required:"Combine --if-absent with one append text source; omit it for list, edit, and delete operations."});if(e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new l(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,d.USAGE,{code:"annotation_message_without_text",required:`Provide ${n} text through a content source; --message only annotates the history entry of a mutation.`,examples:[`pm ${e.collectionKey} <id> --add "text" --message "why"`,`pm ${e.collectionKey} <id> ${Jf(e.collectionKey)}`]})}function Iv(e,t,n,r,o,s){let i=Jt(e.metadata,t),a=o?i.findIndex(c=>c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],entryIndex:a+1}:(i.push(s({created_at:k(),author:n,text:r})),e.metadata[t]=i,{changedFields:[t],entryIndex:i.length})}async function $n(e,t,n,r){Rv(r,t);let o=E(process.cwd(),n.path);await R(o);let s=await T(o),i=O(s,I()),a=or(t.limit);if(r.input.mode==="list"){let h=await U(o,e,s.id_prefix,s.item_format,i.type_to_folder);if(!h)throw new l(`Item ${e} not found`,d.NOT_FOUND);let y=await H(h,{schema:s.schema}),g=Jt(y.document.metadata,r.collectionKey);return vs(h.id,r.collectionKey,g,a,t.includeMeta===!0)}let c=C(t.author,s.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,y;try{y=await ne({pmRoot:o,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(b){let v=Jt(b.metadata,r.collectionKey),S=Yf(r.input.index,v.length,r.collectionKey);return Wf(v[S],"deleted"),v.splice(S,1),b.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(b){hr(b,r.conflictGuidance)}let g=Jt(y.item,r.collectionKey);return vs(y.item.id,r.collectionKey,g,a,t.includeMeta===!0,{action:"delete",entryIndex:r.input.index},t.fullHistory===!0)}let m=r.input.rawValue??r.input.value??"";Cv(m,r);let u=r.parseText(r.input.value??"");if(!u.trim())throw new l(`${r.input.emptyFlag??"--add"} text cannot be empty`,d.USAGE);if(r.input.mode==="edit"){let h=r.editOp??r.op,y;try{y=await ne({pmRoot:o,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(b){let v=Jt(b.metadata,r.collectionKey),S=Yf(r.input.index,v.length,r.collectionKey),A=v[S];return Wf(A,"edited"),v[S]={...A,text:u,edited_at:k()},b.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(b){hr(b,r.conflictGuidance)}let g=Jt(y.item,r.collectionKey);return vs(y.item.id,r.collectionKey,g,a,t.includeMeta===!0,{action:"edit",entryIndex:r.input.index,entry:g[r.input.index-1]},t.fullHistory===!0)}let p,f=0;try{p=await ne({pmRoot:o,settings:s,id:e,op:r.op,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,skipNoop:t.ifAbsent===!0,mutate(h){let y=Iv(h,r.collectionKey,c,u,t.ifAbsent===!0,r.createEntry);return f=y.entryIndex,{changedFields:y.changedFields}}})}catch(h){hr(h,r.conflictGuidance)}let _=Jt(p.item,r.collectionKey);return vs(p.item.id,r.collectionKey,_,a,t.includeMeta===!0,{action:"add",entryIndex:f,entry:_[f-1],changedCount:t.ifAbsent===!0?Math.min(p.changedFields.length,1):void 0},t.fullHistory===!0)}function Yf(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),o=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,s=t===1?`1 ${r}`:`${t} ${n}`;throw new l(`${o} index ${e??"(missing)"} out of range (item has ${s})`,d.USAGE)}return e-1}function xv(e,t,n){return t===void 0?{}:{mutation_receipt:{action:t.action,entry_index:t.entryIndex,changed_count:t.changedCount??1,full_history_included:!n},omission_receipt:{has_omissions:n,omitted_field_group_count:n?1:0,omitted_field_groups:n?[{name:`${e}_history`,restore_with:{selector:"full_history",cli_flag:"--full-history",sdk_option:"fullHistory",mcp_option:"full"}}]:[]}}}function vs(e,t,n,r,o,s,i=!1){let a=s===void 0||i?sc(n,s!==void 0&&i?void 0:r):s.entry===void 0?[]:[s.entry],c=s!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...s?.changedCount===void 0?{}:{changed:s.changedCount===1},...[o,s!==void 0].includes(!0)?{total_count:n.length,returned_count:a.length,has_more:c||a.length<n.length,...r!==void 0?{limit:r}:{}}:{},...xv(t,s,c)}}(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]="d0579277-f123-5f96-8664-dfe05ade1b24")}catch{}})();async function Xf(e,t,n){return[...await Sn(Re(e,t),t).catch(()=>[])].reverse().find(s=>s.patch.some(i=>i.path==="/metadata/assignee"))?.op==="claim"?`claimed by ${n}`:`assigned to ${n}`}(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]="1a61bf25-e320-5adc-8f5a-a427bc89af1a")}catch{}})();var Qf="no_available_next_item";function Zf(e){if(!(e instanceof Error)||e.name!=="PmCliError")return!1;let t=e.context;return typeof t=="object"&&t!==null&&"code"in t&&t.code==="already_claimed_by"}async function Es(e,t,n,r={}){let o=E(process.cwd(),n.path);await R(o);let s=await T(o),i=$(s.schema),a=C(r.author,s.author_default),c=vn(a),m=null,u=!1,p=[],f=await ne({pmRoot:o,settings:s,id:e,op:"claim",author:a,message:r.message,force:t,skipNoop:!0,async mutate(_){let y=_.metadata.assignee??"",g=_.metadata.claim_principal?.trim()||y;if(m=y.trim().length>0?y:null,Wm(_.metadata.status,i)&&!t)throw new l(`Cannot claim terminal item ${_.metadata.id} without --force`,d.CONFLICT);if(m!==null&&g!==c){if(r.ifAvailable===!0)return u=!0,p.push(`claim_skipped_held_by:${m}`),{changedFields:[]};if(!t){let v=await Xf(o,_.metadata.id,y);throw new l(`Item ${_.metadata.id} is already ${v}. Use --force to take over, or --if-available to skip without failing.`,d.CONFLICT,{code:"already_claimed_by",why:"Claim is an atomic test-and-set so parallel agents never proceed believing they own the same item.",nextSteps:["Run pm next to pick a different unclaimed item.","Re-run with --if-available to treat a held item as a no-op skip.","Re-run with --force only when taking over the item is coordinated."]})}p.push(`claim_takeover:${m}->${a}`)}return _.metadata.assignee=a,_.metadata.claim_principal=c,{changedFields:["assignee","claim_principal"],warnings:p}}});return u||await Wa({pmRoot:o,settings:s,principal:c,itemId:f.item.id}),{item:f.item,claimed_by:u&&m!==null?m:a,previous_assignee:m,forced:t,...u?{skipped:!0}:{},...p.length>0?{warnings:p}:{}}}async function e_(e,t,n={},r={}){let o=Ov(n.maxAttempts),s=await T(E(process.cwd(),t.path)),i={...n,author:C(n.author,s.author_default)},a=await pr({...r,callerAuthor:i.author,limit:String(o)},t),c=[a.recommended,...a.ready].filter(m=>m!==null).map(m=>({...m,reasons:"reasons"in m?m.reasons:["ranked ready candidate"]}));return Pv(c.slice(0,o),e,t,i)}function Ov(e){if(e===void 0)return 10;let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>100)throw new l("--max-attempts must be an integer from 1 to 100",d.USAGE);return t}async function Pv(e,t,n,r={},o=Es){let s=0;for(let a of e){s+=1;try{let c=await o(a.id,t,n,r),m={...c,recommendation:a,attempts:s,available:!0};if(!c.skipped)return m}catch(c){if(!Zf(c))throw c}}if(r.ifAvailable===!0)return{available:!1,item:null,claimed_by:C(r.author,""),previous_assignee:null,forced:t,skipped:!0,recommendation:null,attempts:s,warnings:[Qf]};let i=s===0;throw new l(i?"No actionable items matched the selection filters":"No actionable item remained available to claim",i?d.NOT_FOUND:d.CONFLICT,{code:Qf,why:i?"No ready items matched the specified filters or selection criteria.":"Every ranked candidate was claimed by another agent before this atomic selection completed.",nextSteps:[i?"Verify the filters or run pm next to inspect all ready work.":"Run pm claim --next again to refresh the ranked candidate set."]})}async function As(e,t,n,r={}){let o=E(process.cwd(),n.path);await R(o);let s=await T(o),i=C(r.author,s.author_default),a=vn(i),c=r.ownershipReleaseBypass===!0,m=null,u;try{u=await ne({pmRoot:o,settings:s,id:e,op:"release",author:i,message:r.message,force:t,bypassAssigneeConflict:c,mutate(p){return m=p.metadata.assignee??null,!m&&!p.metadata.claim_principal?{changedFields:[]}:(delete p.metadata.assignee,delete p.metadata.claim_principal,{changedFields:["assignee","claim_principal"]})}})}catch(p){hr(p,{required:"For approved non-owner handoffs, prefer the ownership-release bypass before considering --force.",examples:['pm release pm-a1b2 --author "reviewer" --force'],nextSteps:["Use the package-provided ownership-release bypass for handoffs that only clear assignee metadata.","Use --force only when an explicit override is approved for broader ownership conflicts."]})}return await Ya({pmRoot:o,principal:a,itemId:u.item.id}),{item:u.item,released_by:i,previous_assignee:m,forced:t}}(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]="a7ae3c89-b50b-5e4f-8273-8318bc976d84")}catch{}})();var Lv=Object.freeze({requireCloseReason:!0,orderingEdges:"preserve"});function t_(e){let t=[{source:"explicit",value:e.explicit},{source:"duplicate",value:e.duplicateOf===void 0?void 0:`Duplicate of ${e.duplicateOf}`},{source:"resolution",value:e.resolution},{source:"message",value:e.message}];for(let n of t){let r=n.value?.trim();if(r)return{closeReason:r,source:n.source}}return{source:"none"}}function ac(e,t){return cc(e,t,{operation:"close"})}function cc(e,t,n){let r=t_(e);if(!t||r.closeReason!==void 0)return r;let o=n.operation==="create"?[`pm create --title "<title>" --type <type> --status ${n.status??"closed"} --close-reason "<closing summary>"`,`pm create --title "<title>" --type <type> --status ${n.status??"closed"} --resolution "<resolution summary>"`,"pm create --stdin-json < item.json"]:['pm close <id> "Done: <what changed and why>"','pm close <id> --reason "<closing summary>"','pm close <id> -m "<closing summary>"',"pm close <id> --duplicate-of <canonical-id>"];throw new l("Close reason text is required because governance.require_close_reason is enabled",d.USAGE,{code:"close_reason_required",required:"Provide an author-controlled closing summary as the reason, message, resolution, or duplicate target.",why:"governance.require_close_reason is enabled, so tools must not invent immutable closure evidence.",examples:o,nextSteps:[`Re-run the ${n.operation} operation with a closing summary.`,"To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled"]})}function dc(e,t){let n=typeof e.blocked_by=="string"?e.blocked_by.trim():"",r=e.blocked_by!==void 0,o=e.dependencies??[],s=o.filter(m=>m.kind==="blocked_by"),i=e.blocked_reason!==void 0,a=[];if(r&&(delete e.blocked_by,a.push("blocked_by")),i&&(delete e.blocked_reason,a.push("blocked_reason")),t.orderingEdges==="remove"&&s.length>0){let m=o.filter(u=>u.kind!=="blocked_by");m.length>0?e.dependencies=m:delete e.dependencies,a.push("dependencies")}let c=[...new Set([...n?[n]:[],...s.map(m=>m.id)])];return c.length===0?{changedFields:a,warnings:[]}:{changedFields:a,warnings:[t.orderingEdges==="preserve"?`closed_preserved_predecessors:${e.id}:${c.join(",")}`:`closed_removed_predecessors:${e.id}:${c.join(",")}`]}}(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]="9f28f7d8-993b-5201-b606-d1eab0c3ff5c")}catch{}})();var Nv=[{key:"resolution",label:"resolution (--resolution)"},{key:"expected_result",label:"expected_result (--expected-result)"},{key:"actual_result",label:"actual_result (--actual-result)"}];function Fv(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t.length===0||t==="warn")return"warn";if(t==="off"||t==="none"||t==="disabled")return"off";if(t==="strict")return"strict";throw new l(`Invalid --validate-close mode "${e}" (expected "off", "warn", or "strict")`,d.USAGE)}function Mv(e){let t=[];for(let n of Nv){let r=e[n.key];(typeof r!="string"||r.trim().length===0)&&t.push(n)}return t}async function $v(e,t,n){let r=new Set,o=t;for(;typeof o=="string"&&o.trim().length>0;){let s=o.trim();if(s===n)return!0;if(r.has(s))return!1;r.add(s),o=(await e(s))?.duplicate_of}return!1}function Dv(e){return typeof e!="string"||e.trim().length===0}async function Uv(e,t,n,r){let o=n?.trim();if(!o)return;if(o===r)throw new l("An item cannot be closed as a duplicate of itself.",d.USAGE,{code:"duplicate_target_self",why:"--duplicate-of must identify the canonical item that should remain open or already represent the work."});let s=O(t,I()),i=new Map,a=async m=>{if(i.has(m))return i.get(m)??null;let u=await U(e,m,t.id_prefix,t.item_format,s.type_to_folder);if(!u)return i.set(m,null),null;let{document:p}=await H(u,{schema:t.schema});return i.set(m,p.metadata),p.metadata},c=await a(o);if(!c)throw new l(`Duplicate target "${o}" was not found. Create or locate the canonical item first.`,d.USAGE,{code:"duplicate_target_missing",why:"Duplicate closure should point at a real canonical pm item so future dedupe and changelog tooling can trace the relationship.",examples:[`pm close ${r} "Duplicate of ${o}" --duplicate-of ${o}`],nextSteps:["Run pm search/list to find the canonical item, then retry with --duplicate-of <id>."]});if(await $v(a,c.duplicate_of,r))throw new l(`Circular duplicate reference detected. Target "${o}" points back to "${r}".`,d.USAGE,{code:"duplicate_target_circular",why:"Circular duplicate relationships create loops for dedupe and status propagation tooling.",nextSteps:["Choose the existing canonical item, or clear the target duplicate_of metadata before closing this item as a duplicate."]});if(typeof c.duplicate_of=="string"&&c.duplicate_of.trim().length>0)throw new l(`Duplicate target "${o}" is already marked as a duplicate of "${c.duplicate_of.trim()}".`,d.USAGE,{code:"duplicate_target_is_duplicate",why:"Duplicate closure should point directly at the canonical item, not another duplicate.",examples:[`pm close ${r} "Duplicate of ${c.duplicate_of.trim()}" --duplicate-of ${c.duplicate_of.trim()}`],nextSteps:["Use the canonical item referenced by duplicate_of as the --duplicate-of target."]});return c.id}function Gv(e,t,n){return e.filter(r=>r.parent===t&&!ee(r.status,n)).map(r=>r.id).sort((r,o)=>r.localeCompare(o))}function jv(e,t,n){let r=new Map(e.map(a=>[a.id.trim().toLowerCase(),a])),o=Lf(e),s=t.trim().toLowerCase(),i=n.blocked_statuses;return e.filter(a=>i.has(a.status)).map(a=>({item:a,blockerIds:o.get(a.id.trim().toLowerCase())})).filter(({blockerIds:a})=>a.includes(s)).filter(({blockerIds:a})=>a.every(c=>{if(c===s)return!0;let m=r.get(c);return m!==void 0&&ee(m.status,n)})).map(({item:a,blockerIds:c})=>({id:a.id,blocker_ids:c})).sort((a,c)=>a.id.localeCompare(c.id))}async function qv(e,t,n,r,o,s){let i=jv(n,r,s),a=[];for(let c of i)try{let m=await ne({pmRoot:e,settings:t,id:c.id,op:"update",author:o,message:`Auto-unblocked after blocker ${r} closed`,mutate(u){let p=u.metadata.dependencies??[],f=p.filter(h=>{let y=h.id.trim().toLowerCase();return h.kind!=="blocked_by"||!c.blocker_ids.includes(y)});u.metadata.status=s.open_status,delete u.metadata.blocked_by,delete u.metadata.blocked_reason,u.metadata.unblock_note=`Auto-unblocked after blocker ${r} closed; all blockers resolved (${c.blocker_ids.join(", ")}).`,f.length>0?u.metadata.dependencies=f:delete u.metadata.dependencies;let _=["status","blocked_by","blocked_reason","unblock_note"];return f.length!==p.length&&_.push("dependencies"),{changedFields:_}}});a.push(`auto_unblocked:${m.item.id}:resolved_blockers=${c.blocker_ids.join(",")}`)}catch(m){let u=m instanceof Error?m.message.replace(/\s+/g," ").trim():"unknown";a.push(`auto_unblock_failed:${c.id}:${u}`)}return a}function Kv(e,t){let n=[],r=[{option:t.resolution,key:"resolution"},{option:t.expectedResult,key:"expected_result"},{option:t.actualResult,key:"actual_result"}];for(let{option:o,key:s}of r){if(typeof o!="string")continue;let i=o.trim();i.length!==0&&(e[s]=i,n.push(s))}return n}function zv(e,t){if(t===void 0)return[];e.duplicate_of=t;let n=[],r=[{key:"resolution",value:`Duplicate of ${t}`},{key:"expected_result",value:`Canonical item ${t} tracks the work.`},{key:"actual_result",value:`Closed as duplicate of ${t}.`}];for(let{key:o,value:s}of r)Dv(e[o])&&(e[o]=s,n.push(o));return n}function Bv(e,t,n,r){let o=[];if(t!=="off"){let s=Mv(e);if(s.length>0){let i=s.map(a=>a.label);if(t==="strict"){let a=s.map(m=>`--${m.key.replaceAll("_","-")}`),c=["--pm-path",r,"update",e.id,...a.flatMap(m=>[m,"<value>"])];throw new l(`Cannot close item ${e.id}: missing ${i.join(", ")}. Populate fields or use --validate-close warn.`,d.USAGE,{code:"close_validation_missing_fields",recovery:{missing:a,suggested_retry:Lo(c)},nextSteps:["Run the suggested pm update, then retry the original pm close invocation.","Use --validate-close warn only when governance permits an evidenced exception."]})}o.push(`close_validation_missing_fields:${e.id}:${i.join(",")}`)}if(n.length>0){if(t==="strict")throw new l(`Cannot close item ${e.id}: active child items remain open (${n.join(", ")}). Close, cancel, or re-parent them first, or use --validate-close warn.`,d.USAGE);o.push(`close_validation_active_children:${e.id}:${n.join(",")}`)}return o}return n.length>0&&o.push(`closed_with_active_children:${e.id}:${n.join(",")}`),o}function Vv(e,t){return t!==void 0?(e.close_reason=t,["close_reason"]):[]}function Hv(e){return e.assignee===void 0?[]:(delete e.assignee,["assignee"])}function Wv(e,t){if(ee(e.status,t.statusRegistry)&&!t.force)throw new l(`Item ${e.id} is already terminal; use --force to close again.`,d.CONFLICT);let n=Kv(e,t.options),r=zv(e,t.duplicateOf),o=Bv(e,t.validateCloseMode,t.activeChildIds,t.pmRoot);e.status=t.statusRegistry.close_status,e.closed_at=t.closedAt;let s=t.options.completedAt!==void 0||e.completed_at===void 0;s&&(e.completed_at=t.completedAt);let i=["status","closed_at",...s?["completed_at"]:[],...Vv(e,t.closeReason),...n];if(Ep(e)&&(e.plan_mode="completed",i.push("plan_mode")),t.duplicateOf!==void 0){i.push("duplicate_of");for(let c of r)i.includes(c)||i.push(c)}i.push(...Hv(e));let a=dc(e,t.lifecyclePolicy);return i.push(...a.changedFields),o.push(...a.warnings),{changedFields:i,...o.length>0?{warnings:o}:{}}}async function n_(e,t,n,r){let o=E(process.cwd(),r.path);await R(o);let s=await T(o),i=$(s.schema),a=C(n.author,s.author_default),c=O(s,I()).type_to_folder,m=await U(o,e,s.id_prefix,s.item_format,c);if(!m)throw await it(o,e,s.id_prefix,c);let u=await Uv(o,s,n.duplicateOf,m.id),p={requireCloseReason:n.lifecyclePolicy?.requireCloseReason??s.governance.require_close_reason,orderingEdges:n.lifecyclePolicy?.orderingEdges??"preserve"},f=ac({explicit:t,duplicateOf:u,resolution:n.resolution,message:n.message},p.requireCloseReason).closeReason,_=Fv(n.validateClose)??s.governance.close_validation_default,h=await ce(o,s.item_format,c,void 0,s.schema),y=Gv(h,m.id,i),g=k(),b=n.completedAt===void 0?g:te(n.completedAt,new Date(g),"completed-at"),v=await ne({pmRoot:o,settings:s,id:m.id,op:"close",author:a,message:n.message,force:n.force,mutate(S){return Wv(S.metadata,{pmRoot:o,statusRegistry:i,force:n.force,options:n,duplicateOf:u,validateCloseMode:_,activeChildIds:y,closeReason:f,closedAt:g,completedAt:b,lifecyclePolicy:p})}});return{item:v.item,changed_fields:v.changedFields,warnings:[...v.warnings,...await qv(o,s,h,m.id,a,i)]}}function dt(e,t,n,r){return n_(e,t,n,r)}import Yv from"fast-json-patch";import lc from"node:fs/promises";(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]="db5f3a6d-9ae5-5f9b-bedf-766b2b79324c")}catch{}})();function Jv(e,t){return ap(e,t,{errorSubject:"restore",allowFutureTimestamp:!0})}function Xv(e){let t=Ca(e,e.length-1);return Object.keys(t.metadata).length===0?{metadata:{},body:t.body}:Ye(Ht(t))}async function Qv(e,t,n,r){let o=await U(e,t,n.id_prefix,n.item_format,r);if(o){let c=Re(e,o.id),m=await tp({pmRoot:e,settings:n,itemId:o.id,commandLabel:"restore"});return{id:o.id,historyPath:c,located:o,historyPolicyWarnings:m.warnings}}let s=we(t,n.id_prefix),i=Ea(t),a=s===i?[s]:[s,i];for(let c of a){let m=Re(e,c);if(await P(m))return{id:c,historyPath:m,located:null,historyPolicyWarnings:[]}}throw new l(`Item ${t} not found`,d.NOT_FOUND)}function Zv(e,t){let n=nr(e),r=nr(t),o=Yv.compare(n,r),s=new Set;for(let i of o){if(i.path==="/body"||i.path.startsWith("/body/")){s.add("body");continue}let a=i.path.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];s.add(a.replaceAll("~1","/").replaceAll("~0","~"))}return Array.from(s).sort((i,a)=>i.localeCompare(a))}async function ek(e){if(await q(e.subject.historyPath)!==e.historyRawBeforeLock)throw new l(`History for ${e.resolvedId} changed while waiting for lock; retry restore.`,d.CONFLICT);let n=await U(e.pmRoot,e.resolvedId,e.settings.id_prefix,e.settings.item_format,e.typeToFolder),r=n?await H(n,{schema:e.settings.schema}):null;if((r?.raw??null)!==e.currentItemRawBeforeLock)throw new l(`Item ${e.resolvedId} changed while waiting for lock; retry restore.`,d.CONFLICT);return{loadedItemUnderLock:r,existingItemPath:n?.itemPath??null}}function tk(e,t){return e?{document:e.document,originalRaw:e.raw}:{document:Xv(t),originalRaw:null}}function nk(e){let t=e.document.metadata.assignee?.trim();if(!(t&&t!==e.author&&!e.force))return[];if(e.enforcement==="strict")throw new l(`Item ${e.resolvedId} is assigned to ${t}. Use --force to override.`,d.CONFLICT);return e.enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.resolvedId}:${t}`]:[]}async function rk(e){if(e.existingItemPath&&e.resolvedOriginalRaw!==null&&e.restoredItemPath!==e.existingItemPath){await _e(e.existingItemPath,e.resolvedOriginalRaw),await lc.rm(e.restoredItemPath,{force:!0});return}if(e.existingItemPath&&e.resolvedOriginalRaw!==null){await _e(e.existingItemPath,e.resolvedOriginalRaw);return}await lc.rm(e.restoredItemPath,{force:!0})}async function ok(e){return[...await Y({path:e.restoredItemPath,scope:"project",op:"restore",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]}),...await Y({path:e.historyPath,scope:"project",op:"restore:history",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]})]}async function Xt(e,t,n,r){let o=E(process.cwd(),r.path);await R(o);let s=await T(o),i=O(s,I()),a=await Qv(o,e,s,i.type_to_folder),c=a.id,m=await q(a.historyPath),u=await Sn(a.historyPath,c);if(u.length===0)throw new l(`No history exists for ${c}; restore is unavailable.`,d.NOT_FOUND);let p=Jv(t,u),f=cp(Ca(u,p.historyIndex),p),_=Yu(f,{schema:s.schema});if(_.metadata.id!==c)throw new l(`Restore target resolved to item ${_.metadata.id}, expected ${c}.`,d.GENERIC_FAILURE);let y=(a.located?await H(a.located,{schema:s.schema}):null)?.raw??null,g=C(n.author,s.author_default),b=await be(o,c,s.locks.ttl_seconds,g,!!n.force,s.governance.force_required_for_stale_lock,s.locks.wait_ms);try{let{loadedItemUnderLock:v,existingItemPath:S}=await ek({pmRoot:o,resolvedId:c,subject:a,settings:s,typeToFolder:i.type_to_folder,historyRawBeforeLock:m,currentItemRawBeforeLock:y}),A="toon",x=tk(v,u),j=nk({document:x.document,author:g,force:n.force,enforcement:s.governance.ownership_enforcement,resolvedId:c}),M=Zv(x.document,_);await No({pm_root:o,operation:"restore",before:x.document,after:_,changed_fields:M,sdk:qo({pmRoot:o,settings:s,typeToFolder:i.type_to_folder})});let me=je(_,{format:A,schema:s.schema}),W=Kt(o,_.metadata.type,c,A,i.type_to_folder),ge=await An(o,g),ue=[];try{await _e(W,me),S&&W!==S&&await lc.rm(S);let gt=qe({nowIso:k(),author:g,op:"restore",before:x.document,after:_,message:n.message});try{await Rt(a.historyPath,gt)}catch(yt){throw await rk({existingItemPath:S,resolvedOriginalRaw:x.originalRaw,restoredItemPath:W}),yt}ue=await Tn({pmRoot:o,preferredFormat:s.item_format,typeToFolder:i.type_to_folder,schema:s.schema,itemPath:W,previousItemPath:S??void 0,document:_})}finally{await ge()}let Ue=await ok({restoredItemPath:W,historyPath:a.historyPath,before:x.document,after:_});yn({id:_.metadata.id,op:"restore",item_type:_.metadata.type,previous_status:x.document.metadata.status,status:_.metadata.status,previous:Vt(x.document.metadata,M),current:Vt(_.metadata,M),changed_fields:M});let ht=u[p.historyIndex];return{item:_.metadata,restored_from:{kind:p.kind,target:p.raw,history_index:p.historyIndex+1,entry_ts:ht.ts,entry_op:ht.op},changed_fields:M,warnings:[...a.historyPolicyWarnings,...j,...ue,...Ue]}}finally{await b()}}(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]="a97a3cf0-beef-5967-8f5b-2372a6c9f2f7")}catch{}})();var o_=1,mc="close-many",sk=["--filter-status","--filter-type","--filter-tag","--filter-priority","--filter-sprint","--filter-release","--filter-parent","--filter-assignee","--filter-updated-before","--ids"].join(", ");function ik(e,t){return mr(e,t,{includePagination:!1})}function ak(e,t){return mr(e,t)}function ck(e){if(e?.ids!=null&&String(e.ids).trim().length===0)throw new l("--ids requires at least one non-empty item ID",d.USAGE)}function dk(e){let t={};if(!e)return t;for(let[n,r]of Object.entries(e))r==null||typeof r=="string"&&!r.split(",").some(o=>o.trim().length>0)||(t[n]=r);return t}function lk(e,t){let n=String(e??"").trim();if(n.length>0)return n;if(t)throw new l("pm close-many requires a shared close reason via --reason because governance.require_close_reason is enabled.",d.USAGE,{code:"close_reason_required",required:"Provide a shared closing summary via --reason for the whole batch.",why:"governance.require_close_reason is enabled, so every close must record why the items are done.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met"','pm close-many --ids pm-a,pm-b --reason "Superseded by redesign"'],nextSteps:["Re-run with --reason describing the shared outcome.","To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled"]})}async function mk(e,t){let n=$(t.schema),r=O(t,I()),o=await ce(e,t.item_format,r.type_to_folder,void 0,t.schema),s=new Map,i=new Map;for(let a of o){if(typeof a.parent!="string"||a.parent.length===0||(i.set(a.id,a.parent),ee(a.status,n)))continue;let c=s.get(a.parent);c?c.push(a.id):s.set(a.parent,[a.id])}for(let a of s.values())a.sort((c,m)=>c.localeCompare(m));return{childrenByParent:s,parentByChild:i}}function r_(e,t,n){let r=n?.get(e);if(r!==void 0)return r;let o=0,s=t.get(e),i=[],a=new Set,c=!1;for(;s!==void 0&&!a.has(s);){let m=n?.get(s);if(m!==void 0){o+=m+1;break}a.add(s),i.push(s),o+=1,s=t.get(s)}if(s!==void 0&&a.has(s)&&(c=!0),!c){n?.set(e,o);for(let[m,u]of i.entries())n?.set(u,o-m-1)}return o}async function uk(e){let t=await Vo(e.pmRoot,mc,e.rollbackId,o_),n=e.options.message??`Rollback close-many checkpoint ${t.id}`,r=await Ho(t.items,(o,s)=>Xt(o,s,{author:e.options.author,message:n,force:!0},e.global));return{...Bt({applied:r.restored_ids.length,skipped:0,failed:r.failed_count,unmatched:0}),mode:"rollback",matched_count:t.items.length,dry_run:!1,rollback_checkpoint_id:t.id,checkpoint:{id:t.id,created_at:t.created_at,path:t.path,rollback_command:`pm close-many --rollback ${t.id}`},restored_count:r.restored_ids.length,failed_count:r.failed_count,rows:r.rows,ids:r.restored_ids}}function pk(e,t,n,r,o){return e.map(s=>{let i=(t.get(s.id)??[]).filter(c=>!n.has(c)),a=!s_(s,r,o);return{id:s.id,title:typeof s.title=="string"?s.title:"",status:s.status,action:a?"skip":"close",...a?{skip_reason:"already_terminal"}:{},...i.length>0?{active_child_ids:i}:{}}})}async function fk(e){let t=await Bo(e.pmRoot,mc,e.checkpointId,{schema_version:o_,id:e.checkpointId,created_at:e.nowValue,author:C(e.options.author,"unknown"),...e.reason!==void 0?{reason:e.reason}:{},filters:e.filters,items:e.checkpointItems});return{id:e.checkpointId,created_at:e.nowValue,path:t,rollback_command:`pm close-many --rollback ${e.checkpointId}`}}async function _k(e){let t=[],n=[];for(let r of e.matched){if(!e.closableIds.has(r.id)){t.push({id:r.id,status:"skipped",skip_reason:"already_terminal"});continue}try{let o=await dt(r.id,e.reason,e.closeOptions,e.global);t.push({id:r.id,status:"closed",changed_fields:o.changed_fields,...o.warnings&&o.warnings.length>0?{warnings:o.warnings}:{}}),n.push(r.id)}catch(o){t.push({id:r.id,status:"failed",error:hn(o)})}}return{rows:t,closedIds:n}}function hk(e){return typeof e.rollback=="string"?e.rollback:void 0}function gk(e,t){if(t.trim().length===0)throw new l("--rollback requires a checkpoint id",d.USAGE);if(e.dryRun===!0)throw new l("--dry-run cannot be combined with --rollback",d.USAGE);if(ak(e.list,e.status))throw new l("Rollback mode does not accept filter options",d.USAGE)}function yk(e){if(!ik(e.list,e.status))throw new l(`close-many requires at least one filter to scope the close (for example: ${sk}). Refusing to match every item.`,d.USAGE)}function bk(e,t){let n=new Map;return[...e].sort((r,o)=>{let s=r_(o.id,t,n)-r_(r.id,t,n);return s!==0?s:r.id.localeCompare(o.id)})}function s_(e,t,n){return n||!ee(e.status,t)}function wk(e,t,n){return new Set(e.filter(r=>s_(r,t,n)).map(r=>r.id))}async function vk(e){yk(e.options);let t=$(e.settings.schema),n=lk(e.options.reason,e.settings.governance.require_close_reason),r=e.options.force===!0,o=await ct(e.options.status,dk(e.options.list),e.global),{childrenByParent:s,parentByChild:i}=await mk(e.pmRoot,e.settings),a=bk(o.items,i),c=[...new Set(String(e.options.list?.ids??"").split(",").map(f=>f.trim()).filter(f=>f.length>0))],m=c.length===0?[]:(await ct(void 0,{ids:c.join(","),noTruncate:!0,full:!0},e.global)).items,u=new Set(m.map(f=>f.id)),p=wk(a,t,r);return{pmRoot:e.pmRoot,settings:e.settings,statusRegistry:t,reason:n,validateCloseMode:e.options.validateClose,force:r,listed:o,matched:a,unmatchedIds:c.length===0?void 0:c.filter(f=>!u.has(f)),planRows:pk(a,s,p,t,r)}}function kk(e){return{outcome:"effect",exit_code:d.SUCCESS,mode:"dry_run",matched_count:e.matched.length,dry_run:!0,...e.reason!==void 0?{reason:e.reason}:{},filters:e.listed.filters,...e.validateCloseMode?{validate_close:e.validateCloseMode}:{},item_plans:e.planRows,ids:[],...e.unmatchedIds!==void 0?{unmatched_ids:e.unmatchedIds,unmatched_count:e.unmatchedIds.length}:{}}}async function Sk(e){if(e.options.checkpoint===!1||e.closableIds.size===0)return;let t=e.context.matched.filter(n=>e.closableIds.has(n.id)).map(n=>({id:n.id,target_updated_at:n.updated_at}));return fk({pmRoot:e.context.pmRoot,checkpointId:e.checkpointId,nowValue:e.nowValue,options:e.options,reason:e.context.reason,filters:e.context.listed.filters,checkpointItems:t})}async function i_(e,t){let n=E(process.cwd(),t.path);await R(n);let r=await T(n),o=e.dryRun===!0,s=hk(e);if(ck(e.list),s!==void 0)return gk(e,s),uk({pmRoot:n,rollbackId:s,options:e,global:t});let i=await vk({pmRoot:n,settings:r,options:e,global:t});if(o)return kk(i);let a=new Set(i.planRows.filter(b=>b.action==="close").map(b=>b.id)),c=k(),m=zo(mc,c),u=await Sk({context:i,options:e,closableIds:a,checkpointId:m,nowValue:c}),p={author:e.author,message:e.message??`close-many apply ${m}`,completedAt:e.completedAt,validateClose:i.validateCloseMode,force:i.force,resolution:e.resolution,expectedResult:e.expectedResult,actualResult:e.actualResult},{rows:f,closedIds:_}=await _k({matched:i.matched,closableIds:a,reason:i.reason,closeOptions:p,global:t}),h=f.filter(b=>b.status==="closed").length,y=f.filter(b=>b.status==="skipped").length,g=f.filter(b=>b.status==="failed").length;return{...Bt({applied:h,skipped:y,failed:g,unmatched:i.unmatchedIds?.length??0}),mode:"apply",matched_count:i.matched.length,dry_run:!1,...i.reason!==void 0?{reason:i.reason}:{},filters:i.listed.filters,...i.validateCloseMode?{validate_close:i.validateCloseMode}:{},...u?{checkpoint:u}:{},closed_count:h,skipped_count:y,failed_count:g,rows:f,ids:_,...i.unmatchedIds!==void 0?{unmatched_ids:i.unmatchedIds,unmatched_count:i.unmatchedIds.length}:{}}}import{readFile as Ek}from"node:fs/promises";(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]="f761d37b-28df-5176-9e25-762f57aa0abf")}catch{}})();async function uc(e,t){let n=e.add!==void 0,r=e.stdin===!0,o=typeof e.file=="string",s=Number(n)+Number(r)+Number(o);if(s===0)return;if(s>1)throw new l("Specify comment text using only one input source: --add, --stdin, or --file",d.USAGE);if(n)return{value:await t.resolveValue(e.add,"--add",at(e))??"",emptyFlag:"--add"};if(r)return gr(e,"--stdin"),{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};let i=e.file.trim();if(!i)throw new l("--file path cannot be empty",d.USAGE);if(i==="-")return gr(e,"--file -"),{value:await t.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await Ek(i,"utf8"),emptyFlag:"--file"}}catch(a){if(ic(a)&&qt(a))throw new l(`--file path not found: ${i}. Use --file - to read stdin.`,d.USAGE);let c=a instanceof Error?a.message:String(a);throw new l(`Failed to read --file path "${i}": ${c}. Use --file - to read stdin.`,d.USAGE)}}async function Ak(e,t){let n=e.edit,r=e.delete,o=n!==void 0,s=r!==void 0;if(o&&s)throw new l("Specify only one of --edit or --delete",d.USAGE);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw new l("--edit must be a positive integer",d.USAGE);if(r!==void 0&&(!Number.isInteger(r)||r<1))throw new l("--delete must be a positive integer",d.USAGE);if(s){if(await uc(e,t)!==void 0)throw new l("--delete does not take comment text",d.USAGE);return{mode:"delete",index:r}}if(o){let c=await uc(e,t);if(c===void 0)throw new l("--edit requires replacement text via positional [text], --add, --stdin, or --file",d.USAGE);return{mode:"edit",index:n,value:c.value,emptyFlag:c.emptyFlag}}let i=await uc(e,t);return i===void 0?{mode:"list"}:{mode:i.emptyFlag==="--add"?"add":i.emptyFlag==="--stdin"?"stdin":"file",value:i.value,emptyFlag:i.emptyFlag}}async function a_(e,t,n){let r=Ot(),o=await Ak(t,r),s=o.mode==="add"||o.mode==="edit",i=o.value??"";return $n(e,t,n,{input:{...o,rawValue:t.add??i,value:s?Mn(i,{stripPlainTextPrefix:!0}):i},collectionKey:"comments",op:"comment_add",editOp:"comment_edit",deleteOp:"comment_delete",parseText:a=>a,createEntry:a=>a,bypassOwnershipConflict:!!(o.mode==="add"&&t.ownershipAppendBypass),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm comments pm-a1b2 --add "review note" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}})}(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]="972816c9-b407-5b89-a744-249c9771451f")}catch{}})();async function c_(e,t,n){return $n(e,t,n,{input:await Ss(t,"learning"),collectionKey:"learnings",op:"learning_add",editOp:"learning_edit",deleteOp:"learning_delete",parseText:r=>Mn(r),createEntry:r=>r,bypassOwnershipConflict:!!(t.edit===void 0&&t.delete===void 0&&t.ownershipAppendBypass),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm learnings pm-a1b2 --add "review learning" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}})}(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]="216389a2-fb85-56a0-8ef2-9f41f1321c16")}catch{}})();function Tk(e){if(e===void 0)return;if(e.trim().length===0)throw new l("--add-json must contain a JSON value",d.USAGE,{code:"structured_event_json_empty"});let t;try{t=JSON.parse(e)}catch{throw new l("--add-json must be valid JSON",d.USAGE,{code:"structured_event_json_invalid"})}return t}function Ck(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.type;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}function Rk(e){if(e===void 0)return;let t=Date.parse(e);if(!Number.isFinite(t))throw new l("--since must be a valid ISO timestamp",d.USAGE,{code:"structured_event_since_invalid"});return t}async function d_(e,t,n){let r=Tk(t.addJson),o=[t.add!==void 0,t.stdin===!0,t.file!==void 0,t.edit!==void 0,t.delete!==void 0].includes(!0);if(r!==void 0&&o)throw new l("--add-json cannot be combined with text, edit, delete, stdin, or file inputs",d.USAGE,{code:"structured_event_input_conflict"});let s=r===void 0?void 0:V(r),i=[t.since,t.eventType].some(h=>h!==void 0),a=Rk(t.since),c=or(t.limit),m=await $n(e,{...t,...i?{limit:void 0}:{},includeMeta:[t.includeMeta===!0,i].includes(!0)},n,{input:await Ss(s===void 0?t:{add:s},"note"),collectionKey:"notes",op:"note_add",editOp:"note_edit",deleteOp:"note_delete",parseText:h=>Mn(h),createEntry:h=>r===void 0?h:{...h,format:"json",data:r,event_type:Ck(r)},bypassOwnershipConflict:!![t.edit===void 0,t.delete===void 0,t.ownershipAppendBypass===!0].every(Boolean),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm notes pm-a1b2 --add "review note" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}}),u=t.eventType?.trim(),p=m.notes.filter(h=>{let y=[h.format==="json",h.data!==void 0].every(Boolean),g=[a===void 0,Date.parse(h.created_at)>=(a??Number.POSITIVE_INFINITY)].includes(!0),b=[!u,h.event_type===u].includes(!0);return[!i,[y,g,b].every(Boolean)].includes(!0)}),f=i?sc(p,c):p,_=f.filter(h=>h.format==="json").length;return{...m,notes:f,count:f.length,...i?{total_count:p.length,returned_count:f.length,has_more:f.length<p.length,...c===void 0?{}:{limit:c},structured_event_count:_}:t.includeMeta===!0?{structured_event_count:_}:{}}}(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]="d6f359cb-2bc9-5f96-8789-db91512d0bd5")}catch{}})();function yr(e,t,n="--dep"){if(!t&&/[:,=]/.test(e))throw new l(`Invalid ${n} value "${e}". Use a bare item id or id=<id>,kind=<kind>.`,d.USAGE,{code:"dependency_flag_value_invalid",reason:"malformed_dependency_shorthand",flag:n,value:e,required:"Use a bare item id or an explicit id=<id>,kind=<kind> entry."})}function br(e,t,n=Pt()){for(let r of t??[])try{kl(e,r.id,r.kind,n)}catch(o){throw new l(hn(o),d.USAGE,{code:"dependency_edge_not_allowed",why:`${e} -> ${r.id} (${r.kind}) violates the active relationship-kind policy`})}}async function l_(e,t){return(await H(e,{schema:t})).document.metadata.created_at}async function Ik(e,t){if(e.createdAt!==void 0)return e.createdAt;let n=await U(t.pmRoot,e.id,t.idPrefix,t.itemFormat,t.typeToFolder);return n===null?void 0:l_(n,t.schema)}function xk(e){let t=e.registry.require(e.dependency.kind);return new l(`${t.kind} requires source ${e.holder.id} to be created after target ${e.dependency.id}`,d.USAGE,{code:"dependency_temporal_order_invalid",reason:"source_not_after_target",required:`${e.holder.id}.created_at must be later than ${e.dependency.id}.created_at for ${t.kind}.`,why:"Chronological recurrence direction must be validated before the relationship is persisted.",source_id:e.holder.id,source_created_at:e.sourceCreatedAt,target_id:e.dependency.id,target_created_at:e.targetCreatedAt,temporal_order:t.temporalOrder})}async function Ok(e){let t=e.dependencies.filter(o=>e.registry.resolve(o.kind)?.temporalOrder==="source_after_target"&&!e.missingTargets.includes(o.id));if(t.length===0||e.holders.length===0)return;let n=new Map(e.resolutions.flatMap(({target:o,located:s})=>s===null?[]:[[o,s]])),r=new Map(await Promise.all([...new Set(t.map(({id:o})=>o))].map(async o=>[o,await l_(n.get(o),e.context.schema)])));for(let o of e.holders){let s=await Ik(o,e.context);if(s!==void 0)for(let i of t){let a=r.get(i.id),c=Date.parse(s),m=Date.parse(a);if(!(Number.isFinite(c)&&Number.isFinite(m)&&c>m))throw xk({holder:o,dependency:i,sourceCreatedAt:s,targetCreatedAt:a,registry:e.registry})}}}async function Qt(e){let t=e.registry??Pt(),n=(e.dependencies??[]).filter(i=>!Np(i.source_kind)),r=[...new Set(n.map(i=>i.id))],o=await Promise.all(r.map(async i=>({target:i,located:await U(e.pmRoot,i,e.idPrefix,e.itemFormat,e.typeToFolder)}))),s=o.filter(({located:i})=>i===null).map(({target:i})=>i).sort((i,a)=>i<a?-1:1);if(s.length>0&&e.allowUnresolved!==!0)throw new l(`Dependency target${s.length===1?"":"s"} not found: ${s.join(", ")}`,d.NOT_FOUND,{code:"dependency_target_not_found",reason:"unresolved_local_dependency",required:"Every local dependency target must exist before the edge is committed.",why:"Fail-fast target resolution prevents dangling graph nodes and preserves reliable traversal semantics.",unresolved_targets:s,examples:["--dep id=<existing-item-id>,kind=related","--dep id=<external-id>,kind=related,source_kind=external","--allow-unresolved-deps --dep id=<future-item-id>,kind=related"],nextSteps:[`Create or correct ${s.length===1?"the target":"the targets"}, then retry the mutation.`,"Use source_kind=external for a cross-workspace reference.","Use --allow-unresolved-deps only when the dangling local edge is intentional."],recovery:{recovery_mode:"compact",missing:s,suggested_flags:["--allow-unresolved-deps"],suggested_retry:`pm search "${s[0]}" --limit 10`}});return await Ok({dependencies:n,missingTargets:s,resolutions:o,holders:e.holders??[],registry:t,context:e}),s.map(i=>`dependency_target_unresolved:${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]="dcbb6070-7457-5454-abf1-fa8153c8efd6")}catch{}})();function Ts(e){let t=e.trim();return t.toLowerCase()==="med"?"medium":t}function Cs(e){let t=e.trim();return t.toLowerCase()==="med"?"medium":t}function Rs(e){let t=e.trim().toLowerCase();if(t==="med")return"medium";if(Kr.includes(t))return t;let n=de(e,"confidence");if(!Number.isInteger(n)||n<0||n>100)throw new l("Confidence must be an integer 0..100 or one of low|med|medium|high",d.USAGE);return n}function Is(e){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1;throw new l("Regression must be one of true|false|1|0",d.USAGE)}(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]="afc4f3d5-ba5e-5dd7-abc9-531b319cdb4e")}catch{}})();var Pk=new Set(["none","null"]);function xs(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function ze(e){return e===void 0?!1:Pk.has(e.trim().toLowerCase())}function Os(e,t,n){if(!ze(e))return;let r=n?` ${n}`:"";throw new l(`${t} no longer accepts "none" or "null".${r}`.trim(),d.USAGE)}function Se(e,t,n){if(!e||e.length===0||!e.some(s=>ze(s)))return;let o=n?` ${n}`:"";throw new l(`${t} no longer accepts "none" or "null".${o}`.trim(),d.USAGE)}function Ps(e,t){for(let n of t){let r=e[n.optionKey];if(!Array.isArray(r)||r.length===0)continue;if(!r.every(a=>typeof a=="string"))throw new l(`${n.valueFlag} entries must be strings.`,d.USAGE);let o=r;if(!o.some(a=>ze(a)))continue;if(o.filter(a=>!ze(a)).length>0)throw new l(`Cannot mix legacy clear token "none"/"null" with concrete ${n.valueFlag} entries. Use ${n.clearFlag} to clear or provide explicit entries.`,d.USAGE);e[n.optionKey]=void 0,e[n.clearFlagKey]=!0,n.disableFlagKey&&(e[n.disableFlagKey]=!1)}return 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]="2fcfbe50-039b-5031-8b18-a208908a0d87")}catch{}})();function u_(e,t){let n=e.trim().toLowerCase();if(n==="true"||n==="1"||n==="yes")return!0;if(n==="false"||n==="0"||n==="no")return!1;throw new l(`${t} must be one of true|false|1|0|yes|no`,d.USAGE)}function pc(e){return e?e.split("|").map(t=>t.trim()).filter(t=>t.length>0):[]}function Ee(e,t,n){if(!t.includes(e))throw new l(`Invalid ${n} value "${e}". Allowed: ${t.join(", ")}`,d.USAGE);return e}var p_=["recur_freq","recur_interval","recur_count","recur_until","recur_by_weekday","recur_by_month_day","recur_exdates"];function Lk(e,t){return t==="defined"?e!==void 0:!!e}function m_(e,t,n){if(!Lk(e,n))return;let r=de(e,`event ${t}`);if(!Number.isInteger(r)||r<1)throw new l(`--event ${t} must be an integer >= 1`,d.USAGE);return r}function Nk(e,t,n){let r=e?te(e,n,"event.recur_until"):void 0;if(r&&r<t)throw new l("--event recur_until must be at or after start",d.USAGE);return r}function Fk(e){return Array.from(new Set(pc(e).map(t=>Ee(t.toLowerCase(),_l,"event weekday")))).sort((t,n)=>zi(t)-zi(n))}function Mk(e){return Array.from(new Set(pc(e).map(t=>{let n=de(t,"event recur_by_month_day");if(!Number.isInteger(n)||n<1||n>31)throw new l("--event recur_by_month_day values must be integers 1..31",d.USAGE);return n}))).sort((t,n)=>t-n)}function $k(e,t){return Array.from(new Set(pc(e).map(n=>te(n,t,"event.recur_exdates")))).sort((n,r)=>n.localeCompare(r))}function f_(e,t,n,r){let o=e.recur_freq?.trim(),s=e.recur_interval?.trim(),i=e.recur_count?.trim(),a=e.recur_until?.trim(),c=e.recur_by_weekday?.trim(),m=e.recur_by_month_day?.trim(),u=e.recur_exdates?.trim();if(![o,s,i,a,c,m,u].some(S=>S!==void 0))return;if(!o)throw new l("--event recurrence fields require recur_freq=<daily|weekly|monthly|yearly>",d.USAGE);let f=Ee(o.toLowerCase(),fl,"event recurrence frequency"),_=m_(s,"recur_interval",r),h=m_(i,"recur_count",r),y=Nk(a,t,n),g=Fk(c),b=Mk(m),v=$k(u,n);return{freq:f,interval:_,count:h,until:y,by_weekday:g.length>0?g:void 0,by_month_day:b.length>0?b:void 0,exdates:v.length>0?v:void 0}}(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]="8248687e-ba97-5e1b-afbf-a322a72eb1aa")}catch{}})();var __="--event end must be strictly after start. Equal start/end timestamps are treated as an instant event (end is dropped); an end earlier than start is rejected. Omit end for an instant event or set end later than start.",Dk="--event end and duration are mutually exclusive; provide only one (use duration=<relative> like duration=2h, duration=30min, or duration=PT30M, or set an explicit end).",Uk=/^([+-]?)(\d+)(min|mins|minute|minutes)$/i,Gk=/^([+-]?)[Pp][Tt](?:(\d+)[Hh])?(?:(\d+)[Mm])?(?:(\d+)[Ss])?$/,g_=1e3,fc=60*g_,jk=60*fc;function h_(e,t){let n=new Date(e);if(!Number.isFinite(n.getTime()))throw new l(`Invalid event.duration value "${t}". Duration is out of supported timestamp range.`,d.USAGE);return n.toISOString()}function qk(e,t){let n=new Date(e),r=t.trim(),o=Uk.exec(r);if(o){let a=o[1]==="-"?-1:1,c=Number.parseInt(o[2],10)*a;return h_(n.getTime()+c*fc,r)}let s=Gk.exec(r);if(s){let[,a,c,m,u]=s;if(c||m||u){let f=a==="-"?-1:1,_=Number.parseInt(c??"0",10),h=Number.parseInt(m??"0",10),y=Number.parseInt(u??"0",10),g=_*jk+h*fc+y*g_;return h_(n.getTime()+f*g,r)}}let i=r.startsWith("+")||r.startsWith("-")?r:`+${r}`;return te(i,n,"event.duration")}function y_(e,t,n,r){if(t&&n)throw new l(Dk,d.USAGE);if(n){let s=qk(e,n);if(s<e)throw new l(__,d.USAGE);return s===e?void 0:s}if(!t)return;let o=te(t,r,"event.end");if(o<e)throw new l(__,d.USAGE);if(o!==e)return o}(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]="fd41d2bf-7be0-55ee-9048-a9d5092a9a21")}catch{}})();var Kk=["at","date","text","title"],zk=["start","date","end","duration","title","description","location","timezone","all_day",...p_],Bk=["key","value"];function b_(e,t){return t==="trimmed"?e?.trim():e}function Vk(e,t){return t==="defined"?e!==void 0:!!e}function Ls(e,t,n){return e.map(r=>{let o=oe(r,"--reminder");Ke(o,"--reminder",Kk);let s=b_(o.at??o.date,n.valueMode),i=b_(o.text??o.title,n.valueMode);if(!s||!i)throw new l("--reminder requires at=<iso|relative> or date=<iso|relative>, plus text=<value> or title=<value>",d.USAGE);let a=i.trim();if(!a)throw new l("--reminder text must not be empty",d.USAGE);return{at:te(s,t,"reminder.at"),text:a}})}function Ns(e,t,n){return e.map(r=>{let o=oe(r,"--event");Ke(o,"--event",zk);let s=(o.start??o.date)?.trim();if(!s)throw new l("--event requires start=<iso|relative> or date=<iso|relative>",d.USAGE);let i=te(s,t,"event.start"),a=o.end?.trim(),c=o.duration?.trim(),m=y_(i,a,c,t),u=o.title,p=o.description,f=o.location,_=o.timezone,h=u?.trim(),y=p?.trim(),g=f?.trim(),b=_?.trim(),v=[["title",u,h],["description",p,y],["location",f,g],["timezone",_,b]];for(let[j,M,me]of v)if(M!==void 0&&!me)throw new l(`--event ${j} must not be empty`,d.USAGE);let S=o.all_day?.trim(),A=f_(o,i,t,n.recurrenceEmptyNumericGuard),x=Vk(S,n.allDayEmptyGuard)?u_(S,"--event all_day"):void 0;return{start_at:i,end_at:m,title:h,description:y,location:g,all_day:x,timezone:b,recurrence:A}})}function Fs(e){let t={};for(let n of e){let r=n.trim();if(r.length===0)throw new l("--type-option values must not be empty",d.USAGE);let o,s;if(r.includes(",")||r.includes(`
@@ -1,2 +1,2 @@
1
- import{A as ne,Ab as Be,B as oe,Bb as Ce,C as de,Cb as De,D as ae,Db as Ne,E as ue,Eb as Oe,F as se,Fb as Ue,G as fe,Ga as he,Gb as Pe,Ha as we,Hb as je,Ia as ge,Ib as Fe,Jb as qe,Kb as ze,Lb as Je,Mb as _,Nb as Ye,Ob as Ke,Pb as Xe,Qb as Le,Ra as ke,Rb as l,Sa as Ae,Ta as Ee,Ua as Re,Va as Se,aa as pe,ba as ce,c as N,ca as _e,d as O,da as le,e as U,ea as xe,f as P,fa as me,g as j,ga as ve,h as F,ha as be,i as q,ia as ye,j as z,k as J,l as W,m as Z,n as G,o as H,p as V,q as Y,r as K,s as X,t as L,u as Q,v as M,w as ee,x as ie,xb as Te,y as re,yb as Ie,z as te,zb as $e}from"./focused-chunks/chunk-Y6JJIX6I.js";import"./focused-chunks/chunk-4O4CJAR6.js";import"./focused-chunks/chunk-SVXJYD6G.js";import"./focused-chunks/chunk-BEVHCEWG.js";import"./focused-chunks/chunk-S4U5CN5Q.js";import{$a as Ve,Aa as w,Ba as g,Ca as k,Da as A,Ea as E,Ga as R,Ha as S,Ia as T,Ja as I,Ka as $,La as B,Ma as C,Na as D,Xa as We,Ya as Ze,Za as Ge,_a as He,za as h}from"./focused-chunks/chunk-MKHG3T76.js";import"./focused-chunks/chunk-2FEZ5SKM.js";import"./focused-chunks/chunk-JEFKLWMM.js";import{$ as c}from"./focused-chunks/chunk-T2LXXSOD.js";import"./focused-chunks/chunk-QDFJIRKN.js";import"./focused-chunks/chunk-6GCRSLPG.js";import"./focused-chunks/chunk-Z2USIBR2.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new e.Error().stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="3edb1f4f-d26e-51a8-b62a-caffdd3ac44b")}catch{}})();var x=["captured_redacted","captured_verbatim"],m=[{label:"home directory",pattern:/(?:\/home\/|\/Users\/)[^/\s"']+/u},{label:"GitHub token",pattern:/\b(?:gh[oprsu]_[A-Za-z0-9_]{20,})\b/u},{label:"npm token",pattern:/\bnpm_[A-Za-z0-9]{20,}\b/u},{label:"private key",pattern:/-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u}];function n(e){return typeof e=="string"&&e.trim().length>0}function v(e,i){if(typeof i!="object"||i===null||Array.isArray(i))return[{boundary_id:e.id,kind:"invalid_fixture",detail:`${e.fixture_path} must contain a JSON object.`}];let r=i,t=[];r.boundary_id!==e.id&&t.push({boundary_id:e.id,kind:"fixture_boundary_mismatch",detail:`${e.fixture_path} names ${String(r.boundary_id)} instead of ${e.id}.`}),(r.version!==1||!x.includes(r.capture_source)||!n(r.capture_provenance)||!Array.isArray(r.redactions)||!r.redactions.every(n)||!("input"in r)||!("observed"in r))&&t.push({boundary_id:e.id,kind:"invalid_fixture",detail:`${e.fixture_path} lacks captured provenance, redaction metadata, input, or observed output.`});let d=JSON.stringify(i);for(let s of m)s.pattern.test(d)&&t.push({boundary_id:e.id,kind:"unsafe_fixture",detail:`${e.fixture_path} contains a possible ${s.label}.`});return t}function b(e,i){let r=Date.parse(e.waiver_expires_at),t=n(e.waiver_reason)&&n(e.waiver_owner)&&e.waiver_expires_at.endsWith("Z")&&c(e.waiver_expires_at)&&Number.isFinite(r);return{captured:0,waived:t&&r>=i?1:0,findings:t?r<i?[{boundary_id:e.id,kind:"expired_waiver",detail:`Boundary ${e.id} waiver expired at ${e.waiver_expires_at}.`}]:[]:[{boundary_id:e.id,kind:"invalid_waiver",detail:`Boundary ${e.id} waiver requires reason, owner, and an RFC 3339 UTC expiry.`}]}}function y(e,i,r){if(!n(e.id)||!n(e.producer)||!n(e.consumer)||!n(e.format))return{captured:0,waived:0,findings:[{boundary_id:n(e.id)?e.id:"unknown",kind:"invalid_boundary",detail:"Each boundary requires non-empty id, producer, consumer, and format."}]};if("fixture_path"in e){let t=i[e.fixture_path],d=n(e.fixture_path)&&e.fixture_path in i?v(e,t):[{boundary_id:e.id,kind:"missing_fixture",detail:`Boundary ${e.id} fixture ${String(e.fixture_path)} is missing.`}];return{captured:d.length===0?1:0,waived:0,findings:d}}return b(e,r)}function Me(e,i,r=new Date){let t=[];if(e.version!==1||!n(e.inventory_scope)||!Array.isArray(e.boundaries))return{ok:!1,boundary_count:0,captured_count:0,waived_count:0,findings:[{boundary_id:"registry",kind:"invalid_registry",detail:"Boundary registry requires version 1, inventory_scope, and boundaries."}]};let d=new Set,s=0,p=0;for(let o of e.boundaries){if(typeof o!="object"||o===null||Array.isArray(o)){t.push({boundary_id:"unknown",kind:"invalid_boundary",detail:"Each boundary must be a JSON object."});continue}let a=o,u=n(a.id)?a.id:void 0;if(u!==void 0&&d.has(u)){t.push({boundary_id:u,kind:"duplicate_boundary",detail:`Boundary ${u} is inventoried more than once.`});continue}u!==void 0&&d.add(u);let f=y(a,i,r.getTime());s+=f.captured,p+=f.waived,t.push(...f.findings)}return t.sort((o,a)=>o.boundary_id!==a.boundary_id?o.boundary_id.localeCompare(a.boundary_id):o.kind.localeCompare(a.kind)),{ok:t.length===0,boundary_count:e.boundaries.length,captured_count:s,waived_count:p,findings:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new e.Error().stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="ff251826-36f0-5b92-bee8-ca71d265986c")}catch{}})();export{Fe as ASSURANCE_ACTIONS,qe as ASSURANCE_DECLARATION_KINDS,F as ASSURANCE_DOCUMENT_VERSION,q as ASSURANCE_GATE_TRIGGERS,z as ASSURANCE_MEASUREMENT_SOURCE_KINDS,ne as ASSURANCE_PRESET_IDS,O as AssuranceEvaluationRefusalError,N as AssuranceMutationRefusalError,U as AssuranceSourceResolutionError,x as BOUNDARY_FIXTURE_CAPTURE_SOURCES,Ce as DEFECT_ESCAPE_CLASSES,De as DEFECT_GATE_EVIDENCE_DISPOSITIONS,pe as HISTORY_AUTHOR_ATTRIBUTION_BASELINE,h as PM_MUTATION_ACTION_CONTRACTS,Re as _testOnlyHealthCommand,Ze as _testOnlySimilarity,Ie as _testOnlyValidateCommand,Le as _testOnlyWorkspacePosition,ue as acceptAssuranceProposals,ye as acknowledgeUnknownAuthorHistoryEvents,be as acknowledgeUnknownAuthorHistoryEventsFromTransport,Oe as analyzeDefectChangeRisk,de as applyAssurancePreset,J as assuranceAssertionUpdateIsLoosening,Ne as buildDefectRecurrenceIndex,Ae as buildStatusRoleWarnings,ce as classifyHistoryAuthorEvent,oe as createAssurancePreset,Be as createAssuranceWorkspaceContext,V as createEmptyAssuranceDocument,ae as deriveAssuranceProposals,K as evaluateAssuranceAssertion,X as evaluateAssuranceGate,Me as evaluateBoundaryFixtures,Ue as evaluateDefectGateEvidence,Y as evaluateMeasurement,g as evaluateMutationGuard,Ve as evaluateSimilarityGovernance,He as findDuplicateClusters,Ge as findSimilarItems,Xe as formatWorkspacePositionHuman,Q as getAssuranceDeclaration,E as getMutationActionContract,_e as inspectHistoryAuthorStream,C as inspectStaleInProgressItems,ke as inspectStatusRoleAssignments,k as isMutationAction,R as jaccardSimilarity,L as listAssuranceDeclarations,te as listAssuranceVerdicts,we as listInvalidProvenanceHistoryStreamIds,A as listMutationActions,j as normalizeAssuranceEvaluation,P as normalizeAssuranceMutation,he as normalizeInvalidHistoryProvenance,S as normalizeSimilarityText,je as parseDefectChangeRiskRequest,Pe as parseDefectRecurrencePolicy,ve as parseUnknownAuthorHistoryEventCoordinates,xe as planUnknownAuthorHistoryAcknowledgment,I as prepareSimilarityText,Te as projectValidateCounts,se as promoteAssuranceAssertion,M as putAssuranceDeclaration,ee as putAssuranceDeclarationBundle,Ke as readWorkspacePosition,re as recordAssuranceVerdict,ie as removeAssuranceDeclaration,me as resolveUnknownAuthorAcknowledgmentSelector,ze as runAssuranceAction,Je as runAssuranceDispatch,Ye as runGc,Ee as runHealth,l as runReindex,_ as runUpgrade,$e as runValidate,fe as scanExtensionHostVersions,le as scanHistoryAuthorAttribution,w as scanMutationSecrets,ge as scanProvenanceResolverHealth,D as scanStaleInProgressItems,Se as scanStorageIntegrity,$ as scoreItemSimilarity,B as scorePreparedItemSimilarity,We as similarityAdvisoryWarnings,T as tokenizeSimilarityText,Z as validateAssertionDefinition,H as validateAssuranceDocument,G as validateGateDefinition,W as validateMeasurementDefinition};
1
+ import{A as ne,Ab as Be,B as oe,Bb as Ce,C as de,Cb as De,D as ae,Db as Ne,E as ue,Eb as Oe,F as se,Fb as Ue,G as fe,Ga as he,Gb as Pe,Ha as we,Hb as je,Ia as ge,Ib as Fe,Jb as qe,Kb as ze,Lb as Je,Mb as _,Nb as Ye,Ob as Ke,Pb as Xe,Qb as Le,Ra as ke,Rb as l,Sa as Ae,Ta as Ee,Ua as Re,Va as Se,aa as pe,ba as ce,c as N,ca as _e,d as O,da as le,e as U,ea as xe,f as P,fa as me,g as j,ga as ve,h as F,ha as be,i as q,ia as ye,j as z,k as J,l as W,m as Z,n as G,o as H,p as V,q as Y,r as K,s as X,t as L,u as Q,v as M,w as ee,x as ie,xb as Te,y as re,yb as Ie,z as te,zb as $e}from"./focused-chunks/chunk-O67VDLOT.js";import"./focused-chunks/chunk-4O4CJAR6.js";import"./focused-chunks/chunk-SVXJYD6G.js";import"./focused-chunks/chunk-BEVHCEWG.js";import"./focused-chunks/chunk-S4U5CN5Q.js";import{$a as Ve,Aa as w,Ba as g,Ca as k,Da as A,Ea as E,Ga as R,Ha as S,Ia as T,Ja as I,Ka as $,La as B,Ma as C,Na as D,Xa as We,Ya as Ze,Za as Ge,_a as He,za as h}from"./focused-chunks/chunk-MKHG3T76.js";import"./focused-chunks/chunk-2FEZ5SKM.js";import"./focused-chunks/chunk-JEFKLWMM.js";import{$ as c}from"./focused-chunks/chunk-T2LXXSOD.js";import"./focused-chunks/chunk-QDFJIRKN.js";import"./focused-chunks/chunk-6GCRSLPG.js";import"./focused-chunks/chunk-Z2USIBR2.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new e.Error().stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="3edb1f4f-d26e-51a8-b62a-caffdd3ac44b")}catch{}})();var x=["captured_redacted","captured_verbatim"],m=[{label:"home directory",pattern:/(?:\/home\/|\/Users\/)[^/\s"']+/u},{label:"GitHub token",pattern:/\b(?:gh[oprsu]_[A-Za-z0-9_]{20,})\b/u},{label:"npm token",pattern:/\bnpm_[A-Za-z0-9]{20,}\b/u},{label:"private key",pattern:/-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u}];function n(e){return typeof e=="string"&&e.trim().length>0}function v(e,i){if(typeof i!="object"||i===null||Array.isArray(i))return[{boundary_id:e.id,kind:"invalid_fixture",detail:`${e.fixture_path} must contain a JSON object.`}];let r=i,t=[];r.boundary_id!==e.id&&t.push({boundary_id:e.id,kind:"fixture_boundary_mismatch",detail:`${e.fixture_path} names ${String(r.boundary_id)} instead of ${e.id}.`}),(r.version!==1||!x.includes(r.capture_source)||!n(r.capture_provenance)||!Array.isArray(r.redactions)||!r.redactions.every(n)||!("input"in r)||!("observed"in r))&&t.push({boundary_id:e.id,kind:"invalid_fixture",detail:`${e.fixture_path} lacks captured provenance, redaction metadata, input, or observed output.`});let d=JSON.stringify(i);for(let s of m)s.pattern.test(d)&&t.push({boundary_id:e.id,kind:"unsafe_fixture",detail:`${e.fixture_path} contains a possible ${s.label}.`});return t}function b(e,i){let r=Date.parse(e.waiver_expires_at),t=n(e.waiver_reason)&&n(e.waiver_owner)&&e.waiver_expires_at.endsWith("Z")&&c(e.waiver_expires_at)&&Number.isFinite(r);return{captured:0,waived:t&&r>=i?1:0,findings:t?r<i?[{boundary_id:e.id,kind:"expired_waiver",detail:`Boundary ${e.id} waiver expired at ${e.waiver_expires_at}.`}]:[]:[{boundary_id:e.id,kind:"invalid_waiver",detail:`Boundary ${e.id} waiver requires reason, owner, and an RFC 3339 UTC expiry.`}]}}function y(e,i,r){if(!n(e.id)||!n(e.producer)||!n(e.consumer)||!n(e.format))return{captured:0,waived:0,findings:[{boundary_id:n(e.id)?e.id:"unknown",kind:"invalid_boundary",detail:"Each boundary requires non-empty id, producer, consumer, and format."}]};if("fixture_path"in e){let t=i[e.fixture_path],d=n(e.fixture_path)&&e.fixture_path in i?v(e,t):[{boundary_id:e.id,kind:"missing_fixture",detail:`Boundary ${e.id} fixture ${String(e.fixture_path)} is missing.`}];return{captured:d.length===0?1:0,waived:0,findings:d}}return b(e,r)}function Me(e,i,r=new Date){let t=[];if(e.version!==1||!n(e.inventory_scope)||!Array.isArray(e.boundaries))return{ok:!1,boundary_count:0,captured_count:0,waived_count:0,findings:[{boundary_id:"registry",kind:"invalid_registry",detail:"Boundary registry requires version 1, inventory_scope, and boundaries."}]};let d=new Set,s=0,p=0;for(let o of e.boundaries){if(typeof o!="object"||o===null||Array.isArray(o)){t.push({boundary_id:"unknown",kind:"invalid_boundary",detail:"Each boundary must be a JSON object."});continue}let a=o,u=n(a.id)?a.id:void 0;if(u!==void 0&&d.has(u)){t.push({boundary_id:u,kind:"duplicate_boundary",detail:`Boundary ${u} is inventoried more than once.`});continue}u!==void 0&&d.add(u);let f=y(a,i,r.getTime());s+=f.captured,p+=f.waived,t.push(...f.findings)}return t.sort((o,a)=>o.boundary_id!==a.boundary_id?o.boundary_id.localeCompare(a.boundary_id):o.kind.localeCompare(a.kind)),{ok:t.length===0,boundary_count:e.boundaries.length,captured_count:s,waived_count:p,findings:t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new e.Error().stack;i&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[i]="ff251826-36f0-5b92-bee8-ca71d265986c")}catch{}})();export{Fe as ASSURANCE_ACTIONS,qe as ASSURANCE_DECLARATION_KINDS,F as ASSURANCE_DOCUMENT_VERSION,q as ASSURANCE_GATE_TRIGGERS,z as ASSURANCE_MEASUREMENT_SOURCE_KINDS,ne as ASSURANCE_PRESET_IDS,O as AssuranceEvaluationRefusalError,N as AssuranceMutationRefusalError,U as AssuranceSourceResolutionError,x as BOUNDARY_FIXTURE_CAPTURE_SOURCES,Ce as DEFECT_ESCAPE_CLASSES,De as DEFECT_GATE_EVIDENCE_DISPOSITIONS,pe as HISTORY_AUTHOR_ATTRIBUTION_BASELINE,h as PM_MUTATION_ACTION_CONTRACTS,Re as _testOnlyHealthCommand,Ze as _testOnlySimilarity,Ie as _testOnlyValidateCommand,Le as _testOnlyWorkspacePosition,ue as acceptAssuranceProposals,ye as acknowledgeUnknownAuthorHistoryEvents,be as acknowledgeUnknownAuthorHistoryEventsFromTransport,Oe as analyzeDefectChangeRisk,de as applyAssurancePreset,J as assuranceAssertionUpdateIsLoosening,Ne as buildDefectRecurrenceIndex,Ae as buildStatusRoleWarnings,ce as classifyHistoryAuthorEvent,oe as createAssurancePreset,Be as createAssuranceWorkspaceContext,V as createEmptyAssuranceDocument,ae as deriveAssuranceProposals,K as evaluateAssuranceAssertion,X as evaluateAssuranceGate,Me as evaluateBoundaryFixtures,Ue as evaluateDefectGateEvidence,Y as evaluateMeasurement,g as evaluateMutationGuard,Ve as evaluateSimilarityGovernance,He as findDuplicateClusters,Ge as findSimilarItems,Xe as formatWorkspacePositionHuman,Q as getAssuranceDeclaration,E as getMutationActionContract,_e as inspectHistoryAuthorStream,C as inspectStaleInProgressItems,ke as inspectStatusRoleAssignments,k as isMutationAction,R as jaccardSimilarity,L as listAssuranceDeclarations,te as listAssuranceVerdicts,we as listInvalidProvenanceHistoryStreamIds,A as listMutationActions,j as normalizeAssuranceEvaluation,P as normalizeAssuranceMutation,he as normalizeInvalidHistoryProvenance,S as normalizeSimilarityText,je as parseDefectChangeRiskRequest,Pe as parseDefectRecurrencePolicy,ve as parseUnknownAuthorHistoryEventCoordinates,xe as planUnknownAuthorHistoryAcknowledgment,I as prepareSimilarityText,Te as projectValidateCounts,se as promoteAssuranceAssertion,M as putAssuranceDeclaration,ee as putAssuranceDeclarationBundle,Ke as readWorkspacePosition,re as recordAssuranceVerdict,ie as removeAssuranceDeclaration,me as resolveUnknownAuthorAcknowledgmentSelector,ze as runAssuranceAction,Je as runAssuranceDispatch,Ye as runGc,Ee as runHealth,l as runReindex,_ as runUpgrade,$e as runValidate,fe as scanExtensionHostVersions,le as scanHistoryAuthorAttribution,w as scanMutationSecrets,ge as scanProvenanceResolverHealth,D as scanStaleInProgressItems,Se as scanStorageIntegrity,$ as scoreItemSimilarity,B as scorePreparedItemSimilarity,We as similarityAdvisoryWarnings,T as tokenizeSimilarityText,Z as validateAssertionDefinition,H as validateAssuranceDocument,G as validateGateDefinition,W as validateMeasurementDefinition};
2
2
  //# sourceMappingURL=sdk-governance.js.map