@counterfact-labs/cli 0.2.4 → 0.2.5

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 (146) hide show
  1. package/README.md +7 -1
  2. package/bundle/client-release.json +1 -1
  3. package/dist/adapters/anthropic.js +11 -2
  4. package/dist/adapters/completion.js +3 -0
  5. package/dist/adapters/durable-write.js +9 -2
  6. package/dist/adapters/files.js +25 -13
  7. package/dist/adapters/git-ignore.js +28 -14
  8. package/dist/adapters/git.js +1 -1
  9. package/dist/adapters/gitignore-output.js +41 -0
  10. package/dist/adapters/models.js +1 -6
  11. package/dist/adapters/output-paths.js +5 -2
  12. package/dist/adapters/public-instructions.js +1 -1
  13. package/dist/adapters/relay-plan.js +2 -5
  14. package/dist/adapters/release.js +2 -1
  15. package/dist/adapters/repository-files.js +164 -4
  16. package/dist/adapters/repository-root.js +18 -2
  17. package/dist/adapters/results.js +8 -4
  18. package/dist/adapters/settings.js +26 -1
  19. package/dist/adapters/snapshot.js +86 -15
  20. package/dist/analysis-core/analysis/finding-audience-switch.js +1 -0
  21. package/dist/analysis-core/analysis/schemas.js +1 -1
  22. package/dist/analysis-core/analysis/source-notes/types.js +1 -1
  23. package/dist/analysis-core/chunks/377MLK4M.js +21 -0
  24. package/dist/analysis-core/chunks/{D6AWHLRI.js → 3JWEFCTJ.js} +1 -1
  25. package/dist/analysis-core/chunks/{3227KXHF.js → 4H23CSUM.js} +1 -1
  26. package/dist/analysis-core/chunks/5DGPLXYB.js +1 -0
  27. package/dist/analysis-core/chunks/5TATKWLG.js +1 -0
  28. package/dist/analysis-core/chunks/{EH3QQ3T4.js → 6B2HILSY.js} +1 -1
  29. package/dist/analysis-core/chunks/6QY5BV5B.js +14 -0
  30. package/dist/analysis-core/chunks/6U2IR4XB.js +1 -0
  31. package/dist/analysis-core/chunks/A7WJJMRY.js +1 -0
  32. package/dist/analysis-core/chunks/C6X5GDG4.js +1 -0
  33. package/dist/analysis-core/chunks/DLPVYWHZ.js +1 -0
  34. package/dist/analysis-core/chunks/DZZBQDGO.js +1 -0
  35. package/dist/analysis-core/chunks/F3R4J3ND.js +1 -0
  36. package/dist/analysis-core/chunks/FOKDE64Y.js +1 -0
  37. package/dist/analysis-core/chunks/K2GNDX3W.js +1 -0
  38. package/dist/analysis-core/chunks/KTNA2KTN.js +7 -0
  39. package/dist/analysis-core/chunks/KWECQJ6X.js +1 -0
  40. package/dist/analysis-core/chunks/{SL27GMEN.js → M6HYSTQD.js} +1 -1
  41. package/dist/analysis-core/chunks/{ZAA44GPI.js → N7U5N42V.js} +1 -1
  42. package/dist/analysis-core/chunks/NIOS7U6C.js +41 -0
  43. package/dist/analysis-core/chunks/{QMIXCT62.js → OPMA32A6.js} +1 -1
  44. package/dist/analysis-core/chunks/PECX3OXB.js +1 -0
  45. package/dist/analysis-core/chunks/QFY6A3MS.js +66 -0
  46. package/dist/analysis-core/chunks/SKVEBOGA.js +1 -0
  47. package/dist/analysis-core/chunks/{T66VDFXF.js → STI4JE7L.js} +1 -1
  48. package/dist/analysis-core/chunks/SVMEWGD3.js +1 -0
  49. package/dist/analysis-core/chunks/X7WZAA7S.js +1 -0
  50. package/dist/analysis-core/chunks/YDBO7P4X.js +1 -0
  51. package/dist/analysis-core/chunks/YUY436SM.js +1 -0
  52. package/dist/analysis-core/chunks/ZTOVBAG7.js +1 -0
  53. package/dist/analysis-core/contracts/file-safety.js +1 -0
  54. package/dist/analysis-core/contracts/relay-analysis.js +1 -0
  55. package/dist/analysis-core/contracts/requests.js +1 -1
  56. package/dist/analysis-core/conventions/analysis-fit.js +1 -1
  57. package/dist/analysis-core/conventions/file-admission.js +1 -1
  58. package/dist/analysis-core/data/finding-types.js +1 -1
  59. package/dist/analysis-core/findings/sites.js +1 -0
  60. package/dist/analysis-core/github/repo-key.js +1 -1
  61. package/dist/analysis-core/import/outside-loader-sources.js +1 -1
  62. package/dist/analysis-core/index.js +3 -3
  63. package/dist/analysis-core/llm/output-limit.js +1 -1
  64. package/dist/analysis-core/llm/types.js +1 -0
  65. package/dist/analysis-core/requests/answer-formats.js +1 -1
  66. package/dist/analysis-core/requests/headline-request.js +1 -1
  67. package/dist/analysis-core/requests/local-plan.js +1 -1
  68. package/dist/analysis-core/requests/registry.js +1 -1
  69. package/dist/analysis-core/requests/template-version.js +1 -1
  70. package/dist/analysis-core/requests/tools.js +1 -1
  71. package/dist/analysis-core/settings.js +1 -1
  72. package/dist/analysis-core/stages/engine-entry.js +1 -0
  73. package/dist/analysis-core/stages/execution-ports.js +1 -0
  74. package/dist/bundle/seal/deserialise.js +9 -1
  75. package/dist/bundle/seal/engine.js +76 -0
  76. package/dist/bundle/seal/freeze.js +9 -0
  77. package/dist/bundle/seal/metadata.js +3 -0
  78. package/dist/bundle/seal/open-engine.js +26 -0
  79. package/dist/bundle/seal/open.js +2 -8
  80. package/dist/cli/commands/analyze.js +36 -4
  81. package/dist/cli/commands/finding.js +9 -3
  82. package/dist/cli/context.js +4 -1
  83. package/dist/cli/finding-display.js +39 -0
  84. package/dist/cli/finding-lookup.js +92 -0
  85. package/dist/cli/finding-settings.js +5 -0
  86. package/dist/cli/fix-requests.js +42 -0
  87. package/dist/cli/intake-payload.js +19 -11
  88. package/dist/cli/main.js +9 -4
  89. package/dist/cli/mcp.js +65 -18
  90. package/dist/cli/relay-check.js +46 -13
  91. package/dist/cli/relay-preparation.js +28 -5
  92. package/dist/cli/result-check.js +68 -0
  93. package/dist/cli/summary.js +10 -3
  94. package/dist/contract/agent-choice.js +15 -0
  95. package/dist/contract/agent-proposal.js +38 -0
  96. package/dist/contract/attestation.js +106 -0
  97. package/dist/contract/cli-refusals.js +3 -0
  98. package/dist/contract/cli-version.js +1 -1
  99. package/dist/contract/console.js +21 -16
  100. package/dist/contract/engine.js +44 -0
  101. package/dist/contract/findings.js +28 -0
  102. package/dist/contract/fix-requests.js +30 -0
  103. package/dist/contract/messages.js +6 -94
  104. package/dist/contract/public-report.js +1 -0
  105. package/dist/contract/runtime-environment.js +12 -1
  106. package/dist/core/analysis/run-to-end.js +7 -52
  107. package/dist/gatekeeper/attestation.js +1 -1
  108. package/dist/gatekeeper/channel-binding.js +15 -0
  109. package/dist/gatekeeper/cli-api.js +12 -2
  110. package/dist/gatekeeper/connection-exchange.js +16 -12
  111. package/dist/gatekeeper/model.js +2 -1
  112. package/dist/gatekeeper/production-attestation.js +23 -17
  113. package/dist/gatekeeper/trust/policy.js +4 -1
  114. package/dist/gatekeeper/trust/schema.js +4 -0
  115. package/dist/transport/kms.js +25 -0
  116. package/package.json +4 -3
  117. package/dist/adapters/quality.js +0 -6
  118. package/dist/adapters/report.js +0 -29
  119. package/dist/analysis-core/analysis/analysis-flags.js +0 -1
  120. package/dist/analysis-core/analysis/finding-quality/config.js +0 -1
  121. package/dist/analysis-core/analysis/finding-quality/policy.js +0 -1
  122. package/dist/analysis-core/analysis/headlines/attachment.js +0 -1
  123. package/dist/analysis-core/analysis/headlines/input.js +0 -1
  124. package/dist/analysis-core/chunks/3CKW5JIF.js +0 -1
  125. package/dist/analysis-core/chunks/6YCABS5T.js +0 -1
  126. package/dist/analysis-core/chunks/7OYIBWX3.js +0 -1
  127. package/dist/analysis-core/chunks/DRGDIIFA.js +0 -1
  128. package/dist/analysis-core/chunks/FTODBFQW.js +0 -1
  129. package/dist/analysis-core/chunks/HPIAEQHE.js +0 -37
  130. package/dist/analysis-core/chunks/IVDDV6CU.js +0 -14
  131. package/dist/analysis-core/chunks/JF4GYMOZ.js +0 -1
  132. package/dist/analysis-core/chunks/K5OTWBTT.js +0 -22
  133. package/dist/analysis-core/chunks/MXXNED6N.js +0 -7
  134. package/dist/analysis-core/chunks/NCWEOJVJ.js +0 -6
  135. package/dist/analysis-core/chunks/O652FQQH.js +0 -1
  136. package/dist/analysis-core/chunks/OFBJNHC6.js +0 -1
  137. package/dist/analysis-core/chunks/QV2EOS7U.js +0 -1
  138. package/dist/analysis-core/chunks/STZOC7LN.js +0 -1
  139. package/dist/analysis-core/chunks/T2SAP7OV.js +0 -60
  140. package/dist/analysis-core/chunks/T5TREZCQ.js +0 -1
  141. package/dist/analysis-core/chunks/TDNTU4TF.js +0 -1
  142. package/dist/analysis-core/chunks/U5HOEVPE.js +0 -1
  143. package/dist/analysis-core/chunks/UEWL3GMQ.js +0 -1
  144. package/dist/analysis-core/chunks/V7BFUTM7.js +0 -1
  145. package/dist/core/analysis/finding-quality/config.js +0 -4
  146. package/dist/core/analysis/structural-run.js +0 -16
