@counterfact-labs/cli 0.1.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +176 -42
- package/bundle/client-release.json +7 -0
- package/bundle/sealed.json +908 -0
- package/dist/adapters/anthropic.js +151 -0
- package/dist/adapters/completion.js +112 -0
- package/dist/adapters/durable-write.js +34 -0
- package/dist/adapters/files.js +144 -0
- package/dist/adapters/folder-path.js +6 -0
- package/dist/adapters/git-ignore.js +49 -0
- package/dist/adapters/git.js +44 -0
- package/dist/adapters/ignored-files.js +36 -0
- package/dist/adapters/instructions.js +35 -0
- package/dist/adapters/models.js +51 -0
- package/dist/adapters/output-paths.js +92 -0
- package/dist/adapters/prompt-cache.js +28 -0
- package/dist/adapters/public-instructions.js +36 -0
- package/dist/adapters/quality.js +6 -0
- package/dist/adapters/relay-plan.js +15 -0
- package/dist/adapters/release.js +62 -0
- package/dist/adapters/report.js +29 -0
- package/dist/adapters/repository-files.js +199 -0
- package/dist/adapters/repository-root.js +120 -0
- package/dist/adapters/results.js +9 -0
- package/dist/adapters/settings.js +26 -0
- package/dist/adapters/snapshot.js +68 -0
- package/dist/analysis-core/analysis/analysis-flags.js +1 -0
- package/dist/analysis-core/analysis/code-agents/skipped-files.js +1 -0
- package/dist/analysis-core/analysis/finding-quality/config.js +1 -0
- package/dist/analysis-core/analysis/finding-quality/policy.js +1 -0
- package/dist/analysis-core/analysis/headlines/attachment.js +1 -0
- package/dist/analysis-core/analysis/headlines/input.js +1 -0
- package/dist/analysis-core/analysis/headlines/types.js +1 -0
- package/dist/analysis-core/analysis/schemas.js +1 -0
- package/dist/analysis-core/analysis/source-notes/types.js +1 -0
- package/dist/analysis-core/chunks/2PSNOSJ2.js +1 -0
- package/dist/analysis-core/chunks/3227KXHF.js +1 -0
- package/dist/analysis-core/chunks/326F4XNG.js +1 -0
- package/dist/analysis-core/chunks/3CKW5JIF.js +1 -0
- package/dist/analysis-core/chunks/3GUKUEEJ.js +1 -0
- package/dist/analysis-core/chunks/3MTXB4MK.js +6 -0
- package/dist/analysis-core/chunks/4F6ZIHXU.js +1 -0
- package/dist/analysis-core/chunks/57M4OQJM.js +1 -0
- package/dist/analysis-core/chunks/6YCABS5T.js +1 -0
- package/dist/analysis-core/chunks/724WZMYW.js +2 -0
- package/dist/analysis-core/chunks/74FPPPIG.js +1 -0
- package/dist/analysis-core/chunks/7OYIBWX3.js +1 -0
- package/dist/analysis-core/chunks/D6AWHLRI.js +1 -0
- package/dist/analysis-core/chunks/DRGDIIFA.js +1 -0
- package/dist/analysis-core/chunks/E7TFIHC5.js +1 -0
- package/dist/analysis-core/chunks/EH3QQ3T4.js +1 -0
- package/dist/analysis-core/chunks/FSLWD2PE.js +1 -0
- package/dist/analysis-core/chunks/FTODBFQW.js +1 -0
- package/dist/analysis-core/chunks/HPIAEQHE.js +37 -0
- package/dist/analysis-core/chunks/HTLIRVP7.js +1 -0
- package/dist/analysis-core/chunks/IBCFGUHI.js +1 -0
- package/dist/analysis-core/chunks/IVDDV6CU.js +14 -0
- package/dist/analysis-core/chunks/J4AXGE5W.js +1 -0
- package/dist/analysis-core/chunks/JF4GYMOZ.js +1 -0
- package/dist/analysis-core/chunks/JKWTHRUR.js +1 -0
- package/dist/analysis-core/chunks/K5OTWBTT.js +22 -0
- package/dist/analysis-core/chunks/KU5DINLW.js +1 -0
- package/dist/analysis-core/chunks/MJGB25S5.js +1 -0
- package/dist/analysis-core/chunks/MXXNED6N.js +7 -0
- package/dist/analysis-core/chunks/NCWEOJVJ.js +6 -0
- package/dist/analysis-core/chunks/O652FQQH.js +1 -0
- package/dist/analysis-core/chunks/OFBJNHC6.js +1 -0
- package/dist/analysis-core/chunks/PYKAERZZ.js +1 -0
- package/dist/analysis-core/chunks/QDYMR6KS.js +1 -0
- package/dist/analysis-core/chunks/QMIXCT62.js +1 -0
- package/dist/analysis-core/chunks/QV2EOS7U.js +1 -0
- package/dist/analysis-core/chunks/SL27GMEN.js +1 -0
- package/dist/analysis-core/chunks/STZOC7LN.js +1 -0
- package/dist/analysis-core/chunks/T2SAP7OV.js +60 -0
- package/dist/analysis-core/chunks/T5TREZCQ.js +1 -0
- package/dist/analysis-core/chunks/T66VDFXF.js +1 -0
- package/dist/analysis-core/chunks/TDNTU4TF.js +1 -0
- package/dist/analysis-core/chunks/U5HOEVPE.js +1 -0
- package/dist/analysis-core/chunks/UEWL3GMQ.js +1 -0
- package/dist/analysis-core/chunks/V7BFUTM7.js +1 -0
- package/dist/analysis-core/chunks/VGYWI4X2.js +1 -0
- package/dist/analysis-core/chunks/Y7JGSUOA.js +1 -0
- package/dist/analysis-core/chunks/ZAA44GPI.js +1 -0
- package/dist/analysis-core/contracts/requests.js +1 -0
- package/dist/analysis-core/conventions/analysis-fit.js +1 -0
- package/dist/analysis-core/conventions/file-admission.js +1 -0
- package/dist/analysis-core/data/finding-types.js +1 -0
- package/dist/analysis-core/errors.js +1 -0
- package/dist/analysis-core/findings/presentation.js +1 -0
- package/dist/analysis-core/github/repo-key.js +1 -0
- package/dist/analysis-core/import/outside-loader-sources.js +1 -0
- package/dist/analysis-core/index.js +6 -0
- package/dist/analysis-core/llm/cache-policy.js +1 -0
- package/dist/analysis-core/llm/cost.js +1 -0
- package/dist/analysis-core/llm/execution.js +1 -0
- package/dist/analysis-core/llm/output-limit.js +1 -0
- package/dist/analysis-core/llm/slots.js +1 -0
- package/dist/analysis-core/llm/stable-json.js +1 -0
- package/dist/analysis-core/llm/structured-output-error.js +1 -0
- package/dist/analysis-core/map-limit.js +1 -0
- package/dist/analysis-core/requests/answer-formats.js +1 -0
- package/dist/analysis-core/requests/check-diagnostics.js +1 -0
- package/dist/analysis-core/requests/headline-request.js +1 -0
- package/dist/analysis-core/requests/instruction-text.js +1 -0
- package/dist/analysis-core/requests/local-plan.js +1 -0
- package/dist/analysis-core/requests/registry.js +1 -0
- package/dist/analysis-core/requests/schema-descriptions.js +1 -0
- package/dist/analysis-core/requests/shape-finding-input.js +1 -0
- package/dist/analysis-core/requests/template-version.js +1 -0
- package/dist/analysis-core/requests/tools.js +1 -0
- package/dist/analysis-core/settings.js +1 -0
- package/dist/bundle/seal/deserialise.js +75 -0
- package/dist/bundle/seal/encryption.js +25 -0
- package/dist/bundle/seal/metadata.js +69 -0
- package/dist/bundle/seal/open.js +38 -0
- package/dist/bundle/seal/planned-calls.js +20 -0
- package/dist/bundle/seal/signature.js +51 -0
- package/dist/cli/agent-folder.js +17 -0
- package/dist/cli/api-types.js +2 -0
- package/dist/cli/api.js +1 -0
- package/dist/{claude-code-permission.js → cli/claude-code-permission.js} +4 -3
- package/dist/cli/commands/analyze.js +75 -0
- package/dist/cli/commands/login.js +51 -0
- package/dist/cli/completion-recovery.js +18 -0
- package/dist/{context.js → cli/context.js} +8 -14
- package/dist/cli/development-relay.js +34 -0
- package/dist/cli/email-sign-in.js +56 -0
- package/dist/{git.js → cli/git.js} +12 -8
- package/dist/cli/intake-payload.js +18 -0
- package/dist/{main.js → cli/main.js} +23 -12
- package/dist/{mcp.js → cli/mcp.js} +109 -40
- package/dist/cli/output.js +10 -0
- package/dist/cli/relay-check.js +239 -0
- package/dist/cli/relay-preparation.js +33 -0
- package/dist/cli/sign-in-input.js +97 -0
- package/dist/{sign-in.js → cli/sign-in.js} +2 -1
- package/dist/cli/suggested-email.js +10 -0
- package/dist/cli/summary.js +30 -0
- package/dist/contract/cli-api-messages.js +5 -0
- package/dist/contract/cli-refusals.js +24 -0
- package/dist/contract/cli-version.js +1 -0
- package/dist/contract/console-url.js +8 -0
- package/dist/contract/console.js +131 -0
- package/dist/contract/email-sign-in-messages.js +18 -0
- package/dist/contract/messages.js +252 -0
- package/dist/contract/release-key.js +2 -0
- package/dist/contract/runtime-environment.js +37 -0
- package/dist/core/analysis/finding-quality/config.js +4 -0
- package/dist/core/analysis/run-to-end.js +55 -0
- package/dist/core/analysis/structural-run.js +16 -0
- package/dist/gatekeeper/attestation.js +67 -0
- package/dist/gatekeeper/certificate-algorithms.js +18 -0
- package/dist/gatekeeper/certificate-path.js +99 -0
- package/dist/gatekeeper/cli-api.js +174 -0
- package/dist/gatekeeper/client.js +76 -0
- package/dist/gatekeeper/connection-exchange.js +61 -0
- package/dist/gatekeeper/connection.js +140 -0
- package/dist/gatekeeper/console.js +175 -0
- package/dist/gatekeeper/loopback.js +5 -0
- package/dist/gatekeeper/model.js +70 -0
- package/dist/gatekeeper/production-attestation.js +149 -0
- package/dist/gatekeeper/trust/hardware.js +21 -0
- package/dist/gatekeeper/trust/policy.js +42 -0
- package/dist/gatekeeper/trust/production.json +25 -0
- package/dist/setup-pings/client.js +31 -0
- package/dist/setup-pings/contract.js +2 -0
- package/dist/setup-pings/policy.js +3 -0
- package/dist/setup-pings/state.js +261 -0
- package/dist/setup-pings/worker.js +95 -0
- package/dist/transport/base64url.js +9 -0
- package/dist/transport/http-response.js +89 -0
- package/dist/transport/tls-exporter.js +5 -0
- package/package.json +57 -11
- package/LICENSE +0 -1
- package/dist/api-types.js +0 -2
- package/dist/api.js +0 -97
- package/dist/commands/check.js +0 -104
- package/dist/commands/login.js +0 -9
- package/dist/files.js +0 -99
- package/dist/gitignore.js +0 -70
- package/dist/output.js +0 -23
- package/dist/secret-files.js +0 -5
- /package/dist/{browser.js → cli/browser.js} +0 -0
- /package/dist/{commands → cli/commands}/balance.js +0 -0
- /package/dist/{commands → cli/commands}/finding.js +0 -0
- /package/dist/{commands → cli/commands}/logout.js +0 -0
- /package/dist/{credentials.js → cli/credentials.js} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{b as de}from"./V7BFUTM7.js";import{a as J,b as it,c as lt,d as at,e as ft,g as ct,h as se}from"./NCWEOJVJ.js";import{b as te}from"./2PSNOSJ2.js";import{C as oe,E as xe,H as Ue,I as Ye,J as Xe,K as Ze,Ka as Oe,La as ve,Ma as Y,Na as Me,Pa as et,Qa as tt,Ra as nt,Sa as ot,Ta as st,V as Qe,Ya as rt,_ as Ve,b as pe,c as De,d as Be,e as me,f as E,fa as C,g as _,h as M,i as $,j as Z,k as N,l as K,m as ne,n as Ke,o as U,t as Je,v as Q,w as qe,ya as He,z as Ge}from"./HPIAEQHE.js";import{b as D,c as B}from"./T5TREZCQ.js";function bn({prompt:e,link:t}){return{path:t?.callPath??e.path,...t?{line:t.callLine}:{},symbol:e.symbol,promptPath:e.path,promptStart:e.start,...t?.kind==="L4"?{loadedPrompt:!0,...t.callStart!==void 0?{callStart:t.callStart}:{}}:{}}}function pt(e,t,n){return rt(e,t,n)}var ue=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).sort().join("-");function Xt(e,t,n,s={}){let o=new Map(e.map(r=>[ue(r),r]));return t.flatMap(r=>{let i=Object.hasOwn(n,r)?n[r]:void 0;if(i===void 0||!C(s,{path:r},{purpose:"code-support",route:"github"}).admitted)return[];let p=_(r,i,E(r)).toks;return p.flatMap((l,h)=>{if(!$(l))return[];let a=o.get(ue(l.text));if(!a)return[];let m=!1;if($(p[h-1],"function")||$(p[h-1],"def"))m=M(p[h+1],"(");else if(["const","let","var"].some(f=>$(p[h-1],f))){for(let f=h+1;f<p.length&&f<h+80&&!M(p[f],";");f++)if(M(p[f],"=")){let y=$(p[f+1],"async")?f+2:f+1,u=M(p[y],"(")?N(p,y)+1:y+1;m=$(p[y],"function")||M(p[u],"=")&&M(p[u+1],">");break}}return m?[{name:a,sourcePath:r,sourceLine:l.line}]:[]})})}function mt(e,t,n,s,o={}){let r=new Set(e.map(ue)),i=a=>C(o,{path:a},{purpose:"code-support",route:"github"}).admitted,p=a=>Xt(e,[a],n,o).length>0,l=t.filter(a=>i(a)&&p(a)),h=s.filter(a=>i(a)&&r.has(ue(a.split("/").at(-1).replace(/\.[^.]+$/,"")))&&(n[a]===void 0||p(a))).sort();return[...new Set([...l,...h])]}function dt(e){return Je(e,"CF_IMPORT_MANIFEST")}function he(e,t,n,s){let o=E(e);if(!o)return[];let r=_(e,t,o),{toks:i}=r,p=ne(r),l=Y(r,{includeMembers:!0}),h=X(r,"default");h?.name==="default"&&l.push(h),l.sort((u,g)=>u.from-g.from||g.to-u.to);let a=[],m=Ht(r),f=Vt(r,s),y=u=>l.filter(g=>g.params!==null&&g.from<u&&u<g.to).at(-1)?.name??null;for(let u of ot(e,t,o,!0)){let g=p.find(c=>c.source===u.source&&c.names.join("\0")===u.names.join("\0")),k=g?.names.map(c=>({name:c,imported:g.defaultName===c?"default":g.renamed?.[c]??c}))??Qt(r,u.source),w=g?.line??i.find(c=>c.kind==="string"&&c.value===u.source)?.line??1,d=Zt(r,w);for(let{name:c,imported:S}of k){let b=Oe(e,u.source,[S],o,n,!0)??null,P={from:e,to:b,symbol:c,imported:S,source:u.source,...b?{}:{reason:u.source.startsWith(".")?"missing":"external"}},O=i.some((j,A)=>A>d&&$(j,c)&&Z(i,A+1))||l.some(j=>j.name===c&&j.from>d&&!l.some(A=>A.from<j.from&&j.from<A.to&&(A.params!==null||A.kind==="class")));if(O)continue;let x=ut(r,c);for(let j of x)a.push({...P,symbol:j,kind:"import",usage:"reexport",within:null,span:{from:w,to:w}});let L=g?i.flatMap((j,A)=>!O&&$(j,c)&&A>d&&!["def","function","class"].includes(i[A-1]?.text??"")&&(!M(i[A-1],".")||M(i[A-2],".")&&M(i[A-3],"."))&&!l.some(R=>R.from<A&&A<R.to&&R.params?.includes(c))?[A]:[]):[];!L.length&&!x.length&&a.push({...P,kind:"import",usage:"reexport",within:null,span:{from:w,to:w}});for(let j of L){let A=m.find(q=>q.from<=j&&j<q.to),R=!f||f.from<=(A?.at??j)&&(A?.at??j)<f.to,T=A&&!R&&(A.kind!=="tool-registration"||f?.to===0),V=A&&(R||T)?A.kind:"import";a.push({...P,...T?{reason:"unlinked"}:{},kind:V,usage:ve(i,j,r)?"call":"reference",within:y(j),span:{from:Math.min(i[A?.at??j].line,i[j].line),to:Math.max(i[A?.at??j].endLine,i[j].endLine)}})}}if(!k.length){let c=Oe(e,u.source,[],o,n,!0)??null;a.push({from:e,to:c,kind:"import",symbol:"*",imported:"*",source:u.source,usage:"reexport",within:null,span:{from:w,to:w},...c?{}:{reason:u.source.startsWith(".")?"missing":"external"}})}}for(let u=0;u<i.length;u++)!$(i[u])||!["import","import_module","require"].includes(i[u].text)||!M(i[u+1],"(")||i[u+2]?.kind==="string"&&M(i[u+3],")")||a.push({from:e,to:null,kind:"import",symbol:"*",imported:"*",source:"",usage:"call",within:y(u),reason:"dynamic",span:{from:i[u].line,to:i[u].endLine}});return a.filter((u,g)=>a.findIndex(k=>JSON.stringify(k)===JSON.stringify(u))===g)}function Zt(e,t){let{toks:n}=e,s=n.findIndex(o=>o.line===t);for(let o=s;o<n.length;o++){if(e.lang==="py"&&n[o].line>t)return o-1;if(M(n[o],";")||e.lang==="js"&&n[o].kind==="string")return o}return n.length-1}function Qt(e,t){let{toks:n}=e,s=[];for(let o=0;o<n.length;o++){if(!$(n[o],"export"))continue;let r=o+1;if(!M(n[r],"{"))continue;let i=N(n,r);!$(n[i+1],"from")||n[i+2]?.value!==t||s.push(...K(n,r).flatMap(p=>$(n[p.from])?[{name:n[p.to-1].text,imported:n[p.from].text}]:[]))}return s}function ut(e,t){let{toks:n}=e,s=[];for(let o=0;o<n.length;o++)if(!(!$(n[o],"export")||!M(n[o+1],"{"))&&!$(n[N(n,o+1)+1],"from"))for(let r of K(n,o+1))$(n[r.from],t)&&s.push(n[r.to-1].text);return s}function X(e,t){let n=Y(e),{toks:s}=e;if(t==="default"){let r=s.findIndex((i,p)=>$(i,"default")&&$(s[p-1],"export"));if(r>=0){let i=r+1;$(s[i],"async")&&i++;let p=$(s[i],"function"),l=p?i+1:i;if($(s[l])&&(t=s[l].text),M(s[l],"(")){let h=N(s,l),a=p?h+1:h+3;if(p||M(s[h+1],"=")&&M(s[h+2],">")){let m=M(s[a],"{")?N(s,a)+1:s.findIndex((f,y)=>y>=a&&M(f,";"));return{name:"default",line:s[i].line,from:i,to:m<0?s.length:m,params:K(s,l).map(f=>$(s[f.from])?s[f.from].text:null),kind:"function"}}}}}let o=n.find(r=>r.name===t);if(o)return o;for(let r of n)if(ut(e,r.name).includes(t))return r;return null}function Vt(e,t){if(!t||t.path!==e.path)return null;let{toks:n}=e,s=new Set([t.symbol]);for(let l of ne(e))for(let h of l.names)(l.renamed?.[h]??h)===t.symbol&&s.add(h);let o=new Map;t.promptPath===e.path&&t.promptStart!==void 0&&o.set(t.promptStart,t.line??1);let r=et(e,[],o).filter(({site:l})=>(t.line===void 0||l.line===t.line)&&(l.value?.kind==="identifier"&&s.has(l.value.text)||l.value?.siteStart!=null&&l.value.siteStart===t.promptStart)),i=r.length===1?r[0].valueAt:void 0,p=[];for(let l=0;l<n.length;l++){if(!ve(n,l,e))continue;let h=N(n,l+1);(t.callStart!==void 0?n[l].start===t.callStart:i!==void 0?l<i&&i<h:t.line!==void 0&&n[l].line<=t.line&&(n[h]?.endLine??0)>=t.line)&&p.push({from:l,to:h+1})}return i!==void 0||t.callStart!==void 0?p.at(-1)??{from:0,to:0}:p.length===1?p[0]:{from:0,to:0}}function Ht(e){let{toks:t}=e,n=[],s=(o,r,i)=>{if(r&&(n.push({...r,at:o,kind:i}),r.to===r.from+1&&$(t[r.from]))){let p=t.flatMap((l,h)=>$(l,t[r.from].text)&&M(t[h+1],"=")?[h+2]:[]);p.length===1&&M(t[p[0]],"[")&&n.push({from:p[0],to:N(t,p[0])+1,at:o,kind:i})}};for(let o=0;o<t.length;o++){let r=t[o].kind==="string"?t[o].value:t[o].text;if(["tools","state_schema","context_schema","config_schema","model_config","llm_config"].includes(r)&&(M(t[o+1],"=")||M(t[o+1],":"))){let p=o+2,l=M(t[p],"[")?N(t,p)+1:p+1;s(o,{from:p,to:l},r==="tools"?"tool-registration":"config")}if(!M(t[o+1],"("))continue;let i=K(t,o+1);["add_node","addNode"].includes(r)&&s(o,i[1],"graph-node"),["StateGraph"].includes(r)&&s(o,i[0],"config"),["bind_tools","bindTools","ToolNode"].includes(r)&&s(o,i[0],"tool-registration")}return n}import{posix as re}from"node:path";function gt(e){return[...e].filter(t=>re.basename(t)==="langgraph.json")}function $e(e,t,n,s={}){if(re.basename(e)==="langgraph.json")return en(e,t,n,s.root);if(E(e)!=="py")return[];let o=_(e,t,"py"),{toks:r}=o,i=Y(o),p=ne(o),l=s.root?`${s.root}/llm_config.yaml`:"llm_config.yaml",h=[];for(let a of p.filter(m=>m.source==="chainlite"))for(let m of a.names){if((a.renamed?.[m]??m)!=="llm_generation_chain"||p.filter(d=>d.names.includes(m)).length!==1)continue;let f=r.findIndex(d=>d.line===a.line),y=r.findIndex((d,c)=>c>f&&(d.line>a.line||M(d,";"))),u=y<0?r.length:y;if(r.some((d,c)=>c>=u&&$(d,m)&&!M(r[c+1],"("))||i.some(d=>d.name===m)||r.some((d,c)=>$(d,"import")&&M(r[c+1],"*")))continue;let g=r.flatMap((d,c)=>c>=u&&$(d,m)&&M(r[c+1],"(")&&!M(r[c-1],".")&&!i.some(S=>S.from<c&&c<S.to&&S.params?.includes(m))?[c]:[]),k=s.call?.path===e?s.call:void 0,w=g.filter(d=>k?.callStart!==void 0?r[d].start===k.callStart:k?.line===void 0||r[d].line===k.line);for(let d of g){let c=N(r,d+1),S=i.filter(b=>b.params!==null&&b.from<d&&d<b.to).at(-1)?.name??null;h.push({from:e,to:n.has(l)?l:null,kind:"config",symbol:m,imported:"*",source:l,usage:"call",within:S,span:{from:r[d].line,to:r[Math.min(c,r.length-1)].endLine},...n.has(l)?k&&(w.length!==1||w[0]!==d)?{reason:"unlinked"}:{}:{reason:"missing"}})}}return h}function en(e,t,n,s){let o=()=>[{from:e,to:null,kind:"graph-node",symbol:"graphs",imported:"*",source:"",usage:"reference",within:null,span:{from:1,to:Math.max(1,t.split(`
|
|
2
|
+
`).length)},reason:"dynamic"}],r;try{r=JSON.parse(t)}catch{return o()}if(!ht(r)||!ht(r.graphs))return[];let i=r.graphs,p=_(e,t,"js"),{toks:l}=p,h=K(l,0).filter(m=>l[m.from]?.value==="graphs");if(h.length!==1)return o();let a=K(l,h[0].from+2);return a.map(m=>{let f=l[m.from].value,y=i[f],u=a.filter(d=>l[d.from].value===f).length!==1,g=typeof y=="string"?/^(.+):([A-Za-z_$][\w$]*)$/.exec(y):null,k=null,w;if(u||!g)w="dynamic";else if(/^[a-z][a-z\d+.-]*:\/\//i.test(g[1])||!g[1].includes("/")&&!E(g[1]))w="external";else{let d=re.normalize(re.join(re.dirname(e),g[1]));!g[1].startsWith("/")&&!g[1].includes("\\")&&!/^[A-Za-z]:/.test(g[1])&&d!==".."&&!d.startsWith("../")&&B(d,s)!==null&&E(d)&&n.has(d)?k=d:w="missing"}return{from:e,to:k,kind:"graph-node",symbol:f,imported:g?.[2]??"*",source:typeof y=="string"?y:"",usage:"reference",within:f,span:{from:l[m.from].line,to:l[m.to-1].endLine},...w?{reason:w}:{}}})}function kt(e,t,n,s){let o=E(e);if(!o)return[];let r=_(e,t,o),{toks:i}=r,p=X(r,n);if(!p||p.params!==null)return[];let l=i.findIndex((w,d)=>d>=p.from&&d<p.to&&Z(i,d));if(l<0)return[];let h=$(i[l+1])&&M(i[l+2],".")&&$(i[l+3],"compile"),a=h?i[l+1].text:n,m=h?X(r,a):p;if(!m||!i.slice(m.from,m.to).some(w=>$(w,"StateGraph")))return[];if([n,a].some(w=>i.filter((d,c)=>$(d,w)&&Z(i,c+1)).length!==1))return[];let f=Y(r),y=w=>f.filter(d=>d.params!==null&&d.from<w&&w<d.to).map(d=>d.from).join(","),u=[{from:m.from,to:m.to}];for(let w=0;w<i.length;w++)$(i[w],a)&&M(i[w+1],".")&&["add_node","addNode"].includes(i[w+2]?.text)&&M(i[w+3],"(")&&y(w)===y(m.from)&&u.push({from:w,to:N(i,w+3)+1});let g=[];for(let w of u)for(let d=w.from;d<w.to;d++){if(!["add_node","addNode"].includes(i[d]?.text)||!M(i[d+1],"(")||y(d)!==y(m.from))continue;let c=K(i,d+1)[1];if(!c||c.to!==c.from+1||!$(i[c.from]))continue;let S=i[c.from].text;!bt(r,S)||i.some((P,O)=>$(P,S)&&Z(i,O+1))||g.push({from:e,to:e,kind:"graph-node",symbol:S,imported:S,source:S,usage:"reference",within:null,span:{from:i[d].line,to:i[c.from].endLine}})}return[...he(e,t,s).filter(w=>(w.kind==="config"||w.kind==="graph-node")&&u.some(d=>i.slice(d.from,d.to).some(c=>$(c,w.symbol)&&c.line>=w.span.from&&c.line<=w.span.to))),...g].filter((w,d,c)=>c.findIndex(S=>JSON.stringify(S)===JSON.stringify(w))===d)}function yt(e,t,n,s){let o=E(e);if(!o||s?.path!==e)return!1;let r=_(e,t,o),i=bt(r,n);if(!i)return!1;let p=(l,h)=>s.callStart!==void 0?r.toks[l].start<=s.callStart&&r.toks[h-1].end>s.callStart:s.line!==void 0&&r.toks[l].line<=s.line&&r.toks[h-1].endLine>=s.line;return p(i.from,i.to)&&(s.callStart!==void 0||Y(r).filter(l=>l.params!==null&&p(l.from,l.to)).length===1)}function bt(e,t){let n=X(e,t);return n&&n.params!==null&&Y(e).filter(s=>s.name===n.name).length===1?n:null}function ht(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ie(e,t){if(!Q(e))return null;let n=new Set(t.paths),s=qe(e,t),o=new Set(t.skillPaths),r=new Set(t.referencePaths),i=d=>Object.hasOwn(t.files,d)?Buffer.byteLength(t.files[d]):t.sizes?.get(d),p=t.selected??t.skillPaths.filter(d=>Object.hasOwn(t.files,d)).map(d=>({path:d,size:i(d)})),l=[...new Map(p.filter(d=>!r.has(d.path)||o.has(d.path)).map(d=>[d.path,d])).values()],h=new Set(l.map(d=>d.path)),a=l.filter(d=>o.has(d.path)),m=a.length,f=U.conventionImport.skillBytes-a.reduce((d,c)=>d+(i(c.path)??c.size),0),y=me(e)?U.codeAgent.importBytes-l.reduce((d,c)=>d+(i(c.path)??c.size),0):1/0,u=new Map(a.map(d=>[d.path,null])),g=(d,c=!1)=>{if(u.has(d))return;let S=i(d),b=C(e,{path:d,size:S,text:t.files[d]},{...t.admission,purpose:"skill",route:"github",root:t.root,listing:n,managedFiles:t.files}),P=h.has(d)?0:S,O=b.admitted?S===void 0?"missing":m>=U.conventionImport.skillFiles?"allowance":S>f||P>y?"total":null:b.reason;u.set(d,O),(c||!O)&&m++,O||(f-=S,y-=P)};for(let d of r)g(d,!0);let k=[...new Set(t.skillPaths)].sort().filter(d=>Object.hasOwn(t.files,d)).map(d=>{let c={ownerPath:d,files:[],cycles:[],unresolved:[],refused:[]},S=new Set([d]);for(let b of s.references.filter(P=>P.ownerPath===d)){if(!S.has(b.fromPath))continue;g(b.path);let P=u.get(b.path);if(P){c.refused.push({path:b.path,reason:P});continue}S.add(b.path);let O=c.files.find(x=>x.path===b.path);O||(O={path:b.path,evidence:[],sharedOwners:[]},c.files.push(O)),O.evidence.push(b)}return c.cycles=s.cycles.filter(b=>b.ownerPath===d&&S.has(b.fromPath)),c.unresolved=s.unresolved.filter(b=>b.ownerPath===d&&S.has(b.fromPath)),c.refused=te(c.refused),c}),w=new Map;for(let d of k)for(let c of d.files)w.set(c.path,[...w.get(c.path)??[],d.ownerPath]);for(let d of k)for(let c of d.files)c.sharedOwners=w.get(c.path);return k}var St="model call";function wt(e,t){let n=pt(e.ownPaths,t,e.toolCall);return{tools:n.tools.map(s=>({tool:s,from:n.from[s.name]})),toolWarnings:n.warnings}}function je(e=new Map,t){return{left:Math.max(0,U.codeAgent.importBytes-[...e.values()].reduce((n,s)=>n+s,0)),chosen:new Set([...e.keys()].filter(n=>!t?.has(n))),...t?{replacementBytes:t}:{}}}function tn(e,t){return e.modelId??(t.length===1?t[0]:null)}function fo(e,t){return nn(e,tn(e,t))}function nn(e,t){let{prompt:n,link:s}=e,o=[n.kind==="file"?{role:"system prompt",label:null,path:n.path}:{role:"system prompt",label:n.symbol??`line ${n.span.from}`,path:n.path,span:{from:n.span.from,to:n.span.to},...n.filledAtRunTime?{filledAtRunTime:!0}:{}}];for(let i of e.alsoLoads??[])o.push({role:"system prompt",label:"also loaded",path:i});s&&o.push({role:"code",label:St,path:s.callPath}),s?.wrapper&&o.push({role:"code",label:"model wrapper",path:s.wrapper.path}),t&&o.push({role:"code",label:"model setting",path:t.path}),e.shape&&o.push({role:"code",label:"answer shape",path:e.shape.path});let r=new Set;return o.filter(i=>!r.has(i.path)&&!!r.add(i.path))}function co(e,t){let{prompt:n}=e,s=t[n.path]??"";return n.kind==="file"?s:s.split(`
|
|
3
|
+
`).slice(n.span.from-1,n.span.to).join(`
|
|
4
|
+
`)}function Pt(e,t,n){let{files:s,sizes:o,root:r,total:i=je()}=n,p=[...new Set([...t.ownPaths,...n.guides??[]])],l=[],h=new Set(p);p=p.filter(b=>{let P=C(e,{path:b},{purpose:"override",route:"github"});return P.admitted||l.push({path:b,reason:P.reason}),P.admitted});let a=[...o.keys()].filter(b=>{let P=C(e,{path:b},{purpose:"code-support",route:"github",root:r});return!P.admitted&&!h.has(b)&&l.push({path:b,reason:P.reason}),P.admitted}),m=Object.fromEntries(p.filter(b=>s[b]!==void 0).map(b=>[b,s[b]])),f=st(m,a).filter(b=>!p.includes(b)),y=Object.fromEntries([...p,...f].filter(b=>s[b]!==void 0).map(b=>[b,s[b]])),u=wt({ownPaths:p,toolCall:t.toolCall},y).tools.map(({tool:b})=>b.name),g=new Set(mt(u,f,s,a,e)),k=xt(e,p,{...n,total:i});for(let b of new Set([...p,...f,...g]))k.take(b,g.has(b)&&!p.includes(b));let{paths:w,skipped:d}=k,c=Object.fromEntries(w.filter(b=>s[b]!==void 0).map(b=>[b,s[b]])),S=wt(t,c);return{paths:w,skipped:d,refused:te(l,k.refused),...S}}function xt(e,t,{sizes:n,total:s=je()}){let o=[],r=[],i=[],p=U.codeAgent.extraBytes,l=0;return{paths:o,skipped:r,refused:i,take:(a,m,f=!1)=>{if(o.includes(a))return!0;let y=n.get(a),u=a===t[0],g=Math.max(0,(y??0)-(s.replacementBytes?.get(a)??0)),k=t.includes(a)||f?"pointer":"code-support",w=C(e,{path:a,size:y},{purpose:k,route:"github"});w.admitted||i.push({path:a,reason:w.reason});let d=y===void 0?"missing":w.admitted?!u&&y>p?"allowance":!s.chosen.has(a)&&(g>s.left||s.wholeBytesLeft!==void 0&&y>s.wholeBytesLeft)?"total":m&&l>=U.codeAgent.toolCodeFiles?"tool-limit":null:w.reason;return d?(r.push({path:a,reason:d}),!1):(u||(p-=y),m&&l++,s.chosen.has(a)||(s.left-=g,s.wholeBytesLeft!==void 0&&(s.wholeBytesLeft-=y),s.chosen.add(a)),o.push(a),!0)}}}function po(e,t,n){if(!dt(e))return null;let s=n.scopes??ct(e,[...n.sizes.keys()],n.root??void 0),o=n.total??je(),r=new Set(n.sizes.keys()),i=gt(r).flatMap(m=>n.files[m]===void 0?[]:$e(m,n.files[m],r,{root:n.root??void 0})),p=new Map(i.map(m=>[m,m.to&&n.files[m.to]!==void 0?kt(m.to,n.files[m.to],m.imported,r):[]])),l=new Set(i.filter(m=>{let f=m.to&&E(m.to),y=m.to&&n.files[m.to];return f&&y!==void 0&&y!==null&&!X(_(m.to,y,f),m.imported)})),h=t.map(m=>{let f=[...new Set(m.ownFiles.map(O=>O.path))],y=xt(e,f,{...n,total:o}),u={schemaVersion:1,agentId:m.id,scope:{...m.scope},files:[],edges:[],unresolved:[],refused:[]},g=m.ownFiles.map(O=>({path:O.path,symbol:null,role:O.role,evidence:null,span:O.span})),k=i.filter(O=>O.to!==null&&f.includes(O.to)),w=k.filter(O=>new Set(k.filter(x=>x.to===O.to).map(x=>x.imported)).size>1),d=i.filter(O=>!l.has(O)&&(k.includes(O)&&!m.toolCall&&!w.includes(O)||p.get(O).some(x=>{if(x.kind!=="graph-node"||!x.to||!f.includes(x.to)||!m.toolCall||m.toolCall.path!==x.to)return!1;let L=n.files[x.to];return L!==void 0&&yt(x.to,L,x.imported,m.toolCall)})));u.unresolved.push(...k.filter(O=>!d.includes(O)).map(O=>({...O,reason:l.has(O)?"missing":"unlinked"})));for(let O of d)g.push({path:O.from,symbol:O.symbol,role:"config",evidence:O,explicit:!0});let c=new Set,S=new Map,b=new Set,P=new Set;for(let O=0;O<g.length;O++){let x=g[O],L=JSON.stringify([x.path,x.symbol,x.role]);if(c.has(L))continue;c.add(L);let j=s.ownerOf(x.path),A=C(e,{path:x.path},{purpose:f.includes(x.path)||x.explicit?"pointer":"code-support",route:"github",root:n.root}),R=A.admitted?!j||j.key!==m.scope.key||j.folder!==m.scope.folder?"out-of-scope":!f.includes(x.path)&&t.some(v=>v.id!==m.id&&v.ownFiles.some((z,ee)=>z.path===x.path&&(ee===0||z.label===St)))?"other-agent":null:A.reason;if(R){u.refused.push({path:x.path,reason:R});continue}let T=n.files[x.path],V=E(x.path),q=T!==void 0&&V?_(x.path,T,V):null,H=q&&x.symbol?X(q,x.symbol):null,G=H?.name??x.symbol;if(T!==void 0&&!S.has(x.path)){let v=i.filter(F=>F.from===x.path),z=[...v.length?v:$e(x.path,T,r,{root:m.scope.folder,call:m.toolCall}),...[...P].filter(F=>F.to===x.path).flatMap(F=>p.get(F))];z.forEach(F=>b.add(F));let ee=he(x.path,T,r,f.includes(x.path)?m.toolCall:void 0).flatMap(F=>z.some(W=>!W.reason&&W.kind===F.kind&&W.symbol===F.symbol&&W.span.from===F.span.from)?[]:d.some(W=>W.to===x.path)&&!f.includes(x.path)&&(F.kind==="config"||F.kind==="graph-node")&&!F.reason?[{...F,reason:"unlinked"}]:[F]);S.set(x.path,[...ee,...z,...(n.links??[]).filter(F=>F.from===x.path)])}let We=S.get(x.path)??[];if(x.role==="code"&&x.evidence?.kind==="import"&&We.some(v=>v.reason==="external"&&v.usage==="call"&&(v.within===G||v.within===null)&&Ke(v.source,V))){u.refused.push({path:x.path,reason:"provider-transport"});continue}let Ut=x.role==="tool"&&H?.params!=null&&!f.includes(x.path);if(!y.take(x.path,Ut,x.explicit))continue;u.unresolved.push(...i.filter(v=>v.from===x.path&&(v.reason||l.has(v))).map(v=>l.has(v)?{...v,reason:"missing"}:v));let I=u.files.find(v=>v.path===x.path);I||(I={path:x.path,roles:[],spans:[],evidence:[],sharedOwners:[]},u.files.push(I)),I.roles.includes(x.role)||I.roles.push(x.role);let ce=x.span??(q&&H?{from:q.toks[H.from].line,to:q.toks[H.to-1].endLine}:void 0);if(ce&&!I.spans.some(v=>v.from===ce.from&&v.to===ce.to)&&I.spans.push(ce),x.evidence?I.evidence.push(x.evidence):I.evidence.push({kind:"entry",from:x.path,to:x.path,...x.span?{span:x.span}:{}}),T!==void 0)for(let v of We){let z=v.usage==="reexport"&&(v.symbol===G||v.symbol==="*"),ee=v.usage==="call"&&v.within===G;if(!(v.kind!=="import"&&(G===null||v.within===G)||G!==null&&(z||ee)||v.reason==="dynamic"&&(G===null||v.within===G)))continue;if(!v.to||v.reason){u.unresolved.push(v);continue}let W=d.includes(v);W&&(P.add(v),S.delete(v.to)),u.edges.push(v);let Yt=v.kind==="tool-registration"?"tool":v.kind==="config"?"config":v.kind==="graph-node"?"workflow":z?x.role:"code";g.push({path:v.to,symbol:W?null:v.imported==="*"?x.symbol:v.imported,role:Yt,evidence:v,explicit:b.has(v)})}}return u.refused.push(...te(y.skipped,y.refused)),u.unresolved=u.unresolved.filter(O=>O.reason!=="unlinked"||!u.edges.some(x=>x.from===O.from&&x.to===O.to&&x.kind===O.kind&&x.symbol===O.symbol&&x.span.from===O.span.from)),u.unresolved=[...new Map(u.unresolved.map(O=>[JSON.stringify(O),O])).values()],u.refused=u.refused.filter((O,x,L)=>L.findIndex(j=>j.path===O.path&&j.reason===O.reason)===x),u}),a=new Map;for(let m of h)for(let f of m.files)a.set(f.path,[...a.get(f.path)??[],m.agentId]);for(let m of h)for(let f of m.files)f.sharedOwners=[...new Set(a.get(f.path))].sort();return h}import{basename as fn}from"node:path";import{basename as rn}from"node:path";var vt=/^[\w.*:/()-]+$/,Mt=/^(?:true|false|null|~|[-+]?(?:\d[\d_.eExXoObB+-]*|\.\d[\d_eE+-]*|\.inf|\.nan)|\d{4}-\d{1,2}-\d{1,2}(?:[Tt].*)?)$/i,ke=e=>vt.test(e)&&!e.startsWith("*")&&!Mt.test(e);function ge(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e}return e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function ae(e,t=!1,n=!1){let s=[],o="",r=0,i=-1,p=0,l=()=>{i>=0&&s.push([i,p]),i=-1};for(let h=0;h<e.length;h++){let a=e[h];if(o){o==='"'&&a==="\\"?h++:a===o&&(o==="'"&&e[h+1]==="'"?h++:o=""),p=h+1;continue}if(!n&&a==="#"&&(h===0||/\s/.test(e[h-1]))){if(!t)return l(),{spans:s,end:h,comment:e.slice(h)};let m=e.indexOf(`
|
|
5
|
+
`,h);h=m<0?e.length:m;continue}if(t&&a==="]"&&r===0)return l(),{spans:s,end:h,comment:""};if(a===","&&r===0){l();continue}/\s/.test(a)||(i<0&&(i=h),(a==='"'||a==="'")&&(i===h||r>0)?o=a:a==="("?r++:a===")"&&r>0&&r--,p=h+1)}if(t)throw new Error("Unclosed frontmatter tool list");return l(),{spans:s,end:e.length,comment:""}}function Ot(e,t){let n=e.startsWith("["),s=ae(n?e.slice(1):e,n),o=(n?e.slice(1,s.end+1):e.slice(0,s.end)).trimEnd(),r=!n&&s.spans.length===1&&/^["']/.test(o)&&ge(o)!==o?o[0]:"",i=r?ge(o):n?e.slice(1,s.end+1):e.slice(0,s.end).trimEnd(),p=n?s.spans:ae(i,!1,!!r).spans,l=0,h=p.flatMap(([m,f],y)=>{let u=i.slice(m,f),g=ge(u),k=i.slice(l,m).replace(/[^\S\n]*#[^\n]*/g,""),w=n?i.slice(f,p[y+1]?.[0]??i.length):"",d=w.match(/[^\S\n]*#[^\n]*/g)?.join(`
|
|
6
|
+
`)??"";return l=f,g?[{name:g,raw:u,before:k,note:d,noteAfterComma:/^[^\S\n]*,/.test(w)}]:[]}),a=n?e.slice(s.end+2).split(`
|
|
7
|
+
`)[0]:e.slice(o.length);return{style:n?"flow":"comma",outerQuote:r,quote:h.find(m=>/^["']/.test(m.raw))?.raw[0]??"",prefix:"",suffix:a,head:(h[0]?.before??i).replace(/,/g,""),tail:h.length?i.slice(l).replace(/[^\S\n]*#[^\n]*/g,""):"",separator:h[1]?.before.replace(/#[^\n]*/g,"")??(i.includes(`
|
|
8
|
+
`)?`,
|
|
9
|
+
${i.match(/\n([^\S\n]*)/)[1]}`:", "),entries:h,first:t,last:t+e.slice(0,n?s.end+2:e.length).split(`
|
|
10
|
+
`).length-1,indent:" - ",blockComments:[]}}function on(e){let t=oe(e),n=t?.raw.map(p=>p.replace(/\r$/,""))??null,s=[],o=[],r={},i=[];if(n)for(let p=0;p<n.length;p++){let l=/^([A-Za-z_][\w-]*\s*:[^\S\n]*)(.*)$/.exec(n[p]);if(!l||!/^tools\s*:/i.test(l[1]))continue;let h=ae(l[2]),a;l[2].startsWith("[")?a=Ot(n.slice(p).join(`
|
|
11
|
+
`).slice(l[1].length),p):a=Ot(l[2],p),a.prefix=l[1];let m=a.style==="flow"?ae(a.suffix).comment:h.comment;if(m&&(r[a.style==="flow"?a.last:p]=m),a.style==="flow")for(let f of a.entries)f.note&&i.push({tool:f.name,comment:f.note.trim()});if(!l[2].slice(0,h.end).trim()){a.style="block",a.suffix=l[2];for(let f=p+1;f<n.length;f++){if(!n[f].trim()||/^\s*#/.test(n[f])){/^\s+#/.test(n[f])&&a.blockComments.push(f);continue}let y=/^(\s*-\s+)(.*)$/.exec(n[f]);if(!y)break;let u=ae(y[2]),g=y[2].slice(0,u.end).trimEnd(),k=ge(g);a.indent=y[1],k&&a.entries.push({name:k,raw:g,before:"",note:"",noteAfterComma:!1,row:n[f]}),u.comment&&k&&i.push({tool:k,comment:u.comment}),o.push(f),a.last=f}a.quote=a.entries.map(f=>f.raw).find(f=>/^["']/.test(f))?.[0]??""}for(let f=p;f<=(a.style==="block"?p:a.last);f++)o.push(f);s.push(a),p=a.last}return{header:t,lists:s,tools:s.length?s.flatMap(p=>p.entries.map(l=>l.name)):null,lines:n,toolLines:o,toolComments:r,itemComments:i}}function $t(e){try{return on(e)}catch{let t=oe(e);return{header:t,lists:[],tools:[],lines:t.raw.map(n=>n.replace(/\r$/,"")),toolLines:[],toolComments:{},itemComments:[],error:"Unclosed frontmatter tool list"}}}function sn(e){let{tools:t,lines:n,toolLines:s,toolComments:o,itemComments:r,error:i}=$t(e);return{tools:t,lines:n,toolLines:s,toolComments:o,itemComments:r,...i?{error:i}:{}}}function jt(e){let t=sn(e);if(t.error)throw new Error(t.error);let{tools:n,lines:s,toolLines:o,toolComments:r,itemComments:i}=t;return{tools:n,lines:s,toolLines:o,toolComments:r,itemComments:i}}function ye(e){return e.every(t=>vt.test(t)&&!t.startsWith("*"))&&(e.length!==1||ke(e[0]))?e.join(", "):`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}function le(e,t){return t==="'"&&!/[\r\n]/.test(e)?`'${e.replace(/'/g,"''")}'`:t==='"'||!ke(e)?JSON.stringify(e):e}function go(e,t){let n=$t(e);if(n.error)return e;let s=n.tools??[],o=t([...s]);if(o.length===s.length&&o.every((u,g)=>u===s[g]))return e;if(!n.header){let u=e.startsWith("\uFEFF")?"\uFEFF":"";return`${u}---
|
|
12
|
+
tools: ${ye(o)}
|
|
13
|
+
---
|
|
14
|
+
${e.slice(u.length)}`}let{header:r,lists:i,toolLines:p,toolComments:l}=n,h=new Map,a=i[0];if(a){let u=i.flatMap(w=>w.entries),g=o.map(w=>{let d=u.findIndex(c=>c.name===w);return d<0?{name:w,raw:le(w,a.quote),before:a.separator,note:"",noteAfterComma:!1}:u.splice(d,1)[0]}),k=a.prefix.endsWith(" ")?a.prefix:`${a.prefix} `;if(!o.length)h.set(a.first,`${k}[]${a.style==="block"&&a.suffix?` ${a.suffix}`:a.suffix}`);else if(a.style==="block"){h.set(a.first,`${a.prefix}${a.suffix}`);let w=p.filter(d=>d>a.first&&d<=a.last).sort((d,c)=>d-c);for(let d=0;d<g.length;d++){let c=g[d],S=a.entries.includes(c)&&c.row?ke(c.raw)||/^["']/.test(c.raw)?c.row:c.row.replace(c.raw,le(c.name,a.quote)):`${a.indent}${le(c.name,a.quote)}`,b=w[Math.min(d,w.length-1)]??a.first;h.set(b,`${h.has(b)?`${h.get(b)}${r.newline}`:""}${S}`)}}else{let w=a.style==="flow"||o.length===1&&Mt.test(o[0])||o.some(b=>b.includes(",")||b!==b.trim()||/[\r\n]|(?:^|\s)#|:\s|^[[\]{}&*!|>'"%@`]/.test(b)),d=a.head;for(let[b,P]of g.entries()){if(b){let O=P.before||a.separator,x=g[b-1];x.note&&(x.noteAfterComma?(O=O.replace(/,[^\S\n]*/,`,${x.note}`),O.includes(`
|
|
15
|
+
`)||(O+=`
|
|
16
|
+
`)):O=`${x.note}${/^[^\S\n]*\n/.test(O)?"":`
|
|
17
|
+
`}${O}`),d+=O}d+=w?/^["']/.test(P.raw)||ke(P.raw)?P.raw:le(P.name,a.quote):P.name}let c=g[g.length-1];c.note?(d+=c.noteAfterComma&&!a.tail.includes(",")?",":"",d+=c.noteAfterComma&&a.tail.includes(",")?a.tail.replace(",",`,${c.note}`):`${c.note}${a.tail}`,a.tail.includes(`
|
|
18
|
+
`)||(d+=`
|
|
19
|
+
`)):d+=a.tail;let S=w?`[${d}]`:a.outerQuote?le(d,a.outerQuote):d;h.set(a.first,`${a.prefix}${S}${a.suffix}`.replace(/\n/g,r.newline))}}let m=new Set(p),f=r.raw.map((u,g)=>h.has(g)?`${h.get(g)}${r.newline}`:m.has(g)?l[g]&&g>a.last?`${l[g]}${r.newline}`:"":`${!o.length&&i.some(w=>w.blockComments.includes(g))?u.trimStart():u}
|
|
20
|
+
`).join(""),y=a?"":`tools: ${ye(o)}${r.newline}`;return`${e.slice(0,r.start)}${f}${y}${e.slice(r.end)}`}function Ae(e){return e.CF_LEGACY_TOOL_LISTS!=="1"}function bo(e,t){return Ae(e)?ye(t):t.join(", ")}var ln=/^\s*(name|description|tools|model)\s*:\s*(.+?)\s*$/i;function an(e){if(e.startsWith('"')&&e.endsWith('"'))try{return JSON.parse(e)}catch{}return e.replace(/^["']|["']$/g,"")}function fe(e,t,n,s){let o=Ae(e),r=rn(t).replace(/\.md$/i,""),i,p,l=[],h=!1,a=n,m=[],f=oe(n,o?void 0:"markdown");if(f){a=n.slice(f.bodyStart).trim();let u=o?f.raw.map(g=>g.replace(/\r$/,"")):f.raw;for(let g=0;g<u.length;g++){let w=u[g].match(ln);if(!w)continue;let d=w[1].toLowerCase(),c=an(w[2]);if(d==="name")r=c;else if(d==="description")if(/^[>|][+-]?$/.test(w[2])){let S=[];for(;g+1<u.length&&(/^\s+\S/.test(u[g+1])||u[g+1].trim()==="");)S.push(u[++g].trim());i=S.join(c[0]===">"?" ":`
|
|
21
|
+
`).trim()}else i=c;else d==="model"?p=c:d==="tools"&&!o&&(h=!0,l=c.replace(/^\[|\]$/g,"").split(",").map(S=>S.trim()).filter(Boolean))}}if(o)try{let u=jt(n);l=u.tools??[],h=u.tools!==null}catch{h=!0,m.push("tools could not be read; check the tool list")}let y=a.trim();return{name:r,...i!==void 0?{description:i}:{},...y?{prompt:y}:{},...!s?.preserveToolAbsence||h?{tools:l}:{},...p!==void 0?{model:p}:{},...m.length?{warnings:m}:{}}}function At(e,t,n){let s=t.managed,o=[],r=new Set([...s.agents,...s.configs,...Object.keys(n.files),...n.listedPaths??[]]),i=new Set(Ye(e,[...r],n.files)),p=Object.fromEntries(Object.entries(n.files).filter(([f,y])=>{if(i.has(f))return!1;let u=C(e,{path:f,text:y},{purpose:"override",route:"github",root:t.folder,listing:r,managedFiles:n.files});return!u.admitted&&u.reason==="secret"&&o.push({path:f,reason:"secret"}),u.admitted})),l=new Map;for(let f of s.agents){if(p[f]===void 0){o.some(u=>u.path===f)||o.push({path:f,reason:"missing"});continue}let y=Xe(f,p[f],s,n.listedPaths??Object.keys(n.files));o.push(...y.refused),l.set(f,y)}let h=new Set([...l.values()].flatMap(f=>f.relationships.filter(y=>y.kind==="agent").map(y=>y.path))),a=[...l.values()].filter(f=>!h.has(f.path));return!a.length&&l.size&&a.push(l.values().next().value),{agents:a.map(f=>{let y=[{path:f.path,role:"system prompt",label:null}],u=[],g=[],k=(w,d,c)=>{for(let S of w.relationships){if(p[S.path]===void 0){o.some(b=>b.path===S.path)||o.push({path:S.path,reason:"missing"});continue}if(S.kind==="agent"){if(d.has(S.path)){o.push({path:S.path,reason:"cycle"});continue}let b=l.get(S.path);if(!b||g.some(O=>O.path===b.path))continue;let P=[];g.push({path:b.path,name:b.name,description:b.description,prompt:b.prompt,...b.model?{model:b.model}:{},tools:[],skillPaths:[],files:P}),k(b,new Set([...d,b.path]),P)}else if(S.kind==="skill"&&n.skills&&He(e)||S.kind==="config"&&Ze(p[S.path])){if(c.some(b=>b.path===S.path))continue;if(c.push({path:S.path,role:S.kind==="skill"?"skill":"config",label:null}),S.kind==="skill"&&w===f){let b=fe(e,fn(S.path),p[S.path]);u.push({path:S.path,name:b.name,description:b.description??"",body:b.prompt??""})}}}};return k(f,new Set([f.path]),y),{key:`managed:${f.path}`,name:f.name,model:f.model,description:f.description,prompt:{kind:"dedicated",path:f.path},files:y,tools:[],skills:u,subagents:g}}),notes:[],registry:!1,refused:o}}function Ct(e,t,n){let s=t.miniSwe,o=n.templateSelection?.agentPath===s.agentPath?n.templateSelection.configPaths:void 0,r=ft(e,s,n.files,o),i=r.unresolved.filter(k=>k.reason!=="runtime-variable").map(k=>({path:k.target??k.path,reason:k.reason==="duplicate"?"invalid":k.reason})),p=r.fields.find(k=>k.key==="agent.system_template"&&k.value!==null),l=r.fields.find(k=>k.key==="agent.instance_template"&&k.value!==null),h=r.unresolved.some(k=>r.selectedPaths.includes(k.path)&&k.source===k.path);if(!p||!l||h||i.some(k=>k.reason==="invalid"))return{agents:[],notes:[],registry:!1,refused:i};let a=[p,...r.fields.filter(k=>k!==p)].map(k=>({path:k.path,span:k.span,label:k.key,role:k===p?"system prompt":k.key.endsWith("_template")?"template":"config"}));a.push(...r.loaded.map(k=>({path:k.path,role:"template",label:null})));let m=[];for(let k of a){let w=m.find(d=>d.path===k.path);w?w.span&&k.span&&(w.span={from:Math.min(w.span.from,k.span.from),to:Math.max(w.span.to,k.span.to)}):m.push({...k})}let f=[...new Set(m.map(k=>k.path))],y=Object.fromEntries(f.map(k=>[k,n.files[k]])),u=new Map(f.map(k=>[k,Buffer.byteLength(y[k])])),g=Pt(e,{ownPaths:f},{files:y,sizes:u,root:t.folder});return i.push(...g.refused,...g.skipped),r.fields.some(k=>!g.paths.includes(k.path))?{agents:[],notes:[],registry:!1,refused:i}:(r.loaded=r.loaded.filter(k=>g.paths.includes(k.path)),r.edges=r.edges.filter(k=>g.paths.includes(k.from)&&g.paths.includes(k.to)),{agents:[{key:t.key,name:n.fallbackName,model:r.model,description:null,prompt:{kind:"entry",path:p.path,span:p.span,text:p.value},files:m.filter(k=>g.paths.includes(k.path)),tools:[],skills:[],subagents:[],templateVariants:r}],notes:[],registry:!1,refused:i})}function be(e,t,n){return e.filter(s=>t.some(o=>o.includes(n(s))))}function Ft(e,t,n){if(!t.skills||!Q(e))return n;let s=[...new Set([...Object.keys(t.files),...t.listedPaths??[]])],o=se(e,s,t.root),r=new Set(o.files.filter(m=>m.role==="skill").map(m=>m.path)),i=m=>[...new Set([...m.skillPaths.filter(f=>r.has(f)),...m.files?.filter(f=>f.role==="skill").map(f=>f.path)??[]])],p=n.agents.flatMap(m=>[...m.skills.map(f=>f.path),...m.subagents.flatMap(i)]),l=ie(e,{skillPaths:p,paths:s,files:t.files,root:t.root});for(let m of l)m.files=m.files.filter(f=>Object.hasOwn(t.files,f.path));let h=new Map(l.map(m=>[m.ownerPath,m])),a=(m,f)=>{let y=new Set(f.flatMap(g=>g.refused.map(k=>k.path))),u=m.filter(g=>g.role!=="reference"||!y.has(g.path));for(let g of f)for(let k of g.files)u.some(w=>w.path===k.path)||u.push({path:k.path,role:"reference",label:null});return u};return{...n,agents:n.agents.map(m=>{let f=m.skills.flatMap(y=>h.has(y.path)?[h.get(y.path)]:[]);return{...m,files:a(m.files,f),skills:m.skills.map(y=>({...y,...h.has(y.path)?{manifest:h.get(y.path)}:{}})),subagents:m.subagents.map(y=>{let u=i(y).flatMap(P=>h.has(P)?[h.get(P)]:[]);if(!u.length)return y;let g=o.ownerOf(y.path),k=J(e,s.filter(P=>o.ownerOf(P)===g),g?.folder),w=y.files??y.skillPaths.map(P=>({path:P,role:r.has(P)?"skill":"reference",label:k.skillNames[P]??k.skillRefNames[P]??null})),d=new Set([...m.files.map(P=>P.path),...k.subagentPaths,...Object.keys(k.subagentSkillOwners)]),c=k.scoped.filter(P=>!d.has(P)&&pe(P)&&Object.hasOwn(t.files,P)).sort(),S=y.files?[]:be(c,[t.files[y.path],...w.filter(P=>P.role==="reference").map(P=>t.files[P.path])],k.stripRoot).map(P=>({path:P,role:"reference",label:null})),b=a([...w,...S],u);return{...y,files:b,skillPaths:[...new Set([...y.skillPaths,...i(y),...u.flatMap(P=>P.files.map(O=>O.path))])].filter(P=>b.some(O=>O.path===P)),skillManifests:u}})}})}}import{basename as Jt}from"node:path";function Ce(e){let t;try{t=JSON.parse(e)}catch{return{config:null,invalid:!0}}if(typeof t!="object"||t===null||Array.isArray(t))return{config:null,invalid:!0};let n=t,s={};for(let o of["name","model","description","prompt"]){let r=we(n[o]);r&&(s[o]=r)}if(Array.isArray(n.agents)){let o=n.agents.flatMap(r=>{let i=cn(r);return i?[i]:[]});o.length>0?s.agents=o:s.invalidAgents=!0}return{config:s,invalid:!1}}function Yo(e){let{config:t}=Ce(e);return t?Fe(t):"bare"}function Fe(e){return e.agents&&e.agents.length>0?"agents":e.prompt?"prompt":"bare"}function Et(e,t,n){return Lt(e,t,n).paths}function Lt(e,t,n,s={}){let o=Fe(t)==="agents"?(t.agents??[]).map(p=>p.prompt):t.prompt?[t.prompt]:[],r=[],i=[];for(let p of o){let l=Le(p).path,h=Ne(n,l);if(h===null){i.push({path:l,reason:"out-of-scope"});continue}let a=C(e,{path:h},{purpose:"pointer",route:"github",...s});a.admitted?r.push(h):i.push({path:h,reason:a.reason})}return{paths:r,refused:i}}function Ee(e,t,n){let s=Ne(n.markerDir,Le(t).path),o=s!==null?C(e,{path:s},{purpose:"pointer",route:"github"}):null;if(o&&!o.admitted&&o.reason==="secret")return{kind:"secret",path:s};let r=pn(t,n,nt(e));return r?{kind:"resolved",prompt:r}:{kind:"missed"}}function Xo(e,t,n){let s=[],o=[];t.invalidAgents&&o.push(`${n.repoKey}: counterfact.json "agents" has no entry with a prompt pointer; ignored`);let r=Fe(t),i=r==="agents"?t.agents??[]:t.prompt?[{name:t.name,model:t.model,prompt:t.prompt}]:[];for(let p of i){let l=Ee(e,p.prompt,n);if(l.kind==="secret"){o.push(Ve(l.path));continue}if(l.kind==="missed"){o.push(`${n.repoKey}: counterfact.json points at ${p.prompt}, which was not found; ignored`);continue}s.push({name:p.name??null,model:p.model??null,description:r==="prompt"?t.description??null:null,prompt:l.prompt})}return{agents:s,warnings:o,refused:Lt(e,t,n.markerDir).refused}}function we(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function cn(e){if(typeof e!="object"||e===null)return null;let t=e,n=we(t.prompt);if(!n)return null;let s={prompt:n},o=we(t.name),r=we(t.model);return o&&(s.name=o),r&&(s.model=r),s}function Le(e){let t=e.replace(/\\/g,"/"),n=t.indexOf("#");if(n>=0)return{path:t.slice(0,n),symbol:t.slice(n+1),line:null};let s=/^(.*):(\d+)$/.exec(t);return s?{path:s[1],symbol:null,line:Number(s[2])}:{path:t,symbol:null,line:null}}function Ne(e,t){let n=[];for(let s of[...e.split("/"),...t.split("/")])if(s===".."){if(n.pop()===void 0)return null}else s!=="."&&s!==""&&n.push(s);return n.join("/")}function pn(e,t,n){let{path:s,symbol:o,line:r}=Le(e),i=Ne(t.markerDir,s);if(i===null||!Object.hasOwn(t.files,i))return null;let p=t.files[i];if(p===void 0)return null;if(o===null&&r===null)return E(i)?null:Ge(i,p);let{sites:l}=tt(i,p,{minChars:1,promptFunctions:n});return o!==null?l.find(h=>h.symbol===o)??null:mn(l,r)}function mn(e,t){let n=o=>Math.min(o.line,o.span.from),s=e.filter(o=>n(o)<=t&&t<=o.span.to);return s.sort((o,r)=>o.span.to-n(o)-(r.span.to-n(r))),s[0]??null}var dn=25;function Nt(){return dn}function un(e,t,n){return De(e)&&t!==null&&typeof t=="object"&&"groupKey"in t&&typeof t.groupKey=="string"&&t.groupKey?t.groupKey:n}function _t(e,t){let n=Nt(),s=new Set,o=[],r=[];return t.forEach((i,p)=>{let l=un(e,i,p);s.has(l)||s.size<n?(s.add(l),o.push(i)):r.push(i)}),{kept:o,leftOut:r}}function Rt(e){let t=Nt();if(e.kind==="layout")return`Only ${t} agents can be added per import, so ${e.leftOut} were left out.`;if(e.kind==="scan"){let s=e.found-t;return`${s} ${s===1?"agent wasn't":"agents weren't"} read because the repository is large.`}let n=e.kind==="import"?`Not added: this import already has ${t} agents.`:`Only the ${t} strongest agents of a repository are added.`;return e.kind==="model"?`${e.name}: ${n}`:n}var _e="crew:";function Re(e){return e.startsWith(_e)}function Tt(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Object.entries(e);return!t.length||t.some(([,n])=>typeof n!="string"||n.length>=2e3)?null:t.map(([n,s])=>`${n}: ${s}`).join(`
|
|
22
|
+
`)}function zt(e,t){let n=[],s=[],o=(p,l)=>s.push({code:"unreadable-crew",path:p,detail:l?`${l} could not be read; some instructions may be missing.`:"could not be read; some instructions may be missing."}),r=xe(t[e.agentsPath]??""),i=e.tasksPath?xe(t[e.tasksPath]??""):[];r?.length||o(e.agentsPath),i===null&&o(e.tasksPath);for(let{key:p,value:l,span:h}of r??[]){if(!It(l)){o(e.agentsPath,p);continue}let{llm:a,tools:m,...f}=l,y=Tt(f);if(y===null&&Object.keys(f).length){o(e.agentsPath,p);continue}let u=[{role:"system prompt",path:e.agentsPath,label:p,span:h}];for(let g of i??[])It(g.value)&&g.value.agent===p&&u.push({role:"knowledge",path:e.tasksPath,label:g.key,span:g.span});n.push({key:`${_e}${e.agentsPath}#${p}`,name:p,model:typeof a=="string"?a:null,description:typeof l.goal=="string"?l.goal:null,entry:{path:e.agentsPath,span:h,text:y},files:u,tools:Array.isArray(m)?[...new Set(m.filter(g=>typeof g=="string"&&!!g.trim()))]:[],skills:[],subagents:[]})}return{agents:n,notes:s,registry:!1}}function It(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{basename as Wt,posix as Se}from"node:path";function Dt(e,t,n){let s={...t.selected,codeAgentsFound:t.codeAgentsFound||t.selected.codeAgentsFound};if(!Te(e,s,n))return{kind:"none"};let o={...t.bodies,...s.files},r=J(e,Object.keys(o),D(s.root)).templatePaths,i=Ie(e,{...s,files:o},r);if(!t.entries)return{kind:"search",paths:[],ownedPaths:i.ownedPaths};let p=new Set([...Object.keys(o),...t.attemptedPaths??[]]),l=new Set(i.facts.dependencies);for(let u of i.relatedReads)u.target.kind==="file"&&l.add(u.target.path);for(let u of t.entries)i.relatedReads.some(g=>g.target.kind==="directory"&&Pe(g,u.path))&&l.add(u.path);let h=(u,g)=>{let k=C(e,u,{purpose:g,route:"local-folder"});return k.admitted||k.reason==="too-large"},a=[...new Set(t.entries.filter(u=>!p.has(u.path)&&(l.has(u.path)?h(u,"pointer"):B(u.path,s.root)===null&&E(u.path)!==null&&h(u,"code-support"))).map(u=>u.path))],m=D(s.root)??"",f=u=>Se.parse(u).name===(m?Wt(m):s.fallbackName)?0:Qe.test(Wt(u))?1:2,y=u=>Se.relative(m||".",Se.dirname(u)).split("/").filter(g=>g&&g!==".").length;return a.sort((u,g)=>Number(l.has(g))-Number(l.has(u))||f(u)-f(g)||y(u)-y(g)||(u<g?-1:u>g?1:0)),{kind:"search",paths:a,ownedPaths:i.ownedPaths}}function Pe(e,t){return e.target.kind==="file"?e.target.path===t:Se.dirname(t)===e.target.path&&(!e.target.extension||t.endsWith(e.target.extension))}function Te(e,t,n){if(!de(e)||t.codeAgentsFound||t.explicitPrompt!==void 0||n.agents.length||t.listedPaths&&J(e,[...t.listedPaths],D(t.root)).configPath)return null;let s=J(e,Object.keys(t.files),D(t.root)).templatePaths;if(!s.length)return null;let o=Object.fromEntries(Object.entries(t.files).filter(([r])=>B(r,t.root)!==null&&C(e,{path:r},{purpose:"override",route:"github"}).admitted));return Me(o).reads.some(r=>s.some(i=>Pe(r,i)))?null:s}function Ie(e,t,n){let s=Object.fromEntries(Object.entries(t.files).filter(([f])=>C(e,{path:f},{purpose:"override",route:"github"}).admitted)),o=Me(s),r=o.reads.filter(f=>B(f.sourcePath,t.root)===null&&n.some(y=>Pe(f,y))),i=n.filter(f=>r.some(y=>Pe(y,f))).sort(),p=[...new Set(r.map(f=>f.sourcePath))].sort(),l=o.reads.filter(f=>p.includes(f.sourcePath)),h=l.flatMap(f=>f.target.kind==="file"&&Object.hasOwn(s,f.target.path)&&B(f.target.path,t.root)!==null&&!n.includes(f.target.path)?[f.target.path]:[]).sort(),a=r.flatMap(f=>f.consumerPaths).sort(),m=i.length?[...new Set([i[0],...n.filter(f=>f!==i[0]),...h,...p,...a])]:[];return{facts:o,relatedReads:l,provenTemplates:i,ownedPaths:m}}function Rs(e,t){let n=Ft(e,t,qt(e,t)),s=Te(e,t,n);if(!s)return n;let o=Ie(e,t,s);if(!o.provenTemplates.length)return n;let r=o.provenTemplates[0],i=new Set(n.agentScopes?.find(l=>l.key===null)?.notes),p=l=>!(l.code==="no-prompt"&&l.detail==="no-conventions"&&l.path===(D(t.root)??""));return{...n,projection:"conventions",notes:n.notes.filter(p),...n.agentScopes?{agentScopes:n.agentScopes.map(l=>({...l,notes:l.notes.filter(p)}))}:{},...n.unassignedNotes?{unassignedNotes:n.unassignedNotes.filter(l=>!i.has(l))}:{},agents:[{key:null,name:t.fallbackName,model:null,description:null,prompt:{kind:"dedicated",path:r},files:o.ownedPaths.map(l=>({path:l,role:l===r?"system prompt":s.includes(l)?"template":"reference",label:null})),skills:[],subagents:[]}]}}function Ts(e,t){return de(e)?Dt(e,t,qt(e,t.selected)):{kind:"none"}}function qt(e,t){if(!me(e)){let{agents:c,notes:S}=ze(e,t,null);return{agents:c,notes:S}}let n=Ue(e,t.listedPaths??[]).flatMap(c=>[...c.agents,...c.configs]),s=[...new Set([...Object.keys(t.files),...n])],{scopes:o,ownerOf:r,ignoredPaths:i,pluginFolders:p}=se(e,s,t.root),l=new Set(i),h=new Map(o.map(c=>[c,{}]));for(let[c,S]of Object.entries(t.files)){if(l.has(c))continue;let b=r(c);b&&(h.get(b)[c]=S)}let a=o.map(c=>{let S=h.get(c),b={...t,files:S,root:c.folder,fallbackName:c.key===null?t.fallbackName:Jt(c.folder),explicitPrompt:c.key===null?t.explicitPrompt:void 0,...t.pointerFiles?{pointerFiles:Object.fromEntries(Object.entries(t.pointerFiles).filter(([P])=>!l.has(P)&&r(P)===c))}:{}};return{scope:c,input:b,answer:Bt(e,c,b)}}),m=[],f=new Map,y=a.filter(({scope:c,input:S,answer:b})=>{let P=b.agents[0];if(!P)return!0;let O=Object.entries(S.files).map(([j,A])=>[B(j,c.folder),A]).sort(([j],[A])=>j<A?-1:j>A?1:0),x=JSON.stringify([P.name,O,...c.managed||at(e)&&p.includes(c.folder)?[c.folder]:[]]),L=f.get(x);return L!==void 0?(m.push({code:"duplicate-agent",path:c.folder,detail:L}),!1):(f.set(x,c.folder),!0)});if(y.some(({scope:c,answer:S})=>c.key!==null&&S.agents.length)){let c=y.find(({scope:S})=>S.key===null);c.answer=Bt(e,c.scope,c.input,!0),c.answer.notes=c.answer.notes.filter(S=>S.detail!=="no-conventions")}let{kept:u,leftOut:g}=_t(e,y.flatMap(({answer:c})=>c.agents)),k=[...m,...g.length?[{code:"agent-cap",detail:Rt({kind:"layout",leftOut:g.length})}]:[]],w=new Set(u.map(c=>c.key));return{...!t.definitionsOmitted&&y.some(({scope:c})=>c.kind==="crew")&&y.every(({scope:c,answer:S})=>S.notes.length===0&&(c.kind==="crew"?S.agents.length>0&&S.agents.every(b=>Re(b.key??"")):S.agents.length===0))&&(!t.listedPaths||se(e,t.listedPaths,t.root).files.every(c=>Object.hasOwn(t.files,c.path)))?{complete:!0}:{},...y.some(({scope:c,answer:S})=>c.miniSwe&&S.agents.length)&&!t.codeAgentsFound?{projection:"conventions"}:{},agents:u,notes:[...y.flatMap(({answer:c})=>c.notes),...k],...n.length?{scopePaths:s}:{},...y.some(({answer:c})=>c.refused?.length)?{refused:y.flatMap(({answer:c})=>c.refused??[])}:{},...o.length>1||o.some(c=>c.kind==="crew"||c.managed||c.miniSwe)?{agentScopes:y.flatMap(({scope:c,answer:S})=>(S.agents.length?S.agents:[{key:c.key}]).map((b,P)=>({key:b.key,folder:c.folder,registry:S.registry&&!Re(b.key??""),notes:S.notes.filter(O=>O.code!=="unreadable-crew"||P===0)}))),unassignedNotes:[...y.filter(({answer:c})=>!c.agents.some(S=>w.has(S.key))).flatMap(({answer:c})=>c.notes),...k]}:{}}}function Bt(e,t,n,s=!1){if(t.managed)return At(e,t,n);if(t.miniSwe&&n.explicitPrompt===void 0)return Ct(e,t,n);if(t.kind!=="crew")return ze(e,n,t.key,s);let o=hn(e,t,n.files),r=ze(e,n,t.key,s||t.key===null&&o.agents.length>0);return{agents:[...r.agents,...o.agents],notes:[...r.notes.filter(i=>i.detail!=="no-conventions"),...o.notes],registry:r.registry}}function hn(e,t,n){let{agents:s,notes:o,registry:r}=zt(t,n);return{agents:s.map(({entry:i,...p})=>({...p,prompt:Gt(e,{entry:i},o)})),notes:o,registry:r}}function ze(e,t,n,s=!1){let{files:o,skills:r,fallbackName:i}=t,p=D(t.root),l=J(e,Object.keys(o),p),h=[],a=t.explicitPrompt,m=typeof a=="string"&&Object.hasOwn(o,a)&&C(e,{path:a},{purpose:"override",route:"github"}).admitted?a:null,f={...l,skillPaths:r?l.skillPaths:[]},y=it(f),u=Be({codeAgentsFound:!1,folderAgentsFound:s,otherDefinitions:y});if(!(a===null||m!==null||lt(f,u)))return Kt(l,r,h),{agents:[],notes:[...h,{code:"no-prompt",path:p??"",detail:"no-conventions"}],registry:l.registry};let k=gn(o,l.configPath,h),w=Gt(e,{files:o,c:l,guideRole:u,folderAgentsFound:s,root:p,config:k,explicitPath:a===null?null:m??void 0,pointerFiles:t.pointerFiles},h),d=r?l.skillPaths.map(b=>{let P=fe(e,`${l.skillNames[b]}.md`,o[b]);return h.push(...(P.warnings??[]).map(O=>({code:"frontmatter",path:b,detail:O}))),{path:b,name:P.name,description:P.description??"",body:P.prompt??""}}):[];Kt(l,r,h);let c=r?[...l.subagentSkillPaths,...l.subagentSkillRefPaths]:[],S=l.subagentPaths.map(b=>{let P=fe(e,Jt(b),o[b],{preserveToolAbsence:!0});return h.push(...(P.warnings??[]).map(O=>({code:"frontmatter",path:b,detail:O}))),{path:b,name:P.name,description:P.description??null,prompt:P.prompt??"",...P.tools!==void 0?{tools:P.tools}:{},...P.model!==void 0?{model:P.model}:{},skillPaths:c.filter(O=>l.subagentSkillOwners[O]===b)}});return{agents:[{key:n,name:k?.name??i,model:k?.model??null,description:k?.description??null,prompt:w,files:kn(e,o,l,w,r),skills:d,subagents:S}],notes:h,registry:l.registry}}function Is(e,t,n,s){let o=J(e,Object.keys(n),D(s));return Object.hasOwn(o.subagentSkillOwners,t)?!0:ie(e,{skillPaths:o.subagentSkillPaths,paths:o.scoped,files:n,root:s})?.some(r=>r.files.some(i=>i.path===t))??!1}function gn(e,t,n){if(!t)return null;let s=Ce(e[t]);if(s.invalid)try{JSON.parse(e[t])}catch{n.push({code:"invalid-config",path:t})}return s.config}function Gt(e,t,n){if("entry"in t)return t.entry.text?{kind:"entry",...t.entry,text:t.entry.text}:(n.push({code:"no-prompt",path:t.entry.path}),{kind:"none"});let{files:s,c:o,guideRole:r,folderAgentsFound:i,root:p,config:l,explicitPath:h,pointerFiles:a}=t;if(h===null)return{kind:"none"};if(h!==void 0)return{kind:"explicit",path:h};let m=l?.agents?.[0]?.prompt??l?.prompt,f=l?Et(e,l,p??"")[0]:void 0,y=m?Ee(e,m,{repoKey:"",markerDir:p??"",files:a??s}):null,u=f!==void 0&&Object.hasOwn(s,f),g=u&&!!s[f];if(u&&(g||a!==void 0)&&Object.hasOwn(o.subagentSkillOwners,f))n.push({code:"pointer-owned-by-subagent",path:f});else if(u&&(a===void 0?g:y?.kind==="resolved")){let k=y?.kind==="resolved"?y.prompt:null;return{kind:"pointer",path:f,...k&&k.kind!=="file"?{span:{...k.span},site:{kind:k.kind,start:k.start,symbol:k.symbol}}:{}}}else m&&n.push(a!==void 0&&y?.kind==="secret"?{code:"secret-file",path:y.path}:{code:"pointer-missed",...f?{path:f}:{},detail:m});return o.promptPath?{kind:"dedicated",path:o.promptPath}:o.registry&&o.soulPath?{kind:"registry",path:o.soulPath}:o.claudePath&&r==="prompt"?(n.push({code:"claude-fallback"}),{kind:"fallback",path:o.claudePath}):(n.push({code:"no-prompt",path:p??"",...i?{folderAgentsFound:!0}:{}}),{kind:"none"})}function Kt(e,t,n){if(t)for(let s of[...e.subagentSkillPaths,...e.subagentSkillRefPaths])e.subagentSkillOwners[s]||n.push({code:"orphan-skill",path:s})}function kn(e,t,n,s,o){let r=[],i=(m,f,y=null)=>({role:m,label:y,path:f});if(s.kind!=="none"&&s.kind!=="registry"&&r.push(i("system prompt",s.path)),n.soulPath&&r.push(i("soul",n.soulPath)),n.knowledgePath&&r.push(i("knowledge",n.knowledgePath)),o)for(let m of n.skillPaths)r.push(i("skill",m,n.skillNames[m]));for(let m of n.templatePaths)r.push(i("template",m));if(o)for(let m of n.skillRefPaths)r.push(i("reference",m,n.skillRefNames[m]));let p=[];n.configPath&&p.push(i("config",n.configPath));for(let m of[n.toolsPath,n.toolsTsPath,n.cliPath])m&&p.push(i("tools",m));n.mcpPath&&p.push(i("mcp",n.mcpPath));let l=new Set([...r.map(m=>m.path),...p.map(m=>m.path),...n.subagentPaths,...Object.keys(n.subagentSkillOwners),...n.skillPaths,...n.skillRefPaths]),h=n.scoped.filter(m=>!l.has(m)&&pe(m)).sort(),a=Q(e)?r.filter(m=>m.role!=="skill"):r;return r.push(...be(h,a.map(m=>t[m.path]),n.stripRoot).map(m=>i("reference",m)),...p),r}export{bn as a,Xt as b,mt as c,dt as d,gt as e,ie as f,wt as g,je as h,tn as i,fo as j,co as k,Pt as l,po as m,sn as n,go as o,Ae as p,bo as q,fe as r,be as s,Ce as t,Yo as u,Fe as v,Et as w,Lt as x,Xo as y,Nt as z,_t as A,Rt as B,Rs as C,Ts as D,Is as E};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";var n=2,i=["malformed_answer","missing_row","duplicate_key","model_declined","incomplete_pair","invalid_wording","unsupported_number","insufficient_question_evidence","invalid_source","model_unavailable","over_input_allowance","provider_failure","stale_checkpoint","incompatible_relay_result","attachment_mismatch"],t=e.number().int().nonnegative(),o=e.object({requested:t,accepted:t,rejected:t,unexpectedRows:t,byReason:e.partialRecord(e.enum(i),t)}).strict(),r=e.object({key:e.string().min(1),reason:e.enum(i)}).strict(),c=e.object({version:e.literal(n),rows:e.array(e.object({key:e.string().min(1),headline:e.string().min(1),ifLeft:e.string().min(1)}).strict()),rejected:e.array(r),diagnostics:o}).strict();export{n as a,i as b,o as c,r as d,c as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as p,e as o,h as a}from"./JKWTHRUR.js";var s=new Set(["check-findings","check-findings-precision-v1","second-opinion"]);function l(t,n,r=p){let e=t.CF_PROMPT_CACHE!=="0",i="template"in n?s.has(n.template)?[0]:[]:(n.promptBlocks??[]).flatMap((u,h)=>u.cache?[h]:[]),c=e&&i.length>0?"5m":null;return{enabled:e,breakpoints:i,ttl:c,inputMultiplier:c===null?1:o(r,c)}}function f(t,n){for(let e of n)if(!Number.isInteger(e)||e<0||e>=t.length)throw new RangeError("Invalid cache breakpoint index");let r=new Set(n);return t.map((e,i)=>({text:e.text,...r.has(i)?{cache:!0}:{}}))}function d(t,n,r,e,i,c){return a(r,e,i,c,l(t,n,e).inputMultiplier)}function x(t){return o(t,"1h")}function C(t){return l(t,{}).enabled}export{l as a,f as b,d as c,x as d,C as e};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{f as V,yb as C}from"./HPIAEQHE.js";import{f as T,g as M}from"./FSLWD2PE.js";function F(e){let s=e.replace(/\s/g," "),t=[],r=[],n=!0;for(let d=0;d<e.length;d++){let c=s[d];c===" "&&n||(t.push(c),r.push(d),n=c===" ")}return{text:t.join("").trimEnd(),offsets:r}}function*_(e,s){let t=F(e),r=F(s).text;if(!r)return;let n=i=>e.slice(0,t.offsets[i]).split(`
|
|
2
|
+
`).length,d=t.text.indexOf(r);if(d>=0){for(let i=d;i>=0;i=t.text.indexOf(r,i+1))yield[{from:n(i),to:n(i+r.length-1)}];return}let c=r.split(/\s*(?:\.{3}|…)\s*/);if(!(c.length<2||c.some(i=>!i)))for(let i=t.text.indexOf(c[0]);i>=0;i=t.text.indexOf(c[0],i+1)){let o=i+c[0].length,a=[{from:n(i),to:n(o-1)}],f=!0;for(let l of c.slice(1)){let u=t.text.indexOf(l,o);if(u<0||/\n\s*\n|\n\s*#{1,6}\s|\n[^\s][^:\n]*:/.test(e.slice(t.offsets[o-1]+1,t.offsets[u]))){f=!1;break}o=u+l.length,a.push({from:n(u),to:n(o-1)})}f&&(yield a)}}function E(e,s){for(let t of _(e,s))return t[0].from;return null}function se(e,s,t){if(!Number.isInteger(t)||t<1)return null;for(let r of _(e,s)){if(r[0].from===t)return r;if(r[0].from>t)break}return null}var U="We couldn't see this agent's code, so this may already be handled there.";function re(e){return Object.values(e).some(s=>[...s].some(t=>V(t)!==null))}function j(e,s){return e==="better_as_code"&&s===!1?U:void 0}function ce(e){return e.sawCode??e.findingQuality?.sawCode}var W="Findings could not be checked a second time; all findings were kept.";function I(e,s){let t=new Set(s),r=new Map,n=new Set,d=new Set,c=new Set;for(let i of e){if(!t.has(i.id)){d.add(i.id);continue}if(n.has(i.id)){c.add(i.id),r.delete(i.id);continue}n.add(i.id),r.set(i.id,i)}return{byId:r,unknownIds:[...d],duplicateIds:[...c]}}function H(e,s){let t=I(e,s);return t.unknownIds.length===0&&t.duplicateIds.length===0}function ue(e,s,t,r={}){let n=e.map((h,w)=>`f${w+1}`),d=!H(s,n),c=d?"Verdict ids did not match; all findings were kept.":t?.failure,i=new Set(t?.sentIds??n),o=new Map(t?.skipped.map(h=>[h.id,h.reason])??[]),a=d?["verdict ids did not match"]:[],f=new Map(s.map(h=>[h.id,h])),l=[...t?.rejectedBatches??[],...d?[{ids:n,verdicts:s}]:[]],u=new Map,p=[],O=r.mode==="offline-simulation"&&r.shadow?.done?I(r.shadow.verdicts,n).byId:new Map;for(let h of l)for(let w of h.verdicts)h.ids.includes(w.id)&&u.set(w.id,w);let R=e.map((h,w)=>{let g=n[w],v=d?void 0:f.get(g),k=f.get(g)??u.get(g),A=i.has(g)||k!==void 0,$=A?"":o.get(g)??"No model call was made before the check stopped.",b="keep",m;A?c?m=c:v?v.reason.trim()?!v.evidenceAgainst?.trim()||!v.evidenceFor?.trim()||v.verdict==="drop"&&/^[\s"'“”‘’]*none found[\s."'“”‘’]*$/i.test(v.evidenceAgainst)?(m="The model supplied no usable evidence for its decision; this finding was kept.",a.push(`${g}: ${m}`)):(b=v.verdict,m=v.reason,p.push(g)):(m="The model returned an empty reason; this finding was kept.",a.push(`${g}: ${m}`)):(m="The model returned no verdict for this finding in the accepted response; it was kept.",a.push(`${g}: ${m}`)):m=$;let y=O.get(g);return!c&&p.includes(g)&&y&&r.shadow?.coverage.answeredIds.includes(g)&&(y.verdict==="drop"&&y.decisive&&y.quotes.some(L=>L.side==="against")?(b="drop",m=y.reason):y.verdict!==b&&(b="keep",m="The checks disagree without decisive contrary evidence; this finding was kept.")),{id:g,title:h.title,verdict:b,reason:m,sent:A,skipReason:$,modelVerdict:k?.verdict??"",modelReason:k?.reason??"",evidenceAgainst:k?.evidenceAgainst??"",evidenceFor:k?.evidenceFor??""}}),x=[],P=e.filter((h,w)=>{let g=R[w];return g.verdict!=="drop"?!0:(x.push({finding:h,reason:g.reason}),!1)}),z=c?[W]:x.length?[`${x.length} ${x.length===1?"finding was":"findings were"} removed after a second read: ${x.map(({finding:h})=>h.title.replace(/\s+/g," ").trim()).join("; ")}`]:[];return{kept:c?e:P,dropped:x,warnings:z,verdicts:R,...a.length?{diagnostics:a}:{},...l.length?{rejectedBatches:l}:{},...t?.recordAcceptance?{acceptedIds:p}:{}}}var B={critical:0,high:1,medium:2,low:3},J="No strong findings to show.",K=/^[\s"'“”‘’]*none found[\s."'“”‘’]*$/i,Y=/"([^"\n]*(?:\n[^"\n]*)*)"|“([^”]+)”|`([^`]+)`|‘([^’]+)’|'([^'\n]+)'/g;function S(e,s){return I(e.map(t=>({...t,id:t.fingerprint})),s).byId}function q(e,s){return e.repo===s.repo&&e.path===s.path}function N(e,s){let t=e.repos.filter(r=>r.key===s.repo);return t.length===1?t[0].files?.[s.path]:void 0}function Q(e,s,t){return e===void 0||s===null||!Number.isInteger(s)||s<1||!t?.trim()?!1:E(e.split(`
|
|
3
|
+
`).slice(s-1).join(`
|
|
4
|
+
`),t)===1}function X(e){return[...e.site?[{repo:e.siteRepo??"",...e.site,excerpt:e.excerpt}]:[],...e.otherSites]}function D(e,s){let t=N(s,e),r=e.line>1?t.split(`
|
|
5
|
+
`).slice(0,e.line-1).join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`:"",n=t.replace(/\s+/g," "),d=e.excerpt.replace(/\s+/g," ").trim(),c=r.replace(/\s+/g," ").length,i=n.indexOf(d,c);if(i>=0)return{from:i,to:i+d.length};let o=d.split(/\s*(?:\.{3}|…)\s*/),a=n.indexOf(o[0],c),f=a;for(let l of o){let u=n.indexOf(l,f);if(u<0)return null;f=u+l.length}return a<0?null:{from:a,to:f}}function Z(e,s,t){if(!q(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(!M(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<T(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(d=>q(n,d))||N(r,n)===void 0))return"Required files were not included in the check.";for(let n of s){if(!t.requested.some(d=>q(d,n))||!t.included.some(d=>q(d,n)))return"A cited file was not included in the check.";if(!Q(N(r,n),n.line,n.excerpt))return"A cited quote could not be verified at its source line."}return T(e.category)===2&&!s.some((n,d)=>s.slice(d+1).some(c=>Z(n,c,r)))?"The category needs distinct quoted sites.":null}function te(e,s){let t=e.cause.replace(/\s+/g," ").trim();for(let d of s){let c=d.excerpt?.replace(/\s+/g," ").trim();c&&(t=t.replaceAll(c,""))}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(i=>{let o=i[1],a=t.included.filter(l=>l.path===o||`${l.repo}:${l.path}`===o),f=[...new Map(a.map(l=>[JSON.stringify([l.repo,l.path]),l])).values()];return{from:i.index,to:i.index+i[0].length,line:Number(i[2]),ref:f.length===1?f[0]:void 0}});if(n.length===0||n.some(i=>!i.ref))return!1;let d=new Map;for(let i of e.matchAll(Y)){let o=i.index,a=o+i[0].length;if(n.some(p=>p.from>=o&&p.to<=a))continue;let f=i.slice(1).find(p=>p!==void 0),l=n.flatMap((p,O)=>Q(N(r,p.ref),p.line,f)?[O]:[]);if(l.length!==1)return!1;let u=l[0];d.set(u,[...d.get(u)??[],f])}let c=!1;for(let i=0;i<n.length;i++){let o=n[i],{line:a,ref:f}=o,l=d.get(i)??[];if(l.length===0)return!1;s.some(u=>q(u,f)&&u.line===a&&l.some(p=>E(p,u.excerpt??"")!==null))&&(c=!0)}return c}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)?K.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(C),t=S(e.coverage,s),r=S(e.verdicts,s),n=new Set(e.shadowRequestedIds??(e.shadowVerdicts===void 0?[]:s)),d=S(e.shadowVerdicts??[],[...n]);return e.findings.map((c,i)=>{let o=s[i],a=X(c),f=t.get(o),l=ee(c,a,f,e.sources),u=j(c.category,e.sawCode)??l;!u&&!te(c,a)&&(u="The finding does not explain a concrete behavioral consequence."),u||(u=G(r.get(o),a,f,e.sources)),!u&&n.has(o)&&(u=G(d.get(o),a,f,e.sources)),!u&&c.sourceNotes&&(c.sourceNotes.support!=="supported"||c.sourceNotes.counterEvidence.length>0)&&(u="Source notes contain uncertain support or unresolved contrary evidence.");let p=u?"not sure":"sure";return{fingerprint:o,support:l?"incomplete":"complete",confidence:p,weak:p!=="sure"||c.severity==="low",reason:u??(c.severity==="low"?"Verified support, but low impact.":"Verified quotes and an accepted keep support the stated consequence.")}})}function xe(e,s,t){let r=e.map(t??(o=>C(o))),n=S(s,r),d=e.map((o,a)=>{let f=r[a],l=n.get(f),u=l?.confidence==="sure",p=u&&l?.support==="complete"&&!l.weak&&o.severity!=="low";return{finding:o,fingerprint:f,sure:u,strong:p}}).sort((o,a)=>Number(a.strong)-Number(o.strong)||B[o.finding.severity]-B[a.finding.severity]||Number(a.sure)-Number(o.sure)||(o.fingerprint<a.fingerprint?-1:o.fingerprint>a.fingerprint?1:0)),c=d.filter(o=>o.strong).slice(0,3),i=new Set(c);return{ordered:d.map(o=>o.finding),defaultIds:c.map(o=>o.fingerprint),hiddenIds:d.filter(o=>!i.has(o)).map(o=>o.fingerprint),emptyMessage:!c.length&&d.length?J:null}}export{E as a,se as b,re as c,ce as d,W as e,I as f,H as g,ue as h,ve as i,xe as j};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{D as H,F as J,H as Q,Ha as E,T as I,d as X,e as Y,fa as j,g as R,h as b,i as _,na as Z,oa as ee,p as x,q as V,ra as te,s as q,sa as A,t as M,ta as ne,u as $,va as oe,wa as C,ya as T}from"./HPIAEQHE.js";import{a as W,c as S,e as N}from"./T5TREZCQ.js";function G(t,r,n){let f=E(t,r.filter(e=>j(t,{path:e},{purpose:"override",route:"github"}).admitted),{root:n});return B(f)}function B(t){let r=new Map(t.scoped.map(e=>[e.path,e.relativePath])),n=(e,i,l=!1)=>t.files.find(a=>a.role===e&&a.kind!=="background"&&a.preferred!==!1&&(!i||a.kind===i)&&(!l||a.preferred))?.path??null,f=(e,i,l=!1)=>t.files.filter(a=>a.role===e&&(!i||a.kind===i)&&a.ownerPath!==void 0===l).map(a=>a.path).sort();return{scoped:t.scoped.map(e=>e.path),stripRoot:e=>r.get(e)??e,configPath:n("marker"),promptPath:n("prompt","dedicated",!0),claudePath:n("prompt","fallback"),toolsPath:n("tool file","json"),toolsTsPath:n("tool file","sdk"),cliPath:n("tool file","cli"),mcpPath:n("MCP config",void 0,!0),registry:t.registry,soulPath:n("soul"),knowledgePath:n("knowledge"),subagentPaths:f("sub-agent"),skillPaths:f("skill"),skillNames:Object.fromEntries(t.files.filter(e=>e.role==="skill"&&e.name).map(e=>[e.path,e.name])),skillRefNames:Object.fromEntries(t.files.filter(e=>e.role==="reference"&&e.kind==="skill"&&e.name).map(e=>[e.path,e.name])),templatePaths:f("reference","template"),skillRefPaths:f("reference","skill"),subagentSkillPaths:f("skill",void 0,!0),subagentSkillRefPaths:f("reference","skill",!0),subagentSkillOwners:Object.fromEntries(t.files.filter(e=>e.ownerPath!==void 0).map(e=>[e.path,e.ownerPath]))}}function O(t){return!!(t.promptPath||t.toolsPath||t.toolsTsPath||t.cliPath||t.mcpPath||t.soulPath||t.knowledgePath||t.subagentPaths.length||t.skillPaths.length)}function se(t,r){return!!t.configPath||!!t.claudePath&&r==="prompt"||O(t)}function ge(t){return M(t,"CF_IMPORT_LAYOUTS")}function ie(t,r){return ge(t)?[...new Set(r)].sort().flatMap(n=>{if(n.includes("\\")||/[:\0]/.test(n)||n.split("/").some(e=>!e||e==="."||e===".."))return[];let f=/^(?:(.*)\/)?\.claude-plugin\/plugin\.json$/i.exec(n);return f?[{folder:f[1]??"",path:n}]:[]}):[]}function ae(t,r,n){let f=r.split("/");for(let e=0;e<f.length-2;e++)if(!(f[e].toLowerCase()!=="plugins"||!f[e+1])&&re(t,f.slice(e+2).join("/")))return f.slice(0,e+2).join("/");for(let e of[...n].sort((i,l)=>l.folder.length-i.folder.length)){let i=S(r,e.folder);if(i!==null&&re(t,i))return e.folder}return null}function re(t,r){return r.toLowerCase().startsWith(`${A}/`)&&C.test(r)||!!(T(t)&&r.toLowerCase().startsWith(`${ne}/`)&&$(r)?.definition)}import{posix as D}from"node:path";function z(t,r=1){let n=new Set,f=[],e=t.replace(/{#[\s\S]*?#}|{%[-+]?\s*raw\s*[-+]?%}[\s\S]*?(?:{%[-+]?\s*endraw\s*[-+]?%}|$)/g,i=>i.replace(/[^\n]/g," "));for(let i of e.matchAll(/{%[-+]?\s*(include|extends|import|from)\s+(.+?)\s*[-+]?%}/g)){let l=i[2].match(/^(["'])([^"']+)\1(?:\s+(?:as\s+\w+|import\s+.+|ignore missing|with context|without context))?$/),a=r+t.slice(0,i.index).split(`
|
|
2
|
+
`).length-1;f.push({source:l?.[2]??i[2],span:{from:a,to:a},...l?{}:{reason:"dynamic"}})}for(let i of e.matchAll(/{{[-+]?\s*([\w]+)|{%[-+]?\s*(?:if|elif|for\s+\w+\s+in|set\s+\w+\s*=)\s+([\w]+)/g)){let l=i[1]??i[2];!["true","false","none"].includes(l.toLowerCase())&&!/^\d/.test(l)&&n.add(l)}return{variables:[...n],loaders:f}}function le(t){let r=t.split(`
|
|
3
|
+
`),n=[],f=[],e=(i,l,a)=>{let k=new Set;for(let g of J(i.join(`
|
|
4
|
+
`))){let m=a?`${a}.${g.key}`:g.key,d={from:l+g.span.from,to:l+g.span.to},o=i.slice(g.span.from-1,g.span.to);k.has(g.key)&&f.push({key:m,span:d,reason:"duplicate"}),k.add(g.key);let s=o[0].slice(o[0].indexOf(":")+1).trim();if(!s||s.startsWith("#")){let p=o.slice(1),w=p.find(P=>P.trim()&&!P.trimStart().startsWith("#"))?.match(/^ */)?.[0].length;if(w){e(p.map(P=>P.slice(w)),d.from,m);continue}}let h=H(o.join(`
|
|
5
|
+
`))?.[g.key],u=typeof h=="string"?h:null,c=m.endsWith("_template");(c&&u===null||/^[!&*]/.test(s))&&f.push({key:m,span:d,reason:"invalid"}),n.push({key:m,span:d,text:r.slice(d.from-1,d.to).join(`
|
|
6
|
+
`),value:u,...c&&u!==null?z(u,d.from+(/^[|>]/.test(s)?1:0)):{variables:[],loaders:[]}})}};e(r,0,"");for(let i of f.filter(l=>l.reason==="duplicate"))for(let l of n.filter(a=>a.key===i.key||a.key.startsWith(`${i.key}.`)))l.value=null;return{fields:n,unresolved:f}}function ce(t){return M(t,"CF_IMPORT_LAYOUTS")}function fe(t,r){if(!ce(t))return[];let n=new Set(r),f=[];for(let e of[...n].sort()){let i=e.match(/^((?:[^/]+\/)*?)(?:src\/)?minisweagent\/agents\/default\.py$/);if(!i)continue;let l=e.slice(0,-18),a=`${l}/config`,k=`${a}/__init__.py`,g=`${l}/run/mini.py`;if(!n.has(k)||!n.has(g))continue;let m=[...n].filter(d=>S(d,a)!==null&&/\.ya?ml$/.test(d)).sort();m.length&&f.push({folder:i[1].replace(/\/$/,""),configFolder:a,agentPath:e,loaderPath:k,runnerPath:g,configs:m,templates:[...n].filter(d=>S(d,a)!==null&&/\.(?:j2|jinja2?)$/.test(d)).sort()})}return f}function ke(t,r){let n=R(t.agentPath,r[t.agentPath]??"","py").toks,f=R(t.loaderPath,r[t.loaderPath]??"","py").toks,e=R(t.runnerPath,r[t.runnerPath]??"","py").toks;if(!["system_template","instance_template"].every(l=>n.some((a,k)=>_(a,l)&&b(n[k-1],".")))||!f.some((l,a)=>_(l,"safe_load")&&b(f[a+1],"("))||!f.some((l,a)=>_(l,"read_text")&&b(f[a+1],"("))||!e.some((l,a)=>_(l,"get_config_from_spec")&&b(e[a+1],"("))||!e.some((l,a)=>_(l,"get_agent")&&b(e[a+1],"("))||!e.some((l,a)=>_(l,"get")&&b(e[a+1],"(")&&e[a+2]?.value==="agent"))return null;let i=e.flatMap((l,a)=>{if(!_(l,"DEFAULT_CONFIG_FILE")||!b(e[a+1],"="))return[];let k=e.slice(a+2).filter(g=>g.line===l.line);return k.flatMap((g,m)=>_(g,"builtin_config_dir")&&b(k[m+1],"/")&&k[m+2]?.kind==="string"?[D.join(t.configFolder,k[m+2].value)]:[])});return i.length===1?i[0]:null}function Ne(t,r,n,f){let e={variants:[],selectedPaths:[],fields:[],model:null,loaded:[],unresolved:[],edges:[]};if(!ce(t))return e;let i=ke(r,n);if(!i)return e.unresolved.push({path:r.runnerPath,source:"config",reason:"dynamic"}),e;let l=new Map,a=new Set(Object.keys(n)),k=o=>{let s=j(t,{path:o,text:n[o],size:n[o]===void 0?void 0:Buffer.byteLength(n[o])},{purpose:"pointer",route:"github",root:r.configFolder,listing:a,managedFiles:n});return s.admitted||l.set(o,s.reason),s.admitted},g=new Map([...new Set([...r.configs,...f??[]])].flatMap(o=>k(o)&&Object.hasOwn(n,o)?[[o,le(n[o])]]:[]));e.variants=r.configs.map(o=>({path:o,fields:(g.get(o)?.fields??[]).map(s=>({...s,path:o}))})),e.selectedPaths=f?[...f]:[i];let m=new Map;for(let o of e.selectedPaths){if(S(o,r.configFolder)===null){e.unresolved.push({path:o,source:o,reason:"out-of-scope"});continue}let s=g.get(o);if(!s){e.unresolved.push({path:o,source:o,reason:l.get(o)??"missing"});continue}e.unresolved.push(...s.unresolved.map(h=>({path:o,source:h.key,span:h.span,reason:h.reason})));for(let h of s.fields)if(/^(?:agent|model|environment)(?:\.|$)/.test(h.key)){for(let u of m.keys())(u.startsWith(`${h.key}.`)||h.key.startsWith(`${u}.`))&&m.delete(u);m.set(h.key,{...h,path:o})}}e.fields=[...m.values()],e.model=m.get("model.model_name")?.value??null;let d=new Set;for(let o of e.fields){let s=new Set([o.path]),h=[{path:o.path,facts:{variables:o.variables,loaders:o.loaders},next:0}];for(;h.length;){let u=h.at(-1),{path:c,facts:p}=u;if(u.next===0)for(let F of p.variables)e.unresolved.push({path:c,source:F,reason:"runtime-variable"});if(u.next>=p.loaders.length){s.delete(c),h.pop();continue}let w=p.loaders[u.next++],P=D.normalize(D.join(D.dirname(c),w.source)),v=w.reason??(D.isAbsolute(w.source)||S(P,r.configFolder)===null?"out-of-scope":k(P)?s.has(P)?"cycle":Object.hasOwn(n,P)?null:"missing":l.get(P));if(v){e.unresolved.push({path:c,source:w.source,...w.reason?{}:{target:P},span:w.span,reason:v});continue}e.edges.push({from:c,to:P,span:w.span}),!d.has(P)&&(d.add(P),e.loaded.push({path:P}),s.add(P),h.push({path:P,facts:z(n[P]),next:0}))}}return e}var Pe=new Set([...ee,Z.soul].map(t=>t.toLowerCase())),we=["templates","default_prompts","prompts/default","docs","evals","benchmarks"],Se=["tests","__tests__","fixtures","test_data","evals","benchmarks","templates","default_prompts","prompts/default","docs"];function ue(t,r=""){return t===r?null:`folder:${t}`}function et(t,r,n){let f=pe(t,r,n),e=W(n),i=r.filter(s=>!x(t,s,e)),l=i.filter(s=>f.ownerOf(s)?.key===null),a=G(t,l,e),k=O(a)||!!a.configPath,g=E(t,l,{root:e}).files.filter(s=>s.role!=="reference"&&s.kind!=="background"),m=new Set(g.map(s=>s.relativePath)),d=g.flatMap(s=>s.role==="sub-agent"?[s.relativePath.slice(0,-3)]:s.role==="skill"?[s.relativePath.slice(0,s.relativePath.lastIndexOf("/"))]:[]),o=new Map(f.scopes.map(s=>[s.folder,{scope:s,paths:[]}]));for(let s of[...new Set(i)]){let h=f.ownerOf(s);if(!h)continue;let u=S(s,e),c=u.split("/");if(h.key===null&&k&&c.length>1&&!m.has(u)&&!d.some(p=>S(u,p)!==null)){let p=c.slice(0,-1).findIndex((P,v)=>![...m].some(F=>F.startsWith(`${c.slice(0,v+1).join("/")}/`))),w=N(c.slice(0,p<0?-1:p+1).join("/"),e);o.has(w)||o.set(w,{scope:{key:ue(w,e),folder:w,kind:"folder"},paths:[]}),h=o.get(w).scope}o.get(h.folder).paths.push(s)}return[...o.values()].sort((s,h)=>s.scope.folder<h.scope.folder?-1:s.scope.folder>h.scope.folder?1:0).map(({scope:s,paths:h})=>{let u=G(t,h,s.folder),c=f.scopes.includes(s);return{scope:s,paths:h,convention:c&&(!!s.managed||!!s.miniSwe||s.kind==="crew"||O(u)),markerPath:c?u.configPath:null}})}function pe(t,r,n){let f=W(n),e=Y(t),i=ie(t,r),{scopes:l,skipped:a,pluginFolders:k}=e?ve(t,r,f,i):{scopes:[{key:null,folder:f,kind:"root"}],skipped:[],pluginFolders:[]},g=o=>me(l,o),m=r.filter(o=>x(t,o,f)||e&&g(o)&&I(t,o,k)),d=e?r.filter(o=>{let s=g(o);return s?.kind==="crew"&&S(o,s.folder)?.toLowerCase().startsWith("tools/")}):[];return{scopes:l,skipped:a,ownerOf:g,pluginFolders:k,ignoredPaths:m,ignoredImportPaths:d,...i.length?{pluginDeclarations:i.filter(o=>k.includes(o.folder))}:{}}}function me(t,r){return t.findLast(n=>S(r,n.folder)!==null)??null}function ve(t,r,n,f){let e=[...new Set(r)].filter(d=>!I(t,d)).sort().flatMap(d=>{let o=S(d,n);return o===null?[]:[{path:d,relativePath:o}]}),i=[],l=new Map,a=e.filter(d=>!x(t,d.path,n)).map(d=>d.path);for(let d of Q(t,a))l.set(d.folder,d.agents.map(o=>({path:o,plugin:!1,crew:!1,checkPath:`${d.folder}/`,managed:d})));for(let d of fe(t,a))l.set(d.folder,[...l.get(d.folder)??[],{path:d.agentPath,plugin:!1,crew:!1,checkPath:`${d.folder}/`,miniSwe:d}]);for(let{path:d,relativePath:o}of e){let s=o.split("/"),h=Pe.has(s.pop().toLowerCase())&&s.length>0,u=ae(t,d,f);u===n&&!x(t,d,n)&&!i.includes(n)&&i.push(n);let c=u!==null&&u!==n&&!!S(`${u}/`,n),p=o.toLowerCase()==="config/agents.yaml"||o.toLowerCase().endsWith("/config/agents.yaml");if(!h&&!c&&!p)continue;let w=p?d.slice(0,-18).replace(/\/$/,""):c?u:N(s.join("/"),n),P=l.get(w)??[];P.push({path:d,plugin:c,crew:p,checkPath:c?`${w}/`:d}),l.set(w,P)}let k=q(t),g={settings:t,folder:n,scoped:e,candidates:l,rootPlugins:i,excludedFolders:k?we:Se},m=de(g,new Set);if(k){let d=[...new Set(m.accepted.map(c=>c.folder))].filter(c=>c!==n),o=e.filter(c=>!x(t,c.path,n)&&!d.some(p=>S(c.path,p)!==null)).map(c=>c.path),s=E(t,o,{root:n,folderAgentsFound:d.length>0}),h=he(s,d.length>0)?[{path:`${n}/`,checkPath:`${n}/`}]:[],u=V([...m.accepted,...h],c=>c.checkPath,{root:n,listing:new Set(e.map(c=>c.path))});if(m.accepted.some(c=>u(c.checkPath))){let c=new Set([...l.values()].flat().filter(p=>u(p.checkPath)).map(p=>p.path));m=de(g,c)}}return m.skipped.sort((d,o)=>d.path<o.path?-1:d.path>o.path?1:0),{scopes:m.scopes,skipped:m.skipped,pluginFolders:m.pluginFolders}}function de({settings:t,folder:r,scoped:n,candidates:f,rootPlugins:e,excludedFolders:i},l){let a=[{key:null,folder:r,kind:"root"}],k=[],g=[...e],m=[],d=new Map;for(let o of[...f.keys()].sort()){let s=f.get(o),h=me(a,s[0].path),u=d.get(h.folder)??ye(n.map(y=>y.path),h.folder);d.set(h.folder,u);let c=[];for(let y of s){let{path:L,checkPath:U}=y;if(I(t,L,g))continue;let K=x(t,L,r)?"excluded-folder":o===r?null:l.has(L)?"excluded-folder":Fe(S(U,r),S(U,h.folder),u,i);K?k.push({path:L,reason:K}):(c.push(y),m.push({path:L,folder:o,checkPath:U}))}if(!c.length)continue;let p=c.find(y=>y.crew),w=ue(o,r),P=p?{key:w,folder:o,kind:"crew",agentsPath:p.path,tasksPath:n.find(y=>S(y.path,o)?.toLowerCase()==="config/tasks.yaml")?.path??null}:{key:w,folder:o,kind:"folder"},v=s.find(y=>y.managed)?.managed;v&&(P.managed=v);let F=s.find(y=>y.miniSwe)?.miniSwe;F&&(P.miniSwe=F),o===r?a[0]=P:a.push(P),c.some(y=>y.plugin)&&!g.includes(o)&&g.push(o)}return{scopes:a,skipped:k,pluginFolders:g,accepted:m}}function tt(t,r,n,f={}){let e=pe(t,r,n),{scopes:i,ownerOf:l,ignoredPaths:a}=e,k=new Set(a),g=new Map(i.map(u=>[u,[]]));for(let u of r){if(k.has(u))continue;let c=l(u);c&&g.get(c).push(u)}let m=i.map(u=>E(t,g.get(u),{root:u.folder,mode:f.mode,folderAgentsFound:u.key===null&&(i.length>1||u.kind==="crew")})),d=(u,c)=>he(u,i[c].key===null&&(i.length>1||i[c].kind==="crew")),o=i.length===1?m:m.filter((u,c)=>i[c].managed||i[c].miniSwe||i[c].kind==="crew"||d(u,c)),s=!o.length||o.some(u=>{let c=m.indexOf(u);return i[c].managed||i[c].miniSwe||i[c].kind==="crew"&&!d(u,c)?!1:!u.registry&&(!u.files.some(p=>p.role==="prompt")||!u.files.some(p=>p.role==="tool file"))}),h=m.flatMap((u,c)=>{let p=i[c];if(p.miniSwe)return[...u.files,...[...p.miniSwe.configs,...p.miniSwe.templates,p.miniSwe.agentPath,p.miniSwe.loaderPath,p.miniSwe.runnerPath].map(v=>({path:v,relativePath:S(v,p.folder),role:"knowledge",kind:"entry"}))];if(p.managed)return[...p.managed.agents,...p.managed.configs].flatMap(v=>{let F=$(S(v,p.folder))?.definition;if(F&&(f.mode==="core"||!T(t)))return[];let y=p.managed.agents.includes(v);return[{path:v,relativePath:S(v,p.folder),role:y?"prompt":F?"skill":"knowledge",kind:y?"entry":F?"skill":"json"}]});let w=(e.pluginDeclarations??[]).filter(v=>v.folder===p.folder).map(v=>({path:v.path,relativePath:S(v.path,p.folder),role:"marker",kind:"entry"}));if(p.kind!=="crew")return[...u.files,...w];let P=[{path:p.agentsPath,relativePath:S(p.agentsPath,p.folder),role:"prompt",kind:"entry"}];return p.tasksPath&&P.push({path:p.tasksPath,relativePath:S(p.tasksPath,p.folder),role:"knowledge",kind:"entry"}),[...u.files,...P,...w]});return{...e,files:h,needsExtraction:s}}function he(t,r){let n=B(t),f=X({codeAgentsFound:!1,folderAgentsFound:r,otherDefinitions:O(n)});return se(n,f)}function ye(t,r){let n=new Set;for(let f of t){let e=S(f,r);e!==null&&C.test(e)&&n.add(e.slice(0,-3).toLowerCase())}return n}function Fe(t,r,n,f){let e=t.toLowerCase();if(f.some(a=>`/${e}`.includes(`/${a}/`)))return"excluded-folder";let i=e.slice(0,e.lastIndexOf("/"));if($(t,{nested:!0})||oe.some(a=>i===a||i.endsWith(`/${a}`)))return"skill-folder";if(`/${e}`.includes(`/${te}/${A}/`)||C.test(r))return"sub-agent-folder";let l=r.toLowerCase().split("/");return l.some((a,k)=>n.has(l.slice(0,k).join("/")))?"sub-agent-folder":null}export{G as a,O as b,se as c,ge as d,Ne as e,et as f,pe as g,tt as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as g}from"./57M4OQJM.js";import{a as m}from"./IBCFGUHI.js";import{yb as p}from"./HPIAEQHE.js";import{createHash as y}from"node:crypto";function h(e,i){return e==="finding"?p(i):y("sha256").update(g(i)).digest("hex")}function l(e,i,a,n){let c=h(e,i);return x({target:e,index:a,fingerprint:c},n)}function x(e,i){let a={status:"rejected",reason:"attachment_mismatch"};if(!Number.isInteger(e.index)||e.index<0)return a;let n=i.filter(s=>s.target===e.target&&s.index===e.index);if(!n.length)return{status:"absent"};if(n.length!==1||n[0].fingerprint!==e.fingerprint)return a;let c=m(n[0]);return c?{status:"accepted",wording:c}:a}function R(e,i){let a=new Map(i.map(t=>[t.key,t])),n=e.evidence.flatMap(t=>{let r=a.get(t.key);if(!r)return[];let f=e.positions.filter(u=>u.key===t.key),o=f.length===1&&f[0].target===t.kind?f[0]:null;return[{key:t.key,pair:r,position:o}]}),c=n.flatMap(({pair:t,position:r})=>r?[{target:r.target,index:r.index,fingerprint:r.fingerprint,headline:t.headline,ifLeft:t.ifLeft}]:[]),s=[],d=[];for(let{key:t,position:r}of n){let f=r?x(r,c):null;if(!r||f?.status!=="accepted"){d.push({key:t,reason:"attachment_mismatch"});continue}s.push({target:r.target,index:r.index,fingerprint:r.fingerprint,...f.wording})}return{rows:s,rejected:d}}function _(e,i,a,n){let c=[],s=new Set,d=0;for(let t of a){let r=`${t.target}:${t.index}`;if(s.has(r))continue;s.add(r);let f=t.target==="finding"?e[t.index]:void 0,o=t.target==="structure"?i[t.index]:void 0;if((f?l("finding",f,t.index,a):o?l("structure",o,t.index,a):null)?.status!=="accepted"){d++;continue}c.push(t)}return{rows:c,...n?{diagnostics:d?{...n,accepted:n.accepted-d,rejected:n.rejected+d,byReason:{...n.byReason,attachment_mismatch:(n.byReason.attachment_mismatch??0)+d}}:n}:{}}}export{h as a,l as b,R as c,_ as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(e){return{multiPass:e.CF_MULTI_PASS!=="0",splitCheck:e.CF_SPLIT_CHECK!=="0",findingCheck:e.CF_FINDING_CHECK!=="0",sourceNotes:e.CF_SOURCE_NOTES!=="0"}}function c(e,r={}){let s=Number(e.CF_PASS_CONCURRENCY??(r.forLocal?4:3));return{enabled:e.CF_PARALLEL_PASSES!=="0",concurrency:r.passConcurrency??(Number.isSafeInteger(s)&&s>0?s:3)}}function a(e,r){let s=r.analysisFlags;return s?{...s,findingCheck:s.findingCheck??n(e).findingCheck,sourceNotes:s.sourceNotes??!1}:{...n(e),sourceNotes:!1}}export{n as a,c as b,a as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as r}from"./FSLWD2PE.js";function s(t){let e=Object.entries(r).find(([,n])=>n===t)?.[0]??t;return e==="contradiction"?["Says","But also says"]:e==="ambiguity"?["Unclear","Context"]:e==="bypassable_requirement"||e==="missing_requirement"?["Requirement","What actually happens","Why it's a gap"]:["Evidence","Context"]}export{s as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c}from"./E7TFIHC5.js";function O({templates:n,descriptions:t}){function e(r,o={}){if(!Object.hasOwn(n,r))throw new Error(`Unknown template: ${r}`);return c(n[r],o,n)}function u(r,o={}){if(!Object.hasOwn(t,r))throw new Error(`Unknown description: ${r}`);return c(t[r],o)}function w(r,o=[]){if(!Object.hasOwn(n,r))throw new Error(`Unknown template: ${r}`);if(o.includes(r))throw new Error("Include cycle");return n[r].replace(/{{include ([a-z0-9-]+)}}/g,(f,i)=>w(i,[...o,r]))}return{templates:n,descriptions:t,bundleText:e,description:u,templateText:w}}export{O as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as S}from"./T66VDFXF.js";import{c as i,d as n,e as c,f as l,g as a,h as u,i as f,j as h,l as d}from"./IVDDV6CU.js";import{d as s}from"./3MTXB4MK.js";import{z as y}from"zod";function Q(e){let t=d(e),m=h(e);return{...t,headlinePlan(o){let r=t.analysisRequest(o),p=m.headlineFallbackQuestion();return{inputBytes:t.callInputBytes(r),fallbackQuestion:p,identity:{system:r.system,data:r.prompt,schema:y.toJSONSchema(r.schema),fallbackQuestion:p}}},modelReaderPrompt:()=>e.bundleText("model-reader-runtime-prompt"),validateShapeInput:o=>{a(e).shapeInputs(o)},...u(e),...n(e),...i(e),...s(e),...c(e),...l(e),...a(e),...f(e),...m,...S(e)}}export{Q as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as E,l as j,m as T,n as _}from"./7OYIBWX3.js";import{h as B}from"./NCWEOJVJ.js";import{L as I,R as M,b as C,e as x,fa as y,o as g}from"./HPIAEQHE.js";import{c as h,e as O}from"./T5TREZCQ.js";import{posix as v}from"node:path";function D(e,a,c={},u={}){let{root:r}=c,f=a.filter(t=>{let o=y(e,t,{...c,purpose:"source",route:"github"});return o.admitted||o.reason==="wrong-type"||o.reason==="too-large"}),n=x(e)?B(e,f.map(t=>t.path),r):void 0,s=new Set(n?.pluginDeclarations?.map(t=>t.path)),i=n??(u.measureAnalysisSize?B(e,f.map(t=>t.path),r):void 0),l=new Map(i?.files.map(t=>[t.path,t])),k=u.measureAnalysisSize?new Map(a.map(t=>[t.path,t.size])):void 0,z=n?{files:n.files.map(t=>({...t,path:h(t.path,r)})),ownerOf:t=>{let o=n.ownerOf(O(t,r));return o?{...o,folder:o.key===null?"":h(o.folder,r)}:null}}:void 0,q=new Set(n?.ignoredPaths),d=E(e,{paths:f.map(t=>h(t.path,r)),scopes:z});return{descriptions:a.flatMap(t=>{if(q.has(t.path))return[];let o=h(t.path,r),P=o===null?{size:t.size}:j(d,o,t.size),m=y(e,{...t,size:P.size},{...c,purpose:"source",route:"github",scopes:z}),F=o===null?99:_(e,o,z),L=o!==null&&!s.has(t.path)&&!T(d,o)&&(C(t.path)||M(e,o,z)||F===0)?"instruction":"code",S={};if(u.measureAnalysisSize){let N=m.admitted||m.reason==="too-large",R=y(e,t,{...c,purpose:"code-scan",route:"github",listing:k}),w=l.get(t.path),U=w&&(m.admitted||["too-large","wrong-type","empty"].includes(m.reason))&&y(e,{path:t.path},{...c,purpose:I(w.role),route:"github"}).admitted;S.countsTowardAnalysisSize=N||R.admitted||R.reason==="too-large"||!!U,S.analysisPool=w?.role==="skill"||w?.role==="reference"?"instruction":L}return[{entry:t,readEntry:{...t,...P},rel:o,score:F,pool:L,...S,admission:m,...d.enabled&&o!==null?{tier:d.tierOf(o)}:{}}]}),priority:d,declarations:s,discovery:i}}var K=Object.freeze({totalLimitBytes:g.codeAgent.importBytes,instructionLimitBytes:g.sourceFetch.instructionBytes}),b=["totalBytes","instructionBytes","fileCount"],p=()=>new Error("Invalid analysis size"),A=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function W(e){if(!e||typeof e!="object"||Array.isArray(e)||Reflect.ownKeys(e).length!==b.length||b.some(r=>!Object.hasOwn(e,r)||!A(Reflect.get(e,r))))throw p();let{totalBytes:a,instructionBytes:c,fileCount:u}=e;if(c>a)throw p();return{totalBytes:a,instructionBytes:c,fileCount:u}}function ot(e){let a=W(e);return a.totalBytes>K.totalLimitBytes?{fits:!1,measure:"total_text"}:a.instructionBytes>K.instructionLimitBytes?{fits:!1,measure:"instruction_text"}:{fits:!0,measure:null}}function st(e,a,c={}){let u=new Map;for(let s of a){if(!A(s.size)||typeof s.path!="string"||!s.path||s.path.includes("\0"))throw p();let i=v.normalize(s.path.replace(/\\/g,"/"));if(i==="."||i===".."||i.startsWith("../")||i.startsWith("/"))throw p();let l=u.get(i);if(l&&l.size!==s.size)throw p();u.set(i,{path:i,size:s.size,ref:i})}let r=[...u.values()],{descriptions:f}=D(e,r,c,{measureAnalysisSize:!0}),n={totalBytes:0,instructionBytes:0,fileCount:0};for(let s of f){if(!s.countsTowardAnalysisSize)continue;let{entry:i}=s;if(n.totalBytes+=i.size,s.analysisPool==="instruction"&&(n.instructionBytes+=i.size),n.fileCount+=1,!b.every(l=>A(n[l])))throw p()}return W(n)}export{D as a,K as b,W as c,ot as d,st as e};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as m}from"./UEWL3GMQ.js";import{c as r,e as c,g as f}from"./EH3QQ3T4.js";import{a as o,b as a}from"./FSLWD2PE.js";import{z as i}from"zod";var u={expectedOutcome:{setting:"CF_FIX_EXPECTED_OUTCOME",enabled:e=>e.CF_FIX_EXPECTED_OUTCOME!=="0",suffix:"-no-outcome",suffixWhen:!1},untrustedContent:{setting:"CF_UNTRUSTED_CONTENT_CHECK",enabled:o,suffix:"-no-untrusted",suffixWhen:!1},betterAsCode:{setting:"CF_FINDING_BETTER_AS_CODE",enabled:a,suffix:"-better-as-code",suffixWhen:!0}};function d(e){let n=Object.entries(u).map(([t,s])=>({key:t,rule:s,enabled:s.enabled(e)}));return{name:`findings${n.map(({rule:t,enabled:s})=>s===t.suffixWhen?t.suffix:"").join("")}`,switches:Object.fromEntries(n.map(({key:t,enabled:s})=>[t,s])),settings:Object.fromEntries(n.map(({rule:t,enabled:s})=>[t.setting,s?"1":"0"]))}}function _(){let e=[{}];for(let{setting:n}of Object.values(u))e=e.flatMap(t=>["0","1"].map(s=>({...t,[n]:s})));return e.map(n=>({...d(n),schema:h(n)}))}function p(e){return i.object({findings:i.array(e.shape.findings.element.extend({fixes:i.array(r.omit({expectedOutcome:!0})).min(1)}))})}var x=r.extend({expectedOutcome:i.string().default("")}),g=i.array(c.extend({fixes:i.array(x).min(1),sourceNotes:m.nullable().optional().catch(null)}));function h(e){let n=d(e),t=f(n.settings);return n.switches.expectedOutcome?t:p(t)}function S(e){return E(e.findings)}function E(e){return g.parse(e)}export{d as a,_ as b,h as c,S as d,E as e};
|