@counterfact-labs/cli 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +4 -5
  2. package/bundle/client-release.json +1 -1
  3. package/dist/adapters/analysis-results.js +10 -5
  4. package/dist/adapters/completion.js +75 -41
  5. package/dist/adapters/config-directory.js +5 -0
  6. package/dist/adapters/files.js +25 -10
  7. package/dist/adapters/legacy-reports.js +48 -0
  8. package/dist/adapters/output-paths.js +85 -5
  9. package/dist/adapters/result-receipt.js +78 -0
  10. package/dist/adapters/results.js +5 -8
  11. package/dist/adapters/settings.js +10 -4
  12. package/dist/adapters/storage-identity.js +27 -0
  13. package/dist/analysis-core/analysis/code-agents/skipped-files.js +1 -1
  14. package/dist/analysis-core/analysis/file-analysis-plan.js +1 -1
  15. package/dist/analysis-core/analysis/file-dependencies.js +1 -1
  16. package/dist/analysis-core/analysis/finding-quality/policy.js +1 -1
  17. package/dist/analysis-core/analysis/folder-analysis-plan.js +1 -1
  18. package/dist/analysis-core/analysis/passes/full-file-passes.js +1 -1
  19. package/dist/analysis-core/analysis/schemas.js +1 -1
  20. package/dist/analysis-core/chunks/{5VQ4VYIP.js → 2IQN26TC.js} +1 -1
  21. package/dist/analysis-core/chunks/{N2L4JMJE.js → 2J3PWUPG.js} +1 -1
  22. package/dist/analysis-core/chunks/{3GUKUEEJ.js → 5JG3ZRNJ.js} +1 -1
  23. package/dist/analysis-core/chunks/{LFJQ4YLP.js → 6E4K7JTI.js} +1 -1
  24. package/dist/analysis-core/chunks/{66JRJPJC.js → 6W6B7VSP.js} +1 -1
  25. package/dist/analysis-core/chunks/{P253B344.js → AIS3FHQR.js} +7 -7
  26. package/dist/analysis-core/chunks/{YWL52FVW.js → EJ2IZUN2.js} +2 -2
  27. package/dist/analysis-core/chunks/{5UWDUYHF.js → GOBOE2SC.js} +1 -1
  28. package/dist/analysis-core/chunks/GYXDN5W4.js +1 -0
  29. package/dist/analysis-core/chunks/GZSUTDGX.js +1 -0
  30. package/dist/analysis-core/chunks/HB5BTGTI.js +6 -0
  31. package/dist/analysis-core/chunks/HH3HDT5K.js +73 -0
  32. package/dist/analysis-core/chunks/{TA2NIQAY.js → I5F7S63K.js} +1 -1
  33. package/dist/analysis-core/chunks/ICJV6KIZ.js +11 -0
  34. package/dist/analysis-core/chunks/{2CWULBP2.js → JCVB6IC4.js} +1 -1
  35. package/dist/analysis-core/chunks/{DHVEGIU6.js → JLW44GIU.js} +1 -1
  36. package/dist/analysis-core/chunks/JS6HTVYX.js +1 -0
  37. package/dist/analysis-core/chunks/{UKX3A6AX.js → JWQXG5RB.js} +1 -1
  38. package/dist/analysis-core/chunks/LOODGUMW.js +1 -0
  39. package/dist/analysis-core/chunks/{XVGLY4EO.js → NWYNJHY4.js} +1 -1
  40. package/dist/analysis-core/chunks/{KBTM5MBC.js → OHDC3L6V.js} +1 -1
  41. package/dist/analysis-core/chunks/OXGKALKM.js +1 -0
  42. package/dist/analysis-core/chunks/{MJGB25S5.js → P5FCHJ7W.js} +1 -1
  43. package/dist/analysis-core/chunks/PISOGSJF.js +1 -0
  44. package/dist/analysis-core/chunks/{6VHZNBII.js → QENYFKG3.js} +8 -8
  45. package/dist/analysis-core/chunks/{W73WF226.js → QY57UR6E.js} +1 -1
  46. package/dist/analysis-core/chunks/QYYN4YKB.js +35 -0
  47. package/dist/analysis-core/chunks/UYG422QR.js +0 -0
  48. package/dist/analysis-core/chunks/V7GZHSVR.js +1 -0
  49. package/dist/analysis-core/chunks/{VWRFSVLI.js → VBGQKYIT.js} +1 -1
  50. package/dist/analysis-core/chunks/{5BTATES5.js → VVSHUUWX.js} +1 -1
  51. package/dist/analysis-core/chunks/{JKWTHRUR.js → YDSB7UOR.js} +1 -1
  52. package/dist/analysis-core/chunks/ZLUI3EHB.js +1 -0
  53. package/dist/analysis-core/contracts/execution-request.js +1 -1
  54. package/dist/analysis-core/contracts/model-errors.js +1 -0
  55. package/dist/analysis-core/contracts/relay-analysis.js +1 -1
  56. package/dist/analysis-core/contracts/requests.js +1 -1
  57. package/dist/analysis-core/conventions/analysis-fit.js +1 -1
  58. package/dist/analysis-core/conventions/file-admission.js +1 -1
  59. package/dist/analysis-core/errors.js +1 -1
  60. package/dist/analysis-core/import/calls/modules.js +1 -1
  61. package/dist/analysis-core/import/entry-selection.js +1 -1
  62. package/dist/analysis-core/import/outside-loader-sources.js +1 -1
  63. package/dist/analysis-core/index.js +1 -1
  64. package/dist/analysis-core/llm/cache-policy.js +1 -1
  65. package/dist/analysis-core/llm/cost.js +1 -1
  66. package/dist/analysis-core/llm/structured-output-error.js +1 -1
  67. package/dist/analysis-core/requests/frame-budget.js +1 -0
  68. package/dist/analysis-core/requests/local-plan.js +1 -1
  69. package/dist/analysis-core/requests/planned-limits.js +1 -1
  70. package/dist/analysis-core/requests/registry.js +1 -1
  71. package/dist/analysis-core/requests/template-version.js +1 -1
  72. package/dist/analysis-core/requests/tools.js +1 -1
  73. package/dist/analysis-core/settings.js +1 -1
  74. package/dist/analysis-core/stages/engine-entry.js +1 -1
  75. package/dist/analysis-core/wording.js +1 -0
  76. package/dist/cli/analysis-preview.js +22 -0
  77. package/dist/cli/analysis-selection.js +6 -8
  78. package/dist/cli/commands/analyze.js +27 -21
  79. package/dist/cli/commands/login.js +5 -0
  80. package/dist/cli/compatibility.js +39 -0
  81. package/dist/cli/completion-delivery.js +4 -3
  82. package/dist/cli/completion-recovery.js +25 -23
  83. package/dist/cli/credentials.js +3 -2
  84. package/dist/cli/finding-display.js +3 -2
  85. package/dist/cli/git.js +5 -2
  86. package/dist/cli/main.js +8 -2
  87. package/dist/cli/mcp.js +35 -10
  88. package/dist/cli/prior-completion.js +1 -1
  89. package/dist/cli/relay-check.js +85 -23
  90. package/dist/cli/relay-failure.js +19 -11
  91. package/dist/cli/relay-preparation.js +6 -3
  92. package/dist/cli/scope-choices.js +5 -4
  93. package/dist/cli/skipped-files.js +2 -1
  94. package/dist/cli/suggested-email.js +6 -1
  95. package/dist/cli/summary.js +2 -1
  96. package/dist/contract/agent-choice.js +2 -0
  97. package/dist/contract/cli-refusals.js +105 -9
  98. package/dist/contract/cli-version.js +1 -1
  99. package/dist/contract/console.js +2 -1
  100. package/dist/contract/email-sign-in-messages.js +2 -1
  101. package/dist/contract/scope-choice.js +4 -1
  102. package/dist/gatekeeper/client.js +11 -2
  103. package/dist/gatekeeper/connection-exchange.js +19 -4
  104. package/dist/gatekeeper/connection.js +15 -6
  105. package/dist/gatekeeper/console.js +8 -4
  106. package/dist/gatekeeper/model.js +13 -3
  107. package/package.json +1 -1
  108. package/dist/adapters/gitignore-output.js +0 -41
  109. package/dist/analysis-core/chunks/2M55DR2J.js +0 -35
  110. package/dist/analysis-core/chunks/34NVU26H.js +0 -1
  111. package/dist/analysis-core/chunks/C77LGCKF.js +0 -1
  112. package/dist/analysis-core/chunks/HCPO6QPU.js +0 -1
  113. package/dist/analysis-core/chunks/J4AXGE5W.js +0 -1
  114. package/dist/analysis-core/chunks/M5YWJY7P.js +0 -1
  115. package/dist/analysis-core/chunks/NCW5LJ5O.js +0 -6
  116. package/dist/analysis-core/chunks/QPIBHTON.js +0 -67
  117. package/dist/analysis-core/chunks/SJESFYBA.js +0 -10
  118. package/dist/analysis-core/chunks/VC3PYT2B.js +0 -1
