@unbrained/pm-cli 2026.11.29 → 2026.11.30
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-Q6GIFUCW.js → chunk-2SBTXR6C.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PY6A7ULK.js → chunk-3TXEWHQX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-K3MVVDLN.js → chunk-47ZS6RPL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WLZ5KVM2.js → chunk-5PNOVDVO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3TK2YOVB.js → chunk-AOTI76Q6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CV2B4JUB.js → chunk-CCKM5YQM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JQHLOSSS.js → chunk-DCWGM7CY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LQEB6GSY.js → chunk-FECZV72T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FRYNDVLN.js → chunk-FR7ULTM4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NLHNB2L3.js → chunk-HXQ3OHQR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JFPCL45G.js → chunk-IGEFPHV7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NRCGGNOE.js → chunk-JPJNJHQW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-R6M5OGJH.js → chunk-KCVSSONY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3E53F7QY.js → chunk-KXTKLDKD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DBASKWBO.js → chunk-NHBG5ET3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CNZOC6JD.js → chunk-NVYDPNQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3US5T6B2.js → chunk-NZSXWIX7.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-VI3A7UZ2.js → chunk-Q4VZSMUL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RWHS77ME.js → chunk-SJWIPGZW.js} +39 -39
- package/dist/cli-bundle/chunks/{chunk-EYEQC3L2.js → chunk-TX74QJ4W.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WNB62BGK.js → chunk-TY55UX6M.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4EBHZBM2.js → chunk-USBTXMKS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-VCXQ6A35.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-L7HON3BE.js → chunk-WFYE34TO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-YPMNXG2C.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZK4CY24V.js → chunk-YVTALIN3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZSBPE36C.js → chunk-Z7YL2SUM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KCR4NF2A.js → chunk-ZA5NS3PL.js} +2 -2
- package/dist/cli-bundle/chunks/{field-option-collisions-OZE43TOH.js → field-option-collisions-2F2Z7R7B.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-3WXNNFLP.js → item-revision-UAF6L47R.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-RJECL53Y.js +2 -0
- package/dist/cli-bundle/chunks/{linked-resource-value-list-2655COY2.js → linked-resource-value-list-WXPPYUVQ.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-actor-QOKPDYM4.js → mutation-actor-UK3QNEEB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-JNJHB3E6.js → mutation-admission-UTDYPFWP.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-YGVUE4YZ.js → register-list-query-DRA3CWHI.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-3JVZQDHH.js → register-mutation-WO74VLEQ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-LCHUHKRA.js → register-operations-CRBKH7WN.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-IJ7M3VUK.js → register-setup-6V6NQB5C.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-7BD7U2BX.js → stage-DYEHGASU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-WJAUHPXD.js → chunk-2UUBS4BG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KLOHZNJ4.js → chunk-4ER3VMST.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BZ3PUUPG.js → chunk-4YBMHMBJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ACTBMSCH.js → chunk-62AMZMR4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LSVRZ4KQ.js → chunk-7G7JIXLL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BPOU2S44.js → chunk-A3DORTXS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NNLENKU7.js → chunk-FM5WQ6ZU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BPBKHY6H.js → chunk-HXM7K6VH.js} +35 -35
- package/dist/cli-bundle/focused-chunks/{chunk-EUDAUT6T.js → chunk-IIVDBAJM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LKTRICZR.js → chunk-IJ3T3W4U.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-S5VG7RFY.js → chunk-L357ZAES.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PPCBCPIZ.js → chunk-LWBZ7UGG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TSZVCALS.js → chunk-M57KDG7I.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2CQFGJQ6.js → chunk-MZNV26XE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NGHT2LNG.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-GTUPHXKR.js → chunk-NJTKGBSK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5NSWNLFE.js → chunk-P55AZPFN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NO5MUY4I.js → chunk-RQYVX2T6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KWKPX36T.js → chunk-SXC3NVZI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-QTV6UE2Q.js → chunk-TQQO42C2.js} +5 -5
- package/dist/cli-bundle/focused-chunks/{chunk-S4AC7OMI.js → chunk-U35K7FSE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-42SU4LK3.js → chunk-UQJ4PY2Y.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NZA2LP4Y.js → chunk-WAP3DF4B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MYWUMVCZ.js → chunk-XR745UGE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-HABQYZMQ.js → field-option-collisions-7TG7STO7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-YH5R7YPW.js → item-revision-J7EUGCHR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-YZ2PUPGM.js → item-transaction-2IC2MLML.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-DJ2VRLKG.js → mutation-actor-LJVF2HVD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-3SECKVKY.js → mutation-admission-SLFAUONA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-FEJT2UCG.js → stage-MWR73LTZ.js} +2 -2
- package/dist/cli-bundle/main.js +3 -3
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +61 -61
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +1 -1
- package/dist/core/shared/url-credentials.d.ts +4 -2
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/docs/CONFIGURATION.md +22 -3
- package/docs/READ_OUTPUT_CONTRACTS.md +5 -0
- package/docs/SDK.md +19 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-JV7LREUF.js +0 -3
- package/dist/cli-bundle/chunks/chunk-SV27NNXQ.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-DJ5GAITL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-TX24L7RQ.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as mn,B as ie,D as Fi,G as Di,H as vf,Ha as Lf,Ia as Mf,J as oa,Ja as ir,K as kf,Ka as ua,M as bf,Na as Ff,Oc as t_,Rc as n_,U as Sf,_a as sr,bb as gn,eb as yn,l as gf,lb as ji,o as yf,oa as $f,p as tr,pa as Nf,pb as Qf,qb as Zf,s as wf,wb as e_,y as nr,yb as ha,z as rr}from"./chunk-KCR4NF2A.js";import{a as Xo,d as Jo,e as Wp,f as Qo,g as Bp}from"./chunk-X5D5YUHR.js";import{a as Df}from"./chunk-4QA5O64H.js";import{J as hf,a as Oi,b as Jn,c as $i,d as ke,e as Ni,f as mf,g as pf,h as Li,i as Qn,j as ff,k as _f,l as ra,m as ia,n as Zn,r as er,t as Mi,u as X,y as sa}from"./chunk-VI3A7UZ2.js";import{C as qf,E as Gi,F as Gf,G as Kf,H as ma,I as pa,N as zf,O as Wf,P as Bf,Q as Hf,R as Vf,S as fa,T as _a,U as Yf,V as Xf,W as Jf,Z as r_,a as Tf,aa as i_,da as s_,ia as o_,ja as a_,m as hn,q as If,r as Of,t as Pi,u as Ui,v as Pf,w as Uf,x as jf,z as qi}from"./chunk-WNB62BGK.js";import{Aa as Rf,j as Hp,oa as ca,pa as Cf,qa as da,ra as la,u as xf,va as Ef}from"./chunk-JFPCL45G.js";import{a as pm,l as aa}from"./chunk-JQHLOSSS.js";import{i as kt,k as pn,l as fn,m as _n}from"./chunk-3TK2YOVB.js";import{c as Af}from"./chunk-OGVSGXQX.js";import{N as rf,O as Ti,P as sf,Q as ta,S as of,T as af,V as cf,W as df,X as Ii,Y as lf,a as Vp,b as Yp,c as Xp,ca as na,d as Jp,f as Qp,ga as uf,j as Zo,k as Zp,l as ef,m as ea,n as tf,o as nf}from"./chunk-R6M5OGJH.js";import{d as cm,j as dm,r as lm,s as Vn,t as um,w as mm}from"./chunk-4EBHZBM2.js";import{$b as Hn,A as Zd,Ad as am,B as Re,C as Wr,E as bl,H as Sl,Ha as Si,J as Al,Jb as Hu,Ka as ln,La as $u,Ma as Nu,Na as Du,Nc as Po,Ob as Vu,Oc as Uo,Pc as jo,Qb as Yu,Qc as qo,R as ti,Tb as Do,U as Eu,Ua as Pu,Vb as Xu,Xb as Ju,Yb as yt,Zb as Qu,_b as wt,ab as Uu,ac as Dt,c as Be,ca as gi,cc as Zu,e as He,eb as qu,f as tn,fb as Gu,fd as nm,g as ho,ga as De,h as Xd,ha as Tu,i as jr,ib as Ku,j as qr,ja as yi,jb as Ai,k as Jd,ka as Iu,kb as zu,l as Gr,la as wi,lc as em,m as Qd,ma as vi,mb as V,na as ki,nb as le,nd as rm,o as _e,p as Kr,pb as xi,pc as tm,q as go,qb as he,r as Ne,ra as bi,rb as rt,sb as Wu,sd as im,tb as Ft,td as sm,ua as Ou,ud as Ci,v as Ve,vb as un,vd as om,wb as Ie,x as Tt,xa as Bn,yb as Fo,z as zr,zb as Bu,zd as Ei}from"./chunk-PY6A7ULK.js";import{B as ju,H as z,a as Mt,b as Ru,e as cn,f as dn,j as Lu,t as Mu,u as R,v as Fu}from"./chunk-3E53F7QY.js";import{A as _o,Aa as si,Bb as Zl,Da as oi,Ea as re,Fa as Nt,Ga as ae,Ha as No,Hb as ui,Hc as ru,Ia as Lo,Ib as H,If as _u,Ja as jl,Jd as ou,Jg as _i,Kd as au,Kf as hu,La as ai,Lg as hi,Mf as Wn,Na as ql,Nb as Lt,O as Ao,Oa as an,Of as gu,Pa as Gl,Q as Ye,Qa as Kl,Qd as cu,Rf as yu,Sa as zl,T as Ot,Ua as ci,Ub as eu,Ug as vu,Va as Wl,Ve as lu,Wa as Bl,X as te,_ as Zr,a as jd,ab as Hl,ah as M,bb as Vl,bd as iu,cb as Yl,db as Xl,eb as Jl,fa as Rl,fb as di,fd as su,ga as on,gb as li,ha as Ro,hg as gt,hh as ku,ia as ei,ig as pi,ih as bu,kd as Mo,kg as fi,l as qd,lh as nt,m as Gd,mf as uu,n as Kd,nb as Ql,nf as mu,o as zd,oa as Tl,of as mi,oh as Su,p as Wd,ph as Te,q as Bd,qb as Kn,qg as wu,r as We,rb as zn,rh as Au,s as Hd,sh as xu,tf as pu,th as Cu,vc as tu,wc as nu,xa as ii,xe as du,y as Vd,ya as Gn,yf as fu,z as Yd}from"./chunk-RWHS77ME.js";import{A as pl,B as fl,C as _l,D as hl,E as gl,F as yl,b as ko,c as Un,d as ve,g as F,h as et,i as Yr,j as rn,k as jn,l as qn,o as I,p as _t,q as tt,r as sn,s as ll,t as ul,u as Me,v as Xr,x as ml,y as bo,z as So}from"./chunk-GSLOAEY2.js";import{g as zp}from"./chunk-CNZOC6JD.js";import{$ as qm,$a as Yo,Aa as up,Ba as mp,C as zo,Ca as pp,D as Wo,E as vm,F as Ri,G as km,Ga as fp,H as bm,Ha as _p,I as Sm,Ia as hp,J as Am,Ja as gp,K as xm,Ka as yp,L as Cm,La as wp,M as Em,Ma as vp,N as Rm,Na as kp,O as Tm,Oa as bp,P as Im,Pa as Sp,Q as Om,Qa as Ap,R as $m,Ra as xp,S as Nm,Sa as Cp,T as Lm,Ta as Ep,U as Mm,Ua as Rp,V as Fm,Va as Tp,W as Dm,Wa as Ip,X as Pm,Xa as Op,Y as Um,Ya as Vo,Z as jm,Za as $p,_a as Np,aa as Bo,ab as Lp,ba as Gm,bb as Mp,c as fm,ca as Km,cb as Fp,d as _m,da as zm,db as Dp,e as hm,ea as Wm,eb as Pp,fa as Yn,fb as vt,ga as Bm,gb as Up,ha as Hm,hb as jp,ia as Vm,ib as qp,ja as Ym,jb as Gp,ka as Xm,la as Jm,lb as Kp,ma as Qm,na as Zm,nb as Xn,oa as ep,p as Go,pa as tp,q as gm,qa as np,ra as Ho,sa as rp,t as ym,ta as ip,u as Ko,ua as sp,v as Pt,va as op,wa as ap,x as wm,xa as cp,ya as dp,za as lp}from"./chunk-NRCGGNOE.js";import{$ as Oo,A as It,B as xo,C as wl,D as Qr,E as vl,F as Co,I as kl,K as xl,Q as O,S as Eo,T as Cl,U as El,W as se,_ as Ll,a as Z,aa as Ml,b as Pn,ba as $o,ca as Fl,da as ri,fa as Dl,ga as Pl,ha as Ul,i as ze,k as j,l as Ur,m as Rt,v as Jr,x as L}from"./chunk-JV7LREUF.js";import{E as dl,I as Il,P as To,T as Ol,W as $l,X as Nl,Z as Io,_ as ni,ba as q,ca as Fe,d as yo,da as $t,fa as ht,h as wo,i as Br,j as Hr,k as Vr,l as nl,n as rl,o as il,p as sl,q as ol,s as al,t as cl,u as vo}from"./chunk-TE6FBDHP.js";import{A as p,C as f,D as nn,E as me,F as el,G as B,H as ee,L as Le,N as tl,a as Ld,m as Md,p as Fd,s as Dd,u as Pd,w as Ud,x as Pr,y as Et}from"./chunk-K672XXGQ.js";var qb=Object.freeze({"--body":"Set the item body.","--body-file":"Read the item body from a file, or from stdin when set to -.","--description":"Set the item description.","--stdin":"Read the value from stdin.","--stdin-json":"Read a complete JSON document from stdin."}),Gb=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),Kb=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),zb=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),Wb=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),Bb=["--allow-","--check-","--dry-run","--explain","--fail-","--fix-","--full","--has-","--include-","--json","--no-","--prune-","--quiet","--refresh-","--require-","--runtime-only","--schema-only","--skip-","--stream","--strict-","--summary","--today","--verbose"],Hb=new Set(["--activate","--active-only","--adopt","--adopt-all","--all","--all-actionable","--all-affected-ids","--all-day","--all-streams","--acknowledge-linked-tests","--append-stable","--auto-fix","--auto-pm-context","--availability-only","--background","--brief","--by-assignee","--by-priority","--by-tag","--catalog","--claim","--clear","--clear-comments","--clear-criteria","--clear-deps","--clear-docs","--clear-events","--clear-files","--clear-learnings","--clear-notes","--clear-reminders","--clear-tests","--clear-type-options","--cli-only","--closed","--compact","--completion","--count","--counts","--deactivate","--declarative","--defaults","--describe","--diff","--doctor","--empty-body","--explore","--field-utilization","--filter-empty-body","--flags-only","--follow","--force","--global","--highlight","--hybrid","--id-only","--if-available","--ignore-global","--include_unparented","--infer","--init","--install","--isolated","--lean","--list","--local","--manage","--markdown","--metadata-coverage","--next","--normalize-provenance","--only","--only-last","--output-row-contract","--override-linked-pm-context","--override-linked-workspace-context","--packages-only","--past","--phrase-exact","--profile","--progress","--project","--promote-to-item-dep","--provenance","--provenance-summary","--raw","--ready-only","--ready_only","--rebuild","--recent","--reload","--repair","--replace-deps","--replace-docs","--replace-files","--replace-tests","--required","--required-on-create","--run","--runtime-probe","--save-baseline","--scaffold","--semantic","--shared-host-safe","--storage","--takeover-stale","--title-exact","--token-accounting","--trace","--tree","--unbounded","--uninstall","--validate-paths","--verify","--watch","--with-packages"]),Vb=new Set(["--only-index"]),Yb=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),Xb=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),Jb=new Set(["--regression"]);function Qb(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:zb.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:Gb.has(t)&&Kb.has(e)?["argv","stdin"]:["argv"]}function Zb(e,t){let n=Yb.has(`${e}:${t.flag}`)||t.value_name!==void 0||t.value_type==="string"||t.value_type==="number"||t.list===!0||t.repeatable===!0,r=t.value_type==="boolean"||t.flag==="--stdin"||t.flag==="--stdin-json"||t.flag.startsWith("--filter-")&&(t.flag.endsWith("-missing")||t.flag.startsWith("--filter-has-")||t.flag.startsWith("--filter-no-"))||Bb.some(i=>t.flag.startsWith(i));return n||Vb.has(t.flag)||!Hb.has(t.flag)&&!r}function eS(e,t){return t.value_arity!==void 0?t.value_arity:Zb(e,t)?Jb.has(t.flag)||Xb.has(`${e}:${t.flag}`)?"optional":"required":"none"}function tS(e,t){let n=Ur(e),r=eS(n,t),i=r!=="none",s=Qb(n,t.flag),o=t.description??qb[t.flag]??`${i?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:o,takes_value:i,value_required:r==="required",...i?{value_name:t.value_name??"value"}:{},value_type:i?t.value_type??"string":"boolean",required:t.required===!0,repeatable:t.repeatable===!0||t.list===!0,input_sources:s,...s.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...Wb.has(`${n}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function c_(e,t){return t.map(n=>tS(e,n))}function CF(e,t,n){let r=e.trim().toLowerCase(),i=[],s=new Map,o=0;for(let c of n)if(c.command.trim().toLowerCase()===r){if(o+=1,s.has(c.flag)){i.push({code:"duplicate_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} was observed more than once.`});continue}s.set(c.flag,c)}let a=new Set(t.map(({flag:c})=>c));for(let c of t){let d=s.get(c.flag);if(!d){i.push({code:"missing_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} has no executable option observation.`});continue}for(let[l,u]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[l]!==d[l]&&i.push({code:u,command:r,flag:c.flag,detail:`${r} ${c.flag} declares ${l}=${String(c[l])} but the executable option reports ${String(d[l])}.`})}for(let c of s.values())a.has(c.flag)||i.push({code:"undeclared_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,d)=>c.flag.localeCompare(d.flag)||c.code.localeCompare(d.code)),{ok:i.length===0,declared_count:t.length,observed_count:o,findings:i}}import{readFile as nS}from"node:fs/promises";function BF(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,Ve(e,t)}function f_(e){return Object.prototype.toString.call(e)==="[object Object]"}function rS(e,t,n,r){let i=O();if(!f_(e))return{...r({created_at:i,author:n,text:t}),text:t,edited_at:i};let s=o=>typeof o=="string"&&o!=="";return{...e,...s(e.created_at)?{}:{created_at:i},...s(e.author)?{}:{author:n},text:t,edited_at:i}}function d_(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new f(`Structured context events are append-only and cannot be ${t}.`,p.USAGE,{code:"structured_event_immutable"})}function iS(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function Ut(e,t){let n=e[t];return Array.isArray(n)?n:[]}function HF(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=_e(n,"--add");return Object.keys(s).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:s.text?.trim()||n}catch{return n}}function sS(e){return typeof e=="object"&&e!==null&&"code"in e}function l_(e,t){if(!Tt(e))throw new f(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,p.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function oS(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new f(`Specify ${t} text using only one input source: --add, --stdin, or --file`,p.USAGE);let r=Zd(),i=Tt(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",i)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return l_(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let s=e.file.trim();if(!s)throw new f("--file path cannot be empty",p.USAGE);if(s==="-")return l_(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await nS(s,"utf8"),emptyFlag:"--file"}}catch(o){if(sS(o)&&el(o))throw new f(`--file path not found: ${s}. Use --file - to read stdin.`,p.USAGE);let a=o instanceof Error?o.message:String(o);throw new f(`Failed to read --file path "${s}": ${a}. Use --file - to read stdin.`,p.USAGE)}}async function VF(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new f("Specify only one of --edit or --delete",p.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new f("--delete cannot be combined with replacement text",p.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new f("--delete must be a positive integer",p.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new f("--edit must be a positive integer",p.USAGE);let n=await oS(e,t);if(e.edit!==void 0){if(!n)throw new f("--edit requires replacement text from --add, --stdin, or --file",p.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function or(e,t){throw e instanceof f&&e.exitCode===p.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new f(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function __(e){return e==="comments"?"--stdin":"--add -"}var YF="annotation_flag_like_value";function aS(e){return/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(e.trim())}function cS(e){return e==="--file"?"--file <path>":e.startsWith("--file=")?e:e==="--stdin"?"--stdin":void 0}function dS(e){let t=e.value.trim(),n=e.collectionKey.replace(/s$/,""),r=cS(t),i=__(e.collectionKey),s=e.retryArgs===void 0?{}:{field:e.textFlag,recovery:{suggested_flags:[t],suggested_retry:L(e.retryArgs),suggested_retry_args:[...e.retryArgs]}};if(r!==void 0){let o=r.split(/[ =]/,1)[0],a=o==="--file"?"that file":"stdin",c=e.conflictingOperand===void 0?"":` "${e.conflictingOperand}" was read as positional text, which ${o} cannot be combined with: drop it, or pass it as the text without ${o}.`;return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text: ${e.textFlag} took ${o} as its value. Drop ${e.textFlag} and pass ${r} on its own.${c}`,p.USAGE,{code:"annotation_flag_like_value",required:`Drop ${e.textFlag}: ${r} reads the ${n} text from ${a} by itself. Use ${e.textFlag} text=${t} only when the text really is "${t}".`,examples:[`${e.commandPrefix} ${r}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text. Use ${i} to read stdin, or use text=${t} for literal dash-leading text.`,p.USAGE,{code:"annotation_flag_like_value",required:`Use ${i} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${e.commandPrefix} ${i}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}function lS(e,t){if(!((t.input.emptyFlag??"--add")!=="--add"||!aS(e)))throw dS({collectionKey:t.collectionKey,textFlag:"--add",value:e,commandPrefix:t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`})}function uS(e,t,n,r,i){if(n.input.mode!=="edit")return;let s=nu(t);if(s===void 0)return;let o=n.collectionKey.replace(/s$/,""),a=n.input.index,c=Ye(r)[0]==="--pm-path"?["--pm-path",i]:[];throw new f(`Replacement text for ${o} ${a} on ${e} ends with the read-output compaction marker, so it was copied from a compacted read that left out ${s} characters. Nothing was written.`,p.USAGE,{code:"annotation_text_compacted",item_id:e,details:{collection:n.collectionKey,entry_index:a,omitted_characters:s},required:`Read the whole ${o} with --output-budget unbounded, apply the change to the full text, and retry the edit without the trailing marker.`,why:"A budgeted read shortens long entries to a prefix plus a marker naming how many characters it left out; editing from that text would replace the stored entry with the shortened prefix.",examples:[L([...c,n.collectionKey,e,"--output-budget","unbounded","--json"]),`${L([...c,n.collectionKey,e,"--edit",String(a),"--file"])} <full-text-file>`]})}function mS(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new f(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,p.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(pS(e,t),e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new f(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,p.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> ${__(e.collectionKey)}`]})}function pS(e,t){if(t.expectAt!==void 0){if(e.input.mode!=="edit"&&e.input.mode!=="delete")throw new f(`--expect-at guards an --edit or --delete of one ${e.collectionKey.replace(/s$/,"")}`,p.USAGE,{code:"annotation_expectation_without_target",required:"Combine --expect-at with --edit <index> or --delete <index>; omit it for list and append operations.",examples:[`pm ${e.collectionKey} <id> --edit <index> --expect-at <created_at> --add "<text>"`,`pm ${e.collectionKey} <id> --delete <index> --expect-at <created_at>`]});if(typeof t.expectAt!="string"||t.expectAt.trim().length===0)throw new f("--expect-at must be the non-empty created_at timestamp of the entry you read",p.USAGE,{code:"annotation_expectation_invalid",required:"Pass the created_at value of the row you read at that index, as a string."})}}function u_(e,t,n,r,i){if(i===void 0)return;let s=t[n]?.created_at,o=typeof s=="string"?s:null;if(o===i)return;let a=t.flatMap((m,_)=>m?.created_at===i?[_+1]:[]),c=r.collectionKey.replace(/s$/,""),d=r.input.mode==="delete"?"--delete":"--edit",l=n+1,u=a.length===1?` The ${c} created at ${i} is at index ${a[0]}.`:a.length>1?` ${a.length} ${r.collectionKey} were created at ${i}: indexes ${a.join(", ")}.`:` No ${c} on ${e} was created at ${i}.`;throw new f(`${c.charAt(0).toUpperCase()}${c.slice(1)} ${l} on ${e} was created at ${o||"an unrecorded time (malformed entry)"}, not ${i}; refusing ${d} of an entry the caller did not read. Nothing was written.${u}`,p.CONFLICT,{code:"annotation_entry_mismatch",item_id:e,details:{collection:r.collectionKey,entry_index:l,expected_created_at:i,actual_created_at:o,matching_indexes:a},required:`Address the ${c} by the index its listing row reports and keep --expect-at set to that row's created_at. When several indexes share the timestamp, inspect those rows before retrying, because the guard compares timestamps, not entry identities.`,why:"A listing page's position or count is not an entry address; only the row's index is, and the expectation checks that the entry at that index still carries the created_at that was read.",examples:[`pm ${r.collectionKey} ${e} --limit 5`,`pm ${r.collectionKey} ${e} ${d} ${a.length===1?a[0]:"<index>"} --expect-at ${i}${d==="--edit"?' --add "<text>"':""}`]})}function fS(e,t,n,r,i,s){let o=Ut(e.metadata,t),a=i?o.findIndex(c=>f_(c)&&c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],written:o,position:a}:(o.push(s({created_at:O(),author:n,text:r})),e.metadata[t]=o,{changedFields:[t],written:o,position:o.length-1})}function m_(e,t,n){return Gl.has(e)?t.map((i,s)=>s).sort((i,s)=>Kl(t[i],t[s])||i-s).indexOf(n)+1:n+1}async function XF(e,t,n,r){mS(r,t);let i=I(process.cwd(),n.path);await z(i);let s=await R(i),o=F(s,M()),a=Bn(t.limit);if(r.input.mode==="list"){let h=await V(i,e,s.id_prefix,s.item_format,o.type_to_folder);if(!h)throw new f(`Item ${e} not found`,p.NOT_FOUND);let g=await le(h,{schema:s.schema}),y=Ut(g.document.metadata,r.collectionKey);return Ki(h.id,r.collectionKey,y,a,t.includeMeta===!0)}let c=H(t.author,s.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,g;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(w){let v=Ut(w.metadata,r.collectionKey),k=p_(r.input.index,v.length,r.collectionKey);return u_(e,v,k,r,t.expectAt),d_(v[k],"deleted"),v.splice(k,1),w.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(w){or(w,r.conflictGuidance)}let y=Ut(g.item,r.collectionKey);return Ki(g.item.id,r.collectionKey,y,a,t.includeMeta===!0,{action:"delete",entryIndex:r.input.index},t.fullHistory===!0)}let d=r.input.rawValue??r.input.value??"";lS(d,r);let l=r.parseText(r.input.value??"");if(!l.trim())throw new f(`${r.input.emptyFlag??"--add"} text cannot be empty`,p.USAGE);if(uS(e,l,r,n,i),r.input.mode==="edit"){let h=r.editOp??r.op,g,y=0;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(k){let b=Ut(k.metadata,r.collectionKey),A=p_(r.input.index,b.length,r.collectionKey);u_(e,b,A,r,t.expectAt);let C=b[A];return d_(C,"edited"),b[A]=rS(C,l,c,r.createEntry),y=m_(r.collectionKey,b,A),k.metadata[r.collectionKey]=b,{changedFields:[r.collectionKey]}}})}catch(k){or(k,r.conflictGuidance)}let w=Ut(g.item,r.collectionKey),v=y;return Ki(g.item.id,r.collectionKey,w,a,t.includeMeta===!0,{action:"edit",entryIndex:v,entry:w[v-1]},t.fullHistory===!0)}let u,m=0;try{u=await Ie({pmRoot:i,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 g=fS(h,r.collectionKey,c,l,t.ifAbsent===!0,r.createEntry);return m=m_(r.collectionKey,g.written,g.position),{changedFields:g.changedFields}}})}catch(h){or(h,r.conflictGuidance)}let _=Ut(u.item,r.collectionKey);return Ki(u.item.id,r.collectionKey,_,a,t.includeMeta===!0,{action:"add",entryIndex:m,entry:_[m-1],changedCount:t.ifAbsent===!0?Math.min(u.changedFields.length,1):void 0},t.fullHistory===!0)}function p_(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),i=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,s=t===1?`1 ${r}`:`${t} ${n}`;throw new f(`${i} index ${e??"(missing)"} out of range (item has ${s})`,p.USAGE)}return e-1}function _S(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 h_(e,t){if(Object.prototype.toString.call(e)!=="[object Object]")return e;let n={index:t,...e};return n.index=t,n}function hS(e,t){let n=e.length-t.length;return t.map((r,i)=>h_(r,n+i+1))}function Ki(e,t,n,r,i,s,o=!1){let a=s===void 0||o?hS(n,iS(n,s!==void 0&&o?void 0:r)):s.entry===void 0?[]:[h_(s.entry,s.entryIndex)],c=s!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...s?.changedCount===void 0?{}:{changed:s.changedCount===1},...[i,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}:{}}:{},..._S(t,s,c)}}import{isDeepStrictEqual as b_}from"node:util";var gS=new Set(["__proto__","prototype","constructor"]),ar=Symbol("looseOptionOccurrences");function it(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function yS(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n),e[t]=r;return}e[t]=[r,n]}function ga(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(1,o).trim(),value:n.slice(o+1),attached:!0};let a=n.slice(1).trim(),c=e[t+1];return typeof c=="string"&&!c.startsWith("-")?{consumed:2,key:a,value:c}:{consumed:1,key:a,value:!0}}let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(2,r).trim(),value:n.slice(r+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let i=n.slice(2).trim(),s=e[t+1];return typeof s=="string"&&!s.startsWith("-")?{consumed:2,key:i,value:s}:{consumed:1,key:i,value:!0}}function Wi(e){return gS.has(e)}function Hi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Rl(t)}function wn(e){let t=[],n=Ot(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=it(n.slice(2));i.length>0&&!Wi(i)&&t.push(i)}if(r.startsWith("-")&&!r.startsWith("--")){let i=it(r.slice(1));i.length>0&&!Wi(i)&&t.push(i)}return[...new Set(t)]}function nD(e){let t=new Set;for(let n of e)for(let r of wn(n))t.add(r);return t}function jt(e){let t=Ot(e.long)??"";if(t.startsWith("--")){let n=it(t.slice(2));if(n.length>0&&!Wi(n))return n}return wn(e)[0]??null}function vn(e){let t=Ot(e.long)??"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function S_(e,t){return[...(t.definitions??e).map(r=>vn(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function rD(e,t,n,r={}){if(t.length===0)return;let i=new Set,s=new Map,o=[],a=S_(t,r);for(let c of t){let d=wn(c),l=vn(c);for(let u of d)i.add(u),c.enabled===!1&&s.set(u,l);c.required===!0&&c.enabled!==!1&&d.length>0&&o.push({keys:d,label:l,definition:c})}for(let c of Object.keys(e)){i.has(c)||A_(`--${c}`,`--${c}`,n,a);let d=s.get(c);d&&x_(d,n)}for(let c of o){let d=l=>Object.hasOwn(e,l)&&(c.definition.list!==!0||wa(c.definition,e[l]));c.keys.some(d)||C_(c.definition,c.keys[0],c.label,n)}}function A_(e,t,n,r){let i=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new f(`Unknown option '${e}' for extension command '${n}'.${i}`,p.USAGE,{code:"unknown_option",flag:t,required:`Use a flag the command accepts; run pm contracts --command ${n} --flags-only --json to list them.`})}function x_(e,t){throw new f(`Option '${e}' is disabled for extension command '${t}'.`,p.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${t} --help`],nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function C_(e,t,n,r){let i=on(e),s=i.value_arity==="none"?n:i.value_arity==="optional"?`${n} [${i.value_name}]`:`${n} <${i.value_name}>`;throw new f(`Missing required option '${n}' for extension command '${r}'.`,p.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${s}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function wS(e){return typeof e=="string"||e==null?e:String(e)}function vS(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function E_(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var kS={string:wS,number:vS,boolean:E_};function qt(e,t){return Array.isArray(e)?e.map(n=>qt(n,t)):kS[t](e)}function ya(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Ro(e);return t?r.map(i=>qt(i,t)):r}function wa(e,t){return ya(t,null,e.repeatable===!0).length>0}function bS(e,t,n,r){return n?ya(e,t,r):t?qt(e,t):e}function SS(e,t,n){let r=T_(e,t);return r.length===0?n:r.map(i=>i.value)}function R_(e){return on(e).value_arity==="none"}function va(e,t,n,r,i){let s=vn(e),o=i?` for extension command '${i}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new f(`Option '${s}'${o} expects ${r}; received ${a}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${i??"<command>"} --help to review the declared flag contract.`]})}function ka(e,t){return e.value_validation==="strict"&&t!=="string"}function T_(e,t){let n=e[ar];if(!n)return[];let r=new Set(t);return n.filter(i=>r.has(i.key))}function AS(e,t,n,r){if(R_(e))for(let i of T_(n,t)){if(i.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?Ro(i.value):[i.value];for(let o of s){let a=ei(qt(o,"boolean"),"boolean");a!==null&&va(e,"boolean",o,a.expected,r)}}}function xS(e,t,n,r,i){let s=Array.isArray(n)?n.flat(1/0):[n],o=r?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of o)if(typeof a=="string"&&a.trim().length===0){let c=ei(a,t);va(e,t,a,c.expected,i)}}function ba(e,t,n,r){if(!ka(e,n))return t;let i=n==="boolean"&&R_(e),s=o=>{let a=ei(o,n);return a===null?o:i&&typeof o=="string"?!0:va(e,n,o,a.expected,r)};return Array.isArray(t)?t.map(s):s(t)}function CS(e,t,n,r){for(let i of n)if(!(i===t||!Object.hasOwn(e,i))){if(Object.hasOwn(e,t)){if(r){let s=e[t],o=e[i];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(o)?o:[o]].filter(a=>a!=null)}delete e[i];continue}e[t]=e[i],delete e[i]}}function I_(e,t,n=e,r){if(t.length===0)return e;let i=Object.create(null);for(let[o,a]of Object.entries(e))i[o]=a;let s=new Set(t.map(o=>jt(o)).filter(o=>o!==null));for(let o of t){let a=jt(o);if(a){let c=wn(o).filter(d=>d===a||!s.has(d));ES(i,o,a,c,n,r)}}return i}function ES(e,t,n,r,i,s){let o=t.list===!0,a=Hi(t);a&&!o&&RS(e,t,n,r,a,s),CS(e,n,r,o);let c=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=bS(t.default,a,o,c));return}if(a==="boolean"&&ka(t,a)&&AS(t,r,i,s),o){e[n]=TS(t,r,i,e[n],a,c,s);return}a&&(e[n]=ba(t,qt(e[n],a),a,s))}function RS(e,t,n,r,i,s){for(let o of r)o!==n&&Object.hasOwn(e,o)&&ba(t,qt(e[o],i),i,s)}function TS(e,t,n,r,i,s,o){let a=SS(n,t,r);i&&ka(e,i)&&xS(e,i,a,s,o);let c=ya(a,i,s);return i?ba(e,c,i,o):c}function iD(e){let t=Object.create(null),n=[];Object.defineProperty(t,ar,{value:n});let r=0;for(;r<e.length;){let i=ga(e,r);if(!i){r+=1;continue}let s=it(i.key);if(s.length===0||Wi(s)){r+=i.consumed;continue}yS(t,s,i.value),n.push({...i,key:s}),r+=i.consumed}return t}function sD(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let r=ga(e,n);if(r){n+=Math.max(1,r.consumed);continue}t.push(e[n]),n+=1}return t}function oD(e,t){if(t.length===0)return[...e];let n=new Set,r=new Set;for(let o of t){let a=Hi(o);for(let c of wn(o))n.add(c),a==="boolean"&&r.add(c)}if(n.size===0)return[...e];let i=[],s=0;for(;s<e.length;){if(e[s]==="--"){i.push(...e.slice(s+1));break}let o=ga(e,s);if(o){let a=it(o.key);if(n.has(a)){let c=e[s],d=r.has(a)&&!c.includes("=")?1:o.consumed;s+=d;continue}}i.push(e[s]),s+=1}return i}function Sa(e){return jt(e)}function g_(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function aD(e,t){let n=g_(t);if(n.length===0)return[];let r=j(n);return e.flags.filter(i=>j(g_(i.target_command))===r).flatMap(i=>[...i.flags])}function O_(e,t,n,r){let i=vn(e),[s,o]=n;throw new f(`Options '${s}' and '${o}' both set ${i} for extension command '${r}' with different values.`,p.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${i} once, under the handler key '${t}'.`,why:`'${s}' and '${o}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${o}' and pass one value as '${t}'.`,`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`]})}function cD(e,t,n,r={}){if(t.length===0)return e;let i=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),s=L_(i),o=LS(e,s,n),a=new Set([...s.long.values()].map(({handlerKey:l})=>l)),c=Object.create(null),d=Object.create(null);for(let[l,u]of Object.entries(o))a.has(l)?c[l]=u:u===void 0||r.undeclaredKeys==="pass"||OS(l)?d[l]=u:A_(l,$S(l),n,S_(i,{}));return N_(c,i,n),Object.assign(d,I_(c,i,$_(c,s),n))}function $_(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),r=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,o])=>(Array.isArray(o)?o.flat(1/0):[o]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),i=Object.create(null);return Object.defineProperty(i,ar,{value:r}),i}function N_(e,t,n){for(let r of t){let i=jt(r);if(i===null)continue;let s=vn(r),o=e[i],a=Object.hasOwn(e,i);r.enabled===!1&&a&&x_(s,n);let c=a&&(r.list!==!0||wa(r,o));r.required===!0&&r.enabled!==!1&&!c&&C_(r,i,s,n),r.list!==!0&&Array.isArray(o)&&IS(s,n)}}function IS(e,t){throw new f(`Option '${e}' for extension command '${t}' takes one value; received an array.`,p.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${t} --flags-only --json to read each flag's value contract.`]})}var y_=new Set([...[...xl].flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[it(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function OS(e){return y_.has(e)||y_.has(it(e.replace(/^-{1,2}/u,"")))}function $S(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function L_(e){let t={long:new Map,short:new Map},n=(r,i,s)=>{i.length>0&&!r.has(i)&&r.set(i,s)};for(let r of e){let i=jt(r);if(i===null)continue;let s={handlerKey:i,definition:r};n(t.long,i,s);let o=typeof r.short=="string"?r.short.trim():"";o.startsWith("-")&&!o.startsWith("--")&&n(t.short,o.slice(1),s)}return t}function Bi(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(it(t.replace(/^-{1,2}/u,"")))}function M_(e,t,n,r){let i=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(i===void 0||Bi(e,t)!==void 0)return{spelling:t,value:n};let s=Bi(e,i);return s===void 0||Hi(s.definition)!=="boolean"?{spelling:t,value:n}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(n)?{spelling:i,value:n.flat(1/0).map(o=>w_(t,s.definition,o,r))}:s.definition.list===!0&&n!==void 0?{spelling:i,value:w_(t,s.definition,n,r)}:{spelling:i,value:n===void 0?n:zi(t,s.definition,n,r)}}function dD(e,t,n){let r=L_(e);try{let i=M_(r,t,n,"");if(i.spelling===t)return;let s=Bi(r,i.spelling);return(s.definition.list===!0||s.definition.repeatable===!0)&&!wa(s.definition,i.value)?void 0:{key:s.handlerKey,value:i.value}}catch{return}}function w_(e,t,n,r){let i=s=>s.trim().length===0?s:String(zi(e,t,s.trim(),r));return n==null?n:typeof n!="string"?zi(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?zi(e,t,n,r):n.split(",").map(i).join(",")}function zi(e,t,n,r){let i=E_(n);return typeof i=="boolean"?!i:NS(e,t,n,r)}function NS(e,t,n,r){let i=vn(t);throw new f(`Option '${e}' for extension command '${r}' negates ${i} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:i,required:`Pass ${i} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${i}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's value contract.`]})}function LS(e,t,n){let r=Object.create(null),i=new Map;for(let[s,o]of Object.entries(e)){let{spelling:a,value:c}=M_(t,s,o,n),d=Bi(t,a);if(d===void 0)r[a]=c;else if(c!==void 0){let l=i.get(d.handlerKey);l===void 0?(i.set(d.handlerKey,a),r[d.handlerKey]=c):b_(v_(d.definition,d.handlerKey,r[d.handlerKey],t,n),v_(d.definition,d.handlerKey,c,t,n))||O_(d.definition,d.handlerKey,[l,a],n)}}return r}function v_(e,t,n,r,i){let s={[t]:n};return N_(s,[e],i),I_(s,[e],$_(s,r),i)[t]}function F_(e){let t=new Map;for(let n of e){let r=jt(n);if(r===null)continue;let i={definition:n,handlerKey:r,kind:Hi(n),arity:on(n).value_arity,scalar:n.list!==!0},s=[Ot(n.long),typeof n.short=="string"?n.short.trim():""];for(let o of s.filter(a=>a?.startsWith("-")===!0))t.has(o)||t.set(o,i)}return t}function D_(e,t,n,r=KS){let i=e.optionOf(n),s=t.get(n),o=s!==void 0&&r(s)?s:void 0;if(i!==void 0){let a={arity:i.arity,...i.variadic===!0?{variadic:!0}:{}};if(o?.handlerKey===i.key)return{...a,declared:o};if(s!==void 0)return a;let c=GS(t,n,i,r);return c===void 0?a:{...a,declared:c,negates:!0}}if(!(!e.includesLooseFlags||s===void 0))return o===void 0?{arity:s.arity,loose:!0}:{arity:s.arity,declared:o,loose:!0}}function Aa(e){return e.length>1&&e.startsWith("-")}var P_=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function U_(e,t,n){let{tokens:r}=e,i=0,s,o=!1,a=!1;for(;i<r.length||s!==void 0;){let c=s??r[i++];if(c==="--")return;if(a&&s===void 0&&MS(e,c))continue;let d=Aa(c)?DS(e,c,r[i],t,n):{consumedByCommander:!1,consumed:0};if(i+=d.consumed,s=d.group,a=d.variadic===!0,!d.consumedByCommander){if(FS(e.stop,c,o))return;o=!0}}}function MS(e,t){return!Aa(t)||e.negativeNumbersAreValues&&P_.test(t)}function FS(e,t,n){return e!==void 0&&(e.atFirstUnrecognized||!n&&e.atSubcommand(t))}function DS(e,t,n,r,i){let s=PS(t,n,r);if(s!==void 0)return i(s.spelling,s.entry,s.value,"loose"),{consumedByCommander:!1,consumed:s.consumed};let o=r(t);if(o!==void 0){let a=o.arity==="required"||o.arity==="optional"&&n!==void 0&&(!Aa(n)||e.negativeNumbersAreValues&&P_.test(n));return i(t,o,o.negates===!0?!1:a?n:!0,"commander"),{consumedByCommander:!0,consumed:a?1:0,variadic:o.variadic===!0}}return t[1]!=="-"?{consumed:0,...US(t,r,i)}:{consumedByCommander:jS(t,r,i,e.includesLooseFlags?i:()=>{}),consumed:0}}function PS(e,t,n){let r=e.indexOf("="),i=r>1?e.slice(0,r):e,s=n(i);if(s?.loose===!0)return r>1?{spelling:i,entry:s,value:e.slice(r+1),consumed:0}:t!==void 0&&!t.startsWith("-")?{spelling:i,entry:s,value:t,consumed:1}:{spelling:i,entry:s,value:!0,consumed:0};let o=r<0&&e.startsWith("--no-")?n(`--${e.slice(5)}`):void 0;return o?.loose===!0&&o.declared?.kind==="boolean"?{spelling:e,entry:o,value:!1,consumed:0}:void 0}function US(e,t,n){let r=e.slice(0,2),i=e.length>2?t(r):void 0;return i===void 0||i.loose===!0?{consumedByCommander:!1}:i.arity!=="none"?(n(r,i,e.slice(2),"commander"),{consumedByCommander:!0}):(n(r,i,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function jS(e,t,n,r){let i=e.indexOf("=");if(i>2){let o=e.slice(0,i),a=t(o);return a!==void 0&&a.arity!=="none"?(n(o,a,e.slice(i+1),"commander"),!0):(a?.declared?.kind==="boolean"&&r(o,a,e.slice(i+1),"loose"),!1)}let s=e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return s?.declared?.kind==="boolean"&&r(e,s,!1,"loose"),!1}function lD(e,t,n){let r=F_(t),i=new Map;for(let s of e)U_(s,o=>D_(s,r,o),(o,a,c)=>{a.declared!==void 0&&qS(i,a.declared,o,c,n)})}function qS(e,t,n,r,i){let{definition:s,handlerKey:o,kind:a}=t,c=a?qt(r,a):r,d=e.get(o)??new Map,l=[...d].find(([u,m])=>u!==n&&!b_(m,c));l!==void 0&&O_(s,o,[l[0],n],i),d.set(n,c),e.set(o,d)}function GS(e,t,n,r){let i=t.startsWith("--no-")?e.get(`--${t.slice(5)}`):void 0;return i!==void 0&&r(i)&&i.kind==="boolean"&&i.handlerKey===n.key?i:void 0}function KS(e){return e.scalar}function k_(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function uD(e,t,n){let r=F_(n),i=[...new Set(r.values())].filter(k_);if(i.length===0)return e;let s=new Set(n.map(m=>jt(m)).filter(m=>m!==null)),o=m=>wn(m.definition).filter(_=>_===m.handlerKey||!s.has(_)),a=new Map([...i].reverse().flatMap(m=>o(m).map(_=>[_,m]))),c=new Map;for(let m of t)U_(m,_=>D_(m,r,_,k_)??zS(m,a,_),(_,h,g,y)=>{if(h.declared===void 0)return;let w=c.get(h.declared)??[];w.push(y==="commander"?{value:g}:null),c.set(h.declared,w)});let d=[...c].filter(([,m])=>m.some(_=>_!==null));if(d.length===0)return e;let l=e[ar]??[];for(let[m,_]of d){let h=new Set(o(m)),g=l.filter(({key:k})=>h.has(k));if(g.length===0)continue;let y=k=>({consumed:0,key:m.handlerKey,value:k.value}),w=0,v=_.filter(k=>k===null).length===g.length?_.map(k=>k===null?g[w++]:y(k)):[...g,..._.filter(k=>k!==null).map(y)];l=[...l.filter(({key:k})=>!h.has(k)),...v]}let u=Object.assign(Object.create(null),e);return Object.defineProperty(u,ar,{value:l}),u}function zS(e,t,n){let r=!n.startsWith("--")&&e.optionOf(n.slice(0,2))!==void 0;if(!e.includesLooseFlags||r)return;let i=t.get(it(n.replace(/^-+/u,"")));return i===void 0?void 0:{arity:i.arity,declared:i,loose:!0}}var WS=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),BS=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]),HS=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])}),VS=new Set(["extension","install","package","packages","upgrade"]);function YS(e){let t=j(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[n,r]of Object.entries(HS))if(r.has(t))return n;return VS.has(t)?"extensions":"internal"}var kn=Object.freeze([...We.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...ze.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:WS.has(j(e))?"core":BS.has(j(e))?"standard":"full",family:YS(e)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]),XS=kn,j_=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),_D=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);function hD(e){let t=e===""?0:e.split(/\r?\n/).length,n=Buffer.byteLength(e,"utf8");return{lines:t,utf8_bytes:n,within_budget:t<=j_.max_lines&&n<=j_.max_utf8_bytes}}var q_={core:0,standard:1,full:2,internal:3},G_=new Map(XS.map(({command:e,tier:t})=>[e,t]));function xa(e,t="standard"){return G_.get(e.trim().toLowerCase())??G_.get(j(e.trim().toLowerCase()))??t}function gD(e){return K_(e,kn)}function K_(e,t){let n=q_[e];return t.filter(r=>r.tier!=="internal"&&q_[r.tier]<=n).map(r=>r.command)}function yD(e){return z_(e,kn)}function z_(e,t){return t.filter(n=>n.family===e).map(n=>n.command)}var JS=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],QS=new Set([...Rt.filter(e=>e.hidden).map(e=>e.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function wD(e=kn){return JS.map(t=>({family:t,commands:z_(t,e).filter(n=>e.find(r=>r.command===n)?.tier!=="internal"&&!QS.has(n))})).filter(({commands:t})=>t.length>0)}var ZS=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});function vD(e,t){return eA(e,t,kn)}function eA(e,t,n){if(t==="full")return[...e];let r=new Set(K_(t,n));return e.filter(i=>{let s=ZS[i];return s!==void 0&&r.has(s)})}var kD=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]),bD=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:!0},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:!1}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0},{name:"evidence",description:"Exact verification and outcome evidence.",required:!0}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);function SD(){return tA(kn)}function tA(e){return["# Generated agent command surface","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Command | Minimum visibility tier | Capability family |","| --- | --- | --- |",...e.map(({command:n,tier:r,family:i})=>`| \`${n}\` | ${r} | ${i} |`),""].join(`
|
|
1
|
+
import{A as mn,B as ie,D as Fi,G as Di,H as vf,Ha as Lf,Ia as Mf,J as oa,Ja as ir,K as kf,Ka as ua,M as bf,Na as Ff,Oc as t_,Rc as n_,U as Sf,_a as sr,bb as gn,eb as yn,l as gf,lb as ji,o as yf,oa as $f,p as tr,pa as Nf,pb as Qf,qb as Zf,s as wf,wb as e_,y as nr,yb as ha,z as rr}from"./chunk-ZA5NS3PL.js";import{a as Xo,d as Jo,e as Wp,f as Qo,g as Bp}from"./chunk-X5D5YUHR.js";import{a as Df}from"./chunk-4QA5O64H.js";import{J as hf,a as Oi,b as Jn,c as $i,d as ke,e as Ni,f as mf,g as pf,h as Li,i as Qn,j as ff,k as _f,l as ra,m as ia,n as Zn,r as er,t as Mi,u as X,y as sa}from"./chunk-Q4VZSMUL.js";import{C as qf,E as Gi,F as Gf,G as Kf,H as ma,I as pa,N as zf,O as Wf,P as Bf,Q as Hf,R as Vf,S as fa,T as _a,U as Yf,V as Xf,W as Jf,Z as r_,a as Tf,aa as i_,da as s_,ia as o_,ja as a_,m as hn,q as If,r as Of,t as Pi,u as Ui,v as Pf,w as Uf,x as jf,z as qi}from"./chunk-TY55UX6M.js";import{Aa as Rf,j as Hp,oa as ca,pa as Cf,qa as da,ra as la,u as xf,va as Ef}from"./chunk-IGEFPHV7.js";import{a as pm,l as aa}from"./chunk-DCWGM7CY.js";import{i as kt,k as pn,l as fn,m as _n}from"./chunk-AOTI76Q6.js";import{c as Af}from"./chunk-OGVSGXQX.js";import{N as rf,O as Ti,P as sf,Q as ta,S as of,T as af,V as cf,W as df,X as Ii,Y as lf,a as Vp,b as Yp,c as Xp,ca as na,d as Jp,f as Qp,ga as uf,j as Zo,k as Zp,l as ef,m as ea,n as tf,o as nf}from"./chunk-KCVSSONY.js";import{d as cm,j as dm,r as lm,s as Vn,t as um,w as mm}from"./chunk-USBTXMKS.js";import{$b as Hn,A as Zd,Ad as am,B as Re,C as Wr,E as bl,H as Sl,Ha as Si,J as Al,Jb as Hu,Ka as ln,La as $u,Ma as Nu,Na as Du,Nc as Po,Ob as Vu,Oc as Uo,Pc as jo,Qb as Yu,Qc as qo,R as ti,Tb as Do,U as Eu,Ua as Pu,Vb as Xu,Xb as Ju,Yb as yt,Zb as Qu,_b as wt,ab as Uu,ac as Dt,c as Be,ca as gi,cc as Zu,e as He,eb as qu,f as tn,fb as Gu,fd as nm,g as ho,ga as De,h as Xd,ha as Tu,i as jr,ib as Ku,j as qr,ja as yi,jb as Ai,k as Jd,ka as Iu,kb as zu,l as Gr,la as wi,lc as em,m as Qd,ma as vi,mb as V,na as ki,nb as le,nd as rm,o as _e,p as Kr,pb as xi,pc as tm,q as go,qb as he,r as Ne,ra as bi,rb as rt,sb as Wu,sd as im,tb as Ft,td as sm,ua as Ou,ud as Ci,v as Ve,vb as un,vd as om,wb as Ie,x as Tt,xa as Bn,yb as Fo,z as zr,zb as Bu,zd as Ei}from"./chunk-3TXEWHQX.js";import{B as ju,H as z,a as Mt,b as Ru,e as cn,f as dn,j as Lu,t as Mu,u as R,v as Fu}from"./chunk-KXTKLDKD.js";import{A as _o,Aa as si,Bb as Zl,Da as oi,Ea as re,Fa as Nt,Ga as ae,Ha as No,Hb as ui,Hc as ru,Ia as Lo,Ib as H,If as _u,Ja as jl,Jd as ou,Jg as _i,Kd as au,Kf as hu,La as ai,Lg as hi,Mf as Wn,Na as ql,Nb as Lt,O as Ao,Oa as an,Of as gu,Pa as Gl,Q as Ye,Qa as Kl,Qd as cu,Rf as yu,Sa as zl,T as Ot,Ua as ci,Ub as eu,Ug as vu,Va as Wl,Ve as lu,Wa as Bl,X as te,_ as Zr,a as jd,ab as Hl,ah as M,bb as Vl,bd as iu,cb as Yl,db as Xl,eb as Jl,fa as Rl,fb as di,fd as su,ga as on,gb as li,ha as Ro,hg as gt,hh as ku,ia as ei,ig as pi,ih as bu,kd as Mo,kg as fi,l as qd,lh as nt,m as Gd,mf as uu,n as Kd,nb as Ql,nf as mu,o as zd,oa as Tl,of as mi,oh as Su,p as Wd,ph as Te,q as Bd,qb as Kn,qg as wu,r as We,rb as zn,rh as Au,s as Hd,sh as xu,tf as pu,th as Cu,vc as tu,wc as nu,xa as ii,xe as du,y as Vd,ya as Gn,yf as fu,z as Yd}from"./chunk-SJWIPGZW.js";import{A as pl,B as fl,C as _l,D as hl,E as gl,F as yl,b as ko,c as Un,d as ve,g as F,h as et,i as Yr,j as rn,k as jn,l as qn,o as I,p as _t,q as tt,r as sn,s as ll,t as ul,u as Me,v as Xr,x as ml,y as bo,z as So}from"./chunk-GSLOAEY2.js";import{g as zp}from"./chunk-NVYDPNQP.js";import{$ as qm,$a as Yo,Aa as up,Ba as mp,C as zo,Ca as pp,D as Wo,E as vm,F as Ri,G as km,Ga as fp,H as bm,Ha as _p,I as Sm,Ia as hp,J as Am,Ja as gp,K as xm,Ka as yp,L as Cm,La as wp,M as Em,Ma as vp,N as Rm,Na as kp,O as Tm,Oa as bp,P as Im,Pa as Sp,Q as Om,Qa as Ap,R as $m,Ra as xp,S as Nm,Sa as Cp,T as Lm,Ta as Ep,U as Mm,Ua as Rp,V as Fm,Va as Tp,W as Dm,Wa as Ip,X as Pm,Xa as Op,Y as Um,Ya as Vo,Z as jm,Za as $p,_a as Np,aa as Bo,ab as Lp,ba as Gm,bb as Mp,c as fm,ca as Km,cb as Fp,d as _m,da as zm,db as Dp,e as hm,ea as Wm,eb as Pp,fa as Yn,fb as vt,ga as Bm,gb as Up,ha as Hm,hb as jp,ia as Vm,ib as qp,ja as Ym,jb as Gp,ka as Xm,la as Jm,lb as Kp,ma as Qm,na as Zm,nb as Xn,oa as ep,p as Go,pa as tp,q as gm,qa as np,ra as Ho,sa as rp,t as ym,ta as ip,u as Ko,ua as sp,v as Pt,va as op,wa as ap,x as wm,xa as cp,ya as dp,za as lp}from"./chunk-JPJNJHQW.js";import{$ as Oo,A as It,B as xo,C as wl,D as Qr,E as vl,F as Co,I as kl,K as xl,Q as O,S as Eo,T as Cl,U as El,W as se,_ as Ll,a as Z,aa as Ml,b as Pn,ba as $o,ca as Fl,da as ri,fa as Dl,ga as Pl,ha as Ul,i as ze,k as j,l as Ur,m as Rt,v as Jr,x as L}from"./chunk-VCXQ6A35.js";import{E as dl,I as Il,P as To,T as Ol,W as $l,X as Nl,Z as Io,_ as ni,ba as q,ca as Fe,d as yo,da as $t,fa as ht,h as wo,i as Br,j as Hr,k as Vr,l as nl,n as rl,o as il,p as sl,q as ol,s as al,t as cl,u as vo}from"./chunk-TE6FBDHP.js";import{A as p,C as f,D as nn,E as me,F as el,G as B,H as ee,L as Le,N as tl,a as Ld,m as Md,p as Fd,s as Dd,u as Pd,w as Ud,x as Pr,y as Et}from"./chunk-K672XXGQ.js";var qb=Object.freeze({"--body":"Set the item body.","--body-file":"Read the item body from a file, or from stdin when set to -.","--description":"Set the item description.","--stdin":"Read the value from stdin.","--stdin-json":"Read a complete JSON document from stdin."}),Gb=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),Kb=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),zb=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),Wb=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),Bb=["--allow-","--check-","--dry-run","--explain","--fail-","--fix-","--full","--has-","--include-","--json","--no-","--prune-","--quiet","--refresh-","--require-","--runtime-only","--schema-only","--skip-","--stream","--strict-","--summary","--today","--verbose"],Hb=new Set(["--activate","--active-only","--adopt","--adopt-all","--all","--all-actionable","--all-affected-ids","--all-day","--all-streams","--acknowledge-linked-tests","--append-stable","--auto-fix","--auto-pm-context","--availability-only","--background","--brief","--by-assignee","--by-priority","--by-tag","--catalog","--claim","--clear","--clear-comments","--clear-criteria","--clear-deps","--clear-docs","--clear-events","--clear-files","--clear-learnings","--clear-notes","--clear-reminders","--clear-tests","--clear-type-options","--cli-only","--closed","--compact","--completion","--count","--counts","--deactivate","--declarative","--defaults","--describe","--diff","--doctor","--empty-body","--explore","--field-utilization","--filter-empty-body","--flags-only","--follow","--force","--global","--highlight","--hybrid","--id-only","--if-available","--ignore-global","--include_unparented","--infer","--init","--install","--isolated","--lean","--list","--local","--manage","--markdown","--metadata-coverage","--next","--normalize-provenance","--only","--only-last","--output-row-contract","--override-linked-pm-context","--override-linked-workspace-context","--packages-only","--past","--phrase-exact","--profile","--progress","--project","--promote-to-item-dep","--provenance","--provenance-summary","--raw","--ready-only","--ready_only","--rebuild","--recent","--reload","--repair","--replace-deps","--replace-docs","--replace-files","--replace-tests","--required","--required-on-create","--run","--runtime-probe","--save-baseline","--scaffold","--semantic","--shared-host-safe","--storage","--takeover-stale","--title-exact","--token-accounting","--trace","--tree","--unbounded","--uninstall","--validate-paths","--verify","--watch","--with-packages"]),Vb=new Set(["--only-index"]),Yb=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),Xb=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),Jb=new Set(["--regression"]);function Qb(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:zb.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:Gb.has(t)&&Kb.has(e)?["argv","stdin"]:["argv"]}function Zb(e,t){let n=Yb.has(`${e}:${t.flag}`)||t.value_name!==void 0||t.value_type==="string"||t.value_type==="number"||t.list===!0||t.repeatable===!0,r=t.value_type==="boolean"||t.flag==="--stdin"||t.flag==="--stdin-json"||t.flag.startsWith("--filter-")&&(t.flag.endsWith("-missing")||t.flag.startsWith("--filter-has-")||t.flag.startsWith("--filter-no-"))||Bb.some(i=>t.flag.startsWith(i));return n||Vb.has(t.flag)||!Hb.has(t.flag)&&!r}function eS(e,t){return t.value_arity!==void 0?t.value_arity:Zb(e,t)?Jb.has(t.flag)||Xb.has(`${e}:${t.flag}`)?"optional":"required":"none"}function tS(e,t){let n=Ur(e),r=eS(n,t),i=r!=="none",s=Qb(n,t.flag),o=t.description??qb[t.flag]??`${i?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:o,takes_value:i,value_required:r==="required",...i?{value_name:t.value_name??"value"}:{},value_type:i?t.value_type??"string":"boolean",required:t.required===!0,repeatable:t.repeatable===!0||t.list===!0,input_sources:s,...s.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...Wb.has(`${n}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function c_(e,t){return t.map(n=>tS(e,n))}function CF(e,t,n){let r=e.trim().toLowerCase(),i=[],s=new Map,o=0;for(let c of n)if(c.command.trim().toLowerCase()===r){if(o+=1,s.has(c.flag)){i.push({code:"duplicate_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} was observed more than once.`});continue}s.set(c.flag,c)}let a=new Set(t.map(({flag:c})=>c));for(let c of t){let d=s.get(c.flag);if(!d){i.push({code:"missing_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} has no executable option observation.`});continue}for(let[l,u]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[l]!==d[l]&&i.push({code:u,command:r,flag:c.flag,detail:`${r} ${c.flag} declares ${l}=${String(c[l])} but the executable option reports ${String(d[l])}.`})}for(let c of s.values())a.has(c.flag)||i.push({code:"undeclared_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,d)=>c.flag.localeCompare(d.flag)||c.code.localeCompare(d.code)),{ok:i.length===0,declared_count:t.length,observed_count:o,findings:i}}import{readFile as nS}from"node:fs/promises";function BF(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,Ve(e,t)}function f_(e){return Object.prototype.toString.call(e)==="[object Object]"}function rS(e,t,n,r){let i=O();if(!f_(e))return{...r({created_at:i,author:n,text:t}),text:t,edited_at:i};let s=o=>typeof o=="string"&&o!=="";return{...e,...s(e.created_at)?{}:{created_at:i},...s(e.author)?{}:{author:n},text:t,edited_at:i}}function d_(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new f(`Structured context events are append-only and cannot be ${t}.`,p.USAGE,{code:"structured_event_immutable"})}function iS(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function Ut(e,t){let n=e[t];return Array.isArray(n)?n:[]}function HF(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=_e(n,"--add");return Object.keys(s).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:s.text?.trim()||n}catch{return n}}function sS(e){return typeof e=="object"&&e!==null&&"code"in e}function l_(e,t){if(!Tt(e))throw new f(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,p.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function oS(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new f(`Specify ${t} text using only one input source: --add, --stdin, or --file`,p.USAGE);let r=Zd(),i=Tt(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",i)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return l_(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let s=e.file.trim();if(!s)throw new f("--file path cannot be empty",p.USAGE);if(s==="-")return l_(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await nS(s,"utf8"),emptyFlag:"--file"}}catch(o){if(sS(o)&&el(o))throw new f(`--file path not found: ${s}. Use --file - to read stdin.`,p.USAGE);let a=o instanceof Error?o.message:String(o);throw new f(`Failed to read --file path "${s}": ${a}. Use --file - to read stdin.`,p.USAGE)}}async function VF(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new f("Specify only one of --edit or --delete",p.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new f("--delete cannot be combined with replacement text",p.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new f("--delete must be a positive integer",p.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new f("--edit must be a positive integer",p.USAGE);let n=await oS(e,t);if(e.edit!==void 0){if(!n)throw new f("--edit requires replacement text from --add, --stdin, or --file",p.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function or(e,t){throw e instanceof f&&e.exitCode===p.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new f(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function __(e){return e==="comments"?"--stdin":"--add -"}var YF="annotation_flag_like_value";function aS(e){return/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(e.trim())}function cS(e){return e==="--file"?"--file <path>":e.startsWith("--file=")?e:e==="--stdin"?"--stdin":void 0}function dS(e){let t=e.value.trim(),n=e.collectionKey.replace(/s$/,""),r=cS(t),i=__(e.collectionKey),s=e.retryArgs===void 0?{}:{field:e.textFlag,recovery:{suggested_flags:[t],suggested_retry:L(e.retryArgs),suggested_retry_args:[...e.retryArgs]}};if(r!==void 0){let o=r.split(/[ =]/,1)[0],a=o==="--file"?"that file":"stdin",c=e.conflictingOperand===void 0?"":` "${e.conflictingOperand}" was read as positional text, which ${o} cannot be combined with: drop it, or pass it as the text without ${o}.`;return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text: ${e.textFlag} took ${o} as its value. Drop ${e.textFlag} and pass ${r} on its own.${c}`,p.USAGE,{code:"annotation_flag_like_value",required:`Drop ${e.textFlag}: ${r} reads the ${n} text from ${a} by itself. Use ${e.textFlag} text=${t} only when the text really is "${t}".`,examples:[`${e.commandPrefix} ${r}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text. Use ${i} to read stdin, or use text=${t} for literal dash-leading text.`,p.USAGE,{code:"annotation_flag_like_value",required:`Use ${i} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${e.commandPrefix} ${i}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}function lS(e,t){if(!((t.input.emptyFlag??"--add")!=="--add"||!aS(e)))throw dS({collectionKey:t.collectionKey,textFlag:"--add",value:e,commandPrefix:t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`})}function uS(e,t,n,r,i){if(n.input.mode!=="edit")return;let s=nu(t);if(s===void 0)return;let o=n.collectionKey.replace(/s$/,""),a=n.input.index,c=Ye(r)[0]==="--pm-path"?["--pm-path",i]:[];throw new f(`Replacement text for ${o} ${a} on ${e} ends with the read-output compaction marker, so it was copied from a compacted read that left out ${s} characters. Nothing was written.`,p.USAGE,{code:"annotation_text_compacted",item_id:e,details:{collection:n.collectionKey,entry_index:a,omitted_characters:s},required:`Read the whole ${o} with --output-budget unbounded, apply the change to the full text, and retry the edit without the trailing marker.`,why:"A budgeted read shortens long entries to a prefix plus a marker naming how many characters it left out; editing from that text would replace the stored entry with the shortened prefix.",examples:[L([...c,n.collectionKey,e,"--output-budget","unbounded","--json"]),`${L([...c,n.collectionKey,e,"--edit",String(a),"--file"])} <full-text-file>`]})}function mS(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new f(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,p.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(pS(e,t),e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new f(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,p.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> ${__(e.collectionKey)}`]})}function pS(e,t){if(t.expectAt!==void 0){if(e.input.mode!=="edit"&&e.input.mode!=="delete")throw new f(`--expect-at guards an --edit or --delete of one ${e.collectionKey.replace(/s$/,"")}`,p.USAGE,{code:"annotation_expectation_without_target",required:"Combine --expect-at with --edit <index> or --delete <index>; omit it for list and append operations.",examples:[`pm ${e.collectionKey} <id> --edit <index> --expect-at <created_at> --add "<text>"`,`pm ${e.collectionKey} <id> --delete <index> --expect-at <created_at>`]});if(typeof t.expectAt!="string"||t.expectAt.trim().length===0)throw new f("--expect-at must be the non-empty created_at timestamp of the entry you read",p.USAGE,{code:"annotation_expectation_invalid",required:"Pass the created_at value of the row you read at that index, as a string."})}}function u_(e,t,n,r,i){if(i===void 0)return;let s=t[n]?.created_at,o=typeof s=="string"?s:null;if(o===i)return;let a=t.flatMap((m,_)=>m?.created_at===i?[_+1]:[]),c=r.collectionKey.replace(/s$/,""),d=r.input.mode==="delete"?"--delete":"--edit",l=n+1,u=a.length===1?` The ${c} created at ${i} is at index ${a[0]}.`:a.length>1?` ${a.length} ${r.collectionKey} were created at ${i}: indexes ${a.join(", ")}.`:` No ${c} on ${e} was created at ${i}.`;throw new f(`${c.charAt(0).toUpperCase()}${c.slice(1)} ${l} on ${e} was created at ${o||"an unrecorded time (malformed entry)"}, not ${i}; refusing ${d} of an entry the caller did not read. Nothing was written.${u}`,p.CONFLICT,{code:"annotation_entry_mismatch",item_id:e,details:{collection:r.collectionKey,entry_index:l,expected_created_at:i,actual_created_at:o,matching_indexes:a},required:`Address the ${c} by the index its listing row reports and keep --expect-at set to that row's created_at. When several indexes share the timestamp, inspect those rows before retrying, because the guard compares timestamps, not entry identities.`,why:"A listing page's position or count is not an entry address; only the row's index is, and the expectation checks that the entry at that index still carries the created_at that was read.",examples:[`pm ${r.collectionKey} ${e} --limit 5`,`pm ${r.collectionKey} ${e} ${d} ${a.length===1?a[0]:"<index>"} --expect-at ${i}${d==="--edit"?' --add "<text>"':""}`]})}function fS(e,t,n,r,i,s){let o=Ut(e.metadata,t),a=i?o.findIndex(c=>f_(c)&&c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],written:o,position:a}:(o.push(s({created_at:O(),author:n,text:r})),e.metadata[t]=o,{changedFields:[t],written:o,position:o.length-1})}function m_(e,t,n){return Gl.has(e)?t.map((i,s)=>s).sort((i,s)=>Kl(t[i],t[s])||i-s).indexOf(n)+1:n+1}async function XF(e,t,n,r){mS(r,t);let i=I(process.cwd(),n.path);await z(i);let s=await R(i),o=F(s,M()),a=Bn(t.limit);if(r.input.mode==="list"){let h=await V(i,e,s.id_prefix,s.item_format,o.type_to_folder);if(!h)throw new f(`Item ${e} not found`,p.NOT_FOUND);let g=await le(h,{schema:s.schema}),y=Ut(g.document.metadata,r.collectionKey);return Ki(h.id,r.collectionKey,y,a,t.includeMeta===!0)}let c=H(t.author,s.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,g;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(w){let v=Ut(w.metadata,r.collectionKey),k=p_(r.input.index,v.length,r.collectionKey);return u_(e,v,k,r,t.expectAt),d_(v[k],"deleted"),v.splice(k,1),w.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(w){or(w,r.conflictGuidance)}let y=Ut(g.item,r.collectionKey);return Ki(g.item.id,r.collectionKey,y,a,t.includeMeta===!0,{action:"delete",entryIndex:r.input.index},t.fullHistory===!0)}let d=r.input.rawValue??r.input.value??"";lS(d,r);let l=r.parseText(r.input.value??"");if(!l.trim())throw new f(`${r.input.emptyFlag??"--add"} text cannot be empty`,p.USAGE);if(uS(e,l,r,n,i),r.input.mode==="edit"){let h=r.editOp??r.op,g,y=0;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(k){let b=Ut(k.metadata,r.collectionKey),A=p_(r.input.index,b.length,r.collectionKey);u_(e,b,A,r,t.expectAt);let C=b[A];return d_(C,"edited"),b[A]=rS(C,l,c,r.createEntry),y=m_(r.collectionKey,b,A),k.metadata[r.collectionKey]=b,{changedFields:[r.collectionKey]}}})}catch(k){or(k,r.conflictGuidance)}let w=Ut(g.item,r.collectionKey),v=y;return Ki(g.item.id,r.collectionKey,w,a,t.includeMeta===!0,{action:"edit",entryIndex:v,entry:w[v-1]},t.fullHistory===!0)}let u,m=0;try{u=await Ie({pmRoot:i,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 g=fS(h,r.collectionKey,c,l,t.ifAbsent===!0,r.createEntry);return m=m_(r.collectionKey,g.written,g.position),{changedFields:g.changedFields}}})}catch(h){or(h,r.conflictGuidance)}let _=Ut(u.item,r.collectionKey);return Ki(u.item.id,r.collectionKey,_,a,t.includeMeta===!0,{action:"add",entryIndex:m,entry:_[m-1],changedCount:t.ifAbsent===!0?Math.min(u.changedFields.length,1):void 0},t.fullHistory===!0)}function p_(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),i=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,s=t===1?`1 ${r}`:`${t} ${n}`;throw new f(`${i} index ${e??"(missing)"} out of range (item has ${s})`,p.USAGE)}return e-1}function _S(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 h_(e,t){if(Object.prototype.toString.call(e)!=="[object Object]")return e;let n={index:t,...e};return n.index=t,n}function hS(e,t){let n=e.length-t.length;return t.map((r,i)=>h_(r,n+i+1))}function Ki(e,t,n,r,i,s,o=!1){let a=s===void 0||o?hS(n,iS(n,s!==void 0&&o?void 0:r)):s.entry===void 0?[]:[h_(s.entry,s.entryIndex)],c=s!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...s?.changedCount===void 0?{}:{changed:s.changedCount===1},...[i,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}:{}}:{},..._S(t,s,c)}}import{isDeepStrictEqual as b_}from"node:util";var gS=new Set(["__proto__","prototype","constructor"]),ar=Symbol("looseOptionOccurrences");function it(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function yS(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n),e[t]=r;return}e[t]=[r,n]}function ga(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(1,o).trim(),value:n.slice(o+1),attached:!0};let a=n.slice(1).trim(),c=e[t+1];return typeof c=="string"&&!c.startsWith("-")?{consumed:2,key:a,value:c}:{consumed:1,key:a,value:!0}}let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(2,r).trim(),value:n.slice(r+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let i=n.slice(2).trim(),s=e[t+1];return typeof s=="string"&&!s.startsWith("-")?{consumed:2,key:i,value:s}:{consumed:1,key:i,value:!0}}function Wi(e){return gS.has(e)}function Hi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Rl(t)}function wn(e){let t=[],n=Ot(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=it(n.slice(2));i.length>0&&!Wi(i)&&t.push(i)}if(r.startsWith("-")&&!r.startsWith("--")){let i=it(r.slice(1));i.length>0&&!Wi(i)&&t.push(i)}return[...new Set(t)]}function nD(e){let t=new Set;for(let n of e)for(let r of wn(n))t.add(r);return t}function jt(e){let t=Ot(e.long)??"";if(t.startsWith("--")){let n=it(t.slice(2));if(n.length>0&&!Wi(n))return n}return wn(e)[0]??null}function vn(e){let t=Ot(e.long)??"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function S_(e,t){return[...(t.definitions??e).map(r=>vn(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function rD(e,t,n,r={}){if(t.length===0)return;let i=new Set,s=new Map,o=[],a=S_(t,r);for(let c of t){let d=wn(c),l=vn(c);for(let u of d)i.add(u),c.enabled===!1&&s.set(u,l);c.required===!0&&c.enabled!==!1&&d.length>0&&o.push({keys:d,label:l,definition:c})}for(let c of Object.keys(e)){i.has(c)||A_(`--${c}`,`--${c}`,n,a);let d=s.get(c);d&&x_(d,n)}for(let c of o){let d=l=>Object.hasOwn(e,l)&&(c.definition.list!==!0||wa(c.definition,e[l]));c.keys.some(d)||C_(c.definition,c.keys[0],c.label,n)}}function A_(e,t,n,r){let i=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new f(`Unknown option '${e}' for extension command '${n}'.${i}`,p.USAGE,{code:"unknown_option",flag:t,required:`Use a flag the command accepts; run pm contracts --command ${n} --flags-only --json to list them.`})}function x_(e,t){throw new f(`Option '${e}' is disabled for extension command '${t}'.`,p.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${t} --help`],nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function C_(e,t,n,r){let i=on(e),s=i.value_arity==="none"?n:i.value_arity==="optional"?`${n} [${i.value_name}]`:`${n} <${i.value_name}>`;throw new f(`Missing required option '${n}' for extension command '${r}'.`,p.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${s}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function wS(e){return typeof e=="string"||e==null?e:String(e)}function vS(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function E_(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var kS={string:wS,number:vS,boolean:E_};function qt(e,t){return Array.isArray(e)?e.map(n=>qt(n,t)):kS[t](e)}function ya(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Ro(e);return t?r.map(i=>qt(i,t)):r}function wa(e,t){return ya(t,null,e.repeatable===!0).length>0}function bS(e,t,n,r){return n?ya(e,t,r):t?qt(e,t):e}function SS(e,t,n){let r=T_(e,t);return r.length===0?n:r.map(i=>i.value)}function R_(e){return on(e).value_arity==="none"}function va(e,t,n,r,i){let s=vn(e),o=i?` for extension command '${i}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new f(`Option '${s}'${o} expects ${r}; received ${a}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${i??"<command>"} --help to review the declared flag contract.`]})}function ka(e,t){return e.value_validation==="strict"&&t!=="string"}function T_(e,t){let n=e[ar];if(!n)return[];let r=new Set(t);return n.filter(i=>r.has(i.key))}function AS(e,t,n,r){if(R_(e))for(let i of T_(n,t)){if(i.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?Ro(i.value):[i.value];for(let o of s){let a=ei(qt(o,"boolean"),"boolean");a!==null&&va(e,"boolean",o,a.expected,r)}}}function xS(e,t,n,r,i){let s=Array.isArray(n)?n.flat(1/0):[n],o=r?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of o)if(typeof a=="string"&&a.trim().length===0){let c=ei(a,t);va(e,t,a,c.expected,i)}}function ba(e,t,n,r){if(!ka(e,n))return t;let i=n==="boolean"&&R_(e),s=o=>{let a=ei(o,n);return a===null?o:i&&typeof o=="string"?!0:va(e,n,o,a.expected,r)};return Array.isArray(t)?t.map(s):s(t)}function CS(e,t,n,r){for(let i of n)if(!(i===t||!Object.hasOwn(e,i))){if(Object.hasOwn(e,t)){if(r){let s=e[t],o=e[i];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(o)?o:[o]].filter(a=>a!=null)}delete e[i];continue}e[t]=e[i],delete e[i]}}function I_(e,t,n=e,r){if(t.length===0)return e;let i=Object.create(null);for(let[o,a]of Object.entries(e))i[o]=a;let s=new Set(t.map(o=>jt(o)).filter(o=>o!==null));for(let o of t){let a=jt(o);if(a){let c=wn(o).filter(d=>d===a||!s.has(d));ES(i,o,a,c,n,r)}}return i}function ES(e,t,n,r,i,s){let o=t.list===!0,a=Hi(t);a&&!o&&RS(e,t,n,r,a,s),CS(e,n,r,o);let c=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=bS(t.default,a,o,c));return}if(a==="boolean"&&ka(t,a)&&AS(t,r,i,s),o){e[n]=TS(t,r,i,e[n],a,c,s);return}a&&(e[n]=ba(t,qt(e[n],a),a,s))}function RS(e,t,n,r,i,s){for(let o of r)o!==n&&Object.hasOwn(e,o)&&ba(t,qt(e[o],i),i,s)}function TS(e,t,n,r,i,s,o){let a=SS(n,t,r);i&&ka(e,i)&&xS(e,i,a,s,o);let c=ya(a,i,s);return i?ba(e,c,i,o):c}function iD(e){let t=Object.create(null),n=[];Object.defineProperty(t,ar,{value:n});let r=0;for(;r<e.length;){let i=ga(e,r);if(!i){r+=1;continue}let s=it(i.key);if(s.length===0||Wi(s)){r+=i.consumed;continue}yS(t,s,i.value),n.push({...i,key:s}),r+=i.consumed}return t}function sD(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let r=ga(e,n);if(r){n+=Math.max(1,r.consumed);continue}t.push(e[n]),n+=1}return t}function oD(e,t){if(t.length===0)return[...e];let n=new Set,r=new Set;for(let o of t){let a=Hi(o);for(let c of wn(o))n.add(c),a==="boolean"&&r.add(c)}if(n.size===0)return[...e];let i=[],s=0;for(;s<e.length;){if(e[s]==="--"){i.push(...e.slice(s+1));break}let o=ga(e,s);if(o){let a=it(o.key);if(n.has(a)){let c=e[s],d=r.has(a)&&!c.includes("=")?1:o.consumed;s+=d;continue}}i.push(e[s]),s+=1}return i}function Sa(e){return jt(e)}function g_(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function aD(e,t){let n=g_(t);if(n.length===0)return[];let r=j(n);return e.flags.filter(i=>j(g_(i.target_command))===r).flatMap(i=>[...i.flags])}function O_(e,t,n,r){let i=vn(e),[s,o]=n;throw new f(`Options '${s}' and '${o}' both set ${i} for extension command '${r}' with different values.`,p.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${i} once, under the handler key '${t}'.`,why:`'${s}' and '${o}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${o}' and pass one value as '${t}'.`,`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`]})}function cD(e,t,n,r={}){if(t.length===0)return e;let i=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),s=L_(i),o=LS(e,s,n),a=new Set([...s.long.values()].map(({handlerKey:l})=>l)),c=Object.create(null),d=Object.create(null);for(let[l,u]of Object.entries(o))a.has(l)?c[l]=u:u===void 0||r.undeclaredKeys==="pass"||OS(l)?d[l]=u:A_(l,$S(l),n,S_(i,{}));return N_(c,i,n),Object.assign(d,I_(c,i,$_(c,s),n))}function $_(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),r=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,o])=>(Array.isArray(o)?o.flat(1/0):[o]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),i=Object.create(null);return Object.defineProperty(i,ar,{value:r}),i}function N_(e,t,n){for(let r of t){let i=jt(r);if(i===null)continue;let s=vn(r),o=e[i],a=Object.hasOwn(e,i);r.enabled===!1&&a&&x_(s,n);let c=a&&(r.list!==!0||wa(r,o));r.required===!0&&r.enabled!==!1&&!c&&C_(r,i,s,n),r.list!==!0&&Array.isArray(o)&&IS(s,n)}}function IS(e,t){throw new f(`Option '${e}' for extension command '${t}' takes one value; received an array.`,p.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${t} --flags-only --json to read each flag's value contract.`]})}var y_=new Set([...[...xl].flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[it(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function OS(e){return y_.has(e)||y_.has(it(e.replace(/^-{1,2}/u,"")))}function $S(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function L_(e){let t={long:new Map,short:new Map},n=(r,i,s)=>{i.length>0&&!r.has(i)&&r.set(i,s)};for(let r of e){let i=jt(r);if(i===null)continue;let s={handlerKey:i,definition:r};n(t.long,i,s);let o=typeof r.short=="string"?r.short.trim():"";o.startsWith("-")&&!o.startsWith("--")&&n(t.short,o.slice(1),s)}return t}function Bi(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(it(t.replace(/^-{1,2}/u,"")))}function M_(e,t,n,r){let i=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(i===void 0||Bi(e,t)!==void 0)return{spelling:t,value:n};let s=Bi(e,i);return s===void 0||Hi(s.definition)!=="boolean"?{spelling:t,value:n}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(n)?{spelling:i,value:n.flat(1/0).map(o=>w_(t,s.definition,o,r))}:s.definition.list===!0&&n!==void 0?{spelling:i,value:w_(t,s.definition,n,r)}:{spelling:i,value:n===void 0?n:zi(t,s.definition,n,r)}}function dD(e,t,n){let r=L_(e);try{let i=M_(r,t,n,"");if(i.spelling===t)return;let s=Bi(r,i.spelling);return(s.definition.list===!0||s.definition.repeatable===!0)&&!wa(s.definition,i.value)?void 0:{key:s.handlerKey,value:i.value}}catch{return}}function w_(e,t,n,r){let i=s=>s.trim().length===0?s:String(zi(e,t,s.trim(),r));return n==null?n:typeof n!="string"?zi(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?zi(e,t,n,r):n.split(",").map(i).join(",")}function zi(e,t,n,r){let i=E_(n);return typeof i=="boolean"?!i:NS(e,t,n,r)}function NS(e,t,n,r){let i=vn(t);throw new f(`Option '${e}' for extension command '${r}' negates ${i} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:i,required:`Pass ${i} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${i}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's value contract.`]})}function LS(e,t,n){let r=Object.create(null),i=new Map;for(let[s,o]of Object.entries(e)){let{spelling:a,value:c}=M_(t,s,o,n),d=Bi(t,a);if(d===void 0)r[a]=c;else if(c!==void 0){let l=i.get(d.handlerKey);l===void 0?(i.set(d.handlerKey,a),r[d.handlerKey]=c):b_(v_(d.definition,d.handlerKey,r[d.handlerKey],t,n),v_(d.definition,d.handlerKey,c,t,n))||O_(d.definition,d.handlerKey,[l,a],n)}}return r}function v_(e,t,n,r,i){let s={[t]:n};return N_(s,[e],i),I_(s,[e],$_(s,r),i)[t]}function F_(e){let t=new Map;for(let n of e){let r=jt(n);if(r===null)continue;let i={definition:n,handlerKey:r,kind:Hi(n),arity:on(n).value_arity,scalar:n.list!==!0},s=[Ot(n.long),typeof n.short=="string"?n.short.trim():""];for(let o of s.filter(a=>a?.startsWith("-")===!0))t.has(o)||t.set(o,i)}return t}function D_(e,t,n,r=KS){let i=e.optionOf(n),s=t.get(n),o=s!==void 0&&r(s)?s:void 0;if(i!==void 0){let a={arity:i.arity,...i.variadic===!0?{variadic:!0}:{}};if(o?.handlerKey===i.key)return{...a,declared:o};if(s!==void 0)return a;let c=GS(t,n,i,r);return c===void 0?a:{...a,declared:c,negates:!0}}if(!(!e.includesLooseFlags||s===void 0))return o===void 0?{arity:s.arity,loose:!0}:{arity:s.arity,declared:o,loose:!0}}function Aa(e){return e.length>1&&e.startsWith("-")}var P_=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function U_(e,t,n){let{tokens:r}=e,i=0,s,o=!1,a=!1;for(;i<r.length||s!==void 0;){let c=s??r[i++];if(c==="--")return;if(a&&s===void 0&&MS(e,c))continue;let d=Aa(c)?DS(e,c,r[i],t,n):{consumedByCommander:!1,consumed:0};if(i+=d.consumed,s=d.group,a=d.variadic===!0,!d.consumedByCommander){if(FS(e.stop,c,o))return;o=!0}}}function MS(e,t){return!Aa(t)||e.negativeNumbersAreValues&&P_.test(t)}function FS(e,t,n){return e!==void 0&&(e.atFirstUnrecognized||!n&&e.atSubcommand(t))}function DS(e,t,n,r,i){let s=PS(t,n,r);if(s!==void 0)return i(s.spelling,s.entry,s.value,"loose"),{consumedByCommander:!1,consumed:s.consumed};let o=r(t);if(o!==void 0){let a=o.arity==="required"||o.arity==="optional"&&n!==void 0&&(!Aa(n)||e.negativeNumbersAreValues&&P_.test(n));return i(t,o,o.negates===!0?!1:a?n:!0,"commander"),{consumedByCommander:!0,consumed:a?1:0,variadic:o.variadic===!0}}return t[1]!=="-"?{consumed:0,...US(t,r,i)}:{consumedByCommander:jS(t,r,i,e.includesLooseFlags?i:()=>{}),consumed:0}}function PS(e,t,n){let r=e.indexOf("="),i=r>1?e.slice(0,r):e,s=n(i);if(s?.loose===!0)return r>1?{spelling:i,entry:s,value:e.slice(r+1),consumed:0}:t!==void 0&&!t.startsWith("-")?{spelling:i,entry:s,value:t,consumed:1}:{spelling:i,entry:s,value:!0,consumed:0};let o=r<0&&e.startsWith("--no-")?n(`--${e.slice(5)}`):void 0;return o?.loose===!0&&o.declared?.kind==="boolean"?{spelling:e,entry:o,value:!1,consumed:0}:void 0}function US(e,t,n){let r=e.slice(0,2),i=e.length>2?t(r):void 0;return i===void 0||i.loose===!0?{consumedByCommander:!1}:i.arity!=="none"?(n(r,i,e.slice(2),"commander"),{consumedByCommander:!0}):(n(r,i,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function jS(e,t,n,r){let i=e.indexOf("=");if(i>2){let o=e.slice(0,i),a=t(o);return a!==void 0&&a.arity!=="none"?(n(o,a,e.slice(i+1),"commander"),!0):(a?.declared?.kind==="boolean"&&r(o,a,e.slice(i+1),"loose"),!1)}let s=e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return s?.declared?.kind==="boolean"&&r(e,s,!1,"loose"),!1}function lD(e,t,n){let r=F_(t),i=new Map;for(let s of e)U_(s,o=>D_(s,r,o),(o,a,c)=>{a.declared!==void 0&&qS(i,a.declared,o,c,n)})}function qS(e,t,n,r,i){let{definition:s,handlerKey:o,kind:a}=t,c=a?qt(r,a):r,d=e.get(o)??new Map,l=[...d].find(([u,m])=>u!==n&&!b_(m,c));l!==void 0&&O_(s,o,[l[0],n],i),d.set(n,c),e.set(o,d)}function GS(e,t,n,r){let i=t.startsWith("--no-")?e.get(`--${t.slice(5)}`):void 0;return i!==void 0&&r(i)&&i.kind==="boolean"&&i.handlerKey===n.key?i:void 0}function KS(e){return e.scalar}function k_(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function uD(e,t,n){let r=F_(n),i=[...new Set(r.values())].filter(k_);if(i.length===0)return e;let s=new Set(n.map(m=>jt(m)).filter(m=>m!==null)),o=m=>wn(m.definition).filter(_=>_===m.handlerKey||!s.has(_)),a=new Map([...i].reverse().flatMap(m=>o(m).map(_=>[_,m]))),c=new Map;for(let m of t)U_(m,_=>D_(m,r,_,k_)??zS(m,a,_),(_,h,g,y)=>{if(h.declared===void 0)return;let w=c.get(h.declared)??[];w.push(y==="commander"?{value:g}:null),c.set(h.declared,w)});let d=[...c].filter(([,m])=>m.some(_=>_!==null));if(d.length===0)return e;let l=e[ar]??[];for(let[m,_]of d){let h=new Set(o(m)),g=l.filter(({key:k})=>h.has(k));if(g.length===0)continue;let y=k=>({consumed:0,key:m.handlerKey,value:k.value}),w=0,v=_.filter(k=>k===null).length===g.length?_.map(k=>k===null?g[w++]:y(k)):[...g,..._.filter(k=>k!==null).map(y)];l=[...l.filter(({key:k})=>!h.has(k)),...v]}let u=Object.assign(Object.create(null),e);return Object.defineProperty(u,ar,{value:l}),u}function zS(e,t,n){let r=!n.startsWith("--")&&e.optionOf(n.slice(0,2))!==void 0;if(!e.includesLooseFlags||r)return;let i=t.get(it(n.replace(/^-+/u,"")));return i===void 0?void 0:{arity:i.arity,declared:i,loose:!0}}var WS=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),BS=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]),HS=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])}),VS=new Set(["extension","install","package","packages","upgrade"]);function YS(e){let t=j(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[n,r]of Object.entries(HS))if(r.has(t))return n;return VS.has(t)?"extensions":"internal"}var kn=Object.freeze([...We.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...ze.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:WS.has(j(e))?"core":BS.has(j(e))?"standard":"full",family:YS(e)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]),XS=kn,j_=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),_D=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);function hD(e){let t=e===""?0:e.split(/\r?\n/).length,n=Buffer.byteLength(e,"utf8");return{lines:t,utf8_bytes:n,within_budget:t<=j_.max_lines&&n<=j_.max_utf8_bytes}}var q_={core:0,standard:1,full:2,internal:3},G_=new Map(XS.map(({command:e,tier:t})=>[e,t]));function xa(e,t="standard"){return G_.get(e.trim().toLowerCase())??G_.get(j(e.trim().toLowerCase()))??t}function gD(e){return K_(e,kn)}function K_(e,t){let n=q_[e];return t.filter(r=>r.tier!=="internal"&&q_[r.tier]<=n).map(r=>r.command)}function yD(e){return z_(e,kn)}function z_(e,t){return t.filter(n=>n.family===e).map(n=>n.command)}var JS=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],QS=new Set([...Rt.filter(e=>e.hidden).map(e=>e.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function wD(e=kn){return JS.map(t=>({family:t,commands:z_(t,e).filter(n=>e.find(r=>r.command===n)?.tier!=="internal"&&!QS.has(n))})).filter(({commands:t})=>t.length>0)}var ZS=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});function vD(e,t){return eA(e,t,kn)}function eA(e,t,n){if(t==="full")return[...e];let r=new Set(K_(t,n));return e.filter(i=>{let s=ZS[i];return s!==void 0&&r.has(s)})}var kD=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]),bD=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:!0},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:!1}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0},{name:"evidence",description:"Exact verification and outcome evidence.",required:!0}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);function SD(){return tA(kn)}function tA(e){return["# Generated agent command surface","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Command | Minimum visibility tier | Capability family |","| --- | --- | --- |",...e.map(({command:n,tier:r,family:i})=>`| \`${n}\` | ${r} | ${i} |`),""].join(`
|
|
2
2
|
`)}var Ca=[{exit_code:1,class:"generic_failure"},{exit_code:2,class:"usage"},{exit_code:3,class:"not_found"},{exit_code:4,class:"conflict"},{exit_code:5,class:"dependency_failed"}],nA=new Map(Ca.map(e=>[e.exit_code,e.class]));function Vi(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function rA(e){if(!e)return[];let t=new Set,n=new Set;return e.map(r=>{let i=r.state.trim(),s=r.probe_id.trim(),o=Vi(r.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(i)||!/^[a-z][a-z0-9-]*$/.test(s)||o.length===0||t.has(i)||n.has(s))throw new TypeError("Invalid pm refusal state contract");return t.add(i),n.add(s),{state:i,probe_id:s,entrypoints:o,expected_exit_class:r.expected_exit_class}}).sort((r,i)=>r.state.localeCompare(i.state))}function iA(e,t,n,r,i){return![[1,2,3,4,5].includes(e.exit_code),e.meaning.trim().length>0,e.recovery.trim().length>0,t.length>0,n.length>0,/^[a-z][a-z0-9_]*$/.test(r),i.every(s=>/^[a-z][a-z0-9_]*$/.test(s)),nA.get(e.exit_code)===e.class].includes(!1)}function sA(e,t){let n=e,r=new Set;for(;n.canonical_code!==n.code;){if(r.has(n.code))throw new TypeError(`Alias cycle in pm error code catalog: ${e.code}`);r.add(n.code);let i=t.get(n.canonical_code);if(!i)throw new TypeError(`Invalid pm error code contract: ${e.code}`);n=i}return n}function oA(e){let t=new Map(e.map(n=>[n.code,n]));for(let n of e){let r=sA(n,t);if(r.exit_code!==n.exit_code||r.class!==n.class)throw new TypeError(`Alias transport mismatch for pm error code: ${n.code}`);let i=e.filter(s=>s.code!==r.code&&s.canonical_code===r.code).map(s=>s.code).sort();if(n.code===r.code?JSON.stringify(n.aliases)!==JSON.stringify(i):n.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${n.code}`)}}function B_(e){let t=new Set,n=e.map(r=>{let i=r.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(i))throw new TypeError(`Invalid pm error code: ${JSON.stringify(r.code)}`);if(t.has(i))throw new TypeError(`Duplicate pm error code: ${i}`);t.add(i);let s=Vi(r.sources),o=Vi(r.emitting_commands),a=(r.canonical_code??i).trim(),c=Vi(r.aliases??[]),d=rA(r.owned_states);if(!iA(r,s,o,a,c))throw new TypeError(`Invalid pm error code contract: ${i}`);if(d.some(l=>l.expected_exit_class!==r.class))throw new TypeError(`Invalid pm refusal state exit class: ${i}`);return Object.freeze({...r,code:i,meaning:r.meaning.trim(),recovery:r.recovery.trim(),sources:s,emitting_commands:o,canonical_code:a,aliases:c,owned_states:d})});return oA(n),Object.freeze(n.sort((r,i)=>r.code.localeCompare(i.code)))}function xD(e,t){let n=W_(e,t);return W_(n.canonical_code??n.code,t)}function W_(e,t){let n=e.trim(),r=t.find(i=>i.code===n);if(!r)throw new TypeError(`Unknown pm error code "${n}"`);return r}var aA="Inspect the structured error guidance, then retry the suggested command when one is present.",cA=new Map(Ca.map(e=>[e.exit_code,e.class]));function H_(e){return e.map(t=>{let n=`${t.code.replaceAll("_"," ")} condition.`,r={code:t.code,meaning:`${n.charAt(0).toUpperCase()}${n.slice(1)}`,stability:t.stable?"stable":"provisional",exit_code:t.exit_code,class:cA.get(t.exit_code),recovery:aA,sources:t.sources,emitting_commands:t.emitting_commands??["*"],canonical_code:t.canonical_code??t.code,aliases:t.aliases??[]};return t.owned_states&&(r.owned_states=t.owned_states),r})}var V_=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_entry_mismatch",exit_code:4,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_invalid",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_without_target",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_text_compacted",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_text_source_conflict",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/declared-blockers.ts"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_deferred_fields",exit_code:2,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts","sdk/config.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_deferral_conflict",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_field_unsupported",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_fields_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_reason_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/dependency-removal.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"expect_hash_background_unsupported",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invalid",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invocation_rewritten",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_requires_mutation",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_target_required",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expected_revision_duplicate",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"expected_revision_scope_conflict",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_option_disabled",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_option_spelling_conflict",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_flag_invalid",exit_code:2,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_option_collision",exit_code:1,sources:["core/profile/profile-lint.ts"]},{code:"finalization_invalid_document",exit_code:2,sources:["sdk/transactions/item-finalization.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_append_only_repair_unavailable",exit_code:4,sources:["sdk/history/append-only-repair.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_compact_boundary_bridged",exit_code:2,sources:["sdk/history-compact.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_chain_unbridgeable",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_unrepairable_stream",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_record_integrity_invalid",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_record_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_record_version_unsupported",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_redact_bridge_unlocated",exit_code:1,sources:["sdk/history-redact.ts"]},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"history_version_unreconstructable",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"in_progress_idle",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"in_progress_unowned",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/shared/url-credentials.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/extension/listing-fields.ts","sdk/extension/static-inventory.ts","sdk/governance/assurance-mutation-error.ts","sdk/history-redact.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/linked-artifacts.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/test/run-phases.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/lifecycle/item-revision.ts","sdk/merge/three-way.ts","sdk/query/declared-blockers.ts"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"item_revision_conflict",exit_code:4,sources:["core/store/item-mutation-precondition.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_conflict",exit_code:4,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_key_misread",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_resource_value_list",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_immutable",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_patch_fields_unsupported",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]}];var Y_=[{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_reconcile_receipt_evidence_untrusted",exit_code:4,sources:["sdk/history-repair.ts"]},{code:"merge_root_not_found",exit_code:3,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_settlement_hook_conflict",exit_code:4,sources:["sdk/merge/settlement-hook.ts"]},{code:"merge_settlement_review_required",exit_code:4,sources:["sdk/merge/ignored-artifacts.ts","sdk/merge/reconcile.ts","sdk/merge/stage.ts"]},{code:"missing_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"missing_cli_flag",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_directory",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"missing_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_lifecycle_target",exit_code:2,stable:!0,sources:["sdk/extension.ts"]},{code:"missing_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"missing_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_parameter_alias",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_positive_execution_receipt",exit_code:1,sources:["sdk/test/execution.ts"]},{code:"missing_probe",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_required_argument",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/main.ts","cli/register-mutation.ts","cli/schema/registration.ts","core/telemetry/observability.ts","sdk/governance/assurance-action.ts","sdk/history-redact.ts","sdk/invocation-author.ts","sdk/lifecycle/claim.ts","sdk/linked-artifacts.ts"],emitting_commands:["*","claim"]},{code:"missing_required_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/context-intent-contracts.ts","sdk/extension/command-options.ts","sdk/lifecycle/create.ts","sdk/lifecycle/plan.ts"],emitting_commands:["*","create","plan"]},{code:"missing_suggested_retry",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_suggested_retry_args",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"module_import_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"multi_target_github_install_ambiguous",exit_code:2,stable:!0,sources:["cli/register-setup.ts"]},{code:"mutation_author_required",exit_code:2,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"mutation_document_unreadable",exit_code:2,sources:["cli/register-structured-mutation.ts"]},{code:"mutation_option_value_invalid",exit_code:2,sources:["sdk/lifecycle/mutation-option-validation.ts"],emitting_commands:["item mutate"]},{code:"mutation_secret_guard_blocked",exit_code:4,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"no_matching_tests",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_projects_matched_filters",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_test_files_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_tests_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_update_fields",exit_code:1,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"no_version_bounds_declared",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_omits_canonical_pm_version_bounds",probe_id:"author-manifest-version-bounds-missing",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"non_refusal_exit",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"npm_pack_json_shape_unsupported",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_missing",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_unsafe",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_not_found",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"npm_source_shorthand_ambiguous",exit_code:2,sources:["sdk/extension/install-sources.ts"]},{code:"output_budget_exceeded",exit_code:2,sources:["sdk/testing.ts"]},{code:"ownership_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/annotations.ts"]},{code:"ownership_dependency_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"ownership_metadata_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"package_spec_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"package_upgrade_modes_mutually_exclusive",exit_code:2,sources:["sdk/governance/upgrade.ts"]},{code:"positional_shape_budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"positional_signature_mismatch",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"profile_name_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_name_not_normalized",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_summary_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_title_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"project_runtime_history_epoch_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_item_format_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_mutation",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_read",exit_code:1,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_schema_field_requires_declared_flag",exit_code:2,sources:["core/extensions/item-fields.ts"]},{code:"projection_options_mutually_exclusive",exit_code:2,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"provenance_value_domain_invalid",exit_code:2,sources:["core/diagnostics/remediation.ts"]},{code:"read_output_cursor_command_mismatch",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_invalid",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_stale",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_mutation_conflict",exit_code:2,sources:["sdk/read-output-contracts.ts"]},{code:"read_output_surface_unsupported",exit_code:2,sources:["sdk/extension/static-inventory.ts","sdk/read-output-contracts.ts"]},{code:"recovery_kind_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"redundant_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"refusal_allowed_values_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_exit_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_mutated_state",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_probe_missing",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_recovery_failed",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"reindex_already_running",exit_code:4,stable:!0,sources:["sdk/governance/reindex.ts"]},{code:"removed_canonical_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"removed_compatibility_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"reopen_reason_required",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reopen_receipt_missing",exit_code:1,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"reopen_target_status_invalid",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reported_zero_passes",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reported_zero_tests",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reserved_item_field",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"retry_failed",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"schema_field_flag_invalid",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_field_option_collision",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_migration_input_required",exit_code:2,stable:!0,sources:["cli/migration-gates.ts"]},{code:"semantic_spelling_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"settings_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_read_fs_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_schema",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_merge_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_section_document_malformed",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_document_missing",exit_code:3,sources:["core/store/settings-sections.ts"]},{code:"settings_section_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_name_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_reserved",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_revision_conflict",exit_code:4,sources:["core/store/settings-sections.ts"]},{code:"settings_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_write_assigned_path_invalid",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_json",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_schema",exit_code:2,sources:["core/store/settings.ts"]},{code:"stale_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"stale_claim_takeover_refused",exit_code:4,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"stale_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_in_progress_items",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"stale_lock_requires_override",exit_code:4,sources:["core/lock/lock.ts"]},{code:"stale_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_revision",exit_code:4,sources:["core/store/item-store.ts"]},{code:"start_blocked_by_open_dependency",exit_code:4,sources:["sdk/lifecycle/start-blockers.ts"],emitting_commands:["claim","start-task","update"]},{code:"status_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_lifecycle_role_required",exit_code:2,sources:["sdk/schema.ts"]},{code:"stdin_json_invalid",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"stdin_json_persisted_annotation_changed",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"stdin_json_unknown_key",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"structured_entry_key_repeated",exit_code:2,sources:["core/item/parse.ts"]},{code:"structured_event_immutable",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"structured_event_input_conflict",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_empty",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_since_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"suggested_retry_args_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"telemetry_endpoint_probe_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_endpoint_probe_http_status",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_otel_export_failing",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_high_retries",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_invalid_rows",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_pending",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_schema_version_behind",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_state_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"template_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"terminal_plan_mutation",exit_code:4,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"terminal_state_conflict",exit_code:4,stable:!0,sources:["core/telemetry/observability.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"test_measure_requires_execution",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"test_measure_requires_run",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"text_unpaired_surrogate",exit_code:2,sources:["core/item/item-format.ts","core/shared/output-unicode.ts"]},{code:"tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_tracked_runtime_cache_files"]},{code:"tracker_not_initialized",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/tracker-preflight.ts","core/telemetry/observability.ts"],owned_states:[{state:"selected_tracker_root_exists_without_settings",probe_id:"tracker-root-settings-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_missing",exit_code:3,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_does_not_exist",probe_id:"tracker-root-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_not_directory",exit_code:2,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_a_regular_file",probe_id:"tracker-root-not-directory",entrypoints:["list"],expected_exit_class:"usage"}]},{code:"tracker_root_unreadable",exit_code:1,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_not_readable",probe_id:"tracker-root-unreadable",entrypoints:["list"],expected_exit_class:"generic_failure"}]},{code:"transaction_abandoned",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_committed",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_create_compensated",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_journal_invalid",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_partial_mutation",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_plan_mismatch",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_preview_external_schema",exit_code:2,sources:["sdk/item-transaction.ts"]},{code:"transaction_preview_non_regular_file",exit_code:2,sources:["core/fs/fs-utils.ts"]},{code:"transaction_preview_snapshot_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_recovery_plan_missing",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"type_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"type_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"undeclared_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"unexpected_refusal_probe",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"unknown_command",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/cli-contracts/runtime-contracts.ts"]},{code:"unknown_context_intent",exit_code:2,stable:!0,sources:["sdk/context-intent-contracts.ts"]},{code:"unknown_error",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"unknown_field",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_field_projection",exit_code:2,stable:!0,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"unknown_item_type",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_lifecycle_action",exit_code:2,stable:!0,sources:["sdk/agent/subcommand-recovery.ts"],canonical_code:"unknown_subcommand"},{code:"unknown_noun",exit_code:2,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"unknown_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/runtime/invocation-options.ts","core/telemetry/observability.ts","sdk/extension/command-options.ts"],owned_states:[{state:"declared_option_is_rejected_on_the_selected_command_path",probe_id:"cross-command-unknown-option",entrypoints:["deps"],expected_exit_class:"usage"}]},{code:"unknown_plan_template",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"unknown_provenance_dimension",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"unknown_status",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_subcommand",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","sdk/agent/subcommand-recovery.ts"],aliases:["unknown_lifecycle_action"],owned_states:[{state:"config_action_token_is_not_declared",probe_id:"config-unknown-action",entrypoints:["config"],expected_exit_class:"usage"},{state:"graph_command_token_is_not_declared",probe_id:"graph-unknown-subcommand",entrypoints:["graph"],expected_exit_class:"usage"},{state:"nested_command_token_is_not_declared_by_its_family",probe_id:"schema-unknown-subcommand",entrypoints:["schema"],expected_exit_class:"usage"},{state:"package_lifecycle_token_is_not_declared",probe_id:"package-unknown-action",entrypoints:["package"],expected_exit_class:"usage"}]},{code:"unsafe_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"unsupported_update_option",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"upsert_key_ambiguous",exit_code:4,sources:["sdk/structured-mutations.ts"]},{code:"upsert_key_conflict",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"upsert_key_duplicate",exit_code:2,sources:["sdk/item-transaction.ts","sdk/structured-mutations.ts"]},{code:"upsert_key_missing",exit_code:2,sources:["sdk/structured-mutations.ts"]},{code:"upsert_match_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"validate_command_references_stale_pm_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_missing_linked_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_orphaned_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_tracked_all_strict_forces_pm_internals",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_format_version_ahead_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_ahead_format_version"},{code:"validate_format_version_outdated_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_outdated_format_version"},{code:"validate_hierarchy_parent_cycle",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_hierarchy_parent_cycle_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_history_drift_chain_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_chain_mismatch"},{code:"validate_history_drift_hash_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_hash_mismatch"},{code:"validate_history_drift_missing_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_missing_stream"},{code:"validate_history_drift_unreadable_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_unreadable_stream"},{code:"validate_history_drift_version_skews",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_version_skew"},{code:"validate_history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_unknown_author_events"},{code:"validate_lifecycle_active_closure_like_metadata",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_active_terminal_parent",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_stale_blockers",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_driver_configuration",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_fence_drift",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_custom_profile_missing_required_fields",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_duplicate_issue_codes",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_acceptance_criteria",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_close_reason",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_closed_at",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_confidence",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_estimate",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_release",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_reviewer",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_risk",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_sprint",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_resolution_missing_fields",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_schema_field_option_collision",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_duplicate_item_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_history_conflict_markers",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_history_conflict_marker"},{code:"validate_storage_resurrected_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"tracked_runtime_cache_files"},{code:"validate_storage_unparseable_config",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unparseable_history",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unreadable_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_embedding_identity_changed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_stale_items_remaining",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"visible_surface_ceiling_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"workflow_duplicate_type",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_policy_approval_history_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_audit_failed",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_input_unreadable",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_invalid",exit_code:2,sources:["core/policy/workflow-policy.ts"]},{code:"workflow_policy_refused",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_registry_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_status_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_transition_malformed",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workspace_history_chain_invalid",exit_code:4,sources:["core/history/workspace-history.ts"]},{code:"workspace_history_state_conflict",exit_code:4,stable:!0,sources:["core/history/workspace-history.ts"]},{code:"workspace_root_pm_path",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"workspace_snapshot_force_required",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_manifest_mismatch",exit_code:4,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_name_reserved_fingerprint",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_not_found",exit_code:3,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_permission_denied",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_resource_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_storage_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"wrong_item_type",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]}];var X_=B_(H_([...V_,...Y_]));var dA=["mutation_receipt","entity","collection","diagnostic","stream"],lA=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),uA=new Set(["close-many","update-many"]),mA=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),pA=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function cr(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!dA.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function J_(e){let t=e.trim().replace(/\s+/gu," "),[n=t]=t.split(" ");return uA.has(n)?cr({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):lA.has(n)?cr({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):mA.has(n)?cr({command:t,kind:"collection",wrapper_key:n==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):pA.has(n)?cr({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):cr({command:t,kind:n==="get"?"entity":"diagnostic",wrapper_key:n==="get"?"item":null,cardinality:n==="get"?"one":"none",format_flag:"--json"})}var fA=We.map(e=>J_(e)),_A=new Map(fA.map(e=>[e.command,e]));function Q_(e){let t=e.trim().replace(/\s+/gu," ");if(t.length===0)throw new TypeError("command must be a non-empty command path");let[n=t]=Ur(t).split(" "),r=_A.get(n);return r?{...r,command:t}:J_(t)}function hA(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gA(e){return hA(e)&&typeof e.id=="string"&&e.id.length>0&&typeof e.status=="string"&&e.status.length>0&&Number.isSafeInteger(e.changed_field_count)&&Number(e.changed_field_count)>=0&&(e.close_reason===void 0||typeof e.close_reason=="string")&&(e.deleted===void 0||typeof e.deleted=="boolean")&&(e.previous_status===void 0||typeof e.previous_status=="string")&&(e.warnings===void 0||Array.isArray(e.warnings))}function PD(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(n){throw new TypeError(`Mutation receipt must be valid JSON: ${String(n)}`,{cause:n})}if(!gA(t))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:t.id,status:t.status,changedFieldCount:t.changed_field_count,...typeof t.close_reason=="string"?{closeReason:t.close_reason}:{},...typeof t.deleted=="boolean"?{deleted:t.deleted}:{},...typeof t.previous_status=="string"?{previousStatus:t.previous_status}:{},...Array.isArray(t.warnings)?{warnings:t.warnings}:{}}}var Ea=[{exit_code:p.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:p.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:p.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:p.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:p.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:p.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:p.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:p.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],Z_=[p.SUCCESS,p.GENERIC_FAILURE,p.USAGE,p.NOT_FOUND,p.CONFLICT,p.DEPENDENCY_FAILED],yA=new Set(["close-many","update-many"]),th=We.map(e=>({command:e,exit_codes:yA.has(e)?[...Z_,p.NO_EFFECT,p.PARTIAL_EFFECT]:[...Z_]})),eh=new Map(th.map(e=>[e.command,e])),wA=[p.SUCCESS,p.NO_EFFECT,p.PARTIAL_EFFECT];function GD(e){return wA.includes(e)}function KD(e){return Ea.some(t=>t.exit_code===e)}function nh(e){let t=e.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return eh.get(t)??eh.get(t.split(" ")[0])}function zD(e,t=We,n=th){let r=new Map(n.map(d=>[d.command,d])),i=t.filter(d=>!r.has(d)),s=e.filter(d=>{let l=r.get(d.command)??r.get(d.command.split(" ")[0]);return l===void 0||!l.exit_codes.includes(d.exit_code)}),o=new Set(e.map(d=>d.exit_code)),c=[...new Set(n.flatMap(d=>d.exit_codes))].filter(d=>!o.has(d)).sort((d,l)=>d-l);return{ok:i.length===0&&s.length===0&&c.length===0,missing_commands:i,undeclared_observations:s,unreachable_exit_codes:c}}function WD(e){return e.applied===0&&e.failed>0?{outcome:"dependency_failed",exit_code:p.DEPENDENCY_FAILED}:e.applied===0?{outcome:"no_effect",exit_code:p.NO_EFFECT}:e.skipped>0||e.failed>0||e.unmatched>0?{outcome:"partial_effect",exit_code:p.PARTIAL_EFFECT}:{outcome:"effect",exit_code:p.SUCCESS}}var N=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},be=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Xe=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function bn(e){try{return await e()}catch(t){throw t instanceof N?new f(t.message,p.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function Ra(e){try{return await e()}catch(t){throw t instanceof be?new f(t.message,p.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as vA}from"node:crypto";import kA from"node:path";var ih=1,st=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],dr=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],bA=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],SA=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,Yi=30,Xi=5e3,sh=4,AA=50;function ot(e,t){if(!SA.test(e))throw new N(`${t} must be a stable lowercase id`)}function xA(e,t){if(!Number.isFinite(e)||e<0)throw new N(`${t} must be a finite non-negative number`)}function ur(e){let t=bA.filter(i=>e[i]!==void 0);if(t.length!==1)throw new N(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function Ia(e,t){return Z(e)===Z(t)}function oh(e,t){if(t.polarity==="equals")return Ia(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function ah(e){let t=ur(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>oh(r.observed,t)===(r.expected==="pass"))}function CA(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!Ia(e.value,t.value)}function EA(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||Z(e.scope)!==Z(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return CA(ur(e),ur(t))||n[t.enforcement]<n[e.enforcement]||r}function RA(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new N("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new N("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new N("items source equals/state requires field")}function TA(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new N("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new N("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new N("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new N("dependency_kind source source_kind_state must be present or missing")}function IA(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new N("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new N("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new N("prose_edge_gap exemption selectors must not be empty")}}function Oa(e){ot(e.id,"measurement.id"),e.max_cost!==void 0&&xA(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new N(`measurement.source.kind must be one of ${dr.join(", ")}`);let n=Reflect.get(t,"kind");if(!dr.includes(n))throw new N(`measurement.source.kind must be one of ${dr.join(", ")}`);let r=t;if(r.kind==="items"&&RA(r),r.kind==="dependency_kind"&&TA(r),r.kind==="prose_edge_gap"&&IA(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new N(`${r.kind} source requires field`);return r.kind==="provider"&&(ot(r.provider,"provider source provider"),ot(r.key,"provider source key")),e}function $a(e){if(ot(e.id,"assertion.id"),ot(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new N("assertion.owner_item_id is required");let t=ur(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new N(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new N("retired assertion requires retire_reason");e.scope.kind==="filter"&&ot(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new N("assertion negative control requires pass and fail cases");if(!ah(e))throw new N(`assertion ${e.id} negative control does not prove its bound`);return e}function OA(e){if(!Array.isArray(e.allowed_providers))throw new N("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)ot(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new N("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!st.includes(t))throw new N(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new N(`gate provider policy trigger ${t} is invalid`)}}function ch(e){if(ot(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new N("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new N("gate requires at least one assertion");for(let t of e.assertion_ids)ot(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new N(`gate.triggers is required and must be an array of ${st.join(", ")}`);if(e.triggers.length===0)throw new N("gate requires at least one trigger");for(let t of e.triggers)if(!st.includes(t))throw new N(`gate trigger must be one of ${st.join(", ")}`);return e.provider_policy&&OA(e.provider_policy),e}function Sn(e){if(e.version!==ih)throw new N(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(Oa(r),t.has(`measurement:${r.id}`))throw new N(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if($a(r),t.has(`assertion:${r.id}`))throw new N(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){ch(r);let i=r.assertion_ids.filter(s=>!e.assertions.some(o=>o.id===s));if(i.length>0)throw new N(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new N(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of dh(e))if(!n.has(r))throw new N(`${i.join(", ")} references missing measurement ${r}`);return e}function Na(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)Na(n,t)}function dh(e){let t=new Map,n=(r,i)=>{let s=t.get(r)??[];s.push(i),t.set(r,s)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];Na(r.source.expression,i);for(let s of i)n(s,`derived measurement ${r.id}`)}return t}function $A(e,t){let n=e.assertion_ids.flatMap(s=>{let o=t.assertions.find(a=>a.id===s);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let s=n.pop();if(r.has(s))continue;r.add(s);let o=t.measurements.find(a=>a.id===s);o.source.kind==="provider"?i.add(o.source.provider):o.source.kind==="derived"&&Na(o.source.expression,n)}return i}function mr(){return{version:ih,measurements:[],assertions:[],gates:[]}}function NA(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let s=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?s:!s}return Ia(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function LA(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function MA(e,t){let n=[],r=Wn(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let s of i.dependencies??[]){let o=Wn(s.kind)??s.kind.trim().toLowerCase(),a=s.source_kind?.trim();o===r&&LA(e,a)&&n.push(`${i.id}->${s.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function FA(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let s=Reflect.get(i,"text");typeof s=="string"&&t.push(s)}}}return t}function DA(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function Ta(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function PA(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,s=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let a of o.dependencies??[])n.add(Ta(o.id,a.id));for(let a of[o.parent,o.blocked_by])typeof a=="string"&&n.add(Ta(o.id,a));for(let a of FA(o)){let c=[...a.matchAll(i)].map(d=>d[0]);s+=c.length,r.push({holder_id:o.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:s}}function UA(e,t){let n=PA(t.items),r=new Map;for(let o of n.prose_mentions){let a=o.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==o.holder_id),c=[...new Set(a)];for(let d of c){let l=Ta(o.holder_id,d);if(n.linked_pairs.has(l)||DA(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],s=i.map(o=>o.contributor).sort();return{value:s.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:s.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(o=>o.explicit).length,implicit_subject:i.filter(o=>!o.explicit).length}}}function jA(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function qA(e,t){let n=t.items.filter(r=>{let i=r[e.link],s=Array.isArray(i)&&i.length>0;return e.state==="present"?s:!s});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function GA(e,t){let n=e.source;return n.kind==="items"?NA(n,t):n.kind==="dependency_kind"?MA(n,t):n.kind==="prose_edge_gap"?UA(n,t):n.kind==="history"?jA(n,t):n.kind==="links"?qA(n,t):null}function lh(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function KA(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function uh(e,t,n){let r=new Array(e.length),i=0,s=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let o=i;i+=1,r[o]=await n(e[o],o)}});return await Promise.all(s),r}async function mh(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let o=n.find(d=>d.id===e.measurement);if(!o)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await ph(o,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=i.charged.has(o.id)?[]:[a.cost];return i.charged.add(o.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let s=await uh(e.operands,sh,o=>mh(o,t,n,r,i));return{value:KA(e.operator,s.map(o=>o.value)),costs:s.flatMap(o=>o.costs),population_size:Math.max(0,...s.map(o=>o.population_size)),contributors:[...new Set(s.flatMap(o=>o.contributors))]}}async function zA(e,t,n,r,i){Oa(e);let s=Date.now(),o,a=[],c=0;if(e.source.kind==="derived"){let u=await mh(e.source.expression,t,n,[...r,e.id],i);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=GA(e,t);u!==null?o=u:(o=await t.external(e.source),c=1)}let d={units:o.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-s},l=lh([...a,d],Date.now()-s);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new be(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${vA("sha256").update(Z(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function ph(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let s=i.cache.get(e.id);if(s)return s;let o=zA(e,t,n,r,i).catch(a=>{if(a instanceof Xe&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},d=new Xe(a.message,c);throw d.cause=a,d}throw a});return i.cache.set(e.id,o),o}async function La(e,t,n=[e]){return ph(e,t,n,[],{cache:new Map,charged:new Set})}function WA(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function BA(e,t,n={}){$a(e);let r=ur(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:WA(t.value,r),verdict:i?"retired":oh(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:ah(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function HA(e,t,n,r){let i=$A(e,t);if(i.size===0)return;let s=e.provider_policy,o=s?.triggers[r];if(!s||!o)throw new be(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(s.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!a.has(d))throw new be(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new be(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new be(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new be(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function rh(e,t,n,r,i){try{return await La(n,r,i)}catch(s){if(s instanceof Xe){let o=s.check?` check ${s.check}`:"",a=s.measurement_id??n.id,c=new be(`assurance gate ${e} assertion ${t} measurement ${a} source ${s.source_kind}${o} field ${s.field} could not resolve: ${s.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:s.source_kind,field:s.field,...s.check?{check:s.check}:{}});throw c.cause=s,c}throw s}}async function fh(e,t,n,r){Sn(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new be(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new be(`assurance gate ${e} does not declare trigger ${r.trigger}`);HA(i,t,n,r.trigger);let s=await uh(i.assertion_ids,sh,async c=>{let d=t.assertions.find(h=>h.id===c),l=t.measurements.find(h=>h.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let h=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(g=>!h.has(g.status))}}else if(d.scope.kind==="filter"){let h=d.scope.measurement_id,g=t.measurements.find(v=>v.id===h),y=await rh(i.id,d.id,g,n,t.measurements),w=new Set(y.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(h=>h.id===d.owner_item_id),_=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return BA(d,await rh(i.id,d.id,l,u,t.measurements),{owner_terminal:_})}),o=s.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=s.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:o?"block":a?"warn":"pass",exit_code:o?1:0,assertions:s,assertions_total:s.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:lh(s.map(c=>c.cost),Math.max(0,...s.map(c=>c.cost.duration_ms)))}}function Ji(e){return kA.join(e,"assurance.json")}async function _h(e){let t=await ee(Ji(e));return t===null?mr():Qi(t)}function Qi(e){try{return Sn(JSON.parse(e))}catch(t){throw new f("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",p.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function Zi(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function VA(e,t){e==="measurement"?Oa(t):e==="assertion"?$a(t):ch(t)}async function pr(e,t){let n=structuredClone(Zi(await _h(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function hh(e,t,n){let r=Zi(await _h(e),t).find(i=>i.id===n);if(!r)throw new be(`assurance ${t} ${n} not found`);return structuredClone(r)}async function es(e,t,n,r={}){VA(t,n);let i=await R(e),s=H(r.author,i.author_default),o=await dn({pmRoot:e,filePath:Ji(e),op:`assurance:${t}:put`,author:s,message:r.message,lockTtlSeconds:Yi,lockWaitMs:Xi,mutate:a=>{let c=a===null?mr():Qi(a),d=Zi(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&EA(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new N(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),Sn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
3
3
|
`,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...o.result,changed:o.changed}}async function Ma(e,t,n={}){let r=mr();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),Sn(r);let i=await R(e),s=H(n.author,i.author_default),o=await dn({pmRoot:e,filePath:Ji(e),op:"assurance:bundle:apply",author:s,message:n.message,lockTtlSeconds:Yi,lockWaitMs:Xi,mutate:a=>{let c=a===null?mr():Qi(a),d=[],l=[],u=(m,_,h)=>{for(let g of _){let y=m.find(w=>w.id===g.id);if(!y){m.push(structuredClone(g)),d.push(`${h}:${g.id}`);continue}if(Z(y)!==Z(g))throw new N(`assurance bundle refuses to replace divergent ${h} ${g.id}`);l.push(`${h}:${g.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),Sn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
4
4
|
`,result:{changed:d.length>0,created_ids:d,unchanged_ids:l}}}});return{...o.result,changed:o.changed}}async function gh(e,t,n,r={}){let i=await R(e),s=H(r.author,i.author_default),o=await dn({pmRoot:e,filePath:Ji(e),op:`assurance:${t}:remove`,author:s,message:r.message,lockTtlSeconds:Yi,lockWaitMs:Xi,mutate:a=>{let c=a===null?mr():Qi(a);if(t==="measurement"){let u=dh(c).get(n);if(u&&u.length>0)throw new N(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new N(`assurance assertion ${n} is referenced by gate`);let d=Zi(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new N(`assurance ${t} ${n} not found`);return d.splice(l,1),Sn(c),{raw:`${JSON.stringify(c,null,2)}
|
|
@@ -20,4 +20,4 @@ import{A as mn,B as ie,D as Fi,G as Di,H as vf,Ha as Lf,Ia as Mf,J as oa,Ja as i
|
|
|
20
20
|
`)}async function Fn(e,t){let n=So(e,t),r=await ee(n);return r?Jk(r,n):null}async function ZM(e){let t=bo(e);return await me(t)?(await Ln.readdir(t,{withFileTypes:!0})).filter(r=>r.isFile()&&r.name.endsWith(".json")).map(r=>Nr.join(t,r.name)).sort((r,i)=>i.localeCompare(r)):[]}function eF(e){let t=e.match(/^VmRSS:\s+(\d+)\s+kB$/m);if(t)return Number.parseInt(t[1],10)*1024}async function tF(e){if(process.platform==="linux")try{let t=await Ln.readFile(`/proc/${e}/status`,"utf8");return eF(t)}catch{return}}function nF(e){let t=e.lastIndexOf(")");if(t<0)return{};let r=e.slice(t+2).trim().split(/\s+/),i=Number.parseInt(r[11],10),s=Number.parseInt(r[12],10);return!Number.isFinite(i)||!Number.isFinite(s)?{}:{cpu_user_seconds:i/Gk,cpu_system_seconds:s/Gk}}async function rF(e){if(process.platform!=="linux")return{};try{let t=await Ln.readFile(`/proc/${e}/stat`,"utf8");return nF(t)}catch{return{}}}async function gd(e){let t=e.child_pid??e.worker_pid;if(!Mn(t))return;let n=await tF(t),r=await rF(t),i=e.started_at?Date.parse(e.started_at):Number.NaN,s=Number.isFinite(i)?Math.max(0,(Yk()-i)/1e3):void 0;return{recorded_at:O(),rss_bytes:n,cpu_user_seconds:r.cpu_user_seconds,cpu_system_seconds:r.cpu_system_seconds,uptime_seconds:s}}function hd(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function iF(e,t){if(!t||typeof t!="object")return{summary:{passed:0,failed:1,skipped:0},parsedResult:null};let n=t;if(e==="test-all"){let a=n.totals??{};return{summary:{items:typeof a.items=="number"?a.items:void 0,linked_tests:typeof a.linked_tests=="number"?a.linked_tests:void 0,passed:hd(a.passed),failed:hd(a.failed),skipped:hd(a.skipped),fail_on_skipped_triggered:n.fail_on_skipped_triggered===!0?!0:void 0},parsedResult:t}}let r=Array.isArray(n.run_results)?n.run_results:[],i=0,s=0,o=0;for(let a of r){if(!a||typeof a!="object")continue;let c=a.status;if(c==="passed"){i+=1;continue}if(c==="failed"||c==="refused"){s+=1;continue}o+=1}return{summary:{passed:i,failed:s,skipped:o,fail_on_skipped_triggered:n.fail_on_skipped_triggered===!0?!0:void 0},parsedResult:t}}function sF(e){let t=e.trim();if(t.length===0)return null;let n=t.match(/\[pm test-all\]\s+item\s+(\d+)\/(\d+)\s+(start|end)\s+id=([^\s]+)/i);if(n){let d=Number.parseInt(n[1],10),l=Number.parseInt(n[2],10);return{item_index:d,item_total:l,item_id:n[4],linked_test_index:void 0,linked_test_total:void 0,current_command:void 0,elapsed_ms:void 0,heartbeat_at:O(),phase:n[3]?.toLowerCase()==="end"?"finished":"running"}}let r=t.match(/\[pm test\]\s+linked-test\s+(\d+)\/(\d+)\s+(start|running|end)(?:.*elapsed_ms=(\d+))?/i);if(!r)return null;let i=Number.parseInt(r[1],10),s=Number.parseInt(r[2],10),o=r[4]?Number.parseInt(r[4],10):void 0,a=t.match(/\scommand="((?:\\.|[^"\\])*)"/),c=a?a[1].replaceAll('\\"','"').replaceAll("\\\\","\\"):void 0;return{linked_test_index:i,linked_test_total:s,current_command:c,elapsed_ms:Number.isFinite(o)?o:void 0,heartbeat_at:O(),phase:r[3]?.toLowerCase()==="end"?"finished":"running"}}function oF(e){return e.split(/\r?\n/).map(t=>t.trimEnd()).filter(t=>t.length>0)}function yd(e,t){if(t<=0)return[];let n=oF(e);return n.length<=t?n:n.slice(n.length-t)}async function Qk(e){let t=process.env.PM_BACKGROUND_CLI_ENTRY?.trim();if(t&&t.length>0){let i=Nr.resolve(e,t);if(await me(i))return i}let n=Nr.resolve(e,"dist","cli.js");if(await me(n))return n;let r=process.argv[1]?.trim();if(r&&r.length>0){let i=Nr.resolve(e,r);if(await me(i))return i}throw new f("Unable to resolve a CLI entrypoint for background test runs. Build the project or set PM_BACKGROUND_CLI_ENTRY.",p.GENERIC_FAILURE)}async function Lr(e,t){if(!Hk.has(t.status)||Mn(t.worker_pid)||t.finished_at)return t;let r={...t,status:"failed",finished_at:O(),error:t.error??"Background test run worker exited before writing terminal status."};return await Qe(e,r),r}async function vd(e){await QM(e.pmRoot);let t=Xk(e.commandArgs);if(t.length===0)throw new f("Background test run requires command arguments.",p.USAGE);let n=JM(e.kind,t,e.pmRoot),r=await bd(e.pmRoot,{});for(let l of r){let u=await Lr(e.pmRoot,l);if(u.fingerprint===n&&!(!Hk.has(u.status)||!Mn(u.worker_pid)))return{started:!1,run:{...u,duplicate_of:u.id},duplicate_of:u.id}}let i=XM(),s=O(),o=_l(e.pmRoot,i),a=hl(e.pmRoot,i),c=yl(e.pmRoot,i);await Ln.writeFile(o,"","utf8"),await Ln.writeFile(a,"","utf8");let d={id:i,kind:e.kind,status:"queued",created_at:s,updated_at:s,requested_by:e.requestedBy,fingerprint:n,command_args:t,command_label:YM(t),pm_root:e.pmRoot,global_pm_root:e.globalPmRoot,target_id:e.targetId,status_filter:e.statusFilter,attempt:typeof e.attempt=="number"&&Number.isFinite(e.attempt)&&e.attempt>=1?Math.floor(e.attempt):1,resumed_from:e.resumedFrom,resumed_by:e.resumedBy,stdout_path:o,stderr_path:a,result_path:c,progress:{phase:"queued",message:"Queued for background execution.",heartbeat_at:s}};return await Qe(e.pmRoot,d),{started:!0,run:d}}async function kd(e){let t=await Fn(e.pmRoot,e.runId);if(!t)throw new f(`Background test run ${e.runId} not found`,p.NOT_FOUND);if(wd.has(t.status))throw new f(`Background test run ${t.id} is already terminal (${t.status}).`,p.CONFLICT);let n=await Qk(process.cwd()),r=[];e.noExtensions===!0&&r.push("--no-extensions"),r.push("--path",t.pm_root,"test-runs-worker",t.id);let i={...process.env,PM_PATH:t.pm_root,PM_GLOBAL_PATH:t.global_pm_root,PM_BACKGROUND_TEST_RUN_ID:t.id,PM_BACKGROUND_TEST_RUN_ATTEMPT:String(t.attempt),PM_BACKGROUND_TEST_RUN_RESUMED_FROM:t.resumed_from??"",FORCE_COLOR:"0"},s=Bk(process.execPath,[n,...r],{cwd:process.cwd(),env:i,detached:!0,stdio:"ignore",windowsHide:!0});s.unref();let o={...t,status:"queued",worker_pid:s.pid,progress:{phase:"queued",message:"Worker process started.",heartbeat_at:O()}};return await Qe(e.pmRoot,o),o}async function Kk(e,t,n){await e,await Ln.appendFile(t,n,"utf8")}function Zk(e,t){let n=Number.parseInt(process.env[e]??"",10);return Number.isFinite(n)&&n>0?n:t}function aF(e){return{...process.env,PM_PATH:e.pm_root,PM_GLOBAL_PATH:e.global_pm_root,FORCE_COLOR:"0"}}function cF(e,t){return t?["--no-extensions",...e.command_args]:[...e.command_args]}function dF(e,t){let n=Promise.resolve();return{schedule(){n=n.then(async()=>{try{await Qe(e,t)}catch{}})},async flush(){await n}}}function zk(e,t){try{e.kill(t)}catch{}}async function lF(e,t,n,r){if(n.stopRequested)return;n.stopRequested=!0,e.stop_requested_at=O(),e.progress={...e.progress,phase:"stopping",message:"Stop requested for background run.",heartbeat_at:O()},r(),zk(t,"SIGTERM"),setTimeout(()=>zk(t,"SIGKILL"),Zk("PM_BACKGROUND_RUN_FORCE_KILL_DELAY_MS",HM)).unref?.()}function uF(e,t,n){return{phase:n,message:e,heartbeat_at:O(),item_index:t.item_index,item_total:t.item_total,item_id:t.item_id,linked_test_index:void 0,linked_test_total:void 0,current_command:void 0,elapsed_ms:void 0}}function mF(e,t,n,r){return{phase:r,message:e,heartbeat_at:O(),item_index:n.item_index??t.progress?.item_index,item_total:n.item_total??t.progress?.item_total,item_id:n.item_id??t.progress?.item_id,linked_test_index:n.linked_test_index,linked_test_total:n.linked_test_total,current_command:n.current_command,elapsed_ms:n.elapsed_ms}}function Wk(e,t,n){let r=sF(t);if(!r)return!1;let i=e.progress?.phase==="stopping"?"stopping":"running";return e.progress=r.item_id?uF(t,r,i):mF(t,e,r,i),r.phase==="finished"&&!n&&(e.progress.phase="running"),!0}function pF(e){if(e.trim().length===0)return null;try{return JSON.parse(e)}catch{return null}}function fF(e,t,n){return n?"stopped":e===0&&t.failed===0&&t.fail_on_skipped_triggered!==!0?"passed":"failed"}function _F(e,t){return{phase:"finished",message:t?"Background run stopped.":`Background run finished with status=${e.status}.`,heartbeat_at:O(),item_index:e.progress?.item_index,item_total:e.progress?.item_total,item_id:e.progress?.item_id,linked_test_index:e.progress?.linked_test_index,linked_test_total:e.progress?.linked_test_total,current_command:e.progress?.current_command,elapsed_ms:e.progress?.elapsed_ms}}async function hF(e,t,n){if(t!==null){await Le(e.result_path,`${JSON.stringify(t,null,2)}
|
|
21
21
|
`);return}await Le(e.result_path,`${JSON.stringify({parse_error:"Background run output was not valid JSON.",stdout_excerpt:yd(n,Vk)},null,2)}
|
|
22
22
|
`)}async function eb(e,t,n=!1){let r=await Fn(e,t);if(!r)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let i={...r,status:"running",started_at:r.started_at??O(),worker_pid:process.pid,progress:{phase:"running",message:"Worker started.",heartbeat_at:O()}},s=await Qk(process.cwd()),o=aF(i);await Qe(e,i);let a=cF(i,n),c=Bk(process.execPath,[s,...a],{cwd:process.cwd(),env:o,detached:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0});i.child_pid=c.pid;let d=dF(e,i),l=d.schedule,u=Promise.resolve(),m=Promise.resolve(),_="",h="",g={stopRequested:!1},y=()=>{lF(i,c,g,l)};process.on("SIGTERM",y),process.on("SIGINT",y);let w=setInterval(()=>{(async()=>(i.resource=await gd(i),i.progress.heartbeat_at=O(),l()))()},Zk("PM_BACKGROUND_RUN_RESOURCE_INTERVAL_MS",BM));w.unref?.(),c.stdout?.on("data",S=>{let x=S.toString("utf8");_+=x,u=Kk(u,i.stdout_path,x)}),c.stderr?.on("data",S=>{let x=S.toString("utf8");m=Kk(m,i.stderr_path,x),h+=x;let D=h.split(/\r?\n/);h=D.pop();let U=!1;for(let T of D){let E=T.trimEnd();E.length>0&&Wk(i,E,g.stopRequested)&&(U=!0)}U&&l()});let v=null,k=null;try{({code:v,signal:k}=await new Promise(S=>{c.on("close",(x,D)=>{S({code:x,signal:D})})}))}finally{clearInterval(w),process.off("SIGTERM",y),process.off("SIGINT",y)}await u,await m;let b=h.trimEnd();b.length>0&&Wk(i,b,g.stopRequested)&&l(),h="";let A=pF(_),C=iF(i.kind,A);return i.summary=C.summary,i.exit_code=typeof v=="number"?v:void 0,i.signal=k??void 0,i.finished_at=O(),i.status=fF(i.exit_code,C.summary,g.stopRequested),i.progress=_F(i,g.stopRequested),i.resource=await gd(i),await hF(i,A,_),await Qe(e,i),await d.flush(),i}async function bd(e,t){let n=await ZM(e),r=[];for(let c of n){let d=await ee(c);if(!d)continue;let l=await Jk(d,c);r.push(l)}let i=[];for(let c of r)i.push(await Lr(e,c));let o=(t.status?i.filter(c=>c.status===t.status):i).sort((c,d)=>{let l=Date.parse(d.updated_at)-Date.parse(c.updated_at);return Number.isFinite(l)&&l!==0?l:d.id.localeCompare(c.id)}),a=typeof t.limit=="number"&&t.limit>=0?t.limit:void 0;return a===void 0?o:o.slice(0,a)}async function tb(e,t){let n=await Fn(e,t);if(!n)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let r=await Lr(e,n),i=Mn(r.worker_pid),s=Mn(r.child_pid);r.status==="running"&&!s&&!r.finished_at&&!i&&(r.status="failed",r.finished_at=O(),r.error=r.error??"Background run process exited unexpectedly.",await Qe(e,r)),r.status==="running"&&(r.resource=await gd(r),await Qe(e,r));let o=r.progress?.heartbeat_at,a=o?Date.parse(o):Number.NaN,c=Number.isFinite(a)?Math.max(0,Yk()-a):void 0,d=Number.parseInt(process.env.PM_BACKGROUND_RUN_HEARTBEAT_STALE_MS??"",10),l=Number.isFinite(d)&&d>0?d:VM,u=r.status==="running"?c!==void 0&&c>l?"stale":"healthy":"inactive";return{run:r,health:{state:u,last_heartbeat_at:o,heartbeat_lag_ms:c,worker_alive:i,child_alive:s}}}function gF(e,t){let n=t?"SIGKILL":"SIGTERM";if(!Mn(e.worker_pid)||!e.worker_pid)return"none";try{return process.kill(e.worker_pid,n),n}catch{return"none"}}function yF(e,t){return{phase:"stopping",message:t==="none"?"Run marked stopped.":`Stop requested via ${t}.`,heartbeat_at:O(),item_index:e.progress?.item_index,item_total:e.progress?.item_total,item_id:e.progress?.item_id,linked_test_index:e.progress?.linked_test_index,linked_test_total:e.progress?.linked_test_total,current_command:e.progress?.current_command,elapsed_ms:e.progress?.elapsed_ms}}async function nb(e,t,n=!1){let r=await Fn(e,t);if(!r)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let i=await Lr(e,r);if(wd.has(i.status))return{run:i,signal_sent:"none"};let s=gF(i,n);return s==="none"&&(i.status="stopped",i.finished_at=i.finished_at??O()),i.stop_requested_at=O(),i.progress=yF(i,s),await Qe(e,i),{run:i,signal_sent:s}}async function rb(e,t,n,r=!1){let i=await Fn(e,t);if(!i)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let s=await Lr(e,i);if(!wd.has(s.status))throw new f(`Background test run ${t} is not terminal and cannot be resumed.`,p.CONFLICT);let o=await vd({pmRoot:s.pm_root,globalPmRoot:s.global_pm_root,kind:s.kind,commandArgs:s.command_args,requestedBy:n,targetId:s.target_id,statusFilter:s.status_filter,resumedFrom:s.id,resumedBy:n,attempt:s.attempt+1});if(!o.started)return o.run;let a=await kd({pmRoot:e,runId:o.run.id,noExtensions:r}),c={...s,resumed_by:a.id};return await Qe(e,c),a}async function ib(e,t,n,r){let i=await Fn(e,t);if(!i)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let s=typeof r=="number"&&Number.isFinite(r)&&r>=0?Math.floor(r):Vk,o=n==="stdout"||n==="both"?await ee(i.stdout_path)??"":"",a=n==="stderr"||n==="both"?await ee(i.stderr_path)??"":"";return{run:i,stream:n,tail:s,stdout:n==="stdout"||n==="both"?yd(o,s):[],stderr:n==="stderr"||n==="both"?yd(a,s):[]}}var vF=["queued","running","passed","failed","stopped","canceled"],kF=["stdout","stderr","both"];function bF(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(vF.includes(t))return t;throw new f(`Invalid --status value "${e}"`,p.USAGE)}function SF(e){if(e===void 0||e.trim().length===0)return"stderr";let t=e.trim().toLowerCase();if(kF.includes(t))return t;throw new f(`Invalid --stream value "${e}"`,p.USAGE)}function AF(){try{let e=wF.userInfo().username.trim();if(e.length>0)return e}catch{}}function sb(e,t){let n=[e,Zl(),t,process.env.USER,process.env.LOGNAME,process.env.USERNAME,AF()];for(let r of n){if(typeof r!="string")continue;let i=r.trim();if(i.length>0)return i}return"unknown"}async function Jt(e){await z(e)}async function iY(e,t){let n=I(process.cwd(),t.path),r=tt(process.cwd());await Jt(n);let i=await R(n),s=sb(e.author,i.author_default),o=await vd({pmRoot:n,globalPmRoot:r,kind:e.kind,commandArgs:e.commandArgs,requestedBy:s,targetId:e.targetId,statusFilter:e.statusFilter});return o.started?{started:!0,run:await kd({pmRoot:n,runId:o.run.id,noExtensions:e.noExtensions===!0})}:{started:!1,duplicate_of:o.duplicate_of,run:o.run}}async function sY(e,t){let n=I(process.cwd(),t.path);await Jt(n);let r=bF(e.status),i=Bn(e.limit,"limit"),s=await bd(n,{status:r,limit:i});return{runs:s,count:s.length,filters:{status:r,limit:i}}}async function oY(e,t){let n=I(process.cwd(),t.path);await Jt(n);let r=await tb(n,e);return{run:r.run,health:r.health}}async function aY(e,t,n){let r=I(process.cwd(),n.path);await Jt(r);let i=SF(t.stream),s=Bn(t.tail,"tail"),o=await ib(r,e,i,s);return{run:o.run,stream:o.stream,tail:o.tail,stdout:o.stdout,stderr:o.stderr}}async function cY(e,t,n){let r=I(process.cwd(),n.path);await Jt(r);let i=await nb(r,e,t.force===!0);return{run:i.run,signal_sent:i.signal_sent}}async function dY(e,t,n){let r=I(process.cwd(),n.path);await Jt(r);let i=await R(r),s=sb(t.author,i.author_default),o=await rb(r,e,s,t.noExtensions===!0);return{resumed_from:e,run:o}}async function lY(e,t){let n=I(process.cwd(),t.path);await Jt(n);let r=await eb(n,e,t.noExtensions===!0);return{id:r.id,status:r.status,exit_code:r.exit_code}}export{tS as a,c_ as b,CF as c,BF as d,iS as e,Ut as f,HF as g,sS as h,l_ as i,VF as j,or as k,YF as l,aS as m,dS as n,XF as o,p_ as p,nD as q,rD as r,I_ as s,iD as t,sD as u,oD as v,Sa as w,aD as x,cD as y,dD as z,lD as A,uD as B,YS as C,kn as D,XS as E,_D as F,hD as G,xa as H,gD as I,yD as J,wD as K,ZS as L,vD as M,kD as N,bD as O,SD as P,Ca as Q,B_ as R,xD as S,W_ as T,X_ as U,dA as V,cr as W,fA as X,Q_ as Y,gA as Z,PD as _,Ea as $,th as aa,wA as ba,GD as ca,KD as da,nh as ea,zD as fa,WD as ga,N as ha,be as ia,Xe as ja,bn as ka,Ra as la,ih as ma,st as na,dr as oa,EA as pa,Oa as qa,$a as ra,ch as sa,Sn as ta,mr as ua,La as va,BA as wa,fh as xa,pr as ya,hh as za,es as Aa,Ma as Ba,gh as Ca,yh as Da,wh as Ea,xx as Fa,IP as Ga,fC as Ha,Hh as Ia,jP as Ja,yr as Ka,qP as La,kC as Ma,bC as Na,GP as Oa,SC as Pa,Jh as Qa,eg as Ra,dU as Sa,$C as Ta,NC as Ua,ig as Va,qa as Wa,fU as Xa,wU as Ya,cg as Za,lg as _a,DU as $a,PU as ab,wr as bb,cs as cb,fg as db,_g as eb,hg as fb,gg as gb,kg as hb,bg as ib,iE as jb,Ag as kb,oE as lb,cE as mb,dE as nb,lE as ob,Tg as pb,Ig as qb,Og as rb,ls as sb,us as tb,py as ub,Nq as vb,fy as wb,hy as xb,gy as yb,vy as zb,by as Ab,xT as Bb,IG as Cb,ww as Db,Ar as Eb,bw as Fb,Sw as Gb,Aw as Hb,Cc as Ib,LI as Jb,pK as Kb,Iw as Lb,FK as Mb,jK as Nb,YI as Ob,xs as Pb,Ic as Qb,Lw as Rb,nz as Sb,yO as Tb,Cs as Ub,Es as Vb,Ts as Wb,Hw as Xb,Ds as Yb,CO as Zb,Nc as _b,IW as $b,Ht as ac,J0 as bc,Ws as cc,yv as dc,wv as ec,MB as fc,p$ as gc,O$ as hc,N$ as ic,Tr as jc,FB as kc,cH as lc,bN as mc,Zc as nc,dH as oc,lH as pc,Js as qc,xH as rc,CH as sc,EH as tc,ik as uc,UH as vc,HN as wc,od as xc,VN as yc,YN as zc,XN as Ac,jH as Bc,qH as Cc,eV as Dc,tV as Ec,nV as Fc,vk as Gc,kk as Hc,lL as Ic,bk as Jc,AV as Kc,Sk as Lc,xV as Mc,CV as Nc,Zs as Oc,EL as Pc,NV as Qc,cd as Rc,LV as Sc,dd as Tc,t2 as Uc,Tk as Vc,_2 as Wc,h2 as Xc,D2 as Yc,iY as Zc,sY as _c,oY as $c,aY as ad,cY as bd,dY as cd,lY as dd};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
//# sourceMappingURL=chunk-WFYE34TO.js.map
|