@sreetej510/pi-shipd-checks 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,8 +49,8 @@ repeated requests sequentially after applying each result.
49
49
 
50
50
  `/checks --config` opens the row-based settings menu with two sections:
51
51
 
52
- - **Solver**: comparison model and thinking level for the final solver-result reviewer, plus the
53
- TDD solver model, thinking level, timeout, parallel solver count, and artifact-saving setting.
52
+ - **Solver**: reviewer model and thinking level for the final solver-result reviewer, plus the
53
+ solver model, thinking level, timeout, parallel solver count, and artifact-saving setting.
54
54
  - **Analyze Tool**: separate models + thinking levels for the agent-callable gap-analysis and Test
55
55
  Audit modes. The audit model defaults to the gap-analysis model until explicitly changed. These
56
56
  are stored under `analyzeGap.testAuditProvider`, `analyzeGap.testAuditModelId`, and
@@ -130,7 +130,7 @@ On-Demand fallback. Spot interruptions are retried according to `fargate.maxRetr
130
130
  no telemetry history is retained. Set `projectProfiles` to override resources per repository:
131
131
  `{"C:/path/to/repo":"large"}`.
132
132
 
133
- 5. Restart pi, use `/checks --config` to select the solver and comparison models, then run
133
+ 5. Restart pi, use `/checks --config` to select the solver and reviewer models, then run
134
134
  `/checks --solver-gap-finder`. Projects need `Dockerfile`, `agent_prompt.md`,
135
135
  `solution.patch`, `test.patch`, and `test.sh`.
136
136
 
package/dist/index.js CHANGED
@@ -74,7 +74,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
74
74
  `,s),([i,c])=>[[t,i],c])),([t,s])=>[t,s],()=>T(T(W(";",e),([t,s])=>[[t],s]),([t,s])=>[t,s],()=>T(T(W(`
75
75
  `,e),([t,s])=>[[t],s]),([t,s])=>[t,s],()=>[]))),([t,s])=>[t,s]),tPe=(e,t=[])=>T(T($te(e),([s,i])=>T(hwn(i),([c,l])=>[[s,c],l])),([s,i])=>tPe(i,[...t,s]),()=>[t,e]),vwn=e=>T(T(tPe(e),([t,s])=>T(T(T($te(s),([i,c])=>[[i],c]),([i,c])=>[i,c],()=>T([[],s],([i,c])=>[i,c],()=>[])),([i,c])=>[[t,i],c])),([t,s])=>[nxe(t),s]),$te=e=>T(T(_wn(e),([t,s])=>T(T(Rwn(s),([i,c])=>[i,c],()=>T(Swn(s),([i,c])=>[i,c],()=>T(Iwn(s),([i,c])=>[i,c],()=>T(ywn(s),([i,c])=>[i,c],()=>[])))),([i,c])=>T(bxe(c),([l,u])=>[[t,i,l],u]))),([t,s])=>[sxe(t),s]),Cwn=e=>T(T($te(e),([t,s])=>T(vwn(s),([i,c])=>[[t,i],c])),([t,s])=>[rxe(t),s]),nPe=e=>T(T(Cwn(e),([t,s])=>[t,s],()=>T(A$n(e),([t,s])=>[t,s],()=>T(xt(e),([t,s])=>[t,s],()=>[]))),([t,s])=>[t,s]);function sPe(e){let t=Ete(`\`${e}\``);return k.IsEqual(t.length,2)?t[0]:$s()}function Awn(e){return e.join("|")}function Dwn(e){return e.slice(1,e.length-1)}function Ewn(e,t,s){return jm(t,`${s}${e}`)}function bwn(e,t){return jm(e,`${t}${_De}`)}function xwn(e,t){return jm(e,`${t}${GL}`)}function Pwn(e,t){return jm(e,`${t}${NL}`)}function $wn(e,t){return rT(At([Lt("false"),Lt("true")]),e,t)}function wwn(e,t){return jm(e,`${t}${VL}`)}function kwn(e,t,s){return jm(t,`${s}${Dwn(e)}`)}function Lwn(e,t,s){let i=oT(e,{});return rT(i,t,s)}function Mwn(e,t,s){let i=wi(e);return rT(i,t,s)}function rPe(e,t,s,i=[]){return k.ShiftLeft(e,(c,l)=>rPe(l,t,s,[...i,rT(c,[],"")]),()=>jm(t,`${s}(${Awn(i)})`))}function rT(e,t,s){return Jo(e)?Mwn(e.enum,t,s):ea(e)?xwn(t,s):Wt(e)?Ewn(e.const,t,s):Cu(e)?bwn(t,s):mc(e)?$wn(t,s):Fs(e)?Pwn(t,s):ta(e)?wwn(t,s):Bs(e)?kwn(e.pattern,t,s):aPe(e)?Lwn(e.parameters[0],t,s):Be(e)?rPe(e.anyOf,t,s):tDe}function jm(e,t){return k.ShiftLeft(e,(s,i)=>rT(s,i,t),()=>t)}function Gwn(e){return`^${jm(e,"")}$`}function oPe(e){let t=Gwn(e);return FL(t)}function oT(e,t){return St(e)?q.Update(oPe(e),{},t):ZL(e,t)}function iPe(e,t,s,i){let c=ki(e,t,s);return oT(c,i)}function ZL(e,t={}){return Ue("TemplateLiteral",[e],t)}function aPe(e){return Js(e)&&k.HasPropertyKey(e,"action")&&k.IsEqual(e.action,"TemplateLiteral")}function cPe(e){return oT(e,{})}function Own(e){let t=sPe(e);return cPe(t)}function lPe(e,t={}){let s=k.IsString(e)?Own(e):cPe(e);return q.Update(s,{},t)}function Bs(e){return Ge(e,"TemplateLiteral")}var rt={};Un(rt,{ExtendsFalse:()=>ft,ExtendsTrue:()=>Pe,ExtendsUnion:()=>wte,IsExtendsFalse:()=>Nwn,IsExtendsTrue:()=>pPe,IsExtendsTrueLike:()=>Ry,IsExtendsUnion:()=>uPe,Match:()=>Jn});function wte(e){return q.Create({"~kind":"ExtendsUnion"},{inferred:e})}function uPe(e){return k.IsObject(e)&&k.HasPropertyKey(e,"~kind")&&k.HasPropertyKey(e,"inferred")&&k.IsEqual(e["~kind"],"ExtendsUnion")&&k.IsObject(e.inferred)}function Pe(e){return q.Create({"~kind":"ExtendsTrue"},{inferred:e})}function pPe(e){return k.IsObject(e)&&k.HasPropertyKey(e,"~kind")&&k.HasPropertyKey(e,"inferred")&&k.IsEqual(e["~kind"],"ExtendsTrue")&&k.IsObject(e.inferred)}function ft(){return q.Create({"~kind":"ExtendsFalse"},{})}function Nwn(e){return k.IsObject(e)&&k.HasPropertyKey(e,"~kind")&&k.IsEqual(e["~kind"],"ExtendsFalse")}function Ry(e){return uPe(e)||pPe(e)}function Jn(e,t,s){return Ry(e)?t(e.inferred):s()}function Vwn(e,t,s,i){return Jn(Ot(e,s,i),c=>Pe(q.Assign(q.Assign(e,c),{[t]:s})),()=>ft())}function qwn(e,t){return Pe(e)}function Fwn(e,t,s,i,c){return Jn(Ot(e,t,s),l=>Jn(Ot(l,t,i),u=>Pe(u),()=>ft()),()=>Jn(Ot(e,t,c),l=>Pe(l),()=>ft()))}function Bwn(e,t,s){let i=wi(s);return Ot(e,t,i)}function dPe(e,t,s){return k.ShiftLeft(s,(i,c)=>Jn(Ot(e,t,i),l=>dPe(l,t,c),()=>ft()),()=>Pe(e))}function Uwn(e,t,s){let i=Pa(s);return Ot(e,t,i)}function mPe(e,t,s){return k.ShiftLeft(s,(i,c)=>Jn(Ot(e,t,i),l=>Pe(l),()=>mPe(e,t,c)),()=>ft())}function Qt(e,t,s){return qs(s)?qwn(e,t):vs(s)?Fwn(e,t,s.if,s.then,s.else):Jo(s)?Bwn(e,t,s.enum):Ps(s)?Vwn(e,s.name,t,s.extends):kt(s)?dPe(e,t,s.allOf):Bs(s)?Uwn(e,t,s.pattern):Be(s)?mPe(e,t,s.anyOf):er(s)?Pe(e):ft()}function fPe(e,t,s){return Ps(s)?Qt(e,t,s):qs(s)?Pe(e):er(s)?Pe(e):wte(e)}function Hwn(e,t){let s=Yg(e),i=Yg(t);return s&&i||!s&&i?!0:!(s&&!i)}function gPe(e,t,s,i){return as(i)?Hwn(t,i)?Ot(e,s,i.items):ft():Qt(e,t,i)}function RPe(e,t,s){return Cu(s)?Pe(e):Qt(e,t,s)}function SPe(e,t,s){return mc(s)?Pe(e):Qt(e,t,s)}function jwn(e,t,s,i,c){let l=Ps(i)?t:i,u=Ps(i)?i:t,p=ho(t),d=ho(i);return!p&&d?ft():Jn(Ot(e,l,u),m=>aT(m,s,c),()=>ft())}function zwn(e,t,s,i){return k.ShiftLeft(i,(c,l)=>jwn(e,t,s,c,l),()=>ho(t)?Pe(e):ft())}function Kwn(e,t,s){return k.ShiftLeft(t,(i,c)=>zwn(e,i,c,s),()=>Pe(e))}function aT(e,t,s){return Kwn(e,t,s)}function CM(e,t,s){return Tu(s)?Pe(e):Ot(e,t,s)}function IPe(e,t,s,i){return qs(i)?Pe(e):er(i)?Pe(e):pr(i)?Jn(aT(e,t,i.parameters),c=>CM(c,s,i.instanceType),()=>ft()):ft()}function yPe(e,t,s,i,c){return Jn(Ot(e,t,c),()=>Ot(e,s,c),()=>Ot(e,i,c))}function _Pe(e,t,s){let i=wi(t);return Ot(e,i,s)}function hPe(e,t,s,i){return qs(i)?Pe(e):er(i)?Pe(e):dr(i)?Jn(aT(e,t,i.parameters),c=>CM(c,s,i.returnType),()=>ft()):ft()}function vPe(e,t,s){return ea(s)?Pe(e):Fs(s)?Pe(e):Qt(e,t,s)}function CPe(e,t,s){let i=fs(t);return Ot(e,i,s)}function TM(e,t,s){return t===s?Pe(e):ft()}function Wwn(e,t,s){return Wt(s)?TM(e,t,s.const):Cu(s)?Pe(e):Qt(e,Lt(t),s)}function Qwn(e,t,s){return Wt(s)?TM(e,t,s.const):mc(s)?Pe(e):Qt(e,Lt(t),s)}function Zwn(e,t,s){return Wt(s)?TM(e,t,s.const):Fs(s)?Pe(e):Qt(e,Lt(t),s)}function Ywn(e,t,s){return Wt(s)?TM(e,t,s.const):ta(s)?Pe(e):Qt(e,Lt(t),s)}function TPe(e,t,s){return k.IsBigInt(t.const)?Wwn(e,t.const,s):k.IsBoolean(t.const)?Qwn(e,t.const,s):k.IsNumber(t.const)?Zwn(e,t.const,s):k.IsString(t.const)?Ywn(e,t.const,s):$s()}function APe(e,t,s){return Ps(s)?Qt(e,t,s):Pe(e)}function DPe(e,t,s){return ay(s)?Pe(e):Qt(e,t,s)}function EPe(e,t,s){return Fs(s)?Pe(e):Qt(e,t,s)}function Xwn(e,t,s){return ho(t)?ho(s)?Pe(e):ft():Pe(e)}function Jwn(e,t,s){return Ps(s)&&Nm(s.extends)?ft():Jn(Ot(e,t,s),i=>Xwn(i,t,s),()=>ft())}function ekn(e,t){return e.reduce((s,i)=>i in t?Ry(t[i])?{...s,...t[i].inferred}:$s():$s(),{})}function tkn(e,t,s){let i={};for(let u of k.Keys(s))i[u]=u in t?Jwn({},t[u],s[u]):ho(s[u])?Ps(s[u])?Pe(q.Assign(e,{[s[u].name]:s[u].extends})):Pe(e):ft();let c=k.Values(i).every(u=>Ry(u)),l=c?ekn(k.Keys(i),i):{};return c?Pe(l):ft()}function nkn(e,t,s){let i=tkn(e,t,s);return Ry(i)?Pe(q.Assign(e,i.inferred)):ft()}function skn(e,t,s){return nkn(e,t,s)}function rkn(e,t){return k.Keys(t).reduce((s,i)=>({...s,[i]:k.HasPropertyKey(e,i)?Be(s[i])?At([...s[i].anyOf,t[i]]):At([e[i],t[i]]):t[i]}),e)}function bPe(e,t,s,i){return k.ShiftLeft(t,(c,l)=>Jn(Ot({},e[c],s),u=>bPe(e,l,s,rkn(i,u)),()=>ft()),()=>Pe(i))}function okn(e,t,s,i){let c=k.Keys(t);return bPe(t,c,i,e)}function xPe(e,t,s){return qr(s)?okn(e,t,Rc(s),na(s)):Ht(s)?skn(e,t,s.properties):Qt(e,it(t),s)}function akn(e,t){return k.IsEqual(k.Keys(t).length,0)?Pe(e):ft()}function ikn(e,t,s,i,c){return Ot(e,s,c)}function PPe(e,t,s,i){return qr(i)?ikn(e,zL(t),s,zL(Rc(i)),na(i)):Ht(i)?akn(e,i.properties):qs(i)?Pe(e):er(i)?Pe(e):ft()}function $Pe(e,t,s){return ta(s)?Pe(e):Qt(e,t,s)}function wPe(e,t,s){return Vm(s)?Pe(e):Qt(e,t,s)}function kPe(e,t,s){let i=Pa(t);return Ot(e,i,s)}function kte(e,t){return q.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function iT(e){return k.IsObject(e)&&k.HasPropertyKey(e,"~kind")&&k.HasPropertyKey(e,"name")&&k.HasPropertyKey(e,"type")&&k.IsEqual(e["~kind"],"Inferrable")&&k.IsString(e.name)&&k.IsObject(e.type)}function Lte(e){return Bm(e)?Ps(e.items)?as(e.items.extends)?kte(e.items.name,e.items.extends.items):er(e.items.extends)?kte(e.items.name,e.items.extends):void 0:$s():void 0}function AM(e){return Ps(e)?kte(e.name,e.extends):void 0}function Mte(e,t,s=[]){return k.ShiftLeft(e,(i,c)=>Jn(Ot({},i,t),()=>Mte(c,t,[...s,i]),()=>{}),()=>s)}function LPe(e,t,s,i){let c=Mte(s,i);return k.IsArray(c)?Pe(q.Assign(e,{[t]:Us(c)})):ft()}function DM(e,t,s,i){let c=Mte(s,i);return k.IsArray(c)?Pe(q.Assign(e,{[t]:At(c)})):ft()}function ckn(e){return[...e].reverse()}function Gte(e,t){return t?ckn(e):e}function lkn(e){let t=e.length>0?e[0]:void 0,s=Js(t)?Lte(t):void 0;return Js(s)}function ukn(e,t,s,i,c,l){return Jn(Ot(e,s,c),u=>MPe(u,t,i,l),()=>ft())}function pkn(e,t,s,i,c){let l=Lte(i);return iT(l)?LPe(e,l.name,Gte(s,t),l.type):k.ShiftLeft(s,(u,p)=>ukn(e,t,u,p,i,c),()=>ft())}function dkn(e,t,s,i){return k.ShiftLeft(i,(c,l)=>pkn(e,t,s,c,l),()=>k.IsEqual(s.length,0)?Pe(e):ft())}function MPe(e,t,s,i){return dkn(e,t,s,i)}function mkn(e,t,s){let i=zm(e,Hn([],[]),s),c=lkn(i);return MPe(e,c,Gte(t,c),Gte(i,c))}function GPe(e,t,s){let i=AM(s);return iT(i)?DM(e,i.name,t,i.type):k.ShiftLeft(t,(c,l)=>Jn(Ot(e,c,s),u=>GPe(u,l,s),()=>ft()),()=>Pe(e))}function OPe(e,t,s){let i=zm(e,Hn([],[]),t);return Pn(s)?mkn(e,i,s.items):as(s)?GPe(e,i,s.items):Qt(e,Us(i),s)}function NPe(e,t,s){return Tu(s)?Pe(e):dy(s)?Pe(e):Qt(e,t,s)}function VPe(e,t,s){return k.ShiftLeft(s,(i,c)=>Jn(Ot(e,t,i),l=>Pe(l),()=>VPe(e,t,c)),()=>ft())}function Ote(e,t,s){return k.ShiftLeft(t,(i,c)=>Jn(VPe(e,i,s),l=>Ote(l,c,s),()=>ft()),()=>Pe(e))}function qPe(e,t,s){let i=AM(s);return iT(i)?DM(e,i.name,t,i.type):Be(s)?Ote(e,t,s.anyOf):Ote(e,t,[s])}function FPe(e,t,s){return Ps(s)?Qt(e,t,s):qs(s)?Pe(e):er(s)?Pe(e):ft()}function BPe(e,t,s){return Tu(s)?Pe(e):Qt(e,t,s)}function Ot(e,t,s){return qs(t)?fPe(e,t,s):as(t)?gPe(e,t,t.items,s):Cu(t)?RPe(e,t,s):mc(t)?SPe(e,t,s):pr(t)?IPe(e,t.parameters,t.instanceType,s):vs(t)?yPe(e,t.if,t.then,t.else,s):Jo(t)?_Pe(e,t.enum,s):dr(t)?hPe(e,t.parameters,t.returnType,s):ea(t)?vPe(e,t,s):kt(t)?CPe(e,t.allOf,s):Wt(t)?TPe(e,t,s):Nm(t)?APe(e,t,s):ay(t)?DPe(e,t,s):Fs(t)?EPe(e,t,s):Ht(t)?xPe(e,t.properties,s):qr(t)?PPe(e,Rc(t),na(t),s):ta(t)?$Pe(e,t,s):Vm(t)?wPe(e,t,s):Bs(t)?kPe(e,t.pattern,s):Pn(t)?OPe(e,t.items,s):dy(t)?NPe(e,t,s):Be(t)?qPe(e,t.anyOf,s):er(t)?FPe(e,t,s):Tu(t)?BPe(e,t,s):ft()}function fkn(e,t){return fs([...e,it(t)])}function Nte(e,t,s){return St(e)?q.Update(fkn(e,t),{},s):JC(e,t,s)}function UPe(e,t,s,i,c){let l=ki(e,t,s),u=cT(e,t,i);return Nte(l,u,c)}function JC(e,t,s={}){return Ue("Interface",[e,t],s)}function Sy(e){return Js(e)&&k.HasPropertyKey(e,"action")&&k.IsEqual(e.action,"Interface")}function HPe(e,t,s={}){return Nte(e,t,s)}function gkn(e,t,s){return e.includes(s)?!0:lT([...e,s],t,t[s])}function jPe(e,t,s){let i=$L(s);return rR(e,t,i)}function rR(e,t,s){return k.ShiftLeft(s,(i,c)=>lT(e,t,i)?!0:rR(e,t,c),()=>!1)}function lT(e,t,s){return mr(s)?gkn(e,t,s.$ref):as(s)?lT(e,t,s.items):pr(s)?rR(e,t,[...s.parameters,s.instanceType]):dr(s)?rR(e,t,[...s.parameters,s.returnType]):Sy(s)?jPe(e,t,s.parameters[1]):kt(s)?rR(e,t,s.allOf):Ht(s)?jPe(e,t,s.properties):Be(s)?rR(e,t,s.anyOf):Pn(s)?rR(e,t,s.items):qr(s)?lT(e,t,na(s)):!1}function zPe(e,t,s){return lT(e,t,s)}function Rkn(e,t){return t.reduce((s,i)=>zPe([i],e,e[i])?[...s,i]:s,[])}function KPe(e){let t=PL(e);return Rkn(e,t)}function Skn(e,t,s){return s.includes(t)?s:t in e?uT(e,e[t],[...s,t]):$s()}function WPe(e,t,s){let i=$L(t);return Iy(e,i,s)}function Iy(e,t,s){return t.reduce((i,c)=>uT(e,c,i),s)}function uT(e,t,s){return mr(t)?Skn(e,t.$ref,s):as(t)?uT(e,t.items,s):pr(t)?Iy(e,[...t.parameters,t.instanceType],s):dr(t)?Iy(e,[...t.parameters,t.returnType],s):Sy(t)?WPe(e,t.parameters[1],s):kt(t)?Iy(e,t.allOf,s):Ht(t)?WPe(e,t.properties,s):Be(t)?Iy(e,t.anyOf,s):Pn(t)?Iy(e,t.items,s):qr(t)?uT(e,na(t),s):s}function QPe(e,t,s){return uT(e,s,[t])}function Ikn(e){return sy()}function ykn(e){return k.Keys(e).reduce((t,s)=>({...t,[s]:oR(e[s])}),{})}function pT(e){return e.reduce((t,s)=>[...t,oR(s)],[])}function oR(e){return mr(e)?Ikn(e.$ref):as(e)?$i(oR(e.items),xL(e)):pr(e)?Su(pT(e.parameters),oR(e.instanceType)):dr(e)?Iu(pT(e.parameters),oR(e.returnType)):kt(e)?vo(pT(e.allOf)):Ht(e)?it(ykn(e.properties)):qr(e)?jL(uy(e),oR(na(e))):Be(e)?At(pT(e.anyOf)):Pn(e)?Us(pT(e.items)):e}function _kn(e,t){return t in e?oR(e[t]):vr()}function ZPe(e){return _kn(e.$defs,e.$ref)}function hkn(e,t,s){let i=ki(e,Hn([],[]),t),c=cT({},Hn([],[]),s);return fs([...i,it(c)])}function vkn(e,t){return k.Keys(e).filter(i=>t.includes(i)).reduce((i,c)=>{let l=e[c],u=Sy(l)?hkn(e,l.parameters[0],l.parameters[1]):l;return{...i,[c]:u}},{})}function YPe(e,t,s){let i=QPe(e,t,s),c=vkn(e,i);return _u(c,t)}function XPe(e,t){return t in e?mr(e[t])?XPe(e,e[t].$ref):e[t]:Rn()}function Au(e,t){return XPe(e,t)}function JPe(e){return Nr(e)?ZPe(e):wL(e)?vr():e}function Vr(e,t,s){let i=JPe(t),c=JPe(s);return Ot(e,i,c)}var KC="equal",Ckn="disjoint",WC="left-inside",QC="right-inside";function cy(e,t){let s=[er(e)?rt.ExtendsFalse():Vr({},e,t),er(e)?rt.ExtendsTrue({}):Vr({},t,e)];return rt.IsExtendsTrueLike(s[0])&&rt.IsExtendsTrueLike(s[1])?KC:rt.IsExtendsTrueLike(s[0])&&rt.IsExtendsFalse(s[1])?WC:rt.IsExtendsFalse(s[0])&&rt.IsExtendsTrueLike(s[1])?QC:Ckn}function Tkn(e,t){return t.filter(s=>cy(e,s)!==QC)}function Akn(e,t){let s=t.some(i=>{let c=cy(e,i);return k.IsEqual(c,WC)||k.IsEqual(c,KC)});return k.IsEqual(s,!1)}function Dkn(e,t){let s=gc(e);return qs(s)?[s]:Akn(s,t)?[...Tkn(s,t),s]:t}function Ekn(e){return e.reduce((t,s)=>Ht(s)?[...t,s]:Nm(s)?t:Dkn(s,t),[])}function Rte(e){let t=Ekn(e);return YC(t)}function Vte(e,t){return q.Update(gc(e),{},t)}function e$e(e,t,s,i){let c=he(e,t,s);return Vte(c,i)}function dT(e,t=[]){return Gm(e)&&k.IsEqual(e.action,"Conditional")?mr(e.parameters[0])?dT(e.parameters[2],dT(e.parameters[3],[...t,e.parameters[0].$ref])):dT(e.parameters[2],dT(e.parameters[3],t)):Gm(e)&&k.IsEqual(e.action,"Mapped")&&Gm(e.parameters[1])&&k.IsEqual(e.parameters[1].action,"KeyOf")&&mr(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function bkn(e,t){return e.reduce((s,i)=>[...s,t.includes(i.name)],[])}function s$e(e,t,s=[]){return k.ShiftLeft(e,(i,c)=>k.ShiftLeft(t,(l,u)=>s$e(c,u,[...s,[l,i]]),()=>s),()=>s)}function xkn(e){return Be(e)?[...e.anyOf]:[e]}function Pkn(e,t){return e.reduce((s,i)=>[...s,[...i,t]],[])}function t$e(e,t){return t.reduce((s,i)=>[...s,...Pkn(e,i)],[])}function n$e(e){return e.reduce((t,s)=>k.IsEqual(s[0],!0)?t$e(t,xkn(s[1])):t$e(t,[s[1]]),[[]])}function r$e(e,t,s){let i=dT(s),c=bkn(e,i),l=s$e(t,c);return Gm(s)&&k.IsEqual(s.action,"Conditional")||Gm(s)&&k.IsEqual(s.action,"Mapped")?n$e(l):[t]}function $kn(){return["(not-resolvable)",Rn()]}function wkn(){return["(not-generic)",Rn()]}function kkn(e,t,s){return[e,Om(t,s)]}function Lkn(e,t,s){return t in e?o$e(e,t,e[t],s):$kn()}function o$e(e,t,s,i){return ny(s)?kkn(t,s.parameters,s.expression):mr(s)?Lkn(e,s.$ref,i):wkn()}function a$e(e,t,s){return o$e(e,"(anonymous)",t,s)}function Mkn(e,t,s){if(Ps(t)||yy(t)||rt.IsExtendsTrueLike(Vr({},t,s)))return;let i={parameter:e,expect:s,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:i})}function i$e(e,t,s,i,c){let l=he(e,t,c);return Mkn(s,l,i),q.Assign(e,{[s]:l})}function Gkn(e,t,s,i,c){let l=he(e,t,s.extends),u=he(e,t,s.equals);return k.ShiftLeft(c,(p,d)=>qte(i$e(e,t,s.name,l,p),t,i,d),()=>qte(i$e(e,t,s.name,l,u),t,i,[]))}function qte(e,t,s,i){return k.ShiftLeft(s,(c,l)=>Gkn(e,t,c,l,i),()=>e)}function c$e(e,t,s,i){return qte(e,t,s,i)}function Okn(e){return k.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function Nkn(e,t){return k.IsEqual(Okn(e),t)}function Vkn(e,t,s,i,c,l){let u=c$e(e,t,i,l),p=he(u,Hn([...t.callstack,s.$ref],t.visited),c);return he(u,Hn([],[]),p)}function qkn(e,t,s,i,c,l){return l.reduce((u,p)=>[...u,Vkn(e,t,s,i,c,p)],[])}function Fkn(e,t,s,i,c,l){let u=r$e(i,l,c),p=qkn(e,t,s,i,c,u);return k.IsEqual(p.length,1)?p[0]:Ja(p)}function EM(e,t,s,i){let c=ki(e,t,i),l=a$e(e,s,i),u=l[0],p=l[1];return ny(p)?Nkn(t,u)?eT(fd(u),c):Fkn(e,t,fd(u),p.parameters,p.expression,c):eT(s,c)}function eT(e,t){return q.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function l$e(e,t){return EM({},Hn([],[]),e,t)}function yy(e){return Ge(e,"Call")}function Bkn(e){return q.Discard(e,["~immutable"])}function u$e(e,t){return q.Update(Bkn(e),{},t)}function p$e(e,t,s,i){let c=he(e,t,s);return u$e(c,i)}function d$e(e,t){return e(t)}function m$e(e,t){return k.IsString(t)?Lt(d$e(e,t)):Lt(t)}function f$e(e,t){let s=Pa(t);return Sd(e,s)}function g$e(e,t){let s=t.map(i=>Sd(e,i));return At(s)}function Sd(e,t){return Wt(t)?m$e(e,t.const):Bs(t)?f$e(e,t.pattern):Be(t)?g$e(e,t.anyOf):t}function YL(e,t={}){return Ue("Capitalize",[e],t)}function R$e(e,t={}){return Fte(e,t)}function XL(e,t={}){return Ue("Lowercase",[e],t)}function S$e(e,t={}){return Bte(e,t)}function JL(e,t={}){return Ue("Uncapitalize",[e],t)}function I$e(e,t={}){return Ute(e,t)}function eM(e,t={}){return Ue("Uppercase",[e],t)}function y$e(e,t={}){return Hte(e,t)}var Ukn=e=>e[0].toUpperCase()+e.slice(1),Hkn=e=>e.toLowerCase(),jkn=e=>e[0].toLowerCase()+e.slice(1),zkn=e=>e.toUpperCase();function Fte(e,t){return St([e])?q.Update(Sd(Ukn,e),{},t):YL(e,t)}function Bte(e,t){return St([e])?q.Update(Sd(Hkn,e),{},t):XL(e,t)}function Ute(e,t){return St([e])?q.Update(Sd(jkn,e),{},t):JL(e,t)}function Hte(e,t){return St([e])?q.Update(Sd(zkn,e),{},t):eM(e,t)}function _$e(e,t,s,i){let c=he(e,t,s);return Fte(c,i)}function h$e(e,t,s,i){let c=he(e,t,s);return Bte(c,i)}function v$e(e,t,s,i){let c=he(e,t,s);return Ute(c,i)}function C$e(e,t,s,i){let c=he(e,t,s);return Hte(c,i)}function tM(e,t,s,i,c={}){return Ue("Conditional",[e,t,s,i],c)}function T$e(e,t,s,i,c={}){return jte({},Hn([],[]),e,t,s,i,c)}function Kkn(e,t,s,i,c,l){let u=Vr(e,s,i);return rt.IsExtendsUnion(u)?At([he(u.inferred,t,c),he(e,t,l)]):rt.IsExtendsTrue(u)?he(u.inferred,t,c):he(e,t,l)}function jte(e,t,s,i,c,l,u){return St([s,i])?q.Update(Kkn(e,t,s,i,c,l),{},u):tM(s,i,c,l,u)}function A$e(e,t,s,i,c,l,u){let p=he(e,t,s),d=he(e,t,i);return jte(e,t,p,d,c,l,u)}function nM(e,t={}){return Ue("ConstructorParameters",[e],t)}function D$e(e,t={}){return zte(e,t)}function Wkn(e){let t=pr(e)?e.parameters:[],s=zm({},Hn([],[]),t);return Us(s)}function zte(e,t){return St([e])?q.Update(Wkn(e),{},t):nM(e,t)}function E$e(e,t,s,i){let c=he(e,t,s);return zte(c,i)}function sM(e,t,s={}){return Ue("Exclude",[e,t],s)}function b$e(e,t,s={}){return mT(e,t,s)}function mT(e,t,s){return St([e,t])?q.Update(UL(e,t),{},s):sM(e,t,s)}function x$e(e,t,s,i,c){let l=he(e,t,s),u=he(e,t,i);return mT(l,u,c)}function rM(e,t,s={}){return Ue("Extract",[e,t],s)}function P$e(e,t,s={}){return Kte(e,t,s)}function Qkn(e,t){let s=Vr({},e,t);return rt.IsExtendsTrueLike(s)?[e]:[]}function Zkn(e,t){return e.reduce((s,i)=>[...s,...Qkn(i,t)],[])}function $$e(e,t){let s=gc(e),i=Be(s)?s.anyOf:[s],c=Zkn(i,t);return Ja(c)}function Kte(e,t,s){return St([e,t])?q.Update($$e(e,t),{},s):rM(e,t,s)}function w$e(e,t,s,i,c){let l=he(e,t,s),u=he(e,t,i);return Kte(l,u,c)}function Ykn(e){return e.reduce((t,s)=>OL(s)?[...t,Lt(s)]:t,[])}function _y(e){let t=Ykn(e);return At(t)}function tT(e,t,s={}){return Ue("Index",[e,t],s)}function k$e(e,t,s={}){let i=k.IsArray(t)?_y(t):t;return Wte(e,i,s)}function L$e(e,t){let s=Au(e,t);return Li(s)}function M$e(e,t,s){let i=cl(e,t,s);return Li(i)}function Xkn(e,t){let s=k.Keys(e).filter(S=>!k.HasPropertyKey(t,S)),i=k.Keys(t).filter(S=>!k.HasPropertyKey(e,S)),c=k.Keys(e).filter(S=>k.HasPropertyKey(t,S)),l=s.reduce((S,v)=>({...S,[v]:e[v]}),{}),u=i.reduce((S,v)=>({...S,[v]:t[v]}),{}),p=c.reduce((S,v)=>({...S,[v]:fs([e[v],t[v]])}),{}),d=q.Assign(l,u);return q.Assign(d,p)}function G$e(e){return e.reduce((t,s)=>Xkn(t,Li(s)),{})}function O$e(e){let t=BDe(Us(e));return Li(t)}function Jkn(e,t){return k.Keys(e).filter(c=>c in t).reduce((c,l)=>({...c,[l]:Ja([e[l],t[l]])}),{})}function N$e(e,t){return k.ShiftLeft(e,(s,i)=>N$e(i,Jkn(t,Li(s))),()=>t)}function V$e(e){return k.ShiftLeft(e,(t,s)=>N$e(s,Li(t)),()=>$s())}function Li(e){return Nr(e)?L$e(e.$defs,e.$ref):vs(e)?M$e(e.if,e.then,e.else):kt(e)?G$e(e.allOf):Be(e)?V$e(e.anyOf):Pn(e)?O$e(e.items):Ht(e)?e.properties:{}}function hy(e){let t=Li(e);return it(t)}var eLn=new RegExp("^(?:0|[1-9][0-9]*)$");function vy(e){let t=`${e}`;return eLn.test(t)?parseInt(t):e}function tLn(e){return Lt(vy(e))}function q$e(e){return e.map(t=>F$e(t))}function F$e(e){return kt(e)?vo(q$e(e.allOf)):Be(e)?At(q$e(e.anyOf)):Wt(e)?tLn(e.const):e}function B$e(e,t){let s=F$e(t),i=Vr({},s,Xa());return rt.IsExtendsTrueLike(i)?e:Wt(t)&&k.IsEqual(t.const,"length")?Xa():Rn()}function U$e(e,t){let s=Au(e,t);return ei(s)}function H$e(e,t,s){let i=cl(e,t,s);return ei(i)}function j$e(e){let t=wi(e);return ei(t)}function z$e(e){let t=fs(e);return ei(t)}function K$e(e){return[`${e}`]}function W$e(e){let t=Pa(e);return ei(t)}function Q$e(e){return e.reduce((t,s)=>[...t,...ei(s)],[])}function ei(e){return Nr(e)?U$e(e.$defs,e.$ref):vs(e)?H$e(e.if,e.then,e.else):Jo(e)?j$e(e.enum):kt(e)?z$e(e.allOf):Wt(e)?K$e(e.const):Bs(e)?W$e(e.pattern):Be(e)?Q$e(e.anyOf):[]}function Cy(e){return ei(e)}function fT(e,t){return t.map(s=>gT(e,s))}function gT(e,t){return as(t)?$i(gT(e,t.items)):pr(t)?Su(fT(e,t.parameters),gT(e,t.instanceType)):dr(t)?Iu(fT(e,t.parameters),gT(e,t.returnType)):Pn(t)?Us(fT(e,t.items)):Be(t)?At(fT(e,t.anyOf)):kt(t)?vo(fT(e,t.allOf)):WL(t)?it(e):t}function Z$e(e,t){return gT(e,t)}function nLn(e,t){let s=t in e?e[t]:Rn();return Z$e(e,s)}function Y$e(e,t){return t.reduce((s,i)=>[...s,nLn(e,i)],[])}function sLn(e,t){let s=Cy(t),i=Y$e(e,s);return Ja(i)}var rLn=new RegExp(Fm);function oLn(e){return e.filter(s=>rLn.test(s))}function aLn(e){let t=PL(e),s=oLn(t),i=Y$e(e,s);return Ja(i)}function X$e(e,t){return Fs(t)?aLn(e):sLn(e,t)}function iLn(e){return Lt(vy(e))}function J$e(e){return e.map(t=>Qte(t))}function Qte(e){return kt(e)?vo(J$e(e.allOf)):Be(e)?At(J$e(e.anyOf)):Wt(e)?iLn(e.const):e}function cLn(e,t){return e.reduceRight((s,i,c)=>{let l=Vr({},Lt(c),t);return rt.IsExtendsTrueLike(l)?[i,...s]:s},[])}function lLn(e,t){let s=Qte(t),i=cLn(e,s);return gd(i)}function uLn(e){return gd(e)}function ewe(e,t){return Wt(t)&&k.IsEqual(t.const,"length")?Lt(e.length):Fs(t)||ea(t)?uLn(e):lLn(e,t)}function twe(e,t){return as(e)?B$e(e.items,t):Ht(e)?X$e(e.properties,t):Pn(e)?ewe(e.items,t):Rn()}function pLn(e){return Nr(e)||vs(e)||kt(e)||Be(e)?hy(e):e}function Wte(e,t,s){return St([e,t])?q.Update(twe(pLn(e),t),{},s):tT(e,t,s)}function nwe(e,t,s,i,c){let l=he(e,t,s),u=he(e,t,i);return Wte(l,u,c)}function oM(e,t={}){return Ue("InstanceType",[e],t)}function swe(e,t={}){return Zte(e,t)}function dLn(e){return pr(e)?e.instanceType:Rn()}function Zte(e,t){return St([e])?q.Update(dLn(e),{},t):oM(e,t)}function rwe(e,t,s,i={}){let c=he(e,t,s);return Zte(c,i)}function nT(e,t={}){return Ue("KeyOf",[e],t)}function owe(e,t={}){return Yte(e,t)}function awe(){return At([Xa(),fc(),iy()])}function iwe(e){return Xa()}function mLn(e){return e.reduce((s,i)=>OL(i)?[...s,Lt(vy(i))]:$s(),[])}function cwe(e){let t=k.Keys(e),s=mLn(t);return gd(s)}function lwe(e){return uy(e)}function uwe(e){let t=e.map((s,i)=>Lt(i));return gd(t)}function pwe(e){return qs(e)?awe():as(e)?iwe(e.items):Ht(e)?cwe(e.properties):qr(e)?lwe(e):Pn(e)?uwe(e.items):Rn()}function fLn(e){return Nr(e)||vs(e)||kt(e)||Be(e)?hy(e):e}function Yte(e,t){return St([e])?q.Update(pwe(fLn(e)),{},t):nT(e,t)}function dwe(e,t,s,i){let c=he(e,t,s);return Yte(c,i)}function XC(e,t,s,i,c={}){return Ue("Mapped",[e,t,s,i],c)}function mwe(e,t,s,i,c={}){return Xte({},Hn([],[]),e,t,s,i,c)}function gLn(e){let t=Pa(e);return bM(t)}function RLn(e){return e.reduce((t,s)=>[...t,...bM(s)],[])}function SLn(e){let t=wi(e);return bM(t)}function ILn(e){return k.IsNumber(e)?[Lt(`${e}`)]:[Lt(e)]}function bM(e){return Jo(e)?SLn(e.enum):Wt(e)?ILn(e.const):Bs(e)?gLn(e.pattern):Be(e)?RLn(e.anyOf):[e]}function fwe(e){return bM(e)}function yLn(e){return Bs(e)?Pa(e.pattern):e}function _Ln(e,t,s,i,c,l){let u=q.Assign(e,{[s.name]:i}),p=he(u,t,c),d=yLn(p),m=he(u,t,l);return vDe(d)||CDe(d)?{[d.const]:m}:{}}function hLn(e,t,s,i,c,l){return i.reduce((u,p)=>[...u,_Ln(e,t,s,p,c,l)],[])}function vLn(e){return e.reduce((t,s)=>[...t,it(s)],[])}function gwe(e,t,s,i,c,l){let u=fwe(i),p=hLn(e,t,s,u,c,l),d=vLn(p);return fs(d)}function Xte(e,t,s,i,c,l,u){return St([i])?q.Update(gwe(e,t,s,i,c,l),{},u):XC(s,i,c,l,u)}function Rwe(e,t,s,i,c,l,u){let p=he(e,t,i);return Xte(e,t,s,p,c,l,u)}function CLn(e,t,s){let i=q.Assign(e,t);return k.Keys(t).filter(l=>s.includes(l)).reduce((l,u)=>({...l,[u]:YPe(i,u,t[u])}),{})}function TLn(e,t,s){let i=q.Assign(e,t);return k.Keys(t).filter(l=>!s.includes(l)).reduce((l,u)=>({...l,[u]:he(i,Hn([],[]),t[u])}),{})}function ALn(e,t,s){let i=KPe(t),c=CLn(e,t,i),l=TLn(e,t,i),u={...c,...l};return q.Update(u,{},s)}function xM(e,t,s,i){return ALn(e,s,i)}function aM(e,t={}){return Ue("NonNullable",[e],t)}function Swe(e,t={}){return Jte(e,t)}function DLn(e){let t=At([oy(),py()]);return mT(e,t,{})}function Jte(e,t){return St([e])?q.Update(DLn(e),{},t):aM(e,t)}function Iwe(e,t,s,i){let c=he(e,t,s);return Jte(c,i)}function iM(e,t,s={}){return Ue("Omit",[e,t],s)}function ywe(e,t,s={}){let i=k.IsArray(t)?_y(t):t;return ene(e,i,s)}function PM(e){let t=hy(e);return Ht(t)?t.properties:$s()}function ELn(e,t){return k.Keys(e).reduce((i,c)=>t.includes(c)?i:{...i,[c]:e[c]},{})}function _we(e,t){let s=PM(e),i=Cy(t),c=ELn(s,i);return it(c)}function ene(e,t,s){return St([e,t])?q.Update(_we(e,t),{},s):iM(e,t,s)}function hwe(e,t,s,i,c){let l=he(e,t,s),u=he(e,t,i);return ene(l,u,c)}function cM(e,t={}){return Ue("Parameters",[e],t)}function vwe(e,t={}){return tne(e,t)}function bLn(e){let t=dr(e)?e.parameters:[],s=zm({},Hn([],[]),t);return Us(s)}function tne(e,t){return St([e])?q.Update(bLn(e),{},t):cM(e,t)}function Cwe(e,t,s,i){let c=he(e,t,s);return tne(c,i)}function lM(e,t={}){return Ue("Partial",[e],t)}function Twe(e,t={}){return nne(e,t)}function Awe(e,t){let s=Au(e,t),i=Du(s);return _u(q.Assign(e,{[t]:i}),t)}function Dwe(e,t,s){let i=cl(e,t,s);return Du(i)}function Ewe(e){let t=fs(e);return Du(t)}function bwe(e){let t=e.map(s=>Du(s));return At(t)}function xwe(e){let t=k.Keys(e).reduce((i,c)=>({...i,[c]:Qg(e[c])}),{});return it(t)}function Du(e){return Nr(e)?Awe(e.$defs,e.$ref):vs(e)?Dwe(e.if,e.then,e.else):kt(e)?Ewe(e.allOf):Be(e)?bwe(e.anyOf):Ht(e)?xwe(e.properties):it({})}function nne(e,t){return St([e])?q.Update(Du(e),{},t):lM(e,t)}function Pwe(e,t,s,i){let c=he(e,t,s);return nne(c,i)}function uM(e,t,s={}){return Ue("Pick",[e,t],s)}function $we(e,t,s={}){let i=k.IsArray(t)?_y(t):t;return sne(e,i,s)}function xLn(e,t){return k.Keys(e).reduce((i,c)=>t.includes(c)?q.Assign(i,{[c]:e[c]}):i,{})}function wwe(e,t){let s=PM(e),i=Cy(t),c=xLn(s,i);return it(c)}function sne(e,t,s){return St([e,t])?q.Update(wwe(e,t),{},s):uM(e,t,s)}function kwe(e,t,s,i,c){let l=he(e,t,s),u=he(e,t,i);return sne(l,u,c)}function pM(e,t={}){return Ue("ReadonlyObject",[e],t)}function rne(e,t={}){return one(e,t)}var Lwe=rne;function Mwe(e){return ry($i(e))}function Gwe(e,t){let s=Au(e,t),i=Eu(s);return _u(q.Assign(e,{[t]:i}),t)}function Owe(e,t,s){let i=cl(e,t,s);return Eu(i)}function Nwe(e){let t=fs(e);return Eu(t)}function Vwe(e){let t=k.Keys(e).reduce((i,c)=>({...i,[c]:Xg(e[c])}),{});return it(t)}function qwe(e){return ry(Us(e))}function Fwe(e){let t=e.map(s=>Eu(s));return At(t)}function Eu(e){return as(e)?Mwe(e.items):Nr(e)?Gwe(e.$defs,e.$ref):vs(e)?Owe(e.if,e.then,e.else):kt(e)?Nwe(e.allOf):Ht(e)?Vwe(e.properties):Pn(e)?qwe(e.items):Be(e)?Fwe(e.anyOf):e}function one(e,t){return St([e])?q.Update(Eu(e),{},t):pM(e)}function Bwe(e,t,s,i){let c=he(e,t,s);return one(c,i)}function Uwe(e,t,s,i){return t.visited.includes(i)?s:i in e?he(e,Hn(t.callstack,[...t.visited,i]),e[i]):s}function Hwe(e,t){let s=Au(e,t),i=bu(s);return _u(q.Assign(e,{[t]:i}),t)}function jwe(e,t,s){let i=cl(e,t,s);return bu(i)}function zwe(e){let t=fs(e);return bu(t)}function Kwe(e){let t=e.map(s=>bu(s));return At(t)}function Wwe(e){let t=k.Keys(e).reduce((i,c)=>({...i,[c]:BL(e[c])}),{});return it(t)}function bu(e){return Nr(e)?Hwe(e.$defs,e.$ref):vs(e)?jwe(e.if,e.then,e.else):kt(e)?zwe(e.allOf):Be(e)?Kwe(e.anyOf):Ht(e)?Wwe(e.properties):it({})}function dM(e,t={}){return Ue("Required",[e],t)}function Qwe(e,t={}){return ane(e,t)}function ane(e,t){return St([e])?q.Update(bu(e),{},t):dM(e,t)}function Zwe(e,t,s,i){let c=he(e,t,s);return ane(c,i)}function mM(e,t={}){return Ue("ReturnType",[e],t)}function Ywe(e,t={}){return ine(e,t)}function PLn(e){return dr(e)?e.returnType:Rn()}function ine(e,t){return St([e])?q.Update(PLn(e),{},t):mM(e,t)}function Xwe(e,t,s,i={}){let c=he(e,t,s);return ine(c,i)}function fM(e,t){return Ue("With",[e,t],{})}function Jwe(e,t){return cne(e,t)}function cne(e,t){return St([e])?q.Update(e,{},t):fM(e,t)}function eke(e,t,s,i){let c=he(e,t,s);return cne(c,i)}function $Ln(e){return Bm(e)?Pn(e.items)?lne(e.items.items):Ps(e.items)?[e]:mr(e.items)?[e]:[Rn()]:[e]}function lne(e){return e.reduce((s,i)=>[...s,...$Ln(i)],[])}function Hn(e,t){return{callstack:e,visited:t}}function St(e){return k.ShiftLeft(e,(t,s)=>mr(t)?!1:St(s),()=>!0)}function cT(e,t,s){return k.Keys(s).reduce((i,c)=>({...i,[c]:he(e,t,s[c])}),{})}function zm(e,t,s){let i=ki(e,t,s);return lne(i)}function ki(e,t,s){return s.map(i=>he(e,t,i))}function wLn(e,t){let s=ho(e)?qC(t,{}):t,i=Jg(e)?VC(s,{}):s;return Yg(e)?RT(i,{}):i}function kLn(e,t,s,i,c){return k.IsEqual(s,"AddImmutable")?tke(e,t,i[0],c):k.IsEqual(s,"RemoveImmutable")?p$e(e,t,i[0],c):k.IsEqual(s,"AddReadonly")?YAe(e,t,i[0],c):k.IsEqual(s,"RemoveReadonly")?ODe(e,t,i[0],c):k.IsEqual(s,"AddOptional")?XAe(e,t,i[0],c):k.IsEqual(s,"RemoveOptional")?qDe(e,t,i[0],c):k.IsEqual(s,"Capitalize")?_$e(e,t,i[0],c):k.IsEqual(s,"Conditional")?A$e(e,t,i[0],i[1],i[2],i[3],c):k.IsEqual(s,"ConstructorParameters")?E$e(e,t,i[0],c):k.IsEqual(s,"Evaluate")?e$e(e,t,i[0],c):k.IsEqual(s,"Exclude")?x$e(e,t,i[0],i[1],c):k.IsEqual(s,"Extract")?w$e(e,t,i[0],i[1],c):k.IsEqual(s,"Index")?nwe(e,t,i[0],i[1],c):k.IsEqual(s,"InstanceType")?rwe(e,t,i[0],c):k.IsEqual(s,"Interface")?UPe(e,t,i[0],i[1],c):k.IsEqual(s,"KeyOf")?dwe(e,t,i[0],c):k.IsEqual(s,"Lowercase")?h$e(e,t,i[0],c):k.IsEqual(s,"Mapped")?Rwe(e,t,i[0],i[1],i[2],i[3],c):k.IsEqual(s,"Module")?xM(e,t,i[0],c):k.IsEqual(s,"NonNullable")?Iwe(e,t,i[0],c):k.IsEqual(s,"Pick")?kwe(e,t,i[0],i[1],c):k.IsEqual(s,"Parameters")?Cwe(e,t,i[0],c):k.IsEqual(s,"Partial")?Pwe(e,t,i[0],c):k.IsEqual(s,"Omit")?hwe(e,t,i[0],i[1],c):k.IsEqual(s,"ReadonlyObject")?Bwe(e,t,i[0],c):k.IsEqual(s,"Record")?sEe(e,t,i[0],i[1],c):k.IsEqual(s,"Required")?Zwe(e,t,i[0],c):k.IsEqual(s,"ReturnType")?Xwe(e,t,i[0],c):k.IsEqual(s,"TemplateLiteral")?iPe(e,t,i[0],c):k.IsEqual(s,"Uncapitalize")?v$e(e,t,i[0],c):k.IsEqual(s,"Uppercase")?C$e(e,t,i[0],c):k.IsEqual(s,"With")?eke(e,t,i[0],i[1]):Ue(s,i,c)}function LLn(e,t,s){let i=mr(s)?Uwe(e,t,s,s.$ref):as(s)?$i(he(e,t,s.items),xL(s)):yy(s)?EM(e,t,s.target,s.arguments):pr(s)?Su(ki(e,t,s.parameters),he(e,t,s.instanceType),JAe(s)):dr(s)?Iu(ki(e,t,s.parameters),he(e,t,s.returnType),eDe(s)):vs(s)?Zg(he(e,t,s.if),he(e,t,s.then),he(e,t,s.else),aDe(s)):kt(s)?vo(ki(e,t,s.allOf),pDe(s)):Ht(s)?it(cT(e,t,s.properties),rDe(s)):qr(s)?rEe(Rc(s),he(e,t,na(s))):Bm(s)?nR(he(e,t,s.items)):Pn(s)?Us(zm(e,t,s.items),GDe(s)):Be(s)?At(ki(e,t,s.anyOf),ADe(s)):s;return wLn(s,i)}function he(e,t,s){return Gm(s)?kLn(e,t,s.action,s.parameters,s.options):LLn(e,t,s)}function une(e,t){return he(e,Hn([],[]),t)}function MLn(e){return q.Update(e,{"~immutable":!0},{})}function RT(e,t){return q.Update(MLn(e),{},t)}function tke(e,t,s,i){let c=he(e,t,s);return RT(c,i)}function oxe(e,t={}){return Ue("AddImmutable",[e],t)}function ry(e,t={}){return RT(e,t)}function axe(e,t={}){return Ue("Evaluate",[e],t)}function nke(e,t={}){return Vte(e,t)}function ixe(e,t={}){return Ue("Module",[e],t)}function ske(e,t={}){return xM({},Hn([],[]),e,t)}function rke(...e){let[t,s,i]=hu.Match(e,{2:(u,p)=>k.IsString(u)?[{},u,p]:[u,p,{}],3:(u,p,d)=>[u,p,d],1:u=>[{},u,{}]}),c=nPe(s),l=k.IsArray(c)&&k.IsEqual(c.length,2)?he(t,Hn([],[]),c[0]):Rn();return q.Update(l,{},i)}var ut={};Un(ut,{Any:()=>sy,Array:()=>$i,BigInt:()=>HC,Boolean:()=>ML,Call:()=>l$e,Capitalize:()=>R$e,Codec:()=>LL,Conditional:()=>T$e,Constructor:()=>Su,ConstructorParameters:()=>D$e,Cyclic:()=>_u,Decode:()=>gDe,DecodeBuilder:()=>UC,Dependent:()=>Zg,Encode:()=>RDe,EncodeBuilder:()=>BC,Enum:()=>uDe,Evaluate:()=>nke,Exclude:()=>b$e,Extends:()=>Vr,ExtendsResult:()=>rt,Extract:()=>P$e,Function:()=>Iu,Generic:()=>Om,Identifier:()=>jC,Immutable:()=>SDe,Index:()=>k$e,Infer:()=>FC,InstanceType:()=>swe,Instantiate:()=>une,Integer:()=>eR,Interface:()=>HPe,Intersect:()=>vo,IsAny:()=>qs,IsArray:()=>as,IsBigInt:()=>Cu,IsBoolean:()=>mc,IsCall:()=>yy,IsCodec:()=>kL,IsConstructor:()=>pr,IsCyclic:()=>Nr,IsDependent:()=>vs,IsEnum:()=>Jo,IsEnumValue:()=>lDe,IsFunction:()=>dr,IsGeneric:()=>ny,IsIdentifier:()=>hDe,IsImmutable:()=>Yg,IsInfer:()=>Ps,IsInteger:()=>ea,IsIntersect:()=>kt,IsKind:()=>Ge,IsLiteral:()=>Wt,IsNever:()=>Nm,IsNull:()=>ay,IsNumber:()=>Fs,IsObject:()=>Ht,IsOptional:()=>ho,IsParameter:()=>TDe,IsReadonly:()=>Jg,IsRecord:()=>qr,IsRef:()=>mr,IsRefine:()=>ute,IsRest:()=>Bm,IsSchema:()=>Js,IsString:()=>ta,IsSymbol:()=>Vm,IsTemplateLiteral:()=>Bs,IsThis:()=>WL,IsTuple:()=>Pn,IsUndefined:()=>dy,IsUnion:()=>Be,IsUnknown:()=>er,IsUnsafe:()=>wL,IsVoid:()=>Tu,KeyOf:()=>owe,Literal:()=>Lt,Lowercase:()=>S$e,Mapped:()=>mwe,Module:()=>ske,Never:()=>Rn,NonNullable:()=>Swe,Null:()=>oy,Number:()=>Xa,Object:()=>it,Omit:()=>ywe,Optional:()=>nDe,Parameter:()=>tR,Parameters:()=>vwe,Partial:()=>Twe,Pick:()=>$we,Readonly:()=>IDe,ReadonlyObject:()=>rne,ReadonlyType:()=>Lwe,Record:()=>jL,RecordKey:()=>uy,RecordPattern:()=>Rc,RecordValue:()=>na,Ref:()=>fd,Refine:()=>yDe,Required:()=>Qwe,Rest:()=>nR,ReturnType:()=>Ywe,Script:()=>rke,String:()=>fc,Symbol:()=>iy,TemplateLiteral:()=>lPe,This:()=>KL,Tuple:()=>Us,Uncapitalize:()=>I$e,Undefined:()=>py,Union:()=>At,Unknown:()=>vr,Unsafe:()=>oDe,Uppercase:()=>y$e,Void:()=>QL,With:()=>Jwe});var ST="submit_test_gap_candidates",IT="submit_filtered_test_gaps",yT="submit_test_audit_findings",_T="submit_filtered_test_audit_findings",hT="submit_solver_gaps",HJo=ut.Object({verdict:ut.Union([ut.Literal("PASS"),ut.Literal("FAIL")],{description:"FAIL only for a genuine blocking issue (clear rubric violation, agent-fault-worthy gap, unfair/undiscoverable test requirement, or a real determinism/regression risk). Optional, minor, or stylistic points are NOT grounds for FAIL \u2014 put those in `notes` instead and use PASS."}),summary:ut.String({description:"One short sentence summarizing the verdict."}),reasons:ut.Array(ut.String(),{description:"Specific BLOCKING justifications only, citing rubric item IDs and concrete evidence from the files you read. Required (non-empty) when verdict is FAIL. Use an empty array when verdict is PASS."}),notes:ut.Array(ut.String(),{description:"Non-blocking, optional/minor observations or suggested improvements \u2014 the kind of feedback a real reviewer leaves as 'Minor/optional' without failing the task. Include these regardless of verdict; use an empty array if you truly have none."})});var GLn=ut.Object({statement:ut.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:ut.Array(ut.Object({description:ut.String({description:"A fair, publicly observable missing behavioral test."}),risk:ut.String({description:"Why an incorrect implementation could pass the current tests despite this missing behavior."})}),{description:"All candidate positive and negative gaps for this sentence; there is no maximum or target count, so include every distinct evidence-backed gap and relevant edge case rather than stopping at 10; use an empty array only when exhaustive analysis finds none."})});function oke(e){return{name:ST,label:"Submit Candidate Test Gaps",description:"Submit one candidate-gap list for one prompt sentence. Call this after each sentence so the orchestrator can track the todo list; empty lists are required when that sentence has no gaps.",parameters:GLn,async execute(t,s){let i=e.statements??[];return i.push({statement:s.statement,gaps:s.gaps??[]}),e.statements=i,{content:[{type:"text",text:`Recorded ${s.gaps?.length??0} candidate gap(s)`}],details:void 0}}}}var OLn=ut.Object({gaps:ut.Array(ut.Object({description:ut.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:ut.String({description:"Why this is genuinely grounded in agent_prompt.md or the repo, fair to test per the fairness methodology, and a real (non-duplicate) coverage hole in test.patch \u2014 for negative gaps, cite the prompt's prohibition/constraint and why no existing test catches the forbidden outcome."})}),{description:"The filtered, final list of confirmed test gaps. Use an empty array if none of the candidates survive strict scrutiny."})});function ake(e){return{name:IT,label:"Submit Filtered Test Gaps",description:"Submit your final, strictly filtered list of confirmed test gaps. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have independently verified each candidate.",parameters:OLn,async execute(t,s){let i=s.gaps??[];return e.gaps=i,{content:[{type:"text",text:`Confirmed ${i.length} gap(s) after filtering`}],details:void 0}}}}var NLn=ut.Object({category:ut.Union([ut.Literal("unfair-assertion"),ut.Literal("prompt-ambiguity"),ut.Literal("weak-assertion"),ut.Literal("broken-fixture")],{description:"The kind of actionable problem found in the current test or its setup."}),testName:ut.String({description:"The test name or short identifier that lets the caller find the affected assertion."}),problem:ut.String({description:"What is wrong with the test and why it is blocking or actionable."}),evidence:ut.String({description:"The prompt, public repository contract, test, or fixture evidence supporting the finding."}),requiredBehavior:ut.String({description:"The semantic behavior or gap that must remain covered after the test is repaired."}),recommendation:ut.String({description:"A fair repair, or a prompt clarification when the contract is genuinely ambiguous."})}),ike=ut.Object({findings:ut.Array(NLn,{description:"Only confirmed, actionable fairness, ambiguity, test-strength, or fixture findings. Use an empty array when the current tests are fair, strong, and grounded."})});function cke(e){return{name:yT,label:"Submit Test Audit Candidates",description:"Submit candidate findings from the first post-implementation test audit phase. This is the ONLY way to report your result \u2014 call it exactly once, as your last action. Use an empty list when no actionable issue is found.",parameters:ike,async execute(t,s){let i=s.findings??[];return e.findings=i,{content:[{type:"text",text:`Recorded ${i.length} test-audit candidate(s)`}],details:void 0}}}}function lke(e){return{name:_T,label:"Submit Validated Test Audit Findings",description:"Submit the final, independently validated findings from the post-implementation test audit. This is the ONLY way to report your result \u2014 call it exactly once, as your last action. Use an empty list when no candidate survives strict review.",parameters:ike,async execute(t,s){let i=s.findings??[];return e.findings=i,{content:[{type:"text",text:`Recorded ${i.length} validated test-audit finding(s)`}],details:void 0}}}}var VLn=ut.Object({gaps:ut.Array(ut.Object({description:ut.String({description:"The specific behavioral gap: a way one or more solver's diff differs materially from what agent_prompt.md/solution.patch require, despite that solver passing `./test.sh new`."}),justification:ut.String({description:"Why this is a genuine requirement from agent_prompt.md or solution.patch (cite the specific requirement/line) that the solver's diff misses, contradicts, or diverges from \u2014 and why the current tests fail to catch that divergence."}),evidence:ut.String({description:"Which solver(s) (by index) exhibit this, and the specific part of their diff that grounds the gap."})}),{description:"Concrete, diff-grounded behavioral gaps \u2014 cases where a passing solver's materially different approach reveals that `test.sh new` under-specifies a real requirement. Use an empty array if the solvers converged on equivalent behavior; do not manufacture gaps just to report something."})});function uke(e){return{name:hT,label:"Submit Solver Gaps",description:"Submit your final list of behavioral gaps found by comparing the solver diffs against the real solution.patch. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have finished comparing every solver.",parameters:VLn,async execute(t,s){let i=s.gaps??[];return e.gaps=i,{content:[{type:"text",text:`Recorded ${i.length} solver gap(s)`}],details:void 0}}}}function qLn(e){return[e,"You are working inside the actual repository (this is your current directory) in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Read `agent_prompt.md` for the task requirements and inspect the repository's existing source/code files with read/grep/find/ls. Base the analysis on the prompt and the observable behavior supported by those code files."]}var FLn=["Thoroughness \u2014 your job is high recall on genuine gaps only:","- There is no target count or cap: do not stop at 10 (or any other arbitrary number). For each prompt sentence, enumerate as many distinct uncovered required behaviors and edge cases as the files justify, then continue until an additional sweep finds no new genuine gap.","- Find every gap you can justify with concrete evidence. Do not stop after the first obvious ones \u2014 keep reading until you have systematically covered the prompt and relevant repository code.","- After your first pass, run at least one deliberate second sweep (re-read `agent_prompt.md` and grep/read the relevant code files) before submitting \u2014 but if that sweep still finds nothing, submit an empty list.","- Do not self-censor or merge distinct genuine gaps into one \u2014 the validator will prune. Never invent or pad the list to seem thorough; an empty array is correct when exhaustive analysis truly finds none.","- Hunt subtle gaps too: behaviors that may be missed under other valid inputs, repository conventions, interaction effects, ordering/timing, and branches in the relevant source code that need behavioral coverage.","- Include a candidate only when you can cite specific grounding and a concrete false-pass risk \u2014 not to meet a quota."],pke=["Fairness rules \u2014 apply these to every proposed gap and every proposed assertion:","- Ground every candidate in a specific sentence or requirement in `agent_prompt.md`, or in an existing public contract that is clear and directly relevant in the repository. Record the observable behavior and the plausible incorrect implementation that could pass without this check. Do not create requirements from intuition, taste, general best practice, or a desire for more coverage.","- Treat `agent_prompt.md` as the task contract. Existing source can clarify how an already-public API behaves and can make an established convention discoverable, but a neighboring helper, default, example, or implementation choice does not automatically become a requirement for a new behavior. If repository evidence is absent, mixed, or contradictory, leave the detail open rather than choosing one interpretation.","- A fair check must be expressible through a user-visible result, a caller-visible side effect, a named public API, or another documented/public contract. Do not require private state, private helpers, internal classes, file placement, module boundaries, call order, a particular algorithm, or a particular direct platform/API call when another repo-valid route produces the required outcome.","- A newly invented function, class, property, export, constructor, method name, argument shape, import path, or registry/config key is not a fair requirement merely because it would be a convenient way to test the feature. Require a new API only when `agent_prompt.md` names it, or when the API already exists publicly and the task explicitly relies on it.","- For UI behavior, assert the user-facing control, label, visible state, accessible action, or resulting effect when that is the contract. Do not require a particular DOM hierarchy, tag, CSS class, selector, test/data attribute, ARIA attribute, hidden-shim text, focus order, keyboard traversal, or control implementation unless the prompt or an established public UI contract explicitly requires it.","- Test semantics rather than source representation. Do not pin quote style, whitespace, line breaks, token adjacency, identifier spelling, generated-source wording, code length, AST node shape, type-text spelling, serialization style, or a particular equivalent syntax when the resulting behavior is the same. Normalize, parse, compile, or observe the result when that is necessary to compare equivalent forms.","- For structured results, assert the fields, values, relationships, ordering, and preservation that the contract actually requires. Allow additional valid fields and metadata unless the prompt explicitly forbids them. Do not compare a whole object, list, mapping, or serialized document to a minimal reference-shaped object when only a subset of its contents is contractual. For unspecified unknown fields, do not assume either permissive or strict validation: acceptance is fair only when extras are expressly allowed or established, and rejection is fair only when unknown fields are expressly forbidden or established at that schema level.","- Treat configuration schemas as contracts, not guesses. Field type, collection shape, omitted-field defaults, unknown-key policy, extension-based dispatch, coercion, and cross-field constraints are independently specified decisions. Do not require a string-only name, a particular list shape, a filename-driven parser, a boolean-only flag, a valid range relationship, or rejection of an extra key unless the prompt or a public schema settles it.","- Make aggregation semantics explicit before requiring exact counts. A count may be per input, field, item, target, rule, match, category, finding, log record, or operation; multiple units may overlap or be mutually exclusive. For repair or mutation output, also distinguish findings measured before the change from findings remaining after the change. If the contract does not choose the unit, test presence, effect, or a stated relationship rather than an exact number.","- Do not resolve interactions between separately described rules by intuition. Optional-path handling versus target-level checks, validation versus evaluation, duplicate detection across collections, cache reuse versus a new input, and consensus among agreeing versus dissenting values each need an explicit precedence or scope. A test must not silently choose skip-all versus continue, majority versus unanimity, per-collection versus global deduplication, or disjoint versus overlapping diagnostic categories.","- Do not infer a concrete value from relational wording. Terms such as current, latest, selected, next, matching, appropriate, or stable require the stated relationship or effect, not an arbitrary numeric or serialized value. Pin a concrete value only when the prompt or a clear existing public contract determines it.","- Do not infer an exact ordering, grouping, cardinality, count, or error-counting model from incidental map order, loop order, a convenient fixture, or one implementation. Require ordering or counts only when the contract makes them observable; otherwise assert membership, relationships, preservation, and the required effect without choosing a granularity the prompt leaves open. This includes order of newly added versus loaded values and the number or placement of repeated diagnostic terms.","- Preserve scope qualifiers. A requirement for aware values, naive values, all-day values, one mode, one target state, or one lifecycle phase does not automatically apply to every representation or phase. Do not transfer a rule from one subtype to another, or require a changed wall time, timezone, normalization, or side effect outside the scope in which the prompt states it.","- Do not invent an input-domain policy for unspecified cases. Do not require acceptance or rejection of a particular malformed, nullish, Unicode, unusually large, boolean-like, platform-specific, symlink, missing-parent, or other boundary value unless the prompt or an established public contract settles that case. A sensible API policy is not automatically the specified policy.","- For failures, assert the failure or user-visible error behavior required by the contract. Do not require a specific exception class, message wording, punctuation, embedded input value, capitalization, basename, validation phase, or eager-versus-deferred timing unless it is explicitly promised or publicly established. If the contract only says an operation fails clearly, accept equivalent clear failures. When the prompt expressly permits more than one failure phase or handling path\u2014such as load-time rejection or evaluation-time violation\u2014accept every permitted path; do not force one merely because it is easier to assert.","- Do not assume an expression or embedded language has unlisted builtins, operators, container types, mutability, mapping shapes, or context bindings. Test only the language surface and binding representation that the prompt or an existing public evaluator contract names. A useful operation such as length, indexing, mutation, or a helper call is not implicitly available in a restricted environment.","- Respect asynchronous and lazy contracts. If the prompt promises an eventual effect, do not require a callback to return a promise, immediate settlement, a particular debounce interval, construction-time validation, or one exact observation point. Trigger the public operation and observe or wait for the promised result at a fair boundary.","- Do not select an outcome for an underspecified mode boundary. Dry-run, preview, no-op, conflict, rollback, cache, preflight, and post-context-change behavior may have multiple valid outcomes unless the prompt chooses one. Test the guarantees that are stated, such as non-mutation or reporting, without adding a rejection, write, refresh, or validation policy that was not stated.","- Do not convert an incidental side effect into a requirement. For a no-op or reuse case, test the required content, state, preservation, or absence of duplicate effects; do not additionally require an empty file, directory, cache entry, history item, or other artifact to exist or not exist unless that artifact is part of the contract.","- For logs and status messages, check that the required operation or failure is reported when reporting is contractual. Do not demand arbitrary English words, formatting, punctuation, path spelling, message fragments, or exact output layout when the prompt only requires that the operation be communicated.","- A fair behavioral test must not depend on a hidden harness's mock shape, a source-level monkeypatch landing at one import binding, an incomplete module mock, reassigned exported state, a particular failure-injection primitive, or a synthetic fixture that violates real repository invariants. Patch or fake a dependency at a public lookup boundary that supports the repository's valid import styles, rather than assuming whether code imports a module or a symbol. A reasonable implementation must be able to use the repository's valid public exports and state model without being rejected by the setup.","- Test doubles must preserve the public interface and lifecycle needed to reach the assertion. A double for a collaborator must implement existing extension points, return valid shapes, and provide newly required public capabilities or isolate them through an explicit seam. Do not make a detached constructor, unmounted widget, partial collection, missing pane service, or fake cache stand in for an active production flow unless that detached behavior is itself contractual.","- Separate fairness from test strength. A test can be fairly scoped yet too weak if it observes a color anywhere instead of on the required target, checks a generic message without associating it with the operation, or verifies a destination representation without preserving the required identity/instant/relationship. Do not call such a test unfair for being permissive; treat it as insufficient coverage and require a precise public observation.","- Distinguish the semantic goal from the assertion form. If a candidate contains a fair behavioral core plus an unsupported value, representation, timing, API, or harness assumption, keep or rewrite the fair core and remove only the unsupported co-assertion. Do not discard a real gap merely because the first proposed assertion was too specific.","- Do not turn a harness safety limit into a product requirement. A test-level subprocess timeout, signal alarm, poll interval, viewport size, or platform-specific signal is only fair when the task or public performance contract specifies it. Use a separate generous anti-hang guard for malformed or pathological evaluation, and assert the required bounded/failure outcome without choosing an arbitrary wall-clock budget.","- A failed setup and a failed behavioral assertion are different evidence. If a shared fixture crashes before the feature is observed, or an observer renders the wrong viewport/widget after locating a valid result, the test is broken rather than proof of an implementation gap. If the fixture reaches the public behavior but rejects a valid alternative representation or integration path, it is a contract/test mismatch. Do not treat either as a fair behavioral requirement.","- Edge-case coverage is valuable only when the edge case is required or discoverable. Do not report 'more negative tests would be nice' or every conceivable malformed input. Keep a candidate only when it is distinct, publicly testable, concretely grounded, and could let a materially incorrect implementation pass.","- When uncertain, re-read the exact prompt sentence and the closest public source analogues. If two competent implementations can satisfy the contract while differing on the proposed assertion, the assertion is not fair; return the semantic relationship instead or drop the candidate. An empty result is correct when no candidate survives this standard."],dke=pke,BLn=pke;function mke(e,t){let s=[...qLn("You are an exhaustive behavioral test-gap finder. Review the task prompt sentence by sentence, finding both missing required-behavior (positive) and missing forbidden/wrong-behavior (negative) tests."),"","First split `agent_prompt.md` into its meaningful sentences using periods (`.`) as the sentence boundary. Create an explicit TODO checklist of every resulting requirement sentence. Work through it one item at a time; do not finish until every item is checked off.","","Before analyzing each sentence, use read/grep/find/ls to inspect the relevant source files and their closest analogues. Use that code context to understand the public contracts, conventions, branches, guards, early returns, state transitions, side effects, boundary handling, and negative/prohibited outcomes required by the sentence. Report every distinct, prompt-required behavioral edge case or prohibition that a plausible implementation could miss. Include positive and negative gaps together for that sentence. There is no maximum number of gaps: keep enumerating distinct missing behaviors for this sentence, including boundary, empty, repeated, interacting, and other relevant edge cases; do not treat 10 as sufficient.","",...FLn,"",...dke,"","Test-coverage checklist for calibration:",e];return s.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements."),s.push("","For every candidate, state the missing fair behavioral test, the relevant source behavior or branch that led you to investigate it, and why a plausible incorrect implementation could evade that test. The prompt sentence is the required specification: do not report incidental implementation details it does not require. Do not propose the exact test implementation.",`After completing EACH TODO sentence, call \`${ST}\` with that exact sentence and its gap array (including an empty array when none exist). You may and must call the tool multiple times: once per sentence. Only finish after every TODO item has been submitted.`),s.join(`
76
76
  `)}function fke(e,t,s){let i=["You are a strict, skeptical fairness auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Two specialized research agents reviewed `agent_prompt.md` and the repository's source/code files sentence by sentence, proposing both positive (missing required-behavior) and negative (missing forbidden/wrong-behavior) gaps. It submitted the following per-sentence candidate report:","",JSON.stringify(e,null,2),"","Your job is to independently re-verify the files yourself and FILTER this list down to only candidates that are ALL of the following:","1. Genuinely grounded \u2014 actually required by a specific statement in `agent_prompt.md`, or unambiguous from clearly visible, existing repo behavior. Drop anything speculative, nice-to-have, or invented beyond what the prompt actually asks for.","2. Fair to test \u2014 verifying it would not require undiscoverable private internals, an invented/unnamed API, or exact incidental implementation structure. Judge this precisely against the fairness guidance below.","3. A real, distinct behavioral gap \u2014 drop near-duplicate candidates and keep only the clearest phrasing of each distinct gap. Retain a candidate only when the source code and prompt provide concrete grounding for a behavior that deserves an explicit public-outcome check.","4. Behaviorally testable through a public contract \u2014 drop candidates that would require an internal helper, private state, implementation structure, call order, DOM class/attribute/data hook, selector, or exact string literal. The sole exceptions are details explicitly named in `agent_prompt.md` or already established as a public contract in the existing repository.","","Be strict: when genuinely unsure whether a candidate holds up, drop it rather than keep it. It is fine \u2014 expected, even \u2014 to return an empty list if none of the candidates survive scrutiny.","","Checklist for the tests focus area, for calibration:",t];return i.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements.","",...BLn),i.push("","For every gap you keep, give a short justification citing where in `agent_prompt.md` or the repo it is grounded. Preserve POSITIVE:/NEGATIVE: prefix when applicable.",`When you are done, call the \`${IT}\` tool exactly once with your final filtered list (which may be empty). That tool call is your only way to report a result.`),i.join(`
77
- `)}function gke(e,t){return["You are a strict, skeptical post-implementation test-quality and fairness auditor for a coding-agent benchmark task.","You are working inside the actual repository in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code, edit files, or apply patches.","The task's `agent_prompt.md` is the contract. The current tests may be represented by `test.patch` and/or by test files and fixtures in the repository. Read the unified diff carefully, then inspect every added or changed test, fixture, mock, helper, and the public source behavior it exercises. Do not audit hypothetical tests.","Read `solution.patch` only as evidence for scenarios worth inspecting. The reference implementation is not the specification, and its private structure, names, defaults, and call paths must not be required by your audit.","","Your goal is to find actionable problems in the tests that were written or changed during the current gap-finding iteration, while preserving the behavioral gap they were intended to close.","","For each assertion and relevant fixture, independently ask:","1. What exact prompt sentence or established public contract supports this check?","2. What can a user, caller, or public API observe?","3. Could two competent implementations satisfy the contract while differing on this assertion?","4. Does the fixture preserve repository-valid state, module shape, exports, references, and lifecycle?","5. Would the assertion catch a materially incorrect implementation rather than merely a different implementation?","","Report only concrete, actionable findings in these categories:","- unfair-assertion: a valid implementation could fail because the test requires an undocumented API, exact representation, value, timing, structure, call path, message, ordering, count, or harness behavior.","- prompt-ambiguity: the prompt does not select one of multiple reasonable behaviors, but the test forces one. Recommend clarifying the prompt or relaxing the test; never choose an interpretation merely from solution.patch.","- weak-assertion: the check is fair in scope but observes the wrong target or is too permissive to enforce the intended gap. Strengthen the public semantic observation, not the implementation coupling.","- broken-fixture: setup, mocks, or observers remove a valid repository path or fail before the public behavior is reached. Repair the fixture rather than imposing its limitation on implementations.","","A test can contain a fair behavioral core and an unfair co-assertion. Preserve the fair core and recommend removing or relaxing only the unsupported part. Do not discard a genuine gap because the first assertion was too narrow. Conversely, do not call a permissive assertion unfair; classify it as weak and explain how to observe the required public target or relationship precisely.","Do not report style preferences, optional coverage, speculative edge cases, or requirements invented from intuition. When the prompt is genuinely vague, do not silently turn the reference solution into a requirement.","","Fair and unfair test guidance (from `rules.md`):",t,"","Tests checklist for calibration:",e,"","For every finding, provide its category, the test name or short identifier, the problem, concrete evidence, the required behavior that must remain covered, and a fair repair recommendation. If the tests are fair and sufficiently strong, submit an empty list.",`When you are done, call the \`${yT}\` tool exactly once with the complete final list. That tool call is your only way to report a result.`].join(`
77
+ `)}function gke(e,t){return["You are a strict, skeptical post-implementation test-quality and fairness auditor for a coding-agent benchmark task.","You are working inside the actual repository in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code, edit files, or apply patches.","The task's `agent_prompt.md` is the contract. The current tests may be represented by `test.patch` and/or by test files and fixtures in the repository. Read the unified diff carefully, then inspect every added or changed test, fixture, mock, helper, and the public source behavior it exercises. Do not audit hypothetical tests.","Read `solution.patch` only as evidence for scenarios worth inspecting. The reference implementation is not the specification, and its private structure, names, defaults, and call paths must not be required by your audit.","","Your goal is to find actionable problems in the tests that were written or changed during the current gap-finding iteration, while preserving the behavioral gap they were intended to close.","Do not assume an assertion is valid because it is precise, passes the reference solution, or appears related to the prompt. The audit must explicitly check the validity of every assertion; finding no issue is acceptable only after a complete assertion-by-assertion review.","","Mandatory audit procedure:","1. Read `test.patch` and enumerate every added or changed test, test helper, fixture, mock, and assertion/expectation. Create an internal checklist and do not submit until every item has been reviewed.","2. For EACH assertion, inspect the exact prompt requirement, the public repository contract, the fixture state, and the observation target. Do not review only the test name or the main happy-path assertion.","3. Classify every assertion internally as VALID, UNFAIR, AMBIGUOUS, WEAK, or BROKEN. For every non-VALID item, explain the concrete evidence and produce a finding. For every VALID item, actively verify why two reasonable implementations would both be accepted.","4. Check compound assertions separately. If one co-assertion is unsupported, retain the fair behavioral core and report the unsupported part instead of treating the whole test as valid.","5. Perform a final sweep of the checklist before submitting. Do not return an empty list merely because the tests are small, the intended behavior seems obvious, or the reference implementation satisfies them.","","For each assertion and relevant fixture, independently ask:","1. What exact prompt sentence or established public contract supports this check?","2. What can a user, caller, or public API observe?","3. Could two competent implementations satisfy the contract while differing on this assertion?","4. Does the fixture preserve repository-valid state, module shape, exports, references, and lifecycle?","5. Would the assertion catch a materially incorrect implementation rather than merely a different implementation?","","Report only concrete, actionable findings in these categories:","- unfair-assertion: a valid implementation could fail because the test requires an undocumented API, exact representation, value, timing, structure, call path, message, ordering, count, or harness behavior.","- prompt-ambiguity: the prompt does not select one of multiple reasonable behaviors, but the test forces one. Recommend clarifying the prompt or relaxing the test; never choose an interpretation merely from solution.patch.","- weak-assertion: the check is fair in scope but observes the wrong target or is too permissive to enforce the intended gap. Strengthen the public semantic observation, not the implementation coupling.","- broken-fixture: setup, mocks, or observers remove a valid repository path or fail before the public behavior is reached. Repair the fixture rather than imposing its limitation on implementations.","","A test can contain a fair behavioral core and an unfair co-assertion. Preserve the fair core and recommend removing or relaxing only the unsupported part. Do not discard a genuine gap because the first assertion was too narrow. Conversely, do not call a permissive assertion unfair; classify it as weak and explain how to observe the required public target or relationship precisely.","Do not report style preferences, optional coverage, speculative edge cases, or requirements invented from intuition. When the prompt is genuinely vague, do not silently turn the reference solution into a requirement.","","Fair and unfair test guidance (from `rules.md`):",t,"","Tests checklist for calibration:",e,"","For every finding, provide its category, the test name or short identifier, the problem, concrete evidence, the required behavior that must remain covered, and a fair repair recommendation. If the tests are fair and sufficiently strong, submit an empty list.",`When you are done, call the \`${yT}\` tool exactly once with the complete final list. That tool call is your only way to report a result.`].join(`
78
78
  `)}function Rke(e,t,s){return["You are an independent, strict validator for a post-implementation test-quality and fairness audit.","You are working inside the actual repository in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code, edit files, or apply patches.","The first audit agent submitted the following candidate findings:","",JSON.stringify(e,null,2),"","Independently read `agent_prompt.md`, `test.patch`, the affected test files and fixtures, and the relevant public source. Do not trust the candidate wording, and do not treat `solution.patch` as the specification.","Keep a finding only when it is all of the following:","1. Grounded in an explicit prompt requirement or an unambiguous existing public repository contract.","2. A real issue in the current test or fixture, not a hypothetical improvement or a disagreement with style.","3. Fairly classified as an unfair assertion, prompt ambiguity, weak assertion, or broken fixture.","4. Actionable through a public semantic repair, while preserving the required behavior or gap.","5. Distinct from the other retained findings and supported by concrete evidence.","","Drop findings that merely ask for more coverage, rely on private/reference-solution structure, or infer an unstated value, representation, timing, count, ordering, API, error form, or harness shape. If a finding has a fair behavioral core plus one unsupported co-assertion, retain it with a recommendation to remove only that co-assertion. If a prompt is genuinely ambiguous, recommend clarifying the prompt or relaxing the test rather than choosing an interpretation from the reference solution.","","Fair and unfair test guidance (from `rules.md`):",s,"","Tests checklist for calibration:",t,"","Return only the validated, deduplicated findings. Preserve the test name and required behavior, and reword any finding so its recommendation is precise without adding an implementation requirement. An empty list is correct when no candidate survives independent review.",`When you are done, call the \`${_T}\` tool exactly once with the final list. That tool call is your only way to report a result.`].join(`
79
79
  `)}function ULn(e){let t=e.status==="ok"?e.passed?"PASSED all new tests":"did NOT pass all new tests":`did not complete normally (status: ${e.status})`;return`- Solver ${e.index} \u2014 ${t} \u2014 solution.diff / test_output.txt in \`${LC}/solver_${e.index}/\``}function Ske(e,t,s){let i=["You are a strict, skeptical behavioral-gap auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code, apply patches, or edit files.","The repo root contains `agent_prompt.md` (the real task description), `solution.patch` (a unified diff of the real golden/reference solution), and `test.patch` (a unified diff adding the hidden tests).","",`Separately, several coding agents ('solvers') were each given the same \`agent_prompt.md\` plus the failing tests from \`test.patch\` \u2014 but never \`solution.patch\` \u2014 and asked to implement the task TDD-style, iterating with real shell access until the tests passed or they gave up. Each solver's diff and full \`test.sh new\` output \u2014 captured and verified independently by the harness, not self-reported \u2014 is saved under \`${LC}/solver_<index>/\` (\`solution.diff\`, \`test_output.txt\`), with a \`${LC}/manifest.json\` summary. Use read/grep/find/ls to open exactly what you need. Status summary:`,"",...e.map(ULn),"","Your job: compare the reference `solution.patch` with each solver's `solution.diff` to find concrete BEHAVIORAL GAPS. Keep only a difference where: (a) `agent_prompt.md` explicitly requires the behavior, (b) the solver passed the relevant tests (even if it failed elsewhere), (c) the reference and solver produce observably different behavior for a real edge case or scenario, and (d) a fair public-facing test could distinguish them. The reference solution is evidence for scenarios to inspect, never a specification by itself.","","How to work:","1. Read `agent_prompt.md` sentence by sentence and note every distinct requirement, constraint, and prohibition.","2. Read `solution.patch` to see how the reference solution satisfies those requirements.","3. For each solver, read its `solution.diff` and compare it against the reference behavior. Look specifically for a solver shortcut, missed constraint, edge case, or side effect that the PROMPT requires, where the solver still passes because the tests do not observe the behavioral difference.","4. A solver that did not pass the full suite may still provide evidence for a completed, relevant part of its diff, but only when its test output shows the failure is unrelated to that behavior (or shows the relevant tests already passed). Do not treat its failing behavior as a gap, and do not infer gaps from a hypothetical wrong implementation.","5. Treat multiple solvers converging on the same divergent-but-passing shortcut as stronger evidence of a real gap, not proof it's acceptable \u2014 the tests are what's under scrutiny, not majority solver behavior.","",...dke,"- Every gap must be evidenced by an actual, cited solver diff and a contrasting reference behavior. For a solver that failed the full suite, also cite its test output showing that the relevant behavior already passed or is unrelated to the failure. Cite the prompt sentence that makes the behavioral difference required; do not report a gap that is purely theoretical or based only on the reference implementation.","- It is fine, and expected, to submit an empty list if the solvers that passed all converged on behavior equivalent to the reference solution with no material gaps.","- Do not self-censor for volume, but do not pad the list either \u2014 only include what you can concretely justify with cited evidence.","","For reference, here is the checklist for the tests focus area (use it to calibrate what good coverage looks like, not as a list of gaps to report verbatim):",t];return s&&i.push("","Fairness methodology (context on what a fair, in-scope requirement looks like):",s),i.push("",`When you are done, call the \`${hT}\` tool exactly once with your final list (which may be empty). That tool call is your only way to report a result.`),i.join(`
80
80
  `)}var HLn=900*1e3,TT=["read","grep","find","ls"];function AT(e){return e==="off"?void 0:e}async function DT(e,t,s=HLn){return t.aborted?"cancelled":new Promise((i,c)=>{let l=!1,u,p=()=>{u!==void 0&&clearTimeout(u),t.removeEventListener("abort",m)},d=S=>{l||(l=!0,p(),i(S))},m=()=>d("cancelled");u=setTimeout(()=>d("timedOut"),s),t.addEventListener("abort",m,{once:!0}),e().then(()=>d("done"),S=>{l||(l=!0,p(),c(S))})})}async function ET(e){if(e){try{e.isIdle||await e.abort()}catch{}e.dispose()}}async function Ike(e){let t={},s=e.model,i;try{({session:i}=await vT({cwd:e.tempDir,model:s,thinkingLevel:AT(e.thinkingLevel),tools:[...TT,ST],customTools:[oke(t)],sessionManager:CT.inMemory()}));let c=await DT(async()=>{await i?.prompt(mke(e.testRubric,e.fairnessRules))},e.cancelSignal);if(c!=="done")return await i.abort(),{status:c,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await ET(i)}return t.statements?{status:"ok",gaps:t.statements}:{status:"noSubmission",gaps:[]}}async function yke(e){let t={},s=e.model,i;try{({session:i}=await vT({cwd:e.tempDir,model:s,thinkingLevel:AT(e.thinkingLevel),tools:[...TT,hT],customTools:[uke(t)],sessionManager:CT.inMemory()}));let c=await DT(async()=>{await i?.prompt(Ske(e.solverResults,e.testRubric,e.fairnessRules))},e.cancelSignal);if(c!=="done")return await i.abort(),{status:c,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await ET(i)}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}async function _ke(e){let t={},s=e.model,i;try{({session:i}=await vT({cwd:e.tempDir,model:s,thinkingLevel:AT(e.thinkingLevel),tools:[...TT,IT],customTools:[ake(t)],sessionManager:CT.inMemory()}));let c=await DT(async()=>{await i?.prompt(fke(e.statementReports,e.testRubric,e.fairnessRules))},e.cancelSignal);if(c!=="done")return await i.abort(),{status:c,gaps:[]}}catch{return{status:"error",gaps:[]}}finally{await ET(i)}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}async function hke(e){let t={},s=e.model,i;try{({session:i}=await vT({cwd:e.tempDir,model:s,thinkingLevel:AT(e.thinkingLevel),tools:[...TT,yT],customTools:[cke(t)],sessionManager:CT.inMemory()}));let c=await DT(async()=>{await i?.prompt(gke(e.testRubric,e.fairnessRules))},e.cancelSignal);if(c!=="done")return await i.abort(),{status:c,findings:[]}}catch{return{status:"error",findings:[]}}finally{await ET(i)}return t.findings?{status:"ok",findings:t.findings}:{status:"noSubmission",findings:[]}}async function vke(e){let t={},s=e.model,i;try{({session:i}=await vT({cwd:e.tempDir,model:s,thinkingLevel:AT(e.thinkingLevel),tools:[...TT,_T],customTools:[lke(t)],sessionManager:CT.inMemory()}));let c=await DT(async()=>{await i?.prompt(Rke(e.findings,e.testRubric,e.fairnessRules))},e.cancelSignal);if(c!=="done")return await i.abort(),{status:c,findings:[]}}catch{return{status:"error",findings:[]}}finally{await ET(i)}return t.findings?{status:"ok",findings:t.findings}:{status:"noSubmission",findings:[]}}var Hg=Xn(rtn(),1),yo=Xn(Bpn(),1),hr=Xn(VAn(),1),Vee=Xn(bEn(),1),GEn=Xn(F_(),1),QI=Xn(xEn(),1);import{randomUUID as $En}from"node:crypto";import{createReadStream as Obo,existsSync as cAe,mkdirSync as Nbo,readFileSync as Vbo,rmSync as wEn,writeFileSync as Nee}from"node:fs";import{tmpdir as kEn}from"node:os";import{join as km}from"node:path";import{fileURLToPath as LEn}from"node:url";import{posix as kbo}from"node:path";function PEn(e){let t,s="/",i={},c=[];for(let l of Mbo(e)){let u=l.match(/^([A-Za-z]+)(?:\s+(.+))?$/s);if(!u)throw new Error(`Invalid Dockerfile instruction: ${l}`);let p=u[1]?.toUpperCase(),d=u[2]?.trim()??"";switch(p){case"FROM":{if(t)throw new Error("Multi-stage Dockerfiles are not supported by the Fargate runner.");let m=Gee(d);if(!m[0]||m.some(S=>S.startsWith("--")||S.toUpperCase()==="AS"))throw new Error(`Unsupported FROM instruction: ${l}`);t=m[0];break}case"WORKDIR":if(!d||d.includes("$")||d.includes("\\"))throw new Error(`WORKDIR must be a concrete POSIX path: ${l}`);s=kbo.resolve(s,d);break;case"ENV":Lbo(d,i);break;case"COPY":if(Gee(d).length<2||Gee(d).some(m=>m.startsWith("--")))throw new Error(`COPY flags and malformed COPY instructions are not supported: ${l}`);break;case"RUN":if(!d||d.startsWith("--")||d.startsWith("["))throw new Error(`Only shell-form RUN instructions without options are supported: ${l}`);c.push(d);break;case"CMD":case"ENTRYPOINT":case"LABEL":case"EXPOSE":break;default:throw new Error(`Unsupported Dockerfile instruction for Fargate execution: ${p}`)}}if(!t)throw new Error("Dockerfile is missing a FROM instruction.");return{baseImage:t,workdir:s,env:i,runtimeCommands:c}}function Lbo(e,t){let s=Gee(e);if(s.length===0)throw new Error("ENV requires a variable assignment.");if(s[0]?.includes("=")){for(let i of s){let c=i.indexOf("=");if(c<=0)throw new Error(`Invalid ENV assignment: ${i}`);t[i.slice(0,c)]=i.slice(c+1)}return}if(s.length<2)throw new Error(`ENV requires a value: ${e}`);t[s[0]]=s.slice(1).join(" ")}function Mbo(e){let t=[],s="";for(let i of e.split(/\r?\n/)){let c=i.trimEnd();if(!s&&/^\s*#/.test(c))continue;let l=s?`${s}${c.trimStart()}`:c.trimStart();Gbo(l)?s=`${l.slice(0,-1).trimEnd()} `:(l.trim()&&t.push(l.trim()),s="")}return s.trim()&&t.push(s.trim()),t}function Gbo(e){let t=0;for(let s=e.length-1;s>=0&&e[s]==="\\";s-=1)t+=1;return t%2===1}function Gee(e){let t=[],s="",i,c=!1;for(let l of e)c?(s+=l,c=!1):l==="\\"&&i!=="'"?c=!0:i?l===i?i=void 0:s+=l:l==='"'||l==="'"?i=l:/\s/.test(l)?s&&(t.push(s),s=""):s+=l;if(c&&(s+="\\"),i)throw new Error(`Unterminated quote in Dockerfile instruction: ${e}`);return s&&t.push(s),t}var OEn="shipd-worker",qbo="fargate-worker.mjs",EC=3300,Fbo=5e3;function NEn(e){return new Promise(t=>setTimeout(t,e))}function Bbo(e,t){let s=(0,GEn.defaultProvider)({profile:process.env.AWS_PROFILE??t}),i={region:e,credentials:s,maxAttempts:5};return{ecs:new yo.ECSClient(i),ec2:new Hg.EC2Client(i),s3:new hr.S3Client(i),sts:new Vee.STSClient(i)}}async function VEn(e){if(e.cancelSignal.aborted)throw new Error("Cancelled by user.");e.onPhase?.("preparing image");let t=km(e.repoDir,"Dockerfile");if(!cAe(t))throw new Error("Fargate solver gap finder requires Dockerfile in the project root.");let s=PEn(Vbo(t,"utf-8")),i=Ubo(e.config,e.repoDir),c=process.env.AWS_REGION??i.region??"us-east-1",l=Bbo(c,i.awsProfile),u=bAe(e.repoDir,i),p=km(kEn(),`.shipd-fargate-source-${$En()}.tar.gz`),d=jbo(),m=km(Hbo(),"auth.json");if(!cAe(m))throw new Error(`Missing Pi auth file: ${m}`);let S,v,A,x,w=!1,L=()=>{S&&(w=!0,l.ecs.send(new yo.StopTaskCommand({cluster:v,task:S,reason:"shipd checks cancelled"})).catch(()=>{}))};e.cancelSignal.addEventListener("abort",L,{once:!0});let M={source:`runs/${e.runId}/source.tar.gz`,worker:`runs/${e.runId}/${qbo}`,auth:`runs/${e.runId}/auth.json`,bootstrap:`runs/${e.runId}/bootstrap.json`,result:`runs/${e.runId}/result.json`};try{let G=await Kbo(l,i,c);A=G.bucket,v=G.cluster,await zbo(e.pi,e.snapshotDir,p,e.cancelSignal),await Oee(l.s3,G.bucket,M.source,p,"application/gzip"),await Oee(l.s3,G.bucket,M.worker,d,"text/javascript"),await Oee(l.s3,G.bucket,M.auth,m,"application/json"),x=km(kEn(),`.shipd-fargate-bootstrap-${$En()}.json`);let K=await Qbo(l.ecs,s,u.cpu,u.memoryMiB,c,i),re=Math.max(1,Math.floor(e.solverConfig.solverCount)),Se=!!i.taskRoleArn,Fe=Math.min(3,Math.max(0,Math.floor(i.maxRetries??1))),Ae="Fargate task did not produce a result.";e.onPhase?.("requesting sandbox");let ye=[];for(let at=0;at<=Fe;at+=1){if(e.cancelSignal.aborted)throw new Error("Cancelled by user.");e.onPhase?.("requesting sandbox");let pe=await(0,QI.getSignedUrl)(l.s3,new hr.GetObjectCommand({Bucket:G.bucket,Key:M.worker}),{expiresIn:EC}),Ct=Se?void 0:await(0,QI.getSignedUrl)(l.s3,new hr.GetObjectCommand({Bucket:G.bucket,Key:M.source}),{expiresIn:EC}),Le=Se?void 0:await(0,QI.getSignedUrl)(l.s3,new hr.GetObjectCommand({Bucket:G.bucket,Key:M.auth}),{expiresIn:EC}),O=Se?void 0:await(0,QI.getSignedUrl)(l.s3,new hr.PutObjectCommand({Bucket:G.bucket,Key:M.result,ContentType:"application/json"}),{expiresIn:EC}),F=Se?void 0:await(0,QI.getSignedUrl)(l.s3,new hr.GetObjectCommand({Bucket:G.bucket,Key:M.result}),{expiresIn:EC});Nee(x,`${JSON.stringify({workerUrl:pe,sourceUrl:Ct,authUrl:Le,resultPutUrl:O,resultGetUrl:F,...Se?{bucket:G.bucket,region:c,sourceKey:M.source,authKey:M.auth,resultKey:M.result}:{},planB64:Buffer.from(JSON.stringify(s),"utf-8").toString("base64url"),provider:e.solverConfig.provider,modelId:e.solverConfig.modelId,thinkingLevel:e.solverConfig.thinkingLevel,timeoutMinutes:e.solverConfig.timeoutMinutes,solverCount:re,resourceProfile:u.profile})}
@@ -399,4 +399,4 @@ Keep changes separated when possible:\r
399
399
  Evidence: ${s.evidence}
400
400
  Required behavior: ${s.requiredBehavior}
401
401
  Recommendation: ${s.recommendation}`)].join(`
402
- `)}var XEn="analyze_test_gaps",jee=!1,YEn=!1,ZI=!1;function pAe(e){return e.getActiveTools().map(s=>typeof s=="string"?s:s.name)}function dAe(){return jee}function zee(e){let t=pAe(e);return t.includes(XEn)||dAe()!==t.includes(mL)}function Rxo(e){YEn||(ZEn(e),YEn=!0)}function Sxo(e,t){let s=pAe(e);if(t&&s.length===0){ZI=!0;return}let i=s.filter(u=>u!==XEn),c=t?[...new Set([...i,mL])]:i.filter(u=>u!==mL);(c.length!==s.length||c.some((u,p)=>u!==s[p]))&&e.setActiveTools(c),ZI=zee(e)}function xC(e){let t=dAe();t&&Rxo(e),Sxo(e,t)}function mAe(e,t){jee=_L(t),ZI=!0,JEn(e)}function JEn(e,t=0){let s=dAe(),i=pAe(e);if(s&&i.length===0&&t<8){queueMicrotask(()=>JEn(e,t+1));return}xC(e)}function ebn(e){for(let t of[0,50,150,400])setTimeout(()=>{(ZI||zee(e))&&xC(e)},t)}function tbn(){return ZI}function fAe(e,t,s){jee=s,hL(t,s),ZI=!0,xC(e)}function nbn(e,t){jee=_L(t),ZI=!0,xC(e)}var Exo="Ctrl+Shift+X",abn=[{value:"--config",label:"--config",description:"Configure reviewer, gap-finder, and test-audit models"},{value:"--solver-gap-finder",label:"--solver-gap-finder",description:"Use TDD solver attempts to find behavioral gaps"}],bxo=["config","solver-gap-finder"];function xxo(e){let t=e.trimStart(),s=/\s$/.test(t),i=t.trimEnd().split(/\s+/).filter(Boolean),c=s?"":i.at(-1)??"",l=new Set(s?i:i.slice(0,-1)),u=s?t:t.slice(0,t.length-c.length),p=l.has("--config"),d=[...l].some(S=>S!=="--config"),m=abn.filter(S=>!l.has(S.value)&&!p&&!(d&&S.value==="--config")&&S.value.startsWith(c));return m.length?m.map(S=>({...S,value:`${u}${S.value}`})):null}async function Kee(e,t,s){let i=wAe();if(i.length===0)return e.ui.notify("No enabledModels configured in settings.json.","error"),null;let c=e.modelRegistry.getAll(),l=i.map(m=>{let S=kAe(m);if(!S)return null;let v=c.find(w=>w.provider===S.provider&&w.id===S.modelId),A=t?.provider===S.provider&&t?.modelId===S.modelId,x=v?`${v.name} (${m})`:m;return{ref:m,parsed:S,display:A?`${x} [current]`:x,isCurrent:A}}).filter(m=>m!==null);if(l.length===0)return e.ui.notify("Could not resolve any enabledModels entries.","error"),null;let u=[...l].sort((m,S)=>m.isCurrent===S.isCurrent?0:m.isCurrent?-1:1),p=await e.ui.select(s,u.map(m=>m.display));if(!p)return null;let d=l.find(m=>m.display===p);return d?{provider:d.parsed.provider,modelId:d.parsed.modelId}:null}function jg(e,t,s){let i=e.modelRegistry.getAll().find(c=>c.provider===t&&c.id===s);return EAe(i)}var Wee={provider:"",modelId:"",thinkingLevel:"off",timeoutMinutes:Zee,solverCount:Xee,saveArtifacts:Jee},Qee={provider:"",modelId:"",thinkingLevel:"off"};function obn(e,t,s,i){let c=t?jg(e,t.provider,t.modelId):["off"],l=s.provider?jg(e,s.provider,s.modelId):["off"],u=i.provider?jg(e,i.provider,i.modelId):["off"],p=i.testAuditProvider??i.provider,d=i.testAuditModelId??i.modelId,m=p?jg(e,p,d):["off"];return[{id:"reviewer-model",section:"Solver",label:"Comparison model",value:t?`${t.provider}/${t.modelId}`:"not set",kind:"model"},{id:"reviewer-thinking",section:"Solver",label:"Comparison thinking",value:t?.thinkingLevel??"off",kind:"cycle",values:c},{id:"solvergap-model",section:"Solver",label:"Model",value:s.provider?`${s.provider}/${s.modelId}`:"not set",kind:"model"},{id:"solvergap-thinking",section:"Solver",label:"Thinking level",value:s.thinkingLevel,kind:"cycle",values:l},{id:"solvergap-timeout",section:"Solver",label:"Timeout",value:`${s.timeoutMinutes} min`,kind:"cycle",values:[10,20,30,40,50,TAe].filter((S,v,A)=>S>=CAe&&A.indexOf(S)===v).map(S=>`${S} min`)},{id:"solvergap-solver-count",section:"Solver",label:"Parallel agents",value:String(s.solverCount),kind:"cycle",values:Array.from({length:AAe-Yee+1},(S,v)=>`${Yee+v}`)},{id:"solvergap-save-artifacts",section:"Solver",label:"Save artifacts",value:s.saveArtifacts?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-enabled",section:"Analyze Tool",label:"Enabled here",value:vL(e.cwd)?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-gap-model",section:"Analyze Tool",label:"Gap finder model",value:i.provider?`${i.provider}/${i.modelId}`:"not set",kind:"model"},{id:"analyze-gap-thinking",section:"Analyze Tool",label:"Gap finder thinking",value:i.thinkingLevel,kind:"cycle",values:u},{id:"analyze-audit-model",section:"Analyze Tool",label:"Test-audit model",value:p?`${p}/${d}`:"not set",kind:"model"},{id:"analyze-audit-thinking",section:"Analyze Tool",label:"Test-audit thinking",value:i.testAuditThinkingLevel??i.thinkingLevel,kind:"cycle",values:m}]}var gAe=class{constructor(t,s,i,c,l,u){this.ctx=t;this.settingsListTheme=s;this.theme=i;this.onCycleSaved=c;this.onActivateModel=l;this.onExit=u;this.rows=obn(t,ba(),ba()?.solverGap??Wee,ba()?.analyzeGap??Qee)}selectedIndex=0;rows;refresh(){let t=ba();this.rows=obn(this.ctx,t,t?.solverGap??Wee,t?.analyzeGap??Qee),this.selectedIndex=Math.min(this.selectedIndex,this.rows.length-1)}invalidate(){}render(t){let s=[],i=Math.min(30,Math.max(...this.rows.map(l=>l.label.length))),c;for(let l=0;l<this.rows.length;l++){let u=this.rows[l];if(!u)continue;u.section!==c&&(c!==void 0&&s.push(""),s.push(this.theme.bold(this.theme.fg("accent",u.section))),c=u.section);let p=l===this.selectedIndex,d=p?this.settingsListTheme.cursor:" ",m=u.label+" ".repeat(Math.max(0,i-u.label.length)),S=this.settingsListTheme.label(m,p),v=this.settingsListTheme.value(u.value,p);s.push(`${d}${S} ${v}`)}return s}handleInput(t){if(JI(t,XI.ctrl("s"))||JI(t,XI.escape)||JI(t,XI.ctrl("c"))){this.onExit();return}if(JI(t,XI.up)){this.selectedIndex=this.selectedIndex===0?this.rows.length-1:this.selectedIndex-1;return}if(JI(t,XI.down)){this.selectedIndex=this.selectedIndex===this.rows.length-1?0:this.selectedIndex+1;return}if(JI(t,XI.enter)||JI(t,XI.return)||t===" "){let s=this.rows[this.selectedIndex];if(!s)return;if(s.kind==="model"){this.onActivateModel(s.id);return}if(!s.values||s.values.length===0)return;let i=ba();if(!i){this.ctx.ui.notify("Set the comparison model first \u2014 it's required before solver settings","warning");return}let c=i.solverGap??Wee,l=i.analyzeGap??Qee,u=s.values.indexOf(s.value),p=s.values[(u+1)%s.values.length];if(p===void 0)return;s.id==="reviewer-thinking"?Ya({...i,thinkingLevel:p,solverGap:c,analyzeGap:l}):s.id==="solvergap-thinking"?Ya({...i,solverGap:{...c,thinkingLevel:p}}):s.id==="solvergap-timeout"?Ya({...i,solverGap:{...c,timeoutMinutes:Number.parseInt(p,10)}}):s.id==="solvergap-solver-count"?Ya({...i,solverGap:{...c,solverCount:Number.parseInt(p,10)}}):s.id==="solvergap-save-artifacts"?Ya({...i,solverGap:{...c,saveArtifacts:p==="on"}}):s.id==="analyze-enabled"?hL(this.ctx.cwd,p==="on"):s.id==="analyze-gap-thinking"?Ya({...i,analyzeGap:{...l,thinkingLevel:p}}):s.id==="analyze-audit-thinking"&&Ya({...i,analyzeGap:{...l,testAuditThinkingLevel:p}}),this.refresh(),this.onCycleSaved()}}};async function Pxo(e,t){if(t.mode!=="tui"){t.ui.notify("/checks --config requires interactive mode","error");return}let s=0;for(;;){let i=await t.ui.custom((p,d,m,S)=>{let v=new gAe(t,Txo(),d,()=>{nbn(e,t.cwd),p.requestRender()},x=>S(x),()=>S(void 0));v.selectedIndex=s;let A=new Axo;return A.addChild(new rbn(d.bold(d.fg("accent","Checks settings")))),A.addChild({render:x=>v.render(x),invalidate:()=>v.invalidate()}),A.addChild(new Dxo(1)),A.addChild(new rbn(d.fg("dim","\u2191\u2193 navigate enter select ctrl+s save & exit esc cancel"))),{render(x){return A.render(x)},invalidate(){A.invalidate()},handleInput(x){v.handleInput(x),s=v.selectedIndex,p.requestRender()}}});if(!i)return;let c=ba(),l=c?.solverGap??Wee,u=c?.analyzeGap??Qee;if(i==="reviewer-model"){let p=await Kee(t,c,"Select comparison model");if(!p)continue;let d=jg(t,p.provider,p.modelId),m=d.includes(c?.thinkingLevel??"off")?c?.thinkingLevel??"off":d[0]??"off";Ya({...p,thinkingLevel:m,solverGap:l,analyzeGap:u,enabledProjects:c?.enabledProjects??tte(),enableAnalyzeTool:c?.enableAnalyzeTool}),t.ui.notify(`Comparison model saved: ${p.provider}/${p.modelId}`,"info");continue}if(i==="solvergap-model"){if(!c){t.ui.notify("Set the comparison model first \u2014 it's required before solver settings.","warning");continue}let p=await Kee(t,l.provider?l:null,"Select solver model");if(!p)continue;let d=jg(t,p.provider,p.modelId),m=d.includes(l.thinkingLevel)?l.thinkingLevel:d[0]??"off";Ya({...c,solverGap:{...l,...p,thinkingLevel:m}}),t.ui.notify(`Solver model saved: ${p.provider}/${p.modelId}`,"info");continue}if(i==="analyze-gap-model"){if(!c){t.ui.notify("Set the comparison model first \u2014 it's required before analyze-tool settings.","warning");continue}let p=await Kee(t,u.provider?u:null,"Select gap-finder model");if(!p)continue;let d=jg(t,p.provider,p.modelId),m=d.includes(u.thinkingLevel)?u.thinkingLevel:d[0]??"off";Ya({...c,analyzeGap:{...u,...p,thinkingLevel:m}}),t.ui.notify(`Gap-finder model saved: ${p.provider}/${p.modelId}`,"info");continue}if(i==="analyze-audit-model"){if(!c){t.ui.notify("Set the comparison model first \u2014 it's required before analyze-tool settings.","warning");continue}let p=u.testAuditProvider?{provider:u.testAuditProvider,modelId:u.testAuditModelId??u.modelId}:u.provider?{provider:u.provider,modelId:u.modelId}:null,d=await Kee(t,p,"Select test-audit model");if(!d)continue;let m=u.testAuditThinkingLevel??u.thinkingLevel,S=jg(t,d.provider,d.modelId),v=S.includes(m)?m:S[0]??"off";Ya({...c,analyzeGap:{...u,testAuditProvider:d.provider,testAuditModelId:d.modelId,testAuditThinkingLevel:v}}),t.ui.notify(`Test-audit model saved: ${d.provider}/${d.modelId}`,"info")}}}function ibn(e){e.registerCommand("checks",{description:"Configure checks or run the solver-based behavioral gap finder.",getArgumentCompletions:xxo,handler:async(t,s)=>{let i=t.trim();if(!i){let ye=await s.ui.select("Choose a checks action",[...bxo]);if(!ye)return;i=`--${ye}`}let c=[...new Set(i.split(/\s+/).filter(Boolean))],l=new Set(abn.map(ye=>ye.value)),u=c.filter(ye=>!l.has(ye));if(u.length){s.ui.notify(`Unknown option(s): ${u.join(", ")}. Run /checks with no arguments to see options.`,"warning");return}if(c.includes("--config")){c.length>1?s.ui.notify("--config cannot be combined with other options.","warning"):await Pxo(e,s);return}let p=c.includes("--solver-gap-finder");if(!p)return;if(Uee()){s.ui.notify("A checks run is already in progress.","warning");return}let d=ba();if(!d){s.ui.notify("No gap-finder model configured. Run /checks --config first.","error");return}let m=s.modelRegistry.find(d.provider,d.modelId);if(!m||!s.modelRegistry.hasConfiguredAuth(m)){s.ui.notify("Configured behavioral gap-finder model is unavailable or unauthenticated. Run /checks --config.","error");return}let S=lAe.filter(ye=>!sbn(YI(s.cwd,ye)));if(S.length){s.ui.notify(`Missing required file(s): ${S.join(", ")}`,"error");return}let v=null,A;if(p){if(v=PAe(),!v||!sbn(YI(s.cwd,"test.sh"))){s.ui.notify("Configure solver gap finder and provide test.sh before running it.","error");return}if(A=s.modelRegistry.find(v.provider,v.modelId),!A||!s.modelRegistry.hasConfiguredAuth(A)){s.ui.notify("Configured solver gap-finder model is unavailable or unauthenticated.","error");return}}let x=zEn(),w=v?.solverCount??0,L=w+1,M=Date.now(),G=p?"preparing image":"preparing clean snapshot",K=0,re=!p,Se=(ye=G,$e=K,at=re)=>{G=ye,K=$e,re=at,s.ui.setWidget(dL,qEn(ye,$e,L,{showBar:at,startedAt:M}))},Fe=setInterval(()=>Se(),1e3);Se(),s.ui.notify(`checks (${c.join(" ")}) started. Press ${Exo} to cancel.`,"info");let Ae;try{let ye=YI(Cxo(),`checks-${Ixo()}`);_xo(ye,{recursive:!0}),Ae=ye;let $e=await rte(e,s.cwd,ye,x.signal);if($e.status==="error"){s.ui.notify(`checks: ${$e.error}`,"error");return}if(x.signal.aborted)return;for(let rl of lAe)yxo(YI(s.cwd,rl),YI(ye,rl));let at=qee(),pe=Fee(),Ct=0,Le=[],O,F={status:"ok",gaps:[]};if(p&&v){if(x.signal.aborted){s.ui.notify("checks: cancelled.","warning");return}let rl=new Map,dd=!1,ey=()=>Array.from({length:w},(_o,Lm)=>{let fL=rl.get(Lm+1);return fL?`${Lm+1}${fL.passed?"\u2713":"\u2717"}`:`${Lm+1}\u2026`}).join(" "),ol=_o=>{_o==="running agents"&&(dd=!0);let Lm=dd&&(_o==="running agents"||_o==="finalizing"),fL=_o==="running agents"?`${_o} (${ey()})`:_o,dbn=[...rl.values()];Se(fL,Ct+dbn.length,Lm)},lbn=_o=>{for(let Lm of _o)rl.set(Lm.index,Lm);ol("running agents")},ubn=_o=>{rl.set(_o.index,_o),ol("finalizing")};ol("preparing image");let pbn=uAe().replace(/[:.]/g,"-");if(Le=await VEn({pi:e,repoDir:s.cwd,snapshotDir:ye,config:d,solverConfig:v,cancelSignal:x.signal,runId:pbn,onSolverCompleted:ubn,onSolverProgress:lbn,onResourceUsage:_o=>{O=_o},onPhase:ol}),x.signal.aborted){s.ui.notify("checks: cancelled.","warning");return}if(Le.some(_o=>_o.status!=="patchFailed"&&_o.status!=="error")&&(ol("finalizing"),GAe(ye,Le),F=await yke({tempDir:ye,model:m,thinkingLevel:d.thinkingLevel,solverResults:Le,testRubric:at,fairnessRules:pe,cancelSignal:x.signal})),Ct+=1,ol("finalizing"),O&&Ya(xAe(d,s.cwd,O)),x.signal.aborted){s.ui.notify("checks: cancelled.","warning");return}}let Me=BEn({existingReport:FEn(YI(s.cwd,"shipd_report.json")),config:d,runGapFinder:!1,testGaps:[],gapAnalysisIncomplete:!1,gapFinderStatus:"ok",gapFilterStatus:"ok",runSolverGapFinder:p,solverResults:Le,fargateResourceUsage:O,solverGaps:F.gaps,solverGapAnalysisIncomplete:p&&(Le.some(rl=>rl.status==="error")||F.status!=="ok"),solverComparisonStatus:F.status}),Xo=HEn({merged:Me,runGapFinder:!1,runSolverGapFinder:p});e.sendMessage({customType:"shipd_checks_report",content:Xo.content,display:!0,details:Xo.details});let PC=YI(s.cwd,"shipd_report.json");vxo(PC,JSON.stringify(Me,null,2),"utf-8"),s.ui.notify(`checks: wrote details to ${PC}`,"info")}catch(ye){s.ui.notify(`checks failed: ${ye instanceof Error?ye.message:String(ye)}`,"error")}finally{clearInterval(Fe),s.ui.setWidget(dL,void 0),Ae&&hxo(Ae,{recursive:!0,force:!0}),KEn()}}})}var cbn=wxo.ctrlShift("x");function Lxo(e){e.registerCommand("analyze:on",{description:"Enable the test-analysis tool for this project folder",handler:async(t,s)=>{fAe(e,s.cwd,!0),s.ui.notify("Test-analysis tool ON in this project","info")}}),e.registerCommand("analyze:off",{description:"Disable the test-analysis tool for this project folder",handler:async(t,s)=>{fAe(e,s.cwd,!1),s.ui.notify("Test-analysis tool OFF in this project","info")}}),e.registerMessageRenderer("shipd_checks_report",(t,s,i)=>{let c=t.details??{},l=new $xo;l.addChild(new RAe(i.bold(i.fg("accent","Checks")),0,0));let u=!1,p=d=>{l.addChild(new RAe(d,0,0)),u=!0};if(c.showGaps){let d=c.gapsCount??0;p(d>0?i.fg("warning",` \u26A0 ${d} test gap(s) found`):i.fg("success"," \u2713 no test gaps found"))}if(c.showSolverGaps){let d=c.solverDetails??[],m=d.filter(x=>x.passed).length,S=c.solverGapsCount??0;l.addChild(new kxo(1)),p(i.bold(i.fg("accent","Solver gap finder")));for(let x of d){let w=x.passed?i.fg("success","\u2713"):i.fg("error","\u2717"),L=x.passed?"passed":x.status==="ok"?"failed tests":x.status;p(` ${w} Solver ${x.index}: ${L} (${UEn(x.durationMs)})`)}let v=m===d.length&&d.length>0?i.fg("success",`${m}/${d.length} solvers passed`):i.fg("warning",`${m}/${d.length} solvers passed`),A=S>0?i.fg("warning",`${S} behavioral gap(s) found`):i.fg("success","no behavioral gaps found");p(` ${v}, ${A}`)}return u||l.addChild(new RAe(i.fg("dim"," nothing to report"),0,0)),l}),e.registerShortcut(cbn,{description:"Cancel an in-progress /checks run",handler:t=>{Uee()&&WEn()&&(t.ui.setWidget(dL,[`checks: cancelling (${cbn})...`]),t.ui.notify("checks: cancelling...","warning"))}}),Mxo(e),ibn(e)}function Mxo(e){e.on("session_start",(t,s)=>{mAe(e,s.cwd),(t.reason==="resume"||t.reason==="reload"||t.reason==="startup")&&ebn(e)}),e.on("session_tree",async(t,s)=>{mAe(e,s.cwd)}),e.on("before_agent_start",()=>{!tbn()&&!zee(e)||xC(e)})}export{Lxo as default};
402
+ `)}var XEn="analyze_test_gaps",jee=!1,YEn=!1,ZI=!1;function pAe(e){return e.getActiveTools().map(s=>typeof s=="string"?s:s.name)}function dAe(){return jee}function zee(e){let t=pAe(e);return t.includes(XEn)||dAe()!==t.includes(mL)}function Rxo(e){YEn||(ZEn(e),YEn=!0)}function Sxo(e,t){let s=pAe(e);if(t&&s.length===0){ZI=!0;return}let i=s.filter(u=>u!==XEn),c=t?[...new Set([...i,mL])]:i.filter(u=>u!==mL);(c.length!==s.length||c.some((u,p)=>u!==s[p]))&&e.setActiveTools(c),ZI=zee(e)}function xC(e){let t=dAe();t&&Rxo(e),Sxo(e,t)}function mAe(e,t){jee=_L(t),ZI=!0,JEn(e)}function JEn(e,t=0){let s=dAe(),i=pAe(e);if(s&&i.length===0&&t<8){queueMicrotask(()=>JEn(e,t+1));return}xC(e)}function ebn(e){for(let t of[0,50,150,400])setTimeout(()=>{(ZI||zee(e))&&xC(e)},t)}function tbn(){return ZI}function fAe(e,t,s){jee=s,hL(t,s),ZI=!0,xC(e)}function nbn(e,t){jee=_L(t),ZI=!0,xC(e)}var Exo="Ctrl+Shift+X",abn=[{value:"--config",label:"--config",description:"Configure reviewer, gap-finder, and test-audit models"},{value:"--solver-gap-finder",label:"--solver-gap-finder",description:"Use TDD solver attempts to find behavioral gaps"}],bxo=["config","solver-gap-finder"];function xxo(e){let t=e.trimStart(),s=/\s$/.test(t),i=t.trimEnd().split(/\s+/).filter(Boolean),c=s?"":i.at(-1)??"",l=new Set(s?i:i.slice(0,-1)),u=s?t:t.slice(0,t.length-c.length),p=l.has("--config"),d=[...l].some(S=>S!=="--config"),m=abn.filter(S=>!l.has(S.value)&&!p&&!(d&&S.value==="--config")&&S.value.startsWith(c));return m.length?m.map(S=>({...S,value:`${u}${S.value}`})):null}async function Kee(e,t,s){let i=wAe();if(i.length===0)return e.ui.notify("No enabledModels configured in settings.json.","error"),null;let c=e.modelRegistry.getAll(),l=i.map(m=>{let S=kAe(m);if(!S)return null;let v=c.find(w=>w.provider===S.provider&&w.id===S.modelId),A=t?.provider===S.provider&&t?.modelId===S.modelId,x=v?`${v.name} (${m})`:m;return{ref:m,parsed:S,display:A?`${x} [current]`:x,isCurrent:A}}).filter(m=>m!==null);if(l.length===0)return e.ui.notify("Could not resolve any enabledModels entries.","error"),null;let u=[...l].sort((m,S)=>m.isCurrent===S.isCurrent?0:m.isCurrent?-1:1),p=await e.ui.select(s,u.map(m=>m.display));if(!p)return null;let d=l.find(m=>m.display===p);return d?{provider:d.parsed.provider,modelId:d.parsed.modelId}:null}function jg(e,t,s){let i=e.modelRegistry.getAll().find(c=>c.provider===t&&c.id===s);return EAe(i)}var Wee={provider:"",modelId:"",thinkingLevel:"off",timeoutMinutes:Zee,solverCount:Xee,saveArtifacts:Jee},Qee={provider:"",modelId:"",thinkingLevel:"off"};function obn(e,t,s,i){let c=t?jg(e,t.provider,t.modelId):["off"],l=s.provider?jg(e,s.provider,s.modelId):["off"],u=i.provider?jg(e,i.provider,i.modelId):["off"],p=i.testAuditProvider??i.provider,d=i.testAuditModelId??i.modelId,m=p?jg(e,p,d):["off"];return[{id:"solver-model",section:"Solver",label:"Solver model",value:s.provider?`${s.provider}/${s.modelId}`:"not set",kind:"model"},{id:"solver-thinking",section:"Solver",label:"Solver thinking",value:s.thinkingLevel,kind:"cycle",values:l},{id:"solvergap-timeout",section:"Solver",label:"Timeout",value:`${s.timeoutMinutes} min`,kind:"cycle",values:[10,20,30,40,50,TAe].filter((S,v,A)=>S>=CAe&&A.indexOf(S)===v).map(S=>`${S} min`)},{id:"solvergap-solver-count",section:"Solver",label:"Parallel agents",value:String(s.solverCount),kind:"cycle",values:Array.from({length:AAe-Yee+1},(S,v)=>`${Yee+v}`)},{id:"solvergap-save-artifacts",section:"Solver",label:"Save artifacts",value:s.saveArtifacts?"on":"off",kind:"cycle",values:["on","off"]},{id:"reviewer-model",section:"Solver",label:"Reviewer model",value:t?`${t.provider}/${t.modelId}`:"not set",kind:"model"},{id:"reviewer-thinking",section:"Solver",label:"Reviewer thinking",value:t?.thinkingLevel??"off",kind:"cycle",values:c},{id:"analyze-enabled",section:"Analyze Tool",label:"Enabled here",value:vL(e.cwd)?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-gap-model",section:"Analyze Tool",label:"Gap finder model",value:i.provider?`${i.provider}/${i.modelId}`:"not set",kind:"model"},{id:"analyze-gap-thinking",section:"Analyze Tool",label:"Gap finder thinking",value:i.thinkingLevel,kind:"cycle",values:u},{id:"analyze-audit-model",section:"Analyze Tool",label:"Test-audit model",value:p?`${p}/${d}`:"not set",kind:"model"},{id:"analyze-audit-thinking",section:"Analyze Tool",label:"Test-audit thinking",value:i.testAuditThinkingLevel??i.thinkingLevel,kind:"cycle",values:m}]}var gAe=class{constructor(t,s,i,c,l,u){this.ctx=t;this.settingsListTheme=s;this.theme=i;this.onCycleSaved=c;this.onActivateModel=l;this.onExit=u;this.rows=obn(t,ba(),ba()?.solverGap??Wee,ba()?.analyzeGap??Qee)}selectedIndex=0;rows;refresh(){let t=ba();this.rows=obn(this.ctx,t,t?.solverGap??Wee,t?.analyzeGap??Qee),this.selectedIndex=Math.min(this.selectedIndex,this.rows.length-1)}invalidate(){}render(t){let s=[],i=Math.min(30,Math.max(...this.rows.map(l=>l.label.length))),c;for(let l=0;l<this.rows.length;l++){let u=this.rows[l];if(!u)continue;u.section!==c&&(c!==void 0&&s.push(""),s.push(this.theme.bold(this.theme.fg("accent",u.section))),c=u.section);let p=l===this.selectedIndex,d=p?this.settingsListTheme.cursor:" ",m=u.label+" ".repeat(Math.max(0,i-u.label.length)),S=this.settingsListTheme.label(m,p),v=this.settingsListTheme.value(u.value,p);s.push(`${d}${S} ${v}`)}return s}handleInput(t){if(JI(t,XI.ctrl("s"))||JI(t,XI.escape)||JI(t,XI.ctrl("c"))){this.onExit();return}if(JI(t,XI.up)){this.selectedIndex=this.selectedIndex===0?this.rows.length-1:this.selectedIndex-1;return}if(JI(t,XI.down)){this.selectedIndex=this.selectedIndex===this.rows.length-1?0:this.selectedIndex+1;return}if(JI(t,XI.enter)||JI(t,XI.return)||t===" "){let s=this.rows[this.selectedIndex];if(!s)return;if(s.kind==="model"){this.onActivateModel(s.id);return}if(!s.values||s.values.length===0)return;let i=ba();if(!i){this.ctx.ui.notify("Set the reviewer model first \u2014 it's required before solver settings","warning");return}let c=i.solverGap??Wee,l=i.analyzeGap??Qee,u=s.values.indexOf(s.value),p=s.values[(u+1)%s.values.length];if(p===void 0)return;s.id==="reviewer-thinking"?Ya({...i,thinkingLevel:p,solverGap:c,analyzeGap:l}):s.id==="solver-thinking"?Ya({...i,solverGap:{...c,thinkingLevel:p}}):s.id==="solvergap-timeout"?Ya({...i,solverGap:{...c,timeoutMinutes:Number.parseInt(p,10)}}):s.id==="solvergap-solver-count"?Ya({...i,solverGap:{...c,solverCount:Number.parseInt(p,10)}}):s.id==="solvergap-save-artifacts"?Ya({...i,solverGap:{...c,saveArtifacts:p==="on"}}):s.id==="analyze-enabled"?hL(this.ctx.cwd,p==="on"):s.id==="analyze-gap-thinking"?Ya({...i,analyzeGap:{...l,thinkingLevel:p}}):s.id==="analyze-audit-thinking"&&Ya({...i,analyzeGap:{...l,testAuditThinkingLevel:p}}),this.refresh(),this.onCycleSaved()}}};async function Pxo(e,t){if(t.mode!=="tui"){t.ui.notify("/checks --config requires interactive mode","error");return}let s=0;for(;;){let i=await t.ui.custom((p,d,m,S)=>{let v=new gAe(t,Txo(),d,()=>{nbn(e,t.cwd),p.requestRender()},x=>S(x),()=>S(void 0));v.selectedIndex=s;let A=new Axo;return A.addChild(new rbn(d.bold(d.fg("accent","Checks settings")))),A.addChild({render:x=>v.render(x),invalidate:()=>v.invalidate()}),A.addChild(new Dxo(1)),A.addChild(new rbn(d.fg("dim","\u2191\u2193 navigate enter select ctrl+s save & exit esc cancel"))),{render(x){return A.render(x)},invalidate(){A.invalidate()},handleInput(x){v.handleInput(x),s=v.selectedIndex,p.requestRender()}}});if(!i)return;let c=ba(),l=c?.solverGap??Wee,u=c?.analyzeGap??Qee;if(i==="reviewer-model"){let p=await Kee(t,c,"Select reviewer model");if(!p)continue;let d=jg(t,p.provider,p.modelId),m=d.includes(c?.thinkingLevel??"off")?c?.thinkingLevel??"off":d[0]??"off";Ya({...p,thinkingLevel:m,solverGap:l,analyzeGap:u,enabledProjects:c?.enabledProjects??tte(),enableAnalyzeTool:c?.enableAnalyzeTool}),t.ui.notify(`Reviewer model saved: ${p.provider}/${p.modelId}`,"info");continue}if(i==="solver-model"){if(!c){t.ui.notify("Set the reviewer model first \u2014 it's required before solver settings.","warning");continue}let p=await Kee(t,l.provider?l:null,"Select solver model");if(!p)continue;let d=jg(t,p.provider,p.modelId),m=d.includes(l.thinkingLevel)?l.thinkingLevel:d[0]??"off";Ya({...c,solverGap:{...l,...p,thinkingLevel:m}}),t.ui.notify(`Solver model saved: ${p.provider}/${p.modelId}`,"info");continue}if(i==="analyze-gap-model"){if(!c){t.ui.notify("Set the reviewer model first \u2014 it's required before analyze-tool settings.","warning");continue}let p=await Kee(t,u.provider?u:null,"Select gap-finder model");if(!p)continue;let d=jg(t,p.provider,p.modelId),m=d.includes(u.thinkingLevel)?u.thinkingLevel:d[0]??"off";Ya({...c,analyzeGap:{...u,...p,thinkingLevel:m}}),t.ui.notify(`Gap-finder model saved: ${p.provider}/${p.modelId}`,"info");continue}if(i==="analyze-audit-model"){if(!c){t.ui.notify("Set the reviewer model first \u2014 it's required before analyze-tool settings.","warning");continue}let p=u.testAuditProvider?{provider:u.testAuditProvider,modelId:u.testAuditModelId??u.modelId}:u.provider?{provider:u.provider,modelId:u.modelId}:null,d=await Kee(t,p,"Select test-audit model");if(!d)continue;let m=u.testAuditThinkingLevel??u.thinkingLevel,S=jg(t,d.provider,d.modelId),v=S.includes(m)?m:S[0]??"off";Ya({...c,analyzeGap:{...u,testAuditProvider:d.provider,testAuditModelId:d.modelId,testAuditThinkingLevel:v}}),t.ui.notify(`Test-audit model saved: ${d.provider}/${d.modelId}`,"info")}}}function ibn(e){e.registerCommand("checks",{description:"Configure checks or run the solver-based behavioral gap finder.",getArgumentCompletions:xxo,handler:async(t,s)=>{let i=t.trim();if(!i){let ye=await s.ui.select("Choose a checks action",[...bxo]);if(!ye)return;i=`--${ye}`}let c=[...new Set(i.split(/\s+/).filter(Boolean))],l=new Set(abn.map(ye=>ye.value)),u=c.filter(ye=>!l.has(ye));if(u.length){s.ui.notify(`Unknown option(s): ${u.join(", ")}. Run /checks with no arguments to see options.`,"warning");return}if(c.includes("--config")){c.length>1?s.ui.notify("--config cannot be combined with other options.","warning"):await Pxo(e,s);return}let p=c.includes("--solver-gap-finder");if(!p)return;if(Uee()){s.ui.notify("A checks run is already in progress.","warning");return}let d=ba();if(!d){s.ui.notify("No gap-finder model configured. Run /checks --config first.","error");return}let m=s.modelRegistry.find(d.provider,d.modelId);if(!m||!s.modelRegistry.hasConfiguredAuth(m)){s.ui.notify("Configured behavioral gap-finder model is unavailable or unauthenticated. Run /checks --config.","error");return}let S=lAe.filter(ye=>!sbn(YI(s.cwd,ye)));if(S.length){s.ui.notify(`Missing required file(s): ${S.join(", ")}`,"error");return}let v=null,A;if(p){if(v=PAe(),!v||!sbn(YI(s.cwd,"test.sh"))){s.ui.notify("Configure solver gap finder and provide test.sh before running it.","error");return}if(A=s.modelRegistry.find(v.provider,v.modelId),!A||!s.modelRegistry.hasConfiguredAuth(A)){s.ui.notify("Configured solver gap-finder model is unavailable or unauthenticated.","error");return}}let x=zEn(),w=v?.solverCount??0,L=w+1,M=Date.now(),G=p?"preparing image":"preparing clean snapshot",K=0,re=!p,Se=(ye=G,$e=K,at=re)=>{G=ye,K=$e,re=at,s.ui.setWidget(dL,qEn(ye,$e,L,{showBar:at,startedAt:M}))},Fe=setInterval(()=>Se(),1e3);Se(),s.ui.notify(`checks (${c.join(" ")}) started. Press ${Exo} to cancel.`,"info");let Ae;try{let ye=YI(Cxo(),`checks-${Ixo()}`);_xo(ye,{recursive:!0}),Ae=ye;let $e=await rte(e,s.cwd,ye,x.signal);if($e.status==="error"){s.ui.notify(`checks: ${$e.error}`,"error");return}if(x.signal.aborted)return;for(let rl of lAe)yxo(YI(s.cwd,rl),YI(ye,rl));let at=qee(),pe=Fee(),Ct=0,Le=[],O,F={status:"ok",gaps:[]};if(p&&v){if(x.signal.aborted){s.ui.notify("checks: cancelled.","warning");return}let rl=new Map,dd=!1,ey=()=>Array.from({length:w},(_o,Lm)=>{let fL=rl.get(Lm+1);return fL?`${Lm+1}${fL.passed?"\u2713":"\u2717"}`:`${Lm+1}\u2026`}).join(" "),ol=_o=>{_o==="running agents"&&(dd=!0);let Lm=dd&&(_o==="running agents"||_o==="finalizing"),fL=_o==="running agents"?`${_o} (${ey()})`:_o,dbn=[...rl.values()];Se(fL,Ct+dbn.length,Lm)},lbn=_o=>{for(let Lm of _o)rl.set(Lm.index,Lm);ol("running agents")},ubn=_o=>{rl.set(_o.index,_o),ol("finalizing")};ol("preparing image");let pbn=uAe().replace(/[:.]/g,"-");if(Le=await VEn({pi:e,repoDir:s.cwd,snapshotDir:ye,config:d,solverConfig:v,cancelSignal:x.signal,runId:pbn,onSolverCompleted:ubn,onSolverProgress:lbn,onResourceUsage:_o=>{O=_o},onPhase:ol}),x.signal.aborted){s.ui.notify("checks: cancelled.","warning");return}if(Le.some(_o=>_o.status!=="patchFailed"&&_o.status!=="error")&&(ol("finalizing"),GAe(ye,Le),F=await yke({tempDir:ye,model:m,thinkingLevel:d.thinkingLevel,solverResults:Le,testRubric:at,fairnessRules:pe,cancelSignal:x.signal})),Ct+=1,ol("finalizing"),O&&Ya(xAe(d,s.cwd,O)),x.signal.aborted){s.ui.notify("checks: cancelled.","warning");return}}let Me=BEn({existingReport:FEn(YI(s.cwd,"shipd_report.json")),config:d,runGapFinder:!1,testGaps:[],gapAnalysisIncomplete:!1,gapFinderStatus:"ok",gapFilterStatus:"ok",runSolverGapFinder:p,solverResults:Le,fargateResourceUsage:O,solverGaps:F.gaps,solverGapAnalysisIncomplete:p&&(Le.some(rl=>rl.status==="error")||F.status!=="ok"),solverComparisonStatus:F.status}),Xo=HEn({merged:Me,runGapFinder:!1,runSolverGapFinder:p});e.sendMessage({customType:"shipd_checks_report",content:Xo.content,display:!0,details:Xo.details});let PC=YI(s.cwd,"shipd_report.json");vxo(PC,JSON.stringify(Me,null,2),"utf-8"),s.ui.notify(`checks: wrote details to ${PC}`,"info")}catch(ye){s.ui.notify(`checks failed: ${ye instanceof Error?ye.message:String(ye)}`,"error")}finally{clearInterval(Fe),s.ui.setWidget(dL,void 0),Ae&&hxo(Ae,{recursive:!0,force:!0}),KEn()}}})}var cbn=wxo.ctrlShift("x");function Lxo(e){e.registerCommand("analyze:on",{description:"Enable the test-analysis tool for this project folder",handler:async(t,s)=>{fAe(e,s.cwd,!0),s.ui.notify("Test-analysis tool ON in this project","info")}}),e.registerCommand("analyze:off",{description:"Disable the test-analysis tool for this project folder",handler:async(t,s)=>{fAe(e,s.cwd,!1),s.ui.notify("Test-analysis tool OFF in this project","info")}}),e.registerMessageRenderer("shipd_checks_report",(t,s,i)=>{let c=t.details??{},l=new $xo;l.addChild(new RAe(i.bold(i.fg("accent","Checks")),0,0));let u=!1,p=d=>{l.addChild(new RAe(d,0,0)),u=!0};if(c.showGaps){let d=c.gapsCount??0;p(d>0?i.fg("warning",` \u26A0 ${d} test gap(s) found`):i.fg("success"," \u2713 no test gaps found"))}if(c.showSolverGaps){let d=c.solverDetails??[],m=d.filter(x=>x.passed).length,S=c.solverGapsCount??0;l.addChild(new kxo(1)),p(i.bold(i.fg("accent","Solver gap finder")));for(let x of d){let w=x.passed?i.fg("success","\u2713"):i.fg("error","\u2717"),L=x.passed?"passed":x.status==="ok"?"failed tests":x.status;p(` ${w} Solver ${x.index}: ${L} (${UEn(x.durationMs)})`)}let v=m===d.length&&d.length>0?i.fg("success",`${m}/${d.length} solvers passed`):i.fg("warning",`${m}/${d.length} solvers passed`),A=S>0?i.fg("warning",`${S} behavioral gap(s) found`):i.fg("success","no behavioral gaps found");p(` ${v}, ${A}`)}return u||l.addChild(new RAe(i.fg("dim"," nothing to report"),0,0)),l}),e.registerShortcut(cbn,{description:"Cancel an in-progress /checks run",handler:t=>{Uee()&&WEn()&&(t.ui.setWidget(dL,[`checks: cancelling (${cbn})...`]),t.ui.notify("checks: cancelling...","warning"))}}),Mxo(e),ibn(e)}function Mxo(e){e.on("session_start",(t,s)=>{mAe(e,s.cwd),(t.reason==="resume"||t.reason==="reload"||t.reason==="startup")&&ebn(e)}),e.on("session_tree",async(t,s)=>{mAe(e,s.cwd)}),e.on("before_agent_start",()=>{!tbn()&&!zee(e)||xC(e)})}export{Lxo as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sreetej510/pi-shipd-checks",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Pi extension that runs a strict, multi-agent fairness review of a benchmark task's agent_prompt.md, test.patch, and solution.patch, plus behavioral test-gap analysis, via /checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",