@@ -1,7 +1,7 @@
1
- import{A as We,Aa as Xe,C as Ue,D as Be,E as Ge,Fb as $,G as ge,Gb as it,H as Ze,Hb as ye,I as ee,K as Ke,L as we,M as Ye,N as Pe,O as ke,R as Se,S as Je,T as V,a as de,aa as ce,c as Q,d as B,e as pe,eb as He,g as Fe,gb as Qe,h as Me,hb as oe,i as I,ib as et,j as Le,jb as tt,kb as ot,l as K,n as De,o as je,ob as nt,p as G,q as Te,ra as qe,s as ze,sb as st,t as J,ub as fe,ya as W,yb as rt,z as ie,za as te,zb as at}from"./2M55DR2J.js";import{a as Ne}from"./MKYLK6DB.js";import{a as z,c as v,e as Y}from"./C6X5GDG4.js";import{a as j,b as C,c as E,e as Ae,i as he,j as $e,k as T,l as Z,o as Ie,v as le}from"./YWL52FVW.js";import{f as Ve}from"./SJESFYBA.js";function q(e,t,o,c=t,r={}){let a=V(e,t.filter(s=>$(e,{path:s},{purpose:"override",route:"github"}).admitted),{root:o,...r});return be(a,e,c.some(s=>{let d=v(s,o);return d!==null&&de(d)}))}function be(e,t,o=e.scoped.some(c=>de(c.relativePath))){let c=new Map(e.scoped.map(s=>[s.path,s.relativePath])),r=(s,d,w=!1)=>e.files.find(g=>g.role===s&&g.kind!=="background"&&g.preferred!==!1&&(!d||g.kind===d)&&(!w||g.preferred))?.path??null,a=(s,d,w=!1)=>e.files.filter(g=>g.role===s&&(!d||g.kind===d)&&g.ownerPath!==void 0===w).map(g=>g.path).sort();return{scoped:e.scoped.map(s=>s.path),hasRepositoryGuide:o,developerCompanionPaths:!pe(t)&&o?e.scoped.filter(s=>Et(s.relativePath)).map(s=>s.path):[],stripRoot:s=>c.get(s)??s,configPath:r("marker"),promptPath:r("prompt","dedicated",!0),claudePath:r("prompt","fallback"),toolsPath:r("tool file","json"),toolsTsPath:r("tool file","sdk"),cliPath:r("tool file","cli"),mcpPath:r("MCP config",void 0,!0),registry:e.registry,soulPath:r("soul"),knowledgePath:r("knowledge"),subagentPaths:a("sub-agent"),skillPaths:a("skill"),skillNames:Object.fromEntries(e.files.filter(s=>s.role==="skill"&&s.name).map(s=>[s.path,s.name])),skillRefNames:Object.fromEntries(e.files.filter(s=>s.role==="reference"&&s.kind==="skill"&&s.name).map(s=>[s.path,s.name])),templatePaths:a("reference","template"),skillRefPaths:a("reference","skill"),subagentSkillPaths:a("skill",void 0,!0),subagentSkillRefPaths:a("reference","skill",!0),subagentSkillOwners:Object.fromEntries(e.files.filter(s=>s.ownerPath!==void 0).map(s=>[s.path,s.ownerPath]))}}function lt(e){let t=new Set(e.developerCompanionPaths),o=c=>!t.has(c);return{...e,mcpPath:e.mcpPath&&o(e.mcpPath)?e.mcpPath:null,subagentPaths:e.subagentPaths.filter(o),skillPaths:e.skillPaths.filter(o),subagentSkillPaths:e.subagentSkillPaths.filter(o),subagentSkillRefPaths:e.subagentSkillRefPaths.filter(o),skillRefPaths:e.skillRefPaths.filter(o)}}function ne(e){let t=lt(e);return!!(t.promptPath||t.toolsPath||t.toolsTsPath||t.cliPath||t.mcpPath||t.soulPath||t.knowledgePath||t.subagentPaths.length||t.skillPaths.length)}function Ot(e){let t=lt(e);return!!(t.promptPath||t.registry&&t.soulPath||t.subagentPaths.length)}function ct(e,t){return pe(e)?ne(t):Ot(t)}function Et(e){return e.toLowerCase()===".mcp.json"||/^\.claude\/(agents|skills)\//i.test(e)}function ft(e,t){return!!e.configPath||!!e.claudePath&&t==="prompt"||ne(e)}var Ct=/^(evals?|evaluations)\/.*\.(jsonl?|ya?ml|md|csv)$|\.eval\.(json|ya?ml)$/i;function Rt(e){return ge.exec(e)?.[1]?.toLowerCase()==="commands"&&/\.md$/i.test(e)}function Ft(e){return Ct.test(e)}function X(e,t,o={}){if(!B(e))return!1;if(o.agentConfigurations){if(o.agentConfigurations[z(o.root)]!==!0)return!1;if(o.skills!==!1)return!0}let c=t.flatMap(w=>{let g=v(w,o.root);return g===null?[]:[{path:w,relative:g}]}),r=c.filter(({path:w})=>$(e,{path:w},{purpose:"definition",route:"github",root:o.root}).admitted);if(!r.some(({relative:w})=>Q.includes(w.toLowerCase())))return!1;let a=q(e,r.map(w=>w.path),o.root,t),s=!!(a.subagentPaths.length||a.toolsPath||o.skills!==!1&&a.skillPaths.length),d=r.some(({relative:w})=>Rt(w));return!o.agentConfigurations&&c.some(({relative:w})=>{let g=ge.exec(w)?.[1]?.toLowerCase();return!(g==="skills"||(g==="commands"?s:Le(w)&&(s||d)))&&!at.test(w)&&!rt.test(w)&&w.toLowerCase()!==ie.toolsSource&&Xe(w)})?!1:s||d||r.some(({relative:w})=>Ft(w))}function se(e,t,o){let c=new Map([[z(o),[]]]);for(let r of t)v(r,o)!==null&&Q.includes(r.split("/").at(-1).toLowerCase())&&c.set(r.slice(0,Math.max(0,r.lastIndexOf("/"))),[]);for(let r of t){if(v(r,o)===null)continue;let a=r.slice(0,Math.max(0,r.lastIndexOf("/")));for(;c.get(a)?.push(r),!!a;)a=a.slice(0,Math.max(0,a.lastIndexOf("/")))}return Object.fromEntries([...c].map(([r,a])=>[r,X(e,a,{root:r})]))}function fo(e,t){let o=[...new Set([...Object.keys(t.files),...t.listedPaths??[]])],{root:c,skills:r,agentConfigurations:a}=t;if(!X(e,o,{root:c,skills:r,agentConfigurations:a}))return null;let s=q(e,Object.keys(t.files),c,t.listedPaths,{agentConfiguration:!0});return s.claudePath?s:null}import{posix as re}from"node:path";import{posix as Mt}from"node:path";function _e(e,t=1){let o=new Set,c=[],r=e.replace(/{#[\s\S]*?#}|{%[-+]?\s*raw\s*[-+]?%}[\s\S]*?(?:{%[-+]?\s*endraw\s*[-+]?%}|$)/g,a=>a.replace(/[^\n]/g," "));for(let a of r.matchAll(/{%[-+]?\s*(include|extends|import|from)\s+(.+?)\s*[-+]?%}/g)){let s=a[2].match(/^(["'])([^"']+)\1(?:\s+(?:as\s+\w+|import\s+.+|ignore missing|with context|without context))?$/),d=t+e.slice(0,a.index).split(`
2
- `).length-1;c.push({source:s?.[2]??a[2],span:{from:d,to:d},...s?{}:{reason:"dynamic"}})}for(let a of r.matchAll(/{{[-+]?\s*([\w]+)|{%[-+]?\s*(?:if|elif|for\s+\w+\s+in|set\s+\w+\s*=)\s+([\w]+)/g)){let s=a[1]??a[2];!["true","false","none"].includes(s.toLowerCase())&&!/^\d/.test(s)&&o.add(s)}return{variables:[...o],loaders:c}}function ut(e,t={}){let o=e.split(`
3
- `),c=[],r=[],a=(s,d,w)=>{let g=new Set;for(let P of Qe(s.join(`
4
- `))){let k=w?`${w}.${P.key}`:P.key,l={from:d+P.span.from,to:d+P.span.to},n=s.slice(P.span.from-1,P.span.to);g.has(P.key)&&r.push({key:k,span:l,reason:"duplicate"}),g.add(P.key);let p=n[0].slice(n[0].indexOf(":")+1).trim();if(!p||p.startsWith("#")){let f=n.slice(1),u=f.find(y=>y.trim()&&!y.trimStart().startsWith("#"))?.match(/^ */)?.[0].length;if(u){a(f.map(y=>y.slice(u)),l.from,k);continue}}let h=He(n.join(`
5
- `))?.[P.key],m=typeof h=="string"?h:null,i=k.endsWith("_template")||Me(t,"CF_IMPORT_PROMPT_FIELDS")&&k.endsWith("_prompt");(i&&m===null||/^[!&*]/.test(p))&&r.push({key:k,span:l,reason:"invalid"}),c.push({key:k,span:l,text:o.slice(l.from-1,l.to).join(`
6
- `),value:m,...i&&m!==null?_e(m,l.from+(/^[|>]/.test(p)?1:0)):{variables:[],loaders:[]}})}};a(o,0,"");for(let s of r.filter(d=>d.reason==="duplicate"))for(let d of c.filter(w=>w.key===s.key||w.key.startsWith(`${s.key}.`)))d.value=null;return{fields:c,unresolved:r}}function At(e,t){let{toks:o}=e,c=[],r=new Map;for(let a=0;a<o.length;a++){if(!he(o,a))continue;let s=$e(e.text,o[a]),d=c.findLast(k=>k.indent===s);for(;c.length&&c.at(-1).indent>=s;)c.pop();if(r.set(o[a].line,c.some(k=>!k.guard)?null:c.map(k=>k.guard)),!["if","elif","else","for","while","try","except","with","match","case"].some(k=>E(o[a],k)))continue;let w=a+1;for(;w<o.length&&o[w].line===o[a].line;)w++;let g=C(o[w-1],":"),P=null;if(g&&E(o[a],"else")&&d?.guard&&(P={...d.guard,value:!d.guard.value}),g&&E(o[a],"if")){let k=E(o[a+1],"not"),l=a+(k?2:1),n=o.slice(l,w-1).map(m=>m.text).join(""),p=t.owner(a),h=/^[A-Za-z_]\w*$/.test(n)?n:null;if(/^self\.[A-Za-z_]\w*$/.test(n)){let i=o.flatMap((f,u)=>u<a&&he(o,u)&&t.owner(u)===p&&o.slice(u,u+3).map(y=>y.text).join("")===n?[u]:[]).at(-1);h=i!==void 0&&C(o[i+3],"=")&&E(o[i+4])&&o[i+5]?.line!==o[i].line?o[i+4].text:null}if(h&&p?.params?.includes(h)&&!t.binding(h,a)){let m=o.findIndex((y,x)=>p.from<x&&x<a&&C(y,"(")),i=m>=0&&T(o,m)<a?Z(o,m).find(y=>E(o[y.from],h)):void 0,f=i&&o.findIndex((y,x)=>i.from<x&&x<i.to&&C(y,"=")),u=f!==void 0&&f>=0&&f+2===i?.to?o[f+1].text:null;P={parameter:h,value:!k,defaultValue:u==="True"?!0:u==="False"?!1:null}}}c.push({indent:s,guard:P}),r.set(o[a].line,null)}return r}function ko(e,t,o){let c=j(e,t,"py"),r=le(c,{includeMembers:!0}),a=ce(c,r,{enclosingBindings:!0}),{toks:s}=c,d=At(c,a),w=a.assignments.map(h=>["else","try","finally"].includes(h.name)&&E(s[h.from-2])?{...h,name:s[h.from-2].text,at:h.from-2}:h),g=h=>s.slice(h.from,h.to).map(m=>m.kind==="string"?JSON.stringify(m.value):m.text).join(""),P=(h,m,i,f)=>{let u=a.importBinding(h,m);return u?f?!u.namespace&&u.module.source===i&&u.name===f:u.namespace&&u.module.source===i:!1},k=[],l=new Map,n=new Map;for(let h of a.calls.filter(m=>m.callee.endsWith("read_text"))){let m=g(h),i=/^([A-Za-z_]\w*)\.resources\.files\(("(?:[^"\\]|\\.)*")\)\.joinpath\((.*?)\)\.read_text\(\)$/.exec(m)??/^([A-Za-z_]\w*)\.files\(("(?:[^"\\]|\\.)*")\)\.joinpath\((.*?)\)\.read_text\(\)$/.exec(m);if(!i)continue;let f=a.importBinding(i[1],h.from),u=m.startsWith(`${i[1]}.resources.files(`);if(!(f&&(u?f.namespace&&f.name==="importlib"&&["importlib","importlib.resources"].includes(f.module.source):f.namespace&&f.name==="importlib.resources"&&f.module.source==="importlib.resources"||!f.namespace&&f.name==="resources"&&f.module.source==="importlib")))continue;let x=a.calls.find(b=>b.from<h.from&&h.to<b.to&&b.args.length===1&&b.args[0].from===h.from&&b.args[0].to===h.to&&(b.callee.endsWith(".safe_load")&&P(b.callee.split(".")[0],b.from,"yaml")||P(b.callee,b.from,"yaml","safe_load")));if(!x)continue;let S=JSON.parse(i[2]),_;try{_=JSON.parse(i[3])}catch{}let R=null,A;if(typeof _!="string"||!/^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/.test(S))A="dynamic";else if(Mt.isAbsolute(_)||/[\\\0]/.test(_)||_.split("/").includes(".."))A="out-of-scope";else{let b=`${S.replaceAll(".","/")}/${_}`,N=e.indexOf(`${S.split(".")[0]}/`),L=N>=0?e.slice(0,N)+b:null,D=[...o].filter(H=>H===b||H.endsWith(`/${b}`));R=L??(D.length===1?D[0]:null),R?o.has(R)||(A="missing"):A=D.length>1?"dynamic":"missing"}let O=w.find(b=>b.from<=x.from&&x.from<b.to&&a.owner(b.at)===a.owner(x.from)),F={path:R,source:typeof _=="string"?_:i[3],span:{from:s[h.from].line,to:s[h.to-1].endLine},start:s[x.from].start,end:s[x.to-1].end,binding:O?.name??null,forwarded:!1,when:d.get(s[O?.at??h.from].line)??null,className:r.filter(b=>b.kind==="class"&&b.from<h.from&&h.from<b.to).at(-1)?.name??null,...A?{reason:A}:{}};k.push(F),O&&(l.set(F,O),n.set(O,x))}let p=new Set([...l.values()].filter(h=>{let m=n.get(h);return(E(s[h.from],h.name)&&E(s[h.from+1],"or")?h.from+2:h.from)===m.from&&(h.to===m.to||h.to+1===m.to&&C(s[h.to],")"))}));for(let h of k){let m=l.get(h);!m||!p.has(m)||a.owner(m.at)?.name!=="__init__"||(h.forwarded=a.calls.some(i=>a.owner(i.from)===a.owner(m.at)&&s[i.from].start>h.end&&E(s[i.from],"super")&&i.callee.endsWith("__init__")&&i.args.some(f=>E(s[f.from],m.name)&&C(s[f.from+1],"=")&&f.to===f.from+3&&E(s[f.from+2],m.name))&&w.filter(f=>f.name===m.name&&m.at<f.at&&f.at<i.from&&a.owner(f.at)===a.owner(m.at)).every(f=>p.has(f))&&!s.some((f,u)=>u<i.from&&f.start>=h.end&&E(f,m.name)&&a.owner(u)===a.owner(m.at)&&![...p].some(y=>y.at<=u&&u<n.get(y).to))))}return k}function mt(e,t){if(!I(e))return[];let o=new Set(t),c=[];for(let r of[...o].sort()){let a=r.match(/^((?:[^/]+\/)*?)(?:src\/)?minisweagent\/agents\/default\.py$/);if(!a)continue;let s=r.slice(0,-18),d=`${s}/config`,w=`${d}/__init__.py`,g=`${s}/run/mini.py`;if(!o.has(w)||!o.has(g))continue;let P=[...o].filter(k=>v(k,d)!==null&&/\.ya?ml$/.test(k)).sort();P.length&&c.push({folder:a[1].replace(/\/$/,""),configFolder:d,agentPath:r,loaderPath:w,runnerPath:g,configs:P,templates:[...o].filter(k=>v(k,d)!==null&&/\.(?:j2|jinja2?)$/.test(k)).sort()})}return c}function $t(e,t){let o=j(e.agentPath,t[e.agentPath]??"","py").toks,c=j(e.loaderPath,t[e.loaderPath]??"","py").toks,r=j(e.runnerPath,t[e.runnerPath]??"","py").toks;if(!["system_template","instance_template"].every(s=>o.some((d,w)=>E(d,s)&&C(o[w-1],".")))||!c.some((s,d)=>E(s,"safe_load")&&C(c[d+1],"("))||!c.some((s,d)=>E(s,"read_text")&&C(c[d+1],"("))||!r.some((s,d)=>E(s,"get_config_from_spec")&&C(r[d+1],"("))||!r.some((s,d)=>E(s,"get_agent")&&C(r[d+1],"("))||!r.some((s,d)=>E(s,"get")&&C(r[d+1],"(")&&r[d+2]?.value==="agent"))return null;let a=r.flatMap((s,d)=>{if(!E(s,"DEFAULT_CONFIG_FILE")||!C(r[d+1],"="))return[];let w=r.slice(d+2).filter(g=>g.line===s.line);return w.flatMap((g,P)=>E(g,"builtin_config_dir")&&C(w[P+1],"/")&&w[P+2]?.kind==="string"?[re.join(e.configFolder,w[P+2].value)]:[])});return a.length===1?a[0]:null}function Eo(e,t,o,c){let r={variants:[],selectedPaths:[],fields:[],model:null,loaded:[],unresolved:[],edges:[]};if(!I(e))return r;let a=$t(t,o);if(!a)return r.unresolved.push({path:t.runnerPath,source:"config",reason:"dynamic"}),r;let s=new Map,d=new Set(Object.keys(o)),w=l=>{let n=$(e,{path:l,text:o[l],size:o[l]===void 0?void 0:Buffer.byteLength(o[l])},{purpose:"pointer",route:"github",root:t.configFolder,listing:d,managedFiles:o});return n.admitted||s.set(l,n.reason),n.admitted},g=new Map([...new Set([...t.configs,...c??[]])].flatMap(l=>w(l)&&Object.hasOwn(o,l)?[[l,ut(o[l],e)]]:[]));r.variants=t.configs.map(l=>({path:l,fields:(g.get(l)?.fields??[]).map(n=>({...n,path:l}))})),r.selectedPaths=c?[...c]:[a];let P=new Map;for(let l of r.selectedPaths){if(v(l,t.configFolder)===null){r.unresolved.push({path:l,source:l,reason:"out-of-scope"});continue}let n=g.get(l);if(!n){r.unresolved.push({path:l,source:l,reason:s.get(l)??"missing"});continue}r.unresolved.push(...n.unresolved.map(p=>({path:l,source:p.key,span:p.span,reason:p.reason})));for(let p of n.fields)if(/^(?:agent|model|environment)(?:\.|$)/.test(p.key)){for(let h of P.keys())(h.startsWith(`${p.key}.`)||p.key.startsWith(`${h}.`))&&P.delete(h);P.set(p.key,{...p,path:l})}}r.fields=[...P.values()],r.model=P.get("model.model_name")?.value??null;let k=new Set;for(let l of r.fields){let n=new Set([l.path]),p=[{path:l.path,facts:{variables:l.variables,loaders:l.loaders},next:0}];for(;p.length;){let h=p.at(-1),{path:m,facts:i}=h;if(h.next===0)for(let x of i.variables)r.unresolved.push({path:m,source:x,reason:"runtime-variable"});if(h.next>=i.loaders.length){n.delete(m),p.pop();continue}let f=i.loaders[h.next++],u=re.normalize(re.join(re.dirname(m),f.source)),y=f.reason??(re.isAbsolute(f.source)||v(u,t.configFolder)===null?"out-of-scope":w(u)?n.has(u)?"cycle":Object.hasOwn(o,u)?null:"missing":s.get(u));if(y){r.unresolved.push({path:m,source:f.source,...f.reason?{}:{target:u},span:f.span,reason:y});continue}r.edges.push({from:m,to:u,span:f.span}),!k.has(u)&&(k.add(u),r.loaded.push({path:u}),n.add(u),p.push({path:u,facts:_e(o[u]),next:0}))}}return r}import{posix as ue}from"node:path";function Oe(e){return/(?:^|\/)(?:(?:[^/]+_)?(?:crew|agents|tasks))\.py$/i.test(e)}function dt(e,t,o,c=""){let r=j(e,t,"py"),{toks:a}=r,s=le(r,{includeMembers:!0}),d=Ie(r),w=ce(r,s,{enclosingBindings:!0}),g={agents:[],tasks:[],refused:[]},P=l=>s.filter(n=>n.from<=l&&l<n.to),k=l=>{if(!E(a[l])||C(a[l-1],".")||!C(a[l+1],"("))return null;let n=w.importBinding(a[l].text,l);return n?.module.source==="crewai"&&["Agent","Task"].includes(n.name)?n.name:null};for(let l=0;l<a.length;l++){let n=k(l);if(!n)continue;let p=T(a,l+1);if(p>=a.length){g.refused.push({path:e,reason:"invalid"});continue}let h=P(l),m=h.filter(O=>O.kind==="class").at(-1),i=h.filter(O=>O.params!==null).at(-1),f=h.filter(O=>O.params===null&&O.kind!=="class"&&O.kind!=="index").at(-1),u=i?.name??f?.name??`line-${a[l].line}`,y=m?`${m.name}.${u}`:u,x=h.some(O=>O.kind==="index")||g.agents.some(O=>O.factory===y)?`${y}@${a[l].start}`:y,S=new Map(Z(a,l+1).flatMap(O=>E(a[O.from])&&C(a[O.from+1],"=")?[[a[O.from].text,{from:O.from+2,to:O.to}]]:[])),_={path:e,factory:x,span:{from:a[l].line,to:a[p].endLine},callStart:a[l].start},R=S.get("config");if(R){let O=a.slice(R.from,R.to).map(b=>b.kind==="string"?JSON.stringify(b.value):b.text).join(""),F=/^(?:self\.)?(agents_config|tasks_config)\["([^"\n]+)"\]$/.exec(O);if(F){let b=s.filter(M=>M.name===F[1]&&M.params===null&&(m?m.from<M.from&&M.to<=m.to&&!s.some(U=>U.params!==null&&U.from<M.from&&M.from<U.to):!s.some(U=>U.kind==="class"&&U.from<M.from&&M.from<U.to))),N=b.length===1?pt(r,b[0]):void 0,L=m&&Lt(r,m,w),D=N?xe(r,N):b.length===0&&L?`config/${F[1]==="agents_config"?"agents":"tasks"}.yaml`:null,H=null;if(D===null||/[\\\0${}*]/.test(D))g.refused.push({path:e,reason:"dynamic"});else{let M=ue.normalize(ue.join(ue.dirname(e),D));D.startsWith("/")||M===".."||M.startsWith("../")||v(M,c)===null?g.refused.push({path:M,reason:"out-of-scope"}):o.has(M)?H=M:g.refused.push({path:M,reason:"missing"})}_.config={path:H,key:F[2]}}else _.config={path:null,key:""},g.refused.push({path:e,reason:"dynamic"})}let A=ve(r,S.get("tools"),o,s,i,m,g.refused,w);if(n==="Agent"){let O=Object.fromEntries(["role","goal","backstory"].flatMap(F=>{let b=S.get(F)&&xe(r,S.get(F));return S.has(F)&&b==null&&g.refused.push({path:e,reason:"dynamic"}),b==null?[]:[[F,b]]}));g.agents.push({..._,instructions:O,tools:A})}else{let O=L=>It(r,L,m,s,d),F=O(S.get("agent")),b=S.get("context"),N=b&&C(a[b.from],"[")&&T(a,b.from)===b.to-1?Z(a,b.from):[];b&&(!C(a[b.from],"[")||N.some(L=>!O(L)))&&g.refused.push({path:e,reason:"dynamic"}),S.has("agent")&&!F&&g.refused.push({path:e,reason:"dynamic"}),g.tasks.push({..._,agent:F,context:N.flatMap(L=>O(L)??[]),tools:A})}l=p}return g}function pt(e,t){let o=t.from+1;for(;o<t.to&&!C(e.toks[o],"=");)o++;return o<t.to?{from:o+1,to:t.to}:void 0}function xe(e,t){let{toks:o}=e;return t.to===t.from+1&&o[t.from]?.kind==="string"&&Ae(o[t.from]).closed?o[t.from].value:E(o[t.from],"dedent")&&C(o[t.from+1],"(")&&T(o,t.from+1)===t.to-1?xe(e,{from:t.from+2,to:t.to-1}):null}function It(e,t,o,c,r){if(!t)return null;let a=e.toks.slice(t.from,t.to).map(d=>d.text).join(""),s=/^(self\.)?([A-Za-z_]\w*)(?:\(\))?$/.exec(a);if(s&&!s[1]){let d=c.filter(g=>g.params!==null&&g.from<t.from&&t.from<g.to),w=g=>c.filter(P=>P.params!==null&&P.from<g&&g<P.to).at(-1);if(d.some(g=>g.params?.includes(s[2]))||c.some(g=>g.name===s[2]&&d.includes(w(g.from)))||r.some(g=>g.names.includes(s[2])&&d.includes(w(e.toks.findIndex(P=>P.line===g.line)))))return null}return s?s[1]&&o?`${o.name}.${s[2]}`:s[2]:null}function ve(e,t,o,c,r,a,s,d,w=new Set){if(!t)return[];let{toks:g}=e;if(C(g[t.from],"[")&&T(g,t.from)===t.to-1)return Z(g,t.from).flatMap(u=>ve(e,u,o,c,r,a,s,d,new Set(w)));let P=g[t.from];if(!E(P)||w.has(P.text))return s.push({path:e.path,reason:"dynamic"}),[];if(w.add(P.text),r?.params?.includes(P.text))return s.push({path:e.path,reason:"dynamic"}),[];let l=c.filter(u=>u.name===P.text&&u.params===null&&u.kind!=="class"&&u.from<t.from).filter(u=>{let y=c.filter(x=>(x.params!==null||x.kind==="class")&&x.from<u.from&&u.from<x.to).at(-1);return!y||y===r||!r&&y===a}),n=r&&l.filter(u=>r.from<u.from&&u.to<=r.to),p=n&&n.length?n:l;if(p.length===1){let u=pt(e,p[0]);if(u)return ve(e,u,o,c,r,a,s,d,w)}if(p.length>1)return s.push({path:e.path,reason:"dynamic"}),[];let h=d.importBinding(P.text,t.from),m=h?.module,i=null;if(m){let u=ue.dirname(e.path).split("/"),y=u.lastIndexOf(m.source.split(".")[0]),x=m.source.startsWith(".")?m.source:y<0?`.${m.source}`:".".repeat(u.length-y)+m.source.split(".").slice(1).join(".");i=Ve(e.path,x,[h.name],"py",o)??null,!i&&(m.source.startsWith(".")||y>=0)&&s.push({path:e.path,reason:"missing"})}else if(!c.some(u=>u.name===P.text&&(u.kind==="class"||u.params!==null)))return s.push({path:e.path,reason:"dynamic"}),[];let f=t.from+1;for(;C(g[f],".")&&E(g[f+1]);)f+=2;return f<t.to&&(!C(g[f],"(")||T(g,f)!==t.to-1)?(s.push({path:e.path,reason:"dynamic"}),[]):[{name:g.slice(t.from,f).map(u=>u.text).join(""),path:m?i:e.path}]}function Lt(e,t,o){let c=e.text.slice(0,e.toks[t.from].start).trimEnd().split(`
7
- `);for(let r=c.length-1;r>=0;r--){let a=/^\s*@([A-Za-z_]\w*)(?:\(\))?\s*$/.exec(c[r]);if(!a)break;let s=o.importBinding(a[1],t.from);if(s?.module.source==="crewai.project"&&s.name==="CrewBase")return!0}return!1}var Nt=new Set([...We,ie.soul].map(e=>e.toLowerCase())),Dt=["templates","default_prompts","prompts/default","docs","evals","benchmarks"],jt=["tests","__tests__","fixtures","test_data","evals","benchmarks","templates","default_prompts","prompts/default","docs"];function gt(e,t=""){return e===t?null:`folder:${e}`}function Qo(e,t,o){let c=wt(e,t,o),r=z(o),a=t.filter(n=>!G(e,n,r)),s=a.filter(n=>c.ownerOf(n)?.key===null),d=q(e,s,r),w=ne(d)||!!d.configPath,g=V(e,s,{root:r}).files.filter(n=>n.role!=="reference"&&n.kind!=="background"),P=new Set(g.map(n=>n.relativePath)),k=g.flatMap(n=>n.role==="sub-agent"?[n.relativePath.slice(0,-3)]:n.role==="skill"?[n.relativePath.slice(0,n.relativePath.lastIndexOf("/"))]:[]),l=new Map(c.scopes.map(n=>[n.folder,{scope:n,paths:[]}]));for(let n of[...new Set(a)]){let p=c.ownerOf(n);if(!p)continue;let h=v(n,r),m=h.split("/");if(p.key===null&&w&&m.length>1&&!P.has(h)&&!k.some(i=>v(h,i)!==null)){let i=m.slice(0,-1).findIndex((u,y)=>![...P].some(x=>x.startsWith(`${m.slice(0,y+1).join("/")}/`))),f=Y(m.slice(0,i<0?-1:i+1).join("/"),r);l.has(f)||l.set(f,{scope:{key:gt(f,r),folder:f,kind:"folder"},paths:[]}),p=l.get(f).scope}l.get(p.folder).paths.push(n)}return[...l.values()].sort((n,p)=>n.scope.folder<p.scope.folder?-1:n.scope.folder>p.scope.folder?1:0).map(({scope:n,paths:p})=>{let h=q(e,p,n.folder),m=c.scopes.includes(n);return{scope:n,paths:p,convention:m&&(!!n.managed||!!n.miniSwe||n.kind==="crew"&&!n.agentsPath.endsWith(".py")||ct(e,h)),markerPath:m?h.configPath:null}})}function wt(e,t,o,c={},r){let a=z(o);r??=B(e)?se(e,t,o):void 0;let s=K(e),d=et(e,t,c),{scopes:w,skipped:g,pluginFolders:P}=s?Tt(e,t,a,d,r):{scopes:[{key:null,folder:a,kind:"root"}],skipped:[],pluginFolders:[]},k=m=>Pt(w,m),l=new Set(t),n=t.filter(m=>G(e,m,a)||k(m)&&(s&&fe(e,m,P)||je(e,m,{root:a,listing:l}))),p=new Set(I(e)?Object.entries(c).filter(([m])=>m.endsWith(".py")&&k(m)).flatMap(([m,i])=>dt(m,i,new Set(t),a).agents.flatMap(f=>f.tools.flatMap(u=>u.path??[]))):[]),h=s?t.filter(m=>{let i=k(m);return!p.has(m)&&i?.kind==="crew"&&v(m,i.folder)?.toLowerCase().startsWith("tools/")}):[];return{scopes:w,skipped:g,ownerOf:k,pluginFolders:P,ignoredPaths:n,ignoredImportPaths:h,...d.length?{pluginDeclarations:d.filter(m=>P.includes(m.folder))}:{}}}function Pt(e,t){return e.findLast(o=>v(t,o.folder)!==null)??null}function Tt(e,t,o,c,r){let a=[...new Set(t)].filter(l=>!fe(e,l)).sort().flatMap(l=>{let n=v(l,o);return n===null?[]:[{path:l,relativePath:n}]}),s=[],d=new Map,w=a.filter(l=>!G(e,l.path,o)).map(l=>l.path);for(let l of ot(e,w))d.set(l.folder,l.agents.map(n=>({path:n,plugin:!1,crew:!1,checkPath:`${l.folder}/`,managed:l})));for(let l of mt(e,w))d.set(l.folder,[...d.get(l.folder)??[],{path:l.agentPath,plugin:!1,crew:!1,checkPath:`${l.folder}/`,miniSwe:l}]);for(let{path:l,relativePath:n}of a){let p=n.split("/"),h=p.pop().toLowerCase(),m=Y(p.join("/"),o),i=p.length>0&&(Nt.has(h)||Q.includes(h)&&X(e,t,{root:m,agentConfigurations:r})),f=tt(e,l,c);f===o&&!G(e,l,o)&&!s.includes(o)&&s.push(o);let u=f!==null&&f!==o&&!!v(`${f}/`,o),y=n.toLowerCase()==="config/agents.yaml"||n.toLowerCase().endsWith("/config/agents.yaml"),x=I(e)&&Oe(l)&&!/(?:^|\/)(?:tasks|[^/]+_tasks)\.py$/i.test(l),S=y||x;if(!i&&!u&&!S)continue;let _=y?l.slice(0,-18).replace(/\/$/,""):x?l.slice(0,Math.max(0,l.lastIndexOf("/"))):u?f:Y(p.join("/"),o),R=d.get(_)??[];R.push({path:l,plugin:u,crew:S,checkPath:u?`${_}/`:l}),d.set(_,R)}let g=ze(e),P={settings:e,folder:o,scoped:a,candidates:d,rootPlugins:s,excludedFolders:g?Dt:jt},k=ht(P,new Set);if(g){let l=[...new Set(k.accepted.map(i=>i.folder))].filter(i=>i!==o),n=a.filter(i=>!G(e,i.path,o)&&!l.some(f=>v(i.path,f)!==null)).map(i=>i.path),p=V(e,n,{root:o,folderAgentsFound:l.length>0,agentConfiguration:X(e,t,{root:o,agentConfigurations:r})}),h=kt(e,p,l.length>0)?[{path:`${o}/`,checkPath:`${o}/`}]:[],m=Te([...k.accepted,...h],i=>i.checkPath,{root:o,listing:new Set(a.map(i=>i.path)),settings:e});if(k.accepted.some(i=>m(i.checkPath))){let i=new Set([...d.values()].flat().filter(f=>m(f.checkPath)).map(f=>f.path));k=ht(P,i)}}return k.skipped.sort((l,n)=>l.path<n.path?-1:l.path>n.path?1:0),{scopes:k.scopes,skipped:k.skipped,pluginFolders:k.pluginFolders}}function ht({settings:e,folder:t,scoped:o,candidates:c,rootPlugins:r,excludedFolders:a},s){let d=[{key:null,folder:t,kind:"root"}],w=[],g=[...r],P=[],k=new Map;for(let l of[...c.keys()].sort()){let n=c.get(l),p=Pt(d,n[0].path),h=k.get(p.folder)??zt(o.map(S=>S.path),p.folder);k.set(p.folder,h);let m=[];for(let S of n){let{path:_,checkPath:R}=S;if(fe(e,_,g))continue;let A=G(e,_,t)?"excluded-folder":l===t?null:s.has(_)?"excluded-folder":Wt(v(R,t),v(R,p.folder),h,De(e,_,t)?[]:a);A?w.push({path:_,reason:A}):(m.push(S),P.push({path:_,folder:l,checkPath:R}))}if(!m.length)continue;let i=(I(e)?m.find(S=>S.crew&&S.path.endsWith("config/agents.yaml")):void 0)??m.find(S=>S.crew),f=gt(l,t),u=i?{key:f,folder:l,kind:"crew",agentsPath:i.path,tasksPath:o.find(S=>v(S.path,l)?.toLowerCase()==="config/tasks.yaml")?.path??null}:{key:f,folder:l,kind:"folder"},y=m.find(S=>S.managed)?.managed;y&&(u.managed=y);let x=m.find(S=>S.miniSwe)?.miniSwe;x&&(u.miniSwe=x),l===t?d[0]=u:d.push(u),m.some(S=>S.plugin)&&!g.includes(l)&&g.push(l)}return{scopes:d,skipped:w,pluginFolders:g,accepted:P}}function ae(e,t,o,c={}){let r=c.agentConfigurations??(B(e)?se(e,c.listedPaths??t,o):void 0),a=wt(e,t,o,c.files,r),{scopes:s,ownerOf:d,ignoredPaths:w}=a,g=new Set(w),P=new Map(s.map(i=>[i,[]]));for(let i of t){if(g.has(i))continue;let f=d(i);f&&P.get(f).push(i)}let k=s.map(i=>V(e,P.get(i),{root:i.folder,mode:c.mode,agentConfiguration:X(e,c.listedPaths??t,{root:i.folder,agentConfigurations:r}),folderAgentsFound:i.key===null&&(s.length>1||i.kind==="crew")})),l=(i,f)=>kt(e,i,s[f].key===null&&(s.length>1||s[f].kind==="crew")),n=s.length===1?k:k.filter((i,f)=>s[f].managed||s[f].miniSwe||s[f].kind==="crew"||l(i,f)),p=!n.length||n.some(i=>{let f=k.indexOf(i);return s[f].managed||s[f].miniSwe?!1:s[f].kind==="crew"&&!l(i,f)?s[f].agentsPath.endsWith(".py"):!i.registry&&(!i.files.some(u=>u.role==="prompt")||!i.files.some(u=>u.role==="tool file"))}),h=new Set((a.pluginDeclarations??[]).map(i=>i.path));for(let i of oe(e,t))/marketplace\.json$/i.test(i)&&h.add(i);let m=k.flatMap((i,f)=>{let u=s[f],y=[...h].filter(S=>!g.has(S)&&d(S)===u).map(S=>({path:S,relativePath:v(S,u.folder),role:"marker",kind:"entry"}));if(u.miniSwe)return[...i.files,...y,...[...u.miniSwe.configs,...u.miniSwe.templates,u.miniSwe.agentPath,u.miniSwe.loaderPath,u.miniSwe.runnerPath].map(S=>({path:S,relativePath:v(S,u.folder),role:"knowledge",kind:"entry"}))];if(u.managed)return[...[...u.managed.agents,...u.managed.configs].flatMap(S=>{let _=J(v(S,u.folder))?.definition;if(_&&(c.mode==="core"||!Ke(e)))return[];let R=u.managed.agents.includes(S);return[{path:S,relativePath:v(S,u.folder),role:R?"prompt":_?"skill":"knowledge",kind:R?"entry":_?"skill":"json"}]}),...y];if(u.kind!=="crew")return[...i.files,...y];let x=[{path:u.agentsPath,relativePath:v(u.agentsPath,u.folder),role:"prompt",kind:"entry"}];if(I(e))for(let S of P.get(u)){let _=v(S,u.folder);S!==u.agentsPath&&(Oe(_)&&!_.includes("/")||/^config\/[^/]+\.ya?ml$/i.test(_))&&x.push({path:S,relativePath:_,role:"knowledge",kind:"entry"})}return u.tasksPath&&x.push({path:u.tasksPath,relativePath:v(u.tasksPath,u.folder),role:"knowledge",kind:"entry"}),[...i.files,...x,...y]});return{...a,files:m,needsExtraction:p}}function kt(e,t,o){let c=be(t,e),r=Fe({codeAgentsFound:!1,folderAgentsFound:o,otherDefinitions:ne(c),agentConfiguration:t.files.some(a=>a.role==="prompt"&&a.kind==="fallback")},e);return ft(c,r)}function zt(e,t){let o=new Set;for(let c of e){let r=v(c,t);r!==null&&ee.test(r)&&o.add(r.slice(0,-3).toLowerCase())}return o}function Wt(e,t,o,c){let r=e.toLowerCase();if(c.some(d=>`/${r}`.includes(`/${d}/`)))return"excluded-folder";let a=r.slice(0,r.lastIndexOf("/"));if(J(e,{nested:!0})||Ze.some(d=>a===d||a.endsWith(`/${d}`)))return"skill-folder";if(`/${r}`.includes(`/${Be}/${Ge}/`)||ee.test(t))return"sub-agent-folder";let s=t.toLowerCase().split("/");return s.some((d,w)=>o.has(s.slice(0,w).join("/")))?"sub-agent-folder":null}var St="Some of this agent's files weren't read, so findings may be missing.";var yt=e=>e.CF_READING_PRIORITY!=="0";var Ut=new Set(["system prompt","soul","knowledge","config","tools","mcp"]);function bt(e){let t=new Set;for(let c of e.nodes)for(let r of c.files??[])Ut.has(r.role)&&t.add(r.path);let o=new Set(e.edges.filter(c=>c.kind==="delegates").map(c=>c.to));for(let c of e.nodes)o.has(c.id)&&c.sourceRef&&t.add(c.sourceRef.path);return t}function sn(e){return new Set([...e.nodes,...e.edges].flatMap(t=>t.sourceRef?[t.sourceRef.path]:[]))}var me=6e4,Bt=e=>{if(e.length<=me)return e;let t=e.endsWith(ye)?ye:"";return(t?e.slice(0,-t.length):e).slice(0,me)+t};function rn(e,t){let o=[...e].filter(c=>t[c]!==void 0&&Bt(t[c])!==t[c]).sort();return o.length===0?null:`${o.length} core file${o.length===1?" was":"s were"} longer than ${me/1e3} KB, so only the first ${me/1e3} KB ${o.length===1?"was":"were"} read: ${o.join(", ")}`}var Ee=e=>e.split("/").slice(0,-1).join("/"),Gt=/(agent|prompt|tool|llm|model)/i,Zt=2.5;function Re(e,t){if(!yt(e))return{enabled:!1,tierOf:()=>6};if(t.repos?.some(n=>n.kind==="github"&&z(n.root)))return Kt(e,t,t.repos);let o=t.scopes??(K(e)?ae(e,t.paths,void 0,{agentConfigurations:{}}):void 0),c=t.graph?bt(t.graph):new Set,r=new Set(t.graph?.nodes.flatMap(n=>(n.files??[]).filter(p=>p.role==="code"&&W(p.path)).map(p=>p.path))??[]),a=new Set(t.graph?.nodes.flatMap(n=>(n.files??[]).filter(p=>p.role==="system prompt").map(p=>p.path))??[]),s=n=>te(n)&&(Ue.includes(n.split("/").pop().toLowerCase())||/(^|\/)system_prompt_[^/]+\.md$/i.test(n)||Je.test(n)),d=n=>{if(c.has(n))return 1;if(r.has(n))return 2;let p=Pe(e,n,o),h=J(p,{nested:!0});if(h?.reference)return 5;if(h?.definition||ee.test(p))return 4;if(h||/(^|\/)(docs?|references)\//i.test(p)||Ye.test(n.split("/").pop()))return 5;if(we(p)||ke(e,n,o)&&we(n.split("/").pop())||s(n))return 1;if(W(n)){if(Gt.test(n))return Zt;if(Se.test(n))return 3}return 6};for(let n of t.paths)d(n)===1&&s(n)&&a.add(n);let w=[...a].flatMap(n=>{let p=Ee(n);return[p,...p?[Ee(p)]:[]]}),g=n=>W(n)&&w.some(p=>Ee(n)===p),P=new Map(t.paths.map(n=>{let p=d(n);return[n,p>2&&g(n)?2:p]})),k=[...P].filter(([n,p])=>p<=2&&W(n)).map(([n])=>n),l=qe(Object.fromEntries(k.flatMap(n=>t.files?.[n]===void 0?[]:[[n,t.files[n]]])),t.paths);for(let n of l)W(n)&&!J(Pe(e,n,o),{nested:!0})&&(P.get(n)??6)>2&&P.set(n,2);return{enabled:!0,tierOf:n=>P.get(n)??d(n)}}function Kt(e,t,o){let c=new Map;for(let r of o){let a=r.kind==="github"?r.root:void 0,s=t.paths.filter(n=>r.files?.[n]!==void 0&&!c.has(n)),d=n=>v(n,a)??(r.files?.[n]!==void 0?n:null),w=n=>{let p=n?d(n.path):null;return p===null?null:{path:p}},g=t.graph&&{nodes:t.graph.nodes.map(n=>({...n,sourceRef:w(n.sourceRef),files:n.files?.flatMap(p=>{let h=d(p.path);return h===null?[]:[{...p,path:h}]})})),edges:t.graph.edges.map(n=>({...n,sourceRef:w(n.sourceRef)}))},P=s.flatMap(n=>{let p=d(n);return p===null?[]:[p]}),k=Object.fromEntries(s.flatMap(n=>{let p=d(n);return p===null||t.files?.[n]===void 0?[]:[[p,t.files[n]]]})),l=Re(e,{paths:P,files:k,graph:g});for(let n of s)c.set(n,l.tierOf(d(n)??n))}return{enabled:!0,tierOf:r=>c.get(r)??6}}function Yt(e,t){return e.enabled?t.filter(o=>["too-large","total","allowance"].includes(o.reason)&&e.tierOf(o.path)<3).map(o=>o.path):[]}function Jt(e){return e.slice(0,3)}function Vt(e,t=!1){let o=Jt(e);if(!o.length)return;let c=t?". "+St:", so some findings may be missing";return`${o.join(", ")} ${o.length===1?"was":"were"} left out${c}`}function Pn(e,t){return Vt(Yt(e,t))}function kn(e,t){return e.enabled&&e.tierOf(t)<3}function _t(e,t,o){let c=Ne.sourceFetch.codeFileBytes;return e.enabled&&e.tierOf(t)<3&&W(t)&&o>c?{size:c,readBytes:c}:{size:o}}function xt(e,t){return e.enabled&&e.tierOf(t)<3&&W(t)}function Ce(e){return e.split("/").length-1}function vt(e,t,o){return ke(e,t,o)?0:Se.test(t)?1+Math.min(Ce(t),3)/10:Ce(t)<=2?2:Ce(t)<=4?3:4}function Sn(e,t){return(e.tier??0)-(t.tier??0)||e.score-t.score||e.size-t.size}function yn(e,t,o,c){return[...e].sort((r,a)=>(c?.enabled?c.tierOf(r)-c.tierOf(a):0)||Number(o.has(a))-Number(o.has(r))||t[r].length-t[a].length||(r<a?-1:1))}function bn(e,t,o,c){return[...e].sort((r,a)=>(c?.enabled?c.tierOf(r.path)-c.tierOf(a.path):0)||Number(t.has(a.path))-Number(t.has(r.path))||Number(o.has(a.path))-Number(o.has(r.path))||r.text.length-a.text.length)}function $n(e,t,o={},c={}){let{root:r}=o,a=t.map(i=>i.path),s=B(e)?se(e,a,r):void 0,d=t.filter(i=>{let f=$(e,i,{...o,purpose:"source",route:"github"});return f.admitted||f.reason==="wrong-type"||f.reason==="too-large"}),w=K(e)?ae(e,d.map(i=>i.path),r,{files:c.files,listedPaths:a,agentConfigurations:s}):void 0,g=new Set([...w?.pluginDeclarations?.map(i=>i.path)??[],...oe(e,w?.files.map(i=>i.path)??[])]),P=w??(c.measureAnalysisSize?ae(e,d.map(i=>i.path),r,{listedPaths:a,agentConfigurations:s}):void 0),k=new Map(P?.files.map(i=>[i.path,i])),l=c.measureAnalysisSize?new Map(t.map(i=>[i.path,i.size])):void 0,n=w?{files:w.files.map(i=>({...i,path:v(i.path,r)})),ownerOf:i=>{let f=w.ownerOf(Y(i,r));return f?{...f,folder:f.key===null?"":v(f.folder,r)}:null}}:void 0,p=new Set(w?.ignoredPaths),h=Re(e,{paths:d.map(i=>v(i.path,r)),scopes:n});return{descriptions:t.flatMap(i=>{if(p.has(i.path))return[];let f=v(i.path,r),u=f===null?{size:i.size}:_t(h,f,i.size),y=$(e,{...i,size:u.size},{...o,purpose:"source",route:"github",scopes:n}),x=f===null?99:vt(e,f,n),S=f!==null&&!g.has(i.path)&&!xt(h,f)&&(te(i.path)||st(e,f,n)||x===0)?"instruction":"code",_={};if(c.measureAnalysisSize){let R=y.admitted||y.reason==="too-large",A=$(e,i,{...o,purpose:"code-scan",route:"github",listing:l}),O=k.get(i.path),F=O&&(y.admitted||["too-large","wrong-type","empty"].includes(y.reason))&&$(e,{path:i.path},{...o,purpose:nt(O.role),route:"github"}).admitted;_.countsTowardAnalysisSize=R||A.admitted||A.reason==="too-large"||!!F,c.measureAnalysisSizeLowerBound&&(_.countsTowardAnalysisSizeWithoutInventory=it(e,i,o),_.countsTowardInstructionSizeWithoutInventory=_.countsTowardAnalysisSizeWithoutInventory&&te(i.path)&&oe(e,[i.path]).length===0),_.analysisPool=O?.role==="skill"||O?.role==="reference"?"instruction":S}return[{entry:i,readEntry:{...i,...u},rel:f,score:x,pool:S,..._,admission:y,...h.enabled&&f!==null?{tier:h.tierOf(f)}:{}}]}),priority:h,declarations:g,discovery:P}}export{q as a,lt as b,ne as c,ct as d,ft as e,se as f,fo as g,ut as h,ko as i,Eo as j,dt as k,Qo as l,wt as m,ae as n,yt as o,bt as p,sn as q,Bt as r,rn as s,Re as t,Yt as u,Jt as v,Vt as w,Pn as x,kn as y,Sn as z,yn as A,bn as B,$n as C};
1
+ import{A as Ue,Aa as He,C as Be,D as Ge,E as Ze,Fb as $,G as we,Gb as lt,H as Ke,Hb as be,I as ee,K as Ye,L as Pe,M as Je,N as ke,O as Se,R as ye,S as Ve,T as V,a as pe,aa as fe,c as Q,d as B,e as he,eb as Qe,g as Me,gb as et,h as Ae,hb as oe,i as I,ib as tt,j as Ne,jb as ot,kb as nt,l as K,n as je,o as Te,ob as st,p as G,q as ze,ra as Xe,s as We,sb as rt,t as J,ub as ue,ya as W,yb as at,z as le,za as te,zb as it}from"./QYYN4YKB.js";import{a as De}from"./MKYLK6DB.js";import{a as z,c as v,e as Y}from"./C6X5GDG4.js";import{a as ie}from"./JS6HTVYX.js";import{a as j,b as C,c as E,e as $e,i as ge,j as Ie,k as T,l as Z,o as Le,v as ce}from"./EJ2IZUN2.js";import{g as qe}from"./ICJV6KIZ.js";function q(e,t,o,c=t,r={}){let a=V(e,t.filter(s=>$(e,{path:s},{purpose:"override",route:"github"}).admitted),{root:o,...r});return _e(a,e,c.some(s=>{let d=v(s,o);return d!==null&&pe(d)}))}function _e(e,t,o=e.scoped.some(c=>pe(c.relativePath))){let c=new Map(e.scoped.map(s=>[s.path,s.relativePath])),r=(s,d,w=!1)=>e.files.find(g=>g.role===s&&g.kind!=="background"&&g.preferred!==!1&&(!d||g.kind===d)&&(!w||g.preferred))?.path??null,a=(s,d,w=!1)=>e.files.filter(g=>g.role===s&&(!d||g.kind===d)&&g.ownerPath!==void 0===w).map(g=>g.path).sort();return{scoped:e.scoped.map(s=>s.path),hasRepositoryGuide:o,developerCompanionPaths:!he(t)&&o?e.scoped.filter(s=>Ct(s.relativePath)).map(s=>s.path):[],stripRoot:s=>c.get(s)??s,configPath:r("marker"),promptPath:r("prompt","dedicated",!0),claudePath:r("prompt","fallback"),toolsPath:r("tool file","json"),toolsTsPath:r("tool file","sdk"),cliPath:r("tool file","cli"),mcpPath:r("MCP config",void 0,!0),registry:e.registry,soulPath:r("soul"),knowledgePath:r("knowledge"),subagentPaths:a("sub-agent"),skillPaths:a("skill"),skillNames:Object.fromEntries(e.files.filter(s=>s.role==="skill"&&s.name).map(s=>[s.path,s.name])),skillRefNames:Object.fromEntries(e.files.filter(s=>s.role==="reference"&&s.kind==="skill"&&s.name).map(s=>[s.path,s.name])),templatePaths:a("reference","template"),skillRefPaths:a("reference","skill"),subagentSkillPaths:a("skill",void 0,!0),subagentSkillRefPaths:a("reference","skill",!0),subagentSkillOwners:Object.fromEntries(e.files.filter(s=>s.ownerPath!==void 0).map(s=>[s.path,s.ownerPath]))}}function ct(e){let t=new Set(e.developerCompanionPaths),o=c=>!t.has(c);return{...e,mcpPath:e.mcpPath&&o(e.mcpPath)?e.mcpPath:null,subagentPaths:e.subagentPaths.filter(o),skillPaths:e.skillPaths.filter(o),subagentSkillPaths:e.subagentSkillPaths.filter(o),subagentSkillRefPaths:e.subagentSkillRefPaths.filter(o),skillRefPaths:e.skillRefPaths.filter(o)}}function ne(e){let t=ct(e);return!!(t.promptPath||t.toolsPath||t.toolsTsPath||t.cliPath||t.mcpPath||t.soulPath||t.knowledgePath||t.subagentPaths.length||t.skillPaths.length)}function Et(e){let t=ct(e);return!!(t.promptPath||t.registry&&t.soulPath||t.subagentPaths.length)}function ft(e,t){return he(e)?ne(t):Et(t)}function Ct(e){return e.toLowerCase()===".mcp.json"||/^\.claude\/(agents|skills)\//i.test(e)}function ut(e,t){return!!e.configPath||!!e.claudePath&&t==="prompt"||ne(e)}var Rt=/^(evals?|evaluations)\/.*\.(jsonl?|ya?ml|md|csv)$|\.eval\.(json|ya?ml)$/i;function Ft(e){return we.exec(e)?.[1]?.toLowerCase()==="commands"&&/\.md$/i.test(e)}function Mt(e){return Rt.test(e)}function X(e,t,o={}){if(!B(e))return!1;if(o.agentConfigurations){if(o.agentConfigurations[z(o.root)]!==!0)return!1;if(o.skills!==!1)return!0}let c=t.flatMap(w=>{let g=v(w,o.root);return g===null?[]:[{path:w,relative:g}]}),r=c.filter(({path:w})=>$(e,{path:w},{purpose:"definition",route:"github",root:o.root}).admitted);if(!r.some(({relative:w})=>Q.includes(w.toLowerCase())))return!1;let a=q(e,r.map(w=>w.path),o.root,t),s=!!(a.subagentPaths.length||a.toolsPath||o.skills!==!1&&a.skillPaths.length),d=r.some(({relative:w})=>Ft(w));return!o.agentConfigurations&&c.some(({relative:w})=>{let g=we.exec(w)?.[1]?.toLowerCase();return!(g==="skills"||(g==="commands"?s:Ne(w)&&(s||d)))&&!it.test(w)&&!at.test(w)&&w.toLowerCase()!==le.toolsSource&&He(w)})?!1:s||d||r.some(({relative:w})=>Mt(w))}function se(e,t,o){let c=new Map([[z(o),[]]]);for(let r of t)v(r,o)!==null&&Q.includes(r.split("/").at(-1).toLowerCase())&&c.set(r.slice(0,Math.max(0,r.lastIndexOf("/"))),[]);for(let r of t){if(v(r,o)===null)continue;let a=r.slice(0,Math.max(0,r.lastIndexOf("/")));for(;c.get(a)?.push(r),!!a;)a=a.slice(0,Math.max(0,a.lastIndexOf("/")))}return Object.fromEntries([...c].map(([r,a])=>[r,X(e,a,{root:r})]))}function uo(e,t){let o=[...new Set([...Object.keys(t.files),...t.listedPaths??[]])],{root:c,skills:r,agentConfigurations:a}=t;if(!X(e,o,{root:c,skills:r,agentConfigurations:a}))return null;let s=q(e,Object.keys(t.files),c,t.listedPaths,{agentConfiguration:!0});return s.claudePath?s:null}import{posix as re}from"node:path";import{posix as At}from"node:path";function xe(e,t=1){let o=new Set,c=[],r=e.replace(/{#[\s\S]*?#}|{%[-+]?\s*raw\s*[-+]?%}[\s\S]*?(?:{%[-+]?\s*endraw\s*[-+]?%}|$)/g,a=>a.replace(/[^\n]/g," "));for(let a of r.matchAll(/{%[-+]?\s*(include|extends|import|from)\s+(.+?)\s*[-+]?%}/g)){let s=a[2].match(/^(["'])([^"']+)\1(?:\s+(?:as\s+\w+|import\s+.+|ignore missing|with context|without context))?$/),d=t+e.slice(0,a.index).split(`
2
+ `).length-1;c.push({source:s?.[2]??a[2],span:{from:d,to:d},...s?{}:{reason:"dynamic"}})}for(let a of r.matchAll(/{{[-+]?\s*([\w]+)|{%[-+]?\s*(?:if|elif|for\s+\w+\s+in|set\s+\w+\s*=)\s+([\w]+)/g)){let s=a[1]??a[2];!["true","false","none"].includes(s.toLowerCase())&&!/^\d/.test(s)&&o.add(s)}return{variables:[...o],loaders:c}}function mt(e,t={}){let o=e.split(`
3
+ `),c=[],r=[],a=(s,d,w)=>{let g=new Set;for(let P of et(s.join(`
4
+ `))){let k=w?`${w}.${P.key}`:P.key,l={from:d+P.span.from,to:d+P.span.to},n=s.slice(P.span.from-1,P.span.to);g.has(P.key)&&r.push({key:k,span:l,reason:"duplicate"}),g.add(P.key);let p=n[0].slice(n[0].indexOf(":")+1).trim();if(!p||p.startsWith("#")){let f=n.slice(1),u=f.find(y=>y.trim()&&!y.trimStart().startsWith("#"))?.match(/^ */)?.[0].length;if(u){a(f.map(y=>y.slice(u)),l.from,k);continue}}let h=Qe(n.join(`
5
+ `))?.[P.key],m=typeof h=="string"?h:null,i=k.endsWith("_template")||Ae(t,"CF_IMPORT_PROMPT_FIELDS")&&k.endsWith("_prompt");(i&&m===null||/^[!&*]/.test(p))&&r.push({key:k,span:l,reason:"invalid"}),c.push({key:k,span:l,text:o.slice(l.from-1,l.to).join(`
6
+ `),value:m,...i&&m!==null?xe(m,l.from+(/^[|>]/.test(p)?1:0)):{variables:[],loaders:[]}})}};a(o,0,"");for(let s of r.filter(d=>d.reason==="duplicate"))for(let d of c.filter(w=>w.key===s.key||w.key.startsWith(`${s.key}.`)))d.value=null;return{fields:c,unresolved:r}}function $t(e,t){let{toks:o}=e,c=[],r=new Map;for(let a=0;a<o.length;a++){if(!ge(o,a))continue;let s=Ie(e.text,o[a]),d=c.findLast(k=>k.indent===s);for(;c.length&&c.at(-1).indent>=s;)c.pop();if(r.set(o[a].line,c.some(k=>!k.guard)?null:c.map(k=>k.guard)),!["if","elif","else","for","while","try","except","with","match","case"].some(k=>E(o[a],k)))continue;let w=a+1;for(;w<o.length&&o[w].line===o[a].line;)w++;let g=C(o[w-1],":"),P=null;if(g&&E(o[a],"else")&&d?.guard&&(P={...d.guard,value:!d.guard.value}),g&&E(o[a],"if")){let k=E(o[a+1],"not"),l=a+(k?2:1),n=o.slice(l,w-1).map(m=>m.text).join(""),p=t.owner(a),h=/^[A-Za-z_]\w*$/.test(n)?n:null;if(/^self\.[A-Za-z_]\w*$/.test(n)){let i=o.flatMap((f,u)=>u<a&&ge(o,u)&&t.owner(u)===p&&o.slice(u,u+3).map(y=>y.text).join("")===n?[u]:[]).at(-1);h=i!==void 0&&C(o[i+3],"=")&&E(o[i+4])&&o[i+5]?.line!==o[i].line?o[i+4].text:null}if(h&&p?.params?.includes(h)&&!t.binding(h,a)){let m=o.findIndex((y,x)=>p.from<x&&x<a&&C(y,"(")),i=m>=0&&T(o,m)<a?Z(o,m).find(y=>E(o[y.from],h)):void 0,f=i&&o.findIndex((y,x)=>i.from<x&&x<i.to&&C(y,"=")),u=f!==void 0&&f>=0&&f+2===i?.to?o[f+1].text:null;P={parameter:h,value:!k,defaultValue:u==="True"?!0:u==="False"?!1:null}}}c.push({indent:s,guard:P}),r.set(o[a].line,null)}return r}function So(e,t,o){let c=j(e,t,"py"),r=ce(c,{includeMembers:!0}),a=fe(c,r,{enclosingBindings:!0}),{toks:s}=c,d=$t(c,a),w=a.assignments.map(h=>["else","try","finally"].includes(h.name)&&E(s[h.from-2])?{...h,name:s[h.from-2].text,at:h.from-2}:h),g=h=>s.slice(h.from,h.to).map(m=>m.kind==="string"?JSON.stringify(m.value):m.text).join(""),P=(h,m,i,f)=>{let u=a.importBinding(h,m);return u?f?!u.namespace&&u.module.source===i&&u.name===f:u.namespace&&u.module.source===i:!1},k=[],l=new Map,n=new Map;for(let h of a.calls.filter(m=>m.callee.endsWith("read_text"))){let m=g(h),i=/^([A-Za-z_]\w*)\.resources\.files\(("(?:[^"\\]|\\.)*")\)\.joinpath\((.*?)\)\.read_text\(\)$/.exec(m)??/^([A-Za-z_]\w*)\.files\(("(?:[^"\\]|\\.)*")\)\.joinpath\((.*?)\)\.read_text\(\)$/.exec(m);if(!i)continue;let f=a.importBinding(i[1],h.from),u=m.startsWith(`${i[1]}.resources.files(`);if(!(f&&(u?f.namespace&&f.name==="importlib"&&["importlib","importlib.resources"].includes(f.module.source):f.namespace&&f.name==="importlib.resources"&&f.module.source==="importlib.resources"||!f.namespace&&f.name==="resources"&&f.module.source==="importlib")))continue;let x=a.calls.find(b=>b.from<h.from&&h.to<b.to&&b.args.length===1&&b.args[0].from===h.from&&b.args[0].to===h.to&&(b.callee.endsWith(".safe_load")&&P(b.callee.split(".")[0],b.from,"yaml")||P(b.callee,b.from,"yaml","safe_load")));if(!x)continue;let S=JSON.parse(i[2]),_;try{_=JSON.parse(i[3])}catch{}let R=null,A;if(typeof _!="string"||!/^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/.test(S))A="dynamic";else if(At.isAbsolute(_)||/[\\\0]/.test(_)||_.split("/").includes(".."))A="out-of-scope";else{let b=`${S.replaceAll(".","/")}/${_}`,N=e.indexOf(`${S.split(".")[0]}/`),L=N>=0?e.slice(0,N)+b:null,D=[...o].filter(H=>H===b||H.endsWith(`/${b}`));R=L??(D.length===1?D[0]:null),R?o.has(R)||(A="missing"):A=D.length>1?"dynamic":"missing"}let O=w.find(b=>b.from<=x.from&&x.from<b.to&&a.owner(b.at)===a.owner(x.from)),F={path:R,source:typeof _=="string"?_:i[3],span:{from:s[h.from].line,to:s[h.to-1].endLine},start:s[x.from].start,end:s[x.to-1].end,binding:O?.name??null,forwarded:!1,when:d.get(s[O?.at??h.from].line)??null,className:r.filter(b=>b.kind==="class"&&b.from<h.from&&h.from<b.to).at(-1)?.name??null,...A?{reason:A}:{}};k.push(F),O&&(l.set(F,O),n.set(O,x))}let p=new Set([...l.values()].filter(h=>{let m=n.get(h);return(E(s[h.from],h.name)&&E(s[h.from+1],"or")?h.from+2:h.from)===m.from&&(h.to===m.to||h.to+1===m.to&&C(s[h.to],")"))}));for(let h of k){let m=l.get(h);!m||!p.has(m)||a.owner(m.at)?.name!=="__init__"||(h.forwarded=a.calls.some(i=>a.owner(i.from)===a.owner(m.at)&&s[i.from].start>h.end&&E(s[i.from],"super")&&i.callee.endsWith("__init__")&&i.args.some(f=>E(s[f.from],m.name)&&C(s[f.from+1],"=")&&f.to===f.from+3&&E(s[f.from+2],m.name))&&w.filter(f=>f.name===m.name&&m.at<f.at&&f.at<i.from&&a.owner(f.at)===a.owner(m.at)).every(f=>p.has(f))&&!s.some((f,u)=>u<i.from&&f.start>=h.end&&E(f,m.name)&&a.owner(u)===a.owner(m.at)&&![...p].some(y=>y.at<=u&&u<n.get(y).to))))}return k}function dt(e,t){if(!I(e))return[];let o=new Set(t),c=[];for(let r of[...o].sort()){let a=r.match(/^((?:[^/]+\/)*?)(?:src\/)?minisweagent\/agents\/default\.py$/);if(!a)continue;let s=r.slice(0,-18),d=`${s}/config`,w=`${d}/__init__.py`,g=`${s}/run/mini.py`;if(!o.has(w)||!o.has(g))continue;let P=[...o].filter(k=>v(k,d)!==null&&/\.ya?ml$/.test(k)).sort();P.length&&c.push({folder:a[1].replace(/\/$/,""),configFolder:d,agentPath:r,loaderPath:w,runnerPath:g,configs:P,templates:[...o].filter(k=>v(k,d)!==null&&/\.(?:j2|jinja2?)$/.test(k)).sort()})}return c}function It(e,t){let o=j(e.agentPath,t[e.agentPath]??"","py").toks,c=j(e.loaderPath,t[e.loaderPath]??"","py").toks,r=j(e.runnerPath,t[e.runnerPath]??"","py").toks;if(!["system_template","instance_template"].every(s=>o.some((d,w)=>E(d,s)&&C(o[w-1],".")))||!c.some((s,d)=>E(s,"safe_load")&&C(c[d+1],"("))||!c.some((s,d)=>E(s,"read_text")&&C(c[d+1],"("))||!r.some((s,d)=>E(s,"get_config_from_spec")&&C(r[d+1],"("))||!r.some((s,d)=>E(s,"get_agent")&&C(r[d+1],"("))||!r.some((s,d)=>E(s,"get")&&C(r[d+1],"(")&&r[d+2]?.value==="agent"))return null;let a=r.flatMap((s,d)=>{if(!E(s,"DEFAULT_CONFIG_FILE")||!C(r[d+1],"="))return[];let w=r.slice(d+2).filter(g=>g.line===s.line);return w.flatMap((g,P)=>E(g,"builtin_config_dir")&&C(w[P+1],"/")&&w[P+2]?.kind==="string"?[re.join(e.configFolder,w[P+2].value)]:[])});return a.length===1?a[0]:null}function Co(e,t,o,c){let r={variants:[],selectedPaths:[],fields:[],model:null,loaded:[],unresolved:[],edges:[]};if(!I(e))return r;let a=It(t,o);if(!a)return r.unresolved.push({path:t.runnerPath,source:"config",reason:"dynamic"}),r;let s=new Map,d=new Set(Object.keys(o)),w=l=>{let n=$(e,{path:l,text:o[l],size:o[l]===void 0?void 0:Buffer.byteLength(o[l])},{purpose:"pointer",route:"github",root:t.configFolder,listing:d,managedFiles:o});return n.admitted||s.set(l,n.reason),n.admitted},g=new Map([...new Set([...t.configs,...c??[]])].flatMap(l=>w(l)&&Object.hasOwn(o,l)?[[l,mt(o[l],e)]]:[]));r.variants=t.configs.map(l=>({path:l,fields:(g.get(l)?.fields??[]).map(n=>({...n,path:l}))})),r.selectedPaths=c?[...c]:[a];let P=new Map;for(let l of r.selectedPaths){if(v(l,t.configFolder)===null){r.unresolved.push({path:l,source:l,reason:"out-of-scope"});continue}let n=g.get(l);if(!n){r.unresolved.push({path:l,source:l,reason:s.get(l)??"missing"});continue}r.unresolved.push(...n.unresolved.map(p=>({path:l,source:p.key,span:p.span,reason:p.reason})));for(let p of n.fields)if(/^(?:agent|model|environment)(?:\.|$)/.test(p.key)){for(let h of P.keys())(h.startsWith(`${p.key}.`)||p.key.startsWith(`${h}.`))&&P.delete(h);P.set(p.key,{...p,path:l})}}r.fields=[...P.values()],r.model=P.get("model.model_name")?.value??null;let k=new Set;for(let l of r.fields){let n=new Set([l.path]),p=[{path:l.path,facts:{variables:l.variables,loaders:l.loaders},next:0}];for(;p.length;){let h=p.at(-1),{path:m,facts:i}=h;if(h.next===0)for(let x of i.variables)r.unresolved.push({path:m,source:x,reason:"runtime-variable"});if(h.next>=i.loaders.length){n.delete(m),p.pop();continue}let f=i.loaders[h.next++],u=re.normalize(re.join(re.dirname(m),f.source)),y=f.reason??(re.isAbsolute(f.source)||v(u,t.configFolder)===null?"out-of-scope":w(u)?n.has(u)?"cycle":Object.hasOwn(o,u)?null:"missing":s.get(u));if(y){r.unresolved.push({path:m,source:f.source,...f.reason?{}:{target:u},span:f.span,reason:y});continue}r.edges.push({from:m,to:u,span:f.span}),!k.has(u)&&(k.add(u),r.loaded.push({path:u}),n.add(u),p.push({path:u,facts:xe(o[u]),next:0}))}}return r}import{posix as me}from"node:path";function Ee(e){return/(?:^|\/)(?:(?:[^/]+_)?(?:crew|agents|tasks))\.py$/i.test(e)}function pt(e,t,o,c=""){let r=j(e,t,"py"),{toks:a}=r,s=ce(r,{includeMembers:!0}),d=Le(r),w=fe(r,s,{enclosingBindings:!0}),g={agents:[],tasks:[],refused:[]},P=l=>s.filter(n=>n.from<=l&&l<n.to),k=l=>{if(!E(a[l])||C(a[l-1],".")||!C(a[l+1],"("))return null;let n=w.importBinding(a[l].text,l);return n?.module.source==="crewai"&&["Agent","Task"].includes(n.name)?n.name:null};for(let l=0;l<a.length;l++){let n=k(l);if(!n)continue;let p=T(a,l+1);if(p>=a.length){g.refused.push({path:e,reason:"invalid"});continue}let h=P(l),m=h.filter(O=>O.kind==="class").at(-1),i=h.filter(O=>O.params!==null).at(-1),f=h.filter(O=>O.params===null&&O.kind!=="class"&&O.kind!=="index").at(-1),u=i?.name??f?.name??`line-${a[l].line}`,y=m?`${m.name}.${u}`:u,x=h.some(O=>O.kind==="index")||g.agents.some(O=>O.factory===y)?`${y}@${a[l].start}`:y,S=new Map(Z(a,l+1).flatMap(O=>E(a[O.from])&&C(a[O.from+1],"=")?[[a[O.from].text,{from:O.from+2,to:O.to}]]:[])),_={path:e,factory:x,span:{from:a[l].line,to:a[p].endLine},callStart:a[l].start},R=S.get("config");if(R){let O=a.slice(R.from,R.to).map(b=>b.kind==="string"?JSON.stringify(b.value):b.text).join(""),F=/^(?:self\.)?(agents_config|tasks_config)\["([^"\n]+)"\]$/.exec(O);if(F){let b=s.filter(M=>M.name===F[1]&&M.params===null&&(m?m.from<M.from&&M.to<=m.to&&!s.some(U=>U.params!==null&&U.from<M.from&&M.from<U.to):!s.some(U=>U.kind==="class"&&U.from<M.from&&M.from<U.to))),N=b.length===1?ht(r,b[0]):void 0,L=m&&Nt(r,m,w),D=N?ve(r,N):b.length===0&&L?`config/${F[1]==="agents_config"?"agents":"tasks"}.yaml`:null,H=null;if(D===null||/[\\\0${}*]/.test(D))g.refused.push({path:e,reason:"dynamic"});else{let M=me.normalize(me.join(me.dirname(e),D));D.startsWith("/")||M===".."||M.startsWith("../")||v(M,c)===null?g.refused.push({path:M,reason:"out-of-scope"}):o.has(M)?H=M:g.refused.push({path:M,reason:"missing"})}_.config={path:H,key:F[2]}}else _.config={path:null,key:""},g.refused.push({path:e,reason:"dynamic"})}let A=Oe(r,S.get("tools"),o,s,i,m,g.refused,w);if(n==="Agent"){let O=Object.fromEntries(["role","goal","backstory"].flatMap(F=>{let b=S.get(F)&&ve(r,S.get(F));return S.has(F)&&b==null&&g.refused.push({path:e,reason:"dynamic"}),b==null?[]:[[F,b]]}));g.agents.push({..._,instructions:O,tools:A})}else{let O=L=>Lt(r,L,m,s,d),F=O(S.get("agent")),b=S.get("context"),N=b&&C(a[b.from],"[")&&T(a,b.from)===b.to-1?Z(a,b.from):[];b&&(!C(a[b.from],"[")||N.some(L=>!O(L)))&&g.refused.push({path:e,reason:"dynamic"}),S.has("agent")&&!F&&g.refused.push({path:e,reason:"dynamic"}),g.tasks.push({..._,agent:F,context:N.flatMap(L=>O(L)??[]),tools:A})}l=p}return g}function ht(e,t){let o=t.from+1;for(;o<t.to&&!C(e.toks[o],"=");)o++;return o<t.to?{from:o+1,to:t.to}:void 0}function ve(e,t){let{toks:o}=e;return t.to===t.from+1&&o[t.from]?.kind==="string"&&$e(o[t.from]).closed?o[t.from].value:E(o[t.from],"dedent")&&C(o[t.from+1],"(")&&T(o,t.from+1)===t.to-1?ve(e,{from:t.from+2,to:t.to-1}):null}function Lt(e,t,o,c,r){if(!t)return null;let a=e.toks.slice(t.from,t.to).map(d=>d.text).join(""),s=/^(self\.)?([A-Za-z_]\w*)(?:\(\))?$/.exec(a);if(s&&!s[1]){let d=c.filter(g=>g.params!==null&&g.from<t.from&&t.from<g.to),w=g=>c.filter(P=>P.params!==null&&P.from<g&&g<P.to).at(-1);if(d.some(g=>g.params?.includes(s[2]))||c.some(g=>g.name===s[2]&&d.includes(w(g.from)))||r.some(g=>g.names.includes(s[2])&&d.includes(w(e.toks.findIndex(P=>P.line===g.line)))))return null}return s?s[1]&&o?`${o.name}.${s[2]}`:s[2]:null}function Oe(e,t,o,c,r,a,s,d,w=new Set){if(!t)return[];let{toks:g}=e;if(C(g[t.from],"[")&&T(g,t.from)===t.to-1)return Z(g,t.from).flatMap(u=>Oe(e,u,o,c,r,a,s,d,new Set(w)));let P=g[t.from];if(!E(P)||w.has(P.text))return s.push({path:e.path,reason:"dynamic"}),[];if(w.add(P.text),r?.params?.includes(P.text))return s.push({path:e.path,reason:"dynamic"}),[];let l=c.filter(u=>u.name===P.text&&u.params===null&&u.kind!=="class"&&u.from<t.from).filter(u=>{let y=c.filter(x=>(x.params!==null||x.kind==="class")&&x.from<u.from&&u.from<x.to).at(-1);return!y||y===r||!r&&y===a}),n=r&&l.filter(u=>r.from<u.from&&u.to<=r.to),p=n&&n.length?n:l;if(p.length===1){let u=ht(e,p[0]);if(u)return Oe(e,u,o,c,r,a,s,d,w)}if(p.length>1)return s.push({path:e.path,reason:"dynamic"}),[];let h=d.importBinding(P.text,t.from),m=h?.module,i=null;if(m){let u=me.dirname(e.path).split("/"),y=u.lastIndexOf(m.source.split(".")[0]),x=m.source.startsWith(".")?m.source:y<0?`.${m.source}`:".".repeat(u.length-y)+m.source.split(".").slice(1).join(".");i=qe(e.path,x,[h.name],"py",o)??null,!i&&(m.source.startsWith(".")||y>=0)&&s.push({path:e.path,reason:"missing"})}else if(!c.some(u=>u.name===P.text&&(u.kind==="class"||u.params!==null)))return s.push({path:e.path,reason:"dynamic"}),[];let f=t.from+1;for(;C(g[f],".")&&E(g[f+1]);)f+=2;return f<t.to&&(!C(g[f],"(")||T(g,f)!==t.to-1)?(s.push({path:e.path,reason:"dynamic"}),[]):[{name:g.slice(t.from,f).map(u=>u.text).join(""),path:m?i:e.path}]}function Nt(e,t,o){let c=e.text.slice(0,e.toks[t.from].start).trimEnd().split(`
7
+ `);for(let r=c.length-1;r>=0;r--){let a=/^\s*@([A-Za-z_]\w*)(?:\(\))?\s*$/.exec(c[r]);if(!a)break;let s=o.importBinding(a[1],t.from);if(s?.module.source==="crewai.project"&&s.name==="CrewBase")return!0}return!1}var Dt=new Set([...Ue,le.soul].map(e=>e.toLowerCase())),jt=["templates","default_prompts","prompts/default","docs","evals","benchmarks"],Tt=["tests","__tests__","fixtures","test_data","evals","benchmarks","templates","default_prompts","prompts/default","docs"];function wt(e,t=""){return e===t?null:`folder:${e}`}function en(e,t,o){let c=Pt(e,t,o),r=z(o),a=t.filter(n=>!G(e,n,r)),s=a.filter(n=>c.ownerOf(n)?.key===null),d=q(e,s,r),w=ne(d)||!!d.configPath,g=V(e,s,{root:r}).files.filter(n=>n.role!=="reference"&&n.kind!=="background"),P=new Set(g.map(n=>n.relativePath)),k=g.flatMap(n=>n.role==="sub-agent"?[n.relativePath.slice(0,-3)]:n.role==="skill"?[n.relativePath.slice(0,n.relativePath.lastIndexOf("/"))]:[]),l=new Map(c.scopes.map(n=>[n.folder,{scope:n,paths:[]}]));for(let n of[...new Set(a)]){let p=c.ownerOf(n);if(!p)continue;let h=v(n,r),m=h.split("/");if(p.key===null&&w&&m.length>1&&!P.has(h)&&!k.some(i=>v(h,i)!==null)){let i=m.slice(0,-1).findIndex((u,y)=>![...P].some(x=>x.startsWith(`${m.slice(0,y+1).join("/")}/`))),f=Y(m.slice(0,i<0?-1:i+1).join("/"),r);l.has(f)||l.set(f,{scope:{key:wt(f,r),folder:f,kind:"folder"},paths:[]}),p=l.get(f).scope}l.get(p.folder).paths.push(n)}return[...l.values()].sort((n,p)=>n.scope.folder<p.scope.folder?-1:n.scope.folder>p.scope.folder?1:0).map(({scope:n,paths:p})=>{let h=q(e,p,n.folder),m=c.scopes.includes(n);return{scope:n,paths:p,convention:m&&(!!n.managed||!!n.miniSwe||n.kind==="crew"&&!n.agentsPath.endsWith(".py")||ft(e,h)),markerPath:m?h.configPath:null}})}function Pt(e,t,o,c={},r){let a=z(o);r??=B(e)?se(e,t,o):void 0;let s=K(e),d=tt(e,t,c),{scopes:w,skipped:g,pluginFolders:P}=s?zt(e,t,a,d,r):{scopes:[{key:null,folder:a,kind:"root"}],skipped:[],pluginFolders:[]},k=m=>kt(w,m),l=new Set(t),n=t.filter(m=>G(e,m,a)||k(m)&&(s&&ue(e,m,P)||Te(e,m,{root:a,listing:l}))),p=new Set(I(e)?Object.entries(c).filter(([m])=>m.endsWith(".py")&&k(m)).flatMap(([m,i])=>pt(m,i,new Set(t),a).agents.flatMap(f=>f.tools.flatMap(u=>u.path??[]))):[]),h=s?t.filter(m=>{let i=k(m);return!p.has(m)&&i?.kind==="crew"&&v(m,i.folder)?.toLowerCase().startsWith("tools/")}):[];return{scopes:w,skipped:g,ownerOf:k,pluginFolders:P,ignoredPaths:n,ignoredImportPaths:h,...d.length?{pluginDeclarations:d.filter(m=>P.includes(m.folder))}:{}}}function kt(e,t){return e.findLast(o=>v(t,o.folder)!==null)??null}function zt(e,t,o,c,r){let a=[...new Set(t)].filter(l=>!ue(e,l)).sort().flatMap(l=>{let n=v(l,o);return n===null?[]:[{path:l,relativePath:n}]}),s=[],d=new Map,w=a.filter(l=>!G(e,l.path,o)).map(l=>l.path);for(let l of nt(e,w))d.set(l.folder,l.agents.map(n=>({path:n,plugin:!1,crew:!1,checkPath:`${l.folder}/`,managed:l})));for(let l of dt(e,w))d.set(l.folder,[...d.get(l.folder)??[],{path:l.agentPath,plugin:!1,crew:!1,checkPath:`${l.folder}/`,miniSwe:l}]);for(let{path:l,relativePath:n}of a){let p=n.split("/"),h=p.pop().toLowerCase(),m=Y(p.join("/"),o),i=p.length>0&&(Dt.has(h)||Q.includes(h)&&X(e,t,{root:m,agentConfigurations:r})),f=ot(e,l,c);f===o&&!G(e,l,o)&&!s.includes(o)&&s.push(o);let u=f!==null&&f!==o&&!!v(`${f}/`,o),y=n.toLowerCase()==="config/agents.yaml"||n.toLowerCase().endsWith("/config/agents.yaml"),x=I(e)&&Ee(l)&&!/(?:^|\/)(?:tasks|[^/]+_tasks)\.py$/i.test(l),S=y||x;if(!i&&!u&&!S)continue;let _=y?l.slice(0,-18).replace(/\/$/,""):x?l.slice(0,Math.max(0,l.lastIndexOf("/"))):u?f:Y(p.join("/"),o),R=d.get(_)??[];R.push({path:l,plugin:u,crew:S,checkPath:u?`${_}/`:l}),d.set(_,R)}let g=We(e),P={settings:e,folder:o,scoped:a,candidates:d,rootPlugins:s,excludedFolders:g?jt:Tt},k=gt(P,new Set);if(g){let l=[...new Set(k.accepted.map(i=>i.folder))].filter(i=>i!==o),n=a.filter(i=>!G(e,i.path,o)&&!l.some(f=>v(i.path,f)!==null)).map(i=>i.path),p=V(e,n,{root:o,folderAgentsFound:l.length>0,agentConfiguration:X(e,t,{root:o,agentConfigurations:r})}),h=St(e,p,l.length>0)?[{path:`${o}/`,checkPath:`${o}/`}]:[],m=ze([...k.accepted,...h],i=>i.checkPath,{root:o,listing:new Set(a.map(i=>i.path)),settings:e});if(k.accepted.some(i=>m(i.checkPath))){let i=new Set([...d.values()].flat().filter(f=>m(f.checkPath)).map(f=>f.path));k=gt(P,i)}}return k.skipped.sort((l,n)=>l.path<n.path?-1:l.path>n.path?1:0),{scopes:k.scopes,skipped:k.skipped,pluginFolders:k.pluginFolders}}function gt({settings:e,folder:t,scoped:o,candidates:c,rootPlugins:r,excludedFolders:a},s){let d=[{key:null,folder:t,kind:"root"}],w=[],g=[...r],P=[],k=new Map;for(let l of[...c.keys()].sort()){let n=c.get(l),p=kt(d,n[0].path),h=k.get(p.folder)??Wt(o.map(S=>S.path),p.folder);k.set(p.folder,h);let m=[];for(let S of n){let{path:_,checkPath:R}=S;if(ue(e,_,g))continue;let A=G(e,_,t)?"excluded-folder":l===t?null:s.has(_)?"excluded-folder":Ut(v(R,t),v(R,p.folder),h,je(e,_,t)?[]:a);A?w.push({path:_,reason:A}):(m.push(S),P.push({path:_,folder:l,checkPath:R}))}if(!m.length)continue;let i=(I(e)?m.find(S=>S.crew&&S.path.endsWith("config/agents.yaml")):void 0)??m.find(S=>S.crew),f=wt(l,t),u=i?{key:f,folder:l,kind:"crew",agentsPath:i.path,tasksPath:o.find(S=>v(S.path,l)?.toLowerCase()==="config/tasks.yaml")?.path??null}:{key:f,folder:l,kind:"folder"},y=m.find(S=>S.managed)?.managed;y&&(u.managed=y);let x=m.find(S=>S.miniSwe)?.miniSwe;x&&(u.miniSwe=x),l===t?d[0]=u:d.push(u),m.some(S=>S.plugin)&&!g.includes(l)&&g.push(l)}return{scopes:d,skipped:w,pluginFolders:g,accepted:P}}function ae(e,t,o,c={}){let r=c.agentConfigurations??(B(e)?se(e,c.listedPaths??t,o):void 0),a=Pt(e,t,o,c.files,r),{scopes:s,ownerOf:d,ignoredPaths:w}=a,g=new Set(w),P=new Map(s.map(i=>[i,[]]));for(let i of t){if(g.has(i))continue;let f=d(i);f&&P.get(f).push(i)}let k=s.map(i=>V(e,P.get(i),{root:i.folder,mode:c.mode,agentConfiguration:X(e,c.listedPaths??t,{root:i.folder,agentConfigurations:r}),folderAgentsFound:i.key===null&&(s.length>1||i.kind==="crew")})),l=(i,f)=>St(e,i,s[f].key===null&&(s.length>1||s[f].kind==="crew")),n=s.length===1?k:k.filter((i,f)=>s[f].managed||s[f].miniSwe||s[f].kind==="crew"||l(i,f)),p=!n.length||n.some(i=>{let f=k.indexOf(i);return s[f].managed||s[f].miniSwe?!1:s[f].kind==="crew"&&!l(i,f)?s[f].agentsPath.endsWith(".py"):!i.registry&&(!i.files.some(u=>u.role==="prompt")||!i.files.some(u=>u.role==="tool file"))}),h=new Set((a.pluginDeclarations??[]).map(i=>i.path));for(let i of oe(e,t))/marketplace\.json$/i.test(i)&&h.add(i);let m=k.flatMap((i,f)=>{let u=s[f],y=[...h].filter(S=>!g.has(S)&&d(S)===u).map(S=>({path:S,relativePath:v(S,u.folder),role:"marker",kind:"entry"}));if(u.miniSwe)return[...i.files,...y,...[...u.miniSwe.configs,...u.miniSwe.templates,u.miniSwe.agentPath,u.miniSwe.loaderPath,u.miniSwe.runnerPath].map(S=>({path:S,relativePath:v(S,u.folder),role:"knowledge",kind:"entry"}))];if(u.managed)return[...[...u.managed.agents,...u.managed.configs].flatMap(S=>{let _=J(v(S,u.folder))?.definition;if(_&&(c.mode==="core"||!Ye(e)))return[];let R=u.managed.agents.includes(S);return[{path:S,relativePath:v(S,u.folder),role:R?"prompt":_?"skill":"knowledge",kind:R?"entry":_?"skill":"json"}]}),...y];if(u.kind!=="crew")return[...i.files,...y];let x=[{path:u.agentsPath,relativePath:v(u.agentsPath,u.folder),role:"prompt",kind:"entry"}];if(I(e))for(let S of P.get(u)){let _=v(S,u.folder);S!==u.agentsPath&&(Ee(_)&&!_.includes("/")||/^config\/[^/]+\.ya?ml$/i.test(_))&&x.push({path:S,relativePath:_,role:"knowledge",kind:"entry"})}return u.tasksPath&&x.push({path:u.tasksPath,relativePath:v(u.tasksPath,u.folder),role:"knowledge",kind:"entry"}),[...i.files,...x,...y]});return{...a,files:m,needsExtraction:p}}function St(e,t,o){let c=_e(t,e),r=Me({codeAgentsFound:!1,folderAgentsFound:o,otherDefinitions:ne(c),agentConfiguration:t.files.some(a=>a.role==="prompt"&&a.kind==="fallback")},e);return ut(c,r)}function Wt(e,t){let o=new Set;for(let c of e){let r=v(c,t);r!==null&&ee.test(r)&&o.add(r.slice(0,-3).toLowerCase())}return o}function Ut(e,t,o,c){let r=e.toLowerCase();if(c.some(d=>`/${r}`.includes(`/${d}/`)))return"excluded-folder";let a=r.slice(0,r.lastIndexOf("/"));if(J(e,{nested:!0})||Ke.some(d=>a===d||a.endsWith(`/${d}`)))return"skill-folder";if(`/${r}`.includes(`/${Ge}/${Ze}/`)||ee.test(t))return"sub-agent-folder";let s=t.toLowerCase().split("/");return s.some((d,w)=>o.has(s.slice(0,w).join("/")))?"sub-agent-folder":null}var yt="Some of this agent's files weren't read, so findings may be missing.";var bt=e=>e.CF_READING_PRIORITY!=="0";var Bt=new Set(["system prompt","soul","knowledge","config","tools","mcp"]);function _t(e){let t=new Set;for(let c of e.nodes)for(let r of c.files??[])Bt.has(r.role)&&t.add(r.path);let o=new Set(e.edges.filter(c=>c.kind==="delegates").map(c=>c.to));for(let c of e.nodes)o.has(c.id)&&c.sourceRef&&t.add(c.sourceRef.path);return t}function an(e){return new Set([...e.nodes,...e.edges].flatMap(t=>t.sourceRef?[t.sourceRef.path]:[]))}var de=6e4,Gt=e=>{if(e.length<=de)return e;let t=e.endsWith(be)?be:"";return(t?e.slice(0,-t.length):e).slice(0,de)+t};function ln(e,t){let o=[...e].filter(c=>t[c]!==void 0&&Gt(t[c])!==t[c]).sort();return o.length===0?null:`${o.length} ${ie(o.length,"core file was","core files were")} longer than ${de/1e3} KB, so only the first ${de/1e3} KB was read: ${o.join(", ")}`}var Ce=e=>e.split("/").slice(0,-1).join("/"),Zt=/(agent|prompt|tool|llm|model)/i,Kt=2.5;function Fe(e,t){if(!bt(e))return{enabled:!1,tierOf:()=>6};if(t.repos?.some(n=>n.kind==="github"&&z(n.root)))return Yt(e,t,t.repos);let o=t.scopes??(K(e)?ae(e,t.paths,void 0,{agentConfigurations:{}}):void 0),c=t.graph?_t(t.graph):new Set,r=new Set(t.graph?.nodes.flatMap(n=>(n.files??[]).filter(p=>p.role==="code"&&W(p.path)).map(p=>p.path))??[]),a=new Set(t.graph?.nodes.flatMap(n=>(n.files??[]).filter(p=>p.role==="system prompt").map(p=>p.path))??[]),s=n=>te(n)&&(Be.includes(n.split("/").pop().toLowerCase())||/(^|\/)system_prompt_[^/]+\.md$/i.test(n)||Ve.test(n)),d=n=>{if(c.has(n))return 1;if(r.has(n))return 2;let p=ke(e,n,o),h=J(p,{nested:!0});if(h?.reference)return 5;if(h?.definition||ee.test(p))return 4;if(h||/(^|\/)(docs?|references)\//i.test(p)||Je.test(n.split("/").pop()))return 5;if(Pe(p)||Se(e,n,o)&&Pe(n.split("/").pop())||s(n))return 1;if(W(n)){if(Zt.test(n))return Kt;if(ye.test(n))return 3}return 6};for(let n of t.paths)d(n)===1&&s(n)&&a.add(n);let w=[...a].flatMap(n=>{let p=Ce(n);return[p,...p?[Ce(p)]:[]]}),g=n=>W(n)&&w.some(p=>Ce(n)===p),P=new Map(t.paths.map(n=>{let p=d(n);return[n,p>2&&g(n)?2:p]})),k=[...P].filter(([n,p])=>p<=2&&W(n)).map(([n])=>n),l=Xe(Object.fromEntries(k.flatMap(n=>t.files?.[n]===void 0?[]:[[n,t.files[n]]])),t.paths);for(let n of l)W(n)&&!J(ke(e,n,o),{nested:!0})&&(P.get(n)??6)>2&&P.set(n,2);return{enabled:!0,tierOf:n=>P.get(n)??d(n)}}function Yt(e,t,o){let c=new Map;for(let r of o){let a=r.kind==="github"?r.root:void 0,s=t.paths.filter(n=>r.files?.[n]!==void 0&&!c.has(n)),d=n=>v(n,a)??(r.files?.[n]!==void 0?n:null),w=n=>{let p=n?d(n.path):null;return p===null?null:{path:p}},g=t.graph&&{nodes:t.graph.nodes.map(n=>({...n,sourceRef:w(n.sourceRef),files:n.files?.flatMap(p=>{let h=d(p.path);return h===null?[]:[{...p,path:h}]})})),edges:t.graph.edges.map(n=>({...n,sourceRef:w(n.sourceRef)}))},P=s.flatMap(n=>{let p=d(n);return p===null?[]:[p]}),k=Object.fromEntries(s.flatMap(n=>{let p=d(n);return p===null||t.files?.[n]===void 0?[]:[[p,t.files[n]]]})),l=Fe(e,{paths:P,files:k,graph:g});for(let n of s)c.set(n,l.tierOf(d(n)??n))}return{enabled:!0,tierOf:r=>c.get(r)??6}}function Jt(e,t){return e.enabled?t.filter(o=>["too-large","total","allowance"].includes(o.reason)&&e.tierOf(o.path)<3).map(o=>o.path):[]}function Vt(e){return e.slice(0,3)}function qt(e,t=!1){let o=Vt(e);if(!o.length)return;let c=t?". "+yt:", so some findings may be missing";return`${o.join(", ")} ${ie(o.length,"was","were")} left out${c}`}function yn(e,t){return qt(Jt(e,t))}function bn(e,t){return e.enabled&&e.tierOf(t)<3}function xt(e,t,o){let c=De.sourceFetch.codeFileBytes;return e.enabled&&e.tierOf(t)<3&&W(t)&&o>c?{size:c,readBytes:c}:{size:o}}function vt(e,t){return e.enabled&&e.tierOf(t)<3&&W(t)}function Re(e){return e.split("/").length-1}function Ot(e,t,o){return Se(e,t,o)?0:ye.test(t)?1+Math.min(Re(t),3)/10:Re(t)<=2?2:Re(t)<=4?3:4}function _n(e,t){return(e.tier??0)-(t.tier??0)||e.score-t.score||e.size-t.size}function xn(e,t,o,c){return[...e].sort((r,a)=>(c?.enabled?c.tierOf(r)-c.tierOf(a):0)||Number(o.has(a))-Number(o.has(r))||t[r].length-t[a].length||(r<a?-1:1))}function vn(e,t,o,c){return[...e].sort((r,a)=>(c?.enabled?c.tierOf(r.path)-c.tierOf(a.path):0)||Number(t.has(a.path))-Number(t.has(r.path))||Number(o.has(a.path))-Number(o.has(r.path))||r.text.length-a.text.length)}function Nn(e,t,o={},c={}){let{root:r}=o,a=t.map(i=>i.path),s=B(e)?se(e,a,r):void 0,d=t.filter(i=>{let f=$(e,i,{...o,purpose:"source",route:"github"});return f.admitted||f.reason==="wrong-type"||f.reason==="too-large"}),w=K(e)?ae(e,d.map(i=>i.path),r,{files:c.files,listedPaths:a,agentConfigurations:s}):void 0,g=new Set([...w?.pluginDeclarations?.map(i=>i.path)??[],...oe(e,w?.files.map(i=>i.path)??[])]),P=w??(c.measureAnalysisSize?ae(e,d.map(i=>i.path),r,{listedPaths:a,agentConfigurations:s}):void 0),k=new Map(P?.files.map(i=>[i.path,i])),l=c.measureAnalysisSize?new Map(t.map(i=>[i.path,i.size])):void 0,n=w?{files:w.files.map(i=>({...i,path:v(i.path,r)})),ownerOf:i=>{let f=w.ownerOf(Y(i,r));return f?{...f,folder:f.key===null?"":v(f.folder,r)}:null}}:void 0,p=new Set(w?.ignoredPaths),h=Fe(e,{paths:d.map(i=>v(i.path,r)),scopes:n});return{descriptions:t.flatMap(i=>{if(p.has(i.path))return[];let f=v(i.path,r),u=f===null?{size:i.size}:xt(h,f,i.size),y=$(e,{...i,size:u.size},{...o,purpose:"source",route:"github",scopes:n}),x=f===null?99:Ot(e,f,n),S=f!==null&&!g.has(i.path)&&!vt(h,f)&&(te(i.path)||rt(e,f,n)||x===0)?"instruction":"code",_={};if(c.measureAnalysisSize){let R=y.admitted||y.reason==="too-large",A=$(e,i,{...o,purpose:"code-scan",route:"github",listing:l}),O=k.get(i.path),F=O&&(y.admitted||["too-large","wrong-type","empty"].includes(y.reason))&&$(e,{path:i.path},{...o,purpose:st(O.role),route:"github"}).admitted;_.countsTowardAnalysisSize=R||A.admitted||A.reason==="too-large"||!!F,c.measureAnalysisSizeLowerBound&&(_.countsTowardAnalysisSizeWithoutInventory=lt(e,i,o),_.countsTowardInstructionSizeWithoutInventory=_.countsTowardAnalysisSizeWithoutInventory&&te(i.path)&&oe(e,[i.path]).length===0),_.analysisPool=O?.role==="skill"||O?.role==="reference"?"instruction":S}return[{entry:i,readEntry:{...i,...u},rel:f,score:x,pool:S,..._,admission:y,...h.enabled&&f!==null?{tier:h.tierOf(f)}:{}}]}),priority:h,declarations:g,discovery:P}}export{q as a,ct as b,ne as c,ft as d,ut as e,se as f,uo as g,mt as h,So as i,Co as j,pt as k,en as l,Pt as m,ae as n,bt as o,_t as p,an as q,Gt as r,ln as s,Fe as t,Jt as u,Vt as v,qt as w,yn as x,bn as y,_n as z,xn as A,vn as B,Nn as C};
@@ -1,2 +1,2 @@
1
- import{b as L}from"./SJESFYBA.js";function C(e,o,i){let t=L(o,i).filter(n=>n.kind!=="comment");return{path:e,text:o,lang:i,toks:t}}function u(e,o){return e?.kind==="punct"&&e.text===o}function f(e,o){return e?.kind==="ident"&&(o===void 0||e.text===o)}function w(e){return e?.kind==="string"||e?.kind==="template"}function Nt(e){let o=/^[A-Za-z]*/.exec(e.text)[0],i=e.text.slice(o.length),t=i[0]??"",n=i.startsWith(t.repeat(3))&&i.length>=6?3:1,s=i.length>=2*n&&i.endsWith(t.repeat(n));if(s){let l=0;for(let r=i.length-n-1;r>=0&&i[r]==="\\";r--)l++;s=l%2===0}return{prefix:o,width:n,inner:i.slice(n,s?i.length-n:void 0),closed:s}}function A(e,o){return u(e[o],"=")&&!u(e[o+1],"=")&&!u(e[o+1],">")}var _=["function","def","class"],M=12;function k(e,o){return o===0||e[o].line>e[o-1].endLine}function j(e,o){return o.start-(e.lastIndexOf(`
2
- `,o.start-1)+1)}function x(e,o){let i=0;for(let t=o;t<e.length;t++)if(e[t].kind==="punct"){if("([{".includes(e[t].text))i++;else if(")]}".includes(e[t].text)&&--i===0)return t}return e.length}function W(e,o){let i=x(e,o),t=[],n=o+1,s=0;for(let l=o+1;l<i;l++){let r=e[l];r.kind==="punct"&&"([{".includes(r.text)?s++:r.kind==="punct"&&")]}".includes(r.text)?s--:s===0&&u(r,",")&&(t.push({from:n,to:l}),n=l+1)}return n<i&&t.push({from:n,to:i}),t}function v(e,o,i){let t=x(e,o),n=[],s=o+1,l=0,r=!1,c=0;for(let a=o+1;a<t;a++){let g=e[a];if(g.kind==="punct")if("([{".includes(g.text))l++;else if(")]}".includes(g.text))l--;else{if(l!==0)continue;g.text===","&&c===0?(n.push({from:s,to:a}),s=a+1,r=!1):g.text===":"&&!r?r=!0:r&&(i==="js"&&g.text==="<"?c++:i==="js"&&g.text===">"&&c>0&&!u(e[a-1],"=")?c--:c===0&&A(e,a)&&(r=!1))}}return s<t&&n.push({from:s,to:t}),n}var G=100;function Tt(e){return e.replace(/\s+/g," ").trim().slice(0,G)}function B(e,o={}){return e.lang==="py"?it(e,o.namespaceBindings===!0,o.bindingPositions===!0):Q(e,o.bindingPositions===!0,o.completeImports===!0)}var Y=new Set(["@anthropic-ai/sdk","anthropic","openai","ai","@anthropic-ai/claude-agent-sdk","claude_agent_sdk","@openai/agents"]);function Dt(e,o,i={},t){let n=o==="py"?e.split(".")[0]:e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0];return n==="@openai/agents"?i.layouts===!0:o==="py"&&n==="agents"?i.layouts===!0&&(i.openaiAgents===!0||!!t&&Z(t)):Y.has(n)||n.startsWith("@ai-sdk/")||n.startsWith("@langchain/")||n.startsWith("langchain")}function Z({toks:e}){let o=(i,t=!1)=>e.some((n,s)=>f(n,i)&&!_.includes(e[s-1]?.text??"")&&(u(e[s+1],"(")||t&&u(e[s+1],".")));return o("Agent")&&o("Runner",!0)}var J=[".","/","@/","~/"];function Lt(e,o){return e.filter(i=>o==="py"||J.some(t=>i.source.startsWith(t))).flatMap(i=>i.names.map(t=>({name:t,imported:i.renamed?.[t]??t,source:i.source,line:i.line})))}function Q(e,o,i){let{toks:t}=e,n=[];for(let s=0;s<t.length;s++)if(f(t[s],"import")&&!u(t[s-1],".")){let l=u(t[s+1],"(")?U(e,s+1):tt(e,s,i);l&&n.push({...l,...o?{bindingAt:s}:{}})}else f(t[s],"require")&&u(t[s+1],"(")&&w(t[s+2])&&u(t[s+3],")")&&n.push({source:t[s+2].value,line:t[s].line,...nt(e,s),...o?{bindingAt:s}:{}});return n}function U(e,o){let i=e.toks[o+1];return w(i)&&u(e.toks[o+2],")")?{source:i.value,line:i.line,names:[]}:null}var V=80;function tt(e,o,i){let{toks:t}=e,n=i?t.length:Math.min(t.length,o+V);for(let s=o+1;s<n;s++){let l=t[s];if(w(l))return s!==o+1&&!f(t[s-1],"from")?null:{source:l.value,line:t[o].line,...et(e,o+1,s)};if(u(l,";")||f(l,"import"))return null}return null}function et(e,o,i){let{toks:t}=e,n=[],s={},l=f(t[o],"type")&&F(t[o+1])?o+1:o,r=f(t[l])?t[l].text:void 0;for(let c=o;c<i;c++){let a=t[c];if(!(!f(a)||a.text==="from"))if(a.text==="as")f(t[c+1])&&(n.push(t[++c].text),f(t[c-2])&&(s[t[c].text]=t[c-2].text));else{if(f(t[c+1],"as"))continue;(a.text!=="type"||!F(t[c+1]))&&n.push(a.text)}}return{names:n,renamed:s,...r?{defaultName:r}:{}}}function F(e){return u(e,"{")||f(e)&&e?.text!=="from"}function nt(e,o){let{toks:i}=e,t={names:[],renamed:{}};if(!u(i[o-1],"="))return t;if(f(i[o-2]))return{names:[i[o-2].text],renamed:{}};if(!u(i[o-2],"}"))return t;let n=o-2;for(;n>0&&!u(i[n],"{");)n--;let s=[],l={};for(let r=n+1;r<o-2;r++)!f(i[r])||u(i[r+1],":")||(s.push(i[r].text),u(i[r-1],":")&&f(i[r-2])&&(l[i[r].text]=i[r-2].text));return{names:s,renamed:l}}function it(e,o,i){let{toks:t}=e,n=[];for(let s=0;s<t.length;s++)if(k(t,s)){if(f(t[s],"import"))n.push(...ot(e,s+1,o).map(l=>({...l,...i?{bindingAt:s}:{}})));else if(f(t[s],"from")){let l=K(e,s+1);l.next>s+1&&f(e.toks[l.next],"import")&&n.push({source:l.text,line:t[s].line,...st(e,l.next+1),...i?{bindingAt:s}:{}})}}return n}function K(e,o){let{toks:i}=e,t=o,n=!1;for(;;){if(u(i[t],"."))n=!1;else if(f(i[t])&&!n&&i[t].text!=="import")n=!0;else break;t++}return{text:i.slice(o,t).map(s=>s.text).join(""),next:t}}function ot(e,o,i){let{toks:t}=e,n=[],s=o;for(;;){let l=K(e,s);if(l.next===s)break;let r=f(t[l.next],"as")?t[l.next+1]?.text:void 0,c=r??l.text.split(".")[0];if(n.push({source:l.text,line:t[o].line,names:i?[c]:[],...i?{namespaceNames:[c],...r?{renamed:{[r]:l.text}}:{}}:{}}),s=l.next,f(t[s],"as")&&(s+=2),!u(t[s],","))break;s++}return n}function st(e,o){let{toks:i}=e,t=u(i[o],"("),n=t?x(i,o):i.length,s=[],l={};for(let r=t?o+1:o;r<n&&!(!t&&(k(i,r)||u(i[r],";")));r++)f(i[r])&&(f(i[r+1],"as")&&f(i[r+2])?(s.push(i[r+2].text),l[i[r+2].text]=i[r].text,r+=2):s.push(i[r].text));return{names:s,renamed:l}}var rt=new Set(["string","unknown","any","object","never","boolean","number","undefined","null","void"]),lt=new Set(["if","for","while","switch","catch","with"]),ut=24;function Wt(e){return rt.has(e)}function O(e,o){let i=0;for(let t=o-1;t>=0;t--){let n=e.toks[t];if(n.kind==="punct"){if(")]}".includes(n.text))i++;else if("([{".includes(n.text)&&i--===0)return t}}return-1}function T(e,o){let{toks:i}=e;if(!u(i[o],"("))return!1;let t=i[o-1];if(t&&f(t)&&lt.has(t.text))return!1;let n=x(i,o),s=i[n+1];return u(s,"{")||u(s,"=")&&u(i[n+2],">")?!0:u(s,":")&&f(i[o-2],"function")}function q(e,o){let{toks:i}=e;if(!u(i[o],"{"))return!1;for(let n=o-1;n>=0&&n>=o-ut;n--){let s=i[n];if(u(s,";")||u(s,"{")||u(s,"}"))break;if(f(s,"interface")||f(s,"type")&&f(i[n+1])&&(u(i[n+2],"=")||u(i[n+2],"<")))return!0}if(!u(i[o-1],":"))return!1;let t=O(e,o);return t>=0&&(q(e,t)||T(e,t))}function vt(e,o){let i=O(e,o);if(i<0)return!1;if(T(e,i)||q(e,i))return!0;let t=u(e.toks[i],"{")?O(e,i):-1;return t>=0&&T(e,t)}var ft=new Set(["if","for","while","switch","catch","return","function","def","class","elif","with","await","typeof"]),E={js:new Set(["if","for","while","switch","catch","with"]),py:new Set(["if","elif","for","while","with","except"])},ct={js:new Set([...E.js,"return","yield","throw","await","typeof","void","delete","new","in","instanceof","case","else","do","default","extends"]),py:new Set([...E.py,"return","yield","await","not","and","or","is","in","assert","raise","else","lambda","del"])};function X(e,o,i){if(!i)return f(e[o])&&!ft.has(e[o].text)&&u(e[o+1],"(");let t=o+1;if(!u(e[t],"("))return!1;let n=o,s=i.lang==="py"&&u(e[n],"\\");if(s&&n--,i.lang==="py"&&e[n]?.endLine<e[t].line&&!s&&O(i,t)<0)return!1;if(i.lang==="js"&&u(e[n],".")&&u(e[n-1],"?")&&(n-=2),i.lang==="js"&&u(e[n],">")){if(!/\.[cm]?tsx?$/.test(i.path))return!1;let l=0;do{if(u(e[n],";")||u(e[n],"="))return!1;u(e[n],">")?l++:u(e[n],"<")&&l--,n--}while(n>=0&&l>0);if(l!==0)return!1}for(;u(e[n],"]");)n=O(i,n)-1;if(u(e[n],")")){let l=e[O(i,n)-1];return!f(l)||!E[i.lang].has(l.text)}return!f(e[n])||_.some(l=>f(e[n-1],l))||i.lang==="py"&&["match","case"].includes(e[n].text)&&k(e,n)&&u(e[x(e,t)+1],":")?!1:u(e[n-1],".")||!ct[i.lang].has(e[n].text)}function H(e,o={}){let i=e.lang==="py"?wt(e,!!o.includeMembers,!!o.promptFunctions):mt(e,!!o.includeMembers,!!o.typedReturns,!!o.declarationPositions);if(!o.includeMembers)return i;for(let t=0;t<e.toks.length;t++){if(!u(e.toks[t],"["))continue;let n=e.toks[t-1];if(t===0||f(n,"return")||n?.kind==="punct"&&"=:(,[>".includes(n.text))for(let[l,r]of W(e.toks,t).entries())i.push({name:`[${l}]`,line:e.toks[r.from].line,from:r.from-1,to:r.to,params:null,kind:"index"})}return i.map(t=>({...t,kind:t.kind??(t.params===null?"value":"function")}))}function $t(e,o){return P(e,o).at(-1)?.name??null}function P(e,o){return e.filter(i=>i.from<o&&o<i.to).sort((i,t)=>i.from-t.from)}var at="=+-*/,([{:?.&|<>!%",pt=".+-*/?:,|&)]}";function I(e,o,i){let{toks:t}=e,n=0;for(let s=o;s<t.length;s++){i?.(1);let l=t[s];if(l.kind==="punct"&&"([{".includes(l.text))n++;else{if(l.kind==="punct"&&")]}".includes(l.text)&&--n<0)return s;if(n===0&&u(l,";")&&e.lang==="js")return s+1}if(n===0&&s>o&&k(t,s)&&dt(e,s))return s}return t.length}function dt(e,o){if(e.lang==="py")return!0;let i=e.toks[o-1],t=e.toks[o],n=i.kind==="punct"&&at.includes(i.text),s=t.kind==="punct"&&pt.includes(t.text);return!n&&!s}function b(e,o,i){let{toks:t}=e,n=[];for(let{from:s,to:l}of v(t,o,i)){let r=s;for(;r<l&&t[r].kind==="punct"&&(t[r].text==="*"||t[r].text===".");)r++;l-s===1&&t[s].kind==="punct"&&["*","/"].includes(t[s].text)||n.push(r<l&&f(t[r])?t[r].text:null)}return i==="py"&&(n[0]==="self"||n[0]==="cls")&&n.shift(),n}function mt(e,o,i,t){let{toks:n}=e,s=[],l=0;for(let r=0;r<n.length;r++){let c=n[r];if(u(c,"{"))l++;else if(u(c,"}"))l--;else if(f(c,"function")&&!u(n[r-1],".")){let a=kt(e,r,i);a&&s.push(a)}else if(["const","let","var"].includes(c.text)&&c.kind==="ident"&&f(n[r+1])){let a=Ot(e,r,l===0||o);a&&s.push(a)}else if(o&&f(c,"class")&&f(n[r+1])){let a=n.findIndex((g,y)=>y>r+1&&u(g,"{"));a>=0&&s.push({name:n[r+1].text,line:c.line,from:r,to:x(n,a)+1,params:null,kind:"class"})}else if(o&&f(c)){let a=gt(e,r,s,t);a&&s.push(a)}}return s}var ht=["public","private","protected","static","readonly","async","get","set"],xt=["if","for","while","switch","catch","with"];function gt(e,o,i,t){let{toks:n}=e,s=o;for(u(n[s-1],".")&&f(n[s-2],"this")&&(s-=2);f(n[s-1])&&ht.includes(n[s-1].text);)s--;let l=["{","}",",",";"].some(m=>u(n[s-1],m));if(!k(n,s)&&!l||xt.includes(n[o].text))return null;let r=o+1;if(u(n[r],"(")){let m=x(n,r)+1;if(u(n[m],":"))for(;m<n.length&&!u(n[m],"{")&&!u(n[m],";");)m++;if(!u(n[m],"{"))return null;if(t&&!l){let R=P(i,o).at(-1),h=O(e,o);if(R?.kind!=="class"||h<0||x(n,h)+1!==R.to)return null}return{name:n[o].text,line:n[o].line,from:o,to:x(n,m)+1,params:b(e,r,"js"),kind:"method"}}if(!A(n,r)&&!u(n[r],":"))return null;let a=P(i,o).at(-1)?.kind==="class"?$(e,r,I(e,r+1)):A(n,r)?r:null,g=a===null?r+1:a+1,y=I(e,g),d=0;for(let m=g;m<y;m++){if(u(n[m],",")&&d===0){y=m;break}n[m].kind==="punct"&&("([{".includes(n[m].text)?d++:")]}".includes(n[m].text)&&d--)}return{name:n[o].text,line:n[o].line,from:o,to:y,params:null,kind:a===null?"property":"value"}}function kt(e,o,i){let{toks:t}=e,n=o+1;if(u(t[n],"*")&&n++,!f(t[n]))return null;let s=t[n];if(n++,u(t[n],"<")&&(n=yt(e,n)),!u(t[n],"("))return null;let l=b(e,n,"js"),r=x(t,n)+1;i&&u(t[r],":")&&u(t[r+1],"{")&&(r=x(t,r+1)+1);for(let c=r;c<t.length&&!u(t[c],";");c++)if(u(t[c],"{"))return{name:s.text,line:t[o].line,from:o,to:x(t,c)+1,params:l};return null}function yt(e,o){let i=0;for(let t=o;t<e.toks.length;t++)if(u(e.toks[t],"<"))i++;else if(u(e.toks[t],">")&&--i===0)return t+1;return e.toks.length}function Ot(e,o,i){let{toks:t}=e,n=$(e,o+2);if(n===null)return null;let s=I(e,n+1),l=St(e,n+1,s);return!l&&!i?null:{name:t[o+1].text,line:t[o].line,from:o,to:s,params:l}}function $(e,o,i=e.toks.length){let t=o;if(u(e.toks[t],":")){let n=t+M;for(;t<n&&t<i&&!A(e.toks,t);)t++}return t<i&&A(e.toks,t)?t:null}function St(e,o,i){let{toks:t}=e,n=f(t[o],"async")?o+1:o;if(f(t[n],"function"))return n++,u(t[n],"*")&&n++,f(t[n])&&n++,u(t[n],"(")?b(e,n,"js"):null;let s=l=>u(t[l],"=")&&u(t[l+1],">");if(f(t[n])&&s(n+1))return[t[n].text];if(!u(t[n],"("))return null;for(let l=x(t,n)+1;l<i;l++)if(s(l))return b(e,n,"js");return null}function wt(e,o,i){let{toks:t,text:n}=e,s=[];for(let l=0;l<t.length;l++){let r=t[l],c=f(r,"def")&&f(t[l+1])&&u(t[l+2],"("),a=o&&f(r,"class")&&f(t[l+1]);if(c||a){let g=bt(e,c||u(t[l+2],"(")?x(t,l+2)+1:l+2),y=(o||i)&&f(t[l-1],"async")&&t[l-1].line===r.line?t[l-1]:r,d=j(n,y),m=g+1;for(;m<t.length&&!(k(t,m)&&j(n,t[m])<=d);)m++;s.push({name:t[l+1].text,line:r.line,from:l,to:m,params:c?b(e,l+2,"py"):null,...a?{kind:"class"}:{}})}else f(r)&&k(t,l)&&(o||j(n,r)===0)&&At(e,l+1)&&s.push({name:r.text,line:r.line,from:l,to:I(e,l+1),params:null})}return s}function At(e,o){let{toks:i}=e;return A(i,o)||u(i[o],":")}function bt(e,o){let i=o;for(;i<e.toks.length&&!u(e.toks[i],":");)i++;return i}var Rt=40,_t=new Set(["const","let","var","function","class","default","async","interface","enum"]);function jt(e,o){let{toks:i}=e,t=[];for(let n=0;n<i.length;n++){if(!f(i[n],"export"))continue;let s=0,l=o?i.length:Math.min(i.length,n+Rt);for(let r=n+1;r<l&&(u(i[r],"{")&&s++,u(i[r],"}")&&s--,!(u(i[r],";")||(!o||s===0)&&f(i[r])&&_t.has(i[r].text)));r++)if((!o||s===0)&&f(i[r],"from")&&w(i[r+1])){t.push(i[r+1].value);break}}return t}function Qt(e,o,i,t=!1){let n=typeof t=="boolean"?t:t.allReexports===!0,s=typeof t=="object"&&t.completeImports===!0,l=C(e,o,i),r=B(l,{bindingPositions:s,namespaceBindings:s,completeImports:s});if(i==="py"){if(!s)return r;let d=r.flatMap(p=>p.namespaceNames?[{...p,names:[]}]:p.names.length?p.names.map(S=>({...p,names:[p.renamed?.[S]??S]})):[p]),m=new Set(["importlib",...r.filter(p=>p.source==="importlib").flatMap(p=>p.namespaceNames??[])]),R=new Set(r.filter(p=>p.source==="importlib"&&!p.namespaceNames).flatMap(p=>p.names.filter(S=>(p.renamed?.[S]??S)==="import_module"))),{toks:h}=l;for(let p=0;p<h.length;p++){let S=f(h[p],"__import__")&&!u(h[p-1],".")&&!f(h[p-1],"def"),z=f(h[p],"import_module")&&u(h[p-1],".")&&f(h[p-2])&&m.has(h[p-2].text)&&!u(h[p-3],".")||f(h[p])&&R.has(h[p].text)&&!u(h[p-1],".")&&!f(h[p-1],"def");if(!S&&!z||!u(h[p+1],"("))continue;let N=h[p+2],D=N?.kind==="string"&&!/^f/i.test(N.text)&&u(h[p+3],")");d.push({source:D?N.value:"?",names:[],line:h[p].line,bindingAt:p,...D?{}:{dynamic:!0}})}return d}let c=[],{toks:a}=l,g=new Set(s?H(l,{includeMembers:!0,typedReturns:!0,declarationPositions:!0}).filter(d=>d.kind==="method").map(d=>d.from):[]);if(s)for(let d=0;d<a.length;d++){if(!f(a[d],"import")&&!f(a[d],"require")||u(a[d-1],".")||!X(a,d,l)||g.has(d))continue;let m=a[d+2];(!w(m)||!u(a[d+3],")")||m.kind==="template"&&m.value.includes("${"))&&c.push({source:"?",names:[],line:a[d].line,bindingAt:d,dynamic:!0})}let y=new Set(c.map(d=>d.bindingAt));return[...r.filter(d=>!y.has(d.bindingAt)),...jt(l,n).map(d=>({source:d,names:[]})),...c]}export{C as a,u as b,f as c,w as d,Nt as e,A as f,_ as g,M as h,k as i,j,x as k,W as l,v as m,Tt as n,B as o,Dt as p,Lt as q,Wt as r,O as s,vt as t,X as u,H as v,$t as w,I as x,Qt as y};
1
+ import{c as L}from"./ICJV6KIZ.js";function C(e,o,i){let t=L(o,i).filter(n=>n.kind!=="comment");return{path:e,text:o,lang:i,toks:t}}function u(e,o){return e?.kind==="punct"&&e.text===o}function f(e,o){return e?.kind==="ident"&&(o===void 0||e.text===o)}function w(e){return e?.kind==="string"||e?.kind==="template"}function Nt(e){let o=/^[A-Za-z]*/.exec(e.text)[0],i=e.text.slice(o.length),t=i[0]??"",n=i.startsWith(t.repeat(3))&&i.length>=6?3:1,s=i.length>=2*n&&i.endsWith(t.repeat(n));if(s){let l=0;for(let r=i.length-n-1;r>=0&&i[r]==="\\";r--)l++;s=l%2===0}return{prefix:o,width:n,inner:i.slice(n,s?i.length-n:void 0),closed:s}}function A(e,o){return u(e[o],"=")&&!u(e[o+1],"=")&&!u(e[o+1],">")}var _=["function","def","class"],M=12;function k(e,o){return o===0||e[o].line>e[o-1].endLine}function j(e,o){return o.start-(e.lastIndexOf(`
2
+ `,o.start-1)+1)}function x(e,o){let i=0;for(let t=o;t<e.length;t++)if(e[t].kind==="punct"){if("([{".includes(e[t].text))i++;else if(")]}".includes(e[t].text)&&--i===0)return t}return e.length}function W(e,o){let i=x(e,o),t=[],n=o+1,s=0;for(let l=o+1;l<i;l++){let r=e[l];r.kind==="punct"&&"([{".includes(r.text)?s++:r.kind==="punct"&&")]}".includes(r.text)?s--:s===0&&u(r,",")&&(t.push({from:n,to:l}),n=l+1)}return n<i&&t.push({from:n,to:i}),t}function v(e,o,i){let t=x(e,o),n=[],s=o+1,l=0,r=!1,c=0;for(let a=o+1;a<t;a++){let g=e[a];if(g.kind==="punct")if("([{".includes(g.text))l++;else if(")]}".includes(g.text))l--;else{if(l!==0)continue;g.text===","&&c===0?(n.push({from:s,to:a}),s=a+1,r=!1):g.text===":"&&!r?r=!0:r&&(i==="js"&&g.text==="<"?c++:i==="js"&&g.text===">"&&c>0&&!u(e[a-1],"=")?c--:c===0&&A(e,a)&&(r=!1))}}return s<t&&n.push({from:s,to:t}),n}var G=100;function Tt(e){return e.replace(/\s+/g," ").trim().slice(0,G)}function B(e,o={}){return e.lang==="py"?it(e,o.namespaceBindings===!0,o.bindingPositions===!0):Q(e,o.bindingPositions===!0,o.completeImports===!0)}var Y=new Set(["@anthropic-ai/sdk","anthropic","openai","ai","@anthropic-ai/claude-agent-sdk","claude_agent_sdk","@openai/agents"]);function Dt(e,o,i={},t){let n=o==="py"?e.split(".")[0]:e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0];return n==="@openai/agents"?i.layouts===!0:o==="py"&&n==="agents"?i.layouts===!0&&(i.openaiAgents===!0||!!t&&Z(t)):Y.has(n)||n.startsWith("@ai-sdk/")||n.startsWith("@langchain/")||n.startsWith("langchain")}function Z({toks:e}){let o=(i,t=!1)=>e.some((n,s)=>f(n,i)&&!_.includes(e[s-1]?.text??"")&&(u(e[s+1],"(")||t&&u(e[s+1],".")));return o("Agent")&&o("Runner",!0)}var J=[".","/","@/","~/"];function Lt(e,o){return e.filter(i=>o==="py"||J.some(t=>i.source.startsWith(t))).flatMap(i=>i.names.map(t=>({name:t,imported:i.renamed?.[t]??t,source:i.source,line:i.line})))}function Q(e,o,i){let{toks:t}=e,n=[];for(let s=0;s<t.length;s++)if(f(t[s],"import")&&!u(t[s-1],".")){let l=u(t[s+1],"(")?U(e,s+1):tt(e,s,i);l&&n.push({...l,...o?{bindingAt:s}:{}})}else f(t[s],"require")&&u(t[s+1],"(")&&w(t[s+2])&&u(t[s+3],")")&&n.push({source:t[s+2].value,line:t[s].line,...nt(e,s),...o?{bindingAt:s}:{}});return n}function U(e,o){let i=e.toks[o+1];return w(i)&&u(e.toks[o+2],")")?{source:i.value,line:i.line,names:[]}:null}var V=80;function tt(e,o,i){let{toks:t}=e,n=i?t.length:Math.min(t.length,o+V);for(let s=o+1;s<n;s++){let l=t[s];if(w(l))return s!==o+1&&!f(t[s-1],"from")?null:{source:l.value,line:t[o].line,...et(e,o+1,s)};if(u(l,";")||f(l,"import"))return null}return null}function et(e,o,i){let{toks:t}=e,n=[],s={},l=f(t[o],"type")&&F(t[o+1])?o+1:o,r=f(t[l])?t[l].text:void 0;for(let c=o;c<i;c++){let a=t[c];if(!(!f(a)||a.text==="from"))if(a.text==="as")f(t[c+1])&&(n.push(t[++c].text),f(t[c-2])&&(s[t[c].text]=t[c-2].text));else{if(f(t[c+1],"as"))continue;(a.text!=="type"||!F(t[c+1]))&&n.push(a.text)}}return{names:n,renamed:s,...r?{defaultName:r}:{}}}function F(e){return u(e,"{")||f(e)&&e?.text!=="from"}function nt(e,o){let{toks:i}=e,t={names:[],renamed:{}};if(!u(i[o-1],"="))return t;if(f(i[o-2]))return{names:[i[o-2].text],renamed:{}};if(!u(i[o-2],"}"))return t;let n=o-2;for(;n>0&&!u(i[n],"{");)n--;let s=[],l={};for(let r=n+1;r<o-2;r++)!f(i[r])||u(i[r+1],":")||(s.push(i[r].text),u(i[r-1],":")&&f(i[r-2])&&(l[i[r].text]=i[r-2].text));return{names:s,renamed:l}}function it(e,o,i){let{toks:t}=e,n=[];for(let s=0;s<t.length;s++)if(k(t,s)){if(f(t[s],"import"))n.push(...ot(e,s+1,o).map(l=>({...l,...i?{bindingAt:s}:{}})));else if(f(t[s],"from")){let l=K(e,s+1);l.next>s+1&&f(e.toks[l.next],"import")&&n.push({source:l.text,line:t[s].line,...st(e,l.next+1),...i?{bindingAt:s}:{}})}}return n}function K(e,o){let{toks:i}=e,t=o,n=!1;for(;;){if(u(i[t],"."))n=!1;else if(f(i[t])&&!n&&i[t].text!=="import")n=!0;else break;t++}return{text:i.slice(o,t).map(s=>s.text).join(""),next:t}}function ot(e,o,i){let{toks:t}=e,n=[],s=o;for(;;){let l=K(e,s);if(l.next===s)break;let r=f(t[l.next],"as")?t[l.next+1]?.text:void 0,c=r??l.text.split(".")[0];if(n.push({source:l.text,line:t[o].line,names:i?[c]:[],...i?{namespaceNames:[c],...r?{renamed:{[r]:l.text}}:{}}:{}}),s=l.next,f(t[s],"as")&&(s+=2),!u(t[s],","))break;s++}return n}function st(e,o){let{toks:i}=e,t=u(i[o],"("),n=t?x(i,o):i.length,s=[],l={};for(let r=t?o+1:o;r<n&&!(!t&&(k(i,r)||u(i[r],";")));r++)f(i[r])&&(f(i[r+1],"as")&&f(i[r+2])?(s.push(i[r+2].text),l[i[r+2].text]=i[r].text,r+=2):s.push(i[r].text));return{names:s,renamed:l}}var rt=new Set(["string","unknown","any","object","never","boolean","number","undefined","null","void"]),lt=new Set(["if","for","while","switch","catch","with"]),ut=24;function Wt(e){return rt.has(e)}function O(e,o){let i=0;for(let t=o-1;t>=0;t--){let n=e.toks[t];if(n.kind==="punct"){if(")]}".includes(n.text))i++;else if("([{".includes(n.text)&&i--===0)return t}}return-1}function T(e,o){let{toks:i}=e;if(!u(i[o],"("))return!1;let t=i[o-1];if(t&&f(t)&&lt.has(t.text))return!1;let n=x(i,o),s=i[n+1];return u(s,"{")||u(s,"=")&&u(i[n+2],">")?!0:u(s,":")&&f(i[o-2],"function")}function q(e,o){let{toks:i}=e;if(!u(i[o],"{"))return!1;for(let n=o-1;n>=0&&n>=o-ut;n--){let s=i[n];if(u(s,";")||u(s,"{")||u(s,"}"))break;if(f(s,"interface")||f(s,"type")&&f(i[n+1])&&(u(i[n+2],"=")||u(i[n+2],"<")))return!0}if(!u(i[o-1],":"))return!1;let t=O(e,o);return t>=0&&(q(e,t)||T(e,t))}function vt(e,o){let i=O(e,o);if(i<0)return!1;if(T(e,i)||q(e,i))return!0;let t=u(e.toks[i],"{")?O(e,i):-1;return t>=0&&T(e,t)}var ft=new Set(["if","for","while","switch","catch","return","function","def","class","elif","with","await","typeof"]),E={js:new Set(["if","for","while","switch","catch","with"]),py:new Set(["if","elif","for","while","with","except"])},ct={js:new Set([...E.js,"return","yield","throw","await","typeof","void","delete","new","in","instanceof","case","else","do","default","extends"]),py:new Set([...E.py,"return","yield","await","not","and","or","is","in","assert","raise","else","lambda","del"])};function X(e,o,i){if(!i)return f(e[o])&&!ft.has(e[o].text)&&u(e[o+1],"(");let t=o+1;if(!u(e[t],"("))return!1;let n=o,s=i.lang==="py"&&u(e[n],"\\");if(s&&n--,i.lang==="py"&&e[n]?.endLine<e[t].line&&!s&&O(i,t)<0)return!1;if(i.lang==="js"&&u(e[n],".")&&u(e[n-1],"?")&&(n-=2),i.lang==="js"&&u(e[n],">")){if(!/\.[cm]?tsx?$/.test(i.path))return!1;let l=0;do{if(u(e[n],";")||u(e[n],"="))return!1;u(e[n],">")?l++:u(e[n],"<")&&l--,n--}while(n>=0&&l>0);if(l!==0)return!1}for(;u(e[n],"]");)n=O(i,n)-1;if(u(e[n],")")){let l=e[O(i,n)-1];return!f(l)||!E[i.lang].has(l.text)}return!f(e[n])||_.some(l=>f(e[n-1],l))||i.lang==="py"&&["match","case"].includes(e[n].text)&&k(e,n)&&u(e[x(e,t)+1],":")?!1:u(e[n-1],".")||!ct[i.lang].has(e[n].text)}function H(e,o={}){let i=e.lang==="py"?wt(e,!!o.includeMembers,!!o.promptFunctions):mt(e,!!o.includeMembers,!!o.typedReturns,!!o.declarationPositions);if(!o.includeMembers)return i;for(let t=0;t<e.toks.length;t++){if(!u(e.toks[t],"["))continue;let n=e.toks[t-1];if(t===0||f(n,"return")||n?.kind==="punct"&&"=:(,[>".includes(n.text))for(let[l,r]of W(e.toks,t).entries())i.push({name:`[${l}]`,line:e.toks[r.from].line,from:r.from-1,to:r.to,params:null,kind:"index"})}return i.map(t=>({...t,kind:t.kind??(t.params===null?"value":"function")}))}function $t(e,o){return P(e,o).at(-1)?.name??null}function P(e,o){return e.filter(i=>i.from<o&&o<i.to).sort((i,t)=>i.from-t.from)}var at="=+-*/,([{:?.&|<>!%",pt=".+-*/?:,|&)]}";function I(e,o,i,t=!1){let{toks:n}=e,s=0;for(let l=o;l<n.length;l++){i?.(1);let r=n[l],c=s>0;if(r.kind==="punct"&&"([{".includes(r.text))s++;else{if(r.kind==="punct"&&")]}".includes(r.text)&&--s<0)return l;if(s===0&&u(r,";")&&e.lang==="js")return l+1}if(s===0&&l>o&&k(n,l)&&dt(e,l)&&(!t||!c))return l}return n.length}function dt(e,o){if(e.lang==="py")return!0;let i=e.toks[o-1],t=e.toks[o],n=i.kind==="punct"&&at.includes(i.text),s=t.kind==="punct"&&pt.includes(t.text);return!n&&!s}function b(e,o,i){let{toks:t}=e,n=[];for(let{from:s,to:l}of v(t,o,i)){let r=s;for(;r<l&&t[r].kind==="punct"&&(t[r].text==="*"||t[r].text===".");)r++;l-s===1&&t[s].kind==="punct"&&["*","/"].includes(t[s].text)||n.push(r<l&&f(t[r])?t[r].text:null)}return i==="py"&&(n[0]==="self"||n[0]==="cls")&&n.shift(),n}function mt(e,o,i,t){let{toks:n}=e,s=[],l=0;for(let r=0;r<n.length;r++){let c=n[r];if(u(c,"{"))l++;else if(u(c,"}"))l--;else if(f(c,"function")&&!u(n[r-1],".")){let a=kt(e,r,i);a&&s.push(a)}else if(["const","let","var"].includes(c.text)&&c.kind==="ident"&&f(n[r+1])){let a=Ot(e,r,l===0||o);a&&s.push(a)}else if(o&&f(c,"class")&&f(n[r+1])){let a=n.findIndex((g,y)=>y>r+1&&u(g,"{"));a>=0&&s.push({name:n[r+1].text,line:c.line,from:r,to:x(n,a)+1,params:null,kind:"class"})}else if(o&&f(c)){let a=gt(e,r,s,t);a&&s.push(a)}}return s}var ht=["public","private","protected","static","readonly","async","get","set"],xt=["if","for","while","switch","catch","with"];function gt(e,o,i,t){let{toks:n}=e,s=o;for(u(n[s-1],".")&&f(n[s-2],"this")&&(s-=2);f(n[s-1])&&ht.includes(n[s-1].text);)s--;let l=["{","}",",",";"].some(m=>u(n[s-1],m));if(!k(n,s)&&!l||xt.includes(n[o].text))return null;let r=o+1;if(u(n[r],"(")){let m=x(n,r)+1;if(u(n[m],":"))for(;m<n.length&&!u(n[m],"{")&&!u(n[m],";");)m++;if(!u(n[m],"{"))return null;if(t&&!l){let R=P(i,o).at(-1),h=O(e,o);if(R?.kind!=="class"||h<0||x(n,h)+1!==R.to)return null}return{name:n[o].text,line:n[o].line,from:o,to:x(n,m)+1,params:b(e,r,"js"),kind:"method"}}if(!A(n,r)&&!u(n[r],":"))return null;let a=P(i,o).at(-1)?.kind==="class"?$(e,r,I(e,r+1)):A(n,r)?r:null,g=a===null?r+1:a+1,y=I(e,g),d=0;for(let m=g;m<y;m++){if(u(n[m],",")&&d===0){y=m;break}n[m].kind==="punct"&&("([{".includes(n[m].text)?d++:")]}".includes(n[m].text)&&d--)}return{name:n[o].text,line:n[o].line,from:o,to:y,params:null,kind:a===null?"property":"value"}}function kt(e,o,i){let{toks:t}=e,n=o+1;if(u(t[n],"*")&&n++,!f(t[n]))return null;let s=t[n];if(n++,u(t[n],"<")&&(n=yt(e,n)),!u(t[n],"("))return null;let l=b(e,n,"js"),r=x(t,n)+1;i&&u(t[r],":")&&u(t[r+1],"{")&&(r=x(t,r+1)+1);for(let c=r;c<t.length&&!u(t[c],";");c++)if(u(t[c],"{"))return{name:s.text,line:t[o].line,from:o,to:x(t,c)+1,params:l};return null}function yt(e,o){let i=0;for(let t=o;t<e.toks.length;t++)if(u(e.toks[t],"<"))i++;else if(u(e.toks[t],">")&&--i===0)return t+1;return e.toks.length}function Ot(e,o,i){let{toks:t}=e,n=$(e,o+2);if(n===null)return null;let s=I(e,n+1),l=St(e,n+1,s);return!l&&!i?null:{name:t[o+1].text,line:t[o].line,from:o,to:s,params:l}}function $(e,o,i=e.toks.length){let t=o;if(u(e.toks[t],":")){let n=t+M;for(;t<n&&t<i&&!A(e.toks,t);)t++}return t<i&&A(e.toks,t)?t:null}function St(e,o,i){let{toks:t}=e,n=f(t[o],"async")?o+1:o;if(f(t[n],"function"))return n++,u(t[n],"*")&&n++,f(t[n])&&n++,u(t[n],"(")?b(e,n,"js"):null;let s=l=>u(t[l],"=")&&u(t[l+1],">");if(f(t[n])&&s(n+1))return[t[n].text];if(!u(t[n],"("))return null;for(let l=x(t,n)+1;l<i;l++)if(s(l))return b(e,n,"js");return null}function wt(e,o,i){let{toks:t,text:n}=e,s=[];for(let l=0;l<t.length;l++){let r=t[l],c=f(r,"def")&&f(t[l+1])&&u(t[l+2],"("),a=o&&f(r,"class")&&f(t[l+1]);if(c||a){let g=bt(e,c||u(t[l+2],"(")?x(t,l+2)+1:l+2),y=(o||i)&&f(t[l-1],"async")&&t[l-1].line===r.line?t[l-1]:r,d=j(n,y),m=g+1;for(;m<t.length&&!(k(t,m)&&j(n,t[m])<=d);)m++;s.push({name:t[l+1].text,line:r.line,from:l,to:m,params:c?b(e,l+2,"py"):null,...a?{kind:"class"}:{}})}else f(r)&&k(t,l)&&(o||j(n,r)===0)&&At(e,l+1)&&s.push({name:r.text,line:r.line,from:l,to:I(e,l+1),params:null})}return s}function At(e,o){let{toks:i}=e;return A(i,o)||u(i[o],":")}function bt(e,o){let i=o;for(;i<e.toks.length&&!u(e.toks[i],":");)i++;return i}var Rt=40,_t=new Set(["const","let","var","function","class","default","async","interface","enum"]);function jt(e,o){let{toks:i}=e,t=[];for(let n=0;n<i.length;n++){if(!f(i[n],"export"))continue;let s=0,l=o?i.length:Math.min(i.length,n+Rt);for(let r=n+1;r<l&&(u(i[r],"{")&&s++,u(i[r],"}")&&s--,!(u(i[r],";")||(!o||s===0)&&f(i[r])&&_t.has(i[r].text)));r++)if((!o||s===0)&&f(i[r],"from")&&w(i[r+1])){t.push(i[r+1].value);break}}return t}function Qt(e,o,i,t=!1){let n=typeof t=="boolean"?t:t.allReexports===!0,s=typeof t=="object"&&t.completeImports===!0,l=C(e,o,i),r=B(l,{bindingPositions:s,namespaceBindings:s,completeImports:s});if(i==="py"){if(!s)return r;let d=r.flatMap(p=>p.namespaceNames?[{...p,names:[]}]:p.names.length?p.names.map(S=>({...p,names:[p.renamed?.[S]??S]})):[p]),m=new Set(["importlib",...r.filter(p=>p.source==="importlib").flatMap(p=>p.namespaceNames??[])]),R=new Set(r.filter(p=>p.source==="importlib"&&!p.namespaceNames).flatMap(p=>p.names.filter(S=>(p.renamed?.[S]??S)==="import_module"))),{toks:h}=l;for(let p=0;p<h.length;p++){let S=f(h[p],"__import__")&&!u(h[p-1],".")&&!f(h[p-1],"def"),z=f(h[p],"import_module")&&u(h[p-1],".")&&f(h[p-2])&&m.has(h[p-2].text)&&!u(h[p-3],".")||f(h[p])&&R.has(h[p].text)&&!u(h[p-1],".")&&!f(h[p-1],"def");if(!S&&!z||!u(h[p+1],"("))continue;let N=h[p+2],D=N?.kind==="string"&&!/^f/i.test(N.text)&&u(h[p+3],")");d.push({source:D?N.value:"?",names:[],line:h[p].line,bindingAt:p,...D?{}:{dynamic:!0}})}return d}let c=[],{toks:a}=l,g=new Set(s?H(l,{includeMembers:!0,typedReturns:!0,declarationPositions:!0}).filter(d=>d.kind==="method").map(d=>d.from):[]);if(s)for(let d=0;d<a.length;d++){if(!f(a[d],"import")&&!f(a[d],"require")||u(a[d-1],".")||!X(a,d,l)||g.has(d))continue;let m=a[d+2];(!w(m)||!u(a[d+3],")")||m.kind==="template"&&m.value.includes("${"))&&c.push({source:"?",names:[],line:a[d].line,bindingAt:d,dynamic:!0})}let y=new Set(c.map(d=>d.bindingAt));return[...r.filter(d=>!y.has(d.bindingAt)),...jt(l,n).map(d=>({source:d,names:[]})),...c]}export{C as a,u as b,f as c,w as d,Nt as e,A as f,_ as g,M as h,k as i,j,x as k,W as l,v as m,Tt as n,B as o,Dt as p,Lt as q,Wt as r,O as s,vt as t,X as u,H as v,$t as w,I as x,Qt as y};
@@ -1 +1 @@
1
- import{h as B}from"./VC3PYT2B.js";import{C as z}from"./P253B344.js";import{b as _,d as E}from"./W73WF226.js";import{a as A}from"./M5YWJY7P.js";import{Fb as b}from"./2M55DR2J.js";import{a as d}from"./MKYLK6DB.js";var L=t=>typeof t=="string"&&t.length>0&&!/[\\\0\r\n]/.test(t)&&!/^(?:\/|[a-zA-Z]:)/.test(t)&&t.split("/").every(n=>n!==""&&n!=="."&&n!=="..");function q(t){if(!B(t)||t.CF_PART_FILES===void 0)return;let n;try{n=JSON.parse(t.CF_PART_FILES)}catch{throw new Error("bad_request")}if(!Array.isArray(n)||!n.every(L))throw new Error("bad_request");return[...new Set(n)]}function S(t,n){let r=0,i=0,o=0;for(let c of t){let a=n.get(c);a.pool==="instruction"?r+=a.size:(i+=a.size,o++)}return{instruction:r,code:i,count:o}}function M(t,n,r){let{instruction:i,code:o,count:c}=S(t,n);return i<=d.sourceFetch.instructionBytes&&o<=d.sourceFetch.codeBytes&&c<=d.sourceFetch.codeFiles&&i+o<=d.codeAgent.importBytes&&E([...t].map(a=>({path:a,...n.get(a)})),r)!==void 0}var F=(t,n)=>new Set([...t,...n]);function N(t,n){let r=[];for(let i of t){let o=r.find(c=>M(F(c.files,i.files),n));o?(o.roots.push(i),o.files=F(o.files,i.files)):r.push({roots:[i],files:i.files})}return r}function P(t,n,r){let i=[...t].map(o=>[r.get(o).size,r.get(o).inputBytes??0]);return i.sort((o,c)=>o[0]-c[0]||o[1]-c[1]),JSON.stringify([S(t,r),i,[...t].filter(o=>n.has(o)).sort()])}function v(t,n,r,i){let o=[],c=new Set,a=t.map((f,e)=>new Set(t.slice(e).flatMap(s=>[...s.files]))),h=f=>{if(i.remaining--<=0)return!1;if(f===t.length)return!0;let e=l=>P(l,a[f],n),s=JSON.stringify([f,o.map(l=>e(l.files)).sort()]);if(c.has(s))return!1;let u=t[f],w=new Set;for(let l=0;l<=o.length&&l<r;l++){if(i.remaining<=0)return!1;let g=o[l],m=e(g?.files??new Set);if(w.has(m))continue;w.add(m);let p=g?F(g.files,u.files):u.files;if(M(p,n,i)){if(o[l]={roots:[...g?.roots??[],u],files:p},h(f+1))return!0;g?o[l]=g:o.pop()}}return c.add(s),!1};return h(0)?o:void 0}function I(t,n){if(!t.length)return[];let r=[...t].sort((e,s)=>s.weight-e.weight),i=N(r,n),o=S(new Set(t.flatMap(e=>[...e.files])),n),c=Math.max(1,Math.ceil(o.instruction/d.sourceFetch.instructionBytes),Math.ceil(o.code/d.sourceFetch.codeBytes),Math.ceil(o.count/d.sourceFetch.codeFiles)),a=_(),h=i;for(let e=c;e<i.length&&a.remaining>0;e++){let s=v(r,n,e,a);if(s){h=s;break}}let f=new Map(t.map((e,s)=>[e.path,s]));return h.map(e=>({paths:e.roots.map(s=>s.path).sort((s,u)=>f.get(s)-f.get(u)),files:[...e.files]})).sort((e,s)=>f.get(e.paths[0])-f.get(s.paths[0]))}function D(t,n){let r=new Map(n.entries.map(e=>[e.path,e])),{descriptions:i}=z(t,n.entries,{},{measureAnalysisSize:!0}),o=new Map(i.map(e=>[e.entry.path,e.analysisPool??e.pool])),c=new Map,a=new Map;for(let e of r.values()){if(!L(e.path)||!Number.isSafeInteger(e.size)||e.size<0){a.set(e.path,"unavailable");continue}let s=b(t,e,{purpose:"proposal",route:"local-folder"});if(!s.admitted){a.set(e.path,s.reason==="too-large"?"tooLarge":"unavailable");continue}let u=n.inputBytes?.[e.path];if(u!==void 0&&(!Number.isSafeInteger(u)||u<0)){a.set(e.path,"unavailable");continue}if(u!==void 0&&u>=8e5){a.set(e.path,"tooLarge");continue}c.set(e.path,{size:e.size,inputBytes:u,pool:o.get(e.path)??"code"})}let h={groups:[],tooLarge:[],unavailable:[]},f=[];for(let e of new Set(n.paths)){let s=new Set,u=[e],w=new Set,l=new Set,g;for(;u.length;){let p=u.pop();if(w.has(p))continue;w.add(p);let y=a.get(p)??(c.has(p)?void 0:"unavailable");if(y&&p!==e){l.add(p);continue}if(y){g=y;continue}s.add(p),n.dependencies&&Object.hasOwn(n.dependencies,p)&&u.push(...n.dependencies[p])}if(g){h[g].push(e);continue}if(l.size&&(h.missingContext??=[]).push({path:e,imports:[...l].sort()}),!M(s,c)){h.tooLarge.push(e);continue}let m=S(s,c);f.push({path:e,files:s,weight:Math.max(m.instruction/d.sourceFetch.instructionBytes,m.code/d.sourceFetch.codeBytes,m.count/d.sourceFetch.codeFiles)})}return h.groups=I(f,c),h}export{q as a,D as b};
1
+ import{C as z}from"./AIS3FHQR.js";import{b as _,d as E}from"./QY57UR6E.js";import{a as A}from"./GZSUTDGX.js";import{Fb as b}from"./QYYN4YKB.js";import{l as B}from"./LOODGUMW.js";import{a as d}from"./MKYLK6DB.js";var L=t=>typeof t=="string"&&t.length>0&&!/[\\\0\r\n]/.test(t)&&!/^(?:\/|[a-zA-Z]:)/.test(t)&&t.split("/").every(n=>n!==""&&n!=="."&&n!=="..");function q(t){if(!B(t)||t.CF_PART_FILES===void 0)return;let n;try{n=JSON.parse(t.CF_PART_FILES)}catch{throw new Error("bad_request")}if(!Array.isArray(n)||!n.every(L))throw new Error("bad_request");return[...new Set(n)]}function S(t,n){let r=0,i=0,o=0;for(let c of t){let a=n.get(c);a.pool==="instruction"?r+=a.size:(i+=a.size,o++)}return{instruction:r,code:i,count:o}}function M(t,n,r){let{instruction:i,code:o,count:c}=S(t,n);return i<=d.sourceFetch.instructionBytes&&o<=d.sourceFetch.codeBytes&&c<=d.sourceFetch.codeFiles&&i+o<=d.codeAgent.importBytes&&E([...t].map(a=>({path:a,...n.get(a)})),r)!==void 0}var F=(t,n)=>new Set([...t,...n]);function N(t,n){let r=[];for(let i of t){let o=r.find(c=>M(F(c.files,i.files),n));o?(o.roots.push(i),o.files=F(o.files,i.files)):r.push({roots:[i],files:i.files})}return r}function P(t,n,r){let i=[...t].map(o=>[r.get(o).size,r.get(o).inputBytes??0]);return i.sort((o,c)=>o[0]-c[0]||o[1]-c[1]),JSON.stringify([S(t,r),i,[...t].filter(o=>n.has(o)).sort()])}function v(t,n,r,i){let o=[],c=new Set,a=t.map((f,e)=>new Set(t.slice(e).flatMap(s=>[...s.files]))),h=f=>{if(i.remaining--<=0)return!1;if(f===t.length)return!0;let e=l=>P(l,a[f],n),s=JSON.stringify([f,o.map(l=>e(l.files)).sort()]);if(c.has(s))return!1;let u=t[f],w=new Set;for(let l=0;l<=o.length&&l<r;l++){if(i.remaining<=0)return!1;let g=o[l],m=e(g?.files??new Set);if(w.has(m))continue;w.add(m);let p=g?F(g.files,u.files):u.files;if(M(p,n,i)){if(o[l]={roots:[...g?.roots??[],u],files:p},h(f+1))return!0;g?o[l]=g:o.pop()}}return c.add(s),!1};return h(0)?o:void 0}function I(t,n){if(!t.length)return[];let r=[...t].sort((e,s)=>s.weight-e.weight),i=N(r,n),o=S(new Set(t.flatMap(e=>[...e.files])),n),c=Math.max(1,Math.ceil(o.instruction/d.sourceFetch.instructionBytes),Math.ceil(o.code/d.sourceFetch.codeBytes),Math.ceil(o.count/d.sourceFetch.codeFiles)),a=_(),h=i;for(let e=c;e<i.length&&a.remaining>0;e++){let s=v(r,n,e,a);if(s){h=s;break}}let f=new Map(t.map((e,s)=>[e.path,s]));return h.map(e=>({paths:e.roots.map(s=>s.path).sort((s,u)=>f.get(s)-f.get(u)),files:[...e.files]})).sort((e,s)=>f.get(e.paths[0])-f.get(s.paths[0]))}function D(t,n){let r=new Map(n.entries.map(e=>[e.path,e])),{descriptions:i}=z(t,n.entries,{},{measureAnalysisSize:!0}),o=new Map(i.map(e=>[e.entry.path,e.analysisPool??e.pool])),c=new Map,a=new Map;for(let e of r.values()){if(!L(e.path)||!Number.isSafeInteger(e.size)||e.size<0){a.set(e.path,"unavailable");continue}let s=b(t,e,{purpose:"proposal",route:"local-folder"});if(!s.admitted){a.set(e.path,s.reason==="too-large"?"tooLarge":"unavailable");continue}let u=n.inputBytes?.[e.path];if(u!==void 0&&(!Number.isSafeInteger(u)||u<0)){a.set(e.path,"unavailable");continue}if(u!==void 0&&u>=8e5){a.set(e.path,"tooLarge");continue}c.set(e.path,{size:e.size,inputBytes:u,pool:o.get(e.path)??"code"})}let h={groups:[],tooLarge:[],unavailable:[]},f=[];for(let e of new Set(n.paths)){let s=new Set,u=[e],w=new Set,l=new Set,g;for(;u.length;){let p=u.pop();if(w.has(p))continue;w.add(p);let y=a.get(p)??(c.has(p)?void 0:"unavailable");if(y&&p!==e){l.add(p);continue}if(y){g=y;continue}s.add(p),n.dependencies&&Object.hasOwn(n.dependencies,p)&&u.push(...n.dependencies[p])}if(g){h[g].push(e);continue}if(l.size&&(h.missingContext??=[]).push({path:e,imports:[...l].sort()}),!M(s,c)){h.tooLarge.push(e);continue}let m=S(s,c);f.push({path:e,files:s,weight:Math.max(m.instruction/d.sourceFetch.instructionBytes,m.code/d.sourceFetch.codeBytes,m.count/d.sourceFetch.codeFiles)})}return h.groups=I(f,c),h}export{q as a,D as b};
@@ -0,0 +1 @@
1
+ import{e as t}from"./GZSUTDGX.js";import{a as e}from"./ZLUI3EHB.js";var o=64*1024,n=16*1024,E=48*1024;function s(r){if(r>2097152)throw new e}function p(r){s(r+n+o)}function _(r){return r+n+E+o<=2097152}export{o as a,n as b,E as c,s as d,p as e,_ as f};
@@ -0,0 +1 @@
1
+ var N=8e5,_=512,o=2e5,t=64e3,E=2097152;export{N as a,_ as b,o as c,t as d,E as e};
@@ -0,0 +1,6 @@
1
+ import{Ha as O,Ka as _,Qa as $}from"./QYYN4YKB.js";import{a as R}from"./JS6HTVYX.js";import{b as V}from"./ICJV6KIZ.js";import{f as E,g as F}from"./VDUFPTDD.js";var H="We couldn't see this agent's code, so this may already be handled there.";function ie(e){return Object.values(e).some(s=>[...s].some(t=>V(t)!==null))}function j(e,s){return e==="better_as_code"&&s===!1?H:void 0}function oe(e){return e.sawCode??e.findingQuality?.sawCode}var J="Findings could not be checked a second time; all findings were kept.";function N(e,s){let t=new Set(s),r=new Map,n=new Set,a=new Set,d=new Set;for(let o of e){if(!t.has(o.id)){a.add(o.id);continue}if(n.has(o.id)){d.add(o.id),r.delete(o.id);continue}n.add(o.id),r.set(o.id,o)}return{byId:r,unknownIds:[...a],duplicateIds:[...d]}}function K(e,s){let t=N(e,s);return t.unknownIds.length===0&&t.duplicateIds.length===0}function ae(e,s,t,r={}){let n=e.map((h,w)=>`f${w+1}`),a=!K(s,n),d=a?"Verdict ids did not match; all findings were kept.":t?.failure,o=new Set(t?.sentIds??n),l=new Map(t?.skipped.map(h=>[h.id,h.reason])??[]),u=a?["verdict ids did not match"]:[],p=new Map(s.map(h=>[h.id,h])),i=[...t?.rejectedBatches??[],...a?[{ids:n,verdicts:s}]:[]],c=new Map,f=[],k=r.mode==="offline-simulation"&&r.shadow?.done?N(r.shadow.verdicts,n).byId:new Map;for(let h of i)for(let w of h.verdicts)h.ids.includes(w.id)&&c.set(w.id,w);let b=e.map((h,w)=>{let g=n[w],y=a?void 0:p.get(g),q=p.get(g)??c.get(g),C=o.has(g)||q!==void 0,M=C?"":l.get(g)??"No model call was made before the check stopped.",I="keep",m;C?d?m=d:y?y.reason.trim()?!y.evidenceAgainst?.trim()||!y.evidenceFor?.trim()||y.verdict==="drop"&&/^[\s"'“”‘’]*none found[\s."'“”‘’]*$/i.test(y.evidenceAgainst)?(m="The model supplied no usable evidence for its decision; this finding was kept.",u.push(`${g}: ${m}`)):(I=y.verdict,m=y.reason,f.push(g)):(m="The model returned an empty reason; this finding was kept.",u.push(`${g}: ${m}`)):(m="The model returned no verdict for this finding in the accepted response; it was kept.",u.push(`${g}: ${m}`)):m=M;let x=k.get(g);return!d&&f.includes(g)&&x&&r.shadow?.coverage.answeredIds.includes(g)&&(x.verdict==="drop"&&x.decisive&&x.quotes.some(z=>z.side==="against")?(I="drop",m=x.reason):x.verdict!==I&&(I="keep",m="The checks disagree without decisive contrary evidence; this finding was kept.")),{id:g,title:h.title,verdict:I,reason:m,sent:C,skipReason:M,modelVerdict:q?.verdict??"",modelReason:q?.reason??"",evidenceAgainst:q?.evidenceAgainst??"",evidenceFor:q?.evidenceFor??""}}),v=[],Q=e.filter((h,w)=>{let g=b[w];return g.verdict!=="drop"?!0:(v.push({finding:h,reason:g.reason}),!1)}),U=d?[J]:v.length?[`${v.length} ${R(v.length,"finding was","findings were")} removed after a second read: ${v.map(({finding:h})=>h.title.replace(/\s+/g," ").trim()).join("; ")}`]:[];return{kept:d?e:Q,dropped:v,warnings:U,verdicts:b,...u.length?{diagnostics:u}:{},...i.length?{rejectedBatches:i}:{},...t?.recordAcceptance?{acceptedIds:f}:{}}}var B={critical:0,high:1,medium:2,low:3},L="No strong findings to show.",W=/^[\s"'“”‘’]*none found[\s."'“”‘’]*$/i,Y=/"([^"\n]*(?:\n[^"\n]*)*)"|“([^”]+)”|`([^`]+)`|‘([^’]+)’|'([^'\n]+)'/g;function A(e,s){return N(e.map(t=>({...t,id:t.fingerprint})),s).byId}function S(e,s){return e.repo===s.repo&&e.path===s.path}function T(e,s){let t=e.repos.filter(r=>r.key===s.repo);return t.length===1?t[0].files?.[s.path]:void 0}function P(e,s,t){return e===void 0||s===null||!Number.isInteger(s)||s<1||!t?.trim()?!1:O(e.split(`
2
+ `).slice(s-1).join(`
3
+ `),t)===1}function X(e){return[...e.site?[{repo:e.siteRepo??"",...e.site,excerpt:e.excerpt}]:[],...e.otherSites]}function D(e,s){let t=T(s,e),r=e.line>1?t.split(`
4
+ `).slice(0,e.line-1).join(`
5
+ `)+`
6
+ `:"",n=t.replace(/\s+/g," "),a=e.excerpt.replace(/\s+/g," ").trim(),d=r.replace(/\s+/g," ").length,o=n.indexOf(a,d);if(o>=0)return{from:o,to:o+a.length};let l=a.split(/\s*(?:\.{3}|…)\s*/),u=n.indexOf(l[0],d),p=u;for(let i of l){let c=n.indexOf(i,p);if(c<0)return null;p=c+i.length}return u<0?null:{from:u,to:p}}function Z(e,s,t){if(!S(e,s))return!0;let r=D(e,t),n=D(s,t);return r!==null&&n!==null&&(r.to<=n.from||n.to<=r.from)}function ee(e,s,t,r){if(!F(e.category))return"The finding has no supported evidence category.";if(!e.site||!e.siteRepo)return"The finding has no fetched primary site.";if(s.length<E(e.category))return"The category's required quoted sites are missing.";if(!t)return"Evidence coverage was not recorded unambiguously.";if(t.claimTruncated)return"The claim was truncated in the check.";if(!t.coreComplete||t.missing.length||t.truncated.length)return"Required evidence was unavailable or truncated.";if(t.requested.length===0||t.requested.some(n=>!t.included.some(a=>S(n,a))||T(r,n)===void 0))return"Required files were not included in the check.";for(let n of s){if(!t.requested.some(a=>S(a,n))||!t.included.some(a=>S(a,n)))return"A cited file was not included in the check.";if(!P(T(r,n),n.line,n.excerpt))return"A cited quote could not be verified at its source line."}return E(e.category)===2&&!s.some((n,a)=>s.slice(a+1).some(d=>Z(n,d,r)))?"The category needs distinct quoted sites.":null}function te(e,s){let t=e.cause.replace(/\s+/g," ").trim();for(let a of s){let d=a.excerpt?.replace(/\s+/g," ").trim();d&&(t=t.replaceAll(d,""))}if(!t||t===e.title)return!1;let r=/\b(?:without|before|instead|different|wrong|repeatedly|twice|never|cannot|can't|unable to|fails? to|unapproved|unauthori[sz]ed)\b/i,n=/\b(?:send(?:s|ing)?|sent|delet(?:e[sd]?|ing)|appl(?:y|ies|ied|ying)|grant(?:s|ed|ing)?|revok(?:e[sd]?|ing)|return(?:s|ed|ing)?|rout(?:e[sd]?|ing)|run(?:s|ning)?|execut(?:e[sd]?|ing)|writ(?:e[sd]?|ing)|read(?:s|ing)?|retry|retries|retried|retrying|skip(?:s|ped|ping)?|omit(?:s|ted|ting)?|block(?:s|ed|ing)?|allow(?:s|ed|ing)?|charg(?:e[sd]?|ing)|pay(?:s|ing)?|paid|los(?:e[sd]?|ing)|receiv(?:e[sd]?|ing)|select(?:s|ed|ing)?|exclud(?:e[sd]?|ing)|includ(?:e[sd]?|ing)|schedul(?:e[sd]?|ing))\b/i;return r.test(t)&&n.test(t)}function ne(e,s,t,r){let n=[...e.matchAll(/(?:^|[\s(`*])([^\s"'“”‘’`() *]+):(\d+)(?:-\d+)?/g)].map(o=>{let l=o[1],u=t.included.filter(i=>i.path===l||`${i.repo}:${i.path}`===l),p=[...new Map(u.map(i=>[JSON.stringify([i.repo,i.path]),i])).values()];return{from:o.index,to:o.index+o[0].length,line:Number(o[2]),ref:p.length===1?p[0]:void 0}});if(n.length===0||n.some(o=>!o.ref))return!1;let a=new Map;for(let o of e.matchAll(Y)){let l=o.index,u=l+o[0].length;if(n.some(f=>f.from>=l&&f.to<=u))continue;let p=o.slice(1).find(f=>f!==void 0),i=n.flatMap((f,k)=>P(T(r,f.ref),f.line,p)?[k]:[]);if(i.length!==1)return!1;let c=i[0];a.set(c,[...a.get(c)??[],p])}let d=!1;for(let o=0;o<n.length;o++){let l=n[o],{line:u,ref:p}=l,i=a.get(o)??[];if(i.length===0)return!1;s.some(c=>S(c,p)&&c.line===u&&i.some(f=>O(f,c.excerpt??"")!==null))&&(d=!0)}return d}function G(e,s,t,r){if(!e?.accepted)return"No accepted check verdict is available.";let n=e.verdict;return!n.sent||n.verdict!=="keep"||n.modelVerdict!=="keep"||!n.reason.trim()||n.reason!==n.modelReason?"The check kept the finding without an accepted supporting decision.":ne(n.evidenceFor,s,t,r)?W.test(n.evidenceAgainst)?null:"Contrary check evidence has not been resolved.":"The check supplied no verified supporting quote."}function ve(e){let s=e.findings.map($),t=A(e.coverage,s),r=A(e.verdicts,s),n=new Set(e.shadowRequestedIds??(e.shadowVerdicts===void 0?[]:s)),a=A(e.shadowVerdicts??[],[...n]);return e.findings.map((d,o)=>{let l=s[o],u=X(d),p=t.get(l),i=ee(d,u,p,e.sources),c=j(d.category,e.sawCode)??i;!c&&!te(d,u)&&(c="The finding does not explain a concrete behavioral consequence."),c||(c=G(r.get(l),u,p,e.sources)),!c&&n.has(l)&&(c=G(a.get(l),u,p,e.sources)),!c&&d.sourceNotes&&(d.sourceNotes.support!=="supported"||d.sourceNotes.counterEvidence.length>0)&&(c="Source notes contain uncertain support or unresolved contrary evidence.");let f=c?"not sure":"sure";return{fingerprint:l,support:i?"incomplete":"complete",confidence:f,weak:f!=="sure"||d.severity==="low",reason:c??(d.severity==="low"?"Verified support, but low impact.":"Verified quotes and an accepted keep support the stated consequence.")}})}function ye(e,s,t){let r=e.map(t??(i=>$(i))),n=A(s,r),{active:a,notActive:d}=_(e),o=new Set(a),l=e.flatMap((i,c)=>{if(!o.has(i))return[];let f=r[c],k=n.get(f),b=k?.confidence==="sure",v=b&&k?.support==="complete"&&!k.weak&&i.severity!=="low";return[{finding:i,fingerprint:f,sure:b,strong:v}]}).sort((i,c)=>Number(c.strong)-Number(i.strong)||B[i.finding.severity]-B[c.finding.severity]||Number(c.sure)-Number(i.sure)||(i.fingerprint<c.fingerprint?-1:i.fingerprint>c.fingerprint?1:0)),u=l.filter(i=>i.strong).slice(0,3),p=new Set(u);return{ordered:[...l.map(i=>i.finding),...d],defaultIds:u.map(i=>i.fingerprint),hiddenIds:l.filter(i=>!p.has(i)).map(i=>i.fingerprint),emptyMessage:!u.length&&l.length?L:null}}export{ie as a,oe as b,J as c,N as d,K as e,ae as f,ve as g,ye as h};