@counterfact-labs/cli 0.2.9 → 0.2.10
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/bundle/client-release.json +1 -1
- package/dist/adapters/relay-plan.js +7 -5
- package/dist/analysis-core/analysis/file-analysis-plan.js +1 -1
- package/dist/analysis-core/analysis/finding-quality/policy.js +1 -1
- package/dist/analysis-core/analysis/folder-analysis-plan.js +1 -1
- package/dist/analysis-core/analysis/passes/full-file-passes.js +1 -1
- package/dist/analysis-core/analysis/project-architecture.js +1 -1
- package/dist/analysis-core/analysis/schemas.js +1 -1
- package/dist/analysis-core/chunks/{33IGHOYT.js → 2CWULBP2.js} +1 -1
- package/dist/analysis-core/chunks/{2AASSZRO.js → 2M55DR2J.js} +1 -1
- package/dist/analysis-core/chunks/33EUZF25.js +1 -0
- package/dist/analysis-core/chunks/34NVU26H.js +1 -0
- package/dist/analysis-core/chunks/{S27Y2TP5.js → 5BTATES5.js} +1 -1
- package/dist/analysis-core/chunks/{LOBIDUCA.js → 5UWDUYHF.js} +1 -1
- package/dist/analysis-core/chunks/{5B5UCWD3.js → 5VQ4VYIP.js} +1 -1
- package/dist/analysis-core/chunks/{4UDQBDDE.js → 66JRJPJC.js} +1 -1
- package/dist/analysis-core/chunks/{4RXRAB5S.js → 6JTHFDH3.js} +1 -1
- package/dist/analysis-core/chunks/{CTLHKFPH.js → 6VHZNBII.js} +1 -1
- package/dist/analysis-core/chunks/{CQQ4TTXE.js → C77LGCKF.js} +1 -1
- package/dist/analysis-core/chunks/CNQZLSAP.js +1 -0
- package/dist/analysis-core/chunks/{33HRXJ5Q.js → DHVEGIU6.js} +1 -1
- package/dist/analysis-core/chunks/I4F56VMG.js +1 -0
- package/dist/analysis-core/chunks/JAPVLU4Z.js +1 -0
- package/dist/analysis-core/chunks/{HHFDNY6V.js → KBTM5MBC.js} +1 -1
- package/dist/analysis-core/chunks/{FRXOQ2M6.js → LFJQ4YLP.js} +1 -1
- package/dist/analysis-core/chunks/{MZOKZ3N6.js → N2L4JMJE.js} +1 -1
- package/dist/analysis-core/chunks/{F54DOWKN.js → NCW5LJ5O.js} +1 -1
- package/dist/analysis-core/chunks/{4PT5C4IT.js → P253B344.js} +1 -1
- package/dist/analysis-core/chunks/{W24SFYZM.js → QPIBHTON.js} +1 -1
- package/dist/analysis-core/chunks/{RQTNTIR4.js → TA2NIQAY.js} +1 -1
- package/dist/analysis-core/chunks/{JGK37AWN.js → UKX3A6AX.js} +1 -1
- package/dist/analysis-core/chunks/{YTHF2E2S.js → VC3PYT2B.js} +1 -1
- package/dist/analysis-core/chunks/{JEWBPIQI.js → VWRFSVLI.js} +1 -1
- package/dist/analysis-core/chunks/VX6LYNXV.js +1 -0
- package/dist/analysis-core/chunks/{2YREYGOG.js → W73WF226.js} +1 -1
- package/dist/analysis-core/chunks/{HVQJKPQ4.js → XVGLY4EO.js} +1 -1
- package/dist/analysis-core/contracts/execution-request.js +1 -1
- package/dist/analysis-core/contracts/intake-finding.js +1 -1
- package/dist/analysis-core/contracts/relay-analysis.js +1 -1
- package/dist/analysis-core/contracts/requests.js +1 -1
- package/dist/analysis-core/conventions/analysis-fit.js +1 -1
- package/dist/analysis-core/conventions/file-admission.js +1 -1
- package/dist/analysis-core/import/entry-selection.js +1 -1
- package/dist/analysis-core/import/outside-loader-sources.js +1 -1
- package/dist/analysis-core/index.js +1 -1
- package/dist/analysis-core/requests/answer-formats.js +1 -1
- package/dist/analysis-core/requests/local-plan.js +1 -1
- package/dist/analysis-core/requests/registry.js +1 -1
- package/dist/analysis-core/requests/template-version.js +1 -1
- package/dist/analysis-core/requests/tools.js +1 -1
- package/dist/analysis-core/settings.js +1 -1
- package/dist/analysis-core/stages/engine-entry.js +1 -1
- package/dist/cli/commands/analyze.js +3 -6
- package/dist/cli/intake-payload.js +1 -2
- package/dist/cli/relay-check.js +3 -7
- package/dist/cli/relay-preparation.js +3 -3
- package/dist/contract/cli-version.js +1 -1
- package/dist/gatekeeper/console.js +2 -13
- package/package.json +1 -1
- package/dist/adapters/source-relay-plan.js +0 -7
- package/dist/analysis-core/chunks/LFYTD7JF.js +0 -1
- package/dist/analysis-core/chunks/LMUXOKIM.js +0 -1
- package/dist/analysis-core/chunks/MGVIKA74.js +0 -1
- package/dist/analysis-core/chunks/NXHVBJL4.js +0 -1
- package/dist/analysis-core/chunks/OKBK3JL3.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,c as l,d as s,e as m,g as i}from"./33EUZF25.js";import{c as u,d as p}from"./VDUFPTDD.js";function n(a,d={}){return JSON.stringify({bundleDescription:a,inputs:d})}import{z as e}from"zod";import{z as t}from"zod";var r=t.object({motivation:t.array(t.object({kind:t.string(),reason:t.string(),evidence:t.string()})),outcomes:t.array(t.object({improvement:t.string(),measurement:t.string()}))}),O=r.extend({motivation:r.shape.motivation.default([]),outcomes:r.shape.outcomes.default([])});var h=e.object({path:e.string().min(1),line:e.number().int().positive().nullable()}),f=e.object({label:e.string(),source:e.literal("mcp").optional(),brand:e.string().nullable().default(()=>null)}),x=["system prompt","soul","knowledge","skill","config","tools","mcp","template","reference","code"],y=e.object({filledAtRunTime:e.boolean().optional(),role:e.enum(x),label:e.string().nullable().default(()=>null),path:e.string().min(1),span:e.object({from:e.number().int(),to:e.number().int()}).optional()}),S=e.object({id:e.string().min(1),label:e.string().min(1),kind:e.enum(["entry","agent","tool","store","exit"]),desc:e.string(),meta:e.string().nullable(),sourceRef:h.nullable(),sourcePaths:e.array(e.string()).optional(),files:e.array(y).default(()=>[]),tools:e.array(f).default(()=>[])}),j=e.object({from:e.string().min(1),to:e.string().min(1),kind:e.enum(["invokes","delegates","reads","writes","emits"]),label:e.string().nullable(),sourceRef:h.nullable()}),_=e.object({nodes:e.array(S),edges:e.array(j),warnings:e.array(e.string())}),v=e.object({...r.shape,title:e.string().min(1).describe(n("analysis-wire-schemas-1")),approach:e.string().min(1).describe(n("analysis-wire-schemas-2")),kind:e.enum(["code","prompt"]),targetFiles:e.array(e.object({path:e.string().min(1),create:e.boolean().nullable()})),...i.shape});function o(a){return e.string().describe(n("analysis-wire-schemas-3",{v0:Object.values(a.enum).join(", ")}))}var w=e.object({nodes:e.array(e.object({id:e.string().min(1),change:o(s),label:e.string().nullable()})),edges:e.array(e.object({from:e.string().min(1),to:e.string().min(1),kind:o(m),change:o(s),detail:e.string().nullable()}))}),k=v.omit({motivation:!0,outcomes:!0}).extend({expectedOutcome:e.string().describe(n("analysis-wire-schemas-4")),summary:i.shape.summary.catch(null),impact:i.shape.impact.catch(null),objective:i.shape.objective.catch(null),blockedBy:i.shape.blockedBy.catch(null),confidence:o(l).nullable().catch(null),status:o(c).nullable().catch(null),alsoFixes:e.array(e.string()).nullable().default([]).catch(()=>[]),delta:w.nullable().catch(null)}),q=e.object({path:e.string().min(1),line:e.number().int().positive(),excerpt:e.string().trim().min(1)}),F=e.object({path:e.string(),line:e.number(),excerpt:e.string()}),b=a=>e.string().describe(n("analysis-wire-schemas-5",{v0:u(a).join(", ")})).nullable().catch(null),g=e.object({kind:e.enum(["ordering","reliability","coverage","cost","safety","correctness"]),severity:e.enum(["low","medium","high","critical"]),title:e.string().min(1).describe(n("analysis-wire-schemas-6")),cause:e.string().min(1),summary:e.string().describe(n("analysis-wire-schemas-7")).catch(""),site:e.object({path:e.string().min(1),line:e.number().int().positive().nullable()}).nullable(),excerpt:e.string().nullable(),category:b({}),otherSites:e.array(F).nullable().default([]).catch(()=>[]),question:e.string().describe(n("analysis-wire-schemas-8")).catch(""),fixes:e.array(k).min(1)}),E=e.object({findings:e.array(g)});function A(a){return p(a)?E:e.object({findings:e.array(g.extend({category:b(a)}))})}export{n as a,y as b,S as c,j as d,_ as e,k as f,q as g,g as h,E as i,A as j};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./Y7JGSUOA.js";import{d as J}from"./3MTXB4MK.js";import{j as U}from"./
|
|
1
|
+
import{a as M}from"./Y7JGSUOA.js";import{d as J}from"./3MTXB4MK.js";import{j as U}from"./6JTHFDH3.js";import{a as K}from"./HTLIRVP7.js";import{a as G}from"./QDYMR6KS.js";import{b as T}from"./E7TFIHC5.js";import{f as x}from"./VC3PYT2B.js";import{b as P}from"./6YCABS5T.js";import{a as N,b as v,c as D,d as $}from"./VWRFSVLI.js";import{a as E,b as R}from"./MJGB25S5.js";import{d as A}from"./TA2NIQAY.js";import{a as L}from"./74FPPPIG.js";import{a as w}from"./INVTU73D.js";import{c as I}from"./VDUFPTDD.js";import{z as b}from"zod";function _(t,e){if(Buffer.byteLength(t)<=e)return t;let r=0,i=Math.min(t.length,e);for(;r<i;){let a=Math.ceil((r+i)/2);Buffer.byteLength(t.slice(0,a))<=e?r=a:i=a-1}return i>0&&/[\uD800-\uDBFF]/.test(t[i-1])&&i--,t.slice(0,i)}function H(t){let{bundleText:e}=t,r=s=>Buffer.byteLength(JSON.stringify(s));function i(s){let n=[];for(let o of s){if(r([...n,""])>4e3)break;let p=0,l=Buffer.byteLength(o);for(;p<l;){let d=Math.ceil((p+l)/2);r([...n,_(o,d)])<=4e3?p=d:l=d-1}n.push(_(o,p))}return n}function a(s,n=!1){return s.map(o=>typeof o!="string"&&o.kind==="no-core"&&n?e("analysis-check-input-1"):K([o])[0])}function m(s){let n=s.citedFiles===void 0?"":',"citedFiles":'+JSON.stringify(s.citedFiles),o=a(s.diagnostics,!0),p=s.citedFiles===void 0?o:i(o),l=[{text:'{"coreFiles":'+JSON.stringify(s.coreFiles)},{text:n+',"findings":'+JSON.stringify(s.findings)+',"diagnostics":'+JSON.stringify(p)+"}"}];return R(l,E({},{template:"check-findings"}).breakpoints)}function c(s){return Buffer.byteLength(m(s).map(n=>n.text).join(""))}return{checkDiagnosticsText:a,checkPromptBlocks:m,checkPayloadBytes:c}}function O(t,e={}){return t.length?t.map(r=>{let i=e.includeFiles===!1?"":`; files ${r.files.join(", ")||"none"}`;return`${r.ref} "${r.title}" (${r.subKind}): frozen ${r.frozen.join(", ")||"none"}; declined ${r.declined.join(", ")||"none"}${i}`}).join(`
|
|
2
2
|
`):"none"}function F(t){let{bundleText:e}=t,r=e("analysis-scope-check-1"),i=e("analysis-split-check-scope-rule-1"),a=[e("analysis-derive-structures-1"),e("analysis-derive-structures-2"),e("analysis-derive-structures-3"),e("analysis-derive-structures-4"),e("analysis-derive-structures-5"),e("analysis-derive-structures-6"),e("analysis-derive-structures-7"),e("analysis-derive-structures-8")].join(`
|
|
3
3
|
`),m=e("analysis-derive-structures-10");function c(n){return n.map(o=>({unit:JSON.stringify(o.unitKey),kind:o.kind,name:JSON.stringify(o.name),location:JSON.stringify(`${o.sourcePath}:${o.sourceLine}${o.sourceEndLine?`\u2013${o.sourceEndLine}`:""}`)}))}function s(n){return e("code-finding-note",{codeSources:c(n)})}return{RULE:r,SPLIT_SCOPE_RULE:i,SUB_KIND_DEFS:a,STRUCTURE_SCOPE_RULE:m,codeSourceLabels:c,codeFindingNote:s}}import{posix as W}from"node:path";function V(t){let{bundleText:e}=t,r=.25,i=4;function a(c){let s=new Set(c.map(l=>l.name)),n=new Map(c.map(l=>[l.name,new Set(l.skills.filter(d=>d!==l.name&&s.has(d)))])),o=new Map;for(let l of n.values())for(let d of l)o.set(d,(o.get(d)??0)+1);let p=Math.max(i,(c.length-1)*r);return c.map(l=>({name:l.name,linkedFrom:o.get(l.name)??0,linksTo:n.get(l.name).size})).filter(l=>l.linkedFrom>=p||l.linksTo>=p)}function m(c){let s=a(c);if(!s.length)return null;let n=s.map(o=>e("shape-shared-skill",o));return e("analysis-split-check-shared-skills-1",{v0:n.join(`
|
|
4
4
|
`)})}return{sharedSkillsOf:a,sharedSkillsText:m}}function Q(t){let{bundleText:e}=t,{shapeFindingsText:r}=J(t),{sharedSkillsText:i}=V(t);function a(c){let s=new Map(c.map((n,o)=>[n.name,`s${o+1}`]));return e("shape-skills",{skills:c.map(n=>({...n,id:s.get(n.name),refs:n.references.map(o=>W.relative(W.dirname(n.path),o)).join(","),tools:n.tools.join(","),links:n.skills.map(o=>s.get(o)).join(","),hasRefs:n.references.length>0,hasTools:n.tools.length>0,hasLinks:n.skills.length>0,hasDetails:n.references.length>0||n.tools.length>0||n.skills.length>0}))})}function m(c){return e("shape-inventory",{agent:c.agent,v0:a(c.skills),shared:i(c.skills),tools:c.tools.map(s=>({...s,skills:s.skills.join(", ")})),subAgents:c.subAgents.map(s=>({...s,tools:s.tools.join(", "),skills:a(s.skills)})),prompts:c.prompts,knowledge:c.knowledge.map(s=>({...s,headings:s.sections.map(n=>`${n.startLine}-${n.endLine} ${n.heading}`).join(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as _,b as de,k as mt}from"./SP6XFHNH.js";import{b as ae}from"./HCPO6QPU.js";import{a as Be,g as Ne}from"./YTHF2E2S.js";import{C as ht,a as Pe,c as it,d as at,l as lt,m as ct,n as Oe,o as ft,u as pt,v as dt,w as ut,z as ge}from"./4PT5C4IT.js";import{Fb as B,K as Ye,W as We,Y as qe,ea as He,f as ze,fa as ve,g as je,ga as me,h as oe,ha as be,i as ke,ia as Ze,ja as Qe,l as ce,m as $e,n as Je,ob as rt,pa as et,qa as tt,ra as ot,t as fe,u as Ke,wa as nt,x as Ge,y as Ve}from"./2AASSZRO.js";import{a as C}from"./MKYLK6DB.js";import{e as st}from"./YUY436SM.js";import{a as De,c as G}from"./C6X5GDG4.js";import{a as le,b as H,c as Z,k as Te,p as _e}from"./YWL52FVW.js";import{a as X,c as pe}from"./SJESFYBA.js";import{e as Xe}from"./RUVMFAST.js";import{a as Ue}from"./S27VIQMZ.js";function Me(t){let e;try{e=JSON.parse(t)}catch{return{config:null,invalid:!0}}if(typeof e!="object"||e===null||Array.isArray(e))return{config:null,invalid:!0};let o=e,n={};for(let r of["name","model","description","prompt"]){let i=ye(o[r]);i&&(n[r]=i)}if(Array.isArray(o.agents)){let r=o.agents.flatMap(i=>{let c=Dt(i);return c?[c]:[]});r.length>0?n.agents=r:n.invalidAgents=!0}return{config:n,invalid:!1}}function gt(t){let{config:e}=Me(t);return e?Ee(e):"bare"}function Ee(t){return t.agents?.length?"agents":t.prompt?"prompt":"bare"}function yt(t){let e=Ee(t);return e==="agents"?t.agents:e==="prompt"?[{name:t.name,model:t.model,prompt:t.prompt}]:[]}function wt(t,e,o){return St(t,e,o).paths}function St(t,e,o,n={}){let r=yt(e).map(l=>l.prompt),i=[],c=[];for(let l of r){let f=Fe(l).path,y=Ie(o,f);if(y===null){c.push({path:f,reason:"out-of-scope"});continue}let k=B(t,{path:y},{purpose:"pointer",route:"github",...n});k.admitted?i.push(y):c.push({path:y,reason:k.reason})}return{paths:i,refused:c}}function _t(t,e,o){let n=Ie(o.markerDir,Fe(e).path),r=n!==null?B(t,{path:n},{purpose:"pointer",route:"github"}):null;if(r&&!r.admitted&&r.reason==="secret")return{kind:"secret",path:n};let i=$t(e,o,tt(t));return i?{kind:"resolved",prompt:i}:{kind:"missed"}}function lo(t,e,o){let n=[],r=[];e.invalidAgents&&r.push(`${o.repoKey}: counterfact.json "agents" has no entry with a prompt pointer; ignored`);let i=Ee(e);for(let c of yt(e)){let l=_t(t,c.prompt,o);if(l.kind==="secret"){r.push(st(l.path));continue}if(l.kind==="missed"){r.push(`${o.repoKey}: counterfact.json points at ${c.prompt}, which was not found; ignored`);continue}n.push({name:c.name??null,model:c.model??null,description:i==="prompt"?e.description??null:null,prompt:l.prompt})}return{agents:n,warnings:r,refused:St(t,e,o.markerDir).refused}}function ye(t){return typeof t=="string"&&t.trim()?t.trim():void 0}function Dt(t){if(typeof t!="object"||t===null)return null;let e=t,o=ye(e.prompt);if(!o)return null;let n={prompt:o},r=ye(e.name),i=ye(e.model);return r&&(n.name=r),i&&(n.model=i),n}function Fe(t){let e=t.replace(/\\/g,"/"),o=e.indexOf("#");if(o>=0)return{path:e.slice(0,o),symbol:e.slice(o+1),line:null};let n=/^(.*):(\d+)$/.exec(e);return n?{path:n[1],symbol:null,line:Number(n[2])}:{path:e,symbol:null,line:null}}function Ie(t,e){let o=[];for(let n of[...t.split("/"),...e.split("/")])if(n===".."){if(o.pop()===void 0)return null}else n!=="."&&n!==""&&o.push(n);return o.join("/")}function $t(t,e,o){let{path:n,symbol:r,line:i}=Fe(t),c=Ie(e.markerDir,n);if(c===null||!Object.hasOwn(e.files,c))return null;let l=e.files[c];if(l===void 0)return null;if(r===null&&i===null)return X(c)?null:We(c,l);let{sites:f}=et(c,l,{minChars:1,promptFunctions:o});return r!==null?f.find(y=>y.symbol===r)??null:Jt(f,i)}function Jt(t,e){let o=r=>Math.min(r.line,r.span.from),n=t.filter(r=>o(r)<=e&&e<=r.span.to);return n.sort((r,i)=>r.span.to-o(r)-(i.span.to-o(i))),n[0]??null}function Kt(t){return oe(t,"CF_IMPORT_SCOPED_SCAN")}function kt(t,e,o,n="bare"){let r=e.filter(y=>Je(t,y,o)),i=Kt(t);if(!i&&!r.length)return;if(!i&&(n==="agents"||n==="prompt"))return[];let c=i?lt(t,e,o).filter(y=>!y.convention&&(!y.markerPath||y.scope.key===null&&n!=="agents"&&n!=="prompt")).flatMap(y=>y.paths):vt(t,e,o,n)?e:[];if(!c.length&&!r.length)return c;let l=De(o),f=new Set([...c,...r]);for(let y of e){let k=G(y,l);k!==null&&!k.includes("/")&&qe(y)&&f.add(y)}return[...f]}function ne(t,{paths:e,root:o,scanFlag:n,marker:r}){let i={scan:!1,markerToRead:null};if(!n)return i;let c=Pe(t,e,o);if(c.configPath&&r===null)return{scan:!1,markerToRead:c.configPath};let l=kt(t,e,o,r);return l?{scan:l.length>0,markerToRead:null,scanPaths:l}:{scan:vt(t,e,o,r),markerToRead:null}}function vt(t,e,o,n){let r=Pe(t,e,o);return je({usage:"scan",codeAgentsFound:!1,otherDefinitions:it(r)},t)!=="prompt"&&!at(t,r)&&n!=="agents"&&n!=="prompt"}function So(t,e){if(e.phase==="read"){let c=gt(e.text??"");if(e.pending.scanPaths){let l=Me(e.text??"").config,f=e.pending.markerPath.split("/").slice(0,-1).join("/"),y=new Set(l?wt(t,l,f):[]),k=c==="bare"?e.pending.scanPaths:(e.pending.scanPathsIfExplicit??[]).filter(E=>!y.has(E));return{kind:"settled",markerPath:e.pending.markerPath,markerKind:c,scan:k.length>0,scanPaths:k}}return{kind:"settled",markerPath:e.pending.markerPath,markerKind:c,scan:e.pending.scanIfBare&&c==="bare"}}let{paths:o,root:n,scanFlag:r}=e,i=ne(t,{paths:o,root:n,scanFlag:r,marker:null});if(!r)return{kind:"off"};if(i.markerToRead){let c=ne(t,{paths:o,root:n,scanFlag:r,marker:"bare"});return{kind:"marker",markerPath:i.markerToRead,scanIfBare:c.scan,...c.scanPaths?{scanPaths:c.scanPaths,scanPathsIfExplicit:kt(t,o,n,"agents")}:{}}}return{kind:"settled",markerPath:null,markerKind:null,scan:i.scan,...i.scanPaths?{scanPaths:i.scanPaths}:{}}}var bt=(t,e)=>{let{markerToRead:o}=ne(e.settings,{paths:t.map(({path:n})=>n),root:e.dir??void 0,scanFlag:e.flags.scan,marker:null});return o?{strength:"partial",wants:[o]}:null};function Pt(t,e,o="bare"){let{scan:n}=ne(e.settings,{paths:t.map(({path:r})=>r),root:e.dir??void 0,scanFlag:e.flags.scan,marker:o});return n?{strength:"partial",wants:[]}:null}function we(t){return oe(t,"CF_IMPORT_MANIFEST")}function xe(t,e){if(!Ke(t))return null;let o=new Set(e.paths),n=Ge(t,e),r=new Set(e.skillPaths),i=new Set(e.referencePaths),c=a=>Object.hasOwn(e.files,a)?Buffer.byteLength(e.files[a]):e.sizes?.get(a),l=e.selected??[...new Set([...e.skillPaths,...Object.keys(e.files).filter(a=>fe(a,{nested:!0})?.reference)])].filter(a=>Object.hasOwn(e.files,a)).map(a=>({path:a,size:c(a)})),f=[...new Map(l.filter(a=>!i.has(a.path)||r.has(a.path)).map(a=>[a.path,a])).values()],y=new Set(f.map(a=>a.path)),k=f.filter(a=>r.has(a.path)),E=new Set(f.filter(a=>fe(a.path,{nested:!0})?.reference).map(a=>a.path)),S=k.length,x=C.conventionImport.skillBytes-f.filter(a=>r.has(a.path)||E.has(a.path)).reduce((a,m)=>a+(c(m.path)??m.size),0),A=ce(t)?C.codeAgent.importBytes-f.reduce((a,m)=>a+(c(m.path)??m.size),0):1/0,I=new Map(k.map(a=>[a.path,null])),R=(a,m=!1)=>{if(I.has(a))return;let h=c(a),M=E.has(a),u=B(t,{path:a,size:h,text:e.files[a]},{...e.admission,purpose:"skill",route:"github",root:e.root,listing:o,managedFiles:e.files}),P=y.has(a)?0:h,F=u.admitted?h===void 0?"missing":!M&&S>=C.conventionImport.skillFiles?"allowance":!M&&(h>x||P>A)?"total":null:u.reason;I.set(a,F),!M&&(m||!F)&&S++,!M&&!F&&(x-=h,A-=P)};for(let a of i)R(a,!0);let s=[...new Set(e.skillPaths)].sort().filter(a=>Object.hasOwn(e.files,a)).map(a=>{let m={ownerPath:a,files:[],cycles:[],unresolved:[],refused:[]},h=new Set([a]);for(let M of n.references.filter(u=>u.ownerPath===a)){if(!h.has(M.fromPath))continue;R(M.path);let u=I.get(M.path);if(u){m.refused.push({path:M.path,reason:u});continue}h.add(M.path);let P=m.files.find(F=>F.path===M.path);P||(P={path:M.path,evidence:[],sharedOwners:[]},m.files.push(P)),P.evidence.push(M)}return m.cycles=n.cycles.filter(M=>M.ownerPath===a&&h.has(M.fromPath)),m.unresolved=n.unresolved.filter(M=>M.ownerPath===a&&h.has(M.fromPath)),m.refused=ae(m.refused),m}),p=new Map;for(let a of s)for(let m of a.files)p.set(m.path,[...p.get(m.path)??[],a.ownerPath]);for(let a of s)for(let m of a.files)m.sharedOwners=p.get(m.path);return s}var Gt=2e3;function Ot(t,e,o,n={}){let r=e.filter(u=>G(u.path,o)!=null),i={},c=[],l=new Map,f=n.mode!=="core"&&Ye(t),y=Oe(t,r.map(u=>u.path),o,{mode:f?"all":"core",files:n.files}),k=new Set([...y.ignoredPaths,...y.ignoredImportPaths]),E=new Map(y.files.filter(u=>u.role!=="reference").map(u=>[u.path,u])),S=new Map(y.scopes.map(u=>[u.key,C.conventionImport.totalBytes])),x=C.conventionImport.skillBytes,A=ce(t)?C.codeAgent.importBytes:1/0,I=0,R=u=>G(u.path,y.ownerOf(u.path).folder)??u.path,s=(u,P)=>{l.set(u.path,{path:u.path,reason:P})},p=(u,P)=>{let F=B(t,u,{purpose:P,route:"github",root:o});return F.admitted?!0:(s(u,F.reason),!1)},a=u=>{if(i[u.path])return;let P=f&&E.get(u.path)?.role==="skill"?"skill":"core",F=y.ownerOf(u.path),N=P==="skill"?x:S.get(F.key),j=u.size??0;if(P==="skill"&&I>=C.conventionImport.skillFiles){s(u,"allowance");return}if(j>N||j>A){s(u,"total");return}i[u.path]=u.ref,c.push(u.path),A-=j,P==="skill"?(x-=j,I++):S.set(F.key,N-j)},m=r.filter(u=>E.has(u.path));for(let u of m)p(u,rt(E.get(u.path).role))&&a(u);let h=0;if(we(t))for(let u of me(new Set(r.map(P=>P.path)))){let P=r.find(F=>F.path===u);if(h>=C.conventionImport.extractionFiles){s(P,"allowance");continue}if(p(P,"source")&&p(P,"definition")){let F=c.length;a(P),c.length>F&&h++}}let M=y.needsExtraction;if(M){let u=r.flatMap(F=>{if(k.has(F.path)||i[F.path]||f&&fe(R(F)))return[];if(!p(F,"extraction"))return[];let N=Ve(R(F));return N===null?[]:[{entry:F,rank:N}]}).sort((F,N)=>F.rank-N.rank||(F.entry.size??0)-(N.entry.size??0)),P=h;for(let{entry:F}of u){if(P>=C.conventionImport.extractionFiles){s(F,"allowance");continue}let N=c.length;a(F),c.length>N&&P++}}if(f&&n.files){let u=Vt(t,{entries:e,selected:r.filter(P=>Object.hasOwn(i,P.path)),files:n.files,root:o});for(let P of u.paths)Object.hasOwn(i,P)||(c.push(P),i[P]=r.find(F=>F.path===P).ref);for(let P of u.refused)l.set(P.path,P)}return{...ce(t)&&m.some(u=>!Object.hasOwn(i,u.path))?{definitionsOmitted:!0}:{},selectedPaths:c,shaByPath:i,treeListing:r.slice(0,Gt).map(u=>u.path),needsExtraction:M,refused:[...l.values()]}}function Vt(t,e){let o=new Set(e.selected.map(i=>i.path)),n=Oe(t,e.entries.map(i=>i.path),e.root,{files:e.files}).files.filter(i=>i.role==="skill"&&o.has(i.path)).map(i=>i.path),r=xe(t,{skillPaths:n,paths:e.entries.map(i=>i.path),files:e.files,sizes:new Map(e.entries.map(i=>[i.path,i.size])),selected:e.selected,root:e.root,admission:e.admission,referencePaths:e.referencePaths});return{paths:[...new Set(r?.flatMap(i=>i.files.map(c=>c.path))??[])],refused:r?.flatMap(i=>i.refused)??[]}}var Mt=(t,e)=>{let o=Ot(e.settings,t,e.dir??void 0,{mode:e.mode});return{strength:"partial",wants:o.selectedPaths,state:{needsExtraction:o.needsExtraction,treeListing:o.treeListing,shaByPath:o.shaByPath,refused:o.refused,...o.definitionsOmitted?{definitionsOmitted:!0}:{}}}};var Et=["marker","code-scan","conventions"];var Yt={marker:bt,"code-scan":Pt,conventions:Mt};function Ae(t,e,o,n,r=Yt){let i={...o,settings:t},c={readers:[]};for(let l of Et)if(!(n&&!n.includes(l)))try{let f=r[l]?.(e,i);f&&c.readers.push({id:l,claim:f,done:!1})}catch{}return c}function Xo(t){return{readers:t.readers.map(({id:e,done:o})=>({id:e,done:o}))}}function Ft(t){let e=t.readers.find(({id:o})=>o==="conventions").claim;return{selectedPaths:e.wants,...e.state}}var Wt={files:200,bytes:C.codeAgent.importBytes,depth:32,edges:_.edges,entries:pe.inventoryEntries};function It(t={}){return Object.fromEntries(Object.entries(Wt).map(([e,o])=>{let n=t[e]??o;return[e,Number.isFinite(n)?Math.max(0,Math.min(o,Math.floor(n))):0]}))}function xt(t,e,o,n){let r=new Set(o.map(s=>G(s.path,n))),i=t.CF_READING_NOTE_AGENT_ONLY!=="0"&&ft(t),c=new Set(e.agents),l=s=>!r.has(s)&&(!i||c.has(s)),f=e.instruction.filter(l),y=e.code.filter(l),k=e.agents.filter(s=>!r.has(s)),E=new Set(dt(k)),S=[...f,...y].every(s=>E.has(s)),x=f.length,A=y.length,I=[!S&&x>0&&`${x} instruction file${x===1?"":"s"} left out by the ${Math.round(C.sourceFetch.instructionBytes/1e3)}KB instruction budget`,!S&&A>0&&`${A} analyzable file${A===1?"":"s"} left out by the ${Math.round(C.sourceFetch.codeBytes/1e3)}KB/${C.sourceFetch.codeFiles}-file code budget \u2014 the analysis reads the most agent-shaped files first`,ut(k,i)].filter(Boolean),R=o.filter(s=>s.readBytes!==void 0).map(s=>G(s.path,n));return R.length&&I.push(`${R.join(", ")}: only the first ${C.sourceFetch.codeFileBytes/1e3} KB was read`),I.length?I.map((s,p)=>p<I.length-1?String(s).replace(/\.$/,""):s).join("; "):void 0}function At(t,e,o,n={}){let{descriptions:r,priority:i,declarations:c}=ht(t,e,{root:o},n),l=[],f=r.flatMap(a=>a.admission.admitted?[{entry:a.readEntry,rel:a.rel,score:a.score,size:a.readEntry.size,pool:a.pool,...a.tier===void 0?{}:{tier:a.tier}}]:(l.push({path:a.entry.path,reason:a.admission.reason}),[])),y=f.filter(({score:a})=>a===0).sort(ge),k=f.filter(({score:a})=>a>0).sort(ge),E=[],S={instruction:0,code:0},x={instruction:[],code:[]},A=0,I=(i.enabled?[...f].sort(ge):[...y,...k]).sort((a,m)=>Number(c.has(m.entry.path))-Number(c.has(a.entry.path)));for(let{entry:a,rel:m,pool:h}of I){let M=h==="instruction"?C.sourceFetch.instructionBytes:C.sourceFetch.codeBytes;if(S[h]+a.size>M||h==="code"&&A>=C.sourceFetch.codeFiles){x[h].push(m),l.push({path:a.path,reason:S[h]+a.size>M?"total":"allowance"});continue}E.push(a),S[h]+=a.size,h==="code"&&(A+=1)}let R=pt(i,l.flatMap(a=>{let m=G(a.path,o);return m===null?[]:[{...a,path:m}]})),s={...x,agents:R},p=xt(t,s,E,o);return{selected:E,totalBytes:S.instruction+S.code,refused:l,...p?{skippedNote:p}:{},...i.enabled&&p?{readingNotes:s}:{}}}function Re(t){let e=t.CF_CODE_AGENTS!=="0";return{scan:e,model:e&&t.CF_CODE_AGENTS_MODEL!=="0"}}function Rt(t,e){if(e.profile==="entry-analysis"){let l=It(e.limits),f=e.listing.find(k=>k.path===e.selection.entry),y=[...f?[f]:[],...e.listing.filter(k=>k.path!==e.selection.entry)].slice(0,l.entries);return{profile:e.profile,request:e.selection,entries:y,limits:l,inventoryIncomplete:e.listing.length-y.length}}let o=$e(t),n=o.length?{scopeSelections:o}:{},r={dir:e.root??null,mode:e.profile==="hosted-import"?e.mode??"all":"all",flags:e.profile==="hosted-import"?e.flags??Re(t):Re(t)};if(e.profile==="hosted-import"){let l=Ae(t,e.listing,r);return{profile:e.profile,...l,...n,selection:Ft(l),...ke(t)?{mode:r.mode}:{}}}let i=e.listing.filter(l=>B(t,l,{purpose:"pointer",route:"github",root:e.root}).admitted),c=Ae(t,i,r,["marker","code-scan"]);return{profile:e.profile,...c,...n,listing:i,selection:e.selection??At(t,e.listing,e.root),context:r,...e.selection&&ke(t)?{selectionPaths:e.selection.selected.map(l=>l.path)}:{}}}import{createHash as qt}from"node:crypto";var Q=t=>qt("sha256").update(t).digest("hex");function Cn(t,e){let o=s=>({kind:"refused",reason:s,pending:[]}),n=t.entries,r=new Map;for(let s of e)for(let p of s.files){let a=r.get(p.path);if(a&&(a.hash!==p.hash||a.size!==p.size))return o("stale-snapshot");r.set(p.path,{...p,role:n.includes(p.path)?"entry":"imported-helper"})}let i=[...r.values()],c=Q(JSON.stringify([n,e.map(s=>s.snapshot)])),l=[],f=new Set,y=(s,p,a=!1)=>{p=[...new Set(p)];let m=JSON.stringify([...p].sort());f.has(m)||p.length===i.length&&n.every(h=>r.has(h))||p.filter(h=>n.includes(h)).length>de||p.length>_.scopeImports+1||l.length>=_.choices||(f.add(m),l.push({id:Q(m),scope:{snapshot:c,entry:s,entries:n,imports:p.length===1?"none":p.filter(h=>h!==s)},includes:p,omitted:i.filter(h=>!p.includes(h.path)).map(h=>h.path),...a&&p.length>1?{coverage:"entry-imports"}:{}}))};for(let s=0;s<e.length;s+=de){let p=e.slice(s,s+de);y(p[0].kind==="file"?p[0].entry:n[s],p.flatMap(a=>a.files.map(m=>m.path)),!0)}for(let s of n.filter(p=>r.has(p)))y(s,[s]);for(let s of e)y(s.kind==="file"?s.entry:n[0],s.files.map(p=>p.path),!0);for(let s of e)for(let p of s.choices)y(p.scope.entry,p.includes);let k=s=>[...new Map(s.map(p=>[JSON.stringify(p),p])).values()],E=k(e.flatMap(s=>s.refusedEdges)),S=k(e.flatMap(s=>s.edges)),x=E.slice(0,_.edges),I=n.length-e.length+E.length-x.length+Math.max(0,S.length-_.edges)+e.reduce((s,p)=>s+p.completeness.frontierCount,0),R={schemaVersion:1,kind:"file",launchRoot:t.launchRoot,entry:t.entry,entries:n,snapshot:c,resolverVersion:e[0].resolverVersion,files:i,entrySets:e.map(s=>({entry:s.kind==="file"?s.entry:n[0],includes:s.files.map(p=>p.path)})),edges:S.slice(0,_.edges),refusedEdges:x,completeness:{complete:I===0&&e.every(s=>s.completeness.complete),frontierCount:I},choices:l};if(t.scope){if(t.scope.snapshot!==c)return o("stale-snapshot");let s=t.scope,p=Xt(R,s);return p?{kind:"ready",pending:[],selection:{...R,entrySets:void 0,...Ct(R,p.includes),choices:[]}}:o("invalid-scope")}return{kind:"ready",pending:[],selection:mt.parse(R)}}function Ut(t,e){if(t.kind!=="file"||!t.entries||!t.entrySets||!e.length)return;let o=e.map(c=>t.entrySets.find(l=>l.entry===c));if(o.some(c=>!c))return;let n=new Set(o.flatMap(c=>c.includes)),r=t.files.filter(c=>n.has(c.path)).map(c=>c.path);if(t.entries.filter(c=>n.has(c)).length>de||r.length>_.scopeImports+1)return;let i=e[0];return{id:Q(JSON.stringify([...r].sort())),scope:{snapshot:t.snapshot,entry:i,entries:t.entries,imports:r.length===1?"none":r.filter(c=>c!==i)},includes:r,omitted:t.files.filter(c=>!n.has(c.path)).map(c=>c.path),...r.length>1?{coverage:"entry-imports"}:{}}}function Xt(t,e){let o=f=>JSON.stringify([f.snapshot,f.entry,f.imports==="none"?[]:Array.isArray(f.imports)?[...f.imports].sort():f.imports,f.entries]),n=t.choices.find(f=>o(f.scope)===o(e));if(n)return n;if(t.kind!=="file"||!t.entries||e.imports==="all")return;let r=new Set([e.entry,...e.imports==="none"?[]:e.imports]),i=t.entrySets?.filter(f=>f.includes.every(y=>r.has(y))).map(f=>f.entry)??[];if(!i.includes(e.entry))return;let c=[e.entry,...i.filter(f=>f!==e.entry)],l=Ut(t,c);return l&&o(l.scope)===o(e)?l:void 0}function Ct(t,e,o=!0){let n=new Set(e),r=new Set(t.files.map(f=>f.path)),i=t.edges.filter(f=>n.has(f.from)&&!n.has(f.path)&&r.has(f.path)).map(f=>({from:f.from,specifier:f.specifier,status:"refused",provenance:f.provenance,reason:"not-selected"})),c=o?[...new Map([...t.refusedEdges.filter(f=>n.has(f.from)),...i].map(f=>[JSON.stringify(f),f])).values()]:[...t.refusedEdges,...i].slice(0,_.edges).filter(f=>n.has(f.from)),l=t.completeness.frontierCount+(o?Math.max(0,c.length-_.edges):0);return{files:t.files.filter(f=>n.has(f.path)),edges:t.edges.filter(f=>n.has(f.from)&&n.has(f.path)),refusedEdges:c.slice(0,_.edges),completeness:{complete:l===0&&c.every(f=>f.reason==="external"),frontierCount:l}}}function Ht(t,e){let o=new Set(e.map(r=>r.path)),n=new Set(e.filter(r=>r.role==="entry").map(r=>r.path));return!t?.files.some(r=>!o.has(r.path)||r.role==="prompt"&&!n.has(r.path))}function Zt(t){return t.unavailable?t.unavailable:t.entry?!Number.isSafeInteger(t.entry.size)||t.entry.size<0?"over-limit":Ue.safeParse(t.path).success?t.depth>t.limits.depth||!t.spentPaths.has(t.path)&&(t.spentPaths.size>=t.limits.files||t.bytes+t.size>t.limits.bytes)?"over-limit":null:"out-of-scope":"missing"}function Lt(t,e){let o=b=>({kind:"refused",reason:b,pending:[]});if(!Be(t))return o("disabled");let{request:n,files:r,resolutions:i,unavailable:c={}}=e,l=Rt(t,{profile:"entry-analysis",listing:[...e.entries],selection:n,limits:e.limits}),{limits:f}=l,y=new Map(l.entries.map(b=>[b.path,b])),k={},E=[],S=[],x=[],A=[],I=new Set,R=new Set,s=[{path:n.entry,depth:0,settings:!1},...(e.settingsFiles??[]).map(b=>({path:b,depth:0,settings:!0}))],p=new Set,a=new Map,m=new Map,h=new Set(e.attempted?.paths),M=new Set(e.settingsAttempted?.paths),u={files:pe.settingsFiles,bytes:pe.settingsBytes,depth:f.depth},P=e.settingsAttempted?.bytes??0,F=e.attempted?.bytes??0,N=0,j=e.inventoryIncomplete??0;j+=l.inventoryIncomplete;let J=(b,v)=>{A.length<_.edges&&A.push({from:b.from,specifier:b.specifier,status:"refused",provenance:b.provenance,reason:v})};for(let b=0;b<s.length;b++){let v=s[b],T=`${v.settings}:${v.path}`;if(p.has(T))continue;p.add(T);let D=y.get(v.path),$=Object.hasOwn(r,v.path)?r[v.path]:void 0,te=$===void 0?D?.size??0:Buffer.byteLength($),ie=v.settings?M:h,z=Zt({...v,entry:D,size:te,unavailable:Object.hasOwn(c,v.path)?c[v.path]:void 0,spentPaths:ie,bytes:v.settings?P:F,limits:v.settings?u:f});if(z){if(v.path===n.entry&&!v.settings)return o(z);if(v.settings&&Object.defineProperty(k,v.path,{value:z,enumerable:!0}),!v.settings){m.set(v.path,z);for(let g of a.get(v.path)??[])J(g,z);z==="over-limit"&&j++}continue}if(ie.has(v.path)||(v.settings?P+=te:F+=te,ie.add(v.path)),$===void 0){S.push(v.path),(v.settings?I:R).add(v.path);continue}if(v.settings)continue;if(E.push(v.path),!Object.hasOwn(i,v.path)){S.push(v.path);continue}let q=i[v.path];for(let g=0;g<q.length;g++){let O=q[g];if(N++>=f.edges){J(O,"over-limit"),j+=q.length-g;break}if(!Xe.safeParse(O).success||O.from!==v.path){J({from:v.path,specifier:"?",status:"refused",provenance:null,reason:"unsupported"},"unsupported");continue}if(O.status==="refused"){J(O,O.reason);continue}x.push(O),a.set(O.path,[...a.get(O.path)??[],O]);let L=m.get(O.path);if(L){J(O,L);continue}s.push({path:O.path,depth:v.depth+1,settings:!1})}}if(S.length)return{kind:"pending",pending:[...new Set(S)],pendingSettings:[...I].filter(b=>!R.has(b)),...Object.keys(k).length?{unavailable:k}:{}};let se=E.map(b=>({path:b,role:b===n.entry?"entry":"imported-helper",hash:Q(r[b]),size:Buffer.byteLength(r[b])})),ee=Q(JSON.stringify({request:{...n,scope:void 0},files:se,inventory:[...y.values()].map(({path:b,size:v,ref:T})=>({path:b,size:v,ref:T})).sort((b,v)=>b.path.localeCompare(v.path)),metadata:(e.settingsFiles??[]).map(b=>[b,Object.hasOwn(r,b)?Q(r[b]):c[b]??"over-limit"]),edges:x,refusedEdges:A,frontierCount:j,limits:f,resolverVersion:e.resolverVersion,resolverIdentity:e.resolverIdentity,targetIdentity:e.targetIdentity,settings:Object.entries(Ne(t)).sort(([b],[v])=>b.localeCompare(v))})),w=n.scope;if(w&&w.snapshot!==ee)return o("stale-snapshot");let d=E.filter(b=>b!==n.entry);if(w&&(w.entry!==n.entry||Array.isArray(w.imports)&&w.imports.some(b=>!d.includes(b))))return o("invalid-scope");let V=new Set(!w||w.imports==="all"?E:[n.entry,...w.imports==="none"?[]:w.imports]),Y=Ct({files:se,edges:x,refusedEdges:A,completeness:{complete:!1,frontierCount:j}},[...V],!1),U=Y.files;if(!Ht(e.proposal,U))return o("invalid-scope");let re=[],ue=(b,v)=>{let T=[n.entry,...v==="none"?[]:v];T.length!==U.length&&re.push({id:b,scope:{snapshot:ee,entry:n.entry,imports:v},includes:T,omitted:U.filter(D=>!T.includes(D.path)).map(D=>D.path)})};ue("entry-only","none");for(let b of U.filter(v=>v.role==="imported-helper").slice(0,_.choices-1))ue(Q(b.path),[b.path]);let he={schemaVersion:1,kind:"file",launchRoot:n.launchRoot,entry:n.entry,snapshot:ee,resolverVersion:e.resolverVersion,...Y,choices:re};return{kind:"ready",pending:[],selection:he}}function Nn({prompt:t,link:e}){return{path:e?.callPath??t.path,...e?{line:e.callLine}:{},symbol:t.symbol,promptPath:t.path,promptStart:t.start,...e?.kind==="L4"?{loadedPrompt:!0,...e.callStart!==void 0?{callStart:e.callStart}:{}}:{}}}function Bt(t,e,o){return nt(t,e,o)}var Se=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).sort().join("-");function Qt(t,e,o,n={}){let r=new Map(t.map(i=>[Se(i),i]));return e.flatMap(i=>{let c=Object.hasOwn(o,i)?o[i]:void 0;if(c===void 0||!B(n,{path:i},{purpose:"code-support",route:"github"}).admitted)return[];let l=le(i,c,X(i)).toks;return l.flatMap((f,y)=>{if(!Z(f))return[];let k=r.get(Se(f.text));if(!k)return[];let E=!1;if(Z(l[y-1],"function")||Z(l[y-1],"def"))E=H(l[y+1],"(");else if(["const","let","var"].some(S=>Z(l[y-1],S))){for(let S=y+1;S<l.length&&S<y+80&&!H(l[S],";");S++)if(H(l[S],"=")){let x=Z(l[S+1],"async")?S+2:S+1,A=H(l[x],"(")?Te(l,x)+1:x+1;E=Z(l[x],"function")||H(l[A],"=")&&H(l[A+1],">");break}}return E?[{name:k,sourcePath:i,sourceLine:f.line}]:[]})})}function Nt(t,e,o,n,r={}){let i=new Set(t.map(Se)),c=k=>B(r,{path:k},{purpose:"code-support",route:"github"}).admitted,l=k=>Qt(t,[k],o,r).length>0,f=e.filter(k=>c(k)&&l(k)),y=n.filter(k=>c(k)&&i.has(Se(k.split("/").at(-1).replace(/\.[^.]+$/,"")))&&(o[k]===void 0||l(k))).sort();return[...new Set([...f,...y])]}var jt="model call";function zt(t,e){let o=Bt(t.ownPaths,e,t.toolCall);return{tools:o.tools.map(n=>({tool:n,from:o.from[n.name]})),toolWarnings:o.warnings}}function Le(t=new Map,e){return{left:Math.max(0,C.codeAgent.importBytes-[...t.values()].reduce((o,n)=>o+n,0)),chosen:new Set([...t.keys()].filter(o=>!e?.has(o))),...e?{replacementBytes:e}:{}}}function eo(t,e){return t.modelId??(!t.documentation&&e.length===1?e[0]:null)}function ns(t,e,o){return to(t,eo(t,e),o)}function to(t,e,o){let{prompt:n,link:r}=t,i=[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 l of t.alsoLoads??[])i.push({role:"system prompt",label:"also loaded",path:l});r&&i.push({role:"code",label:jt,path:r.callPath}),r?.wrapper&&i.push({role:"code",label:"model wrapper",path:r.wrapper.path}),e&&i.push({role:"code",label:"model setting",path:e.path}),t.shape&&i.push({role:"code",label:"answer shape",path:t.shape.path});let c=new Set;return i.filter(l=>!c.has(l.path)&&!!c.add(l.path)).map(l=>ze(o,l.path,l.path===n.path&&t.promptSource==="marker")?l:{...l,role:"reference"})}function ss(t,e){let{prompt:o}=t,n=e[o.path]??"";return o.kind==="file"?n:n.split(`
|
|
1
|
+
import{a as _,b as de,k as mt}from"./SP6XFHNH.js";import{b as ae}from"./HCPO6QPU.js";import{a as Be,g as Ne}from"./VC3PYT2B.js";import{C as ht,a as Pe,c as it,d as at,l as lt,m as ct,n as Oe,o as ft,u as pt,v as dt,w as ut,z as ge}from"./P253B344.js";import{Fb as B,K as Ye,W as We,Y as qe,ea as He,f as ze,fa as ve,g as je,ga as me,h as oe,ha as be,i as ke,ia as Ze,ja as Qe,l as ce,m as $e,n as Je,ob as rt,pa as et,qa as tt,ra as ot,t as fe,u as Ke,wa as nt,x as Ge,y as Ve}from"./2M55DR2J.js";import{a as C}from"./MKYLK6DB.js";import{e as st}from"./YUY436SM.js";import{a as De,c as G}from"./C6X5GDG4.js";import{a as le,b as H,c as Z,k as Te,p as _e}from"./YWL52FVW.js";import{a as X,c as pe}from"./SJESFYBA.js";import{e as Xe}from"./RUVMFAST.js";import{a as Ue}from"./S27VIQMZ.js";function Me(t){let e;try{e=JSON.parse(t)}catch{return{config:null,invalid:!0}}if(typeof e!="object"||e===null||Array.isArray(e))return{config:null,invalid:!0};let o=e,n={};for(let r of["name","model","description","prompt"]){let i=ye(o[r]);i&&(n[r]=i)}if(Array.isArray(o.agents)){let r=o.agents.flatMap(i=>{let c=Dt(i);return c?[c]:[]});r.length>0?n.agents=r:n.invalidAgents=!0}return{config:n,invalid:!1}}function gt(t){let{config:e}=Me(t);return e?Ee(e):"bare"}function Ee(t){return t.agents?.length?"agents":t.prompt?"prompt":"bare"}function yt(t){let e=Ee(t);return e==="agents"?t.agents:e==="prompt"?[{name:t.name,model:t.model,prompt:t.prompt}]:[]}function wt(t,e,o){return St(t,e,o).paths}function St(t,e,o,n={}){let r=yt(e).map(l=>l.prompt),i=[],c=[];for(let l of r){let f=Fe(l).path,y=Ie(o,f);if(y===null){c.push({path:f,reason:"out-of-scope"});continue}let k=B(t,{path:y},{purpose:"pointer",route:"github",...n});k.admitted?i.push(y):c.push({path:y,reason:k.reason})}return{paths:i,refused:c}}function _t(t,e,o){let n=Ie(o.markerDir,Fe(e).path),r=n!==null?B(t,{path:n},{purpose:"pointer",route:"github"}):null;if(r&&!r.admitted&&r.reason==="secret")return{kind:"secret",path:n};let i=$t(e,o,tt(t));return i?{kind:"resolved",prompt:i}:{kind:"missed"}}function lo(t,e,o){let n=[],r=[];e.invalidAgents&&r.push(`${o.repoKey}: counterfact.json "agents" has no entry with a prompt pointer; ignored`);let i=Ee(e);for(let c of yt(e)){let l=_t(t,c.prompt,o);if(l.kind==="secret"){r.push(st(l.path));continue}if(l.kind==="missed"){r.push(`${o.repoKey}: counterfact.json points at ${c.prompt}, which was not found; ignored`);continue}n.push({name:c.name??null,model:c.model??null,description:i==="prompt"?e.description??null:null,prompt:l.prompt})}return{agents:n,warnings:r,refused:St(t,e,o.markerDir).refused}}function ye(t){return typeof t=="string"&&t.trim()?t.trim():void 0}function Dt(t){if(typeof t!="object"||t===null)return null;let e=t,o=ye(e.prompt);if(!o)return null;let n={prompt:o},r=ye(e.name),i=ye(e.model);return r&&(n.name=r),i&&(n.model=i),n}function Fe(t){let e=t.replace(/\\/g,"/"),o=e.indexOf("#");if(o>=0)return{path:e.slice(0,o),symbol:e.slice(o+1),line:null};let n=/^(.*):(\d+)$/.exec(e);return n?{path:n[1],symbol:null,line:Number(n[2])}:{path:e,symbol:null,line:null}}function Ie(t,e){let o=[];for(let n of[...t.split("/"),...e.split("/")])if(n===".."){if(o.pop()===void 0)return null}else n!=="."&&n!==""&&o.push(n);return o.join("/")}function $t(t,e,o){let{path:n,symbol:r,line:i}=Fe(t),c=Ie(e.markerDir,n);if(c===null||!Object.hasOwn(e.files,c))return null;let l=e.files[c];if(l===void 0)return null;if(r===null&&i===null)return X(c)?null:We(c,l);let{sites:f}=et(c,l,{minChars:1,promptFunctions:o});return r!==null?f.find(y=>y.symbol===r)??null:Jt(f,i)}function Jt(t,e){let o=r=>Math.min(r.line,r.span.from),n=t.filter(r=>o(r)<=e&&e<=r.span.to);return n.sort((r,i)=>r.span.to-o(r)-(i.span.to-o(i))),n[0]??null}function Kt(t){return oe(t,"CF_IMPORT_SCOPED_SCAN")}function kt(t,e,o,n="bare"){let r=e.filter(y=>Je(t,y,o)),i=Kt(t);if(!i&&!r.length)return;if(!i&&(n==="agents"||n==="prompt"))return[];let c=i?lt(t,e,o).filter(y=>!y.convention&&(!y.markerPath||y.scope.key===null&&n!=="agents"&&n!=="prompt")).flatMap(y=>y.paths):vt(t,e,o,n)?e:[];if(!c.length&&!r.length)return c;let l=De(o),f=new Set([...c,...r]);for(let y of e){let k=G(y,l);k!==null&&!k.includes("/")&&qe(y)&&f.add(y)}return[...f]}function ne(t,{paths:e,root:o,scanFlag:n,marker:r}){let i={scan:!1,markerToRead:null};if(!n)return i;let c=Pe(t,e,o);if(c.configPath&&r===null)return{scan:!1,markerToRead:c.configPath};let l=kt(t,e,o,r);return l?{scan:l.length>0,markerToRead:null,scanPaths:l}:{scan:vt(t,e,o,r),markerToRead:null}}function vt(t,e,o,n){let r=Pe(t,e,o);return je({usage:"scan",codeAgentsFound:!1,otherDefinitions:it(r)},t)!=="prompt"&&!at(t,r)&&n!=="agents"&&n!=="prompt"}function So(t,e){if(e.phase==="read"){let c=gt(e.text??"");if(e.pending.scanPaths){let l=Me(e.text??"").config,f=e.pending.markerPath.split("/").slice(0,-1).join("/"),y=new Set(l?wt(t,l,f):[]),k=c==="bare"?e.pending.scanPaths:(e.pending.scanPathsIfExplicit??[]).filter(E=>!y.has(E));return{kind:"settled",markerPath:e.pending.markerPath,markerKind:c,scan:k.length>0,scanPaths:k}}return{kind:"settled",markerPath:e.pending.markerPath,markerKind:c,scan:e.pending.scanIfBare&&c==="bare"}}let{paths:o,root:n,scanFlag:r}=e,i=ne(t,{paths:o,root:n,scanFlag:r,marker:null});if(!r)return{kind:"off"};if(i.markerToRead){let c=ne(t,{paths:o,root:n,scanFlag:r,marker:"bare"});return{kind:"marker",markerPath:i.markerToRead,scanIfBare:c.scan,...c.scanPaths?{scanPaths:c.scanPaths,scanPathsIfExplicit:kt(t,o,n,"agents")}:{}}}return{kind:"settled",markerPath:null,markerKind:null,scan:i.scan,...i.scanPaths?{scanPaths:i.scanPaths}:{}}}var bt=(t,e)=>{let{markerToRead:o}=ne(e.settings,{paths:t.map(({path:n})=>n),root:e.dir??void 0,scanFlag:e.flags.scan,marker:null});return o?{strength:"partial",wants:[o]}:null};function Pt(t,e,o="bare"){let{scan:n}=ne(e.settings,{paths:t.map(({path:r})=>r),root:e.dir??void 0,scanFlag:e.flags.scan,marker:o});return n?{strength:"partial",wants:[]}:null}function we(t){return oe(t,"CF_IMPORT_MANIFEST")}function xe(t,e){if(!Ke(t))return null;let o=new Set(e.paths),n=Ge(t,e),r=new Set(e.skillPaths),i=new Set(e.referencePaths),c=a=>Object.hasOwn(e.files,a)?Buffer.byteLength(e.files[a]):e.sizes?.get(a),l=e.selected??[...new Set([...e.skillPaths,...Object.keys(e.files).filter(a=>fe(a,{nested:!0})?.reference)])].filter(a=>Object.hasOwn(e.files,a)).map(a=>({path:a,size:c(a)})),f=[...new Map(l.filter(a=>!i.has(a.path)||r.has(a.path)).map(a=>[a.path,a])).values()],y=new Set(f.map(a=>a.path)),k=f.filter(a=>r.has(a.path)),E=new Set(f.filter(a=>fe(a.path,{nested:!0})?.reference).map(a=>a.path)),S=k.length,x=C.conventionImport.skillBytes-f.filter(a=>r.has(a.path)||E.has(a.path)).reduce((a,m)=>a+(c(m.path)??m.size),0),A=ce(t)?C.codeAgent.importBytes-f.reduce((a,m)=>a+(c(m.path)??m.size),0):1/0,I=new Map(k.map(a=>[a.path,null])),R=(a,m=!1)=>{if(I.has(a))return;let h=c(a),M=E.has(a),u=B(t,{path:a,size:h,text:e.files[a]},{...e.admission,purpose:"skill",route:"github",root:e.root,listing:o,managedFiles:e.files}),P=y.has(a)?0:h,F=u.admitted?h===void 0?"missing":!M&&S>=C.conventionImport.skillFiles?"allowance":!M&&(h>x||P>A)?"total":null:u.reason;I.set(a,F),!M&&(m||!F)&&S++,!M&&!F&&(x-=h,A-=P)};for(let a of i)R(a,!0);let s=[...new Set(e.skillPaths)].sort().filter(a=>Object.hasOwn(e.files,a)).map(a=>{let m={ownerPath:a,files:[],cycles:[],unresolved:[],refused:[]},h=new Set([a]);for(let M of n.references.filter(u=>u.ownerPath===a)){if(!h.has(M.fromPath))continue;R(M.path);let u=I.get(M.path);if(u){m.refused.push({path:M.path,reason:u});continue}h.add(M.path);let P=m.files.find(F=>F.path===M.path);P||(P={path:M.path,evidence:[],sharedOwners:[]},m.files.push(P)),P.evidence.push(M)}return m.cycles=n.cycles.filter(M=>M.ownerPath===a&&h.has(M.fromPath)),m.unresolved=n.unresolved.filter(M=>M.ownerPath===a&&h.has(M.fromPath)),m.refused=ae(m.refused),m}),p=new Map;for(let a of s)for(let m of a.files)p.set(m.path,[...p.get(m.path)??[],a.ownerPath]);for(let a of s)for(let m of a.files)m.sharedOwners=p.get(m.path);return s}var Gt=2e3;function Ot(t,e,o,n={}){let r=e.filter(u=>G(u.path,o)!=null),i={},c=[],l=new Map,f=n.mode!=="core"&&Ye(t),y=Oe(t,r.map(u=>u.path),o,{mode:f?"all":"core",files:n.files}),k=new Set([...y.ignoredPaths,...y.ignoredImportPaths]),E=new Map(y.files.filter(u=>u.role!=="reference").map(u=>[u.path,u])),S=new Map(y.scopes.map(u=>[u.key,C.conventionImport.totalBytes])),x=C.conventionImport.skillBytes,A=ce(t)?C.codeAgent.importBytes:1/0,I=0,R=u=>G(u.path,y.ownerOf(u.path).folder)??u.path,s=(u,P)=>{l.set(u.path,{path:u.path,reason:P})},p=(u,P)=>{let F=B(t,u,{purpose:P,route:"github",root:o});return F.admitted?!0:(s(u,F.reason),!1)},a=u=>{if(i[u.path])return;let P=f&&E.get(u.path)?.role==="skill"?"skill":"core",F=y.ownerOf(u.path),N=P==="skill"?x:S.get(F.key),j=u.size??0;if(P==="skill"&&I>=C.conventionImport.skillFiles){s(u,"allowance");return}if(j>N||j>A){s(u,"total");return}i[u.path]=u.ref,c.push(u.path),A-=j,P==="skill"?(x-=j,I++):S.set(F.key,N-j)},m=r.filter(u=>E.has(u.path));for(let u of m)p(u,rt(E.get(u.path).role))&&a(u);let h=0;if(we(t))for(let u of me(new Set(r.map(P=>P.path)))){let P=r.find(F=>F.path===u);if(h>=C.conventionImport.extractionFiles){s(P,"allowance");continue}if(p(P,"source")&&p(P,"definition")){let F=c.length;a(P),c.length>F&&h++}}let M=y.needsExtraction;if(M){let u=r.flatMap(F=>{if(k.has(F.path)||i[F.path]||f&&fe(R(F)))return[];if(!p(F,"extraction"))return[];let N=Ve(R(F));return N===null?[]:[{entry:F,rank:N}]}).sort((F,N)=>F.rank-N.rank||(F.entry.size??0)-(N.entry.size??0)),P=h;for(let{entry:F}of u){if(P>=C.conventionImport.extractionFiles){s(F,"allowance");continue}let N=c.length;a(F),c.length>N&&P++}}if(f&&n.files){let u=Vt(t,{entries:e,selected:r.filter(P=>Object.hasOwn(i,P.path)),files:n.files,root:o});for(let P of u.paths)Object.hasOwn(i,P)||(c.push(P),i[P]=r.find(F=>F.path===P).ref);for(let P of u.refused)l.set(P.path,P)}return{...ce(t)&&m.some(u=>!Object.hasOwn(i,u.path))?{definitionsOmitted:!0}:{},selectedPaths:c,shaByPath:i,treeListing:r.slice(0,Gt).map(u=>u.path),needsExtraction:M,refused:[...l.values()]}}function Vt(t,e){let o=new Set(e.selected.map(i=>i.path)),n=Oe(t,e.entries.map(i=>i.path),e.root,{files:e.files}).files.filter(i=>i.role==="skill"&&o.has(i.path)).map(i=>i.path),r=xe(t,{skillPaths:n,paths:e.entries.map(i=>i.path),files:e.files,sizes:new Map(e.entries.map(i=>[i.path,i.size])),selected:e.selected,root:e.root,admission:e.admission,referencePaths:e.referencePaths});return{paths:[...new Set(r?.flatMap(i=>i.files.map(c=>c.path))??[])],refused:r?.flatMap(i=>i.refused)??[]}}var Mt=(t,e)=>{let o=Ot(e.settings,t,e.dir??void 0,{mode:e.mode});return{strength:"partial",wants:o.selectedPaths,state:{needsExtraction:o.needsExtraction,treeListing:o.treeListing,shaByPath:o.shaByPath,refused:o.refused,...o.definitionsOmitted?{definitionsOmitted:!0}:{}}}};var Et=["marker","code-scan","conventions"];var Yt={marker:bt,"code-scan":Pt,conventions:Mt};function Ae(t,e,o,n,r=Yt){let i={...o,settings:t},c={readers:[]};for(let l of Et)if(!(n&&!n.includes(l)))try{let f=r[l]?.(e,i);f&&c.readers.push({id:l,claim:f,done:!1})}catch{}return c}function Xo(t){return{readers:t.readers.map(({id:e,done:o})=>({id:e,done:o}))}}function Ft(t){let e=t.readers.find(({id:o})=>o==="conventions").claim;return{selectedPaths:e.wants,...e.state}}var Wt={files:200,bytes:C.codeAgent.importBytes,depth:32,edges:_.edges,entries:pe.inventoryEntries};function It(t={}){return Object.fromEntries(Object.entries(Wt).map(([e,o])=>{let n=t[e]??o;return[e,Number.isFinite(n)?Math.max(0,Math.min(o,Math.floor(n))):0]}))}function xt(t,e,o,n){let r=new Set(o.map(s=>G(s.path,n))),i=t.CF_READING_NOTE_AGENT_ONLY!=="0"&&ft(t),c=new Set(e.agents),l=s=>!r.has(s)&&(!i||c.has(s)),f=e.instruction.filter(l),y=e.code.filter(l),k=e.agents.filter(s=>!r.has(s)),E=new Set(dt(k)),S=[...f,...y].every(s=>E.has(s)),x=f.length,A=y.length,I=[!S&&x>0&&`${x} instruction file${x===1?"":"s"} left out by the ${Math.round(C.sourceFetch.instructionBytes/1e3)}KB instruction budget`,!S&&A>0&&`${A} analyzable file${A===1?"":"s"} left out by the ${Math.round(C.sourceFetch.codeBytes/1e3)}KB/${C.sourceFetch.codeFiles}-file code budget \u2014 the analysis reads the most agent-shaped files first`,ut(k,i)].filter(Boolean),R=o.filter(s=>s.readBytes!==void 0).map(s=>G(s.path,n));return R.length&&I.push(`${R.join(", ")}: only the first ${C.sourceFetch.codeFileBytes/1e3} KB was read`),I.length?I.map((s,p)=>p<I.length-1?String(s).replace(/\.$/,""):s).join("; "):void 0}function At(t,e,o,n={}){let{descriptions:r,priority:i,declarations:c}=ht(t,e,{root:o},n),l=[],f=r.flatMap(a=>a.admission.admitted?[{entry:a.readEntry,rel:a.rel,score:a.score,size:a.readEntry.size,pool:a.pool,...a.tier===void 0?{}:{tier:a.tier}}]:(l.push({path:a.entry.path,reason:a.admission.reason}),[])),y=f.filter(({score:a})=>a===0).sort(ge),k=f.filter(({score:a})=>a>0).sort(ge),E=[],S={instruction:0,code:0},x={instruction:[],code:[]},A=0,I=(i.enabled?[...f].sort(ge):[...y,...k]).sort((a,m)=>Number(c.has(m.entry.path))-Number(c.has(a.entry.path)));for(let{entry:a,rel:m,pool:h}of I){let M=h==="instruction"?C.sourceFetch.instructionBytes:C.sourceFetch.codeBytes;if(S[h]+a.size>M||h==="code"&&A>=C.sourceFetch.codeFiles){x[h].push(m),l.push({path:a.path,reason:S[h]+a.size>M?"total":"allowance"});continue}E.push(a),S[h]+=a.size,h==="code"&&(A+=1)}let R=pt(i,l.flatMap(a=>{let m=G(a.path,o);return m===null?[]:[{...a,path:m}]})),s={...x,agents:R},p=xt(t,s,E,o);return{selected:E,totalBytes:S.instruction+S.code,refused:l,...p?{skippedNote:p}:{},...i.enabled&&p?{readingNotes:s}:{}}}function Re(t){let e=t.CF_CODE_AGENTS!=="0";return{scan:e,model:e&&t.CF_CODE_AGENTS_MODEL!=="0"}}function Rt(t,e){if(e.profile==="entry-analysis"){let l=It(e.limits),f=e.listing.find(k=>k.path===e.selection.entry),y=[...f?[f]:[],...e.listing.filter(k=>k.path!==e.selection.entry)].slice(0,l.entries);return{profile:e.profile,request:e.selection,entries:y,limits:l,inventoryIncomplete:e.listing.length-y.length}}let o=$e(t),n=o.length?{scopeSelections:o}:{},r={dir:e.root??null,mode:e.profile==="hosted-import"?e.mode??"all":"all",flags:e.profile==="hosted-import"?e.flags??Re(t):Re(t)};if(e.profile==="hosted-import"){let l=Ae(t,e.listing,r);return{profile:e.profile,...l,...n,selection:Ft(l),...ke(t)?{mode:r.mode}:{}}}let i=e.listing.filter(l=>B(t,l,{purpose:"pointer",route:"github",root:e.root}).admitted),c=Ae(t,i,r,["marker","code-scan"]);return{profile:e.profile,...c,...n,listing:i,selection:e.selection??At(t,e.listing,e.root),context:r,...e.selection&&ke(t)?{selectionPaths:e.selection.selected.map(l=>l.path)}:{}}}import{createHash as qt}from"node:crypto";var Q=t=>qt("sha256").update(t).digest("hex");function Cn(t,e){let o=s=>({kind:"refused",reason:s,pending:[]}),n=t.entries,r=new Map;for(let s of e)for(let p of s.files){let a=r.get(p.path);if(a&&(a.hash!==p.hash||a.size!==p.size))return o("stale-snapshot");r.set(p.path,{...p,role:n.includes(p.path)?"entry":"imported-helper"})}let i=[...r.values()],c=Q(JSON.stringify([n,e.map(s=>s.snapshot)])),l=[],f=new Set,y=(s,p,a=!1)=>{p=[...new Set(p)];let m=JSON.stringify([...p].sort());f.has(m)||p.length===i.length&&n.every(h=>r.has(h))||p.filter(h=>n.includes(h)).length>de||p.length>_.scopeImports+1||l.length>=_.choices||(f.add(m),l.push({id:Q(m),scope:{snapshot:c,entry:s,entries:n,imports:p.length===1?"none":p.filter(h=>h!==s)},includes:p,omitted:i.filter(h=>!p.includes(h.path)).map(h=>h.path),...a&&p.length>1?{coverage:"entry-imports"}:{}}))};for(let s=0;s<e.length;s+=de){let p=e.slice(s,s+de);y(p[0].kind==="file"?p[0].entry:n[s],p.flatMap(a=>a.files.map(m=>m.path)),!0)}for(let s of n.filter(p=>r.has(p)))y(s,[s]);for(let s of e)y(s.kind==="file"?s.entry:n[0],s.files.map(p=>p.path),!0);for(let s of e)for(let p of s.choices)y(p.scope.entry,p.includes);let k=s=>[...new Map(s.map(p=>[JSON.stringify(p),p])).values()],E=k(e.flatMap(s=>s.refusedEdges)),S=k(e.flatMap(s=>s.edges)),x=E.slice(0,_.edges),I=n.length-e.length+E.length-x.length+Math.max(0,S.length-_.edges)+e.reduce((s,p)=>s+p.completeness.frontierCount,0),R={schemaVersion:1,kind:"file",launchRoot:t.launchRoot,entry:t.entry,entries:n,snapshot:c,resolverVersion:e[0].resolverVersion,files:i,entrySets:e.map(s=>({entry:s.kind==="file"?s.entry:n[0],includes:s.files.map(p=>p.path)})),edges:S.slice(0,_.edges),refusedEdges:x,completeness:{complete:I===0&&e.every(s=>s.completeness.complete),frontierCount:I},choices:l};if(t.scope){if(t.scope.snapshot!==c)return o("stale-snapshot");let s=t.scope,p=Xt(R,s);return p?{kind:"ready",pending:[],selection:{...R,entrySets:void 0,...Ct(R,p.includes),choices:[]}}:o("invalid-scope")}return{kind:"ready",pending:[],selection:mt.parse(R)}}function Ut(t,e){if(t.kind!=="file"||!t.entries||!t.entrySets||!e.length)return;let o=e.map(c=>t.entrySets.find(l=>l.entry===c));if(o.some(c=>!c))return;let n=new Set(o.flatMap(c=>c.includes)),r=t.files.filter(c=>n.has(c.path)).map(c=>c.path);if(t.entries.filter(c=>n.has(c)).length>de||r.length>_.scopeImports+1)return;let i=e[0];return{id:Q(JSON.stringify([...r].sort())),scope:{snapshot:t.snapshot,entry:i,entries:t.entries,imports:r.length===1?"none":r.filter(c=>c!==i)},includes:r,omitted:t.files.filter(c=>!n.has(c.path)).map(c=>c.path),...r.length>1?{coverage:"entry-imports"}:{}}}function Xt(t,e){let o=f=>JSON.stringify([f.snapshot,f.entry,f.imports==="none"?[]:Array.isArray(f.imports)?[...f.imports].sort():f.imports,f.entries]),n=t.choices.find(f=>o(f.scope)===o(e));if(n)return n;if(t.kind!=="file"||!t.entries||e.imports==="all")return;let r=new Set([e.entry,...e.imports==="none"?[]:e.imports]),i=t.entrySets?.filter(f=>f.includes.every(y=>r.has(y))).map(f=>f.entry)??[];if(!i.includes(e.entry))return;let c=[e.entry,...i.filter(f=>f!==e.entry)],l=Ut(t,c);return l&&o(l.scope)===o(e)?l:void 0}function Ct(t,e,o=!0){let n=new Set(e),r=new Set(t.files.map(f=>f.path)),i=t.edges.filter(f=>n.has(f.from)&&!n.has(f.path)&&r.has(f.path)).map(f=>({from:f.from,specifier:f.specifier,status:"refused",provenance:f.provenance,reason:"not-selected"})),c=o?[...new Map([...t.refusedEdges.filter(f=>n.has(f.from)),...i].map(f=>[JSON.stringify(f),f])).values()]:[...t.refusedEdges,...i].slice(0,_.edges).filter(f=>n.has(f.from)),l=t.completeness.frontierCount+(o?Math.max(0,c.length-_.edges):0);return{files:t.files.filter(f=>n.has(f.path)),edges:t.edges.filter(f=>n.has(f.from)&&n.has(f.path)),refusedEdges:c.slice(0,_.edges),completeness:{complete:l===0&&c.every(f=>f.reason==="external"),frontierCount:l}}}function Ht(t,e){let o=new Set(e.map(r=>r.path)),n=new Set(e.filter(r=>r.role==="entry").map(r=>r.path));return!t?.files.some(r=>!o.has(r.path)||r.role==="prompt"&&!n.has(r.path))}function Zt(t){return t.unavailable?t.unavailable:t.entry?!Number.isSafeInteger(t.entry.size)||t.entry.size<0?"over-limit":Ue.safeParse(t.path).success?t.depth>t.limits.depth||!t.spentPaths.has(t.path)&&(t.spentPaths.size>=t.limits.files||t.bytes+t.size>t.limits.bytes)?"over-limit":null:"out-of-scope":"missing"}function Lt(t,e){let o=b=>({kind:"refused",reason:b,pending:[]});if(!Be(t))return o("disabled");let{request:n,files:r,resolutions:i,unavailable:c={}}=e,l=Rt(t,{profile:"entry-analysis",listing:[...e.entries],selection:n,limits:e.limits}),{limits:f}=l,y=new Map(l.entries.map(b=>[b.path,b])),k={},E=[],S=[],x=[],A=[],I=new Set,R=new Set,s=[{path:n.entry,depth:0,settings:!1},...(e.settingsFiles??[]).map(b=>({path:b,depth:0,settings:!0}))],p=new Set,a=new Map,m=new Map,h=new Set(e.attempted?.paths),M=new Set(e.settingsAttempted?.paths),u={files:pe.settingsFiles,bytes:pe.settingsBytes,depth:f.depth},P=e.settingsAttempted?.bytes??0,F=e.attempted?.bytes??0,N=0,j=e.inventoryIncomplete??0;j+=l.inventoryIncomplete;let J=(b,v)=>{A.length<_.edges&&A.push({from:b.from,specifier:b.specifier,status:"refused",provenance:b.provenance,reason:v})};for(let b=0;b<s.length;b++){let v=s[b],T=`${v.settings}:${v.path}`;if(p.has(T))continue;p.add(T);let D=y.get(v.path),$=Object.hasOwn(r,v.path)?r[v.path]:void 0,te=$===void 0?D?.size??0:Buffer.byteLength($),ie=v.settings?M:h,z=Zt({...v,entry:D,size:te,unavailable:Object.hasOwn(c,v.path)?c[v.path]:void 0,spentPaths:ie,bytes:v.settings?P:F,limits:v.settings?u:f});if(z){if(v.path===n.entry&&!v.settings)return o(z);if(v.settings&&Object.defineProperty(k,v.path,{value:z,enumerable:!0}),!v.settings){m.set(v.path,z);for(let g of a.get(v.path)??[])J(g,z);z==="over-limit"&&j++}continue}if(ie.has(v.path)||(v.settings?P+=te:F+=te,ie.add(v.path)),$===void 0){S.push(v.path),(v.settings?I:R).add(v.path);continue}if(v.settings)continue;if(E.push(v.path),!Object.hasOwn(i,v.path)){S.push(v.path);continue}let q=i[v.path];for(let g=0;g<q.length;g++){let O=q[g];if(N++>=f.edges){J(O,"over-limit"),j+=q.length-g;break}if(!Xe.safeParse(O).success||O.from!==v.path){J({from:v.path,specifier:"?",status:"refused",provenance:null,reason:"unsupported"},"unsupported");continue}if(O.status==="refused"){J(O,O.reason);continue}x.push(O),a.set(O.path,[...a.get(O.path)??[],O]);let L=m.get(O.path);if(L){J(O,L);continue}s.push({path:O.path,depth:v.depth+1,settings:!1})}}if(S.length)return{kind:"pending",pending:[...new Set(S)],pendingSettings:[...I].filter(b=>!R.has(b)),...Object.keys(k).length?{unavailable:k}:{}};let se=E.map(b=>({path:b,role:b===n.entry?"entry":"imported-helper",hash:Q(r[b]),size:Buffer.byteLength(r[b])})),ee=Q(JSON.stringify({request:{...n,scope:void 0},files:se,inventory:[...y.values()].map(({path:b,size:v,ref:T})=>({path:b,size:v,ref:T})).sort((b,v)=>b.path.localeCompare(v.path)),metadata:(e.settingsFiles??[]).map(b=>[b,Object.hasOwn(r,b)?Q(r[b]):c[b]??"over-limit"]),edges:x,refusedEdges:A,frontierCount:j,limits:f,resolverVersion:e.resolverVersion,resolverIdentity:e.resolverIdentity,targetIdentity:e.targetIdentity,settings:Object.entries(Ne(t)).sort(([b],[v])=>b.localeCompare(v))})),w=n.scope;if(w&&w.snapshot!==ee)return o("stale-snapshot");let d=E.filter(b=>b!==n.entry);if(w&&(w.entry!==n.entry||Array.isArray(w.imports)&&w.imports.some(b=>!d.includes(b))))return o("invalid-scope");let V=new Set(!w||w.imports==="all"?E:[n.entry,...w.imports==="none"?[]:w.imports]),Y=Ct({files:se,edges:x,refusedEdges:A,completeness:{complete:!1,frontierCount:j}},[...V],!1),U=Y.files;if(!Ht(e.proposal,U))return o("invalid-scope");let re=[],ue=(b,v)=>{let T=[n.entry,...v==="none"?[]:v];T.length!==U.length&&re.push({id:b,scope:{snapshot:ee,entry:n.entry,imports:v},includes:T,omitted:U.filter(D=>!T.includes(D.path)).map(D=>D.path)})};ue("entry-only","none");for(let b of U.filter(v=>v.role==="imported-helper").slice(0,_.choices-1))ue(Q(b.path),[b.path]);let he={schemaVersion:1,kind:"file",launchRoot:n.launchRoot,entry:n.entry,snapshot:ee,resolverVersion:e.resolverVersion,...Y,choices:re};return{kind:"ready",pending:[],selection:he}}function Nn({prompt:t,link:e}){return{path:e?.callPath??t.path,...e?{line:e.callLine}:{},symbol:t.symbol,promptPath:t.path,promptStart:t.start,...e?.kind==="L4"?{loadedPrompt:!0,...e.callStart!==void 0?{callStart:e.callStart}:{}}:{}}}function Bt(t,e,o){return nt(t,e,o)}var Se=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).sort().join("-");function Qt(t,e,o,n={}){let r=new Map(t.map(i=>[Se(i),i]));return e.flatMap(i=>{let c=Object.hasOwn(o,i)?o[i]:void 0;if(c===void 0||!B(n,{path:i},{purpose:"code-support",route:"github"}).admitted)return[];let l=le(i,c,X(i)).toks;return l.flatMap((f,y)=>{if(!Z(f))return[];let k=r.get(Se(f.text));if(!k)return[];let E=!1;if(Z(l[y-1],"function")||Z(l[y-1],"def"))E=H(l[y+1],"(");else if(["const","let","var"].some(S=>Z(l[y-1],S))){for(let S=y+1;S<l.length&&S<y+80&&!H(l[S],";");S++)if(H(l[S],"=")){let x=Z(l[S+1],"async")?S+2:S+1,A=H(l[x],"(")?Te(l,x)+1:x+1;E=Z(l[x],"function")||H(l[A],"=")&&H(l[A+1],">");break}}return E?[{name:k,sourcePath:i,sourceLine:f.line}]:[]})})}function Nt(t,e,o,n,r={}){let i=new Set(t.map(Se)),c=k=>B(r,{path:k},{purpose:"code-support",route:"github"}).admitted,l=k=>Qt(t,[k],o,r).length>0,f=e.filter(k=>c(k)&&l(k)),y=n.filter(k=>c(k)&&i.has(Se(k.split("/").at(-1).replace(/\.[^.]+$/,"")))&&(o[k]===void 0||l(k))).sort();return[...new Set([...f,...y])]}var jt="model call";function zt(t,e){let o=Bt(t.ownPaths,e,t.toolCall);return{tools:o.tools.map(n=>({tool:n,from:o.from[n.name]})),toolWarnings:o.warnings}}function Le(t=new Map,e){return{left:Math.max(0,C.codeAgent.importBytes-[...t.values()].reduce((o,n)=>o+n,0)),chosen:new Set([...t.keys()].filter(o=>!e?.has(o))),...e?{replacementBytes:e}:{}}}function eo(t,e){return t.modelId??(!t.documentation&&e.length===1?e[0]:null)}function ns(t,e,o){return to(t,eo(t,e),o)}function to(t,e,o){let{prompt:n,link:r}=t,i=[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 l of t.alsoLoads??[])i.push({role:"system prompt",label:"also loaded",path:l});r&&i.push({role:"code",label:jt,path:r.callPath}),r?.wrapper&&i.push({role:"code",label:"model wrapper",path:r.wrapper.path}),e&&i.push({role:"code",label:"model setting",path:e.path}),t.shape&&i.push({role:"code",label:"answer shape",path:t.shape.path});let c=new Set;return i.filter(l=>!c.has(l.path)&&!!c.add(l.path)).map(l=>ze(o,l.path,l.path===n.path&&t.promptSource==="marker")?l:{...l,role:"reference"})}function ss(t,e){let{prompt:o}=t,n=e[o.path]??"";return o.kind==="file"?n:n.split(`
|
|
2
2
|
`).slice(o.span.from-1,o.span.to).join(`
|
|
3
3
|
`)}function rs(t,e){return e?Object.fromEntries(e.files.filter(o=>t[o.path]!==void 0).map(o=>[o.path,t[o.path]])):t}function is(t,e,o){let{files:n,sizes:r,root:i,total:c=Le()}=o,l=[...new Set([...e.ownPaths,...o.guides??[]])],f=[],y=new Set(l);l=l.filter(h=>{let M=B(t,{path:h},{purpose:"override",route:"github"});return M.admitted||f.push({path:h,reason:M.reason}),M.admitted});let k=[...r.keys()].filter(h=>{let M=B(t,{path:h},{purpose:"code-support",route:"github",root:i});return!M.admitted&&!y.has(h)&&f.push({path:h,reason:M.reason}),M.admitted}),E=Object.fromEntries(l.filter(h=>n[h]!==void 0).map(h=>[h,n[h]])),S=ot(E,k).filter(h=>!l.includes(h)),x=Object.fromEntries([...l,...S].filter(h=>n[h]!==void 0).map(h=>[h,n[h]])),A=zt({ownPaths:l,toolCall:e.toolCall},x).tools.map(({tool:h})=>h.name),I=new Set(Nt(A,S,n,k,t)),R=Ce(t,l,{...o,total:c});for(let h of new Set([...l,...S,...I]))R.take(h,I.has(h)&&!l.includes(h));let{paths:s,skipped:p}=R,a=Object.fromEntries(s.filter(h=>n[h]!==void 0).map(h=>[h,n[h]])),m=zt(e,a);return{paths:s,skipped:p,refused:ae(f,R.refused),...m}}function Ce(t,e,{sizes:o,total:n=Le(),pool:r},i=[]){let c=[],l=[],f=[],y=C.codeAgent.extraBytes,k=0;return{paths:c,skipped:l,refused:f,take:(S,x,A=!1)=>{if(c.includes(S))return!0;let I=o.get(S),R=S===e[0],s=i.includes(S),p=[n,...r?[r]:[]],a=u=>Math.max(0,(I??0)-(u.replacementBytes?.get(S)??0)),m=s?"override":e.includes(S)||A?"pointer":"code-support",h=B(t,{path:S,size:I},{purpose:m,route:"github"});h.admitted||f.push({path:S,reason:h.reason});let M=I===void 0?"missing":h.admitted?!s&&!R&&I>y?"allowance":!s&&p.some(u=>!u.chosen.has(S)&&(a(u)>u.left||u.wholeBytesLeft!==void 0&&I>u.wholeBytesLeft))?"total":x&&k>=C.codeAgent.toolCodeFiles?"tool-limit":null:h.reason;if(M)return l.push({path:S,reason:M}),!1;!R&&!s&&(y-=I),x&&k++;for(let u of p)u.chosen.has(S)||(u.left-=a(u),u.wholeBytesLeft!==void 0&&(u.wholeBytesLeft-=I),u.chosen.add(S));return c.push(S),!0}}}function as(t,e,o){return"request"in e?Lt(t,e):oo(t,e,o)}function oo(t,e,o){if(!we(t)&&!(oe(t)&&e.some(s=>s.fileProfile==="layout")))return null;let n=o.scopes??ct(t,[...o.sizes.keys()],o.root??void 0,{},o.agentConfigurations??{}),r=o.total??Le(),i=new Set(o.confirmationIds),c=o.selectedIds&&new Set(o.selectedIds),l=e.filter(s=>!c||c.has(s.id));for(let s of l)for(let{path:p}of s.ownFiles.filter(a=>s.fileProfile==="convention"||s.sharedReferencePaths?.includes(a.path))){let a=o.sizes.get(p),m=s.scopeProof?.paths.includes(p)?void 0:o.root;a===void 0||r.chosen.has(p)||!B(t,{path:p},{purpose:"override",route:"github",root:m}).admitted||(r.left-=Math.max(0,a-(r.replacementBytes?.get(p)??0)),r.wholeBytesLeft!==void 0&&(r.wholeBytesLeft-=a),r.chosen.add(p))}let f=(s,p)=>{for(let a of s){let m=a.ownFiles[0]?.path;if(!m)continue;let h=n.ownerOf(m);!h||h.key!==a.scope.key||h.folder!==a.scope.folder||!B(t,{path:m},{purpose:"pointer",route:"github",root:o.root}).admitted||Ce(t,[m],{...o,total:p,pool:void 0}).take(m,!1)}};f(l,r);let y,k=new Set,E=new Set(o.sizes.keys()),S=me(E).flatMap(s=>o.files[s]===void 0?[]:be(s,o.files[s],E,{root:o.root??void 0})),x=new Map(S.map(s=>[s,s.to&&o.files[s.to]!==void 0?Ze(s.to,o.files[s.to],s.imported,E,t):[]])),A=new Set(S.filter(s=>{let p=s.to&&X(s.to),a=s.to&&o.files[s.to];return p&&a!==void 0&&a!==null&&!ve(le(s.to,a,p),s.imported)})),I=e.map(s=>{let p=[...new Set(s.ownFiles.map(w=>w.path))],a=new Set(s.fileProfile==="layout"?s.ownFiles.filter(w=>w.role==="tools").map(w=>w.path):[]),m={schemaVersion:1,agentId:s.id,scope:{...s.scope},files:[],edges:[],unresolved:[],refused:[]};if(c&&!c.has(s.id))return m;i.has(s.id)&&!y&&(y={left:C.candidateFetch.check,chosen:new Set(k)},f(l.filter(w=>i.has(w.id)),y));let h=Ce(t,p,{...o,total:r,pool:i.has(s.id)?y:void 0},s.fileProfile==="convention"?p:s.sharedReferencePaths),M=new Set(s.skillManifests?.flatMap(w=>w.files.map(d=>d.path))),u=s.ownFiles.filter(w=>w.role!=="reference"||!M.has(w.path)||s.independentReferences?.includes(w.path)).map(w=>({path:w.path,symbol:null,role:w.role,evidence:null,span:w.span})),P=S.filter(w=>w.to!==null&&p.includes(w.to)),F=P.filter(w=>new Set(P.filter(d=>d.to===w.to).map(d=>d.imported)).size>1),N=S.filter(w=>!A.has(w)&&(P.includes(w)&&!s.toolCall&&!F.includes(w)||x.get(w).some(d=>{if(d.kind!=="graph-node"||!d.to||!p.includes(d.to)||!s.toolCall||s.toolCall.path!==d.to)return!1;let V=o.files[d.to];return V!==void 0&&Qe(d.to,V,d.imported,s.toolCall)})));m.unresolved.push(...P.filter(w=>!N.includes(w)).map(w=>({...w,reason:A.has(w)?"missing":"unlinked"})));for(let w of N)u.push({path:w.from,symbol:w.symbol,role:"config",evidence:w,explicit:!0});let j=new Set,J=new Map,se=new Set,ee=new Set;for(let w=0;w<u.length;w++){let d=u[w],V=JSON.stringify([d.path,d.symbol,d.role]);if(j.has(V)){let g=m.files.find(O=>O.path===d.path);g&&d.span&&!g.spans.some(O=>O.from===d.span.from&&O.to===d.span.to)&&(g.spans.push(d.span),g.evidence.push({kind:"entry",from:d.path,to:d.path,span:d.span})),g&&d.evidence?.kind==="skill-reference"&&!g.evidence.some(O=>JSON.stringify(O)===JSON.stringify(d.evidence))&&g.evidence.push(d.evidence);continue}j.add(V);let Y=n.ownerOf(d.path),U=p.includes(d.path)&&s.scopeProof?.paths.includes(d.path),re=B(t,{path:d.path},{purpose:p.includes(d.path)||d.explicit?"pointer":"code-support",route:"github",root:U?void 0:o.root}),ue=d.role==="reference"&&p.includes(d.path)&&(s.sharedReferencePaths?.includes(d.path)||s.skillManifests?.some(g=>m.files.some(O=>O.path===g.ownerPath)&&g.files.some(O=>O.path===d.path)&&!g.refused.some(O=>O.path===d.path))),he=re.admitted?!U&&(!Y||!ue&&(Y.key!==s.scope.key||Y.folder!==s.scope.folder))?"out-of-scope":!p.includes(d.path)&&e.some(g=>g.id!==s.id&&g.ownFiles.some((O,K)=>O.path===d.path&&(K===0||O.label===jt)))?"other-agent":null:re.reason;if(he){m.refused.push({path:d.path,reason:he});continue}let b=o.files[d.path],v=X(d.path),T=b!==void 0&&v?le(d.path,b,v):null,D=T&&d.symbol?ve(T,d.symbol):null,$=D?.name??d.symbol;if(b!==void 0&&!J.has(d.path)){let g=S.filter(L=>L.from===d.path),O=[...g.length?g:be(d.path,b,E,{root:s.scope.folder,call:s.toolCall}),...[...ee].filter(L=>L.to===d.path).flatMap(L=>x.get(L))];O.forEach(L=>se.add(L));let K=He(d.path,b,E,p.includes(d.path)?s.toolCall:void 0,t).flatMap(L=>O.some(W=>!W.reason&&W.kind===L.kind&&W.symbol===L.symbol&&W.span.from===L.span.from)?[]:N.some(W=>W.to===d.path)&&!p.includes(d.path)&&(L.kind==="config"||L.kind==="graph-node")&&!L.reason?[{...L,reason:"unlinked"}]:[L]);J.set(d.path,[...K,...O,...(o.links??[]).filter(L=>L.from===d.path)])}let te=J.get(d.path)??[];if(d.role==="code"&&d.evidence?.kind==="import"&&te.some(g=>g.reason==="external"&&g.usage==="call"&&(g.within===$||g.within===null)&&_e(g.source,v))){m.refused.push({path:d.path,reason:"provider-transport"});continue}let ie=a.has(d.path)||d.role==="tool"&&D?.params!=null&&!p.includes(d.path);if(!h.take(d.path,ie,d.explicit))continue;m.unresolved.push(...S.filter(g=>g.from===d.path&&(g.reason||A.has(g))).map(g=>A.has(g)?{...g,reason:"missing"}:g));let z=m.files.find(g=>g.path===d.path);z||(z={path:d.path,roles:[],spans:[],evidence:[],sharedOwners:[]},m.files.push(z)),z.roles.includes(d.role)||z.roles.push(d.role);let q=d.span??(T&&D?{from:T.toks[D.from].line,to:T.toks[D.to-1].endLine}:void 0);q&&!z.spans.some(g=>g.from===q.from&&g.to===q.to)&&z.spans.push(q),d.evidence?z.evidence.push(d.evidence):z.evidence.push({kind:"entry",from:d.path,to:d.path,...d.span?{span:d.span}:{}});for(let g of s.skillManifests??[])if(m.files.some(O=>O.path===g.ownerPath))for(let O of g.files)for(let K of O.evidence)K.fromPath===d.path&&u.push({path:O.path,symbol:null,role:"reference",explicit:!0,evidence:{kind:"skill-reference",from:K.fromPath,to:O.path,span:K.span}});if(b!==void 0)for(let g of te){let O=g.usage==="reexport"&&(g.symbol===$||g.symbol==="*"),K=g.usage==="call"&&g.within===$;if(!(g.kind!=="import"&&($===null||g.within===$)||$!==null&&(O||K)||g.reason==="dynamic"&&($===null||g.within===$)))continue;if(!g.to||g.reason){m.unresolved.push(g);continue}let W=N.includes(g);W&&(ee.add(g),J.delete(g.to)),m.edges.push(g);let Tt=g.kind==="tool-registration"?"tool":g.kind==="config"?"config":g.kind==="graph-node"?"workflow":O?d.role:"code";u.push({path:g.to,symbol:W?null:g.imported==="*"?d.symbol:g.imported,role:Tt,evidence:g,explicit:se.has(g)})}}if(m.refused.push(...ae(h.skipped,h.refused)),m.unresolved=m.unresolved.filter(w=>w.reason!=="unlinked"||!m.edges.some(d=>d.from===w.from&&d.to===w.to&&d.kind===w.kind&&d.symbol===w.symbol&&d.span.from===w.span.from)),m.unresolved=[...new Map(m.unresolved.map(w=>[JSON.stringify(w),w])).values()],m.refused=m.refused.filter((w,d,V)=>V.findIndex(Y=>Y.path===w.path&&Y.reason===w.reason)===d),!i.has(s.id))for(let w of m.files)k.add(w.path);return m}),R=new Map;for(let s of I)for(let p of s.files)R.set(p.path,[...R.get(p.path)??[],s.agentId]);for(let s of I)for(let p of s.files)p.sharedOwners=[...new Set(R.get(p.path))].sort();return I}export{Nn as a,Qt as b,Nt as c,we as d,xt as e,At as f,Re as g,Me as h,Ee as i,yt as j,wt as k,St as l,_t as m,lo as n,Kt as o,kt as p,So as q,xe as r,Ot as s,Vt as t,Ae as u,Xo as v,Ft as w,Wt as x,Rt as y,Cn as z,Ut as A,Xt as B,Ht as C,zt as D,Le as E,eo as F,ns as G,ss as H,rs as I,is as J,as as K};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./E7TFIHC5.js";import{f as p}from"./
|
|
1
|
+
import{a as s}from"./E7TFIHC5.js";import{f as p}from"./VC3PYT2B.js";import{a}from"./INVTU73D.js";import{createHash as d}from"node:crypto";function x(e){function r(t){if(!("includes"in e)||!Object.hasOwn(e.includes,t))throw new Error(`Unknown template: ${t}`);return e.includes[t]}function m(t){return"templateText"in e?Buffer.byteLength(e.templateText(t)):r(t).expandedSize}function i(t,n={}){return{name:t,hash:"templateText"in e?d("sha256").update(s(e.templateText(t),{promptAgreement:p(n),notActiveGroup:a(n)})).digest("hex"):r(t).expandedFingerprint}}function f(t,n={}){for(let o of t)if(i(o.name,n).hash!==o.hash)throw new Error("Counterfact's instructions changed since this analysis started. Start a new analysis.")}return{templateBytes:m,promptVersion:i,assertPromptVersions:f}}export{x as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Ha as O,Ka as F,Qa as $}from"./
|
|
1
|
+
import{Ha as O,Ka as F,Qa as $}from"./2M55DR2J.js";import{a as R}from"./SJESFYBA.js";import{f as E,g as V}from"./VDUFPTDD.js";var z="We couldn't see this agent's code, so this may already be handled there.";function se(e){return Object.values(e).some(s=>[...s].some(t=>R(t)!==null))}function _(e,s){return e==="better_as_code"&&s===!1?z:void 0}function ie(e){return e.sawCode??e.findingQuality?.sawCode}var H="Findings could not be checked a second time; all findings were kept.";function N(e,s){let t=new Set(s),r=new Map,n=new Set,a=new Set,d=new Set;for(let o of e){if(!t.has(o.id)){a.add(o.id);continue}if(n.has(o.id)){d.add(o.id),r.delete(o.id);continue}n.add(o.id),r.set(o.id,o)}return{byId:r,unknownIds:[...a],duplicateIds:[...d]}}function J(e,s){let t=N(e,s);return t.unknownIds.length===0&&t.duplicateIds.length===0}function de(e,s,t,r={}){let n=e.map((h,w)=>`f${w+1}`),a=!J(s,n),d=a?"Verdict ids did not match; all findings were kept.":t?.failure,o=new Set(t?.sentIds??n),l=new Map(t?.skipped.map(h=>[h.id,h.reason])??[]),u=a?["verdict ids did not match"]:[],p=new Map(s.map(h=>[h.id,h])),i=[...t?.rejectedBatches??[],...a?[{ids:n,verdicts:s}]:[]],c=new Map,f=[],k=r.mode==="offline-simulation"&&r.shadow?.done?N(r.shadow.verdicts,n).byId:new Map;for(let h of i)for(let w of h.verdicts)h.ids.includes(w.id)&&c.set(w.id,w);let b=e.map((h,w)=>{let g=n[w],y=a?void 0:p.get(g),q=p.get(g)??c.get(g),C=o.has(g)||q!==void 0,M=C?"":l.get(g)??"No model call was made before the check stopped.",I="keep",m;C?d?m=d:y?y.reason.trim()?!y.evidenceAgainst?.trim()||!y.evidenceFor?.trim()||y.verdict==="drop"&&/^[\s"'“”‘’]*none found[\s."'“”‘’]*$/i.test(y.evidenceAgainst)?(m="The model supplied no usable evidence for its decision; this finding was kept.",u.push(`${g}: ${m}`)):(I=y.verdict,m=y.reason,f.push(g)):(m="The model returned an empty reason; this finding was kept.",u.push(`${g}: ${m}`)):(m="The model returned no verdict for this finding in the accepted response; it was kept.",u.push(`${g}: ${m}`)):m=M;let x=k.get(g);return!d&&f.includes(g)&&x&&r.shadow?.coverage.answeredIds.includes(g)&&(x.verdict==="drop"&&x.decisive&&x.quotes.some(U=>U.side==="against")?(I="drop",m=x.reason):x.verdict!==I&&(I="keep",m="The checks disagree without decisive contrary evidence; this finding was kept.")),{id:g,title:h.title,verdict:I,reason:m,sent:C,skipReason:M,modelVerdict:q?.verdict??"",modelReason:q?.reason??"",evidenceAgainst:q?.evidenceAgainst??"",evidenceFor:q?.evidenceFor??""}}),v=[],P=e.filter((h,w)=>{let g=b[w];return g.verdict!=="drop"?!0:(v.push({finding:h,reason:g.reason}),!1)}),Q=d?[H]:v.length?[`${v.length} ${v.length===1?"finding was":"findings were"} removed after a second read: ${v.map(({finding:h})=>h.title.replace(/\s+/g," ").trim()).join("; ")}`]:[];return{kept:d?e:P,dropped:v,warnings:Q,verdicts:b,...u.length?{diagnostics:u}:{},...i.length?{rejectedBatches:i}:{},...t?.recordAcceptance?{acceptedIds:f}:{}}}var j={critical:0,high:1,medium:2,low:3},K="No strong findings to show.",L=/^[\s"'“”‘’]*none found[\s."'“”‘’]*$/i,W=/"([^"\n]*(?:\n[^"\n]*)*)"|“([^”]+)”|`([^`]+)`|‘([^’]+)’|'([^'\n]+)'/g;function A(e,s){return N(e.map(t=>({...t,id:t.fingerprint})),s).byId}function S(e,s){return e.repo===s.repo&&e.path===s.path}function T(e,s){let t=e.repos.filter(r=>r.key===s.repo);return t.length===1?t[0].files?.[s.path]:void 0}function G(e,s,t){return e===void 0||s===null||!Number.isInteger(s)||s<1||!t?.trim()?!1:O(e.split(`
|
|
2
2
|
`).slice(s-1).join(`
|
|
3
3
|
`),t)===1}function Y(e){return[...e.site?[{repo:e.siteRepo??"",...e.site,excerpt:e.excerpt}]:[],...e.otherSites]}function B(e,s){let t=T(s,e),r=e.line>1?t.split(`
|
|
4
4
|
`).slice(0,e.line-1).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as We,Aa as Xe,C as Ue,D as Be,E as Ge,Fb as $,G as ge,Gb as it,H as Ze,Hb as ye,I as ee,K as Ke,L as we,M as Ye,N as Pe,O as ke,R as Se,S as Je,T as V,a as de,aa as ce,c as Q,d as B,e as pe,eb as He,g as Fe,gb as Qe,h as Me,hb as oe,i as I,ib as et,j as Le,jb as tt,kb as ot,l as K,n as De,o as je,ob as nt,p as G,q as Te,ra as qe,s as ze,sb as st,t as J,ub as fe,ya as W,yb as rt,z as ie,za as te,zb as at}from"./
|
|
1
|
+
import{A as We,Aa as Xe,C as Ue,D as Be,E as Ge,Fb as $,G as ge,Gb as it,H as Ze,Hb as ye,I as ee,K as Ke,L as we,M as Ye,N as Pe,O as ke,R as Se,S as Je,T as V,a as de,aa as ce,c as Q,d as B,e as pe,eb as He,g as Fe,gb as Qe,h as Me,hb as oe,i as I,ib as et,j as Le,jb as tt,kb as ot,l as K,n as De,o as je,ob as nt,p as G,q as Te,ra as qe,s as ze,sb as st,t as J,ub as fe,ya as W,yb as rt,z as ie,za as te,zb as at}from"./2M55DR2J.js";import{a as Ne}from"./MKYLK6DB.js";import{a as z,c as v,e as Y}from"./C6X5GDG4.js";import{a as j,b as C,c as E,e as Ae,i as he,j as $e,k as T,l as Z,o as Ie,v as le}from"./YWL52FVW.js";import{f as Ve}from"./SJESFYBA.js";function q(e,t,o,c=t,r={}){let a=V(e,t.filter(s=>$(e,{path:s},{purpose:"override",route:"github"}).admitted),{root:o,...r});return be(a,e,c.some(s=>{let d=v(s,o);return d!==null&&de(d)}))}function be(e,t,o=e.scoped.some(c=>de(c.relativePath))){let c=new Map(e.scoped.map(s=>[s.path,s.relativePath])),r=(s,d,w=!1)=>e.files.find(g=>g.role===s&&g.kind!=="background"&&g.preferred!==!1&&(!d||g.kind===d)&&(!w||g.preferred))?.path??null,a=(s,d,w=!1)=>e.files.filter(g=>g.role===s&&(!d||g.kind===d)&&g.ownerPath!==void 0===w).map(g=>g.path).sort();return{scoped:e.scoped.map(s=>s.path),hasRepositoryGuide:o,developerCompanionPaths:!pe(t)&&o?e.scoped.filter(s=>Et(s.relativePath)).map(s=>s.path):[],stripRoot:s=>c.get(s)??s,configPath:r("marker"),promptPath:r("prompt","dedicated",!0),claudePath:r("prompt","fallback"),toolsPath:r("tool file","json"),toolsTsPath:r("tool file","sdk"),cliPath:r("tool file","cli"),mcpPath:r("MCP config",void 0,!0),registry:e.registry,soulPath:r("soul"),knowledgePath:r("knowledge"),subagentPaths:a("sub-agent"),skillPaths:a("skill"),skillNames:Object.fromEntries(e.files.filter(s=>s.role==="skill"&&s.name).map(s=>[s.path,s.name])),skillRefNames:Object.fromEntries(e.files.filter(s=>s.role==="reference"&&s.kind==="skill"&&s.name).map(s=>[s.path,s.name])),templatePaths:a("reference","template"),skillRefPaths:a("reference","skill"),subagentSkillPaths:a("skill",void 0,!0),subagentSkillRefPaths:a("reference","skill",!0),subagentSkillOwners:Object.fromEntries(e.files.filter(s=>s.ownerPath!==void 0).map(s=>[s.path,s.ownerPath]))}}function lt(e){let t=new Set(e.developerCompanionPaths),o=c=>!t.has(c);return{...e,mcpPath:e.mcpPath&&o(e.mcpPath)?e.mcpPath:null,subagentPaths:e.subagentPaths.filter(o),skillPaths:e.skillPaths.filter(o),subagentSkillPaths:e.subagentSkillPaths.filter(o),subagentSkillRefPaths:e.subagentSkillRefPaths.filter(o),skillRefPaths:e.skillRefPaths.filter(o)}}function ne(e){let t=lt(e);return!!(t.promptPath||t.toolsPath||t.toolsTsPath||t.cliPath||t.mcpPath||t.soulPath||t.knowledgePath||t.subagentPaths.length||t.skillPaths.length)}function Ot(e){let t=lt(e);return!!(t.promptPath||t.registry&&t.soulPath||t.subagentPaths.length)}function ct(e,t){return pe(e)?ne(t):Ot(t)}function Et(e){return e.toLowerCase()===".mcp.json"||/^\.claude\/(agents|skills)\//i.test(e)}function ft(e,t){return!!e.configPath||!!e.claudePath&&t==="prompt"||ne(e)}var Ct=/^(evals?|evaluations)\/.*\.(jsonl?|ya?ml|md|csv)$|\.eval\.(json|ya?ml)$/i;function Rt(e){return ge.exec(e)?.[1]?.toLowerCase()==="commands"&&/\.md$/i.test(e)}function Ft(e){return Ct.test(e)}function X(e,t,o={}){if(!B(e))return!1;if(o.agentConfigurations){if(o.agentConfigurations[z(o.root)]!==!0)return!1;if(o.skills!==!1)return!0}let c=t.flatMap(w=>{let g=v(w,o.root);return g===null?[]:[{path:w,relative:g}]}),r=c.filter(({path:w})=>$(e,{path:w},{purpose:"definition",route:"github",root:o.root}).admitted);if(!r.some(({relative:w})=>Q.includes(w.toLowerCase())))return!1;let a=q(e,r.map(w=>w.path),o.root,t),s=!!(a.subagentPaths.length||a.toolsPath||o.skills!==!1&&a.skillPaths.length),d=r.some(({relative:w})=>Rt(w));return!o.agentConfigurations&&c.some(({relative:w})=>{let g=ge.exec(w)?.[1]?.toLowerCase();return!(g==="skills"||(g==="commands"?s:Le(w)&&(s||d)))&&!at.test(w)&&!rt.test(w)&&w.toLowerCase()!==ie.toolsSource&&Xe(w)})?!1:s||d||r.some(({relative:w})=>Ft(w))}function se(e,t,o){let c=new Map([[z(o),[]]]);for(let r of t)v(r,o)!==null&&Q.includes(r.split("/").at(-1).toLowerCase())&&c.set(r.slice(0,Math.max(0,r.lastIndexOf("/"))),[]);for(let r of t){if(v(r,o)===null)continue;let a=r.slice(0,Math.max(0,r.lastIndexOf("/")));for(;c.get(a)?.push(r),!!a;)a=a.slice(0,Math.max(0,a.lastIndexOf("/")))}return Object.fromEntries([...c].map(([r,a])=>[r,X(e,a,{root:r})]))}function fo(e,t){let o=[...new Set([...Object.keys(t.files),...t.listedPaths??[]])],{root:c,skills:r,agentConfigurations:a}=t;if(!X(e,o,{root:c,skills:r,agentConfigurations:a}))return null;let s=q(e,Object.keys(t.files),c,t.listedPaths,{agentConfiguration:!0});return s.claudePath?s:null}import{posix as re}from"node:path";import{posix as Mt}from"node:path";function _e(e,t=1){let o=new Set,c=[],r=e.replace(/{#[\s\S]*?#}|{%[-+]?\s*raw\s*[-+]?%}[\s\S]*?(?:{%[-+]?\s*endraw\s*[-+]?%}|$)/g,a=>a.replace(/[^\n]/g," "));for(let a of r.matchAll(/{%[-+]?\s*(include|extends|import|from)\s+(.+?)\s*[-+]?%}/g)){let s=a[2].match(/^(["'])([^"']+)\1(?:\s+(?:as\s+\w+|import\s+.+|ignore missing|with context|without context))?$/),d=t+e.slice(0,a.index).split(`
|
|
2
2
|
`).length-1;c.push({source:s?.[2]??a[2],span:{from:d,to:d},...s?{}:{reason:"dynamic"}})}for(let a of r.matchAll(/{{[-+]?\s*([\w]+)|{%[-+]?\s*(?:if|elif|for\s+\w+\s+in|set\s+\w+\s*=)\s+([\w]+)/g)){let s=a[1]??a[2];!["true","false","none"].includes(s.toLowerCase())&&!/^\d/.test(s)&&o.add(s)}return{variables:[...o],loaders:c}}function ut(e,t={}){let o=e.split(`
|
|
3
3
|
`),c=[],r=[],a=(s,d,w)=>{let g=new Set;for(let P of Qe(s.join(`
|
|
4
4
|
`))){let k=w?`${w}.${P.key}`:P.key,l={from:d+P.span.from,to:d+P.span.to},n=s.slice(P.span.from-1,P.span.to);g.has(P.key)&&r.push({key:k,span:l,reason:"duplicate"}),g.add(P.key);let p=n[0].slice(n[0].indexOf(":")+1).trim();if(!p||p.startsWith("#")){let f=n.slice(1),u=f.find(y=>y.trim()&&!y.trimStart().startsWith("#"))?.match(/^ */)?.[0].length;if(u){a(f.map(y=>y.slice(u)),l.from,k);continue}}let h=He(n.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Vi}from"./
|
|
1
|
+
import{a as Vi}from"./5VQ4VYIP.js";import{b as D,k as zi}from"./KBTM5MBC.js";import{a as rs,b as Zt,c as is,d as as,e as cs,f as ls,g as en,h as zn,i as Wi}from"./6JTHFDH3.js";import{a as tn,b as nn,c as ps}from"./N7U5N42V.js";import{a as Xi}from"./QDYMR6KS.js";import{a as Ji}from"./4F6ZIHXU.js";import{a as Qi}from"./VGYWI4X2.js";import{b as et}from"./57M4OQJM.js";import{a as Yi}from"./J4AXGE5W.js";import{a as zt}from"./IBCFGUHI.js";import{a as Fi}from"./DZZBQDGO.js";import{a as $e,b as Ki,c as qi,d as Qt,e as bt,f as vt,g as Yt,h as Hi,i as De,j as ke,k as Ui,l as Xn,n as Gi}from"./6VHZNBII.js";import{D as os,E as Jt,F as ss,G as ge,H as Wn,I as xt,J as Ze,K as Bi,a as Vt,b as Mi,c as Ti,d as he,g as Un,h as Gn,i as Li,l as Ni,n as ns,o as ji,p as Di,q as Ye}from"./LFJQ4YLP.js";import{a as H}from"./326F4XNG.js";import{a as Qe,e as Ai}from"./KU5DINLW.js";import{a as On,b as j,c as Cn}from"./HCPO6QPU.js";import{a as $i,b as St,c as Hn,d as Ii,e as Wt,f as Je,g as Ri}from"./NCW5LJ5O.js";import{a as Xt,c as ts,d as Pi}from"./2CWULBP2.js";import{a as Ei}from"./5UWDUYHF.js";import{c as mt}from"./VC3PYT2B.js";import{A as Yo,B as Ve,a as Ce,c as Dn,d as wi,f as Bn,m as yi,n as Kn,p as Q,q as Ne,r as me,s as qn,t as je,x as Gt,y as Si}from"./P253B344.js";import{a as q,c as Ci,d as _i}from"./W73WF226.js";import{a as Ee}from"./M5YWJY7P.js";import{a as A,d as Oi}from"./4H23CSUM.js";import{a as bi,c as vi,e as F}from"./VWRFSVLI.js";import{a as es,e as xi,f as _e}from"./VX6LYNXV.js";import{c as le}from"./MJGB25S5.js";import{f as wr}from"./CNQZLSAP.js";import{c as Zo}from"./QVXARKP7.js";import{$ as T,$a as pi,B as Xo,Ca as Mn,D as Er,Da as Yr,Ea as Xe,F as $r,Fb as J,Ga as ni,Ha as ve,Ia as oi,J as z,Ja as si,Ka as Te,Kb as ki,L as Ir,La as ri,M as Rr,Ma as wt,Na as Oe,P as zo,Q as Vo,Qa as V,Ra as Le,Sa as yt,Ta as Nn,U as Pr,Ua as ii,V as Ar,Va as ze,W as Fr,Wa as ai,Xa as Ut,Y as Jo,Z as Mr,Za as ci,_ as Bt,_a as li,ab as di,bb as fi,cb as ui,d as ht,da as Nr,db as mi,f as Go,g as Wo,h as yr,i as _n,ka as jr,l as In,lb as hi,ma as se,oa as Dr,pa as Br,pb as jn,qa as Kr,sa as qr,t as Dt,ta as Hr,ua as Ur,v as Cr,va as Gr,w as _r,xa as Wr,ya as Fn,za as kt}from"./2M55DR2J.js";import{b as Tn}from"./74FPPPIG.js";import{a as oe}from"./MKYLK6DB.js";import{c as Tr,d as Lr}from"./5TATKWLG.js";import{c as An,f as re}from"./JKWTHRUR.js";import{b as ce,c as fe}from"./3GUKUEEJ.js";import{e as Ht}from"./JAPVLU4Z.js";import{e as gi}from"./YUY436SM.js";import{b as We,c as gt,d as Rn,e as Or}from"./C6X5GDG4.js";import{a as xr,b as $n,l as br,o as vr}from"./YWL52FVW.js";import{a as En,b as Sr}from"./SJESFYBA.js";import{a as ue,d as Zr,g as Ln,h as ei,i as ti,j as Qo}from"./Q5WR6B2H.js";import{b as Pn,c as Xr,d as zr,e as Vr,f as Kt,g as Jr,h as qt,i as Qr}from"./VDUFPTDD.js";var bp={repos:void 0,codeAgents:void 0,modelReader:void 0,projectAgents:void 0,analysisFlags:void 0,findingCheck:void 0,findingQuality:void 0,findingHeadlines:void 0,findingHeadlineDiagnostics:void 0,sawCode:void 0,sourceNotes:void 0,inspectPlan:void 0,passCursor:void 0,passFindings:void 0,passRetries:void 0,passResults:void 0,codeChecks:void 0,newVerdicts:void 0,repoCursor:void 0,mapped:void 0,findingsRaw:void 0,warnings:void 0,scopeCheck:void 0,structuresRaw:void 0,loadModes:void 0,openStructures:void 0,structurePassFailed:void 0,structureScopeCheck:void 0,structureStats:void 0,splitCheckRan:void 0,splitPassFailed:void 0,structurePhase:void 0,shapeFindings:void 0,splitEstimateBase:void 0,splitCheckPriced:void 0,splitFindingsPriced:void 0,readPaths:void 0,rechecks:void 0,recheckedChangeIds:void 0},vp=Object.freeze(Object.keys(bp));function ds(e,t){return Ht.parse(e.mapped?.[t])}function Zi(e,t){return Ht.safeParse(e.mapped?.[t])}function Y(e){return(e.mapped??[]).map((t,n)=>({repoKey:e.repos?.[n]?.key??`repo-${n}`,fragment:ds(e,n)}))}function Be(e){return Object.fromEntries((e.repos??[]).map(t=>[t.key,new Set(Object.keys(t.files??{}))]))}function ie(e){return Object.fromEntries(vp.filter(t=>Object.hasOwn(e,t)).map(t=>[t,e[t]]))}function ae(e,t){let n=[],o=e.flatMap(a=>a.skipped).map(a=>({...a}));for(let a of e)for(let[c,l]of Object.entries(a.files)){let d=Object.hasOwn(t,c)?t[c]:void 0;d===l?n.push(...a.sources.filter(p=>p.sourcePath===c)):o.push({path:c,reason:d===void 0?"Source file was not read.":l.startsWith(d)?"Source file was truncated while reading.":"Source file changed after admission."})}let s=o.filter((a,c)=>o.findIndex(l=>l.path===a.path&&l.reason===a.reason)===c),r=new Set(s.map(({path:a})=>a)).size,i=r?[`${r} ${r===1?"file was":"files were"} skipped, so some findings may be missing.`]:[];return{sources:n,skipped:s,warnings:i}}function on(e,t,n,o){let s=t.filter(l=>Object.hasOwn(l.files,e.path)&&l.sources.some(d=>d.unitKey===n&&d.sourcePath===e.path)&&typeof o[e.path]=="string"&&l.files[e.path].startsWith(o[e.path]));if(!s.length)return!0;let{excerpt:r,line:i}=e,a=Object.hasOwn(o,e.path)?o[e.path]:void 0;if(!r||i===null||typeof a!="string")return!1;let c=oi(a,r,i);return c?s.some(l=>{let d=l.files[e.path];return typeof d!="string"||!d.startsWith(a)?!1:l.sources.some(p=>p.unitKey!==n||p.sourcePath!==e.path?!1:p.kind==="prompt"?c.every(u=>u.from>=p.sourceLine&&u.to<=(p.sourceEndLine??p.sourceLine)):c.some(u=>u.from<=p.sourceLine&&u.to>=p.sourceLine))}):!1}var Op={"too-large":"File is too large.",allowance:"File allowance reached.",total:"Import allowance reached.","scan-limit":"Scan allowance reached.","tool-limit":"Tool file limit reached.",missing:"Source file is missing.",unreadable:"Source file could not be read."};function fs(e){let t={files:{},sources:[],skipped:[]},{agent:n,files:o,allowance:s}=e;if(!e.enabled||!n.codeInputsJson)return t;let r=new Set(s.skipped.map(({path:p})=>p)),i=s.paths.filter(p=>!r.has(p)),a=new Set(i),c=(p,u)=>{t.skipped.some(g=>g.path===p&&g.reason===u)||t.skipped.push({path:p,reason:u})};s.skipped.forEach(({path:p,reason:u})=>{let g=Op[u];g&&c(p,g)});let l=(p,u)=>{let{sourcePath:g,sourceLine:h}=p;if(r.has(g))return!1;if(!a.has(g))return c(g,"File was not admitted for this agent."),!1;let f=Object.hasOwn(o,g)?o[g]:void 0;return typeof f!="string"?(c(g,"Source file is missing."),!1):!Number.isInteger(h)||h<1||h>f.split(`
|
|
2
2
|
`).length?(c(g,"Source line is missing or stale."),!1):p.name.trim()?(t.files[g]=f,t.sources.some(m=>m.kind===u&&m.name===p.name&&m.sourcePath===g&&m.sourceLine===h)||t.sources.push({...p,unitKey:n.unitKey,kind:u}),!0):(c(g,"Source name is missing."),!1)},d=new Set((n.toolsJson??[]).map(({name:p})=>p));for(let p of n.codeInputsJson.tools){if(!d.has(p.name)||!l(p,"tool"))continue;let u=Ti([p.name],i,o,i);u.length||c(p.sourcePath,`Tool implementation was not admitted or found: ${p.name}.`);for(let g of u){let h=Mi([p.name],[g],o);h.length||c(g,"Tool implementation is missing."),h.forEach(f=>l(f,"tool"))}}if(n.codeInputsJson.contextInputs.forEach(p=>l(p,"context")),n.site){let{path:p,span:u}=n.site,g=Object.hasOwn(o,p)?o[p]:void 0;Number.isInteger(u.to)&&u.to>=u.from&&(typeof g!="string"||u.to<=g.split(`
|
|
3
3
|
`).length)?l({name:n.unitKey,sourcePath:p,sourceLine:u.from,sourceEndLine:u.to},"prompt"):c(p,"Prompt source lines are missing or stale.")}return t}function Vn(e){let t=e.qualityConfig?.switches.codeInputs?(e.codeEvidence??[]).filter(s=>s.enabled):[];if(!t.length)return{scopes:t,sources:[],files:[]};let n=t.flatMap(s=>ae(s.inputs,s.files).sources),o=[...new Map(t.flatMap(s=>s.inputs.flatMap(r=>Object.entries(r.files).flatMap(([i,a])=>{let c=Object.hasOwn(s.files,i)?s.files[i]:void 0;return c!==void 0&&a.startsWith(c)?[{repo:s.repo,path:i,text:Le(c),truncated:c!==a}]:[]}))).map(s=>[JSON.stringify([s.repo,s.path,s.text]),s])).values()];return{scopes:t,sources:n,files:o}}var Ie=A.chat,B=8,Z=1,Jn=40,we=6e4,ye=16e3,Ct=8e4,K=4e3,Cp=1536,us=8192,ms=1024;function Ke(e){return us+e*Cp+ms}function tt(e,t="legacy"){return t==="whole-file"?we+Ct+K*e+4e3*4:we+(ye+K)*e+4e3*2}function yu(e,t,n,o,s="legacy"){if(!n||t===0)return null;let r=Math.ceil(t/B),i=1+Z,a=Ke(t)+(us+ms)*(r-1),c={template:o};if(s==="whole-file"){let d=Math.floor(t/B),p=t%B,u=re(tt(B,s))*d+(p?re(tt(p,s)):0);return le(e,c,"Double-check findings",Ie,u*i,a*i)}let l=we*r+(ye+K)*t;return le(e,c,"Double-check findings",Ie,(re(l)+4e3*r)*i,a*i)}function pe(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 Qn(e,t={}){let n=Number(e.CF_PASS_CONCURRENCY??(t.forLocal?4:3));return{enabled:e.CF_PARALLEL_PASSES!=="0",concurrency:t.passConcurrency??(Number.isSafeInteger(n)&&n>0?n:3)}}function ee(e,t){let n=t.analysisFlags;return n?{...n,findingCheck:n.findingCheck??pe(e).findingCheck,sourceNotes:n.sourceNotes??!1}:{...pe(e),sourceNotes:!1}}function Yn(e,t){let n=e.CF_FINDING_QUALITY==="1",o=n&&e.CF_FINDING_FULL_CONTEXT==="1",s=n&&e.CF_FINDING_PRECISION_RULES==="1",r=t?.check.name??(s?"check-findings-precision-v1":"check-findings");return{enabled:n,fullContext:o,precisionRules:s,prompts:{derive:t?.derive.name??"derive-findings-legacy",check:r==="check-findings-legacy"?"check-findings":r}}}function gs(e){return Yn({},e.prompts).prompts}function hs(e,t,{enabled:n,prompts:o}){return vi(e,t,n?o[e]:void 0)}function nt(e,t,n){return hs(e,t,{enabled:n?.switches.enabled??!1,prompts:Yn({},n?.prompts).prompts})}function ea(e,t,n,o){let s=pe(e),r=Yn(e),{fullContext:i}=r,a=hs("derive",e,r),c=hs("check",e,r),l=i?"whole-file":"legacy";return{findings:n,derive:q(e,a,"findings",A.generate,t,o),check:s.findingCheck?q(e,c,"check",Ie,Math.ceil(n/B)*(Z+1),Math.max(o,tt(B,l)),Ke(B)):null}}function ta(e){if(e&&typeof e=="object"){for(let t of Object.values(e))ta(t);Object.freeze(e)}return e}function Pu(e,t,n={}){let{enabled:o,fullContext:s,precisionRules:r,prompts:i}=Yn(e),a=w=>o&&e[w]==="1",c=a("CF_FINDING_SECOND_OPINION"),l=a("CF_FINDING_RANKING"),d=o&&e.CF_FINDING_SEMANTIC_MATCHING!=="0",p=n.codeInputs!==!1&&o&&e.CF_FINDING_CODE_INPUTS!=="0",u=[],g=e.CF_FINDING_RECALL_VARIANT,h=n.recall!==!1&&a("CF_FINDING_RECALL")&&(g==="request-18"||g==="two-sweeps")?g:"off";n.recall!==!1&&a("CF_FINDING_RECALL")&&h==="off"&&u.push("Recall was skipped: no supported variant was selected.");let f=null,m=null;if(n.recall===!1&&e.CF_FINDING_RECALL==="1"&&u.push("Recall isn't available in local checks yet, so CF_FINDING_RECALL has no effect."),n.codeInputs===!1&&e.CF_FINDING_CODE_INPUTS==="1"&&u.push("Code evidence isn't available in local checks yet, so CF_FINDING_CODE_INPUTS has no effect."),c&&n.secondOpinion===!1&&u.push("Second opinion was skipped: local analysis supports Anthropic only."),c&&n.secondOpinion!==!1){let w=e.CF_FINDING_SECOND_OPINION_MODEL??"",v=Object.hasOwn(An,w)?An[w]:void 0,S=An[Ie];v&&v.provider===e.CF_FINDING_SECOND_OPINION_PROVIDER&&v.provider!==S.provider&&v.input<=S.input&&v.output<=S.output&&(v.input<S.input||v.output<S.output)?(f=w,m=v.provider):u.push("Second opinion was skipped: configure a priced, cheaper model from a different provider.")}return ta({ruleVersion:o?"precision-v1":"legacy",switches:{enabled:o,fullContext:s,precisionRules:r,secondOpinion:c,ranking:l,semanticMatching:d,codeInputs:p,recall:h!=="off"},prompts:{derive:t.promptVersion(i.derive,e),check:t.promptVersion(i.check,e)},models:{derive:A.generate,check:Ie,scope:A.mechanical,secondOpinion:f},caps:{coreBytes:we,siteBytes:ye,findingTextBytes:K,siteWindowLines:Jn,citedBatchBytes:s?8e4:0,passBytes:15e4,passContextBytes:6e4,maxPasses:4,passFindings:h==="request-18"?18:wt,totalFindings:24,deriveOutputTokens:Oi,checkBatchSize:B,checkOutputTokens:Ke(B),checkMaxRetries:Z,checkOverheadTokens:4e3,secondOpinionBatchSize:4,secondOpinionInputBytes:tt(4)+(s?8e4:0),secondOpinionOutputTokens:2048,secondOpinionMaxRetries:Z},recallVariant:h,displayPolicyVersion:l?"support-v1":"legacy",meaningMatchingVersion:d?"meaning-v1":"legacy",codeInputScopeVersion:p?"owned-code-v1":"legacy",secondOpinionProvider:m,diagnostics:u})}function _t(e,t,n={}){let o=gs(e);e.switches.enabled&&t.assertPromptVersions([{...e.prompts.derive,name:o.derive},{...e.prompts.check,name:o.check}],n)}function Se(e,t,n,o){return{tools:t,rethrow(s){n?.(s),fe(s)},available:e!==null,settleStartedOnError:e?.settleStartedOnError,withRetry:s=>Se(e?Qi(e,s):null,t,n,o),async execute(s,r={}){if(o&&(r={...r,signal:r.signal?AbortSignal.any([o,r.signal]):o}),r.signal?.throwIfAborted(),!e)throw new Error("model unavailable");return"execute"in e?e.execute(s,r):Ji(e,t,s,r)}}}function M(e,t,n={},o={}){return e.execute(bi(t,n,o.maxInputBytes),o)}async function qe(e){return e.requestTools?e.requestTools():Vi(Xi(await e.instructions()))}var cn=2,_p=10*6e4;function Zn(e,t,n){return new ce("llm",`The model could not read part ${e+1} of ${t} of this agent after ${n} tries, so this analysis stopped. Nothing from this run is saved; starting a new analysis reads every part again.`)}async function na(e){let{data:t,plan:n,progress:o}=e,s=n.passes.length,r={...t.passResults};if(!t.passResults){for(let d=0;d<(t.passCursor??0);d++)r[d]={findings:t.passFindings?.[d],retries:0};t.passRetries&&(r[t.passCursor??0]={retries:t.passRetries})}await o.checkpoint({inspectPlan:n,passResults:r});let i={...t,inspectPlan:n,passResults:r},a=n.passes.map((d,p)=>p).filter(d=>r[d]?.findings===void 0);for(let d of a)if((r[d]?.retries??0)>cn)throw Zn(d,s,r[d].retries);let c;if(await H(e.onePartPerStep?a.slice(0,1):a,e.concurrency,async d=>{let p=o.elapsedMs();try{if((typeof p=="number"?p:await p)>=_p||c)return;let u=r[d]?.retries??0;for(;!c;){o.assertHeld(),o.signal?.throwIfAborted();let g;try{g=await e.run(d,u)}catch(f){if(o.rethrow?.(f),fe(f),e.forLocal)throw f instanceof ce?f:new Error("A findings reading pass failed; no completed report was written.");u++,o.log({level:"warn",code:"analysis.pass_failed",counts:{part:d+1,parts:s,retries:u}});let m={retries:u};if(await o.checkpoint({},{index:d,result:m}),r[d]=m,u>cn)throw Zn(d,s,u);if(e.onePartPerStep)break;await new Promise(w=>setTimeout(w,1e3));continue}let h={findings:g,retries:u};await o.checkpoint({},{index:d,result:h}),r[d]=h;break}}catch(u){c??=u}}),c)throw c;let l=n.passes.every((d,p)=>r[p]?.findings!==void 0);return{...i,...l?{passCursor:s,passRetries:0,passFindings:n.passes.map((d,p)=>r[p].findings)}:{}}}var eo={critical:0,high:1,medium:2,low:3},sa=e=>(e.line??0)>0,to=e=>sa(e)&&!!e.excerpt?.trim();function ks(e,t){let n=i=>{let a=Ln(i);return[a.filter(to).length,a.filter(sa).length,Number(!!i.site&&to({...i.site,excerpt:i.excerpt}))]},[o,s]=[n(e),n(t)],r=o.findIndex((i,a)=>i!==s[a]);return r>=0&&o[r]>s[r]}function ws(e,t){let n=ni(t.map(r=>r.audience)),o=ri(t);if(o===void 0&&!Object.hasOwn(e,"activity"))return n===e.audience?e:{...e,audience:n};let s={...e};return delete s.activity,{...s,...n===void 0?{}:{audience:n},...o===void 0?{}:{activity:o}}}function oa(e,t,n={}){let o=[];if(n.semanticMatching)for(let s of e){let r=Zr({previous:o.map((i,a)=>Qo(i,String(a))),current:s.map((i,a)=>Qo(i,String(a))),enabled:!0});for(let i of r.matches){let a=Number(i.previousId),c=s[Number(i.currentId)];o[a]=ws(ks(c,o[a])?c:o[a],[o[a],c])}for(let i of r.unmatchedCurrent)o.push(s[Number(i.id)])}else for(let s of e.flat()){let r=o.findIndex(i=>ei(i,s));r<0?o.push(s):o[r]=ws(ks(s,o[r])?s:o[r],[o[r],s])}return o.sort((s,r)=>eo[s.severity]-eo[r.severity]).slice(0,t)}function Ep(e,t){let n=eo[e.severity]-eo[t.severity];if(n)return n<0;let o=Ln(e).filter(to).length-Ln(t).filter(to).length;return o?o>0:ks(e,t)}function ra(e,t={}){let n=t.deferCap?1/0:24;if(t.dedupe===!1)return e.length<2?e[0]??[]:oa(e,n,t);let o=e.length<2?e[0]??[]:oa(e,1/0,t),s=o.map((c,l)=>o.map((d,p)=>l===p||ti(c,d))),r=new Set,i=new Map;for(let c=0;c<o.length;c++){if(r.has(c))continue;let l=[c];r.add(c);for(let p=0;p<l.length;p++)for(let u=0;u<o.length;u++)r.has(u)||!s[l[p]][u]||(r.add(u),l.push(u));if(!l.every(p=>l.every(u=>s[p][u]))){for(let p of l)i.set(p,o[p]);continue}let d=l.reduce((p,u)=>Ep(o[u],o[p])?u:p,c);i.set(c,ws(o[d],l.map(p=>o[p])))}let a=i.size===o.length?o:o.flatMap((c,l)=>i.has(l)?[i.get(l)]:[]);return e.length<2?a:a.slice(0,n)}var ia=e=>e.CF_FINDING_DEDUPE!=="0";var $p=15*6e4;async function aa(e,t){let n=new AbortController,o={...e,execute:(i,a={})=>e.execute(i,{...a,signal:a.signal?AbortSignal.any([a.signal,n.signal]):n.signal})},s,r=new Promise((i,a)=>{s=setTimeout(()=>{let c=new ce("llm","The reading part's model call timed out.");a(c),n.abort(c)},$p)});try{return await Promise.race([Promise.resolve().then(()=>t(o)),r])}finally{clearTimeout(s)}}var Ip=A.generate;function Rp(e,t){let n=t.qualityConfig;return{template:nt("derive",e,n),inputs:{maxFindings:String(wt),graph:JSON.stringify(t.graph,null,2),pass:t.pass??null,codeSources:t.codeSources??[],files:Object.entries(t.files).map(([s,r])=>({path:s,text:Le(r)}))},answerFormat:"findings",model:n?.switches.enabled?n.models.derive:Ip,limits:{effort:"high"}}}async function ca(e,t,n){n.qualityConfig&&_t(n.qualityConfig,t.tools,e);let o=await M(t,Rp(e,n),e);return xi({...o,findings:si(o.findings,n.files,e,n.activitySnapshot,n.activitySnapshotComplete)})}function la(e,t,n){return e.flatMap(o=>{let s=o.site?{path:o.site.path,line:o.site.line,excerpt:o.excerpt}:null,r=[...s?[s]:[],...o.otherSites??[]].filter(l=>t.has(l.path));if(!r.some(l=>n.has(l.path)))return[];let i=o.site&&r[0]===s?0:Math.max(0,r.findIndex(l=>(l.line??0)>0)),a=r[i],c=r.filter((l,d)=>d!==i);return[{...o,site:{path:a.path,line:a.line},excerpt:a.excerpt,otherSites:c}]})}function Pe(e){let t=[],n=[],o=new Set;for(let s of e)for(let[r,i]of Object.entries(s.files??{})){if(o.has(r)){n.push({repo:s.key,path:r});continue}o.add(r),t.push({repo:s.key,path:r,text:i})}return{all:t,shadowed:n}}function Et(e){return Object.fromEntries(Pe(e).all.map(t=>[t.path,t.text]))}function $t(e,t){return Ei(e)===void 0?void 0:t}function Pp(e,t){return Object.keys(t).filter(n=>z(n,{nested:!0})).sort().map(n=>{let o=n.split("/").slice(-2,-1)[0]??"skill",{name:s,description:r}=vt(e,`${o}.md`,t[n]);return{name:s,description:r??""}})}function pa(e,t,n,o,s,r,i){let a=$t(e,o);if(a){let f=t.passes[n].own;return{files:Object.fromEntries(f.map(m=>[m,a[m]])),read:f,own:f,...t.passes.length>1?{pass:{part:n+1,count:t.passes.length,own:f,context:[],skills:[]}}:{}}}o=se(e,o,s);let c=new Set(t.core),l=n===0?[...t.core,...t.passes[0].own]:t.passes[n].own,d=[...t.core,...t.passes[n].own,...t.passes.length>1?t.passes[n].context??[]:[]],p=je(e,{paths:Object.keys(o),files:o,graph:s,repos:i}),u=Ve(d.map(f=>({repo:"",path:f,text:c.has(f)?me(o[f]):o[f]})),c,Ne(s),p),g=Object.fromEntries(u.map(f=>[f.path,f.text])),h=r?.enabled?ae(r.inputs.map(f=>({...f,files:se(e,f.files,s)})),g):void 0;return{files:g,...t.passes.length>1?{pass:{part:n+1,count:t.passes.length,own:l,context:t.passes[n].context??[],skills:Pp(e,o)}}:{},read:u.map(f=>f.path),own:l,...h?{codeSources:h.sources,codeSkipped:h.skipped}:{}}}function da(e){return e.find(t=>!t.notFoundAt)??e[0]??null}function Ap(e,t){return t.startsWith(`${e}#`)?t.slice(e.length+1):null}function Fp(e,t){let n=[];for(let o of e?.nodes??[]){let s=o.kind==="agent"?t?Ap(t,o.id):o.id.slice(o.id.indexOf("#")+1):null;s!==null&&n.push({node:o,unitId:s})}return n}function Mp(e,t,n){if(n==null)return e[0];let o=e.flatMap(i=>(i.node.files??[]).flatMap(a=>(a.role==="system prompt"||a.role==="knowledge")&&a.path===t&&a.span?[{c:i,span:a.span}]:[])),s=o.find(i=>i.span&&i.span.from<=n&&n<=i.span.to);if(s)return s.c;let r=null;for(let i of o)i.span&&i.span.to<n&&(!r||i.span.to>r.to)&&(r={c:i.c,to:i.span.to});return r?.c??e[0]}function fa(e,t){return!e.file||!e.excerpt?[]:[...new Set(t.flatMap(n=>n.sources.filter(o=>o.kind!=="prompt"&&o.sourcePath===e.file&&Object.hasOwn(n.files,e.file)&&on({path:e.file,line:e.line??null,excerpt:e.excerpt},[{...n,sources:[o]}],o.unitKey,n.files)).map(o=>o.unitKey)))]}function Tp(e,t,n,o){let s=fa(e,n);if(s.length)return{unitKey:s.length===1?s[0]:null,anchors:s,code:!0};let r=e.file?Fp(t,e.repo??"").filter(i=>i.node.files?.some(a=>a.path===e.file)):[];return{unitKey:r.length?Mp(r,e.file,e.line).unitId:o,anchors:s,code:!1}}function no(e,t,n,o){let s=e[0];if(!s)return!0;let r=n.map(d=>({...d,input:{...d.input,files:Object.fromEntries(Object.entries(d.input.files).filter(([p,u])=>typeof d.files[p]=="string"&&u.startsWith(d.files[p])))}})),i=d=>r.filter(p=>!d.repo||!p.repo||p.repo===d.repo),a=i(s),c=Np(s,t,a.map(d=>d.input),o,{savedRepoPaths:!0});if(!c.unitKey&&!c.code)return!0;let l=c.unitKey?[c.unitKey]:c.anchors;return e.every(d=>{let p=i(d).filter(g=>!s.repo||!g.repo||g.repo===s.repo),u=c.unitKey?[]:fa(d,p.map(g=>g.input));return l.every(g=>(!u.length||u.includes(g))&&p.filter(h=>h.unitKey===g).every(h=>on({path:d.file??"",line:d.line??null,excerpt:d.excerpt??null},[h.input],g,h.files)))})}function ua(e,t,n=!1){let o=n?Lr:Tr,s=t?e.filter(r=>r.repoPath&&o(r.repoPath)===t):[];return{rows:s,unitRows:s.filter(r=>r.unitKey)}}function Lp(e,t,n={}){let{rows:o,unitRows:s}=ua(e,t,n.savedRepoPaths);return da(s)?.id??o[0]?.id??(e.length===1?e[0].id:null)}function Np(e,t,n,o,s){let r=o?Lp(o,e.repo,s):null,i=o?.find(d=>d.id===r)?.unitKey??null,{unitRows:a}=ua(o??[],e.repo,s.savedRepoPaths);if(o&&(!e.repo||!a.length))return{unitKey:i,anchors:[],code:!1,agentId:r};let c=Tp(e,t,n,i);if(!o)return{...c,agentId:null};let l=a.find(d=>d.unitKey===c.unitKey);return{...c,unitKey:c.code?c.unitKey:l?.unitKey??i,agentId:c.unitKey?l?.id??(c.code?null:r):null}}async function ys(e,t){let n=pa(e,t.plan,t.index,t.files,t.reading,t.codeEvidence,t.repos),o=await aa(t.llm,i=>ca(e,i,{graph:t.graph,...n,activitySnapshot:t.repos.length?t.repos.flatMap(a=>Object.values(a.files??{})):Object.values(t.files),activitySnapshotComplete:!t.plan.skipped.length&&!t.repos.some(a=>a.refused?.length),qualityConfig:t.qualityConfig})),s=la(o,new Set(n.read),new Set(n.own));if(!t.codeEvidence?.enabled)return s;let r=t.codeEvidence.inputs.flatMap(i=>i.unitKey?[{repo:i.repo,unitKey:i.unitKey,input:i,files:n.files}]:[...new Set(i.sources.map(a=>a.unitKey))].map(a=>({repo:i.repo,unitKey:a,input:i,files:n.files})));return s.filter(i=>no([...i.site?[{...i.site,excerpt:i.excerpt}]:[],...i.otherSites??[]].map(a=>({repo:t.codeEvidence?.repoByPath?.[a.path]??null,file:a.path,line:a.line,excerpt:a.excerpt})),t.graph,r,t.codeEvidence?.agentRows))}function oo(e,t,n=15e4,o,s,r){let{all:i,shadowed:a}=Pe(e),c=$t(r,Object.fromEntries(i.map(k=>[k.path,k.text])));if(c)return{files:c,skipped:[],readByRepo:Object.fromEntries(e.map(k=>[k.key,Object.keys(k.files??{})])),shadowed:a,warnings:[]};let l=se(r,Object.fromEntries(i.map(k=>[k.path,k.text])),t),d=i.map(k=>({...k,text:l[k.path]})),p=o??Q(t),u={},g=[],h={},f=0,m=je(r,{paths:d.map(k=>k.path),files:l,graph:t,repos:e});for(let k of Ve(d,p,Ne(t),m)){if(!p.has(k.path)&&f+k.text.length>n){g.push(k.path);continue}let b=p.has(k.path)?me(k.text):k.text;u[k.path]=b,(h[k.repo]??=[]).push(k.path),f+=b.length}let w=jp(u,p),v=[...w>n?[`The agent's core files (${Math.round(w/1e3)} KB) are larger than one reading pass, so they were read in full and nothing else was read`]:[],...[qn(p,l)].filter(k=>!!k)],S=Gt(m,g.map(k=>({path:k,reason:"total"})));S&&v.push(S);let y=s?.enabled?ae(s.inputs.map(k=>({...k,files:se(r,k.files,t)})),u):void 0;return{files:u,skipped:g,readByRepo:h,shadowed:a,warnings:[...v,...y?.warnings??[]],...y?{codeSources:y.sources,codeSkipped:y.skipped}:{}}}var jp=(e,t)=>Object.entries(e).reduce((n,[o,s])=>n+(t.has(o)?s.length:0),0);import{posix as ga}from"node:path";var Dp=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Bp=(e,t)=>new RegExp(`(?<![\\w-])${Dp(t)}(?![\\w-])`).test(e);function ot(e,t){return t.name!==null&&Bp(e,t.name)||$e(t.paths,[e],n=>n).length>0}function ma(e,t){let n=e.map(a=>a.paths.map(c=>t[c]).join(`
|
|
4
4
|
`)),o=(a,c)=>ot(n[a],e[c]),s=e.map(()=>new Set);for(let a=0;a<e.length;a++)for(let c=a+1;c<e.length;c++)(o(a,c)||o(c,a))&&(s[a].add(c),s[c].add(a));let r=new Set,i=[];for(let a=0;a<e.length;a++){if(r.has(a))continue;let c=[],l=[a];r.add(a);for(let d=l.shift();d!==void 0;d=l.shift()){c.push(d);for(let p of s[d])r.has(p)||(r.add(p),l.push(p))}c.sort((d,p)=>d-p),i.push({bundles:c.map(d=>e[d]),bytes:c.reduce((d,p)=>d+e[p].bytes,0),adjacent:Object.fromEntries(c.map(d=>[e[d].key,[...s[d]].map(p=>e[p].key).sort()]))})}return i.sort((a,c)=>c.bytes-a.bytes||(a.bundles[0].key<c.bundles[0].key?-1:1))}function ha(e){let t=new Map(e.bundles.map(r=>[r.key,r])),n=new Set,o=r=>e.adjacent[r.key].filter(i=>n.has(i)).length,s=[];for(;t.size>0;){let r=[...t.values()].sort((i,a)=>o(a)-o(i)||e.adjacent[a.key].length-e.adjacent[i.key].length||a.bytes-i.bytes||(i.key<a.key?-1:1))[0];t.delete(r.key),n.add(r.key),s.push(r)}return s}function ka(e,t,n,o,s){if(e.length<2)return{passes:e};let r=new Set(e.flatMap(l=>l.own)),i=[...r].filter(l=>/\.md$/i.test(l)).sort(),a=l=>[...new Set([...$e(i,[n[l]],d=>d),...$e(i,[n[l]],d=>ga.relative(ga.dirname(l),d))])];return{passes:e.map(l=>{let d=new Set([...t,...l.own]),p=new Map,u=new Set;for(let m of l.own){let w=new Set;for(let S of o)if(ot(n[m],S))for(let y of S.paths.filter(k=>z(k,{nested:!0})))w.add(y);for(let S of a(m))w.add(S);for(let S of[...w].filter(y=>z(y,{nested:!0})))for(let y of a(S))w.add(y);for(let S of w)u.add(S);let v=[...w];for(let S=0;S<v.length;S++){let y=v[S];for(let k of a(y))w.has(k)||(w.add(k),v.push(k))}for(let S of w)r.has(S)&&!d.has(S)&&p.set(S,(p.get(S)??0)+1)}let g=[...p.keys()].sort((m,w)=>Number(u.has(w))-Number(u.has(m))||p.get(w)-p.get(m)||(m<w?-1:1)),h=[],f=0;for(let m of g){let w=n[m].length;f+w<=s&&(h.push(m),f+=w)}return{own:l.own,context:h.sort()}})}}import{basename as wa}from"node:path";function Ss(e,t,n,o){let s=[...n].sort();return{key:e,name:t,paths:s,bytes:s.reduce((r,i)=>r+o[i].length,0)}}function ya(e,t){let n=Q(t),o=new Set(Object.keys(e).filter(c=>!n.has(c))),s=[],r=c=>c.filter(l=>o.delete(l)),i=new Set(t.edges.filter(c=>c.kind==="delegates").map(c=>c.to));for(let c of t.nodes){if(!i.has(c.id)||!c.sourceRef)continue;let l=c.sourceRef.path.replace(/\.md$/i,"")+"/",d=(c.files??[]).filter(h=>h.role==="skill").map(h=>Dt(h.path,{nested:!0})?.folder).filter(h=>!!h),p=[...o].filter(h=>h.startsWith(l)||d.some(f=>h.startsWith(f+"/"))),u=(c.files??[]).filter(h=>h.role==="reference"||h.role==="skill").map(h=>h.path),g=r([...p,...u]);g.length&&s.push(Ss(l,wa(l),g,e))}let a=new Map;for(let c of o){let l=Dt(c,{nested:!0})?.folder;l&&a.set(l,[...a.get(l)??[],c])}for(let[c,l]of a)s.push(Ss(c,wa(c),r(l),e));for(let c of o)s.push(Ss(c,null,[c],e));return s.sort((c,l)=>c.key<l.key?-1:c.key>l.key?1:0)}var Kp=(e,t)=>e.reduce((n,o)=>n+t[o].length,0);function Sa(e,t,n,o){let s=n-t;return e<=n||s<=0?1:Math.min(o,Math.ceil((e-t)/s))}function qp(e,t,n){return e.bytes<=t?[e.bundles]:ha(e).flatMap(o=>o.bytes<=t?[o]:o.paths.map(s=>({key:s,name:null,paths:[s],bytes:n[s].length}))).map(o=>[o])}function Hp(e,t){let n=e.split("/").slice(0,-1);for(let o=n.length;o>0;o--){let s=n.slice(0,o).join("/"),r=t.find(i=>i.own.some(a=>a.startsWith(`${s}/`)));if(r)return r}}function xa(e){e={...e,files:se(e.settings,e.files,e.graph)};let{passMaxBytes:t,maxPasses:n,graph:o}=e,s=Q(o),r=Object.keys(e.files).filter(x=>s.has(x)).sort(),i=Object.fromEntries(Object.entries(e.files).map(([x,C])=>[x,s.has(x)?me(C):C])),a=t-Kp(r,i),c=Object.keys(i).filter(x=>!s.has(x)),l=je(e.settings,{paths:Object.keys(i),graph:o,files:i,repos:e.repos}),d=Ne(o),p=Yo(c.filter(x=>Si(l,x)),i,d,l),u=new Set(p),g=new Set(o.nodes.flatMap(x=>(x.files??[]).map(C=>C.path))),h=Object.fromEntries(c.filter(x=>!u.has(x)).map(x=>[x,i[x]])),f=ya(h,o),m=x=>x.name!==null||kt(x.paths[0])&&g.has(x.paths[0]),w=f.filter(x=>!m(x)).flatMap(x=>x.paths),v=[qn(r,e.files)].filter(x=>!!x),S=[],y=[];if(a<=0){v.push("The agent's core files fill a whole reading pass, so nothing else was read");let x=Gt(l,c.map(C=>({path:C,reason:"total"})));return x&&v.push(x),{core:r,passes:[{own:[]}],skipped:[...c].sort(),warnings:v}}for(let x of p){let C=i[x].length,E=y.find(I=>I.bytes+C<=a);!E&&C<=a&&y.length<n&&(E={own:[],bytes:0},y.push(E)),E?(E.own.push(x),E.bytes+=C):S.push(x)}let k=new Set(y);for(let x of ma(f.filter(m),h)){let C=x.bytes>a,E;for(let I of qp(x,a,i)){let R=I.reduce((U,Bo)=>U+Bo.bytes,0),P=I.flatMap(U=>U.paths),N=(C&&E&&E.bytes+R<=a?E:void 0)??y.find(U=>(!C||k.has(U))&&U.bytes+R<=a);N?(C&&(E=N),N.own.push(...P),N.bytes+=R):R>a||y.length>=n?S.push(...P):(E={own:[...P],bytes:R},y.push(E))}}y.length===0&&y.push({own:[],bytes:0});let b=Yo(w,i,d,l);for(let x of b){let C=R=>R.bytes+i[x].length<=a,E=Hp(x,y),I=E&&C(E)?E:y.find(C);if(!I){S.push(x);continue}I.own.push(x),I.bytes+=i[x].length}let O=y.map(x=>({own:x.own.sort()})),_=Gt(l,S.map(x=>({path:x,reason:"total"})));_&&v.push(_);let $=ka(O,r,e.files,f,e.contextMaxBytes??6e4);return{core:r,passes:$.passes,skipped:S.sort(),warnings:v}}function He(e){let t=(n,o)=>`${n}#${o}`;return{nodes:e.flatMap(({repoKey:n,fragment:o})=>o.nodes.map(s=>({id:t(n,s.id),sourceRef:s.sourceRef,files:s.files}))),edges:e.flatMap(({repoKey:n,fragment:o})=>o.edges.map(s=>({from:t(n,s.from),to:t(n,s.to),kind:s.kind,sourceRef:s.sourceRef})))}}import{createHash as Ga}from"node:crypto";import{basename as rd}from"node:path";function It(e,t){return{...e.filenameReferences?{filenameReferences:e.filenameReferences}:{},agents:e.strong.map(n=>({candidate:n,confirmedBy:null})),possible:e.possible,rejected:[],unchecked:[],callsWithoutPrompt:e.callsWithoutPrompt,repoModelIds:e.repoModelIds,scanned:e.scanned,total:t.total,truncated:t.truncated,omitted:e.omitted??{strong:0,possible:0},notRead:e.notRead??[],notReadMore:e.notReadMore??0,...e.skippedFiles?{skippedFiles:e.skippedFiles}:{}}}import{createHash as Up}from"node:crypto";function ba(e,t,n){let o=[e,t.prompt.path,t.prompt.symbol??"",n,t.link?.callExcerpt??""];return Up("sha256").update(o.join("\0")).digest("hex")}var Gp=200,Wp=6e3,Xp=1200,zp=[3,4,5],so=e=>zp.includes(e.score)&&e.prompt.chars>=Gp,Vp=5;function Jp(e,t){let n=e.link,o=n?t[n.callPath]:void 0;if(!n||o===void 0)return null;let s=Math.max(0,n.callLine-1-Vp);return o.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as e}from"./34NVU26H.js";import{z as t}from"zod";var o=t.lazy(()=>t.union([t.string(),t.number(),t.boolean(),t.null(),t.array(o),t.record(t.string(),o)])),n=t.object({data:t.record(t.string(),o),settings:e,maxInputBytes:t.number().int().positive().optional()}).strict(),i=t.string().min(1).max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/),r=t.object({maxTokens:t.number().int().positive().optional(),effort:t.enum(["low","medium","high","max"]).optional(),thinking:t.literal("disabled").optional(),promptCache:t.boolean().optional()}).strict(),m=t.object({template:t.string().min(1),inputs:n,answerFormat:t.string().min(1),model:i,limits:r.optional()}).strict();export{n as a,i as b,r as c,m as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./PBHHWFR6.js";import{C as p}from"./
|
|
1
|
+
import{a}from"./PBHHWFR6.js";import{C as p}from"./P253B344.js";import{a as y}from"./MKYLK6DB.js";import{posix as d}from"node:path";var m=Object.freeze({totalLimitBytes:y.codeAgent.importBytes,instructionLimitBytes:y.sourceFetch.instructionBytes}),A=["totalBytes","instructionBytes","fileCount"],u=()=>new Error("Invalid analysis size"),z=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function g(e){let i=a(e);return i.totalBytes>m.totalLimitBytes?{fits:!1,measure:"total_text"}:i.instructionBytes>m.instructionLimitBytes?{fits:!1,measure:"instruction_text"}:{fits:!0,measure:null}}function v(e,i,n={}){return h(e,i,n,!1)}function b(e,i,n={}){return h(e,i,n,!0)}function h(e,i,n,c){let f=new Map;for(let t of i){if(!z(t.size)||typeof t.path!="string"||!t.path||t.path.includes("\0"))throw u();let s=d.normalize(t.path.replace(/\\/g,"/"));if(s==="."||s===".."||s.startsWith("../")||s.startsWith("/"))throw u();let r=f.get(s);if(r&&r.size!==t.size)throw u();f.set(s,{path:s,size:t.size,ref:s})}let S=[...f.values()],{descriptions:B}=p(e,S,n,{measureAnalysisSize:!0,measureAnalysisSizeLowerBound:c}),l=n.paths?new Set(n.paths):void 0,o={totalBytes:0,instructionBytes:0,fileCount:0};for(let t of B){if(!(c?t.countsTowardAnalysisSizeWithoutInventory:t.countsTowardAnalysisSize)||l&&!l.has(t.entry.path))continue;let{entry:s}=t;if(o.totalBytes+=s.size,(c?t.countsTowardInstructionSizeWithoutInventory:t.analysisPool==="instruction")&&(o.instructionBytes+=s.size),o.fileCount+=1,!A.every(r=>z(o[r])))throw u()}return a(o)}export{m as a,g as b,v as c,b as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{j as t}from"./34NVU26H.js";function E(e){return e.CF_FILE_SCOPE==="1"&&e.CF_LOCAL_IMPORT_RESOLUTION!=="0"}function F(e){return E(e)&&e.CF_SCOPE_CHOICES!=="0"&&e.CF_MULTI_ENTRY!=="0"}function u(e){return e.CF_FINDING_HEADLINES==="1"}function i(e){return e.CF_RESULT_SAFETY_CHECK==="1"}function S(e){return e.CF_IMPORT_OUTSIDE_LOADERS==="1"}function f(e){return e.CF_PROMPT_AGREE==="1"}function I(e){return t(e,"saved")}function C(e){return e.CF_SKIPPED_FILES!=="0"}function l(e){return e.CF_FOLDER_PARTS==="1"&&C(e)}function L(e,r){let _=Object.fromEntries(Object.entries(t(r,"request")).filter(([n])=>/^(?:CF_FINDING_|CF_READING_|CF_RECALL_|CF_MULTI_PASS$|CF_SPLIT_CHECK$|CF_SOURCE_NOTES$|CF_PARALLEL_|CF_PASS_CONCURRENCY$|CF_PROMPT_AGREE$)/.test(n)&&n!=="CF_FINDING_AUDIENCE"));return Object.freeze({...e,..._,CF_PART_FILES:void 0})}export{E as a,F as b,u as c,i as d,S as e,f,I as g,C as h,l as i,L as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as m}from"./
|
|
1
|
+
import{b as a,c as m}from"./VX6LYNXV.js";import{a as u}from"./MJGB25S5.js";import{d}from"./TA2NIQAY.js";import{j as c}from"./34NVU26H.js";import{a as l}from"./INVTU73D.js";function k(e,i={},o){let p={data:l(i)&&(e.answerFormat==="check"||e.answerFormat==="opinion")?{...e.inputs,findingActivityEnabled:!0}:e.inputs,settings:c(i),...o===void 0?{}:{maxInputBytes:o}};return d.parse({...e,answerFormat:Object.hasOwn(r,e.template)?g(e.template,e.answerFormat,i):e.answerFormat,limits:{...e.limits,promptCache:u(i,{template:e.template},e.model).enabled},inputs:JSON.parse(JSON.stringify(p))})}var n=(e,...i)=>Object.freeze({role:e,answerFormats:Object.freeze(i)}),s=m().map(e=>e.name),r=Object.freeze({"derive-findings":n("required",...s),"derive-findings-legacy":n("required",...s),"derive-findings-no-outcome":n("required",...s),"derive-findings-legacy-no-outcome":n("required",...s),"benchmark-judge":n("required","judge"),"judge-code-prompt":n("optional","codeJudge"),"derive-structure":n("optional","structures"),"structure-recheck":n("optional","recheck"),"derive-shape":n("optional","shape"),"scope-items":n("optional","structureScope"),"scope-findings":n("optional","scope"),"check-findings":n("optional","check"),"check-findings-precision-v1":n("optional","check"),"second-opinion":n("optional","opinion"),"explain-sources":n("optional","sourceNotes"),"finding-headlines":n("optional","findingHeadlines")});function A(){return r}function S(e,i,o){let t=o??(e==="derive"?"derive-findings":"check-findings");if(!Object.keys(r).filter(f=>r[f].answerFormats.includes(e==="derive"?"findings":"check")).includes(t))throw new Error("Unknown analysis template");return e==="derive"&&!a(i).switches.expectedOutcome&&!t.endsWith("-no-outcome")?`${t}-no-outcome`:t}function g(e,i,o){let t=i==="findings"?a(o).name:i;if(!Object.hasOwn(r,e)||!r[e].answerFormats.includes(t))throw new Error("Unsupported template answer format");return t}function E(e,i,o){if(o(i),!Object.hasOwn(r,e)||r[e].role!=="optional")throw i}export{k as a,A as b,S as c,g as d,E as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,f as a,h as g,j as h}from"./JAPVLU4Z.js";import{a as f}from"./I4F56VMG.js";import{b as o}from"./33EUZF25.js";import{a as l}from"./INVTU73D.js";import{a as x}from"./A7WJJMRY.js";import{a as m,b as p}from"./VDUFPTDD.js";import{z as r}from"zod";import{z as e}from"zod";var _=["Says","But also says","Unclear","Context","Requirement","What actually happens","Why it's a gap","Evidence"],b=e.object({sites:e.array(e.object({index:e.number().int().nonnegative(),role:e.enum(_),meaning:e.string(),keyPhrase:e.string()})),support:e.enum(["supported","partly","not_supported"]),supportNote:e.string(),counterEvidence:e.array(e.object({repo:e.string(),path:e.string(),line:e.number().int().positive(),excerpt:e.string(),meaning:e.string()}))});var E={expectedOutcome:{setting:"CF_FIX_EXPECTED_OUTCOME",enabled:t=>t.CF_FIX_EXPECTED_OUTCOME!=="0",suffix:"-no-outcome",suffixWhen:!1},untrustedContent:{setting:"CF_UNTRUSTED_CONTENT_CHECK",enabled:m,suffix:"-no-untrusted",suffixWhen:!1},betterAsCode:{setting:"CF_FINDING_BETTER_AS_CODE",enabled:p,suffix:"-better-as-code",suffixWhen:!0},audience:{setting:"CF_FINDING_AUDIENCE",enabled:x,suffix:"-audience",suffixWhen:!0},activity:{setting:"CF_NOT_ACTIVE_GROUP",enabled:l,suffix:"-activity",suffixWhen:!0}};function C(t){let n=Object.entries(E).map(([i,s])=>({key:i,rule:s,enabled:s.enabled(t)}));return{name:`findings${n.map(({rule:i,enabled:s})=>s===i.suffixWhen?i.suffix:"").join("")}`,switches:Object.fromEntries(n.map(({key:i,enabled:s})=>[i,s])),settings:Object.fromEntries(n.map(({rule:i,enabled:s})=>[i.setting,s?"1":"0"]))}}function H(){let t=[{}];for(let{setting:n}of Object.values(E))t=t.flatMap(i=>["0","1"].map(s=>({...i,[n]:s})));return t.map(n=>({...C(n),schema:N(n)}))}function F(t){return r.object({findings:r.array(t.shape.findings.element.extend({fixes:r.array(a.omit({expectedOutcome:!0})).min(1)}))})}var O=r.string(),S=O.catch(void 0),v=a.extend({expectedOutcome:r.string().default("")}),A=r.array(g.extend({audience:o.optional().catch(void 0),activity:f.optional().catch(void 0),fixes:r.array(v).min(1),sourceNotes:b.nullable().optional().catch(null)}));function N(t){let n=C(t),i=h(n.settings),c=(n.switches.expectedOutcome?i:F(i)).shape.findings.element,y=o.describe(u("finding-audience")),d=n.switches.audience?c.extend({audience:y.catch(void 0)}):c;return r.object({findings:r.array(n.switches.activity?d.extend({activity:S}):d)})}function V(t){return T(t.findings)}function T(t){return A.parse(t)}export{b as a,C as b,H as c,N as d,V as e,T as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as h}from"./6YCABS5T.js";import{a as S,c as _}from"./M5YWJY7P.js";import{c as B}from"./M6HYSTQD.js";import{d as A}from"./
|
|
1
|
+
import{a as h}from"./6YCABS5T.js";import{a as S,c as _}from"./M5YWJY7P.js";import{c as B}from"./M6HYSTQD.js";import{d as A}from"./VWRFSVLI.js";import{Ra as T}from"./2M55DR2J.js";function I(p,u,f,d,i,c,N){return{routeId:h(u),templateId:u,answerFormatId:A(u,f,p),model:d,calls:i,maxInputBytes:c,maxInputTokens:2e5,maxOutputTokens:N??B({model:d})}}var E=()=>({remaining:2e3});function C(p,u){return Buffer.byteLength(JSON.stringify({path:p,text:T(u)}))}function F(p,u=E()){let f=[...p].sort((e,t)=>t.size-e.size),d=(e,t,s)=>{let r=e[t],n=(r?.inputBytes??0)+(s.inputBytes??0);if(r&&r.size+s.size>15e4||n>=8e5)return;let o=[...e];return o[t]={own:[...r?.own??[],s.path],size:(r?.size??0)+s.size,inputBytes:n},o},i=[];for(let e of f){let t=i.findIndex(s=>s.size+e.size<=15e4&&s.inputBytes+(e.inputBytes??0)<8e5);if(t>=0)i[t].own.push(e.path),i[t].size+=e.size,i[t].inputBytes+=e.inputBytes??0;else if((e.inputBytes??0)<8e5)i.push({own:[e.path],size:e.size,inputBytes:e.inputBytes??0});else return}if(i.length<=4)return i.length?i.map(({own:e})=>({own:e})):[{own:[]}];let c=[{index:0,groups:[]}],N=new Set;for(;c.length;){if(u.remaining--<=0)return;let{index:e,groups:t}=c.pop();if(e===f.length)return t.map(({own:n})=>({own:n}));let s=JSON.stringify([e,t.map(n=>[n.size,n.inputBytes]).sort((n,o)=>n[0]-o[0]||n[1]-o[1])]);if(N.has(s))continue;N.add(s);let r=new Set;for(let n=Math.min(t.length,3);n>=0;n--){let o=t[n],a=`${o?.size??0}:${o?.inputBytes??0}`;if(r.has(a))continue;r.add(a);let m=d(t,n,f[e]);m&&c.push({index:e+1,groups:m})}}}export{I as a,E as b,C as c,F as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as O}from"./
|
|
1
|
+
import{m as O}from"./6VHZNBII.js";import{a as N}from"./326F4XNG.js";import{b as F}from"./HCPO6QPU.js";import{a as P}from"./MKYLK6DB.js";import{e as x}from"./C6X5GDG4.js";async function H(S,t){let a={entriesVisited:0,filesRead:0,bytesRead:0,truncated:!1},d=[],R=()=>({files:t.selected.files,selection:t.selection,skippedFiles:F(d),search:a});if(O(S,{selected:t.selected,codeAgentsFound:t.codeAgentsFound}).kind==="none")return R();let h=await t.port.context();if(!h)return R();let E=[];try{let r=e=>x(e,h.selectedRoot),L=e=>Object.fromEntries(Object.entries(e).map(([c,I])=>[r(c),I])),A={...t.selected,files:L(t.selected.files),root:h.selectedRoot,...t.selected.listedPaths?{listedPaths:t.selected.listedPaths.map(r)}:{},...t.selected.pointerFiles?{pointerFiles:L(t.selected.pointerFiles)}:{},...typeof t.selected.explicitPrompt=="string"?{explicitPrompt:r(t.selected.explicitPrompt)}:{}},l=await t.port.list();a.entriesVisited=l.entriesVisited,a.truncated=l.truncated;let w=new Map(l.entries.map(e=>[e.path,e])),u=new Set,p={},m=P.codeScan,b=()=>O(S,{selected:A,codeAgentsFound:t.codeAgentsFound,entries:l.entries,bodies:p,attemptedPaths:[...u],completeListing:!l.truncated}),n=b();for(;n.kind==="search"&&n.paths.length;){let e=[],c=0;for(let s of n.paths){let i=w.get(s);if(i.size>m.fileBytes){d.push({path:s,reason:"too-large"}),u.add(s);continue}let o=i.size+1;if(e.length>=4||a.filesRead+e.length>=m.files||a.bytesRead+c+o>m.bytes)break;e.push({entry:i,allowance:o}),c+=o}if(!e.length){if(n=b(),n.kind==="none"||!n.paths.length)break;a.truncated=!0,d.push(...n.paths.map(s=>({path:s,reason:"scan-limit"})));break}(await N(e,4,async({entry:s,allowance:i})=>{u.add(s.path),a.filesRead++;try{return await t.port.read(s,i)}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{text:null,bytesRead:i,refusal:"unreadable"}}},{settleStartedOnError:!0})).forEach((s,i)=>{let{entry:o,allowance:k}=e[i],z=Number.isSafeInteger(s.bytesRead)&&s.bytesRead>=0&&s.bytesRead<=k;a.bytesRead+=z?s.bytesRead:k,z&&s.text!==null&&!s.refusal&&s.bytesRead<=m.fileBytes&&s.bytesRead<k&&Buffer.byteLength(s.text)===s.bytesRead?p[o.path]=s.text:d.push({path:o.path,reason:s.refusal??"unreadable"})}),n=b()}let g=b();if(g.kind==="none"||!g.ownedPaths.length)return R();let f={...A.files};for(let e of g.ownedPaths)Object.hasOwn(p,e)&&(f[e]=p[e]);let v=e=>({...e,path:r(e.path),...e.ref===e.path?{ref:r(e.ref)}:{}}),B=t.selection.selected.map(v),M=new Set(B.map(e=>e.path)),j=g.ownedPaths.filter(e=>!M.has(e)&&Object.hasOwn(f,e)).map(e=>({...w.get(e),path:e,size:Buffer.byteLength(f[e]),ref:w.get(e)?.ref??e})),y=t.selection.readingNotes,V={files:f,root:h.selectedRoot,search:a,skippedFiles:F(d),selection:{...t.selection,selected:[...B,...j],totalBytes:t.selection.totalBytes+j.reduce((e,c)=>e+c.size,0),refused:t.selection.refused.map(e=>({...e,path:r(e.path)})),...y?{readingNotes:{instruction:y.instruction.map(r),code:y.code.map(r),agents:y.agents.map(r)}}:{}}};return E=Object.keys(f),V}finally{t.port.finish?.(E)}}export{H as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"../chunks/
|
|
1
|
+
import{a,b,c,d}from"../chunks/TA2NIQAY.js";import"../chunks/34NVU26H.js";import"../chunks/CNQZLSAP.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";export{a as executionInputs,d as executionRequest,b as modelName,c as requestLimits};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunks/CNQZLSAP.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";export{g as RESULT_CHECK_FREE_TEXT_BYTES,f as RESULT_CHECK_LIMITS,a as findingKind,b as findingSeverity,d as fixDelta,j as intakeFinding,i as nonblankText,e as publicFinding,k as resultCheckFinding,l as resultCheckFindings,h as validIntakeText,c as wording};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as G,B as H,C as I,D as J,a as g,b as h,c as i,d as j,e as k,f as l,g as m,h as n,i as o,j as p,k as q,l as r,m as s,n as t,o as u,p as v,q as w,r as x,s as y,t as z,u as A,v as B,w as C,x as D,y as E,z as F}from"../chunks/34NVU26H.js";import{e as a,f as b,g as c,h as d,k as e,l as f}from"../chunks/CNQZLSAP.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";export{v as ANALYSIS_DATA_FRAME_BYTES,l as ANALYSIS_PROTOCOL,o as ANALYSIS_SETTING_NAMES,n as DECLARED_ANALYSIS_PROTOCOL,c as RESULT_CHECK_FREE_TEXT_BYTES,b as RESULT_CHECK_LIMITS,C as analysisAdvance,G as analysisCallFailure,t as analysisCallFailureCode,z as analysisCancel,m as analysisCapabilities,u as analysisFailure,s as analysisFailureCode,w as analysisFile,D as analysisFinalResult,x as analysisManifest,A as analysisNeedFiles,B as analysisNeedListing,E as analysisResult,F as analysisResultChunk,r as analysisSettings,y as analysisStart,p as filterAnalysisSettings,i as projectPublicFinding,j as projectPublicReport,a as publicFinding,h as publicReportSchema,g as publicStructure,H as relayAnalysisSchemas,J as relayAnalysisV2Schemas,q as requestAnalysisSettings,e as resultCheckFinding,f as resultCheckFindings,I as resultLimitsSchema,k as unredactedAnswer,d as validIntakeText};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g,b as h,c as i,d as j,e as k}from"../chunks/
|
|
1
|
+
import{a as g,b as h,c as i,d as j,e as k}from"../chunks/VWRFSVLI.js";import"../chunks/VX6LYNXV.js";import"../chunks/MJGB25S5.js";import{a as c,b as d,c as e,d as f}from"../chunks/TA2NIQAY.js";import{i as a,j as b}from"../chunks/34NVU26H.js";import"../chunks/CNQZLSAP.js";import"../chunks/QVXARKP7.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/VDUFPTDD.js";export{a as ANALYSIS_SETTING_NAMES,g as analysisExecutionRequest,c as executionInputs,f as executionRequest,b as filterAnalysisSettings,d as modelName,k as recoverRequestFailure,e as requestLimits,h as requestPolicy,i as selectAnalysisTemplate,j as selectAnswerFormat};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e}from"../chunks/
|
|
1
|
+
import{a as b,b as c,c as d,d as e}from"../chunks/UKX3A6AX.js";import{a}from"../chunks/PBHHWFR6.js";import"../chunks/P253B344.js";import"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/YUY436SM.js";import"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";export{b as analysisSizeLimits,c as assessAnalysisSize,d as measureAnalysisSize,e as measureAnalysisSizeLowerBound,a as parseAnalysisSize};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ab as t,Bb as u,Cb as v,Db as w,Eb as x,Fb as y,Gb as z,Hb as A,Ib as B,Jb as C,Kb as D,Lb as E,ob as h,pb as i,qb as j,rb as k,sb as l,tb as m,ub as n,vb as o,wb as p,xb as q,yb as r,zb as s}from"../chunks/
|
|
1
|
+
import{Ab as t,Bb as u,Cb as v,Db as w,Eb as x,Fb as y,Gb as z,Hb as A,Ib as B,Jb as C,Kb as D,Lb as E,ob as h,pb as i,qb as j,rb as k,sb as l,tb as m,ub as n,vb as o,wb as p,xb as q,yb as r,zb as s}from"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import{a,b,c,d,e,f,h as g}from"../chunks/YUY436SM.js";import"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";export{v as CODE_EXT_RE,s as DEPENDENCY_BUILD_FOLDER_RE,p as EXTRACTION_CANDIDATE_RE,q as EXTRACTION_EXT_RE,i as FileReadRefusal,x as GIT_DIR_RE,r as LOCK_FILE_RE,w as NON_SOURCE_FOLDER_RE,j as REFERENCE_FILE_EXTENSIONS,c as SECRET_FILE_RE,A as SOURCE_CUT_MARKER,u as SOURCE_EXCLUDE_RE,t as SOURCE_NON_LOCK_EXCLUDE_RE,y as admitFile,D as admittedFileAccess,E as assertSnapshotAdmission,h as discoveredFilePurpose,f as fileRefusalWarning,l as isFetchableReferencePath,m as isFetchableSourcePath,k as isHtmlReferencePath,o as isReadableLocalPath,d as isReadableRepoPath,n as isUnreadCommandPath,b as localSymlinkGuardEnabled,C as readAdmittedSource,B as readRepoFile,g as resolveLocalExclusions,a as respectGitignore,e as secretFileWarning,z as sourceAdmissionIsInventoryIndependent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as d,c as e}from"../chunks/
|
|
1
|
+
import{a as c,b as d,c as e}from"../chunks/C77LGCKF.js";import{A as a,B as b}from"../chunks/LFJQ4YLP.js";import"../chunks/326F4XNG.js";import"../chunks/SP6XFHNH.js";import"../chunks/HCPO6QPU.js";import"../chunks/VC3PYT2B.js";import"../chunks/P253B344.js";import"../chunks/34NVU26H.js";import"../chunks/CNQZLSAP.js";import"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/YUY436SM.js";import"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";export{d as advanceEntrySelection,c as createEntrySelectionCheckpoint,a as entryGroupChoice,b as findEntryScopeChoice,e as readEntrySelection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"../chunks/
|
|
1
|
+
import{a as c}from"../chunks/XVGLY4EO.js";import"../chunks/6VHZNBII.js";import"../chunks/LFJQ4YLP.js";import"../chunks/326F4XNG.js";import"../chunks/SP6XFHNH.js";import"../chunks/HCPO6QPU.js";import"../chunks/2CWULBP2.js";import"../chunks/VC3PYT2B.js";import"../chunks/P253B344.js";import"../chunks/34NVU26H.js";import"../chunks/CNQZLSAP.js";import"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import{a}from"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/YUY436SM.js";import{e as b}from"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";export{a as READ_LIMITS,c as readOutsideLoaderSources,b as repoPathFrom};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as yr,d as J,e as br,f as Fr}from"./chunks/
|
|
1
|
+
import{a as yr,d as J,e as br,f as Fr}from"./chunks/66JRJPJC.js";import{$ as _e,I as xr,J as Er,K as wr,L as Ar,M as Rr,N as Cr,O as ye,P as xe,Q as B,R as j,S as Ee,T as we,U as D,W as Ae,X as Re,Y as W,Z as Ce,_ as be,aa as Y,ba as _r,ca as ve,da as Fe,ea as ke,fa as Ie,ga as Oe,ha as Te,ka as vr,qa as kr,sa as Ir,ua as Or,wa as Tr,ya as Lr}from"./chunks/QPIBHTON.js";import{a as X}from"./chunks/5VQ4VYIP.js";import{a as hr,d as Se,k as gr,l as Sr}from"./chunks/KBTM5MBC.js";import"./chunks/Y7JGSUOA.js";import"./chunks/3MTXB4MK.js";import"./chunks/N2L4JMJE.js";import"./chunks/6JTHFDH3.js";import"./chunks/HTLIRVP7.js";import"./chunks/N7U5N42V.js";import{a as $}from"./chunks/QDYMR6KS.js";import{b as ur}from"./chunks/E7TFIHC5.js";import"./chunks/4F6ZIHXU.js";import"./chunks/VGYWI4X2.js";import"./chunks/57M4OQJM.js";import"./chunks/J4AXGE5W.js";import"./chunks/IBCFGUHI.js";import"./chunks/DZZBQDGO.js";import{a as dr,b as fr,c as pr}from"./chunks/C77LGCKF.js";import"./chunks/XVGLY4EO.js";import{l as mr}from"./chunks/6VHZNBII.js";import{f as ge,u as nr,v as ir,w as cr,x as ar,y as lr}from"./chunks/LFJQ4YLP.js";import{a as U}from"./chunks/326F4XNG.js";import{a as or,b as tr,c as sr}from"./chunks/UKX3A6AX.js";import"./chunks/KU5DINLW.js";import{a as We,c as Ye,f as Ge,g as Qe,h as Ve,i as Ze,k as er}from"./chunks/SP6XFHNH.js";import{a as rr}from"./chunks/PBHHWFR6.js";import{b as k}from"./chunks/HCPO6QPU.js";import"./chunks/NCW5LJ5O.js";import"./chunks/DHVEGIU6.js";import"./chunks/2CWULBP2.js";import{a as he}from"./chunks/5UWDUYHF.js";import{a as je,c as z,g as De,h as Z}from"./chunks/VC3PYT2B.js";import{r as pe}from"./chunks/P253B344.js";import{d as ue}from"./chunks/W73WF226.js";import"./chunks/6YCABS5T.js";import"./chunks/M5YWJY7P.js";import"./chunks/M6HYSTQD.js";import{a as b,d as me}from"./chunks/4H23CSUM.js";import"./chunks/VWRFSVLI.js";import"./chunks/VX6LYNXV.js";import{c as C}from"./chunks/MJGB25S5.js";import"./chunks/TA2NIQAY.js";import"./chunks/34NVU26H.js";import"./chunks/CNQZLSAP.js";import"./chunks/QVXARKP7.js";import{Fb as L,Jb as fe,Kb as I,Lb as M,Ma as ce,Ra as ae,Ya as le,ab as de,i as ee,p as te,r as se}from"./chunks/2M55DR2J.js";import"./chunks/74FPPPIG.js";import{a as re}from"./chunks/MKYLK6DB.js";import"./chunks/5TATKWLG.js";import{f as T,i as ne,n as ie}from"./chunks/JKWTHRUR.js";import{a as Je,b as q}from"./chunks/3GUKUEEJ.js";import"./chunks/JAPVLU4Z.js";import"./chunks/I4F56VMG.js";import"./chunks/33EUZF25.js";import"./chunks/YUY436SM.js";import{a as oe,c as O}from"./chunks/C6X5GDG4.js";import{b as V}from"./chunks/724WZMYW.js";import"./chunks/YWL52FVW.js";import{i as $e,j as Xe}from"./chunks/SJESFYBA.js";import{a as He,b as Ke,c as ze,d as qe,e as Ue}from"./chunks/RUVMFAST.js";import"./chunks/S27VIQMZ.js";import"./chunks/INVTU73D.js";import"./chunks/A7WJJMRY.js";import"./chunks/Q5WR6B2H.js";import"./chunks/VDUFPTDD.js";function Mr(o){return o?.fromProposal===0&&o.rejected>0}var Nr=new Set;function Pr(o,e={}){let s=oe(e.dir),a=e.limits??re.archive,t=e.listing??Nr,n={commit:null,files:new Map,skipped:[]},f=new Set,y=0,h=0;function m(c){let d=c.replace(/\/$/,"").split("/");return!c.startsWith("/")&&!c.includes("\\")&&!/^[a-z]:/i.test(c)&&!d.some(u=>u===".."||u==="."||!u)}function l(c,d,u,r=t){if(!u||!m(c)||!Number.isSafeInteger(d)||d<0)return"refused";let i=L(o,{path:c,size:d},{purpose:"archive",route:"github",root:s});return i.admitted?e.exampleFolders?.some(E=>c.startsWith(E))||se(c,{root:s,listing:r})?"example":null:i.reason==="excluded"&&te(o,c,s)?"example":i.reason==="excluded"||i.reason==="wrong-type"?"excluded":"refused"}function p(c,d){f.has(c)||(f.add(c),n.skipped.push({path:c,reason:d}))}function g(c,d=t){let u=c.split("/");for(let r=1;r<=u.length;r++){let i=u.slice(0,r).join("/");if(i===s||s.startsWith(`${i}/`))continue;if(O(i,s)===null)return!1;let E=l(`${i}/`,0,!0,d);if(E)return p(`${i}/`,E),!1}return!0}function S(c,d,u=!0){if(O(c,s)===null)return!1;if(!m(c))return p(c,"refused"),!1;let r=c.split("/");if(r.length>1&&!g(r.slice(0,-1).join("/")))return!1;let i=l(c,d,u);return i?(p(c,i),!1):h>=a.files||d>a.bytes-y?(p(c,"over-limit"),!1):(y+=d,h++,!0)}return{result:n,accept:S,enterFolder:g}}function Le(o){return o.CF_MODEL_READER!=="0"}async function Br(o,e,s,a){s=I(o,s);let t=structuredClone(e);for(t.files??={},t.cursor=0;;){let n=await D(o,t,s,a);if(n){t=n;continue}let f=t.selected??[];if((t.cursor??0)>=f.length)return t;let y=f.slice(t.cursor).filter(l=>!Object.hasOwn(t.files,l.path)),h=[],m=await U(y,4,async l=>{try{return{path:l.path,text:await B(l,p=>s.read(p),h,t.refused)}}catch(p){return{error:p}}});for(let l of m){if("error"in l)throw l.error;l.text!==null&&(t.files[l.path]=l.text)}h.length&&(t.refused=k(t.refused,h)),t.cursor=f.length}}async function Me(o,e,s,a){let{codeFindingNote:t}=Se(a),n={deriveBytes:0,codeEvidence:[]};if(!e.findingQuality?.config.switches.codeInputs||!e.projectAgents?.enabled)return n;let f=e.projectAgents,y=(e.repos??[]).filter(r=>[...f.byRepo[r.key]??[],...f.codeByRepo?.[r.key]??[]].some(i=>i.codeInputsJson&&(i.codeInputsJson.tools.length||i.codeInputsJson.contextInputs.length))),m=(await U(y,1,async r=>{try{let i=s.find(E=>E.repoKey===r.key);if(!i)throw new Error("Source reader is missing.");return{repo:await Br(o,r,i,e.modelReader??!1)}}catch(i){return{error:i}}})).map(r=>{if("error"in r)throw r.error;return r.repo}),l=m.map(r=>{let i=Ae(o,r,j(o,e),e.modelReader,f);return Object.assign(r.files,i.virtualFiles),i.fragment}),p=Object.fromEntries(m.map(r=>[r.key,r.files??{}])),S=Re({...e,repos:m,mapped:l}).findingQuality?.codeEvidence?.filter(r=>Object.keys(r.input.files).length)??[];if(!S.length)return n;let c=S.map(r=>({repo:r.repo,unitKey:r.unitKey,enabled:!0,inputs:[r.input],files:p[r.repo]}));return{deriveBytes:[...new Map(S.flatMap(r=>Object.entries(r.input.files).map(([i,E])=>[JSON.stringify([r.repo,i]),{path:i,text:E}]))).values()].reduce((r,{path:i,text:E})=>r+Buffer.byteLength(`### ${i}
|
|
2
2
|
\`\`\`
|
|
3
3
|
${ae(E)}
|
|
4
4
|
\`\`\`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"../chunks/
|
|
1
|
+
import{j as a}from"../chunks/6JTHFDH3.js";import"../chunks/VX6LYNXV.js";import"../chunks/QVXARKP7.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/VDUFPTDD.js";export{a as answerFormats};
|