@unbrained/pm-cli 2026.11.26 → 2026.11.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli-bundle/bundle-manifest.json +1 -1
  3. package/dist/cli-bundle/chunks/{chunk-LNZKNVMT.js → chunk-5CMR4R5V.js} +2 -2
  4. package/dist/cli-bundle/chunks/{chunk-7F3UFYZA.js → chunk-5M7UTO2G.js} +2 -2
  5. package/dist/cli-bundle/chunks/{chunk-B2GM6KOM.js → chunk-63AVXDZS.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-NDS4MXZX.js → chunk-66TNCHHG.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-5AAIRHNE.js → chunk-6NJ3BONB.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-HTGN24XM.js → chunk-AVHRMUXJ.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-KCRRTJ4X.js → chunk-HTT52JL3.js} +37 -37
  10. package/dist/cli-bundle/chunks/{chunk-GQXK4KKH.js → chunk-J25DZRYJ.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-QMM46SJM.js → chunk-J6TFG34A.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-IGW3RVJC.js → chunk-JX475QVU.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-MNFCJNQA.js → chunk-KP75JTTO.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-T3GJPXIZ.js → chunk-KS47NGMQ.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-PQSEEVOA.js → chunk-O23KTJL6.js} +5 -5
  16. package/dist/cli-bundle/chunks/{chunk-KES4VHU4.js → chunk-OFX2VA5Z.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-HOLQZ56F.js → chunk-QVDEZBSV.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-BITDGTAX.js → chunk-SIRZ4VMT.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-XRCE4QNL.js → chunk-VC4BJIA7.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-FWBR3OW7.js → chunk-W7SPEGSP.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-WY7467RY.js +3 -0
  22. package/dist/cli-bundle/chunks/{chunk-5FY2VHRF.js → chunk-X6TE47CS.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-5BPDT7G2.js → chunk-XB6QEVUK.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-XYX4CXFR.js +2 -0
  25. package/dist/cli-bundle/chunks/{chunk-ZDL45VTB.js → chunk-Y5U7QCNX.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-CBBKXTJG.js → chunk-YGK6SA7P.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-DYL2N3OC.js → chunk-ZGV4ZXDS.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-WZOJSHJT.js → chunk-ZILIHDDY.js} +41 -41
  29. package/dist/cli-bundle/chunks/{field-option-collisions-CGRJEAPQ.js → field-option-collisions-UL6BIPAK.js} +2 -2
  30. package/dist/cli-bundle/chunks/{item-revision-FGDR5NSF.js → item-revision-WNUDY5DM.js} +2 -2
  31. package/dist/cli-bundle/chunks/item-transaction-ER3OWOPV.js +2 -0
  32. package/dist/cli-bundle/chunks/{mutation-actor-HGG47KXV.js → mutation-actor-SFYTD2ZB.js} +2 -2
  33. package/dist/cli-bundle/chunks/{mutation-admission-LLHIRY6O.js → mutation-admission-AVOOT3KH.js} +2 -2
  34. package/dist/cli-bundle/chunks/{register-list-query-EKSCZWEZ.js → register-list-query-Q7UW2EPV.js} +2 -2
  35. package/dist/cli-bundle/chunks/{register-mutation-ZIAOKKUJ.js → register-mutation-YNW7E3T4.js} +2 -2
  36. package/dist/cli-bundle/chunks/{register-operations-ECVBZ5FM.js → register-operations-DAUTQCIO.js} +2 -2
  37. package/dist/cli-bundle/chunks/{register-setup-3QYD5H4H.js → register-setup-VSURGF7V.js} +2 -2
  38. package/dist/cli-bundle/chunks/{stage-RSCSUYEJ.js → stage-N5GDBS5A.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-AAB3ZR7Z.js → chunk-24W63UPP.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-AVLB4L7M.js → chunk-2XGHBYDA.js} +5 -5
  41. package/dist/cli-bundle/focused-chunks/{chunk-JUG3BAZZ.js → chunk-3QRMY6KF.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-RDELKGLS.js → chunk-4HLZOOZI.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-52PHSTGP.js +27 -0
  44. package/dist/cli-bundle/focused-chunks/{chunk-QNWNUQSJ.js → chunk-7FKGIJEB.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-QSRXF6XS.js → chunk-7GZMOLQY.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-GQBWI4KA.js → chunk-AL47ODFZ.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-KEZ4VXYD.js → chunk-AN4NFFLL.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-FW5Q26HA.js → chunk-B2HJI6KA.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-YNRW2FWB.js → chunk-C2HW7BSE.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-IWEGGRRD.js → chunk-GISZWMBS.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-3GQRWIT5.js → chunk-GUAT4OAC.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-3BR5NWQI.js → chunk-H4JBS477.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-NSFS3VWP.js → chunk-HGJ4MILN.js} +37 -37
  54. package/dist/cli-bundle/focused-chunks/{chunk-NXUFVQ33.js → chunk-HSWL6L2O.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-RMJKVQYE.js → chunk-I4GY7HAP.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-UA2JNKMY.js → chunk-KMG4O2IU.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-YSZZSV6M.js → chunk-N7ZAMULP.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-TNVLDU7Z.js → chunk-REORRDPH.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-WHHFPATO.js → chunk-SXWUKNTY.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-FQWKESMI.js → chunk-UGQ2EXTU.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/chunk-YPOATPTX.js +3 -0
  62. package/dist/cli-bundle/focused-chunks/{chunk-VV2QF5IE.js → chunk-ZZYJS74B.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{field-option-collisions-WV6GPYYP.js → field-option-collisions-BP7ILGQK.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{item-revision-RPTXN7WW.js → item-revision-NOHVIOQQ.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{item-transaction-A6MVNPT7.js → item-transaction-O26COBOJ.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/{mutation-actor-6ZVW6OME.js → mutation-actor-HVJV5S76.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/{mutation-admission-2DA4CINP.js → mutation-admission-JRICEVYN.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{stage-RG3PKST7.js → stage-NSX6ASBZ.js} +2 -2
  69. package/dist/cli-bundle/main.js +2 -2
  70. package/dist/cli-bundle/sdk-authoring.js +1 -1
  71. package/dist/cli-bundle/sdk-contracts.js +1 -1
  72. package/dist/cli-bundle/sdk-core.js +1 -1
  73. package/dist/cli-bundle/sdk-governance.js +1 -1
  74. package/dist/cli-bundle/sdk-graph.js +1 -1
  75. package/dist/cli-bundle/sdk-merge.js +51 -51
  76. package/dist/cli-bundle/sdk-query.js +1 -1
  77. package/dist/cli-bundle/sdk-runtime.js +1 -1
  78. package/dist/cli-bundle/sdk-testing.js +1 -1
  79. package/dist/cli-bundle/sdk.js +1 -1
  80. package/dist/core/extensions/index.js +1 -1
  81. package/dist/core/shared/command-line.d.ts +2 -2
  82. package/dist/core/shared/command-line.js +1 -1
  83. package/dist/core/shared/secret-rules.js +5 -5
  84. package/docs/CONFIGURATION.md +1 -1
  85. package/docs/MUTATION_INTEGRITY.md +47 -0
  86. package/docs/SDK.md +3 -1
  87. package/marketplace.json +1 -1
  88. package/package.json +1 -1
  89. package/packages/pm-beads/package.json +1 -1
  90. package/packages/pm-calendar/package.json +1 -1
  91. package/packages/pm-command-kit/package.json +1 -1
  92. package/packages/pm-digital-twin/package.json +1 -1
  93. package/packages/pm-governance-audit/package.json +1 -1
  94. package/packages/pm-guide-shell/package.json +1 -1
  95. package/packages/pm-kanban/package.json +1 -1
  96. package/packages/pm-lifecycle-hooks/package.json +1 -1
  97. package/packages/pm-linked-test-adapters/package.json +1 -1
  98. package/packages/pm-search-advanced/package.json +1 -1
  99. package/packages/pm-templates/package.json +1 -1
  100. package/packages/pm-todos/package.json +1 -1
  101. package/packages/pm-vcs/package.json +1 -1
  102. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  103. package/plugins/pm-claude/package.json +1 -1
  104. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  105. package/plugins/pm-codex/package.json +1 -1
  106. package/plugins/pm-codex/plugin.json +1 -1
  107. package/runtime-dependencies.json +1 -1
  108. package/dist/cli-bundle/chunks/chunk-DUJSME77.js +0 -3
  109. package/dist/cli-bundle/chunks/chunk-RFK3ERYX.js +0 -2
  110. package/dist/cli-bundle/chunks/item-transaction-C3KAMEYO.js +0 -2
  111. package/dist/cli-bundle/focused-chunks/chunk-R6QFPHWW.js +0 -3
  112. package/dist/cli-bundle/focused-chunks/chunk-RFJ3MEFP.js +0 -27
@@ -1,4 +1,4 @@
1
- import{a as Wh}from"./chunk-MGJMQSN4.js";import{J as bh,a as Oi,b as Mr,c as Li,d as $e,e as $i,f as gh,g as yh,h as Ni,i as Pr,j as wh,k as vh,l as Tc,m as Rc,n as Fr,r as Dr,t as Mi,u as te,y as Ic}from"./chunk-CBBKXTJG.js";import{Aa as Fh,Ea as Fc,j as Z_,oa as $c,pa as Mh,qa as Nc,ra as Mc,sa as Pc,u as Nh,va as Ph}from"./chunk-T3GJPXIZ.js";import{a as qr,b as Oh,i as Ft,k as jn,l as Un,m as Gn}from"./chunk-LNZKNVMT.js";import{c as Ih}from"./chunk-KHFUHGL3.js";import{c as Lh}from"./chunk-AA52P34H.js";import{A as Dn,B as le,D as Pi,G as Fi,H as Ah,Ha as Uh,Ia as Gh,J as Oc,Ja as Wr,K as Ch,Ka as Dc,M as Th,Na as qh,Oc as Hh,Rc as Vh,U as Rh,_a as Kr,bb as qn,eb as Wn,l as xh,lb as Di,o as Sh,oa as Dh,p as jr,pa as jh,pb as Kh,qb as zh,s as Eh,wb as Bh,y as Ur,yb as jc,z as Gr}from"./chunk-MNFCJNQA.js";import{a as $h}from"./chunk-6H36ZHMI.js";import{a as kp,l as Lc}from"./chunk-QMM46SJM.js";import{N as dh,O as Ri,P as lh,Q as Ac,S as uh,T as mh,V as fh,W as ph,X as Ii,Y as _h,a as eh,b as th,c as nh,ca as Cc,d as rh,f as sh,ga as hh,j as Sc,ja as kh,k as ih,l as oh,m as Ec,n as ah,o as ch}from"./chunk-5FY2VHRF.js";import{d as hp,j as gp,r as yp,s as nn,t as wp,w as vp}from"./chunk-KES4VHU4.js";import{$b as ip,A as In,Ab as he,B as we,Ba as Or,C as Ks,Cb as dc,D as ec,Db as ep,Dd as Ci,E as kr,Ed as _p,F as br,G as xr,H as gt,I as Pm,J as Xs,La as xi,Nb as tp,Oa as Fn,Pa as Uf,Qa as Gf,R as ti,Ra as zf,Rc as uc,Sb as np,Sc as mc,T as Lt,Tc as fc,U as _i,Ub as rp,Uc as pc,V as hi,Xb as lc,Y as Pf,Ya as Bf,Zb as sp,ac as Nt,bc as op,c as ct,cc as Mt,dc as Lr,e as dt,eb as Hf,ec as tn,f as Tn,g as Ka,ga as gi,gc as ap,h as um,i as Us,ib as Yf,j as Gs,jb as Jf,jd as lp,k as mm,ka as et,l as qs,la as Ff,m as fm,mb as Xf,n as pm,na as yi,nb as Si,o as ee,oa as Df,ob as Qf,od as _c,p as Rn,pa as wi,pc as cp,q as yr,qa as vi,qb as Y,r as be,ra as ki,rb as oe,rd as up,tb as Ei,tc as dp,ub as Ce,v as lt,va as bi,vb as wt,wb as Zf,wd as mp,x as Bt,xb as en,xd as fp,ya as jf,yd as Ai,z as Ws,zb as $t,zd as pp}from"./chunk-KCRRTJ4X.js";import{C as Vf,I as U,a as Zt,b as Ir,e as Mn,f as Pn,g as cc,l as qf,u as Wf,v as C,w as Kf}from"./chunk-XRCE4QNL.js";import{A as Wa,Ab as tf,Af as kf,Bb as nf,Ca as ie,Dh as F,Fa as Qs,Hb as rf,Ib as sf,Id as _f,Jb as of,Kb as af,Kh as If,Lb as cf,Lh as Of,Ma as Um,Mb as di,Md as hf,Na as $n,Nb as li,Oa as nc,Oh as yt,Pa as ei,Q as Va,R as wr,Rd as ac,Rh as Lf,S as Oe,Sg as Rr,Sh as He,Tf as bf,Ub as df,Uf as xf,Uh as $f,V as D,Va as Gm,Vf as mi,Vh as Nf,W as ht,Wh as Mf,X as Hs,Xb as Er,Y as Ln,Yb as Ar,Z as vr,_ as Ht,_f as Cr,a as tm,ad as mf,ba as R,bd as ff,ca as ut,cb as si,cf as vf,da as Xe,db as Sr,dg as Sf,ea as Le,fa as xm,fb as ii,ga as Sm,gc as lf,ha as Qe,ia as Vs,ib as oi,ja as Em,jb as de,ka as Am,kb as Xt,kh as fi,l as nm,la as Ya,lb as _e,m as rm,ma as Ja,mb as ic,mc as ui,md as pf,mh as pi,n as sm,na as Cm,nb as oc,nc as j,ng as Ef,o as im,oa as Tm,ob as Ym,oe as gf,p as om,pa as Rm,pe as yf,pg as Af,q as am,qa as Im,qb as ai,r as at,ra as Om,rg as Tr,s as cm,sa as Lm,sb as Jm,sc as Qt,ta as Xa,tb as Nn,tg as Cf,ub as Xm,va as xe,vb as Qm,ve as wf,vh as Rf,wb as Zm,wg as Tf,xb as ef,y as dm,ya as Yt,z as lm,zb as ci,zc as uf}from"./chunk-WZOJSHJT.js";import{l as Q_}from"./chunk-IGW3RVJC.js";import{$ as Yp,$a as xc,Aa as w_,Ba as v_,C as yc,Ca as k_,D as wc,E as Tp,F as Ti,G as Rp,Ga as b_,H as Ip,Ha as x_,I as Op,Ia as S_,J as Lp,Ja as E_,K as $p,Ka as A_,L as Np,La as C_,M as Mp,Ma as T_,N as Pp,Na as R_,O as Fp,Oa as I_,P as Dp,Pa as O_,Q as jp,Qa as L_,R as Up,Ra as $_,S as Gp,Sa as N_,T as qp,Ta as M_,U as Wp,Ua as P_,V as Kp,Va as F_,W as zp,Wa as D_,X as Bp,Xa as j_,Y as Hp,Ya as bc,Z as Vp,Za as U_,_a as G_,aa as vc,ab as q_,ba as Jp,bb as W_,c as bp,ca as Xp,cb as K_,d as xp,da as Qp,db as z_,e as Sp,ea as Zp,eb as B_,fa as $r,fb as Pt,ga as e_,gb as H_,ha as t_,hb as V_,ia as n_,ib as Y_,ja as r_,jb as J_,ka as s_,la as i_,lb as X_,ma as o_,na as a_,nb as Nr,oa as c_,p as hc,pa as d_,q as Ep,qa as l_,ra as kc,sa as u_,t as Ap,ta as m_,u as gc,ua as f_,v as rn,va as p_,wa as __,x as Cp,xa as h_,ya as g_,za as y_}from"./chunk-B2GM6KOM.js";import{$ as rc,A as Vt,B as Qa,C as $m,D as Js,E as Nm,F as Za,I as Mm,K as Fm,Q as O,R as Dm,S as tc,T as jm,U as Zs,W as fe,_ as Wm,a as Z,aa as Km,b as Ue,ba as sc,c as em,ca as zm,da as ri,fa as Bm,ga as Hm,ha as Vm,i as ot,k as K,l as js,m as zt,v as Ys,x as L}from"./chunk-DUJSME77.js";import{E as qm,L as ni,O as z,P as Ze,Q as Jt,S as Ot,d as za,h as Ba,i as Be,j as zs,k as Bs,l as hm,n as gm,o as ym,p as wm,q as vm,s as km,t as bm,u as Ha}from"./chunk-SX76UGEY.js";import{A as f,C as p,D as It,E as se,F as On,G,H as Q,K as Ge,M as _m,a as Vu,m as Yu,p as Ju,s as Xu,u as Qu,w as Zu,x as Ds,y as Kt}from"./chunk-6OIHST4I.js";var ZE=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."}),eA=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),tA=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),nA=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),rA=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),sA=["--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"],iA=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"]),oA=new Set(["--only-index"]),aA=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),cA=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),dA=new Set(["--regression"]);function lA(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:nA.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:eA.has(t)&&tA.has(e)?["argv","stdin"]:["argv"]}function uA(e,t){let n=aA.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-"))||sA.some(s=>t.flag.startsWith(s));return n||oA.has(t.flag)||!iA.has(t.flag)&&!r}function mA(e,t){return t.value_arity!==void 0?t.value_arity:uA(e,t)?dA.has(t.flag)||cA.has(`${e}:${t.flag}`)?"optional":"required":"none"}function fA(e,t){let n=js(e),r=mA(n,t),s=r!=="none",i=lA(n,t.flag),o=t.description??ZE[t.flag]??`${s?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:o,takes_value:s,value_required:r==="required",...s?{value_name:t.value_name??"value"}:{},value_type:s?t.value_type??"string":"boolean",required:t.required===!0,repeatable:t.repeatable===!0||t.list===!0,input_sources:i,...i.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...rA.has(`${n}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function Yh(e,t){return t.map(n=>fA(e,n))}function Iq(e,t,n){let r=e.trim().toLowerCase(),s=[],i=new Map,o=0;for(let c of n)if(c.command.trim().toLowerCase()===r){if(o+=1,i.has(c.flag)){s.push({code:"duplicate_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} was observed more than once.`});continue}i.set(c.flag,c)}let a=new Set(t.map(({flag:c})=>c));for(let c of t){let d=i.get(c.flag);if(!d){s.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]&&s.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 i.values())a.has(c.flag)||s.push({code:"undeclared_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} is executable but absent from invocation contracts.`});return s.sort((c,d)=>c.flag.localeCompare(d.flag)||c.code.localeCompare(d.code)),{ok:s.length===0,declared_count:t.length,observed_count:o,findings:s}}import{readFile as pA}from"node:fs/promises";function Jq(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,lt(e,t)}function tg(e){return Object.prototype.toString.call(e)==="[object Object]"}function _A(e,t,n,r){let s=O();if(!tg(e))return{...r({created_at:s,author:n,text:t}),text:t,edited_at:s};let i=o=>typeof o=="string"&&o!=="";return{...e,...i(e.created_at)?{}:{created_at:s},...i(e.author)?{}:{author:n},text:t,edited_at:s}}function Jh(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new p(`Structured context events are append-only and cannot be ${t}.`,f.USAGE,{code:"structured_event_immutable"})}function hA(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function sn(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Xq(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 i=ee(n,"--add");return Object.keys(i).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:i.text?.trim()||n}catch{return n}}function gA(e){return typeof e=="object"&&e!==null&&"code"in e}function Xh(e,t){if(!Bt(e))throw new p(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,f.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function yA(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new p(`Specify ${t} text using only one input source: --add, --stdin, or --file`,f.USAGE);let r=In(),s=Bt(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",s)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return Xh(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let i=e.file.trim();if(!i)throw new p("--file path cannot be empty",f.USAGE);if(i==="-")return Xh(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await pA(i,"utf8"),emptyFlag:"--file"}}catch(o){if(gA(o)&&On(o))throw new p(`--file path not found: ${i}. Use --file - to read stdin.`,f.USAGE);let a=o instanceof Error?o.message:String(o);throw new p(`Failed to read --file path "${i}": ${a}. Use --file - to read stdin.`,f.USAGE)}}async function Qq(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new p("Specify only one of --edit or --delete",f.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new p("--delete cannot be combined with replacement text",f.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new p("--delete must be a positive integer",f.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new p("--edit must be a positive integer",f.USAGE);let n=await yA(e,t);if(e.edit!==void 0){if(!n)throw new p("--edit requires replacement text from --add, --stdin, or --file",f.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function zr(e,t){throw e instanceof p&&e.exitCode===f.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new p(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function ng(e){return e==="comments"?"--stdin":"--add -"}var Zq="annotation_flag_like_value";function wA(e){return/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(e.trim())}function vA(e){return e==="--file"?"--file <path>":e.startsWith("--file=")?e:e==="--stdin"?"--stdin":void 0}function kA(e){let t=e.value.trim(),n=e.collectionKey.replace(/s$/,""),r=vA(t),s=ng(e.collectionKey),i=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 p(`${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}`,f.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}`],...i})}return new p(`${e.textFlag} value "${t}" looks like an option, not annotation text. Use ${s} to read stdin, or use text=${t} for literal dash-leading text.`,f.USAGE,{code:"annotation_flag_like_value",required:`Use ${s} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${e.commandPrefix} ${s}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...i})}function bA(e,t){if(!((t.input.emptyFlag??"--add")!=="--add"||!wA(e)))throw kA({collectionKey:t.collectionKey,textFlag:"--add",value:e,commandPrefix:t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`})}function xA(e,t,n,r,s){if(n.input.mode!=="edit")return;let i=ff(t);if(i===void 0)return;let o=n.collectionKey.replace(/s$/,""),a=n.input.index,c=xe(r)[0]==="--pm-path"?["--pm-path",s]:[];throw new p(`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 ${i} characters. Nothing was written.`,f.USAGE,{code:"annotation_text_compacted",item_id:e,details:{collection:n.collectionKey,entry_index:a,omitted_characters:i},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 SA(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new p(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,f.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(EA(e,t),e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new p(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,f.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> ${ng(e.collectionKey)}`]})}function EA(e,t){if(t.expectAt!==void 0){if(e.input.mode!=="edit"&&e.input.mode!=="delete")throw new p(`--expect-at guards an --edit or --delete of one ${e.collectionKey.replace(/s$/,"")}`,f.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 p("--expect-at must be the non-empty created_at timestamp of the entry you read",f.USAGE,{code:"annotation_expectation_invalid",required:"Pass the created_at value of the row you read at that index, as a string."})}}function Qh(e,t,n,r,s){if(s===void 0)return;let i=t[n]?.created_at,o=typeof i=="string"?i:null;if(o===s)return;let a=t.flatMap((m,_)=>m?.created_at===s?[_+1]:[]),c=r.collectionKey.replace(/s$/,""),d=r.input.mode==="delete"?"--delete":"--edit",l=n+1,u=a.length===1?` The ${c} created at ${s} is at index ${a[0]}.`:a.length>1?` ${a.length} ${r.collectionKey} were created at ${s}: indexes ${a.join(", ")}.`:` No ${c} on ${e} was created at ${s}.`;throw new p(`${c.charAt(0).toUpperCase()}${c.slice(1)} ${l} on ${e} was created at ${o||"an unrecorded time (malformed entry)"}, not ${s}; refusing ${d} of an entry the caller did not read. Nothing was written.${u}`,f.CONFLICT,{code:"annotation_entry_mismatch",item_id:e,details:{collection:r.collectionKey,entry_index:l,expected_created_at:s,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 ${s}${d==="--edit"?' --add "<text>"':""}`]})}function AA(e,t,n,r,s,i){let o=sn(e.metadata,t),a=s?o.findIndex(c=>tg(c)&&c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],written:o,position:a}:(o.push(i({created_at:O(),author:n,text:r})),e.metadata[t]=o,{changedFields:[t],written:o,position:o.length-1})}function Zh(e,t,n){return Xm.has(e)?t.map((s,i)=>i).sort((s,i)=>Qm(t[s],t[i])||s-i).indexOf(n)+1:n+1}async function eW(e,t,n,r){SA(r,t);let s=R(process.cwd(),n.path);await U(s);let i=await C(s),o=D(i,F()),a=Or(t.limit);if(r.input.mode==="list"){let h=await Y(s,e,i.id_prefix,i.item_format,o.type_to_folder);if(!h)throw new p(`Item ${e} not found`,f.NOT_FOUND);let g=await oe(h,{schema:i.schema}),y=sn(g.document.metadata,r.collectionKey);return ji(h.id,r.collectionKey,y,a,t.includeMeta===!0)}let c=j(t.author,i.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,g;try{g=await he({pmRoot:s,settings:i,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(w){let v=sn(w.metadata,r.collectionKey),k=eg(r.input.index,v.length,r.collectionKey);return Qh(e,v,k,r,t.expectAt),Jh(v[k],"deleted"),v.splice(k,1),w.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(w){zr(w,r.conflictGuidance)}let y=sn(g.item,r.collectionKey);return ji(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??"";bA(d,r);let l=r.parseText(r.input.value??"");if(!l.trim())throw new p(`${r.input.emptyFlag??"--add"} text cannot be empty`,f.USAGE);if(xA(e,l,r,n,s),r.input.mode==="edit"){let h=r.editOp??r.op,g,y=0;try{g=await he({pmRoot:s,settings:i,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(k){let b=sn(k.metadata,r.collectionKey),x=eg(r.input.index,b.length,r.collectionKey);Qh(e,b,x,r,t.expectAt);let A=b[x];return Jh(A,"edited"),b[x]=_A(A,l,c,r.createEntry),y=Zh(r.collectionKey,b,x),k.metadata[r.collectionKey]=b,{changedFields:[r.collectionKey]}}})}catch(k){zr(k,r.conflictGuidance)}let w=sn(g.item,r.collectionKey),v=y;return ji(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 he({pmRoot:s,settings:i,id:e,op:r.op,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,skipNoop:t.ifAbsent===!0,mutate(h){let g=AA(h,r.collectionKey,c,l,t.ifAbsent===!0,r.createEntry);return m=Zh(r.collectionKey,g.written,g.position),{changedFields:g.changedFields}}})}catch(h){zr(h,r.conflictGuidance)}let _=sn(u.item,r.collectionKey);return ji(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 eg(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),s=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,i=t===1?`1 ${r}`:`${t} ${n}`;throw new p(`${s} index ${e??"(missing)"} out of range (item has ${i})`,f.USAGE)}return e-1}function CA(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 rg(e,t){if(Object.prototype.toString.call(e)!=="[object Object]")return e;let n={index:t,...e};return n.index=t,n}function TA(e,t){let n=e.length-t.length;return t.map((r,s)=>rg(r,n+s+1))}function ji(e,t,n,r,s,i,o=!1){let a=i===void 0||o?TA(n,hA(n,i!==void 0&&o?void 0:r)):i.entry===void 0?[]:[rg(i.entry,i.entryIndex)],c=i!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...i?.changedCount===void 0?{}:{changed:i.changedCount===1},...[s,i!==void 0].includes(!0)?{total_count:n.length,returned_count:a.length,has_more:c||a.length<n.length,...r!==void 0?{limit:r}:{}}:{},...CA(t,i,c)}}import{isDeepStrictEqual as dg}from"node:util";var RA=new Set(["__proto__","prototype","constructor"]),Br=Symbol("looseOptionOccurrences");function vt(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function IA(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 Gc(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 s=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:s,value:i}:{consumed:1,key:s,value:!0}}function Gi(e){return RA.has(e)}function qi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Um(t)}function Kn(e){let t=[],n=Yt(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let s=vt(n.slice(2));s.length>0&&!Gi(s)&&t.push(s)}if(r.startsWith("-")&&!r.startsWith("--")){let s=vt(r.slice(1));s.length>0&&!Gi(s)&&t.push(s)}return[...new Set(t)]}function oW(e){let t=new Set;for(let n of e)for(let r of Kn(n))t.add(r);return t}function on(e){let t=Yt(e.long)??"";if(t.startsWith("--")){let n=vt(t.slice(2));if(n.length>0&&!Gi(n))return n}return Kn(e)[0]??null}function zn(e){let t=Yt(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 lg(e,t){return[...(t.definitions??e).map(r=>zn(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function aW(e,t,n,r={}){if(t.length===0)return;let s=new Set,i=new Map,o=[],a=lg(t,r);for(let c of t){let d=Kn(c),l=zn(c);for(let u of d)s.add(u),c.enabled===!1&&i.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)){s.has(c)||ug(`--${c}`,`--${c}`,n,a);let d=i.get(c);d&&mg(d,n)}for(let c of o){let d=l=>Object.hasOwn(e,l)&&(c.definition.list!==!0||_g(c.definition,e[l]));c.keys.some(d)||fg(c.definition,c.keys[0],c.label,n)}}function ug(e,t,n,r){let s=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new p(`Unknown option '${e}' for extension command '${n}'.${s}`,f.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 mg(e,t){throw new p(`Option '${e}' is disabled for extension command '${t}'.`,f.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 fg(e,t,n,r){let s=$n(e),i=s.value_arity==="none"?n:s.value_arity==="optional"?`${n} [${s.value_name}]`:`${n} <${s.value_name}>`;throw new p(`Missing required option '${n}' for extension command '${r}'.`,f.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${i}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${i}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function OA(e){return typeof e=="string"||e==null?e:String(e)}function LA(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 pg(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 $A={string:OA,number:LA,boolean:pg};function an(e,t){return Array.isArray(e)?e.map(n=>an(n,t)):$A[t](e)}function qc(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(s=>s!=null&&s!==""):nc(e);return t?r.map(s=>an(s,t)):r}function _g(e,t){return qc(t,null,e.repeatable===!0).length>0}function NA(e,t,n,r){return n?qc(e,t,r):t?an(e,t):e}function MA(e,t,n){let r=gg(e,t);return r.length===0?n:r.map(s=>s.value)}function hg(e){return $n(e).value_arity==="none"}function Wc(e,t,n,r,s){let i=zn(e),o=s?` for extension command '${s}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new p(`Option '${i}'${o} expects ${r}; received ${a}.`,f.USAGE,{code:"extension_flag_value_invalid",flag:i,required:`Pass ${i} ${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 ${i}.`,`Run pm ${s??"<command>"} --help to review the declared flag contract.`]})}function Kc(e,t){return e.value_validation==="strict"&&t!=="string"}function gg(e,t){let n=e[Br];if(!n)return[];let r=new Set(t);return n.filter(s=>r.has(s.key))}function PA(e,t,n,r){if(hg(e))for(let s of gg(n,t)){if(s.attached!==!0)continue;let i=e.list===!0&&e.repeatable!==!0?nc(s.value):[s.value];for(let o of i){let a=ei(an(o,"boolean"),"boolean");a!==null&&Wc(e,"boolean",o,a.expected,r)}}}function FA(e,t,n,r,s){let i=Array.isArray(n)?n.flat(1/0):[n],o=r?i:i.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);Wc(e,t,a,c.expected,s)}}function zc(e,t,n,r){if(!Kc(e,n))return t;let s=n==="boolean"&&hg(e),i=o=>{let a=ei(o,n);return a===null?o:s&&typeof o=="string"?!0:Wc(e,n,o,a.expected,r)};return Array.isArray(t)?t.map(i):i(t)}function DA(e,t,n,r){for(let s of n)if(!(s===t||!Object.hasOwn(e,s))){if(Object.hasOwn(e,t)){if(r){let i=e[t],o=e[s];e[t]=[...Array.isArray(i)?i:[i],...Array.isArray(o)?o:[o]].filter(a=>a!=null)}delete e[s];continue}e[t]=e[s],delete e[s]}}function yg(e,t,n=e,r){if(t.length===0)return e;let s=Object.create(null);for(let[o,a]of Object.entries(e))s[o]=a;let i=new Set(t.map(o=>on(o)).filter(o=>o!==null));for(let o of t){let a=on(o);if(a){let c=Kn(o).filter(d=>d===a||!i.has(d));jA(s,o,a,c,n,r)}}return s}function jA(e,t,n,r,s,i){let o=t.list===!0,a=qi(t);a&&!o&&UA(e,t,n,r,a,i),DA(e,n,r,o);let c=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=NA(t.default,a,o,c));return}if(a==="boolean"&&Kc(t,a)&&PA(t,r,s,i),o){e[n]=GA(t,r,s,e[n],a,c,i);return}a&&(e[n]=zc(t,an(e[n],a),a,i))}function UA(e,t,n,r,s,i){for(let o of r)o!==n&&Object.hasOwn(e,o)&&zc(t,an(e[o],s),s,i)}function GA(e,t,n,r,s,i,o){let a=MA(n,t,r);s&&Kc(e,s)&&FA(e,s,a,i,o);let c=qc(a,s,i);return s?zc(e,c,s,o):c}function cW(e){let t=Object.create(null),n=[];Object.defineProperty(t,Br,{value:n});let r=0;for(;r<e.length;){let s=Gc(e,r);if(!s){r+=1;continue}let i=vt(s.key);if(i.length===0||Gi(i)){r+=s.consumed;continue}IA(t,i,s.value),n.push({...s,key:i}),r+=s.consumed}return t}function dW(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let r=Gc(e,n);if(r){n+=Math.max(1,r.consumed);continue}t.push(e[n]),n+=1}return t}function lW(e,t){if(t.length===0)return[...e];let n=new Set,r=new Set;for(let o of t){let a=qi(o);for(let c of Kn(o))n.add(c),a==="boolean"&&r.add(c)}if(n.size===0)return[...e];let s=[],i=0;for(;i<e.length;){if(e[i]==="--"){s.push(...e.slice(i+1));break}let o=Gc(e,i);if(o){let a=vt(o.key);if(n.has(a)){let c=e[i],d=r.has(a)&&!c.includes("=")?1:o.consumed;i+=d;continue}}s.push(e[i]),i+=1}return s}function Bc(e){return on(e)}function sg(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function uW(e,t){let n=sg(t);if(n.length===0)return[];let r=K(n);return e.flags.filter(s=>K(sg(s.target_command))===r).flatMap(s=>[...s.flags])}function wg(e,t,n,r){let s=zn(e),[i,o]=n;throw new p(`Options '${i}' and '${o}' both set ${s} for extension command '${r}' with different values.`,f.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${s} once, under the handler key '${t}'.`,why:`'${i}' and '${o}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${i}' 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 mW(e,t,n,r={}){if(t.length===0)return e;let s=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),i=zA(s),o=VA(e,i,n),a=new Set([...i.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"||WA(l)?d[l]=u:ug(l,KA(l),n,lg(s,{}));return kg(c,s,n),Object.assign(d,yg(c,s,vg(c,i),n))}function vg(e,t){let n=new Set([...t.long.values()].map(({handlerKey:i})=>i)),r=Object.entries(e).filter(([i])=>n.has(i)).flatMap(([i,o])=>(Array.isArray(o)?o.flat(1/0):[o]).map(a=>({consumed:1,key:i,value:a,attached:!0}))),s=Object.create(null);return Object.defineProperty(s,Br,{value:r}),s}function kg(e,t,n){for(let r of t){let s=on(r);if(s===null)continue;let i=zn(r),o=e[s],a=Object.hasOwn(e,s);r.enabled===!1&&a&&mg(i,n);let c=a&&(r.list!==!0||_g(r,o));r.required===!0&&r.enabled!==!1&&!c&&fg(r,s,i,n),r.list!==!0&&Array.isArray(o)&&qA(i,n)}}function qA(e,t){throw new p(`Option '${e}' for extension command '${t}' takes one value; received an array.`,f.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 ig=new Set([...[...Fm].flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[vt(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function WA(e){return ig.has(e)||ig.has(vt(e.replace(/^-{1,2}/u,"")))}function KA(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function zA(e){let t={long:new Map,short:new Map},n=(r,s,i)=>{s.length>0&&!r.has(s)&&r.set(s,i)};for(let r of e){let s=on(r);if(s===null)continue;let i={handlerKey:s,definition:r};n(t.long,s,i);let o=typeof r.short=="string"?r.short.trim():"";o.startsWith("-")&&!o.startsWith("--")&&n(t.short,o.slice(1),i)}return t}function Uc(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(vt(t.replace(/^-{1,2}/u,"")))}function BA(e,t,n,r){let s=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(s===void 0||Uc(e,t)!==void 0)return{spelling:t,value:n};let i=Uc(e,s);return i===void 0||qi(i.definition)!=="boolean"?{spelling:t,value:n}:(i.definition.list===!0||i.definition.repeatable===!0)&&Array.isArray(n)?{spelling:s,value:n.flat(1/0).map(o=>og(t,i.definition,o,r))}:i.definition.list===!0&&n!==void 0?{spelling:s,value:og(t,i.definition,n,r)}:{spelling:s,value:n===void 0?n:Ui(t,i.definition,n,r)}}function og(e,t,n,r){let s=i=>i.trim().length===0?i:String(Ui(e,t,i.trim(),r));return n==null?n:typeof n!="string"?Ui(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?Ui(e,t,n,r):n.split(",").map(s).join(",")}function Ui(e,t,n,r){let s=pg(n);return typeof s=="boolean"?!s:HA(e,t,n,r)}function HA(e,t,n,r){let s=zn(t);throw new p(`Option '${e}' for extension command '${r}' negates ${s} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,f.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${s}, 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 VA(e,t,n){let r=Object.create(null),s=new Map;for(let[i,o]of Object.entries(e)){let{spelling:a,value:c}=BA(t,i,o,n),d=Uc(t,a);if(d===void 0)r[a]=c;else if(c!==void 0){let l=s.get(d.handlerKey);l===void 0?(s.set(d.handlerKey,a),r[d.handlerKey]=c):dg(ag(d.definition,d.handlerKey,r[d.handlerKey],t,n),ag(d.definition,d.handlerKey,c,t,n))||wg(d.definition,d.handlerKey,[l,a],n)}}return r}function ag(e,t,n,r,s){let i={[t]:n};return kg(i,[e],s),yg(i,[e],vg(i,r),s)[t]}function bg(e){let t=new Map;for(let n of e){let r=on(n);if(r===null)continue;let s={definition:n,handlerKey:r,kind:qi(n),arity:$n(n).value_arity,scalar:n.list!==!0},i=[Yt(n.long),typeof n.short=="string"?n.short.trim():""];for(let o of i.filter(a=>a?.startsWith("-")===!0))t.has(o)||t.set(o,s)}return t}function xg(e,t,n,r=rC){let s=e.optionOf(n),i=t.get(n),o=i!==void 0&&r(i)?i:void 0;if(s!==void 0){let a={arity:s.arity,...s.variadic===!0?{variadic:!0}:{}};if(o?.handlerKey===s.key)return{...a,declared:o};if(i!==void 0)return a;let c=nC(t,n,s,r);return c===void 0?a:{...a,declared:c,negates:!0}}if(!(!e.includesLooseFlags||i===void 0))return o===void 0?{arity:i.arity,loose:!0}:{arity:i.arity,declared:o,loose:!0}}function Hc(e){return e.length>1&&e.startsWith("-")}var Sg=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function Eg(e,t,n){let{tokens:r}=e,s=0,i,o=!1,a=!1;for(;s<r.length||i!==void 0;){let c=i??r[s++];if(c==="--")return;if(a&&i===void 0&&YA(e,c))continue;let d=Hc(c)?XA(e,c,r[s],t,n):{consumedByCommander:!1,consumed:0};if(s+=d.consumed,i=d.group,a=d.variadic===!0,!d.consumedByCommander){if(JA(e.stop,c,o))return;o=!0}}}function YA(e,t){return!Hc(t)||e.negativeNumbersAreValues&&Sg.test(t)}function JA(e,t,n){return e!==void 0&&(e.atFirstUnrecognized||!n&&e.atSubcommand(t))}function XA(e,t,n,r,s){let i=QA(t,n,r);if(i!==void 0)return s(i.spelling,i.entry,i.value,"loose"),{consumedByCommander:!1,consumed:i.consumed};let o=r(t);if(o!==void 0){let a=o.arity==="required"||o.arity==="optional"&&n!==void 0&&(!Hc(n)||e.negativeNumbersAreValues&&Sg.test(n));return s(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,...ZA(t,r,s)}:{consumedByCommander:eC(t,r,s,e.includesLooseFlags?s:()=>{}),consumed:0}}function QA(e,t,n){let r=e.indexOf("="),s=r>1?e.slice(0,r):e,i=n(s);if(i?.loose===!0)return r>1?{spelling:s,entry:i,value:e.slice(r+1),consumed:0}:t!==void 0&&!t.startsWith("-")?{spelling:s,entry:i,value:t,consumed:1}:{spelling:s,entry:i,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 ZA(e,t,n){let r=e.slice(0,2),s=e.length>2?t(r):void 0;return s===void 0||s.loose===!0?{consumedByCommander:!1}:s.arity!=="none"?(n(r,s,e.slice(2),"commander"),{consumedByCommander:!0}):(n(r,s,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function eC(e,t,n,r){let s=e.indexOf("=");if(s>2){let o=e.slice(0,s),a=t(o);return a!==void 0&&a.arity!=="none"?(n(o,a,e.slice(s+1),"commander"),!0):(a?.declared?.kind==="boolean"&&r(o,a,e.slice(s+1),"loose"),!1)}let i=e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return i?.declared?.kind==="boolean"&&r(e,i,!1,"loose"),!1}function fW(e,t,n){let r=bg(t),s=new Map;for(let i of e)Eg(i,o=>xg(i,r,o),(o,a,c)=>{a.declared!==void 0&&tC(s,a.declared,o,c,n)})}function tC(e,t,n,r,s){let{definition:i,handlerKey:o,kind:a}=t,c=a?an(r,a):r,d=e.get(o)??new Map,l=[...d].find(([u,m])=>u!==n&&!dg(m,c));l!==void 0&&wg(i,o,[l[0],n],s),d.set(n,c),e.set(o,d)}function nC(e,t,n,r){let s=t.startsWith("--no-")?e.get(`--${t.slice(5)}`):void 0;return s!==void 0&&r(s)&&s.kind==="boolean"&&s.handlerKey===n.key?s:void 0}function rC(e){return e.scalar}function cg(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function pW(e,t,n){let r=bg(n),s=[...new Set(r.values())].filter(cg);if(s.length===0)return e;let i=new Set(n.map(m=>on(m)).filter(m=>m!==null)),o=m=>Kn(m.definition).filter(_=>_===m.handlerKey||!i.has(_)),a=new Map([...s].reverse().flatMap(m=>o(m).map(_=>[_,m]))),c=new Map;for(let m of t)Eg(m,_=>xg(m,r,_,cg)??sC(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[Br]??[];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,Br,{value:l}),u}function sC(e,t,n){let r=!n.startsWith("--")&&e.optionOf(n.slice(0,2))!==void 0;if(!e.includesLooseFlags||r)return;let s=t.get(vt(n.replace(/^-+/u,"")));return s===void 0?void 0:{arity:s.arity,declared:s,loose:!0}}var iC=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),oC=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"]),aC=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"])}),cC=new Set(["extension","install","package","packages","upgrade"]);function dC(e){let t=K(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[n,r]of Object.entries(aC))if(r.has(t))return n;return cC.has(t)?"extensions":"internal"}var Bn=Object.freeze([...at.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...ot.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:iC.has(K(e))?"core":oC.has(K(e))?"standard":"full",family:dC(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"}]),lC=Bn,Ag=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),yW=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 wW(e){let t=e===""?0:e.split(/\r?\n/).length,n=Buffer.byteLength(e,"utf8");return{lines:t,utf8_bytes:n,within_budget:t<=Ag.max_lines&&n<=Ag.max_utf8_bytes}}var Cg={core:0,standard:1,full:2,internal:3},Tg=new Map(lC.map(({command:e,tier:t})=>[e,t]));function Vc(e,t="standard"){return Tg.get(e.trim().toLowerCase())??Tg.get(K(e.trim().toLowerCase()))??t}function vW(e){return Rg(e,Bn)}function Rg(e,t){let n=Cg[e];return t.filter(r=>r.tier!=="internal"&&Cg[r.tier]<=n).map(r=>r.command)}function kW(e){return Ig(e,Bn)}function Ig(e,t){return t.filter(n=>n.family===e).map(n=>n.command)}var uC=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],mC=new Set([...zt.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 bW(e=Bn){return uC.map(t=>({family:t,commands:Ig(t,e).filter(n=>e.find(r=>r.command===n)?.tier!=="internal"&&!mC.has(n))})).filter(({commands:t})=>t.length>0)}var fC=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 xW(e,t){return pC(e,t,Bn)}function pC(e,t,n){if(t==="full")return[...e];let r=new Set(Rg(t,n));return e.filter(s=>{let i=fC[s];return i!==void 0&&r.has(i)})}var SW=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"}]),EW=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 AW(){return _C(Bn)}function _C(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:s})=>`| \`${n}\` | ${r} | ${s} |`),""].join(`
1
+ import{a as Wh}from"./chunk-MGJMQSN4.js";import{J as bh,a as Oi,b as Mr,c as Li,d as $e,e as $i,f as gh,g as yh,h as Ni,i as Pr,j as wh,k as vh,l as Tc,m as Rc,n as Fr,r as Dr,t as Mi,u as te,y as Ic}from"./chunk-YGK6SA7P.js";import{Aa as Fh,Ea as Fc,j as Z_,oa as $c,pa as Mh,qa as Nc,ra as Mc,sa as Pc,u as Nh,va as Ph}from"./chunk-KS47NGMQ.js";import{a as qr,b as Oh,i as Ft,k as jn,l as Un,m as Gn}from"./chunk-5CMR4R5V.js";import{c as Ih}from"./chunk-KHFUHGL3.js";import{c as Lh}from"./chunk-AA52P34H.js";import{A as Dn,B as le,D as Pi,G as Fi,H as Ah,Ha as Uh,Ia as Gh,J as Oc,Ja as Wr,K as Ch,Ka as Dc,M as Th,Na as qh,Oc as Hh,Rc as Vh,U as Rh,_a as Kr,bb as qn,eb as Wn,l as xh,lb as Di,o as Sh,oa as Dh,p as jr,pa as jh,pb as Kh,qb as zh,s as Eh,wb as Bh,y as Ur,yb as jc,z as Gr}from"./chunk-KP75JTTO.js";import{a as $h}from"./chunk-6H36ZHMI.js";import{a as kp,l as Lc}from"./chunk-J6TFG34A.js";import{N as dh,O as Ri,P as lh,Q as Ac,S as uh,T as mh,V as fh,W as ph,X as Ii,Y as _h,a as eh,b as th,c as nh,ca as Cc,d as rh,f as sh,ga as hh,j as Sc,ja as kh,k as ih,l as oh,m as Ec,n as ah,o as ch}from"./chunk-X6TE47CS.js";import{d as hp,j as gp,r as yp,s as nn,t as wp,w as vp}from"./chunk-OFX2VA5Z.js";import{$b as ip,A as In,Ab as he,B as we,Ba as Or,C as Ks,Cb as dc,D as ec,Db as ep,Dd as Ci,E as kr,Ed as _p,F as br,G as xr,H as gt,I as Pm,J as Xs,La as xi,Nb as tp,Oa as Fn,Pa as Uf,Qa as Gf,R as ti,Ra as zf,Rc as uc,Sb as np,Sc as mc,T as Lt,Tc as fc,U as _i,Ub as rp,Uc as pc,V as hi,Xb as lc,Y as Pf,Ya as Bf,Zb as sp,ac as Nt,bc as op,c as ct,cc as Mt,dc as Lr,e as dt,eb as Hf,ec as tn,f as Tn,g as Ka,ga as gi,gc as ap,h as um,i as Us,ib as Yf,j as Gs,jb as Jf,jd as lp,k as mm,ka as et,l as qs,la as Ff,m as fm,mb as Xf,n as pm,na as yi,nb as Si,o as ee,oa as Df,ob as Qf,od as _c,p as Rn,pa as wi,pc as cp,q as yr,qa as vi,qb as Y,r as be,ra as ki,rb as oe,rd as up,tb as Ei,tc as dp,ub as Ce,v as lt,va as bi,vb as wt,wb as Zf,wd as mp,x as Bt,xb as en,xd as fp,ya as jf,yd as Ai,z as Ws,zb as $t,zd as pp}from"./chunk-HTT52JL3.js";import{C as Vf,I as U,a as Zt,b as Ir,e as Mn,f as Pn,g as cc,l as qf,u as Wf,v as C,w as Kf}from"./chunk-VC4BJIA7.js";import{A as Wa,Ab as tf,Af as kf,Bb as nf,Ca as ie,Dh as F,Fa as Qs,Hb as rf,Ib as sf,Id as _f,Jb as of,Kb as af,Kh as If,Lb as cf,Lh as Of,Ma as Um,Mb as di,Md as hf,Na as $n,Nb as li,Oa as nc,Oh as yt,Pa as ei,Q as Va,R as wr,Rd as ac,Rh as Lf,S as Oe,Sg as Rr,Sh as He,Tf as bf,Ub as df,Uf as xf,Uh as $f,V as D,Va as Gm,Vf as mi,Vh as Nf,W as ht,Wh as Mf,X as Hs,Xb as Er,Y as Ln,Yb as Ar,Z as vr,_ as Ht,_f as Cr,a as tm,ad as mf,ba as R,bd as ff,ca as ut,cb as si,cf as vf,da as Xe,db as Sr,dg as Sf,ea as Le,fa as xm,fb as ii,ga as Sm,gc as lf,ha as Qe,ia as Vs,ib as oi,ja as Em,jb as de,ka as Am,kb as Xt,kh as fi,l as nm,la as Ya,lb as _e,m as rm,ma as Ja,mb as ic,mc as ui,md as pf,mh as pi,n as sm,na as Cm,nb as oc,nc as j,ng as Ef,o as im,oa as Tm,ob as Ym,oe as gf,p as om,pa as Rm,pe as yf,pg as Af,q as am,qa as Im,qb as ai,r as at,ra as Om,rg as Tr,s as cm,sa as Lm,sb as Jm,sc as Qt,ta as Xa,tb as Nn,tg as Cf,ub as Xm,va as xe,vb as Qm,ve as wf,vh as Rf,wb as Zm,wg as Tf,xb as ef,y as dm,ya as Yt,z as lm,zb as ci,zc as uf}from"./chunk-ZILIHDDY.js";import{l as Q_}from"./chunk-JX475QVU.js";import{$ as Yp,$a as xc,Aa as w_,Ba as v_,C as yc,Ca as k_,D as wc,E as Tp,F as Ti,G as Rp,Ga as b_,H as Ip,Ha as x_,I as Op,Ia as S_,J as Lp,Ja as E_,K as $p,Ka as A_,L as Np,La as C_,M as Mp,Ma as T_,N as Pp,Na as R_,O as Fp,Oa as I_,P as Dp,Pa as O_,Q as jp,Qa as L_,R as Up,Ra as $_,S as Gp,Sa as N_,T as qp,Ta as M_,U as Wp,Ua as P_,V as Kp,Va as F_,W as zp,Wa as D_,X as Bp,Xa as j_,Y as Hp,Ya as bc,Z as Vp,Za as U_,_a as G_,aa as vc,ab as q_,ba as Jp,bb as W_,c as bp,ca as Xp,cb as K_,d as xp,da as Qp,db as z_,e as Sp,ea as Zp,eb as B_,fa as $r,fb as Pt,ga as e_,gb as H_,ha as t_,hb as V_,ia as n_,ib as Y_,ja as r_,jb as J_,ka as s_,la as i_,lb as X_,ma as o_,na as a_,nb as Nr,oa as c_,p as hc,pa as d_,q as Ep,qa as l_,ra as kc,sa as u_,t as Ap,ta as m_,u as gc,ua as f_,v as rn,va as p_,wa as __,x as Cp,xa as h_,ya as g_,za as y_}from"./chunk-63AVXDZS.js";import{$ as rc,A as Vt,B as Qa,C as $m,D as Js,E as Nm,F as Za,I as Mm,K as Fm,Q as O,R as Dm,S as tc,T as jm,U as Zs,W as fe,_ as Wm,a as Z,aa as Km,b as Ue,ba as sc,c as em,ca as zm,da as ri,fa as Bm,ga as Hm,ha as Vm,i as ot,k as K,l as js,m as zt,v as Ys,x as L}from"./chunk-WY7467RY.js";import{E as qm,L as ni,O as z,P as Ze,Q as Jt,S as Ot,d as za,h as Ba,i as Be,j as zs,k as Bs,l as hm,n as gm,o as ym,p as wm,q as vm,s as km,t as bm,u as Ha}from"./chunk-SX76UGEY.js";import{A as f,C as p,D as It,E as se,F as On,G,H as Q,K as Ge,M as _m,a as Vu,m as Yu,p as Ju,s as Xu,u as Qu,w as Zu,x as Ds,y as Kt}from"./chunk-6OIHST4I.js";var ZE=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."}),eA=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),tA=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),nA=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),rA=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),sA=["--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"],iA=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"]),oA=new Set(["--only-index"]),aA=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),cA=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),dA=new Set(["--regression"]);function lA(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:nA.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:eA.has(t)&&tA.has(e)?["argv","stdin"]:["argv"]}function uA(e,t){let n=aA.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-"))||sA.some(s=>t.flag.startsWith(s));return n||oA.has(t.flag)||!iA.has(t.flag)&&!r}function mA(e,t){return t.value_arity!==void 0?t.value_arity:uA(e,t)?dA.has(t.flag)||cA.has(`${e}:${t.flag}`)?"optional":"required":"none"}function fA(e,t){let n=js(e),r=mA(n,t),s=r!=="none",i=lA(n,t.flag),o=t.description??ZE[t.flag]??`${s?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:o,takes_value:s,value_required:r==="required",...s?{value_name:t.value_name??"value"}:{},value_type:s?t.value_type??"string":"boolean",required:t.required===!0,repeatable:t.repeatable===!0||t.list===!0,input_sources:i,...i.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...rA.has(`${n}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function Yh(e,t){return t.map(n=>fA(e,n))}function Iq(e,t,n){let r=e.trim().toLowerCase(),s=[],i=new Map,o=0;for(let c of n)if(c.command.trim().toLowerCase()===r){if(o+=1,i.has(c.flag)){s.push({code:"duplicate_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} was observed more than once.`});continue}i.set(c.flag,c)}let a=new Set(t.map(({flag:c})=>c));for(let c of t){let d=i.get(c.flag);if(!d){s.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]&&s.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 i.values())a.has(c.flag)||s.push({code:"undeclared_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} is executable but absent from invocation contracts.`});return s.sort((c,d)=>c.flag.localeCompare(d.flag)||c.code.localeCompare(d.code)),{ok:s.length===0,declared_count:t.length,observed_count:o,findings:s}}import{readFile as pA}from"node:fs/promises";function Jq(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,lt(e,t)}function tg(e){return Object.prototype.toString.call(e)==="[object Object]"}function _A(e,t,n,r){let s=O();if(!tg(e))return{...r({created_at:s,author:n,text:t}),text:t,edited_at:s};let i=o=>typeof o=="string"&&o!=="";return{...e,...i(e.created_at)?{}:{created_at:s},...i(e.author)?{}:{author:n},text:t,edited_at:s}}function Jh(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new p(`Structured context events are append-only and cannot be ${t}.`,f.USAGE,{code:"structured_event_immutable"})}function hA(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function sn(e,t){let n=e[t];return Array.isArray(n)?n:[]}function Xq(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 i=ee(n,"--add");return Object.keys(i).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:i.text?.trim()||n}catch{return n}}function gA(e){return typeof e=="object"&&e!==null&&"code"in e}function Xh(e,t){if(!Bt(e))throw new p(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,f.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function yA(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new p(`Specify ${t} text using only one input source: --add, --stdin, or --file`,f.USAGE);let r=In(),s=Bt(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",s)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return Xh(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let i=e.file.trim();if(!i)throw new p("--file path cannot be empty",f.USAGE);if(i==="-")return Xh(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await pA(i,"utf8"),emptyFlag:"--file"}}catch(o){if(gA(o)&&On(o))throw new p(`--file path not found: ${i}. Use --file - to read stdin.`,f.USAGE);let a=o instanceof Error?o.message:String(o);throw new p(`Failed to read --file path "${i}": ${a}. Use --file - to read stdin.`,f.USAGE)}}async function Qq(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new p("Specify only one of --edit or --delete",f.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new p("--delete cannot be combined with replacement text",f.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new p("--delete must be a positive integer",f.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new p("--edit must be a positive integer",f.USAGE);let n=await yA(e,t);if(e.edit!==void 0){if(!n)throw new p("--edit requires replacement text from --add, --stdin, or --file",f.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function zr(e,t){throw e instanceof p&&e.exitCode===f.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new p(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function ng(e){return e==="comments"?"--stdin":"--add -"}var Zq="annotation_flag_like_value";function wA(e){return/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(e.trim())}function vA(e){return e==="--file"?"--file <path>":e.startsWith("--file=")?e:e==="--stdin"?"--stdin":void 0}function kA(e){let t=e.value.trim(),n=e.collectionKey.replace(/s$/,""),r=vA(t),s=ng(e.collectionKey),i=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 p(`${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}`,f.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}`],...i})}return new p(`${e.textFlag} value "${t}" looks like an option, not annotation text. Use ${s} to read stdin, or use text=${t} for literal dash-leading text.`,f.USAGE,{code:"annotation_flag_like_value",required:`Use ${s} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${e.commandPrefix} ${s}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...i})}function bA(e,t){if(!((t.input.emptyFlag??"--add")!=="--add"||!wA(e)))throw kA({collectionKey:t.collectionKey,textFlag:"--add",value:e,commandPrefix:t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`})}function xA(e,t,n,r,s){if(n.input.mode!=="edit")return;let i=ff(t);if(i===void 0)return;let o=n.collectionKey.replace(/s$/,""),a=n.input.index,c=xe(r)[0]==="--pm-path"?["--pm-path",s]:[];throw new p(`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 ${i} characters. Nothing was written.`,f.USAGE,{code:"annotation_text_compacted",item_id:e,details:{collection:n.collectionKey,entry_index:a,omitted_characters:i},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 SA(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new p(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,f.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(EA(e,t),e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new p(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,f.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> ${ng(e.collectionKey)}`]})}function EA(e,t){if(t.expectAt!==void 0){if(e.input.mode!=="edit"&&e.input.mode!=="delete")throw new p(`--expect-at guards an --edit or --delete of one ${e.collectionKey.replace(/s$/,"")}`,f.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 p("--expect-at must be the non-empty created_at timestamp of the entry you read",f.USAGE,{code:"annotation_expectation_invalid",required:"Pass the created_at value of the row you read at that index, as a string."})}}function Qh(e,t,n,r,s){if(s===void 0)return;let i=t[n]?.created_at,o=typeof i=="string"?i:null;if(o===s)return;let a=t.flatMap((m,_)=>m?.created_at===s?[_+1]:[]),c=r.collectionKey.replace(/s$/,""),d=r.input.mode==="delete"?"--delete":"--edit",l=n+1,u=a.length===1?` The ${c} created at ${s} is at index ${a[0]}.`:a.length>1?` ${a.length} ${r.collectionKey} were created at ${s}: indexes ${a.join(", ")}.`:` No ${c} on ${e} was created at ${s}.`;throw new p(`${c.charAt(0).toUpperCase()}${c.slice(1)} ${l} on ${e} was created at ${o||"an unrecorded time (malformed entry)"}, not ${s}; refusing ${d} of an entry the caller did not read. Nothing was written.${u}`,f.CONFLICT,{code:"annotation_entry_mismatch",item_id:e,details:{collection:r.collectionKey,entry_index:l,expected_created_at:s,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 ${s}${d==="--edit"?' --add "<text>"':""}`]})}function AA(e,t,n,r,s,i){let o=sn(e.metadata,t),a=s?o.findIndex(c=>tg(c)&&c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],written:o,position:a}:(o.push(i({created_at:O(),author:n,text:r})),e.metadata[t]=o,{changedFields:[t],written:o,position:o.length-1})}function Zh(e,t,n){return Xm.has(e)?t.map((s,i)=>i).sort((s,i)=>Qm(t[s],t[i])||s-i).indexOf(n)+1:n+1}async function eW(e,t,n,r){SA(r,t);let s=R(process.cwd(),n.path);await U(s);let i=await C(s),o=D(i,F()),a=Or(t.limit);if(r.input.mode==="list"){let h=await Y(s,e,i.id_prefix,i.item_format,o.type_to_folder);if(!h)throw new p(`Item ${e} not found`,f.NOT_FOUND);let g=await oe(h,{schema:i.schema}),y=sn(g.document.metadata,r.collectionKey);return ji(h.id,r.collectionKey,y,a,t.includeMeta===!0)}let c=j(t.author,i.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,g;try{g=await he({pmRoot:s,settings:i,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(w){let v=sn(w.metadata,r.collectionKey),k=eg(r.input.index,v.length,r.collectionKey);return Qh(e,v,k,r,t.expectAt),Jh(v[k],"deleted"),v.splice(k,1),w.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(w){zr(w,r.conflictGuidance)}let y=sn(g.item,r.collectionKey);return ji(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??"";bA(d,r);let l=r.parseText(r.input.value??"");if(!l.trim())throw new p(`${r.input.emptyFlag??"--add"} text cannot be empty`,f.USAGE);if(xA(e,l,r,n,s),r.input.mode==="edit"){let h=r.editOp??r.op,g,y=0;try{g=await he({pmRoot:s,settings:i,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(k){let b=sn(k.metadata,r.collectionKey),x=eg(r.input.index,b.length,r.collectionKey);Qh(e,b,x,r,t.expectAt);let A=b[x];return Jh(A,"edited"),b[x]=_A(A,l,c,r.createEntry),y=Zh(r.collectionKey,b,x),k.metadata[r.collectionKey]=b,{changedFields:[r.collectionKey]}}})}catch(k){zr(k,r.conflictGuidance)}let w=sn(g.item,r.collectionKey),v=y;return ji(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 he({pmRoot:s,settings:i,id:e,op:r.op,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,skipNoop:t.ifAbsent===!0,mutate(h){let g=AA(h,r.collectionKey,c,l,t.ifAbsent===!0,r.createEntry);return m=Zh(r.collectionKey,g.written,g.position),{changedFields:g.changedFields}}})}catch(h){zr(h,r.conflictGuidance)}let _=sn(u.item,r.collectionKey);return ji(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 eg(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),s=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,i=t===1?`1 ${r}`:`${t} ${n}`;throw new p(`${s} index ${e??"(missing)"} out of range (item has ${i})`,f.USAGE)}return e-1}function CA(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 rg(e,t){if(Object.prototype.toString.call(e)!=="[object Object]")return e;let n={index:t,...e};return n.index=t,n}function TA(e,t){let n=e.length-t.length;return t.map((r,s)=>rg(r,n+s+1))}function ji(e,t,n,r,s,i,o=!1){let a=i===void 0||o?TA(n,hA(n,i!==void 0&&o?void 0:r)):i.entry===void 0?[]:[rg(i.entry,i.entryIndex)],c=i!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...i?.changedCount===void 0?{}:{changed:i.changedCount===1},...[s,i!==void 0].includes(!0)?{total_count:n.length,returned_count:a.length,has_more:c||a.length<n.length,...r!==void 0?{limit:r}:{}}:{},...CA(t,i,c)}}import{isDeepStrictEqual as dg}from"node:util";var RA=new Set(["__proto__","prototype","constructor"]),Br=Symbol("looseOptionOccurrences");function vt(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function IA(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 Gc(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 s=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:s,value:i}:{consumed:1,key:s,value:!0}}function Gi(e){return RA.has(e)}function qi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Um(t)}function Kn(e){let t=[],n=Yt(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let s=vt(n.slice(2));s.length>0&&!Gi(s)&&t.push(s)}if(r.startsWith("-")&&!r.startsWith("--")){let s=vt(r.slice(1));s.length>0&&!Gi(s)&&t.push(s)}return[...new Set(t)]}function oW(e){let t=new Set;for(let n of e)for(let r of Kn(n))t.add(r);return t}function on(e){let t=Yt(e.long)??"";if(t.startsWith("--")){let n=vt(t.slice(2));if(n.length>0&&!Gi(n))return n}return Kn(e)[0]??null}function zn(e){let t=Yt(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 lg(e,t){return[...(t.definitions??e).map(r=>zn(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function aW(e,t,n,r={}){if(t.length===0)return;let s=new Set,i=new Map,o=[],a=lg(t,r);for(let c of t){let d=Kn(c),l=zn(c);for(let u of d)s.add(u),c.enabled===!1&&i.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)){s.has(c)||ug(`--${c}`,`--${c}`,n,a);let d=i.get(c);d&&mg(d,n)}for(let c of o){let d=l=>Object.hasOwn(e,l)&&(c.definition.list!==!0||_g(c.definition,e[l]));c.keys.some(d)||fg(c.definition,c.keys[0],c.label,n)}}function ug(e,t,n,r){let s=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new p(`Unknown option '${e}' for extension command '${n}'.${s}`,f.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 mg(e,t){throw new p(`Option '${e}' is disabled for extension command '${t}'.`,f.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 fg(e,t,n,r){let s=$n(e),i=s.value_arity==="none"?n:s.value_arity==="optional"?`${n} [${s.value_name}]`:`${n} <${s.value_name}>`;throw new p(`Missing required option '${n}' for extension command '${r}'.`,f.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${i}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${i}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function OA(e){return typeof e=="string"||e==null?e:String(e)}function LA(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 pg(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 $A={string:OA,number:LA,boolean:pg};function an(e,t){return Array.isArray(e)?e.map(n=>an(n,t)):$A[t](e)}function qc(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(s=>s!=null&&s!==""):nc(e);return t?r.map(s=>an(s,t)):r}function _g(e,t){return qc(t,null,e.repeatable===!0).length>0}function NA(e,t,n,r){return n?qc(e,t,r):t?an(e,t):e}function MA(e,t,n){let r=gg(e,t);return r.length===0?n:r.map(s=>s.value)}function hg(e){return $n(e).value_arity==="none"}function Wc(e,t,n,r,s){let i=zn(e),o=s?` for extension command '${s}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new p(`Option '${i}'${o} expects ${r}; received ${a}.`,f.USAGE,{code:"extension_flag_value_invalid",flag:i,required:`Pass ${i} ${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 ${i}.`,`Run pm ${s??"<command>"} --help to review the declared flag contract.`]})}function Kc(e,t){return e.value_validation==="strict"&&t!=="string"}function gg(e,t){let n=e[Br];if(!n)return[];let r=new Set(t);return n.filter(s=>r.has(s.key))}function PA(e,t,n,r){if(hg(e))for(let s of gg(n,t)){if(s.attached!==!0)continue;let i=e.list===!0&&e.repeatable!==!0?nc(s.value):[s.value];for(let o of i){let a=ei(an(o,"boolean"),"boolean");a!==null&&Wc(e,"boolean",o,a.expected,r)}}}function FA(e,t,n,r,s){let i=Array.isArray(n)?n.flat(1/0):[n],o=r?i:i.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);Wc(e,t,a,c.expected,s)}}function zc(e,t,n,r){if(!Kc(e,n))return t;let s=n==="boolean"&&hg(e),i=o=>{let a=ei(o,n);return a===null?o:s&&typeof o=="string"?!0:Wc(e,n,o,a.expected,r)};return Array.isArray(t)?t.map(i):i(t)}function DA(e,t,n,r){for(let s of n)if(!(s===t||!Object.hasOwn(e,s))){if(Object.hasOwn(e,t)){if(r){let i=e[t],o=e[s];e[t]=[...Array.isArray(i)?i:[i],...Array.isArray(o)?o:[o]].filter(a=>a!=null)}delete e[s];continue}e[t]=e[s],delete e[s]}}function yg(e,t,n=e,r){if(t.length===0)return e;let s=Object.create(null);for(let[o,a]of Object.entries(e))s[o]=a;let i=new Set(t.map(o=>on(o)).filter(o=>o!==null));for(let o of t){let a=on(o);if(a){let c=Kn(o).filter(d=>d===a||!i.has(d));jA(s,o,a,c,n,r)}}return s}function jA(e,t,n,r,s,i){let o=t.list===!0,a=qi(t);a&&!o&&UA(e,t,n,r,a,i),DA(e,n,r,o);let c=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=NA(t.default,a,o,c));return}if(a==="boolean"&&Kc(t,a)&&PA(t,r,s,i),o){e[n]=GA(t,r,s,e[n],a,c,i);return}a&&(e[n]=zc(t,an(e[n],a),a,i))}function UA(e,t,n,r,s,i){for(let o of r)o!==n&&Object.hasOwn(e,o)&&zc(t,an(e[o],s),s,i)}function GA(e,t,n,r,s,i,o){let a=MA(n,t,r);s&&Kc(e,s)&&FA(e,s,a,i,o);let c=qc(a,s,i);return s?zc(e,c,s,o):c}function cW(e){let t=Object.create(null),n=[];Object.defineProperty(t,Br,{value:n});let r=0;for(;r<e.length;){let s=Gc(e,r);if(!s){r+=1;continue}let i=vt(s.key);if(i.length===0||Gi(i)){r+=s.consumed;continue}IA(t,i,s.value),n.push({...s,key:i}),r+=s.consumed}return t}function dW(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let r=Gc(e,n);if(r){n+=Math.max(1,r.consumed);continue}t.push(e[n]),n+=1}return t}function lW(e,t){if(t.length===0)return[...e];let n=new Set,r=new Set;for(let o of t){let a=qi(o);for(let c of Kn(o))n.add(c),a==="boolean"&&r.add(c)}if(n.size===0)return[...e];let s=[],i=0;for(;i<e.length;){if(e[i]==="--"){s.push(...e.slice(i+1));break}let o=Gc(e,i);if(o){let a=vt(o.key);if(n.has(a)){let c=e[i],d=r.has(a)&&!c.includes("=")?1:o.consumed;i+=d;continue}}s.push(e[i]),i+=1}return s}function Bc(e){return on(e)}function sg(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function uW(e,t){let n=sg(t);if(n.length===0)return[];let r=K(n);return e.flags.filter(s=>K(sg(s.target_command))===r).flatMap(s=>[...s.flags])}function wg(e,t,n,r){let s=zn(e),[i,o]=n;throw new p(`Options '${i}' and '${o}' both set ${s} for extension command '${r}' with different values.`,f.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${s} once, under the handler key '${t}'.`,why:`'${i}' and '${o}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${i}' 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 mW(e,t,n,r={}){if(t.length===0)return e;let s=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),i=zA(s),o=VA(e,i,n),a=new Set([...i.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"||WA(l)?d[l]=u:ug(l,KA(l),n,lg(s,{}));return kg(c,s,n),Object.assign(d,yg(c,s,vg(c,i),n))}function vg(e,t){let n=new Set([...t.long.values()].map(({handlerKey:i})=>i)),r=Object.entries(e).filter(([i])=>n.has(i)).flatMap(([i,o])=>(Array.isArray(o)?o.flat(1/0):[o]).map(a=>({consumed:1,key:i,value:a,attached:!0}))),s=Object.create(null);return Object.defineProperty(s,Br,{value:r}),s}function kg(e,t,n){for(let r of t){let s=on(r);if(s===null)continue;let i=zn(r),o=e[s],a=Object.hasOwn(e,s);r.enabled===!1&&a&&mg(i,n);let c=a&&(r.list!==!0||_g(r,o));r.required===!0&&r.enabled!==!1&&!c&&fg(r,s,i,n),r.list!==!0&&Array.isArray(o)&&qA(i,n)}}function qA(e,t){throw new p(`Option '${e}' for extension command '${t}' takes one value; received an array.`,f.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 ig=new Set([...[...Fm].flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[vt(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function WA(e){return ig.has(e)||ig.has(vt(e.replace(/^-{1,2}/u,"")))}function KA(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function zA(e){let t={long:new Map,short:new Map},n=(r,s,i)=>{s.length>0&&!r.has(s)&&r.set(s,i)};for(let r of e){let s=on(r);if(s===null)continue;let i={handlerKey:s,definition:r};n(t.long,s,i);let o=typeof r.short=="string"?r.short.trim():"";o.startsWith("-")&&!o.startsWith("--")&&n(t.short,o.slice(1),i)}return t}function Uc(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(vt(t.replace(/^-{1,2}/u,"")))}function BA(e,t,n,r){let s=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(s===void 0||Uc(e,t)!==void 0)return{spelling:t,value:n};let i=Uc(e,s);return i===void 0||qi(i.definition)!=="boolean"?{spelling:t,value:n}:(i.definition.list===!0||i.definition.repeatable===!0)&&Array.isArray(n)?{spelling:s,value:n.flat(1/0).map(o=>og(t,i.definition,o,r))}:i.definition.list===!0&&n!==void 0?{spelling:s,value:og(t,i.definition,n,r)}:{spelling:s,value:n===void 0?n:Ui(t,i.definition,n,r)}}function og(e,t,n,r){let s=i=>i.trim().length===0?i:String(Ui(e,t,i.trim(),r));return n==null?n:typeof n!="string"?Ui(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?Ui(e,t,n,r):n.split(",").map(s).join(",")}function Ui(e,t,n,r){let s=pg(n);return typeof s=="boolean"?!s:HA(e,t,n,r)}function HA(e,t,n,r){let s=zn(t);throw new p(`Option '${e}' for extension command '${r}' negates ${s} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,f.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${s}, 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 VA(e,t,n){let r=Object.create(null),s=new Map;for(let[i,o]of Object.entries(e)){let{spelling:a,value:c}=BA(t,i,o,n),d=Uc(t,a);if(d===void 0)r[a]=c;else if(c!==void 0){let l=s.get(d.handlerKey);l===void 0?(s.set(d.handlerKey,a),r[d.handlerKey]=c):dg(ag(d.definition,d.handlerKey,r[d.handlerKey],t,n),ag(d.definition,d.handlerKey,c,t,n))||wg(d.definition,d.handlerKey,[l,a],n)}}return r}function ag(e,t,n,r,s){let i={[t]:n};return kg(i,[e],s),yg(i,[e],vg(i,r),s)[t]}function bg(e){let t=new Map;for(let n of e){let r=on(n);if(r===null)continue;let s={definition:n,handlerKey:r,kind:qi(n),arity:$n(n).value_arity,scalar:n.list!==!0},i=[Yt(n.long),typeof n.short=="string"?n.short.trim():""];for(let o of i.filter(a=>a?.startsWith("-")===!0))t.has(o)||t.set(o,s)}return t}function xg(e,t,n,r=rC){let s=e.optionOf(n),i=t.get(n),o=i!==void 0&&r(i)?i:void 0;if(s!==void 0){let a={arity:s.arity,...s.variadic===!0?{variadic:!0}:{}};if(o?.handlerKey===s.key)return{...a,declared:o};if(i!==void 0)return a;let c=nC(t,n,s,r);return c===void 0?a:{...a,declared:c,negates:!0}}if(!(!e.includesLooseFlags||i===void 0))return o===void 0?{arity:i.arity,loose:!0}:{arity:i.arity,declared:o,loose:!0}}function Hc(e){return e.length>1&&e.startsWith("-")}var Sg=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function Eg(e,t,n){let{tokens:r}=e,s=0,i,o=!1,a=!1;for(;s<r.length||i!==void 0;){let c=i??r[s++];if(c==="--")return;if(a&&i===void 0&&YA(e,c))continue;let d=Hc(c)?XA(e,c,r[s],t,n):{consumedByCommander:!1,consumed:0};if(s+=d.consumed,i=d.group,a=d.variadic===!0,!d.consumedByCommander){if(JA(e.stop,c,o))return;o=!0}}}function YA(e,t){return!Hc(t)||e.negativeNumbersAreValues&&Sg.test(t)}function JA(e,t,n){return e!==void 0&&(e.atFirstUnrecognized||!n&&e.atSubcommand(t))}function XA(e,t,n,r,s){let i=QA(t,n,r);if(i!==void 0)return s(i.spelling,i.entry,i.value,"loose"),{consumedByCommander:!1,consumed:i.consumed};let o=r(t);if(o!==void 0){let a=o.arity==="required"||o.arity==="optional"&&n!==void 0&&(!Hc(n)||e.negativeNumbersAreValues&&Sg.test(n));return s(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,...ZA(t,r,s)}:{consumedByCommander:eC(t,r,s,e.includesLooseFlags?s:()=>{}),consumed:0}}function QA(e,t,n){let r=e.indexOf("="),s=r>1?e.slice(0,r):e,i=n(s);if(i?.loose===!0)return r>1?{spelling:s,entry:i,value:e.slice(r+1),consumed:0}:t!==void 0&&!t.startsWith("-")?{spelling:s,entry:i,value:t,consumed:1}:{spelling:s,entry:i,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 ZA(e,t,n){let r=e.slice(0,2),s=e.length>2?t(r):void 0;return s===void 0||s.loose===!0?{consumedByCommander:!1}:s.arity!=="none"?(n(r,s,e.slice(2),"commander"),{consumedByCommander:!0}):(n(r,s,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function eC(e,t,n,r){let s=e.indexOf("=");if(s>2){let o=e.slice(0,s),a=t(o);return a!==void 0&&a.arity!=="none"?(n(o,a,e.slice(s+1),"commander"),!0):(a?.declared?.kind==="boolean"&&r(o,a,e.slice(s+1),"loose"),!1)}let i=e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return i?.declared?.kind==="boolean"&&r(e,i,!1,"loose"),!1}function fW(e,t,n){let r=bg(t),s=new Map;for(let i of e)Eg(i,o=>xg(i,r,o),(o,a,c)=>{a.declared!==void 0&&tC(s,a.declared,o,c,n)})}function tC(e,t,n,r,s){let{definition:i,handlerKey:o,kind:a}=t,c=a?an(r,a):r,d=e.get(o)??new Map,l=[...d].find(([u,m])=>u!==n&&!dg(m,c));l!==void 0&&wg(i,o,[l[0],n],s),d.set(n,c),e.set(o,d)}function nC(e,t,n,r){let s=t.startsWith("--no-")?e.get(`--${t.slice(5)}`):void 0;return s!==void 0&&r(s)&&s.kind==="boolean"&&s.handlerKey===n.key?s:void 0}function rC(e){return e.scalar}function cg(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function pW(e,t,n){let r=bg(n),s=[...new Set(r.values())].filter(cg);if(s.length===0)return e;let i=new Set(n.map(m=>on(m)).filter(m=>m!==null)),o=m=>Kn(m.definition).filter(_=>_===m.handlerKey||!i.has(_)),a=new Map([...s].reverse().flatMap(m=>o(m).map(_=>[_,m]))),c=new Map;for(let m of t)Eg(m,_=>xg(m,r,_,cg)??sC(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[Br]??[];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,Br,{value:l}),u}function sC(e,t,n){let r=!n.startsWith("--")&&e.optionOf(n.slice(0,2))!==void 0;if(!e.includesLooseFlags||r)return;let s=t.get(vt(n.replace(/^-+/u,"")));return s===void 0?void 0:{arity:s.arity,declared:s,loose:!0}}var iC=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),oC=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"]),aC=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"])}),cC=new Set(["extension","install","package","packages","upgrade"]);function dC(e){let t=K(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[n,r]of Object.entries(aC))if(r.has(t))return n;return cC.has(t)?"extensions":"internal"}var Bn=Object.freeze([...at.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...ot.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:iC.has(K(e))?"core":oC.has(K(e))?"standard":"full",family:dC(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"}]),lC=Bn,Ag=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),yW=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 wW(e){let t=e===""?0:e.split(/\r?\n/).length,n=Buffer.byteLength(e,"utf8");return{lines:t,utf8_bytes:n,within_budget:t<=Ag.max_lines&&n<=Ag.max_utf8_bytes}}var Cg={core:0,standard:1,full:2,internal:3},Tg=new Map(lC.map(({command:e,tier:t})=>[e,t]));function Vc(e,t="standard"){return Tg.get(e.trim().toLowerCase())??Tg.get(K(e.trim().toLowerCase()))??t}function vW(e){return Rg(e,Bn)}function Rg(e,t){let n=Cg[e];return t.filter(r=>r.tier!=="internal"&&Cg[r.tier]<=n).map(r=>r.command)}function kW(e){return Ig(e,Bn)}function Ig(e,t){return t.filter(n=>n.family===e).map(n=>n.command)}var uC=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],mC=new Set([...zt.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 bW(e=Bn){return uC.map(t=>({family:t,commands:Ig(t,e).filter(n=>e.find(r=>r.command===n)?.tier!=="internal"&&!mC.has(n))})).filter(({commands:t})=>t.length>0)}var fC=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 xW(e,t){return pC(e,t,Bn)}function pC(e,t,n){if(t==="full")return[...e];let r=new Set(Rg(t,n));return e.filter(s=>{let i=fC[s];return i!==void 0&&r.has(i)})}var SW=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"}]),EW=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 AW(){return _C(Bn)}function _C(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:s})=>`| \`${n}\` | ${r} | ${s} |`),""].join(`
2
2
  `)}var Yc=[{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"}],hC=new Map(Yc.map(e=>[e.exit_code,e.class]));function Wi(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function gC(e){if(!e)return[];let t=new Set,n=new Set;return e.map(r=>{let s=r.state.trim(),i=r.probe_id.trim(),o=Wi(r.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(s)||!/^[a-z][a-z0-9-]*$/.test(i)||o.length===0||t.has(s)||n.has(i))throw new TypeError("Invalid pm refusal state contract");return t.add(s),n.add(i),{state:s,probe_id:i,entrypoints:o,expected_exit_class:r.expected_exit_class}}).sort((r,s)=>r.state.localeCompare(s.state))}function yC(e,t,n,r,s){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),s.every(i=>/^[a-z][a-z0-9_]*$/.test(i)),hC.get(e.exit_code)===e.class].includes(!1)}function wC(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 s=t.get(n.canonical_code);if(!s)throw new TypeError(`Invalid pm error code contract: ${e.code}`);n=s}return n}function vC(e){let t=new Map(e.map(n=>[n.code,n]));for(let n of e){let r=wC(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 s=e.filter(i=>i.code!==r.code&&i.canonical_code===r.code).map(i=>i.code).sort();if(n.code===r.code?JSON.stringify(n.aliases)!==JSON.stringify(s):n.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${n.code}`)}}function Lg(e){let t=new Set,n=e.map(r=>{let s=r.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(s))throw new TypeError(`Invalid pm error code: ${JSON.stringify(r.code)}`);if(t.has(s))throw new TypeError(`Duplicate pm error code: ${s}`);t.add(s);let i=Wi(r.sources),o=Wi(r.emitting_commands),a=(r.canonical_code??s).trim(),c=Wi(r.aliases??[]),d=gC(r.owned_states);if(!yC(r,i,o,a,c))throw new TypeError(`Invalid pm error code contract: ${s}`);if(d.some(l=>l.expected_exit_class!==r.class))throw new TypeError(`Invalid pm refusal state exit class: ${s}`);return Object.freeze({...r,code:s,meaning:r.meaning.trim(),recovery:r.recovery.trim(),sources:i,emitting_commands:o,canonical_code:a,aliases:c,owned_states:d})});return vC(n),Object.freeze(n.sort((r,s)=>r.code.localeCompare(s.code)))}function TW(e,t){let n=Og(e,t);return Og(n.canonical_code??n.code,t)}function Og(e,t){let n=e.trim(),r=t.find(s=>s.code===n);if(!r)throw new TypeError(`Unknown pm error code "${n}"`);return r}var kC="Inspect the structured error guidance, then retry the suggested command when one is present.",bC=new Map(Yc.map(e=>[e.exit_code,e.class]));function $g(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:bC.get(t.exit_code),recovery:kC,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 Ng=[{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_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 Mg=[{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 Pg=Lg($g([...Ng,...Mg]));var xC=["mutation_receipt","entity","collection","diagnostic","stream"],SC=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),EC=new Set(["close-many","update-many"]),AC=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),CC=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function Hr(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!xC.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function Fg(e){let t=e.trim().replace(/\s+/gu," "),[n=t]=t.split(" ");return EC.has(n)?Hr({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):SC.has(n)?Hr({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):AC.has(n)?Hr({command:t,kind:"collection",wrapper_key:n==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):CC.has(n)?Hr({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):Hr({command:t,kind:n==="get"?"entity":"diagnostic",wrapper_key:n==="get"?"item":null,cardinality:n==="get"?"one":"none",format_flag:"--json"})}var TC=at.map(e=>Fg(e)),RC=new Map(TC.map(e=>[e.command,e]));function Dg(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]=js(t).split(" "),r=RC.get(n);return r?{...r,command:t}:Fg(t)}function IC(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function OC(e){return IC(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 GW(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(!OC(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 Jc=[{exit_code:f.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:f.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:f.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:f.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:f.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:f.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:f.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:f.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],jg=[f.SUCCESS,f.GENERIC_FAILURE,f.USAGE,f.NOT_FOUND,f.CONFLICT,f.DEPENDENCY_FAILED],LC=new Set(["close-many","update-many"]),Gg=at.map(e=>({command:e,exit_codes:LC.has(e)?[...jg,f.NO_EFFECT,f.PARTIAL_EFFECT]:[...jg]})),Ug=new Map(Gg.map(e=>[e.command,e])),$C=[f.SUCCESS,f.NO_EFFECT,f.PARTIAL_EFFECT];function zW(e){return $C.includes(e)}function BW(e){return Jc.some(t=>t.exit_code===e)}function qg(e){let t=e.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return Ug.get(t)??Ug.get(t.split(" ")[0])}function HW(e,t=at,n=Gg){let r=new Map(n.map(d=>[d.command,d])),s=t.filter(d=>!r.has(d)),i=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:s.length===0&&i.length===0&&c.length===0,missing_commands:s,undeclared_observations:i,unreachable_exit_codes:c}}function VW(e){return e.applied===0&&e.failed>0?{outcome:"dependency_failed",exit_code:f.DEPENDENCY_FAILED}:e.applied===0?{outcome:"no_effect",exit_code:f.NO_EFFECT}:e.skipped>0||e.failed>0||e.unmatched>0?{outcome:"partial_effect",exit_code:f.PARTIAL_EFFECT}:{outcome:"effect",exit_code:f.SUCCESS}}var M=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},Ne=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},mt=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 Hn(e){try{return await e()}catch(t){throw t instanceof M?new p(t.message,f.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function Xc(e){try{return await e()}catch(t){throw t instanceof Ne?new p(t.message,f.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as NC}from"node:crypto";import MC from"node:path";var Kg=1,kt=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],Vr=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],PC=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],FC=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,Ki=30,zi=5e3,zg=4,DC=50;function bt(e,t){if(!FC.test(e))throw new M(`${t} must be a stable lowercase id`)}function jC(e,t){if(!Number.isFinite(e)||e<0)throw new M(`${t} must be a finite non-negative number`)}function Jr(e){let t=PC.filter(s=>e[s]!==void 0);if(t.length!==1)throw new M(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function Zc(e,t){return Z(e)===Z(t)}function Bg(e,t){if(t.polarity==="equals")return Zc(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(s=>r.includes(s))}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 Hg(e){let t=Jr(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>Bg(r.observed,t)===(r.expected==="pass"))}function UC(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(s=>!n.includes(s))}return!Zc(e.value,t.value)}function GC(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 UC(Jr(e),Jr(t))||n[t.enforcement]<n[e.enforcement]||r}function qC(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new M("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 M("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new M("items source equals/state requires field")}function WC(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new M("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 M("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 M("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 M("dependency_kind source source_kind_state must be present or missing")}function KC(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new M("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 M("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 M("prose_edge_gap exemption selectors must not be empty")}}function ed(e){bt(e.id,"measurement.id"),e.max_cost!==void 0&&jC(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new M(`measurement.source.kind must be one of ${Vr.join(", ")}`);let n=Reflect.get(t,"kind");if(!Vr.includes(n))throw new M(`measurement.source.kind must be one of ${Vr.join(", ")}`);let r=t;if(r.kind==="items"&&qC(r),r.kind==="dependency_kind"&&WC(r),r.kind==="prose_edge_gap"&&KC(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new M(`${r.kind} source requires field`);return r.kind==="provider"&&(bt(r.provider,"provider source provider"),bt(r.key,"provider source key")),e}function td(e){if(bt(e.id,"assertion.id"),bt(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new M("assertion.owner_item_id is required");let t=Jr(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new M(`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 M("retired assertion requires retire_reason");e.scope.kind==="filter"&&bt(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 M("assertion negative control requires pass and fail cases");if(!Hg(e))throw new M(`assertion ${e.id} negative control does not prove its bound`);return e}function zC(e){if(!Array.isArray(e.allowed_providers))throw new M("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)bt(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new M("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!kt.includes(t))throw new M(`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 M(`gate provider policy trigger ${t} is invalid`)}}function Vg(e){if(bt(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new M("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new M("gate requires at least one assertion");for(let t of e.assertion_ids)bt(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new M(`gate.triggers is required and must be an array of ${kt.join(", ")}`);if(e.triggers.length===0)throw new M("gate requires at least one trigger");for(let t of e.triggers)if(!kt.includes(t))throw new M(`gate trigger must be one of ${kt.join(", ")}`);return e.provider_policy&&zC(e.provider_policy),e}function Vn(e){if(e.version!==Kg)throw new M(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(ed(r),t.has(`measurement:${r.id}`))throw new M(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(td(r),t.has(`assertion:${r.id}`))throw new M(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){Vg(r);let s=r.assertion_ids.filter(i=>!e.assertions.some(o=>o.id===i));if(s.length>0)throw new M(`gate ${r.id} references missing assertions: ${s.join(", ")}`);if(t.has(`gate:${r.id}`))throw new M(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,s]of Yg(e))if(!n.has(r))throw new M(`${s.join(", ")} references missing measurement ${r}`);return e}function nd(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)nd(n,t)}function Yg(e){let t=new Map,n=(r,s)=>{let i=t.get(r)??[];i.push(s),t.set(r,i)};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 s=[];nd(r.source.expression,s);for(let i of s)n(i,`derived measurement ${r.id}`)}return t}function BC(e,t){let n=e.assertion_ids.flatMap(i=>{let o=t.assertions.find(a=>a.id===i);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,s=new Set;for(;n.length>0;){let i=n.pop();if(r.has(i))continue;r.add(i);let o=t.measurements.find(a=>a.id===i);o.source.kind==="provider"?s.add(o.source.provider):o.source.kind==="derived"&&nd(o.source.expression,n)}return s}function Xr(){return{version:Kg,measurements:[],assertions:[],gates:[]}}function HC(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(s=>r.tags?.includes(s)))&&(e.field===void 0||(()=>{let s=r[e.field];if(e.state!==void 0){let i=s==null||s===""||Array.isArray(s)&&s.length===0;return e.state==="missing"?i:!i}return Zc(s,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function VC(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 YC(e,t){let n=[],r=Tr(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let s of t.items)for(let i of s.dependencies??[]){let o=Tr(i.kind)??i.kind.trim().toLowerCase(),a=i.source_kind?.trim();o===r&&VC(e,a)&&n.push(`${s.id}->${i.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function JC(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 s of r)if(typeof s=="string")t.push(s);else if(typeof s=="object"&&s!==null){let i=Reflect.get(s,"text");typeof i=="string"&&t.push(i)}}}return t}function XC(e,t,n,r){return e.some(s=>s.holder_id.trim().toLowerCase()===t.toLowerCase()&&(s.target_id===void 0||s.target_id.trim().toLowerCase()===n.toLowerCase())&&(s.text_contains===void 0||r.toLowerCase().includes(s.text_contains.trim().toLowerCase())))}function Qc(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function QC(e){let t=new Map,n=new Set,r=[],s=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,i=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let a of o.dependencies??[])n.add(Qc(o.id,a.id));for(let a of[o.parent,o.blocked_by])typeof a=="string"&&n.add(Qc(o.id,a));for(let a of JC(o)){let c=[...a.matchAll(s)].map(d=>d[0]);i+=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:i}}function ZC(e,t){let n=QC(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=Qc(o.holder_id,d);if(n.linked_pairs.has(l)||XC(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 s=[...r.values()],i=s.map(o=>o.contributor).sort();return{value:i.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:i.slice(0,e.sample_limit??25),partitions:{explicit_subject:s.filter(o=>o.explicit).length,implicit_subject:s.filter(o=>!o.explicit).length}}}function eT(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 tT(e,t){let n=t.items.filter(r=>{let s=r[e.link],i=Array.isArray(s)&&s.length>0;return e.state==="present"?i:!i});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function nT(e,t){let n=e.source;return n.kind==="items"?HC(n,t):n.kind==="dependency_kind"?YC(n,t):n.kind==="prose_edge_gap"?ZC(n,t):n.kind==="history"?eT(n,t):n.kind==="links"?tT(n,t):null}function Jg(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 rT(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 Xg(e,t,n){let r=new Array(e.length),s=0,i=Array.from({length:Math.min(t,e.length)},async()=>{for(;s<e.length;){let o=s;s+=1,r[o]=await n(e[o],o)}});return await Promise.all(i),r}async function Qg(e,t,n,r,s){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 Zg(o,t,n,r,s);if(typeof a.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=s.charged.has(o.id)?[]:[a.cost];return s.charged.add(o.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let i=await Xg(e.operands,zg,o=>Qg(o,t,n,r,s));return{value:rT(e.operator,i.map(o=>o.value)),costs:i.flatMap(o=>o.costs),population_size:Math.max(0,...i.map(o=>o.population_size)),contributors:[...new Set(i.flatMap(o=>o.contributors))]}}async function sT(e,t,n,r,s){ed(e);let i=Date.now(),o,a=[],c=0;if(e.source.kind==="derived"){let u=await Qg(e.source.expression,t,n,[...r,e.id],s);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=nT(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()-i},l=Jg([...a,d],Date.now()-i);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new Ne(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${NC("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 Zg(e,t,n,r,s){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let i=s.cache.get(e.id);if(i)return i;let o=sT(e,t,n,r,s).catch(a=>{if(a instanceof mt&&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 mt(a.message,c);throw d.cause=a,d}throw a});return s.cache.set(e.id,o),o}async function rd(e,t,n=[e]){return Zg(e,t,n,[],{cache:new Map,charged:new Set})}function iT(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 oT(e,t,n={}){td(e);let r=Jr(e),s=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:iT(t.value,r),verdict:s?"retired":Bg(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:Hg(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function aT(e,t,n,r){let s=BC(e,t);if(s.size===0)return;let i=e.provider_policy,o=i?.triggers[r];if(!i||!o)throw new Ne(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(i.allowed_providers),c={low:0,medium:1,high:2};for(let d of s){if(!a.has(d))throw new Ne(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new Ne(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new Ne(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new Ne(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function Wg(e,t,n,r,s){try{return await rd(n,r,s)}catch(i){if(i instanceof mt){let o=i.check?` check ${i.check}`:"",a=i.measurement_id??n.id,c=new Ne(`assurance gate ${e} assertion ${t} measurement ${a} source ${i.source_kind}${o} field ${i.field} could not resolve: ${i.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:i.source_kind,field:i.field,...i.check?{check:i.check}:{}});throw c.cause=i,c}throw i}}async function ey(e,t,n,r){Vn(t);let s=t.gates.find(c=>c.id===e);if(!s)throw new Ne(`assurance gate ${e} not found`);if(!s.triggers.includes(r.trigger))throw new Ne(`assurance gate ${e} does not declare trigger ${r.trigger}`);aT(s,t,n,r.trigger);let i=await Xg(s.assertion_ids,zg,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 Wg(s.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 oT(d,await Wg(s.id,d.id,l,u,t.measurements),{owner_terminal:_})}),o=i.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=i.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:s.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:i,assertions_total:i.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:Jg(i.map(c=>c.cost),Math.max(0,...i.map(c=>c.cost.duration_ms)))}}function Bi(e){return MC.join(e,"assurance.json")}async function ty(e){let t=await Q(Bi(e));return t===null?Xr():Hi(t)}function Hi(e){try{return Vn(JSON.parse(e))}catch(t){throw new p("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",f.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 Vi(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function cT(e,t){e==="measurement"?ed(t):e==="assertion"?td(t):Vg(t)}async function Qr(e,t){let n=structuredClone(Vi(await ty(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function ny(e,t,n){let r=Vi(await ty(e),t).find(s=>s.id===n);if(!r)throw new Ne(`assurance ${t} ${n} not found`);return structuredClone(r)}async function Yi(e,t,n,r={}){cT(t,n);let s=await C(e),i=j(r.author,s.author_default),o=await Pn({pmRoot:e,filePath:Bi(e),op:`assurance:${t}:put`,author:i,message:r.message,lockTtlSeconds:Ki,lockWaitMs:zi,mutate:a=>{let c=a===null?Xr():Hi(a),d=Vi(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&GC(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new M(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),Vn(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 sd(e,t,n={}){let r=Xr();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),Vn(r);let s=await C(e),i=j(n.author,s.author_default),o=await Pn({pmRoot:e,filePath:Bi(e),op:"assurance:bundle:apply",author:i,message:n.message,lockTtlSeconds:Ki,lockWaitMs:zi,mutate:a=>{let c=a===null?Xr():Hi(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 M(`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"),Vn(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 ry(e,t,n,r={}){let s=await C(e),i=j(r.author,s.author_default),o=await Pn({pmRoot:e,filePath:Bi(e),op:`assurance:${t}:remove`,author:i,message:r.message,lockTtlSeconds:Ki,lockWaitMs:zi,mutate:a=>{let c=a===null?Xr():Hi(a);if(t==="measurement"){let u=Yg(c).get(n);if(u&&u.length>0)throw new M(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new M(`assurance assertion ${n} is referenced by gate`);let d=Vi(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new M(`assurance ${t} ${n} not found`);return d.splice(l,1),Vn(c),{raw:`${JSON.stringify(c,null,2)}
@@ -28,4 +28,4 @@ ${t}`;for(let r of cU)if(r.regex.test(n))return{code:r.code};return null}functio
28
28
  `)}async function hr(e,t){let n=Ja(e,t),r=await Q(n);return r?dE(r,n):null}async function rq(e){let t=Ya(e);return await se(t)?(await pr.readdir(t,{withFileTypes:!0})).filter(r=>r.isFile()&&r.name.endsWith(".json")).map(r=>$s.join(t,r.name)).sort((r,s)=>s.localeCompare(r)):[]}function sq(e){let t=e.match(/^VmRSS:\s+(\d+)\s+kB$/m);if(t)return Number.parseInt(t[1],10)*1024}async function iq(e){if(process.platform==="linux")try{let t=await pr.readFile(`/proc/${e}/status`,"utf8");return sq(t)}catch{return}}function oq(e){let t=e.lastIndexOf(")");if(t<0)return{};let r=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(r[11],10),i=Number.parseInt(r[12],10);return!Number.isFinite(s)||!Number.isFinite(i)?{}:{cpu_user_seconds:s/eE,cpu_system_seconds:i/eE}}async function aq(e){if(process.platform!=="linux")return{};try{let t=await pr.readFile(`/proc/${e}/stat`,"utf8");return oq(t)}catch{return{}}}async function Ou(e){let t=e.child_pid??e.worker_pid;if(!_r(t))return;let n=await iq(t),r=await aq(t),s=e.started_at?Date.parse(e.started_at):Number.NaN,i=Number.isFinite(s)?Math.max(0,(aE()-s)/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:i}}function Iu(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function cq(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:Iu(a.passed),failed:Iu(a.failed),skipped:Iu(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:[],s=0,i=0,o=0;for(let a of r){if(!a||typeof a!="object")continue;let c=a.status;if(c==="passed"){s+=1;continue}if(c==="failed"||c==="refused"){i+=1;continue}o+=1}return{summary:{passed:s,failed:i,skipped:o,fail_on_skipped_triggered:n.fail_on_skipped_triggered===!0?!0:void 0},parsedResult:t}}function dq(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 s=Number.parseInt(r[1],10),i=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:s,linked_test_total:i,current_command:c,elapsed_ms:Number.isFinite(o)?o:void 0,heartbeat_at:O(),phase:r[3]?.toLowerCase()==="end"?"finished":"running"}}function lq(e){return e.split(/\r?\n/).map(t=>t.trimEnd()).filter(t=>t.length>0)}function Lu(e,t){if(t<=0)return[];let n=lq(e);return n.length<=t?n:n.slice(n.length-t)}async function lE(e){let t=process.env.PM_BACKGROUND_CLI_ENTRY?.trim();if(t&&t.length>0){let s=$s.resolve(e,t);if(await se(s))return s}let n=$s.resolve(e,"dist","cli.js");if(await se(n))return n;let r=process.argv[1]?.trim();if(r&&r.length>0){let s=$s.resolve(e,r);if(await se(s))return s}throw new p("Unable to resolve a CLI entrypoint for background test runs. Build the project or set PM_BACKGROUND_CLI_ENTRY.",f.GENERIC_FAILURE)}async function Ns(e,t){if(!iE.has(t.status)||_r(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 pt(e,r),r}async function Nu(e){await nq(e.pmRoot);let t=cE(e.commandArgs);if(t.length===0)throw new p("Background test run requires command arguments.",f.USAGE);let n=tq(e.kind,t,e.pmRoot),r=await Pu(e.pmRoot,{});for(let l of r){let u=await Ns(e.pmRoot,l);if(u.fingerprint===n&&!(!iE.has(u.status)||!_r(u.worker_pid)))return{started:!1,run:{...u,duplicate_of:u.id},duplicate_of:u.id}}let s=eq(),i=O(),o=Rm(e.pmRoot,s),a=Im(e.pmRoot,s),c=Lm(e.pmRoot,s);await pr.writeFile(o,"","utf8"),await pr.writeFile(a,"","utf8");let d={id:s,kind:e.kind,status:"queued",created_at:i,updated_at:i,requested_by:e.requestedBy,fingerprint:n,command_args:t,command_label:ZG(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:i}};return await pt(e.pmRoot,d),{started:!0,run:d}}async function Mu(e){let t=await hr(e.pmRoot,e.runId);if(!t)throw new p(`Background test run ${e.runId} not found`,f.NOT_FOUND);if($u.has(t.status))throw new p(`Background test run ${t.id} is already terminal (${t.status}).`,f.CONFLICT);let n=await lE(process.cwd()),r=[];e.noExtensions===!0&&r.push("--no-extensions"),r.push("--path",t.pm_root,"test-runs-worker",t.id);let s={...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"},i=sE(process.execPath,[n,...r],{cwd:process.cwd(),env:s,detached:!0,stdio:"ignore",windowsHide:!0});i.unref();let o={...t,status:"queued",worker_pid:i.pid,progress:{phase:"queued",message:"Worker process started.",heartbeat_at:O()}};return await pt(e.pmRoot,o),o}async function tE(e,t,n){await e,await pr.appendFile(t,n,"utf8")}function uE(e,t){let n=Number.parseInt(process.env[e]??"",10);return Number.isFinite(n)&&n>0?n:t}function uq(e){return{...process.env,PM_PATH:e.pm_root,PM_GLOBAL_PATH:e.global_pm_root,FORCE_COLOR:"0"}}function mq(e,t){return t?["--no-extensions",...e.command_args]:[...e.command_args]}function fq(e,t){let n=Promise.resolve();return{schedule(){n=n.then(async()=>{try{await pt(e,t)}catch{}})},async flush(){await n}}}function nE(e,t){try{e.kill(t)}catch{}}async function pq(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(),nE(t,"SIGTERM"),setTimeout(()=>nE(t,"SIGKILL"),uE("PM_BACKGROUND_RUN_FORCE_KILL_DELAY_MS",XG)).unref?.()}function _q(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 hq(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 rE(e,t,n){let r=dq(t);if(!r)return!1;let s=e.progress?.phase==="stopping"?"stopping":"running";return e.progress=r.item_id?_q(t,r,s):hq(t,e,r,s),r.phase==="finished"&&!n&&(e.progress.phase="running"),!0}function gq(e){if(e.trim().length===0)return null;try{return JSON.parse(e)}catch{return null}}function yq(e,t,n){return n?"stopped":e===0&&t.failed===0&&t.fail_on_skipped_triggered!==!0?"passed":"failed"}function wq(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 vq(e,t,n){if(t!==null){await Ge(e.result_path,`${JSON.stringify(t,null,2)}
29
29
  `);return}await Ge(e.result_path,`${JSON.stringify({parse_error:"Background run output was not valid JSON.",stdout_excerpt:Lu(n,oE)},null,2)}
30
30
  `)}async function mE(e,t,n=!1){let r=await hr(e,t);if(!r)throw new p(`Background test run ${t} not found`,f.NOT_FOUND);let s={...r,status:"running",started_at:r.started_at??O(),worker_pid:process.pid,progress:{phase:"running",message:"Worker started.",heartbeat_at:O()}},i=await lE(process.cwd()),o=uq(s);await pt(e,s);let a=mq(s,n),c=sE(process.execPath,[i,...a],{cwd:process.cwd(),env:o,detached:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0});s.child_pid=c.pid;let d=fq(e,s),l=d.schedule,u=Promise.resolve(),m=Promise.resolve(),_="",h="",g={stopRequested:!1},y=()=>{pq(s,c,g,l)};process.on("SIGTERM",y),process.on("SIGINT",y);let w=setInterval(()=>{(async()=>(s.resource=await Ou(s),s.progress.heartbeat_at=O(),l()))()},uE("PM_BACKGROUND_RUN_RESOURCE_INTERVAL_MS",JG));w.unref?.(),c.stdout?.on("data",S=>{let E=S.toString("utf8");_+=E,u=tE(u,s.stdout_path,E)}),c.stderr?.on("data",S=>{let E=S.toString("utf8");m=tE(m,s.stderr_path,E),h+=E;let $=h.split(/\r?\n/);h=$.pop();let P=!1;for(let I of $){let T=I.trimEnd();T.length>0&&rE(s,T,g.stopRequested)&&(P=!0)}P&&l()});let v=null,k=null;try{({code:v,signal:k}=await new Promise(S=>{c.on("close",(E,$)=>{S({code:E,signal:$})})}))}finally{clearInterval(w),process.off("SIGTERM",y),process.off("SIGINT",y)}await u,await m;let b=h.trimEnd();b.length>0&&rE(s,b,g.stopRequested)&&l(),h="";let x=gq(_),A=cq(s.kind,x);return s.summary=A.summary,s.exit_code=typeof v=="number"?v:void 0,s.signal=k??void 0,s.finished_at=O(),s.status=yq(s.exit_code,A.summary,g.stopRequested),s.progress=wq(s,g.stopRequested),s.resource=await Ou(s),await vq(s,x,_),await pt(e,s),await d.flush(),s}async function Pu(e,t){let n=await rq(e),r=[];for(let c of n){let d=await Q(c);if(!d)continue;let l=await dE(d,c);r.push(l)}let s=[];for(let c of r)s.push(await Ns(e,c));let o=(t.status?s.filter(c=>c.status===t.status):s).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 fE(e,t){let n=await hr(e,t);if(!n)throw new p(`Background test run ${t} not found`,f.NOT_FOUND);let r=await Ns(e,n),s=_r(r.worker_pid),i=_r(r.child_pid);r.status==="running"&&!i&&!r.finished_at&&!s&&(r.status="failed",r.finished_at=O(),r.error=r.error??"Background run process exited unexpectedly.",await pt(e,r)),r.status==="running"&&(r.resource=await Ou(r),await pt(e,r));let o=r.progress?.heartbeat_at,a=o?Date.parse(o):Number.NaN,c=Number.isFinite(a)?Math.max(0,aE()-a):void 0,d=Number.parseInt(process.env.PM_BACKGROUND_RUN_HEARTBEAT_STALE_MS??"",10),l=Number.isFinite(d)&&d>0?d:QG,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:s,child_alive:i}}}function kq(e,t){let n=t?"SIGKILL":"SIGTERM";if(!_r(e.worker_pid)||!e.worker_pid)return"none";try{return process.kill(e.worker_pid,n),n}catch{return"none"}}function bq(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 pE(e,t,n=!1){let r=await hr(e,t);if(!r)throw new p(`Background test run ${t} not found`,f.NOT_FOUND);let s=await Ns(e,r);if($u.has(s.status))return{run:s,signal_sent:"none"};let i=kq(s,n);return i==="none"&&(s.status="stopped",s.finished_at=s.finished_at??O()),s.stop_requested_at=O(),s.progress=bq(s,i),await pt(e,s),{run:s,signal_sent:i}}async function _E(e,t,n,r=!1){let s=await hr(e,t);if(!s)throw new p(`Background test run ${t} not found`,f.NOT_FOUND);let i=await Ns(e,s);if(!$u.has(i.status))throw new p(`Background test run ${t} is not terminal and cannot be resumed.`,f.CONFLICT);let o=await Nu({pmRoot:i.pm_root,globalPmRoot:i.global_pm_root,kind:i.kind,commandArgs:i.command_args,requestedBy:n,targetId:i.target_id,statusFilter:i.status_filter,resumedFrom:i.id,resumedBy:n,attempt:i.attempt+1});if(!o.started)return o.run;let a=await Mu({pmRoot:e,runId:o.run.id,noExtensions:r}),c={...i,resumed_by:a.id};return await pt(e,c),a}async function hE(e,t,n,r){let s=await hr(e,t);if(!s)throw new p(`Background test run ${t} not found`,f.NOT_FOUND);let i=typeof r=="number"&&Number.isFinite(r)&&r>=0?Math.floor(r):oE,o=n==="stdout"||n==="both"?await Q(s.stdout_path)??"":"",a=n==="stderr"||n==="both"?await Q(s.stderr_path)??"":"";return{run:s,stream:n,tail:i,stdout:n==="stdout"||n==="both"?Lu(o,i):[],stderr:n==="stderr"||n==="both"?Lu(a,i):[]}}var Sq=["queued","running","passed","failed","stopped","canceled"],Eq=["stdout","stderr","both"];function Aq(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(Sq.includes(t))return t;throw new p(`Invalid --status value "${e}"`,f.USAGE)}function Cq(e){if(e===void 0||e.trim().length===0)return"stderr";let t=e.trim().toLowerCase();if(Eq.includes(t))return t;throw new p(`Invalid --stream value "${e}"`,f.USAGE)}function Tq(){try{let e=xq.userInfo().username.trim();if(e.length>0)return e}catch{}}function gE(e,t){let n=[e,lf(),t,process.env.USER,process.env.LOGNAME,process.env.USERNAME,Tq()];for(let r of n){if(typeof r!="string")continue;let s=r.trim();if(s.length>0)return s}return"unknown"}async function An(e){await U(e)}async function YQ(e,t){let n=R(process.cwd(),t.path),r=Xe(process.cwd());await An(n);let s=await C(n),i=gE(e.author,s.author_default),o=await Nu({pmRoot:n,globalPmRoot:r,kind:e.kind,commandArgs:e.commandArgs,requestedBy:i,targetId:e.targetId,statusFilter:e.statusFilter});return o.started?{started:!0,run:await Mu({pmRoot:n,runId:o.run.id,noExtensions:e.noExtensions===!0})}:{started:!1,duplicate_of:o.duplicate_of,run:o.run}}async function JQ(e,t){let n=R(process.cwd(),t.path);await An(n);let r=Aq(e.status),s=Or(e.limit,"limit"),i=await Pu(n,{status:r,limit:s});return{runs:i,count:i.length,filters:{status:r,limit:s}}}async function XQ(e,t){let n=R(process.cwd(),t.path);await An(n);let r=await fE(n,e);return{run:r.run,health:r.health}}async function QQ(e,t,n){let r=R(process.cwd(),n.path);await An(r);let s=Cq(t.stream),i=Or(t.tail,"tail"),o=await hE(r,e,s,i);return{run:o.run,stream:o.stream,tail:o.tail,stdout:o.stdout,stderr:o.stderr}}async function ZQ(e,t,n){let r=R(process.cwd(),n.path);await An(r);let s=await pE(r,e,t.force===!0);return{run:s.run,signal_sent:s.signal_sent}}async function eZ(e,t,n){let r=R(process.cwd(),n.path);await An(r);let s=await C(r),i=gE(t.author,s.author_default),o=await _E(r,e,i,t.noExtensions===!0);return{resumed_from:e,run:o}}async function tZ(e,t){let n=R(process.cwd(),t.path);await An(n);let r=await mE(n,e,t.noExtensions===!0);return{id:r.id,status:r.status,exit_code:r.exit_code}}export{fA as a,Yh as b,Iq as c,Jq as d,hA as e,sn as f,Xq as g,gA as h,Xh as i,Qq as j,zr as k,Zq as l,wA as m,kA as n,eW as o,eg as p,qi as q,oW as r,aW as s,yg as t,cW as u,dW as v,lW as w,Bc as x,uW as y,mW as z,fW as A,pW as B,dC as C,Bn as D,lC as E,yW as F,wW as G,Vc as H,vW as I,kW as J,bW as K,fC as L,xW as M,SW as N,EW as O,AW as P,Yc as Q,Lg as R,TW as S,Og as T,Pg as U,xC as V,Hr as W,TC as X,Dg as Y,OC as Z,GW as _,Jc as $,Gg as aa,$C as ba,zW as ca,BW as da,qg as ea,HW as fa,VW as ga,M as ha,Ne as ia,mt as ja,Hn as ka,Xc as la,Kg as ma,kt as na,Vr as oa,GC as pa,ed as qa,td as ra,Vg as sa,Vn as ta,Xr as ua,rd as va,oT as wa,ey as xa,Qr as ya,ny as za,Yi as Aa,sd as Ba,ry as Ca,sy as Da,iy as Ea,jT as Fa,$K as Ga,TR as Ha,$y as Ia,WK as Ja,rs as Ka,KK as La,MR as Ma,PR as Na,zK as Oa,FR as Pa,fd as Qa,lI as Ra,vd as Sa,is as Ta,Xy as Ua,kd as Va,yI as Wa,wI as Xa,vI as Ya,Jn as Za,kI as _a,St as $a,bI as ab,xI as bb,wd as cb,bd as db,xd as eb,SI as fb,no as gb,ro as hb,ew as ib,rw as jb,Dz as kb,KI as lb,zI as mb,aw as nb,Ad as ob,Wz as pb,Vz as qb,uw as rb,fw as sb,mB as tb,fB as ub,os as vb,co as wb,gw as xb,yw as yb,ww as zb,vw as Ab,Sw as Bb,Ew as Cb,hO as Db,Cw as Eb,yO as Fb,vO as Gb,kO as Hb,bO as Ib,Lw as Jb,$w as Kb,Nw as Lb,uo as Mb,mo as Nb,hv as Ob,cV as Pb,gv as Qb,wv as Rb,vv as Sb,xv as Tb,Ev as Ub,Zd as Vb,us as Wb,ms as Xb,EL as Yb,rr as Zb,$v as _b,al as $b,Mv as ac,Pv as bc,ZL as cc,pY as dc,Ok as ec,_s as fc,Nk as gc,Mk as hc,Pk as ic,El as jc,aN as kc,XY as lc,qk as mc,vJ as nc,SJ as oc,bN as pc,$o as qc,Rl as rc,Bk as sc,UJ as tc,zN as uc,No as vc,Mo as wc,Fo as xc,db as yc,or as zc,gn as Ac,Go as Bc,hn as Cc,rb as Dc,ws as Ec,vs as Fc,qo as Gc,Wo as Hc,yn as Ic,wn as Jc,ar as Kc,Ko as Lc,zo as Mc,Bo as Nc,ks as Oc,ta as Pc,mM as Qc,Ll as Rc,E4 as Sc,bn as Tc,FP as Uc,da as Vc,Nb as Wc,Mb as Xc,R3 as Yc,ZP as Zc,gF as _c,wF as $c,Ss as ad,I3 as bd,n5 as cd,cD as dd,Ql as ed,r5 as fd,s5 as gd,_a as hd,w5 as id,v5 as jd,k5 as kd,vx as ld,F5 as md,$D as nd,iu as od,ND as pd,MD as qd,PD as rd,D5 as sd,j5 as td,Q5 as ud,Z5 as vd,e9 as wd,Px as xd,Fx as yd,JD as zd,Dx as Ad,b9 as Bd,jx as Cd,x9 as Dd,S9 as Ed,ga as Fd,fj as Gd,O9 as Hd,au as Id,L9 as Jd,cu as Kd,pj as Ld,Cs as Md,Wx as Nd,Kx as Od,t6 as Pd,Hx as Qd,_6 as Rd,h6 as Sd,cS as Td,pu as Ud,Eu as Vd,iQ as Wd,b1 as Xd,E1 as Yd,Cu as Zd,YS as _d,TQ as $d,YQ as ae,JQ as be,XQ as ce,QQ as de,ZQ as ee,eZ as fe,tZ as ge};
31
- //# sourceMappingURL=chunk-GQXK4KKH.js.map
31
+ //# sourceMappingURL=chunk-J25DZRYJ.js.map