@@ -0,0 +1 @@
1
+ import{A as ke,B as ne,C as wt,D as kt,E as ae,F as St,G as bt,H as vt,I as Ft,J as L,K as Rt,L as yt,M as Et,N as Ot,T as xt,V as Mt,Z as Ct,_ as Bt,a as ge,b as nt,c as at,d as it,e as lt,f as oe,g as Pe,h as ct,i as re,j as N,k as q,l as dt,m as U,ma as It,n as G,o as W,oa as At,p as pt,pa as Lt,q as ft,qa as Tt,r as mt,ra as _t,s as Y,t as ht,u as ut,v as we,w as se,x as gt,y as Pt,z as D}from"./QFY6A3MS.js";import{a as rt}from"./OPMA32A6.js";import{i as ot}from"./K2GNDX3W.js";import{a as te}from"./QDYMR6KS.js";import{a as st}from"./4H23CSUM.js";import{a as Ye}from"./SVMEWGD3.js";import{a as qe,g as Ue,h as Ge,i as We,o as Z}from"./FOKDE64Y.js";import{a as tt}from"./3JWEFCTJ.js";import{C as $,e as ee,f as Je,h as Ve,t as Ze,w as et}from"./377MLK4M.js";import{a as K}from"./326F4XNG.js";import{c as Xe,e as Qe}from"./ZTOVBAG7.js";import{n as z}from"./KTNA2KTN.js";import{b as H,c as J}from"./2PSNOSJ2.js";import{A as O,B as Ae,Gb as $e,I as Le,J as he,Ja as Ke,Ua as Q,V,Y as Te,Z as _e,aa as je,ba as X,bb as De,e as Be,l as me,n as A,o as Ie,ra as R,tb as He,wa as ze,xa as Ne}from"./NIOS7U6C.js";import{b as Ee}from"./724WZMYW.js";import{c as I,e as T}from"./C6X5GDG4.js";import{c as ue}from"./MJGB25S5.js";import{f as fe,i as Oe,j as xe,m as Me,n as Ce}from"./JKWTHRUR.js";var jt=(r,e)=>{let{markerToRead:s}=re(e.settings,{paths:r.map(({path:n})=>n),root:e.dir??void 0,scanFlag:e.flags.scan,marker:null});return s?{strength:"partial",wants:[s]}:null};function zt(r,e,s="bare"){let{scan:n}=re(e.settings,{paths:r.map(({path:t})=>t),root:e.dir??void 0,scanFlag:e.flags.scan,marker:s});return n?{strength:"partial",wants:[]}:null}var no=2e3;function ie(r,e,s,n={}){let t=e.filter(P=>I(P.path,s)!=null),i={},a=[],p=new Map,d=n.mode!=="core"&&Ke(r),f=z(r,t.map(P=>P.path),s,{mode:d?"all":"core",files:n.files}),l=new Set([...f.ignoredPaths,...f.ignoredImportPaths]),o=new Map(f.files.filter(P=>P.role!=="reference").map(P=>[P.path,P])),c=new Map(f.scopes.map(P=>[P.key,O.conventionImport.totalBytes])),m=O.conventionImport.skillBytes,u=me(r)?O.codeAgent.importBytes:1/0,g=0,w=P=>I(P.path,f.ownerOf(P.path).folder)??P.path,h=(P,b)=>{p.set(P.path,{path:P.path,reason:b})},S=(P,b)=>{let v=R(r,P,{purpose:b,route:"github",root:s});return v.admitted?!0:(h(P,v.reason),!1)},k=P=>{if(i[P.path])return;let b=d&&o.get(P.path)?.role==="skill"?"skill":"core",v=f.ownerOf(P.path),M=b==="skill"?m:c.get(v.key),y=P.size??0;if(b==="skill"&&g>=O.conventionImport.skillFiles){h(P,"allowance");return}if(y>M||y>u){h(P,"total");return}i[P.path]=P.ref,a.push(P.path),u-=y,b==="skill"?(m-=y,g++):c.set(v.key,M-y)},E=t.filter(P=>o.has(P.path));for(let P of E)S(P,je(o.get(P.path).role))&&k(P);let F=0;if(ee(r))for(let P of De(new Set(t.map(b=>b.path)))){let b=t.find(v=>v.path===P);if(F>=O.conventionImport.extractionFiles){h(b,"allowance");continue}if(S(b,"source")&&S(b,"definition")){let v=a.length;k(b),a.length>v&&F++}}let B=f.needsExtraction;if(B){let P=t.flatMap(v=>{if(l.has(v.path)||i[v.path]||d&&Le(w(v)))return[];if(!S(v,"extraction"))return[];let M=Ne(w(v));return M===null?[]:[{entry:v,rank:M}]}).sort((v,M)=>v.rank-M.rank||(v.entry.size??0)-(M.entry.size??0)),b=F;for(let{entry:v}of P){if(b>=O.conventionImport.extractionFiles){h(v,"allowance");continue}let M=a.length;k(v),a.length>M&&b++}}if(d&&n.files){let P=Se(r,{entries:e,selected:t.filter(b=>Object.hasOwn(i,b.path)),files:n.files,root:s});for(let b of P.paths)Object.hasOwn(i,b)||(a.push(b),i[b]=t.find(v=>v.path===b).ref);for(let b of P.refused)p.set(b.path,b)}return{...me(r)&&E.some(P=>!Object.hasOwn(i,P.path))?{definitionsOmitted:!0}:{},selectedPaths:a,shaByPath:i,treeListing:t.slice(0,no).map(P=>P.path),needsExtraction:B,refused:[...p.values()]}}function Se(r,e){let s=new Set(e.selected.map(i=>i.path)),n=z(r,e.entries.map(i=>i.path),e.root,{files:e.files}).files.filter(i=>i.role==="skill"&&s.has(i.path)).map(i=>i.path),t=Je(r,{skillPaths:n,paths:e.entries.map(i=>i.path),files:e.files,sizes:new Map(e.entries.map(i=>[i.path,i.size])),selected:e.selected,root:e.root,admission:e.admission,referencePaths:e.referencePaths});return{paths:[...new Set(t?.flatMap(i=>i.files.map(a=>a.path))??[])],refused:t?.flatMap(i=>i.refused)??[]}}var Nt=(r,e)=>{let s=ie(e.settings,r,e.dir??void 0,{mode:e.mode});return{strength:"partial",wants:s.selectedPaths,state:{needsExtraction:s.needsExtraction,treeListing:s.treeListing,shaByPath:s.shaByPath,refused:s.refused,...s.definitionsOmitted?{definitionsOmitted:!0}:{}}}};var Kt=["marker","code-scan","conventions"];var ao={marker:jt,"code-scan":zt,conventions:Nt};function be(r,e,s,n,t=ao){let i={...s,settings:r},a={readers:[]};for(let p of Kt)if(!(n&&!n.includes(p)))try{let d=t[p]?.(e,i);d&&a.readers.push({id:p,claim:d,done:!1})}catch{}return a}function Vo(r){return{readers:r.readers.map(({id:e,done:s})=>({id:e,done:s}))}}function Dt(r){let e=r.readers.find(({id:s})=>s==="conventions").claim;return{selectedPaths:e.wants,...e.state}}function _(r,e,s,n){let t=new Set(s.map(h=>I(h.path,n))),i=r.CF_READING_NOTE_AGENT_ONLY!=="0"&&qe(r),a=new Set(e.agents),p=h=>!t.has(h)&&(!i||a.has(h)),d=e.instruction.filter(p),f=e.code.filter(p),l=e.agents.filter(h=>!t.has(h)),o=new Set(Ge(l)),c=[...d,...f].every(h=>o.has(h)),m=d.length,u=f.length,g=[!c&&m>0&&`${m} instruction file${m===1?"":"s"} left out by the ${Math.round(O.sourceFetch.instructionBytes/1e3)}KB instruction budget`,!c&&u>0&&`${u} analyzable file${u===1?"":"s"} left out by the ${Math.round(O.sourceFetch.codeBytes/1e3)}KB/${O.sourceFetch.codeFiles}-file code budget \u2014 the analysis reads the most agent-shaped files first`,We(l,i)].filter(Boolean),w=s.filter(h=>h.readBytes!==void 0).map(h=>I(h.path,n));return w.length&&g.push(`${w.join(", ")}: only the first ${O.sourceFetch.codeFileBytes/1e3} KB was read`),g.length?g.map((h,S)=>S<g.length-1?String(h).replace(/\.$/,""):h).join("; "):void 0}function le(r,e,s,n={}){let{descriptions:t,priority:i,declarations:a}=Ye(r,e,{root:s},n),p=[],d=t.flatMap(k=>k.admission.admitted?[{entry:k.readEntry,rel:k.rel,score:k.score,size:k.readEntry.size,pool:k.pool,...k.tier===void 0?{}:{tier:k.tier}}]:(p.push({path:k.entry.path,reason:k.admission.reason}),[])),f=d.filter(({score:k})=>k===0).sort(Z),l=d.filter(({score:k})=>k>0).sort(Z),o=[],c={instruction:0,code:0},m={instruction:[],code:[]},u=0,g=(i.enabled?[...d].sort(Z):[...f,...l]).sort((k,E)=>Number(a.has(E.entry.path))-Number(a.has(k.entry.path)));for(let{entry:k,rel:E,pool:F}of g){let B=F==="instruction"?O.sourceFetch.instructionBytes:O.sourceFetch.codeBytes;if(c[F]+k.size>B||F==="code"&&u>=O.sourceFetch.codeFiles){m[F].push(E),p.push({path:k.path,reason:c[F]+k.size>B?"total":"allowance"});continue}o.push(k),c[F]+=k.size,F==="code"&&(u+=1)}let w=Ue(i,p.flatMap(k=>{let E=I(k.path,s);return E===null?[]:[{...k,path:E}]})),h={...m,agents:w},S=_(r,h,o,s);return{selected:o,totalBytes:c.instruction+c.code,refused:p,...S?{skippedNote:S}:{},...i.enabled&&S?{readingNotes:h}:{}}}function ce(r,e){let s=Ae(r),n=s.length?{scopeSelections:s}:{},t={dir:e.root??null,mode:e.profile==="hosted-import"?e.mode??"all":"all",flags:e.profile==="hosted-import"?e.flags??W(r):W(r)};if(e.profile==="hosted-import"){let p=be(r,e.listing,t);return{profile:e.profile,...p,...n,selection:Dt(p),...A(r)?{mode:t.mode}:{}}}let i=e.listing.filter(p=>R(r,p,{purpose:"pointer",route:"github",root:e.root}).admitted),a=be(r,i,t,["marker","code-scan"]);return{profile:e.profile,...a,...n,listing:i,selection:e.selection??le(r,e.listing,e.root),context:t,...e.selection&&A(r)?{selectionPaths:e.selection.selected.map(p=>p.path)}:{}}}import{posix as lo}from"node:path";function Ht(r,e,s){let n=new Set(e.entries.map(l=>l.path)),t=new Set(V(r,[...n])),i=Object.fromEntries(Object.entries(e.files).filter(([l])=>e.selected.some(o=>o.path===l&&o.readBytes===void 0))),a=new Set(_e(r,[...n],i)),p=[],d=new Set;return{read:async l=>{if(a.has(l.path)||e.managedReadPaths?.includes(l.path)&&e.files[l.path]===void 0)return e.refused.push({path:l.path,reason:"unreadable"}),null;p.push(l);try{let o=await s(l);if(o!==null){if(d.has(l.path)){let c=R(r,{path:l.path,size:Buffer.byteLength(o),text:o},{...e.admission,purpose:"skill",route:"github",root:e.root,listing:n,managedFiles:e.files});if(!c.admitted)return e.refused.push({path:l.path,reason:c.reason}),null}if(A(r)||Ee(r)){let c=R(r,{path:l.path,text:o},{...e.admission,purpose:"override",route:"github",root:e.root,listing:n,managedFiles:e.files});if(!c.admitted)return e.refused.push({path:l.path,reason:c.reason}),null}if(e.phase==="manifest"){let c=R(r,{path:l.path,size:Buffer.byteLength(o)},{...e.admission,purpose:"pointer",route:"github",root:e.root});if(!c.admitted)return e.refused.push({path:l.path,reason:c.reason}),null}return o}}catch(o){if(o instanceof X&&(o.reason==="secret-content"||A(r)||d.has(l.path)||t.has(l.path)))return e.refused.push({path:l.path,reason:o.reason}),null;if(e.profile==="hosted-import"&&!d.has(l.path)&&!t.has(l.path))throw o}return e.refused.push({path:l.path,reason:"unreadable"}),null},requestedReads:p,skillReads:d}}import{createHash as io}from"node:crypto";function ve(r){return io("sha256").update(JSON.stringify(r.map(({path:e,ref:s,size:n})=>({path:e,ref:s,size:n})))).digest("hex")}function $t(r,e,s){return $(r)?{settings:Qe(r),commit:s??ve(e),revisionKind:s===void 0?"listing":"commit",completed:[]}:void 0}function qt(r,e,s){let n=r.agentPages;if(!n)return;let t=s??n.listingEntries??r.entries,i=n.revisionKind??(n.commit===ve(n.listingEntries??r.entries)?"listing":"commit");if(i==="commit"&&e!==void 0&&n.commit!==e||i==="listing"&&n.commit!==ve(t))throw new Error("stale-agent-page");return n.commit}function Ut(r,e,s){e.ranked??=se(r,e.scan,new Map);let n=new Map([...we(e.scan.plan),...Object.entries(e.agentPages?.actualSizes??{})]),t=ge(r,e.ranked,n,new Map,{files:{},...e.agentPages?{page:{commit:e.agentPages.commit,scope:e.root,continuation:s}}:{}});t.page&&(e.ranked={...e.ranked,agentPage:t.page,strong:t.strong,possible:t.window,notRead:t.notRead,notReadMore:t.notReadMore});let i=[...t.refused,...e.ranked.skippedFiles??[]];if(e.requestedPaths.push(...i.map(a=>a.path)),e.refused.push(...i),e.profile==="hosted-import"&&t.paths.length||t.page){let a=Pt(r,[],t.paths,e.scan.plan);e.refused.push(...a.refused),e.profile==="hosted-import"?bt(e,a.selected):(kt(r,e),ae(e,a.selected))}else ne(r,e,t.paths,e.scan.plan);e.phase=e.selected.length?"files":"done"}function Gt(r,e,s,n){let t={...e.agentPages.actualSizes};s.forEach((o,c)=>{n[c]!==null&&(t[o.path]=Buffer.byteLength(n[c]))}),e.agentPages={...e.agentPages,actualSizes:t};let i=new Map([...we(e.scan.plan),...Object.entries(t)]),a=new Map(Object.entries(e.files).map(([o,c])=>[o,Buffer.byteLength(c)])),p=new Set(e.skillReferencePaths),d=new Set([...e.conventionPaths,...St(e),...p,...e.markerPath?[e.markerPath]:[]]);for(let o of s)if(d.has(o.path)&&t[o.path]!==void 0){let c=R(r,{path:o.path,size:t[o.path]},{purpose:p.has(o.path)?"skill":"pointer",route:"github",root:e.root,listing:new Set(e.entries.map(u=>u.path)),managedFiles:e.files}),m=Ve(a).left+(a.get(o.path)??0);c.admitted&&t[o.path]<=m?a.set(o.path,t[o.path]):e.refused.push({path:o.path,reason:c.admitted?"total":c.reason})}let f=ge(r,e.ranked,i,a),l=new Set(f.paths);s.forEach((o,c)=>{n[c]!==null&&(l.has(o.path)||d.has(o.path)&&a.has(o.path)?e.files[o.path]=n[c]:e.refused.push(f.refused.find(m=>m.path===o.path)??f.skippedFiles?.find(m=>m.path===o.path)??{path:o.path,reason:"total"}))}),e.ranked={...e.ranked,agentPage:f.page,strong:f.strong,possible:f.window}}function Fe(r){let e=r.ranked,s=e?.agentPage;if(!s||r.phase!=="done")return;let n=[...e.agentInventory.strong,...e.agentInventory.possible],t=new Set(s.selected),i=new Set(s.refusals.map(d=>d.id)),a=n.filter(d=>t.has(Q(d.prompt))&&!i.has(Q(d.prompt))&&r.files[d.prompt.path]===void 0),p=[...s.refusals,...a.map(d=>({id:Q(d.prompt),reason:r.refused.find(f=>f.path===d.prompt.path)?.reason??"missing"}))];r.ranked={...e,strong:e.strong.filter(d=>r.files[d.prompt.path]!==void 0),possible:e.possible.filter(d=>r.files[d.prompt.path]!==void 0),agentPage:{...s,refusals:p,partial:p.length>0,estimatedInputBytes:Object.values(r.files).reduce((d,f)=>d+Buffer.byteLength(f),0)}}}async function Wt(r,e,s){if(!A(r))return!1;let n=Te(r,e.entries.map(o=>o.path));if(!n.length)return!1;let t=new Set(n.flatMap(o=>o.agents)),i=new Map(e.selected.map(o=>[o.path,o])),a=new Set(e.selected.filter(o=>o.readBytes===void 0&&e.files[o.path]!==void 0).map(o=>o.path));e.managedReadPaths||(e.managedReadPaths=[],(e.scan||e.ranked)&&(delete e.scan,delete e.ranked,delete e.manifestReadPaths,e.phase!=="marker"&&(e.phase="scan")));let p=new Set([...e.managedReadPaths,...a]),d=e.entries.filter(o=>t.has(o.path)&&i.has(o.path)&&!p.has(o.path)),f=d.slice(0,D);if(!f.length)return!1;let l=await K(f,4,async o=>{let c=R(r,o,{...e.admission,purpose:"pointer",route:"github",root:e.root});return c.admitted?s(o):(e.refused.push({path:o.path,reason:c.reason}),null)});if(f.forEach((o,c)=>{l[c]!==null&&(e.files[o.path]=l[c],e.selected=e.selected.map(m=>m.path===o.path?o:m))}),e.managedReadPaths.push(...f.map(o=>o.path)),d.length>f.length){for(let o of Object.keys(e.files))!t.has(o)&&n.some(c=>I(o,c.folder)!==null)&&delete e.files[o];e.cursor=0,(e.phase==="done"||e.phase==="manifest")&&(e.phase="files")}return!0}async function Yt(r,e,s){if(e.marketplacePlanned)return!1;let n=new Set(V(r,e.entries.map(o=>o.path)));if(!e.selected.some(o=>n.has(o.path)))return!1;let t=new Set(e.marketplaceReadPaths),a=e.selected.filter(o=>n.has(o.path)&&!t.has(o.path)).slice(0,D),p=await K(a,4,async o=>{let c=R(r,o,{...e.admission,purpose:"definition",route:"github",root:e.root});if(!c.admitted)return e.refused.push({path:o.path,reason:c.reason}),null;let u=(o.readBytes===void 0?e.files[o.path]:void 0)??await s({path:o.path,size:o.size,ref:o.ref});if(u===null)return null;let g=R(r,{path:o.path,size:Buffer.byteLength(u),text:u},{...e.admission,purpose:"definition",route:"github",root:e.root});return g.admitted?u:(e.refused.push({path:o.path,reason:g.reason}),null)});a.forEach((o,c)=>{p[c]!==null?e.files[o.path]=p[c]:delete e.files[o.path]}),e.marketplaceReadPaths=[...t,...a.map(o=>o.path)];let d=new Map(a.flatMap((o,c)=>p[c]===null?[]:[[o.path,Buffer.byteLength(p[c])]]));e.agentPages&&d.size&&(e.agentPages={...e.agentPages,listingEntries:e.agentPages.listingEntries??e.entries}),e.entries=e.entries.map(o=>d.has(o.path)?{...o,size:d.get(o.path)}:o);let f,l=e.marketplaceSelection?new Set(e.marketplaceSelection):void 0;do{let o=new Set(e.marketplaceReadPaths.filter(h=>e.files[h]===void 0)),c=e.entries.filter(h=>!o.has(h.path)&&(!l||l.has(h.path))),m=e.profile==="local-analysis"?le(r,c,e.root,{files:e.files}):ie(r,c,e.root,{files:e.files,mode:e.marketplaceMode}),u="selected"in m?m.selected.map(h=>h.path):m.selectedPaths,g=new Set(u),w=new Map(c.map(h=>[h.path,h]));e.selected=u.map(h=>w.get(h)),e.selectionRefused=m.refused,e.hosted&&"selectedPaths"in m&&(e.hosted.fallback=m,e.hosted.codeMode||(e.hosted.needsExtraction=m.needsExtraction)),f=Object.keys(e.files).filter(h=>n.has(h)&&!g.has(h));for(let h of f)e.refused.push(m.refused.find(S=>S.path===h)??{path:h,reason:"total"});for(let h of Object.keys(e.files))g.has(h)||delete e.files[h]}while(f.length);return e.conventionPaths=z(r,e.entries.filter(o=>!n.has(o.path)||e.files[o.path]!==void 0).map(o=>o.path),e.root,{files:e.files}).files.filter(o=>o.role!=="reference").map(o=>o.path),e.cursor=0,e.marketplacePlanned=!e.selected.some(o=>n.has(o.path)&&!e.marketplaceReadPaths.includes(o.path)),a.length>0||!e.marketplacePlanned}function Re(r,e){let{plan:s,entries:n}=e,t=s.profile==="local-analysis"?s.context.dir??"":e.root??"",i=s.readers.find(l=>l.id==="marker")?.claim.wants[0],a=s.readers.some(l=>l.id==="code-scan"),p=new Map(n.map(l=>[l.path,l])),d=s.profile==="local-analysis"?s.selection.selected:s.selection.selectedPaths.flatMap(l=>p.has(l)?[p.get(l)]:[]),f=ct(r)?N(r,{phase:"start",root:t,paths:n.map(l=>l.path),scanFlag:!!i||a}):void 0;return{...$(r)?{agentPages:$t(r,n,e.commit)}:{},version:1,profile:s.profile,root:t,entries:n,selected:[...d],..."mode"in s?{marketplaceMode:s.mode}:{},..."selectionPaths"in s?{marketplaceSelection:s.selectionPaths}:{},conventionPaths:s.profile==="hosted-import"||$(r)?z(r,n.map(l=>l.path),t).files.filter(l=>l.role!=="reference").map(l=>l.path):[],...e.admission?{admission:e.admission}:{},selectionRefused:s.selection.refused,requestedPaths:[],refused:[],files:{},cursor:0,treeTruncated:e.treeTruncated??!1,...s.profile==="hosted-import"?{hosted:{fallback:structuredClone(s.selection),weakCodeFallback:r.CF_IMPORT_WEAK_CODE_FALLBACK!=="0",codeMode:!1,needsExtraction:s.selection.needsExtraction}}:{},decision:f??(i?{kind:"marker",markerPath:i,scanIfBare:a}:{kind:"settled",markerPath:null,markerKind:null,scan:a}),phase:i?"marker":a?"scan":"files"}}async function Jt(r,e,s){if(e.version!==1)throw new Error("unsupported-import-checkpoint");e.agentPages&&(r=e.agentPages.settings,qt(e,s.commit));let n=ke(r,e.profile),t={...e,selected:[...e.selected],files:{...e.files},requestedPaths:[...e.requestedPaths],refused:[...e.refused],...e.hosted?{hosted:{...e.hosted}}:{},...e.managedReadPaths?{managedReadPaths:[...e.managedReadPaths]}:{}},{read:i,requestedReads:a,skillReads:p}=Ht(n,t,o=>s.read(o));if(await Yt(n,t,i))return L(n,t,a);if(await Wt(n,t,i))return L(n,t,a);if(Ft(n,t),t.phase==="done")return s.resolvedCode&&vt(t,s.resolvedCode),L(n,t,a);if(t.phase==="manifest")return await Rt(n,t,i),Fe(t),L(n,t,a);if(t.phase==="marker"&&t.decision.kind==="marker"){let o=t.decision,c=o.markerPath,m=t.entries.find(g=>g.path===c);if(t.profile==="hosted-import"){let g=R(n,m,{purpose:"pointer",route:"github",root:t.root});if(!g.admitted)return t.refused.push({path:c,reason:g.reason}),t.decision={kind:"settled",markerPath:null,markerKind:null,scan:o.scanIfBare},t.phase=o.scanIfBare?"scan":"files",L(n,t,a)}ne(n,t,[c],t.entries);let u=await i(m);if(u!==null&&(t.files[c]=u),t.decision=N(n,{phase:"read",pending:o,text:u}),t.markerPath=c,t.markerKind=t.decision.markerKind,t.markerKind!=="bare"){let g=t.profile==="hosted-import"?await s.listing():{entries:t.entries,truncated:!1};t.treeTruncated||=g.truncated;let w=await yt(n,{config:et(u).config,markerDir:c.split("/").slice(0,-1).join("/"),selected:t.profile==="hosted-import"?[]:t.selected,admission:{...t.admission,root:t.root||void 0},modelReader:!1,priorRefused:t.refused,refusalMode:"append",requestedMode:"kept-and-refused",listing:async()=>g.entries});if(t.requestedPaths.push(...w.requestedPaths),t.refused=w.refused,t.agentPages&&w.selected){let h=new Set(w.requestedPaths);t.conventionPaths=[...new Set([...t.conventionPaths,...w.selected.filter(S=>h.has(S.path)).map(S=>S.path)])]}t.profile==="hosted-import"?ae(t,w.selected??[]):w.selected&&(t.selected=w.selected)}if(t.phase=t.decision.scan?"scan":"files",t.profile!=="hosted-import"||t.markerKind!=="bare"||t.decision.scan)return L(n,t,a)}if(t.phase==="scan"){if(!t.scan){let o=mt(n,t.entries,t.root,!0,t.decision.kind==="settled"?t.decision.scanPaths:void 0);t.scan=o.state,t.refused.push(...o.refused)}if(!Y(t.scan)){let o=await gt(n,t.scan,i,{modelReader:!1,alreadyRead:new Map,size:{batch:pt,parallel:4}});t.scan=o.scan,o.selection&&(t.ranked=o.selection.ranked)}return Y(t.scan)&&Ut(n,t),L(n,t,a)}if(he(n))for(let o of t.skillReferencePaths??[])p.add(o);let d=t.selected.slice(t.cursor,t.cursor+D),f=d.filter(o=>t.files[o.path]===void 0),l=await K(f,4,i);if(t.agentPages&&t.ranked&&t.scan?Gt(n,t,f,l):f.forEach((o,c)=>{l[c]!==null&&(t.files[o.path]=l[c])}),t.cursor+=d.length,he(n)){let o=Object.fromEntries(Object.entries(t.files).filter(([h])=>t.selected.some(S=>S.path===h&&S.readBytes===void 0))),c=Se(n,{entries:t.entries,selected:t.selected,files:o,root:t.root,admission:t.admission,referencePaths:t.skillReferencePaths});t.refused=H(t.refused,c.refused);for(let h of c.refused)p.has(h.path)&&delete t.files[h.path];if(t.cursor<t.selected.length)return L(n,t,a);let m=new Map(t.selected.map(h=>[h.path,h])),u=c.paths.filter(h=>!m.has(h)||m.get(h).readBytes!==void 0),g=new Set(u.filter(h=>m.has(h)));t.cursor-=t.selected.slice(0,t.cursor).filter(h=>g.has(h.path)).length,t.selected=t.selected.filter(h=>!g.has(h.path));for(let h of g)delete t.files[h];t.requestedPaths.push(...u),u.length&&(t.skillReferencePaths=[...t.skillReferencePaths??[],...u]);let w=new Map(t.entries.map(h=>[h.path,h]));t.selected.push(...u.map(h=>{let S=w.get(h);return{path:h,size:S.size,ref:S.ref}})),wt(t,u,"fallback")}return t.cursor>=t.selected.length&&(t.phase=ee(n)&&t.ranked||A(n)?"manifest":"done"),Fe(t),L(n,t,a)}async function de(r,e){let s=Re(r,e),n;do n=await Jt(r,s,{listing:async()=>({entries:e.entries,truncated:!1}),read:e.read}),s=n.state;while(s.phase!=="done");let t={};return s.markerPath!==void 0&&(t.markerPath=s.markerPath,t.markerKind=s.markerKind),s.ranked!==void 0&&(t.ranked=s.ranked,t.scan=s.scan),{files:n.files,settled:n.settled,skippedFiles:n.refused,...t}}function co(r){return r.CF_IMPORT_PROPOSAL!=="0"}var po=new Set(["secret","secret-content","out-of-scope"]);async function fo(r,e,s,n,t,i,a){let p={...e.admission,purpose:"proposal",route:"local-folder"},d=R(r,n??{path:s},p);if(!d.admitted)return{reason:d.reason};if(!n)return{reason:a??"missing"};if(n.size>i)return{reason:"allowance"};try{let f=t??await(e.proposalRead??e.read)({...n,readBytes:void 0});if(f===null)return{reason:a??"unreadable"};let l=Buffer.byteLength(f),o=R(r,{path:s,size:l,text:f},p);return o.admitted?l>i?{reason:"allowance"}:{text:f}:{reason:o.reason}}catch(f){return f instanceof X?{reason:f.reason,invalidates:po.has(f.reason)}:{reason:"unreadable"}}}async function mo(r,e,s,n,t){let i=new Set(n.map(m=>m.path)),a=new Set(t.map(m=>m.path)),p=new Map(e.entries.map(m=>[m.path,m])),d=n.map(m=>({...p.get(m.path),readBytes:void 0})),f=m=>!i.has(m.path)&&!a.has(m.path),l=[...e.selection.selected.filter(f),...d],o=n.length||t.length?{...e.selection,selected:l,totalBytes:l.reduce((m,u)=>m+(u.readBytes??u.size),0),refused:e.selection.refused.filter(m=>!i.has(m.path))}:e.selection,c=e.evidence??{};if(t.length){let m=e.entries.filter(S=>!a.has(S.path)),{ranked:u,scan:g,markerPath:w,markerKind:h}=await de(r,{entries:m,admission:e.admission,read:async S=>Object.hasOwn(s,S.path)?s[S.path]:null,plan:ce(r,{profile:"local-analysis",listing:m,selection:o})});c={ranked:u,scan:g,markerPath:w,markerKind:h}}return{...c,files:s,selection:o,settled:[...e.settled.filter(f),...d],skippedFiles:(e.skippedFiles??[]).filter(m=>!i.has(m.path)),...t.length?{invalidated:t}:{}}}async function Vt(r,e){if(!co(r)||!e.proposal)return;let s={...e.files},n=new Map(e.entries.map(o=>[o.path,o])),t=new Map(e.unavailable?.map(o=>[o.path,o.reason])),i={},a=[],p=[],d=new Set,f=new Set(e.settled.filter(o=>o.readBytes===void 0).map(o=>o.path)),l=Object.values(s).reduce((o,c)=>o+Buffer.byteLength(c),0);for(let o of e.proposal.files){let c=lo.normalize(o.path.replace(/\\/g,"/")),m=Object.hasOwn(s,c)?Buffer.byteLength(s[c]):0,u=!e.proposalRead&&f.has(c)&&Object.hasOwn(s,c)?s[c]:void 0,g=d.has(c)?{reason:"duplicate"}:await fo(r,e,c,n.get(c),u,O.codeAgent.importBytes-l+m,t.get(c));if(d.add(c),"text"in g)l+=Buffer.byteLength(g.text)-m,s={...s,[c]:g.text},p.push({...o,path:c});else{let w=g.reason==="wrong-type"?"coding-guide":g.reason;i[w]=(i[w]??0)+1,g.invalidates&&Object.hasOwn(s,c)&&(l-=m,delete s[c],a.push({path:c,reason:g.reason}))}}return{...await mo(r,e,s,p,a),proposal:{...e.proposal,files:p},rejectedByReason:i}}import{posix as ye}from"node:path";function ho(r,e={}){return(r.CF_CHOOSE_AGENT??e.CF_CHOOSE_AGENT)!=="0"}function Qt(r,{codeAgents:e,conventions:s,root:n}){if(Be(r)||!ho(r))return;let t=new Set(e.map(f=>f.prompt.path)),i=new Map(s.agentScopes?.map(f=>[f.key,f.folder])),a=uo(e);if(a.push(...s.agents.flatMap(f=>Ze(f)?(f.definitionPaths??[]).filter(l=>f.key===null||!t.has(l)).map(l=>({folder:go(f,l,i,n),reason:l})):[])),a.some(f=>a.every(l=>Xt(f.folder,l.folder))))return;let d=a.filter((f,l)=>!a.some((o,c)=>c!==l&&Xt(o.folder,f.folder)&&(o.folder!==f.folder||c<l)));return{kind:d.length?"choose_agent":"no_agent",candidates:d}}function Xt(r,e){return r==="."||e===r||e.startsWith(`${r}/`)}function pe(r){let e=ye.dirname(r[0]);for(let s of r.slice(1))for(;e!=="."&&s!==e&&!s.startsWith(`${e}/`);)e=ye.dirname(e);return e}function uo(r){let e=r.map(()=>new Set),s=new Map(r.map((a,p)=>[a.unitKey,p])),n=new Map,t=(a,p)=>{p!==void 0&&(e[a].add(p),e[p].add(a))};r.forEach((a,p)=>{t(p,n.get(a.prompt.path)),n.set(a.prompt.path,p);for(let d of a.links??[])t(p,s.get(d.to))});let i=new Set;return r.flatMap((a,p)=>{if(i.has(p))return[];let d=[p],f=[];for(;d.length;){let l=d.pop();i.has(l)||(i.add(l),f.push(r[l].prompt.path,...r[l].ownFiles.map(o=>o.path)),d.push(...e[l]))}return[{folder:pe(f),reason:a.prompt.path}]})}function go(r,e,s,n){return r.key!==null?s.get(r.key)||ye.dirname(e):(s.get(null)??n)||"."}function Zt(r,e=[],s){return e.find(n=>at(n.key,s)===r.id)?.folder??pe(r.files.length?r.files.map(n=>n.path):[r.sourceRef?.path??"."])}function Po(r,e,s,n){let t=new Set(r.flatMap(p=>p.files.map(d=>d.path))),i=new Set(e.flatMap(p=>p.files.map(d=>d.path))),a=e.map(p=>Zt(p,s,n));return p=>i.has(p)||!t.has(p)&&a.some(d=>d==="."||d===""||p.startsWith(`${d}/`))}function wo(r,e,s){let n=Object.fromEntries(Object.entries(e.files).filter(([o])=>s(o))),t=e.selection.selected.filter(o=>Object.hasOwn(n,o.path)),i=e.settled.filter(o=>s(o.path)),a=e.selection.refused.filter(o=>s(o.path)),p=e.selection.readingNotes,d=p?{instruction:p.instruction.filter(s),code:p.code.filter(s),agents:p.agents.filter(s)}:void 0,f=_(r,d??{instruction:[],code:[],agents:[]},i),l={...e.selection,selected:t,refused:a,readingNotes:d,skippedNote:f,totalBytes:t.reduce((o,c)=>o+(c.readBytes??c.size),0)};return{files:n,selection:l,settled:i,skippedFiles:e.skippedFiles.filter(o=>s(o.path)),invalidated:e.invalidated?.filter(o=>s(o.path))}}function ko(r,e,s,n=[],t){let i=s??pe([...e]),a=r.filter(l=>l.kind==="agent").map(l=>{let o=Zt(l,n,t),c=o==="."||o===""||i===o||i.startsWith(`${o}/`);return{node:l,overlap:new Set(l.files.filter(m=>e.has(m.path)).map(m=>m.path)).size,containment:c?o.split("/").filter(m=>m&&m!==".").length+1:0}}).filter(l=>l.overlap||l.containment);a.sort((l,o)=>o.overlap-l.overlap||o.containment-l.containment);let[p,d]=a,f=!!p&&p.overlap===d?.overlap&&p.containment===d?.containment;return{target:f?void 0:p?.node,overlapping:a.filter(l=>l.overlap).map(l=>l.node),tied:f?a.filter(l=>l.overlap===p.overlap&&l.containment===p.containment).map(l=>l.node):[]}}function So(r,e,s){let n=new Set(r.map(a=>a.path)),t=!!s&&!r.some(a=>a.path===s.path&&a.role==="system prompt"),i=t?r.filter(a=>a.path!==s.path).map(a=>a.role==="system prompt"||a.role==="soul"?{...a,role:"reference"}:a):[...r];return i.push(...e.filter(a=>!n.has(a.path)&&a.path!==s?.path).map(a=>({path:a.path,role:a.role==="tools"||a.role==="config"?a.role:"reference",label:null}))),t&&i.unshift({path:s.path,role:"system prompt",label:null}),{files:i,promptChanged:t}}function bo(r,e){let s=new Map(r.map(n=>[n.label,n]));for(let n of e)s.has(n.label)||s.set(n.label,n);return[...s.values()]}function vo(r,e,s,n,t){return n.filter(i=>i.role==="tools"&&(/\.json$/i.test(i.path)||Ie(i.path)==="js")).flatMap(i=>He(r,e,s.files,{toolsPath:/\.json$/i.test(i.path)?i.path:null,toolsTsPath:/\.json$/i.test(i.path)?null:i.path,cliPath:null,mcpPath:null},t))}function Fo(r,e,s,n,t,i){let a=So(n?.files??[],s,t),d={...n??{id:nt("",e.ruleResult.fragment.nodes.map(f=>f.id),()=>{})("agent"),kind:"agent",desc:Pe(null,a.files,!1),meta:null,tools:[],sourceRef:null},label:e.proposalSources.proposal.agentName,files:a.files,tools:bo(n?.tools??[],vo(r,e.repoKey,e.proposalSources,s,i))};return a.promptChanged&&t&&(d.desc=Pe(t.path,a.files,!1),d.sourceRef={path:t.path,line:null}),{agent:d,promptChanged:a.promptChanged}}function Ro(r,e,s,n,t){let{target:i,overlapping:a,tied:p}=s,{fragment:d}=r,f=new Set([e.id,...(t?[...a,...p]:d.nodes).map(m=>m.id)]);for(let m=-1;m!==f.size;){m=f.size;for(let u of d.edges)f.has(u.from)&&f.add(u.to)}let l=d.nodes.filter(m=>f.has(m.id)).map(m=>m===i?e:m);i||l.push(e);let o=d.edges.filter(m=>f.has(m.from)&&f.has(m.to)),c=r.codeAgents?.filter(m=>f.has(m.unitKey)).flatMap(m=>m.unitKey!==i?.id?[m]:n?[]:[{...m,name:e.label,ownFiles:e.files}]);return{fragment:{...d,nodes:l,edges:o},...c?{codeAgents:c}:{}}}function yo(r,e,s){let n=new Set(e.map(a=>a.path)),t=new Set([...r.flatMap(a=>a.files.map(p=>p.path)),...n]),i=n.size;return{fromProposal:i,fromRulesOnly:t.size-i,rejected:Object.values(s).reduce((a,p)=>a+p,0),rejectedByReason:s}}function eo(r){return r.files.some(e=>e.role==="system prompt"||e.role==="soul")}function Eo(r,e,s){if(e.some(t=>t.kind==="agent"&&!eo(t)))return new Set;let n=new Set([oe({code:"no-prompt",detail:"no-conventions"},r),oe({code:"no-prompt"},r),oe({code:"no-prompt",folderAgentsFound:!0},r)]);return s!==void 0&&n.add(lt(r,{scanned:s})),n}function to(r,e){let{ruleResult:s,proposalSources:n,root:t,repoKey:i,scopes:a,scanned:p,agentChoice:d}=e,f=s,{files:l,selection:o,settled:c,skippedFiles:m,invalidated:u}=n,g=[...s.warnings],w=n.proposal.files.map(k=>({...k,path:T(k.path,t)})),h=w.find(k=>k.role==="prompt"),S=!1;if(w.length){let k=ko(f.fragment.nodes,new Set(w.map(E=>E.path)),h?.path,a,t);if(k.target||h){let{agent:E,promptChanged:F}=Fo(r,e,w,k.target,h,g),B=d?.kind==="choose_agent";f={...f,...Ro(s,E,k,F,B)},B&&({files:l,selection:o,settled:c,skippedFiles:m,invalidated:u}=wo(r,n,Po(s.fragment.nodes,f.fragment.nodes,a,t))),S=eo(E);let P=Eo(i,f.fragment.nodes,p);g=g.filter(b=>!P.has(b))}}return{...f,files:l,selection:o,settled:c,skippedFiles:m,invalidated:u,...d&&!S?{agentChoice:d}:{},warnings:g,proposalCounts:yo(f.fragment.nodes,w,n.rejectedByReason)}}function nn(r){let e=[],s=!1,n=Promise.resolve();return t=>new Promise((i,a)=>{e.push({entry:t,resolve:i,reject:a}),!s&&(s=!0,queueMicrotask(()=>{let p=e;e=[],s=!1,n=n.then(async()=>{try{let d=await r(p.map(f=>f.entry));if(d.length!==p.length)throw new Error("bad_request");p.forEach((f,l)=>f.resolve(d[l]))}catch(d){p.forEach(f=>f.reject(d))}})}))})}async function an(r,e){let s=y=>e.localListing?y.filter(j=>R(r,j,{purpose:"listing",route:"local-folder",...e.admission}).admitted):y,n=s(e.entries),t=ce(r,{profile:"local-analysis",listing:n,selection:e.selection}),i=await de(r,{entries:n,read:e.read,admission:e.admission,plan:t}),{files:a,settled:p,skippedFiles:d,...f}=i,l=await Vt(r,{proposal:e.proposal,entries:n,read:e.read,proposalRead:e.proposalRead,admission:e.admission,files:a,settled:p,skippedFiles:d,selection:t.selection,unavailable:e.proposalRefusals,evidence:f}),{files:o,settled:c,skippedFiles:m}=l??i,u=q({...l??f,key:e.repoKey,files:o},t.context.flags,void 0,{markerPolicy:"any-read"}),g=l?.selection??t.selection,w;if(Xe(r)&&e.repository){let y=e.repository,j=await tt(r,{selected:{files:o,listedPaths:n.map(x=>x.path),fallbackName:dt(e),skills:!0},selection:g,codeAgentsFound:it(r,u?.resolved,o),port:e.localListing?{context:()=>y.context(),read:(x,C)=>y.read(x,C),finish:x=>y.finish?.(x),list:async()=>{let x=await y.list();return{...x,entries:s(x.entries)}}}:y}),so=new Set(Object.keys(o).map(x=>T(x,j.root)));if(o=j.files,g=j.selection,w=j.root,w!==void 0){m=m.map(C=>({...C,path:T(C.path,w)})),c=c.map(C=>({...C,path:T(C.path,w)}));let x=new Set(c.map(C=>C.path));c.push(...g.selected.filter(C=>!x.has(C.path)&&Object.hasOwn(o,C.path)))}m=H(m,j.skippedFiles).filter(x=>so.has(x.path)||!Object.hasOwn(o,x.path))}let h={repoKey:e.repoKey,files:o,listedPaths:n.map(y=>T(y.path,w)),...w!==void 0?{root:w}:{},forLocal:!0,code:u},S=U(r,h),k=G(r,S),E=Qt(r,{codeAgents:k.codeAgents??[],conventions:S.conventions,root:w}),F=l?to(r,{ruleResult:k,proposalSources:{...l,files:o,selection:g,settled:c,skippedFiles:m,invalidated:l.invalidated?.map(y=>({...y,path:T(y.path,w)}))},root:w,repoKey:e.repoKey,scopes:S.conventions.agentScopes,scanned:u?.resolved?.scanned,agentChoice:E}):void 0,{settled:B,invalidated:P,...b}=F??{...k,settled:c,invalidated:void 0};F&&(o=F.files,g=F.selection,c=B,m=F.skippedFiles);let v=g.readingNotes?_(r,g.readingNotes,c):g.skippedNote,M=F?F.agentChoice:E;return{...b,...M?{agentChoice:M}:{},files:o,...w!==void 0?{root:w}:{},skippedFiles:P?.length?H(m,P):m,...F?{proposalCounts:F.proposalCounts}:{},warnings:[...new Set([...b.warnings,...v?[v]:[],...J(m)])],selection:g}}var Oo=new Set(Et);function dn(r,e){for(let n of[...Object.keys(e.set),...e.clear])if(!Oo.has(n))throw new Error(`Unknown analysis field: ${n}`);let s={...r,...e.set};for(let n of e.clear)s[n]=void 0;return s}async function xo(r,e,s){let n=Object.entries(e).map(([i,a])=>({path:i,size:Buffer.byteLength(a),ref:i})),t=ft(r,n,s.root,!1,s.scanPaths);for(;!Y(t);)t=await ht(t,async i=>e[i.path]??null);return{scan:se(r,t),summary:ut(t)}}async function oo(r,e,s){let{repoKey:n,root:t,agentConfigurations:i,codingGuides:a,forLocal:p}=s,d=s.flags??W(r),f=Object.keys(e),l=N(r,{phase:"start",paths:f,root:t,scanFlag:d.scan}),o=l.kind==="marker"?N(r,{phase:"read",pending:l,text:e[l.markerPath]??null}):l,c=o.kind==="off"?null:o.markerPath,m=o.kind==="off"?null:o.markerKind;if(o.kind==="off"||!o.scan){let k=q({key:n,files:e,markerPath:c,markerKind:m},d,void 0,{markerPolicy:"any-read"});return{...G(r,U(r,{repoKey:n,files:e,root:t,agentConfigurations:i,codingGuides:a,forLocal:p,code:k})),scanned:!1,resolved:null}}let{scan:u,summary:g}=await xo(r,e,{repoKey:n,root:t,scanPaths:o.scanPaths}),w=q({key:n,files:e,ranked:u,scan:g,markerPath:c,markerKind:m},d,void 0,{markerPolicy:"any-read"});return{...G(r,U(r,{repoKey:n,files:e,root:t,agentConfigurations:i,codingGuides:a,forLocal:p,code:w})),scanned:!0,resolved:w.resolved}}async function ro(r,e){let{state:s,settings:n}=r;if(!xt(n,s).splitCheck||!s.splitEstimateBase)return{next:"inspecting",set:{repoCursor:0},clear:[]};let i=r.execution.preparation?.capUsd??s.splitEstimateBase.capUsd,a={...s.splitEstimateBase,capUsd:i};Ce(a,e.progress.log);let p=It(n,s),d={next:"inspecting",set:{repoCursor:0,splitCheckPriced:!0,splitFindingsPriced:!0},clear:["splitEstimateBase"]};if(!p.length)return d;let f=rt(te(await e.instructions())),l=p.reduce((g,{inventory:w})=>g+fe(Buffer.byteLength(Lt({tools:f},{...w,findings:[]}).prompt))+fe(f.SHAPE_FINDINGS_INPUT_BYTES),0),o=a.lines.find(g=>g.label==="Scope check"),c=ue(n,{template:"scope-findings"},"Scope check",st.mechanical,(o?.inputTokens??0)+p.length*_t,(o?.outputTokens??0)+p.length*Tt),m=a.lines.map(g=>g.label==="Scope check"?c:g);o||m.push(c),m.push(ue(n,{template:"derive-shape"},"Split check",At,l,p.length*ot));let u=Oe(m,i);return xe(u)?(d.estimate=a,d.clear.push("splitCheckPriced","splitFindingsPriced"),delete d.set.splitCheckPriced,delete d.set.splitFindingsPriced,e.progress.log({level:"warn",code:"analysis.split_check_over_cap",counts:{totalUsd:u.totalUsd,capUsd:u.capUsd}}),d.set.warnings=[...s.warnings??[],Me]):d.estimate=u,d}var Nn=async(r,e)=>{e.progress.assertHeld(),e.progress.signal?.throwIfAborted();let{state:s,settings:n}=r,t=s.repos??[];await ze(n,s,e.readers);let i=s.repoCursor??0;if(i>=t.length)return ro(r,e);let a=t[i],p=r.execution.forLocal,d=p?s.mapped?.[i]?{fragment:Ot(s,i),warnings:[]}:await oo(n,a.files??{},{repoKey:a.key,root:a.root,agentConfigurations:a.agentConfigurations??{},forLocal:!0}):void 0,f=d?(()=>{let u=$e(d.fragment,a.key);return{...u,warnings:[...d.warnings,...u.warnings]}})():Bt(n,a,Mt(n,s),s.modelReader??!1,s.projectAgents,te(await e.instructions()).bundleText("model-reader-runtime-prompt")),l=!p&&a.sourceReadNotes?_(n,a.sourceReadNotes,a.selected??[],a.root):void 0,o=p?[]:J((a.refused??[]).filter(u=>u.reason==="secret-content")),c="virtualFiles"in f?f.virtualFiles:void 0,m=[...s.mapped??[]];return m[i]=f.fragment,{next:"mapping",clear:[],set:{...c?{repos:t.map((u,g)=>g===i?{...u,files:{...u.files,...c}}:u)}:{},mapped:m,warnings:[...s.warnings??[],...l?[`${a.key}: ${l}`]:[],...o,...f.warnings,...Ct(a)],repoCursor:i+1}}};export{le as a,be as b,Vo as c,Dt as d,ce as e,co as f,nn as g,an as h,dn as i,Nn as j};
@@ -0,0 +1 @@
1
+ function t(n,e){return n?[n,...e]:[]}export{t as a};
@@ -0,0 +1 @@
1
+ var n=Object.freeze({checkpoint:async()=>{},assertHeld(){},elapsedMs:()=>0,log(){}});function l(t,e=n){return{readers:[],model:t.model,instructions:t.instructions,requestTools:async()=>t.requestTools,context:{},progress:{checkpoint:e.checkpoint.bind(e),assertHeld:e.assertHeld.bind(e),elapsedMs:e.elapsedMs.bind(e),log:e.log.bind(e),signal:e.signal,rethrow:e.rethrow?.bind(e)}}}export{n as a,l as b};
@@ -0,0 +1 @@
1
+ import{n as G}from"./KTNA2KTN.js";import{A as T,Ba as I,Ha as F,I as R,Ka as _,La as $,Ma as P,Na as w,Qa as M,Ra as y,h as l,i as N,l as C,lb as D,sa as E}from"./NIOS7U6C.js";import{a as b,c as x}from"./C6X5GDG4.js";var k="Some of this agent's files weren't read, so findings may be missing.";var B=r=>r.CF_READING_PRIORITY!=="0";var U=new Set(["system prompt","soul","knowledge","config","tools","mcp"]);function L(r){let t=new Set;for(let s of r.nodes)for(let f of s.files??[])U.has(f.role)&&t.add(f.path);let n=new Set(r.edges.filter(s=>s.kind==="delegates").map(s=>s.to));for(let s of r.nodes)n.has(s.id)&&s.sourceRef&&t.add(s.sourceRef.path);return t}function V(r){return new Set([...r.nodes,...r.edges].flatMap(t=>t.sourceRef?[t.sourceRef.path]:[]))}var p=6e4,j=r=>{if(r.length<=p)return r;let t=r.endsWith(E)?E:"";return(t?r.slice(0,-t.length):r).slice(0,p)+t};function Z(r,t){let n=[...r].filter(s=>t[s]!==void 0&&j(t[s])!==t[s]).sort();return n.length===0?null:`${n.length} core file${n.length===1?" was":"s were"} longer than ${p/1e3} KB, so only the first ${p/1e3} KB ${n.length===1?"was":"were"} read: ${n.join(", ")}`}var A=r=>r.split("/").slice(0,-1).join("/"),Y=/(agent|prompt|tool|llm|model)/i,z=2.5;function K(r,t){if(!B(r))return{enabled:!1,tierOf:()=>6};if(t.repos?.some(e=>e.kind==="github"&&b(e.root)))return v(r,t,t.repos);let n=t.scopes??(C(r)?G(r,t.paths,void 0,{agentConfigurations:{}}):void 0),s=t.graph?L(t.graph):new Set,f=new Set(t.graph?.nodes.flatMap(e=>(e.files??[]).filter(o=>o.role==="code"&&l(o.path)).map(o=>o.path))??[]),i=new Set(t.graph?.nodes.flatMap(e=>(e.files??[]).filter(o=>o.role==="system prompt").map(o=>o.path))??[]),a=e=>N(e)&&(I.includes(e.split("/").pop().toLowerCase())||/(^|\/)system_prompt_[^/]+\.md$/i.test(e)||y.test(e)),c=e=>{if(s.has(e))return 1;if(f.has(e))return 2;let o=P(r,e,n),d=R(o,{nested:!0});if(d?.reference)return 5;if(d?.definition||F.test(o))return 4;if(d||/(^|\/)(docs?|references)\//i.test(o)||$.test(e.split("/").pop()))return 5;if(_(o)||w(r,e,n)&&_(e.split("/").pop())||a(e))return 1;if(l(e)){if(Y.test(e))return z;if(M.test(e))return 3}return 6};for(let e of t.paths)c(e)===1&&a(e)&&i.add(e);let m=[...i].flatMap(e=>{let o=A(e);return[o,...o?[A(o)]:[]]}),h=e=>l(e)&&m.some(o=>A(e)===o),u=new Map(t.paths.map(e=>{let o=c(e);return[e,o>2&&h(e)?2:o]})),g=[...u].filter(([e,o])=>o<=2&&l(e)).map(([e])=>e),O=D(Object.fromEntries(g.flatMap(e=>t.files?.[e]===void 0?[]:[[e,t.files[e]]])),t.paths);for(let e of O)l(e)&&!R(P(r,e,n),{nested:!0})&&(u.get(e)??6)>2&&u.set(e,2);return{enabled:!0,tierOf:e=>u.get(e)??c(e)}}function v(r,t,n){let s=new Map;for(let f of n){let i=f.kind==="github"?f.root:void 0,a=t.paths.filter(e=>f.files?.[e]!==void 0&&!s.has(e)),c=e=>x(e,i)??(f.files?.[e]!==void 0?e:null),m=e=>{let o=e?c(e.path):null;return o===null?null:{path:o}},h=t.graph&&{nodes:t.graph.nodes.map(e=>({...e,sourceRef:m(e.sourceRef),files:e.files?.flatMap(o=>{let d=c(o.path);return d===null?[]:[{...o,path:d}]})})),edges:t.graph.edges.map(e=>({...e,sourceRef:m(e.sourceRef)}))},u=a.flatMap(e=>{let o=c(e);return o===null?[]:[o]}),g=Object.fromEntries(a.flatMap(e=>{let o=c(e);return o===null||t.files?.[e]===void 0?[]:[[o,t.files[e]]]})),O=K(r,{paths:u,files:g,graph:h});for(let e of a)s.set(e,O.tierOf(c(e)??e))}return{enabled:!0,tierOf:f=>s.get(f)??6}}function H(r,t){return r.enabled?t.filter(n=>["too-large","total","allowance"].includes(n.reason)&&r.tierOf(n.path)<3).map(n=>n.path):[]}function W(r){return r.slice(0,3)}function q(r,t=!1){let n=W(r);if(!n.length)return;let s=t?". "+k:", so some findings may be missing";return`${n.join(", ")} ${n.length===1?"was":"were"} left out${s}`}function ue(r,t){return q(H(r,t))}function de(r,t){return r.enabled&&r.tierOf(t)<3}function me(r,t,n){let s=T.sourceFetch.codeFileBytes;return r.enabled&&r.tierOf(t)<3&&l(t)&&n>s?{size:s,readBytes:s}:{size:n}}function pe(r,t){return r.enabled&&r.tierOf(t)<3&&l(t)}function S(r){return r.split("/").length-1}function he(r,t,n){return w(r,t,n)?0:M.test(t)?1+Math.min(S(t),3)/10:S(t)<=2?2:S(t)<=4?3:4}function ge(r,t){return(r.tier??0)-(t.tier??0)||r.score-t.score||r.size-t.size}function Oe(r,t,n,s){return[...r].sort((f,i)=>(s?.enabled?s.tierOf(f)-s.tierOf(i):0)||Number(n.has(i))-Number(n.has(f))||t[f].length-t[i].length||(f<i?-1:1))}function Re(r,t,n,s){return[...r].sort((f,i)=>(s?.enabled?s.tierOf(f.path)-s.tierOf(i.path):0)||Number(t.has(i.path))-Number(t.has(f.path))||Number(n.has(i.path))-Number(n.has(f.path))||f.text.length-i.text.length)}export{B as a,L as b,V as c,j as d,Z as e,K as f,H as g,W as h,q as i,ue as j,de as k,me as l,pe as m,he as n,ge as o,Oe as p,Re as q};
@@ -0,0 +1 @@
1
+ import{b,c as l}from"./6U2IR4XB.js";import{a as r}from"./6B2HILSY.js";import{a as u,b as o,c as g}from"./KWECQJ6X.js";import{z as _}from"zod";import{z as c}from"zod";function h(a=r){return c.object({rows:c.array(c.object({key:c.string().describe(a("finding-headlines-key")),headline:c.string().nullable().describe(a("finding-headlines-headline")),ifLeft:c.string().nullable().describe(a("finding-headlines-if-left"))}).strict())}).strict()}var A=h();import{z as n}from"zod";var p=n.object({verdicts:n.array(n.object({id:n.string(),inScope:n.boolean(),reason:n.string()}))});import{z as e}from"zod";var z=3,F=64e3,C=8,H=60,E=e.object({subKind:e.string().describe(r("analysis-structure-schema-1")),kind:e.string().describe(r("analysis-structure-schema-2")),severity:e.string().describe(r("analysis-structure-schema-3")),title:e.string(),cause:e.string(),evidence:e.array(e.object({path:e.string(),line:e.number(),excerpt:e.string()})),children:e.array(e.object({ref:e.string().describe(r("analysis-structure-schema-4")),how:e.string()})),files:e.array(e.object({path:e.string(),action:e.string().describe(r("analysis-structure-schema-5")),role:e.string().describe(r("analysis-structure-schema-6")),unit:e.string().describe(r("analysis-structure-schema-7")),loadMode:e.string().describe(r("analysis-structure-schema-8")),loadVia:e.string().describe(r("analysis-structure-schema-9")),purpose:e.string(),fmName:e.string().describe(r("analysis-structure-schema-10")),fmDescription:e.string(),fmTools:e.array(e.string())})),segments:e.array(e.object({path:e.string(),startLine:e.number(),endLine:e.number(),to:e.string().describe(r("analysis-structure-schema-11")),disposition:e.string().describe(r("analysis-structure-schema-12")),intoPath:e.string().describe(r("analysis-structure-schema-13")),intoLine:e.number().describe(r("analysis-structure-schema-14")),childRef:e.string().describe(r("analysis-structure-schema-15")),heading:e.string().describe(r("analysis-structure-schema-16")),reason:e.string()})),additions:e.array(e.object({path:e.string(),text:e.string(),kind:e.string().describe(r("analysis-structure-schema-17")),heading:e.string()})),reorders:e.array(e.object({path:e.string(),startLine:e.number(),endLine:e.number(),order:e.array(e.number()).describe(r("analysis-structure-schema-reorder-order")),reasons:e.array(e.string()).describe(r("analysis-structure-schema-reorder-reasons"))})).describe(r("analysis-structure-schema-18")),toolMoves:e.array(e.object({tool:e.string(),fromUnit:e.string(),toUnit:e.string(),reason:e.string()}))}),y=e.object({structures:e.array(E)}),f=e.object({verdict:e.string().describe(r("structure-recheck-verdict")),reason:e.string()}),S=e.object({verdicts:e.array(e.object({index:e.number(),inScope:e.boolean(),reason:e.string()}))});import{z as t}from"zod";var j=t.object({verdicts:t.array(o.shape.verdicts.element.extend({decisive:t.boolean(),quotes:t.array(t.object({side:t.enum(["against","for"]),repo:t.string(),path:t.string(),line:t.number().int().positive(),quote:t.string()}))}))});import{z as s}from"zod";var q=4,K=1,J=16e3,k=s.object({path:s.string(),startLine:s.number(),endLine:s.number()}),x=s.object({decision:s.string().describe(r("analysis-split-check-schema-1")),reason:s.string(),frontDoor:s.object({job:s.string().describe(r("analysis-split-check-schema-2")),skills:s.array(s.string()).describe(r("analysis-split-check-schema-3"))}),subAgents:s.array(s.object({name:s.string().describe(r("analysis-split-check-schema-4")),job:s.string().describe(r("analysis-split-check-schema-5")),description:s.string().describe(r("analysis-split-check-schema-6")),skills:s.array(s.string()),tools:s.array(s.string()).describe(r("analysis-split-check-schema-7")),promptSections:s.array(k),knowledgeSections:s.array(k).describe(r("analysis-split-check-schema-8")),resolves:s.array(s.string()).describe(r("analysis-split-check-schema-9")),evidence:s.array(s.object({path:s.string(),line:s.number(),excerpt:s.string()})),handoff:s.string().describe(r("analysis-split-check-schema-10"))}))});function ie(a=m=>m,T){let m={codeJudge:u,findings:l({}),scope:p,structures:y,structureScope:S,check:o,opinion:j,sourceNotes:g,shape:x,recheck:f,findingHeadlines:h(i=>T?.(i)??r(i)),judge:_.object({row:_.string().min(1).nullable()}).strict()},U=b().map(({name:i,schema:d})=>[i,d]);return Object.fromEntries([...Object.entries(m),...U].map(([i,d])=>[i,a(d)]))}export{A as a,z as b,F as c,C as d,H as e,j as f,q as g,K as h,J as i,ie as j};
@@ -0,0 +1,7 @@
1
+ import{C as be,Ca as De,D as _e,Da as Ne,E as T,F as Ce,Fa as le,Ga as We,H as Fe,Ha as ce,I as ie,Ja as Te,S as Ee,Sa as G,U as Oe,V as $e,Va as Ue,W as Le,Wa as te,X as Me,Xa as ne,Y as Ie,a as se,c as K,d as q,e as re,g as ge,ga as Q,j as ke,ka as Ae,l as we,la as Re,m as Pe,n as I,p as D,q as E,r as F,ra as B,s as ye,t as ae,u as Se,v as N,w as z,x as xe,ya as ee,z as ve,za as je}from"./NIOS7U6C.js";import{a as U,c as _,e as H}from"./C6X5GDG4.js";function Z(e,o,n,u=o,r={}){let s=G(e,o.filter(t=>B(e,{path:t},{purpose:"override",route:"github"}).admitted),{root:n,...r});return fe(s,e,u.some(t=>{let d=_(t,n);return d!==null&&se(d)}))}function fe(e,o,n=e.scoped.some(u=>se(u.relativePath))){let u=new Map(e.scoped.map(t=>[t.path,t.relativePath])),r=(t,d,g=!1)=>e.files.find(p=>p.role===t&&p.kind!=="background"&&p.preferred!==!1&&(!d||p.kind===d)&&(!g||p.preferred))?.path??null,s=(t,d,g=!1)=>e.files.filter(p=>p.role===t&&(!d||p.kind===d)&&p.ownerPath!==void 0===g).map(p=>p.path).sort();return{scoped:e.scoped.map(t=>t.path),hasRepositoryGuide:n,developerCompanionPaths:!re(o)&&n?e.scoped.filter(t=>tt(t.relativePath)).map(t=>t.path):[],stripRoot:t=>u.get(t)??t,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:s("sub-agent"),skillPaths:s("skill"),skillNames:Object.fromEntries(e.files.filter(t=>t.role==="skill"&&t.name).map(t=>[t.path,t.name])),skillRefNames:Object.fromEntries(e.files.filter(t=>t.role==="reference"&&t.kind==="skill"&&t.name).map(t=>[t.path,t.name])),templatePaths:s("reference","template"),skillRefPaths:s("reference","skill"),subagentSkillPaths:s("skill",void 0,!0),subagentSkillRefPaths:s("reference","skill",!0),subagentSkillOwners:Object.fromEntries(e.files.filter(t=>t.ownerPath!==void 0).map(t=>[t.path,t.ownerPath]))}}function ze(e){let o=new Set(e.developerCompanionPaths),n=u=>!o.has(u);return{...e,mcpPath:e.mcpPath&&n(e.mcpPath)?e.mcpPath:null,subagentPaths:e.subagentPaths.filter(n),skillPaths:e.skillPaths.filter(n),subagentSkillPaths:e.subagentSkillPaths.filter(n),subagentSkillRefPaths:e.subagentSkillRefPaths.filter(n),skillRefPaths:e.skillRefPaths.filter(n)}}function X(e){let o=ze(e);return!!(o.promptPath||o.toolsPath||o.toolsTsPath||o.cliPath||o.mcpPath||o.soulPath||o.knowledgePath||o.subagentPaths.length||o.skillPaths.length)}function et(e){let o=ze(e);return!!(o.promptPath||o.registry&&o.soulPath||o.subagentPaths.length)}function Be(e,o){return re(e)?X(o):et(o)}function tt(e){return e.toLowerCase()===".mcp.json"||/^\.claude\/(agents|skills)\//i.test(e)}function Ge(e,o){return!!e.configPath||!!e.claudePath&&o==="prompt"||X(e)}var nt=/^(evals?|evaluations)\/.*\.(jsonl?|ya?ml|md|csv)$|\.eval\.(json|ya?ml)$/i;function ot(e){return le.exec(e)?.[1]?.toLowerCase()==="commands"&&/\.md$/i.test(e)}function st(e){return nt.test(e)}function J(e,o,n={}){if(!q(e))return!1;if(n.agentConfigurations){if(n.agentConfigurations[U(n.root)]!==!0)return!1;if(n.skills!==!1)return!0}let u=o.flatMap(g=>{let p=_(g,n.root);return p===null?[]:[{path:g,relative:p}]}),r=u.filter(({path:g})=>B(e,{path:g},{purpose:"definition",route:"github",root:n.root}).admitted);if(!r.some(({relative:g})=>K.includes(g.toLowerCase())))return!1;let s=Z(e,r.map(g=>g.path),n.root,o),t=!!(s.subagentPaths.length||s.toolsPath||n.skills!==!1&&s.skillPaths.length),d=r.some(({relative:g})=>ot(g));return!n.agentConfigurations&&u.some(({relative:g})=>{let p=le.exec(g)?.[1]?.toLowerCase();return!(p==="skills"||(p==="commands"?t:ve(g)&&(t||d)))&&!Re.test(g)&&!Ae.test(g)&&g.toLowerCase()!==ee.toolsSource&&ke(g)})?!1:t||d||r.some(({relative:g})=>st(g))}function me(e,o,n){let u=new Map([[U(n),[]]]);for(let r of o)_(r,n)!==null&&K.includes(r.split("/").at(-1).toLowerCase())&&u.set(r.slice(0,Math.max(0,r.lastIndexOf("/"))),[]);for(let r of o){if(_(r,n)===null)continue;let s=r.slice(0,Math.max(0,r.lastIndexOf("/")));for(;u.get(s)?.push(r),!!s;)s=s.slice(0,Math.max(0,s.lastIndexOf("/")))}return Object.fromEntries([...u].map(([r,s])=>[r,J(e,s,{root:r})]))}function $t(e,o){let n=[...new Set([...Object.keys(o.files),...o.listedPaths??[]])],{root:u,skills:r,agentConfigurations:s}=o;if(!J(e,n,{root:u,skills:r,agentConfigurations:s}))return null;let t=Z(e,Object.keys(o.files),u,o.listedPaths,{agentConfiguration:!0});return t.claudePath?t:null}import{posix as Y}from"node:path";import{posix as rt}from"node:path";function ue(e,o=1){let n=new Set,u=[],r=e.replace(/{#[\s\S]*?#}|{%[-+]?\s*raw\s*[-+]?%}[\s\S]*?(?:{%[-+]?\s*endraw\s*[-+]?%}|$)/g,s=>s.replace(/[^\n]/g," "));for(let s of r.matchAll(/{%[-+]?\s*(include|extends|import|from)\s+(.+?)\s*[-+]?%}/g)){let t=s[2].match(/^(["'])([^"']+)\1(?:\s+(?:as\s+\w+|import\s+.+|ignore missing|with context|without context))?$/),d=o+e.slice(0,s.index).split(`
2
+ `).length-1;u.push({source:t?.[2]??s[2],span:{from:d,to:d},...t?{}:{reason:"dynamic"}})}for(let s of r.matchAll(/{{[-+]?\s*([\w]+)|{%[-+]?\s*(?:if|elif|for\s+\w+\s+in|set\s+\w+\s*=)\s+([\w]+)/g)){let t=s[1]??s[2];!["true","false","none"].includes(t.toLowerCase())&&!/^\d/.test(t)&&n.add(t)}return{variables:[...n],loaders:u}}function Ze(e,o={}){let n=e.split(`
3
+ `),u=[],r=[],s=(t,d,g)=>{let p=new Set;for(let k of Oe(t.join(`
4
+ `))){let P=g?`${g}.${k.key}`:k.key,a={from:d+k.span.from,to:d+k.span.to},m=t.slice(k.span.from-1,k.span.to);p.has(k.key)&&r.push({key:P,span:a,reason:"duplicate"}),p.add(k.key);let w=m[0].slice(m[0].indexOf(":")+1).trim();if(!w||w.startsWith("#")){let f=m.slice(1),i=f.find(S=>S.trim()&&!S.trimStart().startsWith("#"))?.match(/^ */)?.[0].length;if(i){s(f.map(S=>S.slice(i)),a.from,P);continue}}let h=Ee(m.join(`
5
+ `))?.[k.key],c=typeof h=="string"?h:null,l=P.endsWith("_template")||Pe(o,"CF_IMPORT_PROMPT_FIELDS")&&P.endsWith("_prompt");(l&&c===null||/^[!&*]/.test(w))&&r.push({key:P,span:a,reason:"invalid"}),u.push({key:P,span:a,text:n.slice(a.from-1,a.to).join(`
6
+ `),value:c,...l&&c!==null?ue(c,a.from+(/^[|>]/.test(w)?1:0)):{variables:[],loaders:[]}})}};s(n,0,"");for(let t of r.filter(d=>d.reason==="duplicate"))for(let d of u.filter(g=>g.key===t.key||g.key.startsWith(`${t.key}.`)))d.value=null;return{fields:u,unresolved:r}}function at(e,o){let{toks:n}=e,u=[],r=new Map;for(let s=0;s<n.length;s++){if(!ae(n,s))continue;let t=Se(e.text,n[s]),d=u.findLast(P=>P.indent===t);for(;u.length&&u.at(-1).indent>=t;)u.pop();if(r.set(n[s].line,u.some(P=>!P.guard)?null:u.map(P=>P.guard)),!["if","elif","else","for","while","try","except","with","match","case"].some(P=>F(n[s],P)))continue;let g=s+1;for(;g<n.length&&n[g].line===n[s].line;)g++;let p=E(n[g-1],":"),k=null;if(p&&F(n[s],"else")&&d?.guard&&(k={...d.guard,value:!d.guard.value}),p&&F(n[s],"if")){let P=F(n[s+1],"not"),a=s+(P?2:1),m=n.slice(a,g-1).map(c=>c.text).join(""),w=o.owner(s),h=/^[A-Za-z_]\w*$/.test(m)?m:null;if(/^self\.[A-Za-z_]\w*$/.test(m)){let l=n.flatMap((f,i)=>i<s&&ae(n,i)&&o.owner(i)===w&&n.slice(i,i+3).map(S=>S.text).join("")===m?[i]:[]).at(-1);h=l!==void 0&&E(n[l+3],"=")&&F(n[l+4])&&n[l+5]?.line!==n[l].line?n[l+4].text:null}if(h&&w?.params?.includes(h)&&!o.binding(h,s)){let c=n.findIndex((S,v)=>w.from<v&&v<s&&E(S,"(")),l=c>=0&&N(n,c)<s?z(n,c).find(S=>F(n[S.from],h)):void 0,f=l&&n.findIndex((S,v)=>l.from<v&&v<l.to&&E(S,"=")),i=f!==void 0&&f>=0&&f+2===l?.to?n[f+1].text:null;k={parameter:h,value:!P,defaultValue:i==="True"?!0:i==="False"?!1:null}}}u.push({indent:t,guard:k}),r.set(n[s].line,null)}return r}function Nt(e,o,n){let u=D(e,o,"py"),r=te(u,{includeMembers:!0}),s=ne(u,r,{enclosingBindings:!0}),{toks:t}=u,d=at(u,s),g=s.assignments.map(h=>["else","try","finally"].includes(h.name)&&F(t[h.from-2])?{...h,name:t[h.from-2].text,at:h.from-2}:h),p=h=>t.slice(h.from,h.to).map(c=>c.kind==="string"?JSON.stringify(c.value):c.text).join(""),k=(h,c,l,f)=>{let i=s.importBinding(h,c);return i?f?!i.namespace&&i.module.source===l&&i.name===f:i.namespace&&i.module.source===l:!1},P=[],a=new Map,m=new Map;for(let h of s.calls.filter(c=>c.callee.endsWith("read_text"))){let c=p(h),l=/^([A-Za-z_]\w*)\.resources\.files\(("(?:[^"\\]|\\.)*")\)\.joinpath\((.*?)\)\.read_text\(\)$/.exec(c)??/^([A-Za-z_]\w*)\.files\(("(?:[^"\\]|\\.)*")\)\.joinpath\((.*?)\)\.read_text\(\)$/.exec(c);if(!l)continue;let f=s.importBinding(l[1],h.from),i=c.startsWith(`${l[1]}.resources.files(`);if(!(f&&(i?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 v=s.calls.find(x=>x.from<h.from&&h.to<x.to&&x.args.length===1&&x.args[0].from===h.from&&x.args[0].to===h.to&&(x.callee.endsWith(".safe_load")&&k(x.callee.split(".")[0],x.from,"yaml")||k(x.callee,x.from,"yaml","safe_load")));if(!v)continue;let y=JSON.parse(l[2]),b;try{b=JSON.parse(l[3])}catch{}let O=null,M;if(typeof b!="string"||!/^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/.test(y))M="dynamic";else if(rt.isAbsolute(b)||/[\\\0]/.test(b)||b.split("/").includes(".."))M="out-of-scope";else{let x=`${y.replaceAll(".","/")}/${b}`,R=e.indexOf(`${y.split(".")[0]}/`),A=R>=0?e.slice(0,R)+x:null,j=[...n].filter(V=>V===x||V.endsWith(`/${x}`));O=A??(j.length===1?j[0]:null),O?n.has(O)||(M="missing"):M=j.length>1?"dynamic":"missing"}let C=g.find(x=>x.from<=v.from&&v.from<x.to&&s.owner(x.at)===s.owner(v.from)),L={path:O,source:typeof b=="string"?b:l[3],span:{from:t[h.from].line,to:t[h.to-1].endLine},start:t[v.from].start,end:t[v.to-1].end,binding:C?.name??null,forwarded:!1,when:d.get(t[C?.at??h.from].line)??null,className:r.filter(x=>x.kind==="class"&&x.from<h.from&&h.from<x.to).at(-1)?.name??null,...M?{reason:M}:{}};P.push(L),C&&(a.set(L,C),m.set(C,v))}let w=new Set([...a.values()].filter(h=>{let c=m.get(h);return(F(t[h.from],h.name)&&F(t[h.from+1],"or")?h.from+2:h.from)===c.from&&(h.to===c.to||h.to+1===c.to&&E(t[h.to],")"))}));for(let h of P){let c=a.get(h);!c||!w.has(c)||s.owner(c.at)?.name!=="__init__"||(h.forwarded=s.calls.some(l=>s.owner(l.from)===s.owner(c.at)&&t[l.from].start>h.end&&F(t[l.from],"super")&&l.callee.endsWith("__init__")&&l.args.some(f=>F(t[f.from],c.name)&&E(t[f.from+1],"=")&&f.to===f.from+3&&F(t[f.from+2],c.name))&&g.filter(f=>f.name===c.name&&c.at<f.at&&f.at<l.from&&s.owner(f.at)===s.owner(c.at)).every(f=>w.has(f))&&!t.some((f,i)=>i<l.from&&f.start>=h.end&&F(f,c.name)&&s.owner(i)===s.owner(c.at)&&![...w].some(S=>S.at<=i&&i<m.get(S).to))))}return P}function Je(e,o){if(!I(e))return[];let n=new Set(o),u=[];for(let r of[...n].sort()){let s=r.match(/^((?:[^/]+\/)*?)(?:src\/)?minisweagent\/agents\/default\.py$/);if(!s)continue;let t=r.slice(0,-18),d=`${t}/config`,g=`${d}/__init__.py`,p=`${t}/run/mini.py`;if(!n.has(g)||!n.has(p))continue;let k=[...n].filter(P=>_(P,d)!==null&&/\.ya?ml$/.test(P)).sort();k.length&&u.push({folder:s[1].replace(/\/$/,""),configFolder:d,agentPath:r,loaderPath:g,runnerPath:p,configs:k,templates:[...n].filter(P=>_(P,d)!==null&&/\.(?:j2|jinja2?)$/.test(P)).sort()})}return u}function it(e,o){let n=D(e.agentPath,o[e.agentPath]??"","py").toks,u=D(e.loaderPath,o[e.loaderPath]??"","py").toks,r=D(e.runnerPath,o[e.runnerPath]??"","py").toks;if(!["system_template","instance_template"].every(t=>n.some((d,g)=>F(d,t)&&E(n[g-1],".")))||!u.some((t,d)=>F(t,"safe_load")&&E(u[d+1],"("))||!u.some((t,d)=>F(t,"read_text")&&E(u[d+1],"("))||!r.some((t,d)=>F(t,"get_config_from_spec")&&E(r[d+1],"("))||!r.some((t,d)=>F(t,"get_agent")&&E(r[d+1],"("))||!r.some((t,d)=>F(t,"get")&&E(r[d+1],"(")&&r[d+2]?.value==="agent"))return null;let s=r.flatMap((t,d)=>{if(!F(t,"DEFAULT_CONFIG_FILE")||!E(r[d+1],"="))return[];let g=r.slice(d+2).filter(p=>p.line===t.line);return g.flatMap((p,k)=>F(p,"builtin_config_dir")&&E(g[k+1],"/")&&g[k+2]?.kind==="string"?[Y.join(e.configFolder,g[k+2].value)]:[])});return s.length===1?s[0]:null}function Jt(e,o,n,u){let r={variants:[],selectedPaths:[],fields:[],model:null,loaded:[],unresolved:[],edges:[]};if(!I(e))return r;let s=it(o,n);if(!s)return r.unresolved.push({path:o.runnerPath,source:"config",reason:"dynamic"}),r;let t=new Map,d=new Set(Object.keys(n)),g=a=>{let m=B(e,{path:a,text:n[a],size:n[a]===void 0?void 0:Buffer.byteLength(n[a])},{purpose:"pointer",route:"github",root:o.configFolder,listing:d,managedFiles:n});return m.admitted||t.set(a,m.reason),m.admitted},p=new Map([...new Set([...o.configs,...u??[]])].flatMap(a=>g(a)&&Object.hasOwn(n,a)?[[a,Ze(n[a],e)]]:[]));r.variants=o.configs.map(a=>({path:a,fields:(p.get(a)?.fields??[]).map(m=>({...m,path:a}))})),r.selectedPaths=u?[...u]:[s];let k=new Map;for(let a of r.selectedPaths){if(_(a,o.configFolder)===null){r.unresolved.push({path:a,source:a,reason:"out-of-scope"});continue}let m=p.get(a);if(!m){r.unresolved.push({path:a,source:a,reason:t.get(a)??"missing"});continue}r.unresolved.push(...m.unresolved.map(w=>({path:a,source:w.key,span:w.span,reason:w.reason})));for(let w of m.fields)if(/^(?:agent|model|environment)(?:\.|$)/.test(w.key)){for(let h of k.keys())(h.startsWith(`${w.key}.`)||w.key.startsWith(`${h}.`))&&k.delete(h);k.set(w.key,{...w,path:a})}}r.fields=[...k.values()],r.model=k.get("model.model_name")?.value??null;let P=new Set;for(let a of r.fields){let m=new Set([a.path]),w=[{path:a.path,facts:{variables:a.variables,loaders:a.loaders},next:0}];for(;w.length;){let h=w.at(-1),{path:c,facts:l}=h;if(h.next===0)for(let v of l.variables)r.unresolved.push({path:c,source:v,reason:"runtime-variable"});if(h.next>=l.loaders.length){m.delete(c),w.pop();continue}let f=l.loaders[h.next++],i=Y.normalize(Y.join(Y.dirname(c),f.source)),S=f.reason??(Y.isAbsolute(f.source)||_(i,o.configFolder)===null?"out-of-scope":g(i)?m.has(i)?"cycle":Object.hasOwn(n,i)?null:"missing":t.get(i));if(S){r.unresolved.push({path:c,source:f.source,...f.reason?{}:{target:i},span:f.span,reason:S});continue}r.edges.push({from:c,to:i,span:f.span}),!P.has(i)&&(P.add(i),r.loaded.push({path:i}),m.add(i),w.push({path:i,facts:ue(n[i]),next:0}))}}return r}import{posix as oe}from"node:path";function he(e){return/(?:^|\/)(?:(?:[^/]+_)?(?:crew|agents|tasks))\.py$/i.test(e)}function Ve(e,o,n,u=""){let r=D(e,o,"py"),{toks:s}=r,t=te(r,{includeMembers:!0}),d=xe(r),g=ne(r,t,{enclosingBindings:!0}),p={agents:[],tasks:[],refused:[]},k=a=>t.filter(m=>m.from<=a&&a<m.to),P=a=>{if(!F(s[a])||E(s[a-1],".")||!E(s[a+1],"("))return null;let m=g.importBinding(s[a].text,a);return m?.module.source==="crewai"&&["Agent","Task"].includes(m.name)?m.name:null};for(let a=0;a<s.length;a++){let m=P(a);if(!m)continue;let w=N(s,a+1);if(w>=s.length){p.refused.push({path:e,reason:"invalid"});continue}let h=k(a),c=h.filter(C=>C.kind==="class").at(-1),l=h.filter(C=>C.params!==null).at(-1),f=h.filter(C=>C.params===null&&C.kind!=="class"&&C.kind!=="index").at(-1),i=l?.name??f?.name??`line-${s[a].line}`,S=c?`${c.name}.${i}`:i,v=h.some(C=>C.kind==="index")||p.agents.some(C=>C.factory===S)?`${S}@${s[a].start}`:S,y=new Map(z(s,a+1).flatMap(C=>F(s[C.from])&&E(s[C.from+1],"=")?[[s[C.from].text,{from:C.from+2,to:C.to}]]:[])),b={path:e,factory:v,span:{from:s[a].line,to:s[w].endLine},callStart:s[a].start},O=y.get("config");if(O){let C=s.slice(O.from,O.to).map(x=>x.kind==="string"?JSON.stringify(x.value):x.text).join(""),L=/^(?:self\.)?(agents_config|tasks_config)\["([^"\n]+)"\]$/.exec(C);if(L){let x=t.filter($=>$.name===L[1]&&$.params===null&&(c?c.from<$.from&&$.to<=c.to&&!t.some(W=>W.params!==null&&W.from<$.from&&$.from<W.to):!t.some(W=>W.kind==="class"&&W.from<$.from&&$.from<W.to))),R=x.length===1?Ke(r,x[0]):void 0,A=c&&ct(r,c,g),j=R?de(r,R):x.length===0&&A?`config/${L[1]==="agents_config"?"agents":"tasks"}.yaml`:null,V=null;if(j===null||/[\\\0${}*]/.test(j))p.refused.push({path:e,reason:"dynamic"});else{let $=oe.normalize(oe.join(oe.dirname(e),j));j.startsWith("/")||$===".."||$.startsWith("../")||_($,u)===null?p.refused.push({path:$,reason:"out-of-scope"}):n.has($)?V=$:p.refused.push({path:$,reason:"missing"})}b.config={path:V,key:L[2]}}else b.config={path:null,key:""},p.refused.push({path:e,reason:"dynamic"})}let M=pe(r,y.get("tools"),n,t,l,c,p.refused,g);if(m==="Agent"){let C=Object.fromEntries(["role","goal","backstory"].flatMap(L=>{let x=y.get(L)&&de(r,y.get(L));return y.has(L)&&x==null&&p.refused.push({path:e,reason:"dynamic"}),x==null?[]:[[L,x]]}));p.agents.push({...b,instructions:C,tools:M})}else{let C=A=>lt(r,A,c,t,d),L=C(y.get("agent")),x=y.get("context"),R=x&&E(s[x.from],"[")&&N(s,x.from)===x.to-1?z(s,x.from):[];x&&(!E(s[x.from],"[")||R.some(A=>!C(A)))&&p.refused.push({path:e,reason:"dynamic"}),y.has("agent")&&!L&&p.refused.push({path:e,reason:"dynamic"}),p.tasks.push({...b,agent:L,context:R.flatMap(A=>C(A)??[]),tools:M})}a=w}return p}function Ke(e,o){let n=o.from+1;for(;n<o.to&&!E(e.toks[n],"=");)n++;return n<o.to?{from:n+1,to:o.to}:void 0}function de(e,o){let{toks:n}=e;return o.to===o.from+1&&n[o.from]?.kind==="string"&&ye(n[o.from]).closed?n[o.from].value:F(n[o.from],"dedent")&&E(n[o.from+1],"(")&&N(n,o.from+1)===o.to-1?de(e,{from:o.from+2,to:o.to-1}):null}function lt(e,o,n,u,r){if(!o)return null;let s=e.toks.slice(o.from,o.to).map(d=>d.text).join(""),t=/^(self\.)?([A-Za-z_]\w*)(?:\(\))?$/.exec(s);if(t&&!t[1]){let d=u.filter(p=>p.params!==null&&p.from<o.from&&o.from<p.to),g=p=>u.filter(k=>k.params!==null&&k.from<p&&p<k.to).at(-1);if(d.some(p=>p.params?.includes(t[2]))||u.some(p=>p.name===t[2]&&d.includes(g(p.from)))||r.some(p=>p.names.includes(t[2])&&d.includes(g(e.toks.findIndex(k=>k.line===p.line)))))return null}return t?t[1]&&n?`${n.name}.${t[2]}`:t[2]:null}function pe(e,o,n,u,r,s,t,d,g=new Set){if(!o)return[];let{toks:p}=e;if(E(p[o.from],"[")&&N(p,o.from)===o.to-1)return z(p,o.from).flatMap(i=>pe(e,i,n,u,r,s,t,d,new Set(g)));let k=p[o.from];if(!F(k)||g.has(k.text))return t.push({path:e.path,reason:"dynamic"}),[];if(g.add(k.text),r?.params?.includes(k.text))return t.push({path:e.path,reason:"dynamic"}),[];let a=u.filter(i=>i.name===k.text&&i.params===null&&i.kind!=="class"&&i.from<o.from).filter(i=>{let S=u.filter(v=>(v.params!==null||v.kind==="class")&&v.from<i.from&&i.from<v.to).at(-1);return!S||S===r||!r&&S===s}),m=r&&a.filter(i=>r.from<i.from&&i.to<=r.to),w=m&&m.length?m:a;if(w.length===1){let i=Ke(e,w[0]);if(i)return pe(e,i,n,u,r,s,t,d,g)}if(w.length>1)return t.push({path:e.path,reason:"dynamic"}),[];let h=d.importBinding(k.text,o.from),c=h?.module,l=null;if(c){let i=oe.dirname(e.path).split("/"),S=i.lastIndexOf(c.source.split(".")[0]),v=c.source.startsWith(".")?c.source:S<0?`.${c.source}`:".".repeat(i.length-S)+c.source.split(".").slice(1).join(".");l=Ue(e.path,v,[h.name],"py",n)??null,!l&&(c.source.startsWith(".")||S>=0)&&t.push({path:e.path,reason:"missing"})}else if(!u.some(i=>i.name===k.text&&(i.kind==="class"||i.params!==null)))return t.push({path:e.path,reason:"dynamic"}),[];let f=o.from+1;for(;E(p[f],".")&&F(p[f+1]);)f+=2;return f<o.to&&(!E(p[f],"(")||N(p,f)!==o.to-1)?(t.push({path:e.path,reason:"dynamic"}),[]):[{name:p.slice(o.from,f).map(i=>i.text).join(""),path:c?l:e.path}]}function ct(e,o,n){let u=e.text.slice(0,e.toks[o.from].start).trimEnd().split(`
7
+ `);for(let r=u.length-1;r>=0;r--){let s=/^\s*@([A-Za-z_]\w*)(?:\(\))?\s*$/.exec(u[r]);if(!s)break;let t=n.importBinding(s[1],o.from);if(t?.module.source==="crewai.project"&&t.name==="CrewBase")return!0}return!1}var ft=new Set([...je,ee.soul].map(e=>e.toLowerCase())),mt=["templates","default_prompts","prompts/default","docs","evals","benchmarks"],ut=["tests","__tests__","fixtures","test_data","evals","benchmarks","templates","default_prompts","prompts/default","docs"];function Xe(e,o=""){return e===o?null:`folder:${e}`}function Pn(e,o,n){let u=Ye(e,o,n),r=U(n),s=o.filter(m=>!T(e,m,r)),t=s.filter(m=>u.ownerOf(m)?.key===null),d=Z(e,t,r),g=X(d)||!!d.configPath,p=G(e,t,{root:r}).files.filter(m=>m.role!=="reference"&&m.kind!=="background"),k=new Set(p.map(m=>m.relativePath)),P=p.flatMap(m=>m.role==="sub-agent"?[m.relativePath.slice(0,-3)]:m.role==="skill"?[m.relativePath.slice(0,m.relativePath.lastIndexOf("/"))]:[]),a=new Map(u.scopes.map(m=>[m.folder,{scope:m,paths:[]}]));for(let m of[...new Set(s)]){let w=u.ownerOf(m);if(!w)continue;let h=_(m,r),c=h.split("/");if(w.key===null&&g&&c.length>1&&!k.has(h)&&!P.some(l=>_(h,l)!==null)){let l=c.slice(0,-1).findIndex((i,S)=>![...k].some(v=>v.startsWith(`${c.slice(0,S+1).join("/")}/`))),f=H(c.slice(0,l<0?-1:l+1).join("/"),r);a.has(f)||a.set(f,{scope:{key:Xe(f,r),folder:f,kind:"folder"},paths:[]}),w=a.get(f).scope}a.get(w.folder).paths.push(m)}return[...a.values()].sort((m,w)=>m.scope.folder<w.scope.folder?-1:m.scope.folder>w.scope.folder?1:0).map(({scope:m,paths:w})=>{let h=Z(e,w,m.folder),c=u.scopes.includes(m);return{scope:m,paths:w,convention:c&&(!!m.managed||!!m.miniSwe||m.kind==="crew"&&!m.agentsPath.endsWith(".py")||Be(e,h)),markerPath:c?h.configPath:null}})}function Ye(e,o,n,u={},r){let s=U(n);r??=q(e)?me(e,o,n):void 0;let t=we(e),d=Le(e,o,u),{scopes:g,skipped:p,pluginFolders:k}=t?dt(e,o,s,d,r):{scopes:[{key:null,folder:s,kind:"root"}],skipped:[],pluginFolders:[]},P=c=>He(g,c),a=new Set(o),m=o.filter(c=>T(e,c,s)||P(c)&&(t&&Q(e,c,k)||_e(e,c,{root:s,listing:a}))),w=new Set(I(e)?Object.entries(u).filter(([c])=>c.endsWith(".py")&&P(c)).flatMap(([c,l])=>Ve(c,l,new Set(o),s).agents.flatMap(f=>f.tools.flatMap(i=>i.path??[]))):[]),h=t?o.filter(c=>{let l=P(c);return!w.has(c)&&l?.kind==="crew"&&_(c,l.folder)?.toLowerCase().startsWith("tools/")}):[];return{scopes:g,skipped:p,ownerOf:P,pluginFolders:k,ignoredPaths:m,ignoredImportPaths:h,...d.length?{pluginDeclarations:d.filter(c=>k.includes(c.folder))}:{}}}function He(e,o){return e.findLast(n=>_(o,n.folder)!==null)??null}function dt(e,o,n,u,r){let s=[...new Set(o)].filter(a=>!Q(e,a)).sort().flatMap(a=>{let m=_(a,n);return m===null?[]:[{path:a,relativePath:m}]}),t=[],d=new Map,g=s.filter(a=>!T(e,a.path,n)).map(a=>a.path);for(let a of Ie(e,g))d.set(a.folder,a.agents.map(m=>({path:m,plugin:!1,crew:!1,checkPath:`${a.folder}/`,managed:a})));for(let a of Je(e,g))d.set(a.folder,[...d.get(a.folder)??[],{path:a.agentPath,plugin:!1,crew:!1,checkPath:`${a.folder}/`,miniSwe:a}]);for(let{path:a,relativePath:m}of s){let w=m.split("/"),h=w.pop().toLowerCase(),c=H(w.join("/"),n),l=w.length>0&&(ft.has(h)||K.includes(h)&&J(e,o,{root:c,agentConfigurations:r})),f=Me(e,a,u);f===n&&!T(e,a,n)&&!t.includes(n)&&t.push(n);let i=f!==null&&f!==n&&!!_(`${f}/`,n),S=m.toLowerCase()==="config/agents.yaml"||m.toLowerCase().endsWith("/config/agents.yaml"),v=I(e)&&he(a)&&!/(?:^|\/)(?:tasks|[^/]+_tasks)\.py$/i.test(a),y=S||v;if(!l&&!i&&!y)continue;let b=S?a.slice(0,-18).replace(/\/$/,""):v?a.slice(0,Math.max(0,a.lastIndexOf("/"))):i?f:H(w.join("/"),n),O=d.get(b)??[];O.push({path:a,plugin:i,crew:y,checkPath:i?`${b}/`:a}),d.set(b,O)}let p=Fe(e),k={settings:e,folder:n,scoped:s,candidates:d,rootPlugins:t,excludedFolders:p?mt:ut},P=qe(k,new Set);if(p){let a=[...new Set(P.accepted.map(l=>l.folder))].filter(l=>l!==n),m=s.filter(l=>!T(e,l.path,n)&&!a.some(f=>_(l.path,f)!==null)).map(l=>l.path),w=G(e,m,{root:n,folderAgentsFound:a.length>0,agentConfiguration:J(e,o,{root:n,agentConfigurations:r})}),h=Qe(e,w,a.length>0)?[{path:`${n}/`,checkPath:`${n}/`}]:[],c=Ce([...P.accepted,...h],l=>l.checkPath,{root:n,listing:new Set(s.map(l=>l.path)),settings:e});if(P.accepted.some(l=>c(l.checkPath))){let l=new Set([...d.values()].flat().filter(f=>c(f.checkPath)).map(f=>f.path));P=qe(k,l)}}return P.skipped.sort((a,m)=>a.path<m.path?-1:a.path>m.path?1:0),{scopes:P.scopes,skipped:P.skipped,pluginFolders:P.pluginFolders}}function qe({settings:e,folder:o,scoped:n,candidates:u,rootPlugins:r,excludedFolders:s},t){let d=[{key:null,folder:o,kind:"root"}],g=[],p=[...r],k=[],P=new Map;for(let a of[...u.keys()].sort()){let m=u.get(a),w=He(d,m[0].path),h=P.get(w.folder)??pt(n.map(y=>y.path),w.folder);P.set(w.folder,h);let c=[];for(let y of m){let{path:b,checkPath:O}=y;if(Q(e,b,p))continue;let M=T(e,b,o)?"excluded-folder":a===o?null:t.has(b)?"excluded-folder":ht(_(O,o),_(O,w.folder),h,be(e,b,o)?[]:s);M?g.push({path:b,reason:M}):(c.push(y),k.push({path:b,folder:a,checkPath:O}))}if(!c.length)continue;let l=(I(e)?c.find(y=>y.crew&&y.path.endsWith("config/agents.yaml")):void 0)??c.find(y=>y.crew),f=Xe(a,o),i=l?{key:f,folder:a,kind:"crew",agentsPath:l.path,tasksPath:n.find(y=>_(y.path,a)?.toLowerCase()==="config/tasks.yaml")?.path??null}:{key:f,folder:a,kind:"folder"},S=c.find(y=>y.managed)?.managed;S&&(i.managed=S);let v=c.find(y=>y.miniSwe)?.miniSwe;v&&(i.miniSwe=v),a===o?d[0]=i:d.push(i),c.some(y=>y.plugin)&&!p.includes(a)&&p.push(a)}return{scopes:d,skipped:g,pluginFolders:p,accepted:k}}function yn(e,o,n,u={}){let r=u.agentConfigurations??(q(e)?me(e,u.listedPaths??o,n):void 0),s=Ye(e,o,n,u.files,r),{scopes:t,ownerOf:d,ignoredPaths:g}=s,p=new Set(g),k=new Map(t.map(l=>[l,[]]));for(let l of o){if(p.has(l))continue;let f=d(l);f&&k.get(f).push(l)}let P=t.map(l=>G(e,k.get(l),{root:l.folder,mode:u.mode,agentConfiguration:J(e,u.listedPaths??o,{root:l.folder,agentConfigurations:r}),folderAgentsFound:l.key===null&&(t.length>1||l.kind==="crew")})),a=(l,f)=>Qe(e,l,t[f].key===null&&(t.length>1||t[f].kind==="crew")),m=t.length===1?P:P.filter((l,f)=>t[f].managed||t[f].miniSwe||t[f].kind==="crew"||a(l,f)),w=!m.length||m.some(l=>{let f=P.indexOf(l);return t[f].managed||t[f].miniSwe?!1:t[f].kind==="crew"&&!a(l,f)?t[f].agentsPath.endsWith(".py"):!l.registry&&(!l.files.some(i=>i.role==="prompt")||!l.files.some(i=>i.role==="tool file"))}),h=new Set((s.pluginDeclarations??[]).map(l=>l.path));for(let l of $e(e,o))/marketplace\.json$/i.test(l)&&h.add(l);let c=P.flatMap((l,f)=>{let i=t[f],S=[...h].filter(y=>!p.has(y)&&d(y)===i).map(y=>({path:y,relativePath:_(y,i.folder),role:"marker",kind:"entry"}));if(i.miniSwe)return[...l.files,...S,...[...i.miniSwe.configs,...i.miniSwe.templates,i.miniSwe.agentPath,i.miniSwe.loaderPath,i.miniSwe.runnerPath].map(y=>({path:y,relativePath:_(y,i.folder),role:"knowledge",kind:"entry"}))];if(i.managed)return[...[...i.managed.agents,...i.managed.configs].flatMap(y=>{let b=ie(_(y,i.folder))?.definition;if(b&&(u.mode==="core"||!Te(e)))return[];let O=i.managed.agents.includes(y);return[{path:y,relativePath:_(y,i.folder),role:O?"prompt":b?"skill":"knowledge",kind:O?"entry":b?"skill":"json"}]}),...S];if(i.kind!=="crew")return[...l.files,...S];let v=[{path:i.agentsPath,relativePath:_(i.agentsPath,i.folder),role:"prompt",kind:"entry"}];if(I(e))for(let y of k.get(i)){let b=_(y,i.folder);y!==i.agentsPath&&(he(b)&&!b.includes("/")||/^config\/[^/]+\.ya?ml$/i.test(b))&&v.push({path:y,relativePath:b,role:"knowledge",kind:"entry"})}return i.tasksPath&&v.push({path:i.tasksPath,relativePath:_(i.tasksPath,i.folder),role:"knowledge",kind:"entry"}),[...l.files,...v,...S]});return{...s,files:c,needsExtraction:w}}function Qe(e,o,n){let u=fe(o,e),r=ge({codeAgentsFound:!1,folderAgentsFound:n,otherDefinitions:X(u),agentConfiguration:o.files.some(s=>s.role==="prompt"&&s.kind==="fallback")},e);return Ge(u,r)}function pt(e,o){let n=new Set;for(let u of e){let r=_(u,o);r!==null&&ce.test(r)&&n.add(r.slice(0,-3).toLowerCase())}return n}function ht(e,o,n,u){let r=e.toLowerCase();if(u.some(d=>`/${r}`.includes(`/${d}/`)))return"excluded-folder";let s=r.slice(0,r.lastIndexOf("/"));if(ie(e,{nested:!0})||We.some(d=>s===d||s.endsWith(`/${d}`)))return"skill-folder";if(`/${r}`.includes(`/${De}/${Ne}/`)||ce.test(o))return"sub-agent-folder";let t=o.toLowerCase().split("/");return t.some((d,g)=>n.has(t.slice(0,g).join("/")))?"sub-agent-folder":null}export{Z as a,ze as b,X as c,Be as d,Ge as e,me as f,$t as g,Ze as h,Nt as i,Jt as j,Ve as k,Pn as l,Ye as m,yn as n};
@@ -0,0 +1 @@
1
+ import{z as e}from"zod";var o=e.object({isSystemPrompt:e.boolean(),name:e.string(),reason:e.string()}),i=e.object({verdicts:e.array(e.object({id:e.string(),evidenceAgainst:e.string(),evidenceFor:e.string(),verdict:e.enum(["keep","drop"]),reason:e.string()}))}),r=e.object({sites:e.array(e.object({index:e.number(),role:e.string(),meaning:e.string(),keyPhrase:e.string()})),support:e.string(),supportNote:e.string(),counterEvidence:e.array(e.object({repo:e.string(),path:e.string(),line:e.number(),excerpt:e.string(),meaning:e.string()}))});import{z as t}from"zod";var n=["Says","But also says","Unclear","Context","Requirement","What actually happens","Why it's a gap","Evidence"],p=t.object({sites:t.array(t.object({index:t.number().int().nonnegative(),role:t.enum(n),meaning:t.string(),keyPhrase:t.string()})),support:t.enum(["supported","partly","not_supported"]),supportNote:t.string(),counterEvidence:t.array(t.object({repo:t.string(),path:t.string(),line:t.number().int().positive(),excerpt:t.string(),meaning:t.string()}))});export{o as a,i as b,r as c,n as d,p as e};
@@ -1 +1 @@
1
- import{b as t}from"./3227KXHF.js";var r=16e3;function n(o){return!o.includes("haiku")}function i(o){return o.maxTokens??(n(o.model)?t:r)}export{r as a,n as b,i as c};
1
+ import{d as t}from"./4H23CSUM.js";var r=16e3;function n(o){return!o.includes("haiku")}function i(o){return o.maxTokens??(n(o.model)?t:r)}export{r as a,n as b,i as c};
@@ -1 +1 @@
1
- import{a as e}from"./3227KXHF.js";var t=e.mechanical,i=4096;function a(n){return{template:"finding-headlines",answerFormat:"findingHeadlines",model:t,limits:{maxTokens:i},inputs:{evidence:n}}}export{t as a,i as b,a as c};
1
+ import{a as e}from"./4H23CSUM.js";var t=e.mechanical,i=4096;function a(n){return{template:"finding-headlines",answerFormat:"findingHeadlines",model:t,limits:{maxTokens:i},inputs:{evidence:n}}}export{t as a,i as b,a as c};