@counterfact-labs/cli 0.2.7 → 0.2.9
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/analysis-results.js +87 -0
- package/dist/adapters/combined-results.js +27 -0
- package/dist/adapters/entry-files.js +5 -2
- package/dist/adapters/entry-packing.js +161 -0
- package/dist/adapters/entry-selection.js +13 -1
- package/dist/adapters/files.js +110 -5
- package/dist/adapters/git.js +10 -1
- package/dist/adapters/relay-plan.js +5 -7
- package/dist/adapters/release.js +4 -1
- package/dist/adapters/results.js +9 -2
- package/dist/adapters/selection.js +19 -9
- package/dist/adapters/settings.js +37 -6
- package/dist/adapters/source-relay-plan.js +7 -0
- package/dist/analysis-core/analysis/code-agents/skipped-files.js +1 -1
- package/dist/analysis-core/analysis/file-analysis-plan.js +1 -0
- package/dist/analysis-core/analysis/file-dependencies.js +1 -0
- package/dist/analysis-core/analysis/finding-activity-switch.js +1 -0
- package/dist/analysis-core/analysis/finding-identity.js +1 -0
- package/dist/analysis-core/analysis/finding-quality/policy.js +1 -0
- package/dist/analysis-core/analysis/folder-analysis-plan.js +1 -0
- package/dist/analysis-core/analysis/passes/full-file-passes.js +1 -0
- package/dist/analysis-core/analysis/project-architecture.js +1 -0
- package/dist/analysis-core/analysis/schemas.js +1 -1
- package/dist/analysis-core/chunks/2AASSZRO.js +35 -0
- package/dist/analysis-core/chunks/2YREYGOG.js +1 -0
- package/dist/analysis-core/chunks/33HRXJ5Q.js +1 -0
- package/dist/analysis-core/chunks/33IGHOYT.js +1 -0
- package/dist/analysis-core/chunks/4PT5C4IT.js +7 -0
- package/dist/analysis-core/chunks/4RXRAB5S.js +1 -0
- package/dist/analysis-core/chunks/4UDQBDDE.js +1 -0
- package/dist/analysis-core/chunks/{6RWEWBHK.js → 5B5UCWD3.js} +1 -1
- package/dist/analysis-core/chunks/6YCABS5T.js +1 -0
- package/dist/analysis-core/chunks/CQQ4TTXE.js +1 -0
- package/dist/analysis-core/chunks/CTLHKFPH.js +19 -0
- package/dist/analysis-core/chunks/F54DOWKN.js +6 -0
- package/dist/analysis-core/chunks/FRXOQ2M6.js +3 -0
- package/dist/analysis-core/chunks/HCPO6QPU.js +1 -0
- package/dist/analysis-core/chunks/HHFDNY6V.js +14 -0
- package/dist/analysis-core/chunks/{FBTOOUPL.js → HVQJKPQ4.js} +1 -1
- package/dist/analysis-core/chunks/INVTU73D.js +1 -0
- package/dist/analysis-core/chunks/JEWBPIQI.js +1 -0
- package/dist/analysis-core/chunks/JGK37AWN.js +1 -0
- package/dist/analysis-core/chunks/LFYTD7JF.js +1 -0
- package/dist/analysis-core/chunks/LMUXOKIM.js +1 -0
- package/dist/analysis-core/chunks/LOBIDUCA.js +1 -0
- package/dist/analysis-core/chunks/M5YWJY7P.js +1 -0
- package/dist/analysis-core/chunks/MGVIKA74.js +1 -0
- package/dist/analysis-core/chunks/MKYLK6DB.js +1 -0
- package/dist/analysis-core/chunks/MZOKZ3N6.js +1 -0
- package/dist/analysis-core/chunks/NXHVBJL4.js +1 -0
- package/dist/analysis-core/chunks/OKBK3JL3.js +1 -0
- package/dist/analysis-core/chunks/PBHHWFR6.js +1 -0
- package/dist/analysis-core/chunks/Q5WR6B2H.js +2 -0
- package/dist/analysis-core/chunks/QVXARKP7.js +1 -0
- package/dist/analysis-core/chunks/RQTNTIR4.js +1 -0
- package/dist/analysis-core/chunks/{RNTMH4MU.js → S27Y2TP5.js} +1 -1
- package/dist/analysis-core/chunks/SJESFYBA.js +10 -0
- package/dist/analysis-core/chunks/SP6XFHNH.js +1 -0
- package/dist/analysis-core/chunks/VDUFPTDD.js +1 -0
- package/dist/analysis-core/chunks/W24SFYZM.js +67 -0
- package/dist/analysis-core/chunks/YTHF2E2S.js +1 -0
- package/dist/analysis-core/chunks/YWL52FVW.js +2 -0
- package/dist/analysis-core/contracts/analysis-selection.js +1 -1
- package/dist/analysis-core/contracts/analysis-size.js +1 -0
- package/dist/analysis-core/contracts/execution-request.js +1 -0
- package/dist/analysis-core/contracts/intake-finding.js +1 -0
- package/dist/analysis-core/contracts/model-call-identity.js +1 -0
- 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/conventions/read-limits.js +1 -0
- package/dist/analysis-core/import/calls/modules.js +1 -1
- package/dist/analysis-core/import/entry-selection.js +1 -0
- package/dist/analysis-core/import/outside-loader-sources.js +1 -1
- package/dist/analysis-core/index.js +3 -3
- 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/planned-limits.js +1 -0
- 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/bundle/seal/engine.js +1 -1
- package/dist/cli/analysis-selection.js +47 -5
- package/dist/cli/api.js +1 -1
- package/dist/cli/commands/analyze.js +58 -15
- package/dist/cli/commands/skipped.js +65 -0
- package/dist/cli/context.js +2 -1
- package/dist/cli/finding-display.js +102 -7
- package/dist/cli/finding-settings.js +3 -1
- package/dist/cli/intake-payload.js +26 -2
- package/dist/cli/main.js +21 -7
- package/dist/cli/mcp-failure.js +6 -5
- package/dist/cli/mcp.js +134 -28
- package/dist/cli/relay-check.js +107 -23
- package/dist/cli/relay-failure.js +4 -4
- package/dist/cli/relay-preparation.js +50 -12
- package/dist/cli/result-check.js +31 -12
- package/dist/cli/saved-results.js +10 -0
- package/dist/cli/scope-choices.js +3 -3
- package/dist/cli/sign-in.js +2 -2
- package/dist/cli/skipped-files.js +22 -0
- package/dist/cli/summary.js +15 -1
- package/dist/contract/agent-choice.js +25 -2
- package/dist/contract/cli-api-messages.js +3 -0
- package/dist/contract/cli-refusals.js +31 -5
- package/dist/contract/cli-version.js +1 -1
- package/dist/contract/console-url.js +3 -0
- package/dist/contract/console.js +17 -38
- package/dist/contract/engine.js +1 -1
- package/dist/contract/messages.js +4 -3
- package/dist/contract/project-architecture.js +1 -0
- package/dist/contract/scope-choice.js +31 -11
- package/dist/contract/selection-offer.js +5 -8
- package/dist/gatekeeper/cli-api.js +70 -4
- package/dist/gatekeeper/console.js +19 -3
- package/dist/gatekeeper/model.js +5 -23
- package/dist/gatekeeper/trust/policy.js +2 -1
- package/package.json +4 -2
- package/dist/analysis-core/analysis/source-notes/types.js +0 -1
- package/dist/analysis-core/chunks/2PSNOSJ2.js +0 -1
- package/dist/analysis-core/chunks/2PZF54KH.js +0 -10
- package/dist/analysis-core/chunks/6B2HILSY.js +0 -1
- package/dist/analysis-core/chunks/6U2IR4XB.js +0 -1
- package/dist/analysis-core/chunks/7NEWZ74F.js +0 -1
- package/dist/analysis-core/chunks/CGCJN73D.js +0 -14
- package/dist/analysis-core/chunks/CWYVUGG4.js +0 -1
- package/dist/analysis-core/chunks/FSLWD2PE.js +0 -1
- package/dist/analysis-core/chunks/GOQVKWP3.js +0 -32
- package/dist/analysis-core/chunks/IHAVDX4L.js +0 -66
- package/dist/analysis-core/chunks/IVULXWQN.js +0 -21
- package/dist/analysis-core/chunks/K2GNDX3W.js +0 -1
- package/dist/analysis-core/chunks/K5FUABWW.js +0 -1
- package/dist/analysis-core/chunks/KGQYR62R.js +0 -7
- package/dist/analysis-core/chunks/KWECQJ6X.js +0 -1
- package/dist/analysis-core/chunks/PY5M22CL.js +0 -1
- package/dist/analysis-core/chunks/PYKAERZZ.js +0 -1
- package/dist/analysis-core/chunks/SKVEBOGA.js +0 -1
- package/dist/analysis-core/chunks/SLJ6CW7W.js +0 -1
- package/dist/analysis-core/chunks/UEORNVQB.js +0 -1
- package/dist/analysis-core/chunks/WYLIV2P2.js +0 -1
- package/dist/analysis-core/data/finding-types.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as Z,B as dt,C as pt,D as ct,E as ft,F as O,G as mt,H as ht,I as ut,J as gt,P as Pt,R as wt,V as kt,W as St,a as ie,b as Je,c as Ve,d as Qe,e as Xe,f as V,g as le,h as z,i as Ze,j as K,ja as bt,k as N,l as et,la as vt,m as tt,ma as Rt,n as ot,na as Ft,o as q,oa as Et,p as st,q as at,r as de,s as Q,t as rt,u as nt,v as A,w as pe,x as X,y as it,z as lt}from"./W24SFYZM.js";import{a as Ye}from"./5B5UCWD3.js";import{i as $e}from"./4RXRAB5S.js";import{a as J}from"./QDYMR6KS.js";import{a as We}from"./HVQJKPQ4.js";import{g as _}from"./CTLHKFPH.js";import{E as Ge,d as ze,e as M,f as Ke,g as Ne,h as qe,o as He,q as C,s as Ue,t as De,y as Y}from"./FRXOQ2M6.js";import{a as L}from"./326F4XNG.js";import{b as T,c as U}from"./HCPO6QPU.js";import{a as Te,b as _e,c as ne}from"./33HRXJ5Q.js";import{a as je,b as re}from"./LOBIDUCA.js";import{e as ke,g as Se}from"./YTHF2E2S.js";import{n as $}from"./4PT5C4IT.js";import{c as Ie}from"./2YREYGOG.js";import{a as Ae}from"./4H23CSUM.js";import{c as ae}from"./MJGB25S5.js";import{$ as D,Ca as ye,Fb as k,Lb as Le,Ta as Ce,hb as G,i as y,kb as Be,lb as Me,pb as W,u as oe}from"./2AASSZRO.js";import{a as ve}from"./MKYLK6DB.js";import{f as se,i as Fe,j as Ee,m as Oe,n as xe}from"./JKWTHRUR.js";import{c as Re,e as x}from"./C6X5GDG4.js";import{b as we}from"./724WZMYW.js";import{a as be}from"./SJESFYBA.js";import{posix as Ut}from"node:path";function Ot(r,e,a){let s=new Set(e.entries.map(l=>l.path)),t=new Set(G(r,[...s])),d=Object.fromEntries(Object.entries(e.files).filter(([l])=>e.selected.some(o=>o.path===l&&o.readBytes===void 0))),n=new Set(Me(r,[...s],d)),f=[],c=new Set;return{read:async l=>{if(n.has(l.path)||e.managedReadPaths?.includes(l.path)&&e.files[l.path]===void 0)return e.refused.push({path:l.path,reason:"unreadable"}),null;f.push(l);try{let o=await a(l);if(o!==null){if(c.has(l.path)){let p=k(r,{path:l.path,size:Buffer.byteLength(o),text:o},{...e.admission,purpose:"skill",route:"github",root:e.root,listing:s,managedFiles:e.files});if(!p.admitted)return e.refused.push({path:l.path,reason:p.reason}),null}if(y(r)||we(r)){let p=k(r,{path:l.path,text:o},{...e.admission,purpose:"override",route:"github",root:e.root,listing:s,managedFiles:e.files});if(!p.admitted)return e.refused.push({path:l.path,reason:p.reason}),null}if(e.phase==="manifest"){let p=k(r,{path:l.path,size:Buffer.byteLength(o)},{...e.admission,purpose:"pointer",route:"github",root:e.root});if(!p.admitted)return e.refused.push({path:l.path,reason:p.reason}),null}return o}}catch(o){if(o instanceof W&&(o.reason==="secret-content"||y(r)||c.has(l.path)||t.has(l.path)))return e.refused.push({path:l.path,reason:o.reason}),null;if(e.profile==="hosted-import"&&!c.has(l.path)&&!t.has(l.path))throw o}return e.refused.push({path:l.path,reason:"unreadable"}),null},requestedReads:f,skillReads:c}}import{createHash as Ht}from"node:crypto";function ce(r){return Ht("sha256").update(JSON.stringify(r.map(({path:e,ref:a,size:s})=>({path:e,ref:a,size:s})))).digest("hex")}function xt(r,e,a){return _(r)?{settings:Se(r),commit:a??ce(e),revisionKind:a===void 0?"listing":"commit",completed:[]}:void 0}function yt(r,e,a){let s=r.agentPages;if(!s)return;let t=a??s.listingEntries??r.entries,d=s.revisionKind??(s.commit===ce(s.listingEntries??r.entries)?"listing":"commit");if(d==="commit"&&e!==void 0&&s.commit!==e||d==="listing"&&s.commit!==ce(t))throw new Error("stale-agent-page");return s.commit}function Ct(r,e,a){e.ranked??=Q(r,e.scan,new Map);let s=new Map([...de(e.scan.plan),...Object.entries(e.agentPages?.actualSizes??{})]),t=ie(r,e.ranked,s,new Map,{files:{},...e.agentPages?{page:{commit:e.agentPages.commit,scope:e.root,continuation:a}}:{}});t.page&&(e.ranked={...e.ranked,agentPage:t.page,strong:t.strong,possible:t.window,notRead:t.notRead,notReadMore:t.notReadMore});let d=[...t.refused,...e.ranked.skippedFiles??[]];if(e.requestedPaths.push(...d.map(n=>n.path)),e.refused.push(...d),e.profile==="hosted-import"&&t.paths.length||t.page){let n=nt(r,[],t.paths,e.scan.plan);e.refused.push(...n.refused),e.profile==="hosted-import"?pt(e,n.selected):(lt(r,e),Z(e,n.selected))}else X(r,e,t.paths,e.scan.plan);e.phase=e.selected.length?"files":"done"}function Bt(r,e,a,s){let t={...e.agentPages.actualSizes};a.forEach((o,p)=>{s[p]!==null&&(t[o.path]=Buffer.byteLength(s[p]))}),e.agentPages={...e.agentPages,actualSizes:t};let d=new Map([...de(e.scan.plan),...Object.entries(t)]),n=new Map(Object.entries(e.files).map(([o,p])=>[o,Buffer.byteLength(p)])),f=new Set(e.skillReferencePaths),c=new Set([...e.conventionPaths,...dt(e),...f,...e.markerPath?[e.markerPath]:[]]);for(let o of a)if(c.has(o.path)&&t[o.path]!==void 0){let p=k(r,{path:o.path,size:t[o.path]},{purpose:f.has(o.path)?"skill":"pointer",route:"github",root:e.root,listing:new Set(e.entries.map(u=>u.path)),managedFiles:e.files}),i=Ge(n).left+(n.get(o.path)??0);p.admitted&&t[o.path]<=i?n.set(o.path,t[o.path]):e.refused.push({path:o.path,reason:p.admitted?"total":p.reason})}let m=ie(r,e.ranked,d,n),l=new Set(m.paths);a.forEach((o,p)=>{s[p]!==null&&(l.has(o.path)||c.has(o.path)&&n.has(o.path)?e.files[o.path]=s[p]:e.refused.push(m.refused.find(i=>i.path===o.path)??m.skippedFiles?.find(i=>i.path===o.path)??{path:o.path,reason:"total"}))}),e.ranked={...e.ranked,agentPage:m.page,strong:m.strong,possible:m.window}}function fe(r){let e=r.ranked,a=e?.agentPage;if(!a||r.phase!=="done")return;let s=[...e.agentInventory.strong,...e.agentInventory.possible],t=new Set(a.selected),d=new Set(a.refusals.map(c=>c.id)),n=s.filter(c=>t.has(D(c.prompt))&&!d.has(D(c.prompt))&&r.files[c.prompt.path]===void 0),f=[...a.refusals,...n.map(c=>({id:D(c.prompt),reason:r.refused.find(m=>m.path===c.prompt.path)?.reason??"missing"}))];r.ranked={...e,strong:e.strong.filter(c=>r.files[c.prompt.path]!==void 0),possible:e.possible.filter(c=>r.files[c.prompt.path]!==void 0),agentPage:{...a,refusals:f,partial:f.length>0,estimatedInputBytes:Object.values(r.files).reduce((c,m)=>c+Buffer.byteLength(m),0)}}}async function Mt(r,e,a){if(!y(r))return!1;let s=Be(r,e.entries.map(o=>o.path));if(!s.length)return!1;let t=new Set(s.flatMap(o=>o.agents)),d=new Map(e.selected.map(o=>[o.path,o])),n=new Set(e.selected.filter(o=>o.readBytes===void 0&&e.files[o.path]!==void 0).map(o=>o.path));e.managedReadPaths||(e.managedReadPaths=[],(e.scan||e.ranked)&&(delete e.scan,delete e.ranked,delete e.manifestReadPaths,e.phase!=="marker"&&(e.phase="scan")));let f=new Set([...e.managedReadPaths,...n]),c=e.entries.filter(o=>t.has(o.path)&&d.has(o.path)&&!f.has(o.path)),m=c.slice(0,A);if(!m.length)return!1;let l=await L(m,4,async o=>{let p=k(r,o,{...e.admission,purpose:"pointer",route:"github",root:e.root});return p.admitted?a(o):(e.refused.push({path:o.path,reason:p.reason}),null)});if(m.forEach((o,p)=>{l[p]!==null&&(e.files[o.path]=l[p],e.selected=e.selected.map(i=>i.path===o.path?o:i))}),e.managedReadPaths.push(...m.map(o=>o.path)),c.length>m.length){for(let o of Object.keys(e.files))!t.has(o)&&s.some(p=>Re(o,p.folder)!==null)&&delete e.files[o];e.cursor=0,(e.phase==="done"||e.phase==="manifest")&&(e.phase="files")}return!0}async function Lt(r,e,a){if(e.marketplacePlanned)return!1;let s=new Set(G(r,e.entries.map(o=>o.path)));if(!e.selected.some(o=>s.has(o.path)))return!1;let t=new Set(e.marketplaceReadPaths),n=e.selected.filter(o=>s.has(o.path)&&!t.has(o.path)).slice(0,A),f=await L(n,4,async o=>{let p=k(r,o,{...e.admission,purpose:"definition",route:"github",root:e.root});if(!p.admitted)return e.refused.push({path:o.path,reason:p.reason}),null;let u=(o.readBytes===void 0?e.files[o.path]:void 0)??await a({path:o.path,size:o.size,ref:o.ref});if(u===null)return null;let g=k(r,{path:o.path,size:Buffer.byteLength(u),text:u},{...e.admission,purpose:"definition",route:"github",root:e.root});return g.admitted?u:(e.refused.push({path:o.path,reason:g.reason}),null)});n.forEach((o,p)=>{f[p]!==null?e.files[o.path]=f[p]:delete e.files[o.path]}),e.marketplaceReadPaths=[...t,...n.map(o=>o.path)];let c=new Map(n.flatMap((o,p)=>f[p]===null?[]:[[o.path,Buffer.byteLength(f[p])]]));e.agentPages&&c.size&&(e.agentPages={...e.agentPages,listingEntries:e.agentPages.listingEntries??e.entries}),e.entries=e.entries.map(o=>c.has(o.path)?{...o,size:c.get(o.path)}:o);let m,l=e.marketplaceSelection?new Set(e.marketplaceSelection):void 0;do{let o=new Set(e.marketplaceReadPaths.filter(h=>e.files[h]===void 0)),p=e.entries.filter(h=>!o.has(h.path)&&(!l||l.has(h.path))),i=e.profile==="local-analysis"?Ke(r,p,e.root,{files:e.files}):Ue(r,p,e.root,{files:e.files,mode:e.marketplaceMode}),u="selected"in i?i.selected.map(h=>h.path):i.selectedPaths,g=new Set(u),P=new Map(p.map(h=>[h.path,h]));e.selected=u.map(h=>P.get(h)),e.selectionRefused=i.refused,e.hosted&&"selectedPaths"in i&&(e.hosted.fallback=i,e.hosted.codeMode||(e.hosted.needsExtraction=i.needsExtraction)),m=Object.keys(e.files).filter(h=>s.has(h)&&!g.has(h));for(let h of m)e.refused.push(i.refused.find(w=>w.path===h)??{path:h,reason:"total"});for(let h of Object.keys(e.files))g.has(h)||delete e.files[h]}while(m.length);return e.conventionPaths=$(r,e.entries.filter(o=>!s.has(o.path)||e.files[o.path]!==void 0).map(o=>o.path),e.root,{files:e.files}).files.filter(o=>o.role!=="reference").map(o=>o.path),e.cursor=0,e.marketplacePlanned=!e.selected.some(o=>s.has(o.path)&&!e.marketplaceReadPaths.includes(o.path)),n.length>0||!e.marketplacePlanned}function me(r,e){let{plan:a,entries:s}=e,t=a.profile==="local-analysis"?a.context.dir??"":e.root??"",d=a.readers.find(l=>l.id==="marker")?.claim.wants[0],n=a.readers.some(l=>l.id==="code-scan"),f=new Map(s.map(l=>[l.path,l])),c=a.profile==="local-analysis"?a.selection.selected:a.selection.selectedPaths.flatMap(l=>f.has(l)?[f.get(l)]:[]),m=He(r)?C(r,{phase:"start",root:t,paths:s.map(l=>l.path),scanFlag:!!d||n}):void 0;return{..._(r)?{agentPages:xt(r,s,e.commit)}:{},version:1,profile:a.profile,root:t,entries:s,selected:[...c],..."mode"in a?{marketplaceMode:a.mode}:{},..."selectionPaths"in a?{marketplaceSelection:a.selectionPaths}:{},conventionPaths:a.profile==="hosted-import"||_(r)?$(r,s.map(l=>l.path),t).files.filter(l=>l.role!=="reference").map(l=>l.path):[],...e.admission?{admission:e.admission}:{},selectionRefused:a.selection.refused,requestedPaths:[],refused:[],files:{},cursor:0,treeTruncated:e.treeTruncated??!1,...a.profile==="hosted-import"?{hosted:{fallback:structuredClone(a.selection),weakCodeFallback:r.CF_IMPORT_WEAK_CODE_FALLBACK!=="0",codeMode:!1,needsExtraction:a.selection.needsExtraction}}:{},decision:m??(d?{kind:"marker",markerPath:d,scanIfBare:n}:{kind:"settled",markerPath:null,markerKind:null,scan:n}),phase:d?"marker":n?"scan":"files"}}async function At(r,e,a){if(e.version!==1)throw new Error("unsupported-import-checkpoint");e.agentPages&&(r=e.agentPages.settings,yt(e,a.commit));let s=pe(r,e.profile),t={...e,selected:[...e.selected],files:{...e.files},requestedPaths:[...e.requestedPaths],refused:[...e.refused],...e.hosted?{hosted:{...e.hosted}}:{},...e.managedReadPaths?{managedReadPaths:[...e.managedReadPaths]}:{}},{read:d,requestedReads:n,skillReads:f}=Ot(s,t,o=>a.read(o));if(await Lt(s,t,d))return O(s,t,n);if(await Mt(s,t,d))return O(s,t,n);if(ft(s,t),t.phase==="done")return a.resolvedCode&&ct(t,a.resolvedCode),O(s,t,n);if(t.phase==="manifest")return await mt(s,t,d),fe(t),O(s,t,n);if(t.phase==="marker"&&t.decision.kind==="marker"){let o=t.decision,p=o.markerPath,i=t.entries.find(g=>g.path===p);if(t.profile==="hosted-import"){let g=k(s,i,{purpose:"pointer",route:"github",root:t.root});if(!g.admitted)return t.refused.push({path:p,reason:g.reason}),t.decision={kind:"settled",markerPath:null,markerKind:null,scan:o.scanIfBare},t.phase=o.scanIfBare?"scan":"files",O(s,t,n)}X(s,t,[p],t.entries);let u=await d(i);if(u!==null&&(t.files[p]=u),t.decision=C(s,{phase:"read",pending:o,text:u}),t.markerPath=p,t.markerKind=t.decision.markerKind,t.markerKind!=="bare"){let g=t.profile==="hosted-import"?await a.listing():{entries:t.entries,truncated:!1};t.treeTruncated||=g.truncated;let P=await ht(s,{config:qe(u).config,markerDir:p.split("/").slice(0,-1).join("/"),selected:t.profile==="hosted-import"?[]:t.selected,admission:{...t.admission,root:t.root||void 0},modelReader:!1,priorRefused:t.refused,refusalMode:"append",requestedMode:"kept-and-refused",listing:async()=>g.entries});if(t.requestedPaths.push(...P.requestedPaths),t.refused=P.refused,t.agentPages&&P.selected){let h=new Set(P.requestedPaths);t.conventionPaths=[...new Set([...t.conventionPaths,...P.selected.filter(w=>h.has(w.path)).map(w=>w.path)])]}t.profile==="hosted-import"?Z(t,P.selected??[]):P.selected&&(t.selected=P.selected)}if(t.phase=t.decision.scan?"scan":"files",t.profile!=="hosted-import"||t.markerKind!=="bare"||t.decision.scan)return O(s,t,n)}if(t.phase==="scan"){if(!t.scan){let o=ot(s,t.entries,t.root,!0,t.decision.kind==="settled"?t.decision.scanPaths:void 0);t.scan=o.state,t.refused.push(...o.refused)}if(!q(t.scan)){let o=await rt(s,t.scan,d,{modelReader:!1,alreadyRead:new Map,size:{batch:et,parallel:4}});t.scan=o.scan,o.selection&&(t.ranked=o.selection.ranked)}return q(t.scan)&&Ct(s,t),O(s,t,n)}if(oe(s))for(let o of t.skillReferencePaths??[])f.add(o);let c=t.selected.slice(t.cursor,t.cursor+A),m=c.filter(o=>t.files[o.path]===void 0),l=await L(m,4,d);if(t.agentPages&&t.ranked&&t.scan?Bt(s,t,m,l):m.forEach((o,p)=>{l[p]!==null&&(t.files[o.path]=l[p])}),t.cursor+=c.length,oe(s)){let o=Object.fromEntries(Object.entries(t.files).filter(([h])=>t.selected.some(w=>w.path===h&&w.readBytes===void 0))),p=De(s,{entries:t.entries,selected:t.selected,files:o,root:t.root,admission:t.admission,referencePaths:t.skillReferencePaths});t.refused=T(t.refused,p.refused);for(let h of p.refused)f.has(h.path)&&delete t.files[h.path];if(t.cursor<t.selected.length)return O(s,t,n);let i=new Map(t.selected.map(h=>[h.path,h])),u=p.paths.filter(h=>!i.has(h)||i.get(h).readBytes!==void 0),g=new Set(u.filter(h=>i.has(h)));t.cursor-=t.selected.slice(0,t.cursor).filter(h=>g.has(h.path)).length,t.selected=t.selected.filter(h=>!g.has(h.path));for(let h of g)delete t.files[h];t.requestedPaths.push(...u),u.length&&(t.skillReferencePaths=[...t.skillReferencePaths??[],...u]);let P=new Map(t.entries.map(h=>[h.path,h]));t.selected.push(...u.map(h=>{let w=P.get(h);return{path:h,size:w.size,ref:w.ref}})),it(t,u,"fallback")}return t.cursor>=t.selected.length&&(t.phase=ze(s)&&t.ranked||y(s)?"manifest":"done"),fe(t),O(s,t,n)}async function ee(r,e){let a=me(r,e),s;do s=await At(r,a,{listing:async()=>({entries:e.entries,truncated:!1}),read:e.read}),a=s.state;while(a.phase!=="done");let t={};return a.markerPath!==void 0&&(t.markerPath=a.markerPath,t.markerKind=a.markerKind),a.ranked!==void 0&&(t.ranked=a.ranked,t.scan=a.scan),{files:s.files,settled:s.settled,skippedFiles:s.refused,...t}}function Dt(r){return r.CF_IMPORT_PROPOSAL!=="0"}var Gt=new Set(["secret","secret-content","out-of-scope"]);async function Wt(r,e,a,s,t,d,n){let f={...e.admission,purpose:"proposal",route:"local-folder"},c=k(r,s??{path:a},f);if(!c.admitted)return{reason:c.reason};if(!s)return{reason:n??"missing"};if(s.size>d)return{reason:"allowance"};try{let m=t??await(e.proposalRead??e.read)({...s,readBytes:void 0});if(m===null)return{reason:n??"unreadable"};let l=Buffer.byteLength(m),o=k(r,{path:a,size:l,text:m},f);return o.admitted?l>d?{reason:"allowance"}:{text:m}:{reason:o.reason}}catch(m){return m instanceof W?{reason:m.reason,invalidates:Gt.has(m.reason)}:{reason:"unreadable"}}}async function $t(r,e,a,s,t){let d=new Set(s.map(i=>i.path)),n=new Set(t.map(i=>i.path)),f=new Map(e.entries.map(i=>[i.path,i])),c=s.map(i=>({...f.get(i.path),readBytes:void 0})),m=i=>!d.has(i.path)&&!n.has(i.path),l=[...e.selection.selected.filter(m),...c],o=s.length||t.length?{...e.selection,selected:l,totalBytes:l.reduce((i,u)=>i+(u.readBytes??u.size),0),refused:e.selection.refused.filter(i=>!d.has(i.path))}:e.selection,p=e.evidence??{};if(t.length){let i=e.entries.filter(w=>!n.has(w.path)),{ranked:u,scan:g,markerPath:P,markerKind:h}=await ee(r,{entries:i,admission:e.admission,read:async w=>Object.hasOwn(a,w.path)?a[w.path]:null,plan:Y(r,{profile:"local-analysis",listing:i,selection:o})});p={ranked:u,scan:g,markerPath:P,markerKind:h}}return{...p,files:a,selection:o,settled:[...e.settled.filter(m),...c],skippedFiles:(e.skippedFiles??[]).filter(i=>!d.has(i.path)),...t.length?{invalidated:t}:{}}}async function te(r,e,a={}){if(!a.explicitScope&&!Dt(r)||!e.proposal)return;let s={...e.files},t=new Map(e.entries.map(p=>[p.path,p])),d=new Map(e.unavailable?.map(p=>[p.path,p.reason])),n={},f=[],c=[],m=new Set,l=new Set(e.settled.filter(p=>p.readBytes===void 0).map(p=>p.path)),o=Object.values(s).reduce((p,i)=>p+Buffer.byteLength(i),0);for(let p of e.proposal.files){let i=Ut.normalize(p.path.replace(/\\/g,"/")),u=Object.hasOwn(s,i)?Buffer.byteLength(s[i]):0,g=!e.proposalRead&&l.has(i)&&Object.hasOwn(s,i)?s[i]:void 0,P=m.has(i)?{reason:"duplicate"}:await Wt(r,e,i,t.get(i),g,ve.codeAgent.importBytes-o+u,d.get(i));if(m.add(i),"text"in P)o+=Buffer.byteLength(P.text)-u,s={...s,[i]:P.text},c.push({...p,path:i});else{let h=P.reason==="wrong-type"?"coding-guide":P.reason;n[h]=(n[h]??0)+1,P.invalidates&&Object.hasOwn(s,i)&&(o-=u,delete s[i],f.push({path:i,reason:P.reason}))}}return{...await $t(r,e,s,c,f),proposal:{...e.proposal,files:c},rejectedByReason:n}}function It(r,e=[],a){return e.find(s=>Ve(s.key,a)===r.id)?.folder??ne(r.files.length?r.files.map(s=>s.path):[r.sourceRef?.path??"."])}function Yt(r,e,a,s){let t=new Set(r.flatMap(f=>f.files.map(c=>c.path))),d=new Set(e.flatMap(f=>f.files.map(c=>c.path))),n=e.map(f=>It(f,a,s));return f=>d.has(f)||!t.has(f)&&n.some(c=>c==="."||c===""||f.startsWith(`${c}/`))}function Jt(r,e,a){let s=Object.fromEntries(Object.entries(e.files).filter(([o])=>a(o))),t=e.selection.selected.filter(o=>Object.hasOwn(s,o.path)),d=e.settled.filter(o=>a(o.path)),n=e.selection.refused.filter(o=>a(o.path)),f=e.selection.readingNotes,c=f?{instruction:f.instruction.filter(a),code:f.code.filter(a),agents:f.agents.filter(a)}:void 0,m=M(r,c??{instruction:[],code:[],agents:[]},d),l={...e.selection,selected:t,refused:n,readingNotes:c,skippedNote:m,totalBytes:t.reduce((o,p)=>o+(p.readBytes??p.size),0)};return{files:s,selection:l,settled:d,skippedFiles:e.skippedFiles.filter(o=>a(o.path)),invalidated:e.invalidated?.filter(o=>a(o.path))}}function Vt(r,e,a,s=[],t){let d=a??ne([...e]),n=r.filter(l=>l.kind==="agent").map(l=>{let o=It(l,s,t),p=o==="."||o===""||d===o||d.startsWith(`${o}/`);return{node:l,overlap:new Set(l.files.filter(i=>e.has(i.path)).map(i=>i.path)).size,containment:p?o.split("/").filter(i=>i&&i!==".").length+1:0}}).filter(l=>l.overlap||l.containment);n.sort((l,o)=>o.overlap-l.overlap||o.containment-l.containment);let[f,c]=n,m=!!f&&f.overlap===c?.overlap&&f.containment===c?.containment;return{target:m?void 0:f?.node,overlapping:n.filter(l=>l.overlap).map(l=>l.node),tied:m?n.filter(l=>l.overlap===f.overlap&&l.containment===f.containment).map(l=>l.node):[]}}function Qt(r,e,a){let s=new Set(r.map(n=>n.path)),t=!!a&&!r.some(n=>n.path===a.path&&n.role==="system prompt"),d=t?r.filter(n=>n.path!==a.path).map(n=>n.role==="system prompt"||n.role==="soul"?{...n,role:"reference"}:n):[...r];return d.push(...e.filter(n=>!s.has(n.path)&&n.path!==a?.path).map(n=>({path:n.path,role:n.role==="tools"||n.role==="config"?n.role:"reference",label:null}))),t&&d.unshift({path:a.path,role:"system prompt",label:null}),{files:d,promptChanged:t}}function Xt(r,e){let a=new Map(r.map(s=>[s.label,s]));for(let s of e)a.has(s.label)||a.set(s.label,s);return[...a.values()]}function Zt(r,e,a,s,t){return s.filter(d=>d.role==="tools"&&(/\.json$/i.test(d.path)||be(d.path)==="js")).flatMap(d=>Ce(r,e,a.files,{toolsPath:/\.json$/i.test(d.path)?d.path:null,toolsTsPath:/\.json$/i.test(d.path)?null:d.path,cliPath:null,mcpPath:null},t))}function eo(r,e,a,s,t,d){let n=Qt(s?.files??[],a,t),c={...s??{id:Je("",e.ruleResult.fragment.nodes.map(m=>m.id),()=>{})("agent"),kind:"agent",desc:le(null,n.files,!1),meta:null,tools:[],sourceRef:null},label:e.proposalSources.proposal.agentName,files:n.files,tools:Xt(s?.tools??[],Zt(r,e.repoKey,e.proposalSources,a,d))};return n.promptChanged&&t&&(c.desc=le(t.path,n.files,!1),c.sourceRef={path:t.path,line:null}),{agent:c,promptChanged:n.promptChanged}}function to(r,e,a,s,t){let{target:d,overlapping:n,tied:f}=a,{fragment:c}=r,m=new Set([e.id,...(t?[...n,...f]:c.nodes).map(i=>i.id)]);for(let i=-1;i!==m.size;){i=m.size;for(let u of c.edges)m.has(u.from)&&m.add(u.to)}let l=c.nodes.filter(i=>m.has(i.id)).map(i=>i===d?e:i);d||l.push(e);let o=c.edges.filter(i=>m.has(i.from)&&m.has(i.to)),p=r.codeAgents?.filter(i=>m.has(i.unitKey)).flatMap(i=>i.unitKey!==d?.id?[i]:s?[]:[{...i,name:e.label,ownFiles:e.files}]);return{fragment:{...c,nodes:l,edges:o},...p?{codeAgents:p}:{}}}function oo(r,e,a){let s=new Set(e.map(n=>n.path)),t=new Set([...r.flatMap(n=>n.files.map(f=>f.path)),...s]),d=s.size;return{fromProposal:d,fromRulesOnly:t.size-d,rejected:Object.values(a).reduce((n,f)=>n+f,0),rejectedByReason:a}}function jt(r){return r.files.some(e=>e.role==="system prompt"||e.role==="soul")}function so(r,e,a){if(e.some(t=>t.kind==="agent"&&!jt(t)))return new Set;let s=new Set([V({code:"no-prompt",detail:"no-conventions"},r),V({code:"no-prompt"},r),V({code:"no-prompt",folderAgentsFound:!0},r)]);return a!==void 0&&s.add(Xe(r,{scanned:a})),s}function Tt(r,e){let{ruleResult:a,proposalSources:s,root:t,repoKey:d,scopes:n,scanned:f,agentChoice:c}=e,m=a,{files:l,selection:o,settled:p,skippedFiles:i,invalidated:u}=s,g=[...a.warnings],P=s.proposal.files.map(v=>({...v,path:x(v.path,t)})),h=P.find(v=>v.role==="prompt"),w=!1;if(P.length){let v=Vt(m.fragment.nodes,new Set(P.map(E=>E.path)),h?.path,n,t);if(v.target||h||e.explicitScope){let{agent:E,promptChanged:B}=eo(r,e,P,v.target,h,g),I=c?.kind==="choose_agent";m={...m,...to(a,E,v,B,I)},I&&({files:l,selection:o,settled:p,skippedFiles:i,invalidated:u}=Jt(r,s,Yt(a.fragment.nodes,m.fragment.nodes,n,t))),w=jt(E);let H=so(d,m.fragment.nodes,f);g=g.filter(F=>!H.has(F))}}return{...m,files:l,selection:o,settled:p,skippedFiles:i,invalidated:u,...c&&!w&&!e.explicitScope?{agentChoice:c}:{},warnings:g,proposalCounts:oo(m.fragment.nodes,P,s.rejectedByReason)}}async function _t(r,e){let a=re(r,{entries:e.entries,paths:e.scope});if(a.tooLarge.length||a.unavailable.length||a.groups.length>1)throw new Error("bad_request");let s=new Map(e.proposal?.files.map(f=>[f.path,f])),t={agentName:e.proposal?.agentName??e.repoKey,files:e.scope.map(f=>s.get(f)??{path:f,role:"other"})},d=await te(r,{...e,proposal:t,files:{},settled:[],skippedFiles:[],selection:{selected:[],refused:[],totalBytes:0}},{explicitScope:!0});if(!d)throw new Error("bad_request");if(d.proposal.files.length!==new Set(e.scope).size)throw new Error("unavailable");let n=re(r,{entries:e.entries.map(f=>Object.hasOwn(d.files,f.path)?{...f,size:Buffer.byteLength(d.files[f.path])}:f),paths:Object.keys(d.files),inputBytes:Object.fromEntries(Object.entries(d.files).map(([f,c])=>[f,Ie(f,c)]))});if(n.tooLarge.length||n.unavailable.length||n.groups.length>1)throw new Error("bad_request");return d}function ao(r,e,a){return e.filter(s=>k(r,s,{purpose:"listing",route:"local-folder",...a}).admitted)}function Qs(r){let e=[],a=!1,s=Promise.resolve();return t=>new Promise((d,n)=>{e.push({entry:t,resolve:d,reject:n}),!a&&(a=!0,queueMicrotask(()=>{let f=e;e=[],a=!1,s=s.then(async()=>{try{let c=await r(f.map(m=>m.entry));if(c.length!==f.length)throw new Error("bad_request");f.forEach((m,l)=>m.resolve(c[l]))}catch(c){f.forEach(m=>m.reject(c))}})}))})}async function Xs(r,e){let a=je(r),s=a===void 0?void 0:new Set(a),t=S=>e.localListing?ao(r,S,e.admission):S,d=a===void 0?t(e.entries):e.entries.filter(S=>s.has(S.path)),n=Y(r,{profile:"local-analysis",listing:d,selection:e.selection}),f=a===void 0?await ee(r,{entries:d,read:e.read,admission:e.admission,plan:n}):{files:{},settled:[],skippedFiles:[]},{files:c,settled:m,skippedFiles:l,...o}=f,p=a!==void 0?await _t(r,{...e,entries:e.entries,scope:a}):await te(r,{proposal:e.proposal,entries:d,read:e.read,proposalRead:e.proposalRead,admission:e.admission,files:c,settled:m,skippedFiles:l,selection:n.selection,unavailable:e.proposalRefusals,evidence:o}),{files:i,settled:u,skippedFiles:g}=p??f,P=z({...p??o,key:e.repoKey,files:i},n.context.flags,void 0,{markerPolicy:"any-read"}),h=p?.selection??n.selection,w;if(a===void 0&&ke(r)&&e.repository){let S=e.repository,j=await We(r,{selected:{files:i,listedPaths:d.map(b=>b.path),fallbackName:Ze(e),skills:!0},selection:h,codeAgentsFound:Qe(r,P?.resolved,i),port:e.localListing?{context:()=>S.context(),read:(b,R)=>S.read(b,R),finish:b=>S.finish?.(b),list:async()=>{let b=await S.list();return{...b,entries:t(b.entries)}}}:S}),qt=new Set(Object.keys(i).map(b=>x(b,j.root)));if(i=j.files,h=j.selection,w=j.root,w!==void 0){g=g.map(R=>({...R,path:x(R.path,w)})),u=u.map(R=>({...R,path:x(R.path,w)}));let b=new Set(u.map(R=>R.path));u.push(...h.selected.filter(R=>!b.has(R.path)&&Object.hasOwn(i,R.path)))}g=T(g,j.skippedFiles).filter(b=>qt.has(b.path)||!Object.hasOwn(i,b.path))}let v={repoKey:e.repoKey,files:i,listedPaths:d.map(S=>x(S.path,w)),...w!==void 0?{root:w}:{},forLocal:!0,code:P},E=K(r,v),B=N(r,E),I=e.includeAgentPromptPaths?Te({codeAgents:B.codeAgents??[],conventions:E.conventions,root:w}):void 0,H=_e(r,{codeAgents:B.codeAgents??[],conventions:E.conventions,root:w,selection:e.membership}),F=p?Tt(r,{ruleResult:B,proposalSources:{...p,files:i,selection:h,settled:u,skippedFiles:g,invalidated:p.invalidated?.map(S=>({...S,path:x(S.path,w)}))},root:w,repoKey:e.repoKey,scopes:E.conventions.agentScopes,scanned:P?.resolved?.scanned,agentChoice:H,explicitScope:a!==void 0}):void 0,{settled:Nt,invalidated:he,...ue}=F??{...B,settled:u,invalidated:void 0};F&&(i=F.files,h=F.selection,u=Nt,g=F.skippedFiles);let ge=h.readingNotes?M(r,h.readingNotes,u):h.skippedNote,Pe=F?F.agentChoice:H;return{...ue,...Pe?{agentChoice:Pe}:{},...I?{agentPromptPaths:I}:{},files:i,...w!==void 0?{root:w}:{},skippedFiles:he?.length?T(g,he):g,...F?{proposalCounts:F.proposalCounts}:{},warnings:[...new Set([...ue.warnings,...ge?[ge]:[],...U(g)])],selection:h}}var ro=new Set(ut);function ta(r,e){for(let s of[...Object.keys(e.set),...e.clear])if(!ro.has(s))throw new Error(`Unknown analysis field: ${s}`);let a={...r,...e.set};for(let s of e.clear)a[s]=void 0;return a}async function no(r,e,a){let s=Object.entries(e).map(([d,n])=>({path:d,size:Buffer.byteLength(n),ref:d})),t=tt(r,s,a.root,!1,a.scanPaths);for(;!q(t);)t=await st(t,async d=>e[d.path]??null);return{scan:Q(r,t),summary:at(t)}}async function zt(r,e,a){let{repoKey:s,root:t,agentConfigurations:d,codingGuides:n,forLocal:f}=a,c=a.flags??Ne(r),m=Object.keys(e),l=C(r,{phase:"start",paths:m,root:t,scanFlag:c.scan}),o=l.kind==="marker"?C(r,{phase:"read",pending:l,text:e[l.markerPath]??null}):l,p=o.kind==="off"?null:o.markerPath,i=o.kind==="off"?null:o.markerKind;if(o.kind==="off"||!o.scan){let v=z({key:s,files:e,markerPath:p,markerKind:i},c,void 0,{markerPolicy:"any-read"});return{...N(r,K(r,{repoKey:s,files:e,root:t,agentConfigurations:d,codingGuides:n,forLocal:f,code:v})),scanned:!1,resolved:null}}let{scan:u,summary:g}=await no(r,e,{repoKey:s,root:t,scanPaths:o.scanPaths}),P=z({key:s,files:e,ranked:u,scan:g,markerPath:p,markerKind:i},c,void 0,{markerPolicy:"any-read"});return{...N(r,K(r,{repoKey:s,files:e,root:t,agentConfigurations:d,codingGuides:n,forLocal:f,code:P})),scanned:!0,resolved:P.resolved}}async function Kt(r,e){let{state:a,settings:s}=r;if(!Pt(s,a).splitCheck||!a.splitEstimateBase)return{next:"inspecting",set:{repoCursor:0},clear:[]};let d=r.execution.preparation?.capUsd??a.splitEstimateBase.capUsd,n={...a.splitEstimateBase,capUsd:d};xe(n,e.progress.log);let f=bt(s,a),c={next:"inspecting",set:{repoCursor:0,splitCheckPriced:!0,splitFindingsPriced:!0},clear:["splitEstimateBase"]};if(!f.length)return c;let m=Ye(J(await e.instructions())),l=f.reduce((g,{inventory:P})=>g+se(Buffer.byteLength(Rt({tools:m},{...P,findings:[]}).prompt))+se(m.SHAPE_FINDINGS_INPUT_BYTES),0),o=n.lines.find(g=>g.label==="Scope check"),p=ae(s,{template:"scope-findings"},"Scope check",Ae.mechanical,(o?.inputTokens??0)+f.length*Et,(o?.outputTokens??0)+f.length*Ft),i=n.lines.map(g=>g.label==="Scope check"?p:g);o||i.push(p),i.push(ae(s,{template:"derive-shape"},"Split check",vt,l,f.length*$e));let u=Fe(i,d);return Ee(u)?(c.estimate=n,c.clear.push("splitCheckPriced","splitFindingsPriced"),delete c.set.splitCheckPriced,delete c.set.splitFindingsPriced,e.progress.log({level:"warn",code:"analysis.split_check_over_cap",counts:{totalUsd:u.totalUsd,capUsd:u.capUsd}}),c.set.warnings=[...a.warnings??[],Oe]):c.estimate=u,c}var Ba=async(r,e)=>{e.progress.assertHeld(),e.progress.signal?.throwIfAborted();let{state:a,settings:s}=r,t=a.repos??[];await Le(s,a,e.readers);let d=a.repoCursor??0;if(d>=t.length)return Kt(r,e);let n=t[d],f=r.execution.forLocal,c=f?a.mapped?.[d]?{fragment:gt(a,d),warnings:[]}:await zt(s,n.files??{},{repoKey:n.key,root:n.root,agentConfigurations:n.agentConfigurations??{},forLocal:!0}):void 0,m=c?(()=>{let u=ye(c.fragment,n.key);return{...u,warnings:[...c.warnings,...u.warnings]}})():St(s,n,wt(s,a),a.modelReader??!1,a.projectAgents,J(await e.instructions()).bundleText("model-reader-runtime-prompt")),l=!f&&n.sourceReadNotes?M(s,n.sourceReadNotes,n.selected??[],n.root):void 0,o=f?[]:U((n.refused??[]).filter(u=>u.reason==="secret-content")),p="virtualFiles"in m?m.virtualFiles:void 0,i=[...a.mapped??[]];return i[d]=m.fragment,{next:"mapping",clear:[],set:{...p?{repos:t.map((u,g)=>g===d?{...u,files:{...u.files,...p}}:u)}:{},mapped:i,warnings:[...a.warnings??[],...l?[`${n.key}: ${l}`]:[],...o,...m.warnings,...kt(n)],repoCursor:d+1}}};export{Dt as a,ao as b,Qs as c,Xs as d,ta as e,Ba as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as i,d as n,e as c,f as l,g as a,h as u,i as f,j as h,l as d}from"./HHFDNY6V.js";import{d as s}from"./3MTXB4MK.js";import{a as S}from"./MZOKZ3N6.js";import{z as y}from"zod";function Q(e){let t=d(e),m=h(e);return{...t,headlinePlan(o){let r=t.analysisRequest(o),p=m.headlineFallbackQuestion();return{inputBytes:t.callInputBytes(r),fallbackQuestion:p,identity:{system:r.system,data:r.prompt,schema:y.toJSONSchema(r.schema),fallbackQuestion:p}}},modelReaderPrompt:()=>e.bundleText("model-reader-runtime-prompt"),validateShapeInput:o=>{a(e).shapeInputs(o)},...u(e),...n(e),...i(e),...s(e),...c(e),...l(e),...a(e),...f(e),...m,...S(e)}}export{Q as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.freeze({"benchmark-judge":"score_match","judge-code-prompt":"judge-code-prompt","derive-findings":"derive_findings","derive-findings-legacy":"derive_findings","derive-findings-no-outcome":"derive_findings","derive-findings-legacy-no-outcome":"derive_findings","derive-structure":"derive_structure","structure-recheck":"structure_recheck","derive-shape":"derive_shape","scope-items":"scope_check_structure","scope-findings":"scope_check","explain-sources":"explain_sources","finding-headlines":"finding_headlines","check-findings":"finding_check","check-findings-precision-v1":"finding_check","second-opinion":"finding_second_opinion"});function c(e){if(!Object.hasOwn(n,e))throw new Error("Unknown analysis template");return n[e]}function s(e){return Object.fromEntries(Object.entries(e).map(([i,r])=>[i,{...r,route:c(i)}]))}export{c as a,s as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as T,K as A,y as F,z as L}from"./FRXOQ2M6.js";import{a as S}from"./326F4XNG.js";import{a as _,f as O}from"./SP6XFHNH.js";import{a as E,b as C,g as R}from"./YTHF2E2S.js";import{Fb as x}from"./2AASSZRO.js";import{y as q}from"./YWL52FVW.js";import{a as M,j as I}from"./SJESFYBA.js";import{a as P}from"./S27VIQMZ.js";import{createHash as G}from"node:crypto";var N=new WeakMap,j={version:"shared-modules-v1",settingsFiles:I.settingsFiles,resolve(i,s){let{paths:l,files:t,settings:f}=s,u=M(i);if(!u)return[];let c=N.get(s);return c||(c=new I({files:new Map([...l].map(d=>[d,t.get(d)??""]))},f),N.set(s,c)),q(i,t.get(i)??"",u,{allReexports:!0,completeImports:!0}).map(d=>d.dynamic?{from:i,specifier:d.source,status:"refused",provenance:null,reason:"dynamic"}:c.resolve(i,d.source,d.names))}};var B=i=>i==="too-large"?"over-limit":i==="wrong-type"||i==="empty"?"unsupported":i;function V(i,s){let l=R(i);if(!E(l))return{kind:"refused",reason:"disabled"};let t=O.safeParse(s.request);if(!t.success||t.data.kind!=="file"||t.data.entries)return{kind:"refused",reason:"invalid-selection"};let f=t.data,u=s.resolver??j,c=F(l,{profile:"entry-analysis",listing:[...s.entries],selection:f,limits:s.limits}),{entries:d}=c;return{kind:"pending",checkpoint:{version:1,settings:l,request:f,entries:d,files:{},resolutions:{},unavailable:{},targets:{},attempted:{paths:[],bytes:0},resolverVersion:u.version,...u.identity===void 0?{}:{resolverIdentity:u.identity},...s.proposal?{proposal:structuredClone(s.proposal)}:{},limits:c.limits,inventoryIncomplete:(s.inventoryIncomplete??0)+c.inventoryIncomplete}}}async function Y(i,s){let l=O.safeParse(i.request);if(i.version!==1||!l.success||l.data.kind!=="file"||l.data.entries)return{kind:"refused",reason:"invalid-selection"};let t=structuredClone(i);t.request=l.data;let{settings:f,request:u}=t,c=s.resolver??j;if(c.version!==t.resolverVersion||c.identity!==t.resolverIdentity)return{kind:"refused",reason:"stale-snapshot"};if(!E(f))return{kind:"refused",reason:"disabled"};let d=new Map(t.entries.map(e=>[e.path,e])),k=new Set(d.keys()),v=new Map(Object.entries(t.files)),p=c.settingsFiles?.(k,v,[u.entry,...Object.keys(t.files)])??[];if(p.every(e=>Object.hasOwn(t.files,e)||Object.hasOwn(t.unavailable,e))){let e=Object.keys(t.files).filter(n=>!Object.hasOwn(t.resolutions,n)),r={paths:k,files:v,settings:f},o=await S(e,4,async n=>{try{return{path:n,edges:await c.resolve(n,r)}}catch{return{path:n,reason:"unreadable"}}});for(let{path:n,edges:g,reason:b}of o)Object.defineProperty(b?t.unavailable:t.resolutions,n,{value:b??g,enumerable:!0,configurable:!0,writable:!0})}let m=A(f,{...t,settingsFiles:p,targetIdentity:G("sha256").update(JSON.stringify(Object.entries(t.targets).sort(([e],[r])=>e.localeCompare(r)))).digest("hex")});if(m.kind==="refused")return{kind:"refused",reason:m.reason};if(m.kind==="ready")return{kind:"ready",selection:m.selection,files:Object.fromEntries(m.selection.files.map(e=>[e.path,t.files[e.path]]))};for(let[e,r]of Object.entries(m.unavailable??{}))Object.defineProperty(t.unavailable,e,{value:r,enumerable:!0,configurable:!0,writable:!0});let a={...f,CF_RESPECT_GITIGNORE:"1",CF_LOCAL_SYMLINK_GUARD:"1",CF_SECRET_SCAN:"1"},y=(e,r,o)=>{if(!P.safeParse(e).success||r&&r.root!==u.launchRoot)return"out-of-scope";let n=x(a,{path:e,...o===void 0?{}:{text:o}},{purpose:"entry",route:"local-folder",...s.admission,gitIgnored:s.gitIgnored,...r?{localTarget:r}:{}});return n.admitted?null:n.reason==="out-of-scope"&&r?"symlink-escape":B(n.reason)},z=await S(m.pending.filter(e=>!Object.hasOwn(t.files,e)).slice(0,4),4,async e=>{let r=0,o=!1;try{let n=y(e);if(n)return{path:e,reason:n,bytes:r,attempted:o};let g=await s.localTarget(e);if(!g)return{path:e,reason:"unreadable",bytes:r,attempted:o};if(n=y(e,g),n)return{path:e,reason:n,bytes:r,attempted:o};let b=d.get(e);o=!0,r=b.size;let h=await s.read({path:e,size:b.size,ref:b.ref,readBytes:b.size+1});if(h!==null&&(r=Buffer.byteLength(h)),h===null)return{path:e,reason:"unreadable",bytes:r,attempted:o};let w=await s.localTarget(e);return!w||w.path!==g.path||w.root!==g.root?{path:e,reason:"symlink-escape",bytes:r,attempted:o}:(n=y(e,w,h),n?{path:e,reason:n,bytes:r,attempted:o}:r!==b.size?{path:e,reason:"over-limit",bytes:r,attempted:o}:{path:e,text:h,target:w.path,bytes:r,attempted:o})}catch{return{path:e,reason:"unreadable",bytes:r,attempted:o}}});for(let e of z){if(e.attempted){let o=m.pendingSettings.includes(e.path)?t.settingsAttempted??={paths:[],bytes:0}:t.attempted;o.paths.push(e.path),o.bytes+=e.bytes}let r=(o,n)=>Object.defineProperty(o,e.path,{value:n,enumerable:!0,configurable:!0,writable:!0});e.reason?r(t.unavailable,e.reason):e.text!==void 0&&(r(t.files,e.text),r(t.targets,e.target))}return{kind:"pending",checkpoint:t}}async function D(i,s){let l=O.safeParse(s.request);if(l.success&&l.data.kind==="file"&&l.data.entries){if(!C(i))return{kind:"refused",reason:"disabled"};let f=l.data,u=new Map,c=a=>{let y=u.get(a.path);return y||(y=Promise.resolve(s.read(a)),u.set(a.path,y)),y},d=await S(f.entries.slice(0,_.choices),4,async a=>{try{return await D(i,{...s,proposal:void 0,read:c,request:{kind:"file",launchRoot:f.launchRoot,entry:a}})}catch{return{kind:"refused",reason:"invalid-selection"}}}),k=d.find(a=>a.kind==="refused"&&a.reason!=="over-limit");if(k?.kind==="refused")return k;let v=d.filter(a=>a.kind==="ready");if(!v.length)return{kind:"refused",reason:"over-limit"};let p=L(f,v.map(a=>a.selection));if(p.kind!=="ready")return{kind:"refused",reason:p.kind==="refused"?p.reason:"invalid-selection"};let m=Object.fromEntries(v.flatMap(a=>Object.entries(a.files)));return T(s.proposal,p.selection.files)?{kind:"ready",selection:p.selection,files:Object.fromEntries(p.selection.files.map(a=>[a.path,m[a.path]]))}:{kind:"refused",reason:"invalid-scope"}}let t=V(i,s);for(;t.kind==="pending";)t=await Y(t.checkpoint,s);return t}export{V as a,Y as b,D as c};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{J as ct,K as pt,d as rt,h as at,j as lt,k as it,m as ft,r as re}from"./FRXOQ2M6.js";import{b as st}from"./33IGHOYT.js";import{e as te,g as Ce}from"./YTHF2E2S.js";import{a as W,b as he,c as Qe,e as He,f as Ze,g as et,h as tt,i as ge,j as ot,k as nt,n as V}from"./4PT5C4IT.js";import{Fb as _,K as Ie,X,a as Me,aa as ze,b as je,ba as ue,ca as Ge,d as de,db as Q,e as K,f as Ae,fb as se,g as Ee,h as oe,i as I,k as _e,ka as Ke,kb as De,l as Ne,la as qe,lb as Ue,mb as Ye,n as Te,na as Je,nb as Ve,r as Le,u as ne,wb as Xe,za as J}from"./2AASSZRO.js";import{b as G,c as L}from"./C6X5GDG4.js";import{a as Re,b as R,c as B,k as z,l as q,v as Be}from"./YWL52FVW.js";import{a as Fe,f as We}from"./SJESFYBA.js";function ye(e,t,n){if(!oe(e)||!t.filenameReferences?.length)return n;let f=n.agents.flatMap(l=>l.prompt.kind==="dedicated"?[{path:l.prompt.path}]:[]),i=Ge(t.filenameReferences,f);return{...n,agents:n.agents.map(l=>{if(l.prompt.kind!=="dedicated")return l;let m=l.prompt.path,p=i.filter(d=>d.promptPath===m&&!l.files.some(y=>y.path===d.readerPath)&&_(e,{path:d.readerPath},{purpose:"override",route:"github",root:t.root}).admitted);return p.length?{...l,files:[...l.files,...p.map(d=>({path:d.readerPath,role:"reference",label:"prompt filename reference"}))]}:l})}}function D(e,t,n){return e.filter(f=>t.some(i=>i.includes(n(f))))}function mt(e,t,n){if(!e.length||n&&!I(n.settings))return;let f;if(n&&!K(n.settings)){let i=Object.keys(n.files).filter(p=>L(p,n.root)!==null&&_(n.settings,{path:p},{purpose:"override",route:"github",root:n.root}).admitted),l=i.filter(p=>Me(L(p,n.root))).sort((p,d)=>je(L(p,n.root),L(d,n.root)));if(!l.length)return;let m=D(i.filter(p=>!l.includes(p)&&J(p)).sort(),l.map(p=>n.files[p]),p=>L(p,n.root));f=[...l.map(p=>({path:p,role:"reference",label:"developer guidance"})),...m.map(p=>({path:p,role:"reference",label:null}))]}else{if(!t||t.prompt.kind!=="fallback")return;let i=t.prompt.path;if(e.some(l=>l.files.some(m=>m.path===i)))return;f=t.files.map(l=>({...l,role:"reference",label:l.role==="system prompt"?"developer guidance":l.label}))}f=f.filter(i=>!e.some(l=>l.files.some(m=>m.path===i.path))),f.length&&(e[0]={...e[0],files:[...e[0].files,...f],sharedReferencePaths:[...e[0].sharedReferencePaths??[],...f.map(i=>i.path)]})}function ke(e,t){return["[","{"].some(n=>R(e.source.toks[t.from],n))&&z(e.source.toks,t.from)===t.to?{...t,to:t.to+1}:e.calls.find(n=>n.from===t.from&&n.to===t.to+1&&R(e.source.toks[t.to],")"))??t}function N(e,t,n=new Set){let{toks:f}=e.source;if(t.to!==t.from+1||!B(f[t.from])||["True","False","None"].includes(f[t.from].text))return t;let i=e.binding(f[t.from].text,t.from);return!i||i.append||!e.bindingIsCertain(i,t.from)||n.has(i.at)||e.functions.some(l=>l.from<t.from&&t.from<l.to&&l.params?.includes(i.name))?null:N(e,ke(e,i),new Set([...n,i.at]))}import{posix as dt}from"node:path";function ut(e,t,n,f,i){let{source:{path:l,toks:m}}=e,p=[],d=[],y=[],a=[],k=(u,o)=>a.push({path:u,reason:o}),c=(u,o,b,S=null)=>({path:o,role:u,label:S,...b?{span:b}:{}}),r=(u,o)=>{let b=e.importBinding(u,o),S=t.filter(g=>g.name===u&&g.from<o&&(g.params!==null||g.kind==="class")&&(!e.owner(g.from)||e.owner(g.from)===e.owner(o)));if(!b)return S.length===1?{path:l,span:{from:m[S[0].from].line,to:m[S[0].to-1].endLine}}:null;let x=b.module.source,O=i.length===1?dt.dirname(dt.dirname(i[0])):"",s=We(x.startsWith(".")?l:`${O?`${O}/`:""}__root__.py`,x.startsWith(".")?x:`.${x}`,[b.name],"py",f);return s?{path:s}:null},h=n&&N(e,n);if(h&&R(m[h.from],"[")&&z(m,h.from)===h.to-1)for(let u of q(m,h.from)){let o=u.to===u.from+1&&B(m[u.from])&&!e.binding(m[u.from].text,u.from)?u:N(e,u);if(!o||!B(m[o.from])){k(l,"dynamic");continue}let b=m[o.from].text;if(!(o.to===o.from+1||R(m[o.from+1],"(")&&z(m,o.from+1)===o.to-1)){k(l,"dynamic");continue}if(e.functions.some(O=>O.from<o.from&&o.from<O.to&&O.params?.includes(b))){k(l,"dynamic");continue}if(!e.importBinding(b,o.from)&&!t.some(O=>O.name===b&&(O.params!==null||O.kind==="class")&&O.from<o.from)){k(l,"dynamic");continue}p.push(b);let x=r(b,o.from);x&&(y.push(c("tools",x.path,x.span,b)),d.push(x.path))}else n&&k(l,"dynamic");return{names:p,files:y,proofPaths:d,refused:a}}function ht(e,t,n,f,i,l){let m=t.source,{path:p,toks:d}=m,{files:y,paths:a,frameworks:k,defaultsByPath:c}=l,r={prompt:{kind:"none"},files:[]},h=[],u,o=(s,g)=>h.push({path:s,reason:g}),b=(s,g,P,w=null)=>({path:g,role:s,label:w,...P?{span:P}:{}});c.has(p)||c.set(p,ge(p,m.text,a));let S=c.get(p),x=s=>{r.layoutProof??={kind:"outside-loader",paths:[]},r.layoutProof.paths.push(s);let g=y[s];if(g===void 0){r.files.push(b("template",s)),o(s,"missing");return}let P=tt(g,e);if(P.unresolved.length||!P.fields.some(w=>w.key==="system_prompt"&&w.value!==null)){o(s,"invalid");return}for(let w of P.fields.filter(v=>v.value!==null))r.files.push(b(w.key==="system_prompt"?"system prompt":"template",s,w.span,w.key)),w.key==="system_prompt"&&(r.prompt={kind:"entry",path:s,span:w.span,text:w.value})},O=n.get("prompt_templates")??n.get("system_prompt");if(O){let s=N(t,O),g=s&&X(m,s);if(g&&n.has("system_prompt"))r.prompt={kind:"entry",path:p,span:g.span,text:d[s.from].value},u={path:p,start:g.start},r.files.push(b("system prompt",p,g.span));else if(s&&R(d[s.from],"{")&&z(d,s.from)===s.to-1){let P=!1,w=(v,C="")=>{let $=new Set;for(let j of q(d,v.from)){let M=d[j.from]?.kind==="string"?d[j.from].value:null;if(!M||$.has(M)||!R(d[j.from+1],":")){o(p,"invalid"),P=!0;return}$.add(M);let A=N(t,{from:j.from+2,to:j.to}),T=A&&X(m,A);T?(r.files.push(b(M==="system_prompt"?"system prompt":"template",p,T.span,C+M)),M==="system_prompt"&&!C&&(r.prompt={kind:"entry",path:p,span:T.span,text:d[A.from].value},u={path:p,start:T.start})):A&&R(d[A.from],"{")?w(A,`${C}${M}.`):o(p,"dynamic")}};w(s),P&&(r.prompt={kind:"none"},r.files=[])}else{let P=s&&S.find(w=>w.start===d[s.from].start&&w.end===d[s.to-1].end);P?.path&&!P.reason?x(P.path):o(p,"dynamic")}}else if(f.args.some(s=>!B(d[s.from])||!R(d[s.from+1],"=")))o(p,"dynamic");else if(k.length===1){let s=k[0],g=y[s];if(g===void 0)r.files.push(b("config",s)),r.layoutProof={kind:"outside-loader",paths:[s]};else{c.has(s)||c.set(s,ge(s,g,a));let P=c.get(s).filter(M=>M.className===i&&M.binding==="prompt_templates"&&M.forwarded),w=n.get("use_structured_outputs_internally"),v=w?N(t,w):null,C=v&&v.to===v.from+1&&["True","False"].includes(d[v.from].text)?d[v.from].text==="True":null,$=P.filter(M=>M.when?.every(A=>A.parameter==="use_structured_outputs_internally"&&A.value===(w?C:A.defaultValue))),j=$.length===1?$[0]:null;j?.path&&(!j.reason||j.reason==="missing")?x(j.path):o(s,"dynamic")}}else o(p,k.length>1?"dynamic":"missing");return{...r,promptSite:u,refused:h}}function gt(e,t,n=t.files){let f={agents:[],refused:[]};if(!I(e))return f;let i={...n,...t.files},l=new Set([...Object.keys(i),...t.listedPaths??[]]),m=new Set(Ke(e,[...l],t.root)),p=[...l].filter(a=>/(?:^|\/)smolagents\/agents\.py$/.test(a)),d=new Map,y=(a,k)=>f.refused.push({path:a,reason:k});for(let[a,k]of Object.entries(t.files)){if(!k.includes("smolagents")||Le(a,{listing:l,root:t.root})&&!Te(e,a,t.root)||!/\.py$/i.test(a)&&!m.has(a)||!_(e,{path:a,size:Buffer.byteLength(k)},{purpose:"code-scan",route:"github",root:t.root,listing:l}).admitted)continue;let c=m.has(a)?qe(a,k).filter(s=>s.lang==="py"):null,r=c?Je(k,c):k,h=Re(a,r,"py"),u=Be(h,{includeMembers:!0}),o=ze(h,u,{enclosingBindings:!0}),{toks:b}=h,S=[],x=s=>{let g=s&&N(o,s);return g&&X(h,g)?b[g.from].value:null},O=(s,g,P,w=null)=>({path:g,role:s,label:w,...P?{span:P}:{}});for(let s of o.calls){let g=o.importBinding(s.callee,s.from);if(!g||!["smolagents","smolagents.agents"].includes(g.module.source)||!["CodeAgent","ToolCallingAgent"].includes(g.name))continue;let P=new Map(s.args.flatMap(E=>B(b[E.from])&&R(b[E.from+1],"=")?[[b[E.from].text,{from:E.from+2,to:E.to}]]:[])),w=c?.find(E=>E.span.from<=b[s.from].line&&b[s.from].line<=E.span.to);if(w&&(g.module.line<w.span.from||w.span.to<g.module.line)){let E=P.get("managed_agents"),Y=E&&N(o,E);if(!(Y&&R(b[Y.from],"[")&&q(b,Y.from).some(me=>{let $e=N(o,me);return $e&&S.some(Bt=>Bt.at===$e.from)})))continue}let C=o.assignments.find(E=>E.from===s.from&&ke(o,E).to===s.to)?.name??`line-${b[s.from].line}`,$=`smolagents:${JSON.stringify([a,b[s.from].start])}`,j={from:b[s.from].line,to:b[s.to-1].endLine},M={key:$,name:x(P.get("name"))??C,model:null,description:x(P.get("description")),prompt:{kind:"none"},files:[],skills:[],tools:[],subagents:[],layoutCall:{path:a,callStart:b[s.from].start,line:j.from,loadedPrompt:!0}},A=ht(e,o,P,s,g.name,{files:i,paths:l,frameworks:p,defaultsByPath:d});M.prompt=A.prompt,M.files.push(...A.files),A.layoutProof&&(M.layoutProof=A.layoutProof),A.promptSite&&(M.layoutCall.promptPath=A.promptSite.path,M.layoutCall.promptStart=A.promptSite.start),f.refused.push(...A.refused),M.files.push(O(c?"system prompt":"config",a,j));let T=ut(o,u,P.get("tools"),l,p);M.tools=T.names,M.files.push(...T.files),T.proofPaths.length&&(M.layoutProof??={kind:"outside-loader",paths:[]},M.layoutProof.paths.push(...T.proofPaths)),f.refused.push(...T.refused),f.agents.push(M),S.push({agent:M,name:C,at:s.from,children:P.get("managed_agents")})}for(let s of S){if(!s.children)continue;let g=N(o,s.children);if(!g||!R(b[g.from],"[")||z(b,g.from)!==g.to-1){y(a,"dynamic");continue}for(let P of q(b,g.from)){let w=N(o,P),v=w&&S.find($=>$.at===w.from&&w.to===o.calls.find(j=>j.from===$.at)?.to);if(!v||v===s){y(a,"dynamic");continue}let C=v.agent.prompt;s.agent.subagents.push({key:v.agent.key,path:C.kind==="none"?a:C.path,name:v.agent.name,description:v.agent.description,prompt:C.kind==="entry"?C.text:"",tools:v.agent.tools,skillPaths:[],files:v.agent.files})}}}return f}import{basename as Dt}from"node:path";import{basename as Kt}from"node:path";var kt=/^[\w.*:/()-]+$/,bt=/^(?:true|false|null|~|[-+]?(?:\d[\d_.eExXoObB+-]*|\.\d[\d_eE+-]*|\.inf|\.nan)|\d{4}-\d{1,2}-\d{1,2}(?:[Tt].*)?)$/i,le=e=>kt.test(e)&&!e.startsWith("*")&&!bt.test(e);function ae(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e}return e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function Z(e,t=!1,n=!1){let f=[],i="",l=0,m=-1,p=0,d=()=>{m>=0&&f.push([m,p]),m=-1};for(let y=0;y<e.length;y++){let a=e[y];if(i){i==='"'&&a==="\\"?y++:a===i&&(i==="'"&&e[y+1]==="'"?y++:i=""),p=y+1;continue}if(!n&&a==="#"&&(y===0||/\s/.test(e[y-1]))){if(!t)return d(),{spans:f,end:y,comment:e.slice(y)};let k=e.indexOf(`
|
|
2
|
+
`,y);y=k<0?e.length:k;continue}if(t&&a==="]"&&l===0)return d(),{spans:f,end:y,comment:""};if(a===","&&l===0){d();continue}/\s/.test(a)||(m<0&&(m=y),(a==='"'||a==="'")&&(m===y||l>0)?i=a:a==="("?l++:a===")"&&l>0&&l--,p=y+1)}if(t)throw new Error("Unclosed frontmatter tool list");return d(),{spans:f,end:e.length,comment:""}}function yt(e,t){let n=e.startsWith("["),f=Z(n?e.slice(1):e,n),i=(n?e.slice(1,f.end+1):e.slice(0,f.end)).trimEnd(),l=!n&&f.spans.length===1&&/^["']/.test(i)&&ae(i)!==i?i[0]:"",m=l?ae(i):n?e.slice(1,f.end+1):e.slice(0,f.end).trimEnd(),p=n?f.spans:Z(m,!1,!!l).spans,d=0,y=p.flatMap(([k,c],r)=>{let h=m.slice(k,c),u=ae(h),o=m.slice(d,k).replace(/[^\S\n]*#[^\n]*/g,""),b=n?m.slice(c,p[r+1]?.[0]??m.length):"",S=b.match(/[^\S\n]*#[^\n]*/g)?.join(`
|
|
3
|
+
`)??"";return d=c,u?[{name:u,raw:h,before:o,note:S,noteAfterComma:/^[^\S\n]*,/.test(b)}]:[]}),a=n?e.slice(f.end+2).split(`
|
|
4
|
+
`)[0]:e.slice(i.length);return{style:n?"flow":"comma",outerQuote:l,quote:y.find(k=>/^["']/.test(k.raw))?.raw[0]??"",prefix:"",suffix:a,head:(y[0]?.before??m).replace(/,/g,""),tail:y.length?m.slice(d).replace(/[^\S\n]*#[^\n]*/g,""):"",separator:y[1]?.before.replace(/#[^\n]*/g,"")??(m.includes(`
|
|
5
|
+
`)?`,
|
|
6
|
+
${m.match(/\n([^\S\n]*)/)[1]}`:", "),entries:y,first:t,last:t+e.slice(0,n?f.end+2:e.length).split(`
|
|
7
|
+
`).length-1,indent:" - ",blockComments:[]}}function zt(e){let t=Q(e),n=t?.raw.map(p=>p.replace(/\r$/,""))??null,f=[],i=[],l={},m=[];if(n)for(let p=0;p<n.length;p++){let d=/^([A-Za-z_][\w-]*\s*:[^\S\n]*)(.*)$/.exec(n[p]);if(!d||!/^tools\s*:/i.test(d[1]))continue;let y=Z(d[2]),a;d[2].startsWith("[")?a=yt(n.slice(p).join(`
|
|
8
|
+
`).slice(d[1].length),p):a=yt(d[2],p),a.prefix=d[1];let k=a.style==="flow"?Z(a.suffix).comment:y.comment;if(k&&(l[a.style==="flow"?a.last:p]=k),a.style==="flow")for(let c of a.entries)c.note&&m.push({tool:c.name,comment:c.note.trim()});if(!d[2].slice(0,y.end).trim()){a.style="block",a.suffix=d[2];for(let c=p+1;c<n.length;c++){if(!n[c].trim()||/^\s*#/.test(n[c])){/^\s+#/.test(n[c])&&a.blockComments.push(c);continue}let r=/^(\s*-\s+)(.*)$/.exec(n[c]);if(!r)break;let h=Z(r[2]),u=r[2].slice(0,h.end).trimEnd(),o=ae(u);a.indent=r[1],o&&a.entries.push({name:o,raw:u,before:"",note:"",noteAfterComma:!1,row:n[c]}),h.comment&&o&&m.push({tool:o,comment:h.comment}),i.push(c),a.last=c}a.quote=a.entries.map(c=>c.raw).find(c=>/^["']/.test(c))?.[0]??""}for(let c=p;c<=(a.style==="block"?p:a.last);c++)i.push(c);f.push(a),p=a.last}return{header:t,lists:f,tools:f.length?f.flatMap(p=>p.entries.map(d=>d.name)):null,lines:n,toolLines:i,toolComments:l,itemComments:m}}function Pt(e){try{return zt(e)}catch{let t=Q(e);return{header:t,lists:[],tools:[],lines:t.raw.map(n=>n.replace(/\r$/,"")),toolLines:[],toolComments:{},itemComments:[],error:"Unclosed frontmatter tool list"}}}function Gt(e){let{tools:t,lines:n,toolLines:f,toolComments:i,itemComments:l,error:m}=Pt(e);return{tools:t,lines:n,toolLines:f,toolComments:i,itemComments:l,...m?{error:m}:{}}}function wt(e){let t=Gt(e);if(t.error)throw new Error(t.error);let{tools:n,lines:f,toolLines:i,toolComments:l,itemComments:m}=t;return{tools:n,lines:f,toolLines:i,toolComments:l,itemComments:m}}function ie(e){return e.every(t=>kt.test(t)&&!t.startsWith("*"))&&(e.length!==1||le(e[0]))?e.join(", "):`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}function H(e,t){return t==="'"&&!/[\r\n]/.test(e)?`'${e.replace(/'/g,"''")}'`:t==='"'||!le(e)?JSON.stringify(e):e}function Bo(e,t){let n=Pt(e);if(n.error)return e;let f=n.tools??[],i=t([...f]);if(i.length===f.length&&i.every((h,u)=>h===f[u]))return e;if(!n.header){let h=e.startsWith("\uFEFF")?"\uFEFF":"";return`${h}---
|
|
9
|
+
tools: ${ie(i)}
|
|
10
|
+
---
|
|
11
|
+
${e.slice(h.length)}`}let{header:l,lists:m,toolLines:p,toolComments:d}=n,y=new Map,a=m[0];if(a){let h=m.flatMap(b=>b.entries),u=i.map(b=>{let S=h.findIndex(x=>x.name===b);return S<0?{name:b,raw:H(b,a.quote),before:a.separator,note:"",noteAfterComma:!1}:h.splice(S,1)[0]}),o=a.prefix.endsWith(" ")?a.prefix:`${a.prefix} `;if(!i.length)y.set(a.first,`${o}[]${a.style==="block"&&a.suffix?` ${a.suffix}`:a.suffix}`);else if(a.style==="block"){y.set(a.first,`${a.prefix}${a.suffix}`);let b=p.filter(S=>S>a.first&&S<=a.last).sort((S,x)=>S-x);for(let S=0;S<u.length;S++){let x=u[S],O=a.entries.includes(x)&&x.row?le(x.raw)||/^["']/.test(x.raw)?x.row:x.row.replace(x.raw,H(x.name,a.quote)):`${a.indent}${H(x.name,a.quote)}`,s=b[Math.min(S,b.length-1)]??a.first;y.set(s,`${y.has(s)?`${y.get(s)}${l.newline}`:""}${O}`)}}else{let b=a.style==="flow"||i.length===1&&bt.test(i[0])||i.some(s=>s.includes(",")||s!==s.trim()||/[\r\n]|(?:^|\s)#|:\s|^[[\]{}&*!|>'"%@`]/.test(s)),S=a.head;for(let[s,g]of u.entries()){if(s){let P=g.before||a.separator,w=u[s-1];w.note&&(w.noteAfterComma?(P=P.replace(/,[^\S\n]*/,`,${w.note}`),P.includes(`
|
|
12
|
+
`)||(P+=`
|
|
13
|
+
`)):P=`${w.note}${/^[^\S\n]*\n/.test(P)?"":`
|
|
14
|
+
`}${P}`),S+=P}S+=b?/^["']/.test(g.raw)||le(g.raw)?g.raw:H(g.name,a.quote):g.name}let x=u[u.length-1];x.note?(S+=x.noteAfterComma&&!a.tail.includes(",")?",":"",S+=x.noteAfterComma&&a.tail.includes(",")?a.tail.replace(",",`,${x.note}`):`${x.note}${a.tail}`,a.tail.includes(`
|
|
15
|
+
`)||(S+=`
|
|
16
|
+
`)):S+=a.tail;let O=b?`[${S}]`:a.outerQuote?H(S,a.outerQuote):S;y.set(a.first,`${a.prefix}${O}${a.suffix}`.replace(/\n/g,l.newline))}}let k=new Set(p),c=l.raw.map((h,u)=>y.has(u)?`${y.get(u)}${l.newline}`:k.has(u)?d[u]&&u>a.last?`${d[u]}${l.newline}`:"":`${!i.length&&m.some(b=>b.blockComments.includes(u))?h.trimStart():h}
|
|
17
|
+
`).join(""),r=a?"":`tools: ${ie(i)}${l.newline}`;return`${e.slice(0,l.start)}${c}${r}${e.slice(l.end)}`}function be(e){return e.CF_LEGACY_TOOL_LISTS!=="1"}function Ko(e,t){return be(e)?ie(t):t.join(", ")}var qt=/^\s*(name|description|tools|model)\s*:\s*(.+?)\s*$/i;function Jt(e){if(e.startsWith('"')&&e.endsWith('"'))try{return JSON.parse(e)}catch{}return e.replace(/^["']|["']$/g,"")}function ee(e,t,n,f){let i=be(e),l=Kt(t).replace(/\.md$/i,""),m,p,d=[],y=!1,a=n,k=[],c=Q(n,i?void 0:"markdown");if(c){a=n.slice(c.bodyStart).trim();let h=i?c.raw.map(u=>u.replace(/\r$/,"")):c.raw;for(let u=0;u<h.length;u++){let b=h[u].match(qt);if(!b)continue;let S=b[1].toLowerCase(),x=Jt(b[2]);if(S==="name")l=x;else if(S==="description")if(/^[>|][+-]?$/.test(b[2])){let O=[];for(;u+1<h.length&&(/^\s+\S/.test(h[u+1])||h[u+1].trim()==="");)O.push(h[++u].trim());m=O.join(x[0]===">"?" ":`
|
|
18
|
+
`).trim()}else m=x;else S==="model"?p=x:S==="tools"&&!i&&(y=!0,d=x.replace(/^\[|\]$/g,"").split(",").map(O=>O.trim()).filter(Boolean))}}if(i)try{let h=wt(n);d=h.tools??[],y=h.tools!==null}catch{y=!0,k.push("tools could not be read; check the tool list")}let r=a.trim();return{name:l,...m!==void 0?{description:m}:{},...r?{prompt:r}:{},...!f?.preserveToolAbsence||y?{tools:d}:{},...p!==void 0?{model:p}:{},...k.length?{warnings:k}:{}}}function St(e,t,n){let f=t.managed,i=[],l=new Set([...f.agents,...f.configs,...Object.keys(n.files),...n.listedPaths??[]]),m=new Set(Ue(e,[...l],n.files)),p=Object.fromEntries(Object.entries(n.files).filter(([c,r])=>{if(m.has(c))return!1;let h=_(e,{path:c,text:r},{purpose:"override",route:"github",root:t.folder,listing:l,managedFiles:n.files});return!h.admitted&&h.reason==="secret"&&i.push({path:c,reason:"secret"}),h.admitted})),d=new Map;for(let c of f.agents){if(p[c]===void 0){i.some(h=>h.path===c)||i.push({path:c,reason:"missing"});continue}let r=Ye(c,p[c],f,n.listedPaths??Object.keys(n.files));i.push(...r.refused),d.set(c,r)}let y=new Set([...d.values()].flatMap(c=>c.relationships.filter(r=>r.kind==="agent").map(r=>r.path))),a=[...d.values()].filter(c=>!y.has(c.path));return!a.length&&d.size&&a.push(d.values().next().value),{agents:a.map(c=>{let r=[{path:c.path,role:"system prompt",label:null}],h=[],u=[],o=(b,S,x)=>{for(let O of b.relationships){if(p[O.path]===void 0){i.some(s=>s.path===O.path)||i.push({path:O.path,reason:"missing"});continue}if(O.kind==="agent"){if(S.has(O.path)){i.push({path:O.path,reason:"cycle"});continue}let s=d.get(O.path);if(!s||u.some(P=>P.path===s.path))continue;let g=[];u.push({path:s.path,name:s.name,description:s.description,prompt:s.prompt,...s.model?{model:s.model}:{},tools:[],skillPaths:[],files:g}),o(s,new Set([...S,s.path]),g)}else if(O.kind==="skill"&&n.skills&&Ie(e)||O.kind==="config"&&Ve(p[O.path])){if(x.some(s=>s.path===O.path))continue;if(x.push({path:O.path,role:O.kind==="skill"?"skill":"config",label:null}),O.kind==="skill"&&b===c){let s=ee(e,Dt(O.path),p[O.path]);h.push({path:O.path,name:s.name,description:s.description??"",body:s.prompt??""})}}}};return o(c,new Set([c.path]),r),{key:`managed:${c.path}`,name:c.name,model:c.model,description:c.description,prompt:{kind:"dedicated",path:c.path},files:r,tools:[],skills:h,subagents:u}}),notes:[],registry:!1,refused:i}}function vt(e,t,n){let f=t.miniSwe,i=n.templateSelection?.agentPath===f.agentPath?n.templateSelection.configPaths:void 0,l=ot(e,f,n.files,i),m=l.unresolved.filter(o=>o.reason!=="runtime-variable").map(o=>({path:o.target??o.path,reason:o.reason==="duplicate"?"invalid":o.reason})),p=l.fields.find(o=>o.key==="agent.system_template"&&o.value!==null),d=l.fields.find(o=>o.key==="agent.instance_template"&&o.value!==null),y=l.unresolved.some(o=>l.selectedPaths.includes(o.path)&&o.source===o.path);if(!p||!d||y||m.some(o=>o.reason==="invalid"))return{agents:[],notes:[],registry:!1,refused:m};let a=[p,...l.fields.filter(o=>o!==p)].map(o=>({path:o.path,span:o.span,label:o.key,role:o===p?"system prompt":o.key.endsWith("_template")?"template":"config"}));a.push(...l.loaded.map(o=>({path:o.path,role:"template",label:null})));let k=[];for(let o of a){let b=k.find(S=>S.path===o.path);b?b.span&&o.span&&(b.span={from:Math.min(b.span.from,o.span.from),to:Math.max(b.span.to,o.span.to)}):k.push({...o})}let c=[...new Set(k.map(o=>o.path))],r=Object.fromEntries(c.map(o=>[o,n.files[o]])),h=new Map(c.map(o=>[o,Buffer.byteLength(r[o])])),u=ct(e,{ownPaths:c},{files:r,sizes:h,root:t.folder});return m.push(...u.refused,...u.skipped),l.fields.some(o=>!u.paths.includes(o.path))?{agents:[],notes:[],registry:!1,refused:m}:(l.loaded=l.loaded.filter(o=>u.paths.includes(o.path)),l.edges=l.edges.filter(o=>u.paths.includes(o.from)&&u.paths.includes(o.to)),{agents:[{key:t.key,name:n.fallbackName,model:l.model,description:null,prompt:{kind:"entry",path:p.path,span:p.span,text:p.value},files:k.filter(o=>u.paths.includes(o.path)),tools:[],skills:[],subagents:[],templateVariants:l}],notes:[],registry:!1,refused:m})}function Ot(e,t,n){if(!t.skills||!ne(e))return n;let f=[...new Set([...Object.keys(t.files),...t.listedPaths??[]])],i=V(e,f,t.root,{files:t.files,listedPaths:t.listedPaths,agentConfigurations:t.agentConfigurations}),l=new Set(i.files.filter(k=>k.role==="skill").map(k=>k.path)),m=k=>[...new Set([...k.skillPaths.filter(c=>l.has(c)),...k.files?.filter(c=>c.role==="skill").map(c=>c.path)??[]])],p=n.agents.flatMap(k=>[...k.skills.map(c=>c.path),...k.subagents.flatMap(m)]),d=re(e,{skillPaths:p,paths:f,files:t.files,root:t.root});for(let k of d)k.files=k.files.filter(c=>Object.hasOwn(t.files,c.path));let y=new Map(d.map(k=>[k.ownerPath,k])),a=(k,c)=>{let r=new Set(c.flatMap(u=>u.refused.map(o=>o.path))),h=k.filter(u=>u.role!=="reference"||!r.has(u.path));for(let u of c)for(let o of u.files)h.some(b=>b.path===o.path)||h.push({path:o.path,role:"reference",label:null});return h};return{...n,agents:n.agents.map(k=>{let c=k.skills.flatMap(r=>y.has(r.path)?[y.get(r.path)]:[]);return{...k,files:a(k.files,c),skills:k.skills.map(r=>({...r,...y.has(r.path)?{manifest:y.get(r.path)}:{}})),subagents:k.subagents.map(r=>{let h=m(r).flatMap(g=>y.has(g)?[y.get(g)]:[]);if(!h.length)return r;let u=i.ownerOf(r.path),o=W(e,f.filter(g=>i.ownerOf(g)===u),u?.folder),b=r.files??r.skillPaths.map(g=>({path:g,role:l.has(g)?"skill":"reference",label:o.skillNames[g]??o.skillRefNames[g]??null})),S=new Set([...k.files.map(g=>g.path),...o.subagentPaths,...Object.keys(o.subagentSkillOwners)]),x=o.scoped.filter(g=>!S.has(g)&&J(g)&&Object.hasOwn(t.files,g)).sort(),O=r.files?[]:D(x,[t.files[r.path],...b.filter(g=>g.role==="reference").map(g=>t.files[g.path])],o.stripRoot).map(g=>({path:g,role:"reference",label:null})),s=a([...b,...O],h);return{...r,files:s,skillPaths:[...new Set([...r.skillPaths,...m(r),...h.flatMap(g=>g.files.map(P=>P.path))])].filter(g=>s.some(P=>P.path===g)),skillManifests:h}})}})}}import{basename as Lt}from"node:path";import{createHash as Ut}from"node:crypto";var xt=25,Yt=e=>oe(e,"CF_IMPORT_AGENT_PAGES");function yn(e,t,n,f,i=xt,l){if(!Yt(e))return null;let m=f?.pageSize??i,p=f?.offset??0;if(![8,25,400].includes(m)||!Number.isSafeInteger(p)||p<0)throw new Error("invalid-agent-page");let d=[...new Map(t.map(P=>[P.id,P])).values()],y=Ut("sha256").update(JSON.stringify({version:1,context:{commit:n.commit,scope:n.scope},size:m,budgets:l,settings:Object.entries(Ce(e)).filter(([,P])=>P!==void 0).sort(([P],[w])=>P.localeCompare(w)),rows:d.map(({id:P,path:w,groupKey:v,pool:C})=>({id:P,path:w,groupKey:v,pool:C}))})).digest("hex");if(f&&(f.version!==1||f.binding!==y))throw new Error("stale-agent-page");let a=d.map((P,w)=>{let v=Ct(e,P,w);return typeof v=="string"?`group:${v}`:`agent:${P.id}`}),k=[...new Set(a)];if(p>0&&p>=k.length)throw new Error("invalid-agent-page");let c=f?.end;if(c!==void 0&&(!Number.isSafeInteger(c)||c<p||c>k.length||c>p+m||c===p&&k.length>0))throw new Error("invalid-agent-page");let r=new Set,h=new Set,u=l?{...l}:null,o=p,b=!1;for(let P of k.slice(p,c??p+m)){let w=new Map(d.filter((C,$)=>a[$]===P&&!h.has(d[$].path)).map(C=>[C.path,C])),v={strong:0,possible:0};for(let C of w.values())v[C.pool??"strong"]+=C.bytes;if(c===void 0&&u&&r.size&&(v.strong>u.strong||v.possible>u.possible)){b=!0;break}r.add(P),o++;for(let C of w.keys())h.add(C);u&&(u.strong=Math.max(0,u.strong-v.strong),u.possible=Math.max(0,u.possible-v.possible))}c!==void 0&&(b=o<k.length&&o-p<m);let S=new Set(k.slice(o)),x=d.filter((P,w)=>r.has(a[w])),O=d.filter((P,w)=>S.has(a[w])).map(P=>P.id),s={version:1,binding:y,offset:p,pageSize:m,end:o},g=new Map(x.map(P=>[P.path,P.bytes]));return{context:{...n},current:s,continuation:O.length?{version:1,binding:y,offset:o,pageSize:m}:null,detected:d.length,detectedGroups:k.length,selected:x.map(P=>P.id),remaining:O,refusals:O.map(P=>({id:P,reason:b?"prompt-over-limit":"page"})),partial:O.length>0,estimatedInputBytes:[...g.values()].reduce((P,w)=>P+w,0)}}function $t(){return xt}function Ct(e,t,n){return _e(e)&&t!==null&&typeof t=="object"&&"groupKey"in t&&typeof t.groupKey=="string"&&t.groupKey?t.groupKey:n}function Mt(e,t){let n=$t(),f=new Set,i=[],l=[];return t.forEach((m,p)=>{let d=Ct(e,m,p);f.has(d)||f.size<n?(f.add(d),i.push(m)):l.push(m)}),{kept:i,leftOut:l}}function jt(e){let t=$t();if(e.kind==="layout")return`Only ${t} agents can be added per import, so ${e.leftOut} were left out.`;if(e.kind==="scan"){let f=e.found-t;return`${f} ${f===1?"agent wasn't":"agents weren't"} read because the repository is large.`}let n=e.kind==="import"?`Not added: this import already has ${t} agents.`:`Only the ${t} strongest agents of a repository are added.`;return e.kind==="model"?`${e.name}: ${n}`:n}var fe="crew:";function Pe(e){return e.startsWith(fe)}function we(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Object.entries(e);return!t.length||t.some(([,n])=>typeof n!="string"||n.length>=2e3)?null:t.map(([n,f])=>`${n}: ${f}`).join(`
|
|
19
|
+
`)}function At(e,t,n={},f=Object.keys(t)){return I(n)?Vt(e,t,f):e.kind!=="crew"?{agents:[],notes:[],registry:!1}:Et(e,t)}function Et(e,t){let n=[],f=[],i=(p,d)=>f.push({code:"unreadable-crew",path:p,detail:d?`${d} could not be read; some instructions may be missing.`:"could not be read; some instructions may be missing."}),l=se(t[e.agentsPath]??""),m=e.tasksPath?se(t[e.tasksPath]??""):[];l?.length||i(e.agentsPath),m===null&&i(e.tasksPath);for(let{key:p,value:d,span:y}of l??[]){if(!U(d)){i(e.agentsPath,p);continue}let{llm:a,tools:k,...c}=d,r=we(c);if(r===null&&Object.keys(c).length){i(e.agentsPath,p);continue}let h=[{role:"system prompt",path:e.agentsPath,label:p,span:y}];for(let u of m??[])U(u.value)&&u.value.agent===p&&h.push({role:"knowledge",path:e.tasksPath,label:u.key,span:u.span});n.push({key:`${fe}${e.agentsPath}#${p}`,name:p,model:typeof a=="string"?a:null,description:typeof d.goal=="string"?d.goal:null,entry:{path:e.agentsPath,span:y,text:r},files:h,tools:Array.isArray(k)?[...new Set(k.filter(u=>typeof u=="string"&&!!u.trim()))]:[],skills:[],subagents:[]})}return{agents:n,notes:f,registry:!1}}function U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Vt(e,t,n){let f=new Set([...n,...Object.keys(t)]),i=Object.entries(t).filter(([r])=>r.endsWith(".py")).map(([r,h])=>nt(r,h,f,e.folder)),l=i.flatMap(r=>r.agents),m=i.flatMap(r=>r.refused);if(!l.length)return e.kind==="crew"&&/\.ya?ml$/i.test(e.agentsPath)?{...Et(e,t),refused:m}:{agents:[],notes:[],refused:m,registry:!1};let p=new Map,d=r=>{if(!p.has(r)){let h=t[r]===void 0?null:se(t[r]);p.set(r,h),h===null&&m.push({path:r,reason:t[r]===void 0?"missing":"invalid"})}return p.get(r)??[]},y=i.flatMap(r=>r.tasks).flatMap(r=>{let h=r.config?.path?d(r.config.path).find(b=>b.key===r.config.key):void 0;if(r.config&&(!r.config.path||!h||!U(h.value)))return r.config.path&&m.push({path:r.config.path,reason:h?"invalid":"missing"}),[];let u=U(h?.value)?h.value:{},o=r.factory.includes(".")?r.factory.slice(0,r.factory.lastIndexOf(".")):null;return[{fact:r,path:r.config?.path??r.path,key:r.config?.key??r.factory,span:h?.span??r.span,agent:r.agent??(typeof u.agent=="string"?o?`${o}.${u.agent}`:u.agent:null),context:[...r.context,...Array.isArray(u.context)?u.context.filter(b=>typeof b=="string"):[]],tools:r.tools}]}),a=i.flatMap(r=>r.tasks).filter(r=>r.config),k=a.flatMap(r=>r.config?.path?[{path:r.config.path,source:r.path,owner:r.factory.includes(".")?r.factory.slice(0,r.factory.lastIndexOf(".")):null}]:[]);!a.length&&e.kind==="crew"&&e.tasksPath&&k.push({path:e.tasksPath,source:e.tasksPath,owner:null});for(let{path:r,source:h,owner:u}of k)for(let o of d(r)){if(y.some(S=>S.path===r&&S.key===o.key&&S.fact.path===h&&(S.fact.factory.includes(".")?S.fact.factory.slice(0,S.fact.factory.lastIndexOf(".")):null)===u)||!U(o.value))continue;let b=o.value;y.push({fact:{path:h,factory:u?`${u}.${o.key}`:o.key,span:o.span,callStart:0,agent:null,context:[],tools:[]},path:r,key:o.key,span:o.span,agent:typeof b.agent=="string"?u?`${u}.${b.agent}`:b.agent:null,context:Array.isArray(b.context)?b.context.filter(S=>typeof S=="string"):[],tools:[]})}let c=[];for(let r of l){let h=r.config?.path?d(r.config.path).find(v=>v.key===r.config.key):void 0;if(r.config&&(!r.config.path||!h||!U(h.value))){r.config.path&&m.push({path:r.config.path,reason:h?"invalid":"missing"});continue}let u=U(h?.value)?h.value:{},o={...Object.fromEntries(Object.entries(u).filter(([v,C])=>!["llm","tools"].includes(v)&&typeof C=="string")),...r.instructions},b=we(o);if(!b){m.push({path:r.path,reason:"dynamic"});continue}let S=r.config?.key??r.factory.split(".").at(-1),x=r.config?.path??r.path,O=h?.span??r.span,s=[{path:x,role:"system prompt",label:S,span:O}];x!==r.path&&s.push({path:r.path,role:"config",label:r.factory,span:r.span});let g=y.filter(v=>v.fact.path===r.path?v.agent===r.factory||v.agent===S:/\.ya?ml$/i.test(v.fact.path)&&v.agent===S&&l.filter(C=>(C.config?.key??C.factory)===S).length===1),P=new Set,w=[...r.tools];for(let v=0;v<g.length;v++){let C=g[v];if(!P.has(C)&&(P.add(C),!(C.fact.config&&!C.fact.config.path))){s.push({path:C.path,role:"knowledge",label:C.key,span:C.span}),w.push(...C.tools);for(let $ of C.context){let j=y.filter(M=>M.fact.path===C.fact.path&&M.fact.factory===$||M.path===C.path&&M.key===$);j.length===1?g.push(j[0]):m.push({path:C.path,reason:j.length?"dynamic":"missing"})}}}for(let v of w)v.path&&v.path!==r.path&&!s.some(C=>C.path===v.path)&&(t[v.path]===void 0&&m.push({path:v.path,reason:"missing"}),s.push({path:v.path,role:"tools",label:v.name}));c.push({key:`${fe}${r.path}#${r.factory}`,name:S,model:typeof u.llm=="string"?u.llm:null,description:typeof o.goal=="string"?o.goal:null,entry:{path:x,span:O,text:b},files:s,tools:[...new Set([...w.map(v=>v.name),...Array.isArray(u.tools)?u.tools.filter(v=>typeof v=="string"):[]])],skills:[],subagents:[],crewCall:{path:r.path,callStart:r.callStart}})}return{agents:c,notes:[],refused:m,registry:!1}}import{basename as Ft,posix as ce}from"node:path";function Rt(e,t,n){let f={...t.selected,codeAgentsFound:t.codeAgentsFound||t.selected.codeAgentsFound};if(!Se(e,f,n))return{kind:"none"};let i={...t.bodies,...f.files},l=W(e,Object.keys(i),G(f.root)).templatePaths,m=ve(e,{...f,files:i},l);if(!t.entries)return{kind:"search",paths:[],ownedPaths:m.ownedPaths};let p=new Set([...Object.keys(i),...t.attemptedPaths??[]]),d=new Set(m.facts.dependencies);for(let h of m.relatedReads)h.target.kind==="file"&&d.add(h.target.path);for(let h of t.entries)m.relatedReads.some(u=>u.target.kind==="directory"&&pe(u,h.path))&&d.add(h.path);let y=(h,u)=>{let o=_(e,h,{purpose:u,route:"local-folder"});return o.admitted||o.reason==="too-large"},a=[...new Set(t.entries.filter(h=>!p.has(h.path)&&(d.has(h.path)?y(h,"pointer"):L(h.path,f.root)===null&&Fe(h.path)!==null&&y(h,"code-support"))).map(h=>h.path))],k=G(f.root)??"",c=h=>ce.parse(h).name===(k?Ft(k):f.fallbackName)?0:Xe.test(Ft(h))?1:2,r=h=>ce.relative(k||".",ce.dirname(h)).split("/").filter(u=>u&&u!==".").length;return a.sort((h,u)=>Number(d.has(u))-Number(d.has(h))||c(h)-c(u)||r(h)-r(u)||(h<u?-1:h>u?1:0)),{kind:"search",paths:a,ownedPaths:m.ownedPaths}}function pe(e,t){return e.target.kind==="file"?e.target.path===t:ce.dirname(t)===e.target.path&&(!e.target.extension||t.endsWith(e.target.extension))}function Se(e,t,n){if(!te(e)||t.codeAgentsFound||t.explicitPrompt!==void 0||n.agents.length||t.listedPaths&&W(e,[...t.listedPaths],G(t.root)).configPath)return null;let f=W(e,Object.keys(t.files),G(t.root)).templatePaths;if(!f.length)return null;let i=Object.fromEntries(Object.entries(t.files).filter(([l])=>L(l,t.root)!==null&&_(e,{path:l},{purpose:"override",route:"github"}).admitted));return ue(e,i).reads.some(l=>f.some(m=>pe(l,m)))?null:f}function ve(e,t,n){let f=Object.fromEntries(Object.entries(t.files).filter(([c])=>_(e,{path:c},{purpose:"override",route:"github"}).admitted)),i=ue(e,f),l=i.reads.filter(c=>L(c.sourcePath,t.root)===null&&n.some(r=>pe(c,r))),m=n.filter(c=>l.some(r=>pe(r,c))).sort(),p=[...new Set(l.map(c=>c.sourcePath))].sort(),d=i.reads.filter(c=>p.includes(c.sourcePath)),y=d.flatMap(c=>c.target.kind==="file"&&Object.hasOwn(f,c.target.path)&&L(c.target.path,t.root)!==null&&!n.includes(c.target.path)?[c.target.path]:[]).sort(),a=l.flatMap(c=>c.consumerPaths).sort(),k=m.length?[...new Set([m[0],...n.filter(c=>c!==m[0]),...y,...p,...a])]:[];return{facts:i,relatedReads:d,provenTemplates:m,ownedPaths:k}}function cs(e,t,n={}){return de(e)&&!t.agentConfigurations&&(t={...t,agentConfigurations:Ze(e,t.listedPaths??Object.keys(t.files),t.root)}),st(e,t,Xt(e,t,n))}function Xt(e,t,n){let f=It(e,t),{answer:i,scopeProof:l}=Qt(e,t,f),m=rt(e);if(!m&&!i.agents.some(o=>o.crewCall||o.layoutCall))return ye(e,t,i);let p=[...new Set([...Object.keys(t.files),...t.listedPaths??[],...i.scopePaths??[]])],d=V(e,p,t.root,{files:t.files,agentConfigurations:t.agentConfigurations,listedPaths:t.listedPaths}),y=i.agents.filter(o=>m||o.crewCall||o.layoutCall).map(o=>{let b=f.agents.find($=>$.key===o.key),S=Oe(b?.files??[]),x=i.agentScopes?.find($=>$.key===o.key)?.folder,O=d.scopes.find($=>x===void 0?$.key===o.key:$.folder===x)??d.scopes[0],s=W(e,p.filter($=>d.ownerOf($)===O),O.folder),g=new Set([...o.files.filter($=>$.role!=="reference"||$.label!==null).map($=>$.path),...o.subagents.flatMap($=>[$.path,...b?.subagents.find(j=>j.path===$.path)?.skillPaths??$.skillPaths]),...i.notes.filter($=>$.code==="orphan-skill").map($=>$.path)]),P=s.scoped.filter($=>!g.has($)&&J($)).sort(),w=`convention:${JSON.stringify(o.key)}`,v=o.files.map($=>o.prompt.kind!=="none"&&o.prompt.path===$.path&&"span"in o.prompt?{...$,span:$.span??o.prompt.span}:$),C=o.subagents.map($=>{let j=b?.subagents.find(F=>F.path===$.path),M=$.files??$.skillPaths.map(F=>({path:F,role:s.skillNames[F]?"skill":"reference",label:s.skillNames[F]??s.skillRefNames[F]??null})),A=ne(e)?Oe(j?.files??[]):M.map(F=>F.path),T=$.files&&!s.subagentPaths.includes($.path)?[]:D(P,[$.path,...A].map(F=>t.files[F]??""),s.stripRoot),E=T.filter(F=>!M.some(me=>me.path===F)).map(F=>({path:F,role:"reference",label:null})),Y=i.agents.find(F=>"key"in $&&F.key===$.key);return{child:$,id:`${w}:${JSON.stringify("key"in $?$.key:$.path)}`,scopeProof:Y?.layoutProof??l,toolCall:Y?.layoutCall,independentReferences:[...Oe(j?.files??[]),...T],ownFiles:"key"in $?[...M,...E]:[{path:$.path,role:"system prompt",label:null},...M,...E]}});return{agent:o,id:w,scope:O,ownFiles:v,independentReferences:S,children:C,scopeProof:o.layoutProof??l,toolCall:o.crewCall??o.layoutCall}}),a=y.flatMap(({agent:o,id:b,scope:S,ownFiles:x,independentReferences:O,children:s,scopeProof:g,toolCall:P})=>[{id:b,scope:S,ownFiles:x,independentReferences:O,scopeProof:g,toolCall:P,sharedReferencePaths:o.sharedReferencePaths,fileProfile:o.crewCall||o.layoutCall?"layout":"convention",skillManifests:o.skills.flatMap(w=>w.manifest?[w.manifest]:[])},...s.map(({child:w,id:v,ownFiles:C,independentReferences:$,scopeProof:j,toolCall:M})=>({id:v,scope:S,ownFiles:C,independentReferences:$,scopeProof:j,toolCall:M,fileProfile:"key"in w?"layout":"convention",skillManifests:w.skillManifests}))]),k=pt(e,a,{files:t.files,sizes:n.sizes??new Map(Object.entries(t.files).map(([o,b])=>[o,Buffer.byteLength(b)])),total:n.total,root:t.root,scopes:d}),c=new Map(k.map(o=>[o.agentId,o])),{complete:r,...h}=i,u=new Map(y.map(({agent:o,id:b,children:S})=>{let x=c.get(b);return[o.key,{...o,manifest:x,files:_t(x,o.files),skills:o.skills.filter(O=>x.files.some(s=>s.path===O.path)),subagents:S.flatMap(({child:O,id:s,ownFiles:g})=>{let P=c.get(s);if(!P.files.some(C=>C.path===O.path))return[];let w=_t(P,g),v="key"in O?w:w.filter(C=>C.path!==O.path);return[{...O,files:v,skillPaths:O.skillPaths.filter(C=>v.some($=>$.path===C))}]})}]}));return ye(e,t,{...h,...r&&!k.some(o=>o.refused.length)?{complete:r}:{},scopePaths:p,manifests:k,agents:i.agents.map(o=>u.get(o.key)??o)})}function _t(e,t){return e.files.flatMap(n=>t.some(f=>f.path===n.path)?t.filter(f=>f.path===n.path):[{path:n.path,role:n.roles.includes("config")?"config":"tools",label:null,...n.spans.length===1?{span:n.spans[0]}:{}}])}function Oe(e){return e.filter(t=>t.role==="reference"&&t.label===null).map(t=>t.path)}function Qt(e,t,n){let f=Ot(e,t,n);if(!K(e)&&t.codeAgentsFound)return{answer:{...f,projection:"code"}};let i=Se(e,t,f);if(!i)return{answer:f};let l=ve(e,t,i);if(!l.provenTemplates.length)return{answer:f};let m=l.provenTemplates[0],p=new Set(f.agentScopes?.find(y=>y.key===null)?.notes),d=y=>!(y.code==="no-prompt"&&y.detail==="no-conventions"&&y.path===(G(t.root)??""));return{scopeProof:{kind:"outside-loader",paths:l.ownedPaths},answer:{...f,projection:"conventions",notes:f.notes.filter(d),...f.agentScopes?{agentScopes:f.agentScopes.map(y=>({...y,notes:y.notes.filter(d)}))}:{},...f.unassignedNotes?{unassignedNotes:f.unassignedNotes.filter(y=>!p.has(y))}:{},agents:[{key:null,name:t.fallbackName,model:null,description:null,prompt:{kind:"dedicated",path:m},files:l.ownedPaths.map(y=>({path:y,role:y===m?"system prompt":i.includes(y)?"template":"reference",label:null})),skills:[],subagents:[]}]}}}function ps(e,t){return te(e)?Rt(e,t,It(e,t.selected)):{kind:"none"}}function It(e,t){if(!Ne(e)){let{agents:s,notes:g}=xe(e,t,null);return{agents:s,notes:g}}let n=De(e,t.listedPaths??[]).flatMap(s=>[...s.agents,...s.configs]),f=[...new Set([...Object.keys(t.files),...n,...I(e)?t.listedPaths??[]:[]])],{scopes:i,ownerOf:l,ignoredPaths:m,pluginFolders:p}=V(e,f,t.root,{files:t.files,agentConfigurations:t.agentConfigurations,listedPaths:t.listedPaths}),d=new Set(m),y=new Map(i.map(s=>[s,{}]));for(let[s,g]of Object.entries(t.files)){if(d.has(s))continue;let P=l(s);P&&(y.get(P)[s]=g)}let a=i.map(s=>{let g=y.get(s),P={...t,files:g,root:s.folder,fallbackName:s.key===null?t.fallbackName:Lt(s.folder),explicitPrompt:s.key===null?t.explicitPrompt:void 0,...t.pointerFiles?{pointerFiles:Object.fromEntries(Object.entries(t.pointerFiles).filter(([w])=>!d.has(w)&&l(w)===s))}:{}};return{scope:s,input:P,answer:Nt(e,s,P,!1,t.files)}}),k=[],c=new Map,r=a.filter(({scope:s,input:g,answer:P})=>{let w=P.agents[0];if(!w)return!0;let v=Object.entries(g.files).map(([j,M])=>[L(j,s.folder),M]).sort(([j],[M])=>j<M?-1:j>M?1:0),C=JSON.stringify([w.name,v,...s.managed||I(e)&&(s.kind==="crew"||p.includes(s.folder))?[s.folder]:[]]),$=c.get(C);return $!==void 0?(k.push({code:"duplicate-agent",path:s.folder,detail:$}),!1):(c.set(C,s.folder),!0)}),h=r.find(({scope:s})=>s.key===null),u=h.answer.agents[0];r.some(({scope:s,answer:g})=>s.key!==null&&g.agents.length)&&(h.answer=Nt(e,h.scope,h.input,!0,t.files),h.answer.notes=h.answer.notes.filter(s=>s.detail!=="no-conventions"));for(let{scope:s,answer:g}of K(e)?[]:r)p.includes(s.folder)&&(g.agents=g.agents.map(P=>({...P,plugin:!0})));let{kept:o,leftOut:b}=Mt(e,r.flatMap(({answer:s})=>s.agents));mt(o,u,{settings:e,files:t.files,root:t.root});let S=[...k,...b.length?[{code:"agent-cap",detail:jt({kind:"layout",leftOut:b.length})}]:[]],x=new Set(o.map(s=>s.key));return{...!t.definitionsOmitted&&r.some(({scope:s})=>s.kind==="crew")&&r.every(({scope:s,answer:g})=>g.notes.length===0&&!g.refused?.length&&(s.kind==="crew"?g.agents.length>0&&g.agents.every(P=>Pe(P.key??"")):g.agents.length===0))&&(!t.listedPaths||V(e,t.listedPaths,t.root,{agentConfigurations:t.agentConfigurations}).files.every(s=>Object.hasOwn(t.files,s.path)))?{complete:!0}:{},...r.some(({scope:s,answer:g})=>s.miniSwe&&g.agents.length)&&!t.codeAgentsFound?{projection:"conventions"}:{},agents:o.map(s=>s.layoutCall?{...s,subagents:s.subagents.filter(g=>"key"in g&&x.has(g.key))}:s),notes:[...r.flatMap(({answer:s})=>s.notes),...S],...n.length?{scopePaths:f}:{},...r.some(({answer:s})=>s.refused?.length)?{refused:r.flatMap(({answer:s})=>s.refused??[])}:{},...i.length>1||i.some(s=>s.kind==="crew"||s.managed||s.miniSwe)||r.some(({answer:s})=>s.agents.some(g=>g.layoutCall))?{agentScopes:r.flatMap(({scope:s,answer:g})=>(g.agents.length?g.agents:[{key:s.key}]).map((P,w)=>({key:P.key,folder:s.folder,registry:g.registry&&!Pe(P.key??""),notes:g.notes.filter(v=>v.code!=="unreadable-crew"||w===0)}))),unassignedNotes:[...r.filter(({answer:s})=>!s.agents.some(g=>x.has(g.key))).flatMap(({answer:s})=>s.notes),...S]}:{}}}function Nt(e,t,n,f=!1,i){if(t.managed)return St(e,t,n);if(t.miniSwe&&n.explicitPrompt===void 0)return vt(e,t,n);if(t.kind!=="crew"&&!I(e))return xe(e,n,t.key,f);let l=gt(e,n,i),m=Ht(e,t,n.files,n.listedPaths),p=xe(e,n,t.key,f||t.key===null&&(m.agents.length>0||l.agents.length>0));return{agents:[...p.agents,...m.agents,...l.agents],notes:[...p.notes.filter(d=>d.detail!=="no-conventions"||t.kind!=="crew"&&m.agents.length===0&&l.agents.length===0),...m.notes],registry:p.registry,...m.refused?.length||l.refused.length?{refused:[...m.refused??[],...l.refused]}:{}}}function Ht(e,t,n,f){let i=At(t,n,e,f),{agents:l,notes:m,registry:p}=i;return{agents:l.map(({entry:d,...y})=>({...y,prompt:Wt(e,{entry:d},m)})),notes:m,registry:p,...i.refused?.length?{refused:i.refused}:{}}}function xe(e,t,n,f=!1){let{files:i,skills:l,fallbackName:m}=t,p=G(t.root),d=W(e,Object.keys(i),p,t.listedPaths),y=[],a=typeof t.explicitPrompt=="string"&&!Ae(e,t.explicitPrompt);a&&y.push({code:"explicit-guide",path:t.explicitPrompt});let k=a?null:t.explicitPrompt,c=typeof k=="string"&&Object.hasOwn(i,k)&&_(e,{path:k},{purpose:"override",route:"github"}).admitted?k:null,r={...d,skillPaths:l?d.skillPaths:[]},h=Qe(r),u=Zt(i,d.configPath,y),o=!K(e)&&!u?.prompt&&!u?.agents?.length?et(e,t):null,b=Ee({codeAgentsFound:!K(e)&&!!t.codeAgentsFound,folderAgentsFound:f,otherDefinitions:h,agentConfiguration:o!==null},e);if(o&&b==="prompt"&&(d=o),!(k===null||c!==null||He({...r,claudePath:d.claudePath},b)))return Tt(he(d),l,y),{agents:[],notes:[...y,{code:"no-prompt",path:p??"",detail:"no-conventions"}],registry:d.registry};let x=Wt(e,{files:i,c:d,guideRole:b,folderAgentsFound:f,root:p,config:u,explicitPath:k===null?null:c??void 0,pointerFiles:t.pointerFiles},y);x.kind==="none"&&(d=he(d));let O=l?d.skillPaths.map(P=>{let w=ee(e,`${d.skillNames[P]}.md`,i[P]);return y.push(...(w.warnings??[]).map(v=>({code:"frontmatter",path:P,detail:v}))),{path:P,name:w.name,description:w.description??"",body:w.prompt??""}}):[];Tt(d,l,y);let s=l?[...d.subagentSkillPaths,...d.subagentSkillRefPaths]:[],g=d.subagentPaths.map(P=>{let w=ee(e,Lt(P),i[P],{preserveToolAbsence:!0});return y.push(...(w.warnings??[]).map(v=>({code:"frontmatter",path:P,detail:v}))),{path:P,name:w.name,description:w.description??null,prompt:w.prompt??"",...w.tools!==void 0?{tools:w.tools}:{},...w.model!==void 0?{model:w.model}:{},skillPaths:s.filter(v=>d.subagentSkillOwners[v]===P)}});return{agents:[{key:n,name:u?.name??m,model:u?.model??null,description:u?.description??null,prompt:x,files:eo(e,i,d,x,l),skills:O,subagents:g}],notes:y,registry:d.registry}}function ms(e,t,n,f){let i=W(e,Object.keys(n),G(f));return Object.hasOwn(i.subagentSkillOwners,t)?!0:re(e,{skillPaths:i.subagentSkillPaths,paths:i.scoped,files:n,root:f})?.some(l=>l.files.some(m=>m.path===t))??!1}function Zt(e,t,n){if(!t)return null;let f=at(e[t]);if(f.invalid)try{JSON.parse(e[t])}catch{n.push({code:"invalid-config",path:t})}return f.config}function Wt(e,t,n){if("entry"in t)return t.entry.text?{kind:"entry",...t.entry,text:t.entry.text}:(n.push({code:"no-prompt",path:t.entry.path}),{kind:"none"});let{files:f,c:i,guideRole:l,folderAgentsFound:m,root:p,config:d,explicitPath:y,pointerFiles:a}=t;if(y===null)return{kind:"none"};if(y!==void 0)return{kind:"explicit",path:y};let k=d?lt(d)[0]?.prompt:void 0,c=d?it(e,d,p??"")[0]:void 0,r=k?ft(e,k,{repoKey:"",markerDir:p??"",files:a??f}):null,h=c!==void 0&&Object.hasOwn(f,c),u=h&&!!f[c];if(h&&(u||a!==void 0)&&Object.hasOwn(i.subagentSkillOwners,c))n.push({code:"pointer-owned-by-subagent",path:c});else if(h&&(a===void 0?u:r?.kind==="resolved")){let o=r?.kind==="resolved"?r.prompt:null;return{kind:"pointer",path:c,...o&&o.kind!=="file"?{span:{...o.span},site:{kind:o.kind,start:o.start,symbol:o.symbol}}:{}}}else k&&n.push(a!==void 0&&r?.kind==="secret"?{code:"secret-file",path:r.path}:{code:"pointer-missed",...c?{path:c}:{},detail:k});return i.promptPath?{kind:"dedicated",path:i.promptPath}:i.registry&&i.soulPath?{kind:"registry",path:i.soulPath}:i.claudePath&&l==="prompt"?(n.push({code:"claude-fallback",...de(e)?{path:i.claudePath}:{}}),{kind:"fallback",path:i.claudePath}):(n.push({code:"no-prompt",path:p??"",...m?{folderAgentsFound:!0}:{}}),{kind:"none"})}function Tt(e,t,n){if(t)for(let f of[...e.subagentSkillPaths,...e.subagentSkillRefPaths])e.subagentSkillOwners[f]||n.push({code:"orphan-skill",path:f})}function eo(e,t,n,f,i){let l=[],m=(a,k,c=null)=>({role:a,label:c,path:k});if(f.kind!=="none"&&f.kind!=="registry"&&l.push(m("system prompt",f.path)),n.soulPath&&l.push(m("soul",n.soulPath)),n.knowledgePath&&l.push(m("knowledge",n.knowledgePath)),i)for(let a of n.skillPaths)l.push(m("skill",a,n.skillNames[a]));for(let a of n.templatePaths)l.push(m("template",a));if(i)for(let a of n.skillRefPaths)l.push(m("reference",a,n.skillRefNames[a]));let p=[];n.configPath&&p.push(m("config",n.configPath));for(let a of[n.toolsPath,n.toolsTsPath,n.cliPath])a&&p.push(m("tools",a));n.mcpPath&&p.push(m("mcp",n.mcpPath));let d=new Set([...l.map(a=>a.path),...p.map(a=>a.path),...n.subagentPaths,...Object.keys(n.subagentSkillOwners),...n.skillPaths,...n.skillRefPaths]),y=n.scoped.filter(a=>!d.has(a)&&J(a)).sort();return l.push(...D(y,l.map(a=>t[a.path]),n.stripRoot).map(a=>m("reference",a)),...p),l}export{D as a,Gt as b,Bo as c,be as d,Ko as e,ee as f,Yt as g,yn as h,$t as i,Mt as j,jt as k,cs as l,ps as m,ms as n};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Ha as O,Ka as F,Qa as $}from"./2AASSZRO.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
|
+
`).slice(s-1).join(`
|
|
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
|
+
`).slice(0,e.line-1).join(`
|
|
5
|
+
`)+`
|
|
6
|
+
`:"",n=t.replace(/\s+/g," "),a=e.excerpt.replace(/\s+/g," ").trim(),d=r.replace(/\s+/g," ").length,o=n.indexOf(a,d);if(o>=0)return{from:o,to:o+a.length};let l=a.split(/\s*(?:\.{3}|…)\s*/),u=n.indexOf(l[0],d),p=u;for(let i of l){let c=n.indexOf(i,p);if(c<0)return null;p=c+i.length}return u<0?null:{from:u,to:p}}function X(e,s,t){if(!S(e,s))return!0;let r=B(e,t),n=B(s,t);return r!==null&&n!==null&&(r.to<=n.from||n.to<=r.from)}function Z(e,s,t,r){if(!V(e.category))return"The finding has no supported evidence category.";if(!e.site||!e.siteRepo)return"The finding has no fetched primary site.";if(s.length<E(e.category))return"The category's required quoted sites are missing.";if(!t)return"Evidence coverage was not recorded unambiguously.";if(t.claimTruncated)return"The claim was truncated in the check.";if(!t.coreComplete||t.missing.length||t.truncated.length)return"Required evidence was unavailable or truncated.";if(t.requested.length===0||t.requested.some(n=>!t.included.some(a=>S(n,a))||T(r,n)===void 0))return"Required files were not included in the check.";for(let n of s){if(!t.requested.some(a=>S(a,n))||!t.included.some(a=>S(a,n)))return"A cited file was not included in the check.";if(!G(T(r,n),n.line,n.excerpt))return"A cited quote could not be verified at its source line."}return E(e.category)===2&&!s.some((n,a)=>s.slice(a+1).some(d=>X(n,d,r)))?"The category needs distinct quoted sites.":null}function ee(e,s){let t=e.cause.replace(/\s+/g," ").trim();for(let a of s){let d=a.excerpt?.replace(/\s+/g," ").trim();d&&(t=t.replaceAll(d,""))}if(!t||t===e.title)return!1;let r=/\b(?:without|before|instead|different|wrong|repeatedly|twice|never|cannot|can't|unable to|fails? to|unapproved|unauthori[sz]ed)\b/i,n=/\b(?:send(?:s|ing)?|sent|delet(?:e[sd]?|ing)|appl(?:y|ies|ied|ying)|grant(?:s|ed|ing)?|revok(?:e[sd]?|ing)|return(?:s|ed|ing)?|rout(?:e[sd]?|ing)|run(?:s|ning)?|execut(?:e[sd]?|ing)|writ(?:e[sd]?|ing)|read(?:s|ing)?|retry|retries|retried|retrying|skip(?:s|ped|ping)?|omit(?:s|ted|ting)?|block(?:s|ed|ing)?|allow(?:s|ed|ing)?|charg(?:e[sd]?|ing)|pay(?:s|ing)?|paid|los(?:e[sd]?|ing)|receiv(?:e[sd]?|ing)|select(?:s|ed|ing)?|exclud(?:e[sd]?|ing)|includ(?:e[sd]?|ing)|schedul(?:e[sd]?|ing))\b/i;return r.test(t)&&n.test(t)}function te(e,s,t,r){let n=[...e.matchAll(/(?:^|[\s(`*])([^\s"'“”‘’`() *]+):(\d+)(?:-\d+)?/g)].map(o=>{let l=o[1],u=t.included.filter(i=>i.path===l||`${i.repo}:${i.path}`===l),p=[...new Map(u.map(i=>[JSON.stringify([i.repo,i.path]),i])).values()];return{from:o.index,to:o.index+o[0].length,line:Number(o[2]),ref:p.length===1?p[0]:void 0}});if(n.length===0||n.some(o=>!o.ref))return!1;let a=new Map;for(let o of e.matchAll(W)){let l=o.index,u=l+o[0].length;if(n.some(f=>f.from>=l&&f.to<=u))continue;let p=o.slice(1).find(f=>f!==void 0),i=n.flatMap((f,k)=>G(T(r,f.ref),f.line,p)?[k]:[]);if(i.length!==1)return!1;let c=i[0];a.set(c,[...a.get(c)??[],p])}let d=!1;for(let o=0;o<n.length;o++){let l=n[o],{line:u,ref:p}=l,i=a.get(o)??[];if(i.length===0)return!1;s.some(c=>S(c,p)&&c.line===u&&i.some(f=>O(f,c.excerpt??"")!==null))&&(d=!0)}return d}function D(e,s,t,r){if(!e?.accepted)return"No accepted check verdict is available.";let n=e.verdict;return!n.sent||n.verdict!=="keep"||n.modelVerdict!=="keep"||!n.reason.trim()||n.reason!==n.modelReason?"The check kept the finding without an accepted supporting decision.":te(n.evidenceFor,s,t,r)?L.test(n.evidenceAgainst)?null:"Contrary check evidence has not been resolved.":"The check supplied no verified supporting quote."}function me(e){let s=e.findings.map($),t=A(e.coverage,s),r=A(e.verdicts,s),n=new Set(e.shadowRequestedIds??(e.shadowVerdicts===void 0?[]:s)),a=A(e.shadowVerdicts??[],[...n]);return e.findings.map((d,o)=>{let l=s[o],u=Y(d),p=t.get(l),i=Z(d,u,p,e.sources),c=_(d.category,e.sawCode)??i;!c&&!ee(d,u)&&(c="The finding does not explain a concrete behavioral consequence."),c||(c=D(r.get(l),u,p,e.sources)),!c&&n.has(l)&&(c=D(a.get(l),u,p,e.sources)),!c&&d.sourceNotes&&(d.sourceNotes.support!=="supported"||d.sourceNotes.counterEvidence.length>0)&&(c="Source notes contain uncertain support or unresolved contrary evidence.");let f=c?"not sure":"sure";return{fingerprint:l,support:i?"incomplete":"complete",confidence:f,weak:f!=="sure"||d.severity==="low",reason:c??(d.severity==="low"?"Verified support, but low impact.":"Verified quotes and an accepted keep support the stated consequence.")}})}function we(e,s,t){let r=e.map(t??(i=>$(i))),n=A(s,r),{active:a,notActive:d}=F(e),o=new Set(a),l=e.flatMap((i,c)=>{if(!o.has(i))return[];let f=r[c],k=n.get(f),b=k?.confidence==="sure",v=b&&k?.support==="complete"&&!k.weak&&i.severity!=="low";return[{finding:i,fingerprint:f,sure:b,strong:v}]}).sort((i,c)=>Number(c.strong)-Number(i.strong)||j[i.finding.severity]-j[c.finding.severity]||Number(c.sure)-Number(i.sure)||(i.fingerprint<c.fingerprint?-1:i.fingerprint>c.fingerprint?1:0)),u=l.filter(i=>i.strong).slice(0,3),p=new Set(u);return{ordered:[...l.map(i=>i.finding),...d],defaultIds:u.map(i=>i.fingerprint),hiddenIds:l.filter(i=>!p.has(i)).map(i=>i.fingerprint),emptyMessage:!u.length&&l.length?K:null}}export{se as a,ie as b,H as c,N as d,J as e,de as f,me as g,we as h};
|
|
@@ -0,0 +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(`
|
|
2
|
+
`).slice(o.span.from-1,o.span.to).join(`
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as f}from"./724WZMYW.js";function w(t){return t.skippedFiles??(t.notRead??[]).map(({path:e,kind:n})=>({path:e,reason:n==="prompt-too-large"?"too-large":"allowance"}))}function p(...t){let e={"secret-content":-7,secret:-6,hidden:-5,excluded:-4,"wrong-type":-3,empty:-2,"out-of-scope":-1,"too-large":0,allowance:1,"tool-limit":2,"scan-limit":3,total:4,unreadable:5,missing:6},n=new Map;for(let i of t)for(let o of i??[]){let r=n.get(o.path);(!r||e[o.reason]<e[r.reason])&&n.set(o.path,o)}return[...n.values()]}function d(t,e=0){let n=p(t),i=(...s)=>n.filter(({reason:u})=>s.includes(u)).length,o=n.filter(s=>s.reason==="secret-content").map(s=>f(s.path)),r=i("too-large"),a=i("allowance","tool-limit"),l=i("total","scan-limit"),c=i("missing","unreadable");return r&&o.push(`${r} ${r===1?"file was":"files were"} too big to read.`),a&&o.push(`${a} ${a===1?"file wasn't":"files weren't"} read because the file allowance was reached.`),l&&o.push(`${l} ${l===1?"file wasn't":"files weren't"} read because the repository is large.`),c&&o.push(`${c} ${c===1?"file couldn't":"files couldn't"} be read, so some tools may be missing.`),e>0&&o.push(`${e} more ${e===1?"file wasn't":"files weren't"} read.`),o}function h(t,e){return e?[...t.filter(i=>{let o=/^(\d+) more (?:file wasn't|files weren't) read\.$/.exec(i);return o?(e+=Number(o[1]),!1):!0}),...d([],e)]:[...t]}var $="Analyze them separately?";function m(t){return p(t).filter(e=>["too-large","total","allowance","scan-limit","tool-limit"].includes(e.reason))}function F(t){let e=m(t).length;return e?`${e} ${e===1?"file was":"files were"} too large to read, so findings in ${e===1?"it":"them"} may be missing.`:void 0}function b(t,e){return p(t,e.map(n=>({path:n,reason:"total"})))}export{w as a,p as b,d as c,h as d,$ as e,m as f,F as g,b as h};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as M}from"./Y7JGSUOA.js";import{d as J}from"./3MTXB4MK.js";import{j as U}from"./4RXRAB5S.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"./YTHF2E2S.js";import{b as P}from"./6YCABS5T.js";import{a as N,b as v,c as D,d as $}from"./JEWBPIQI.js";import{a as E,b as R}from"./MJGB25S5.js";import{d as A}from"./RQTNTIR4.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
|
+
`):"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
|
+
`),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
|
+
`)})}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(`
|
|
5
|
+
`)})),findings:r(c.findings)})}return{inventoryText:m}}function X(t){let{SPLIT_SCOPE_RULE:e}=F(t),{inventoryText:r}=Q(t);function i(a){return{scopeRule:e,open:O(a.open),inventory:r(a)}}return{shapeInputs:i,SPLIT_SCOPE_RULE:e}}function j(t){let{bundleText:e}=t,r={contradiction:{def:e("analysis-categories-1"),evidence:e("analysis-categories-2")},ambiguity:{def:e("analysis-categories-3"),evidence:e("analysis-categories-4")},bypassable_requirement:{def:e("analysis-categories-5"),evidence:e("analysis-categories-6")},stale_fact:{def:e("analysis-categories-7"),evidence:e("analysis-categories-8")},description_mismatch:{def:e("analysis-categories-9"),evidence:e("analysis-categories-10")},ungoverned_tool:{def:e("analysis-categories-11"),evidence:e("analysis-categories-12")},untrusted_instructions:{def:e("analysis-categories-13"),evidence:e("analysis-categories-14")},better_as_code:{def:e("analysis-categories-15"),evidence:e("analysis-categories-16")}},i={untrusted_instructions:{derive:"analysis-categories-17",check:"analysis-categories-18"},better_as_code:{derive:"analysis-categories-19",check:"analysis-categories-20"}};function a(s){return I(s).map(n=>{let o=r[n];return e("category-entry",{category:n,definition:o.def,evidence:o.evidence})}).join(`
|
|
6
|
+
`)}function m(s,n){return I(s).map(o=>{let p=i[o]?.[n];return p?`
|
|
7
|
+
|
|
8
|
+
${e(p,{promptAgreement:x(s)})}`:""}).join("")}function c(){return[e("analysis-categories-21"),e("analysis-categories-22"),e("analysis-categories-23"),e("analysis-categories-24"),e("analysis-categories-25"),e("analysis-categories-26")].join(`
|
|
9
|
+
`)}return{categoryBlock:a,categoryRules:m,impactBlock:c}}function Y(t){let{checkPromptBlocks:e}=H(t),{shapeInputs:r}=X(t),{templates:i}=t,{categoryBlock:a,categoryRules:m}=j(t);function c(s,n,o,p={}){if(s==="derive-shape")return{...n,...r(n.inventoryData)};if(s.startsWith("check-findings")||s==="second-opinion"){let l=e(n.checkInput),d=a(o),f=m(o,"check"),k=x(o),h=w(o),S={...n,notActiveGroup:h,promptAgreement:k,categories:d,categoryRules:f,core:l[0].text,claims:l[1].text};if(s!=="second-opinion")return S;let g;try{if(typeof n.checkTemplate!="string")throw new Error;g=D("check",o,n.checkTemplate)}catch{throw new Error("Unknown check template")}let u=typeof g=="string"&&Object.hasOwn(p,g)?p[g]:void 0;if(u?.route!=="finding_check"||u.system===void 0)throw new Error("Unknown check template");return{...S,checkSystem:T(u.system,{notActiveGroup:h,promptAgreement:k,categories:d,categoryRules:f},i)}}return n}return{stageInputs:c}}var Z="<<<BEGIN REPOSITORY TEXT>>>",q="<<<END REPOSITORY TEXT>>>";function B(t){let e=t;for(let r="";r!==e;)r=e,e=e.replaceAll(Z,"").replaceAll(q,"");return`${Z}
|
|
10
|
+
${e.replaceAll("{{","{ {")}
|
|
11
|
+
${q}`}function ee(t,e){return{location:B(String(t.location)),text:B(String(t.text)),usage:B(t.usage===null?e.bundleText("code-check-no-usage"):String(t.usage))}}function te(t){let{categoryBlock:e,categoryRules:r,impactBlock:i}=j(t),{codeSourceLabels:a,codeFindingNote:m,RULE:c,SPLIT_SCOPE_RULE:s,STRUCTURE_SCOPE_RULE:n,SUB_KIND_DEFS:o}=F(t),{bundleText:p}=t;function l(d,f,k){if(d==="finding-headlines")return{data:JSON.stringify(f.evidence),choiceCategories:L.join(", ")};if(d==="judge-code-prompt")return ee(f,t);if(d.startsWith("derive-findings"))return{...f,notActiveGroup:w(k),promptAgreement:x(k),pass:f.pass??null,codeSources:a(f.codeSources??[]),categories:e(k),categoryRules:r(k,"derive"),impacts:i()};if(d==="derive-structure"){let h=f.loadModesData,S=f.openStructuresData,g=f.findingsData;return{...f,findings:(g??[]).map(u=>({...u,category:u.category??"\u2014",excerpt:u.excerpt??"",site:u.site?{...u.site,line:u.site.line??"?"}:null,otherSites:(u.otherSites??[]).map(y=>({...y,line:y.line??"?",excerpt:y.excerpt??""})),question:u.question??"",options:u.fixes.map(y=>y.title)})),subKinds:o,scopeRule:n,open:O(S,{includeFiles:!1}),loadModes:h.map(u=>{let y=u.evidenceKind?p("load-evidence-skill-frontmatter"):u.evidence;return p("analysis-derive-structures-11",{v0:u.path,v1:u.mode,v2:u.unit??"no unit",v3:u.via,v4:y?` (${y})`:""})}).join(`
|
|
12
|
+
`)}}if(d==="scope-items"){let h=f.scopeRuleId==="structure"?n:f.scopeRuleId==="split"?s:"";return{items:f.items??[],scopeRule:h}}if(d==="scope-findings"){let h=f.codeSources,S=f.codeFiles,g=m(h);return{...f,system:g?p("scope-system-code")+`
|
|
13
|
+
|
|
14
|
+
`+g:c,code:S.length?p("code-evidence",{files:JSON.stringify(S)}):""}}return f}return{enrichRequestInputs:l,headlineFallbackQuestion:()=>t.description("finding-headlines-fallback-question")}}function ne(t,e){if(!Object.hasOwn(e.templates,t.template))throw new Error(`Unknown template: ${t.template}`);if(!Object.hasOwn(e.answerFormats,t.answerFormat))throw new Error(`Unknown answer format: ${t.answerFormat}`);let r=e.templates[t.template],i=t.limits??{};if(i.maxTokens!==void 0&&(!Number.isSafeInteger(i.maxTokens)||i.maxTokens<=0))throw new Error("Invalid maxTokens");let a=T(r.prompt,t.inputs,e.includes),m=r.promptBlocks?.map(c=>({text:T(c.text,t.inputs,e.includes),...c.cache?{cache:!0}:{}}));if(m&&m.map(c=>c.text).join("")!==a)throw new Error("Registered blocks must match the prompt");return{route:r.route??t.template,model:t.model,...r.system===void 0?{}:{system:T(r.system,t.inputs,e.includes)},prompt:a,...m?{promptBlocks:m}:{},schema:e.answerFormats[t.answerFormat],...i.maxTokens===void 0?{}:{maxTokens:i.maxTokens},...i.effort===void 0?{}:{effort:i.effort},...i.thinking===void 0?{}:{thinking:i.thinking}}}var C=class extends Error{name="InputBudgetError"};function nt(t){let{templates:e,descriptions:r}=t,{withDescriptions:i}=M(t),a=U(i,t.description);function m(){let o={prompt:e["check-evidence"],promptBlocks:[{text:"{{core}}"},{text:"{{claims}}"}]},p=P({"benchmark-judge":{system:e["benchmark-judge"],prompt:"{{data}}"},"judge-code-prompt":{prompt:e["judge-code-prompt"]},"derive-findings":{prompt:e["derive-findings"]},"derive-findings-legacy":{prompt:e["derive-findings-legacy"]},"derive-findings-no-outcome":{prompt:e["derive-findings-no-outcome"]},"derive-findings-legacy-no-outcome":{prompt:e["derive-findings-legacy-no-outcome"]},"derive-structure":{prompt:e["derive-structure"]},"structure-recheck":{system:e["structure-recheck-system"],prompt:e["structure-recheck"]},"derive-shape":{prompt:e["derive-shape"]},"scope-items":{prompt:e["scope-items"],system:e["scope-system"]},"scope-findings":{prompt:e["scope-findings"],system:"{{system}}"},"check-findings":{...o,system:e["check-findings"]},"check-findings-precision-v1":{...o,system:e["check-findings-precision-v1"]},"second-opinion":{...o,system:e["opinion-system"]},"explain-sources":{prompt:e["source-evidence"],system:e["explain-sources"]},"finding-headlines":{system:e["finding-headlines"],prompt:"{{data}}"}});return Object.fromEntries(Object.entries(p).map(([l,d])=>[l,{...d,...d.promptBlocks?{promptBlocks:R(d.promptBlocks,E({},{template:l}).breakpoints)}:{}}]))}function c(){return{templates:m(),includes:e,answerFormats:a,descriptions:r,policy:v()}}function s(o,p={}){let l=Object.hasOwn(v(),o.template)?$(o.template,o.answerFormat,p):o.answerFormat;return re({...o,answerFormat:l},c(),p)}function n(o,p={}){let l=oe(N(o,p),c());return{...l,schema:l.schema}}return{instructionRegistry:c,analysisModelRequest:s,analysisRequest:n,buildAnalysisCall:o=>oe(o,c()),withDescriptions:i,callInputBytes:se}}function se(t){return Buffer.byteLength(t.prompt)+Buffer.byteLength(t.system??"")}function re(t,e,r){let i=e.policy??v();if(!Object.hasOwn(i,t.template)||!i[t.template].answerFormats.includes(t.answerFormat))throw new Error("Unsupported template answer format");if(!Object.hasOwn(v(),t.template))return{...t,inputs:t.inputs};let a=G({templates:e.includes??{},descriptions:e.descriptions??{}}),{stageInputs:m}=Y(a),{enrichRequestInputs:c}=te(a),s=t.answerFormat.endsWith("-activity")||(t.answerFormat==="check"||t.answerFormat==="opinion")&&t.inputs.findingActivityEnabled===!0,n={...r,CF_NOT_ACTIVE_GROUP:s?"1":"0"};return{...t,inputs:c(t.template,m(t.template,t.inputs,n,e.templates),n)}}function oe(t,e){let r=A.parse({template:t.template,inputs:t.inputs,answerFormat:t.answerFormat,model:t.model,...t.limits?{limits:t.limits}:{}}),{data:i,settings:a,maxInputBytes:m}=r.inputs,c=ne(re({...r,inputs:i},e,a),e);if(m!==void 0&&se(c)>m)throw new C("serialized evidence exceeds the priced input budget");let s=r.template==="judge-code-prompt"?b.object({path:b.string(),line:b.number()}).parse(i.at):r.template==="structure-recheck"?b.object({childId:b.string()}).parse(i):{};return{...c,...Object.hasOwn(v(),r.template)&&r.template!=="benchmark-judge"?{context:s}:{}}}export{ne as a,_ as b,H as c,F as d,V as e,Q as f,X as g,j as h,Y as i,te as j,C as k,nt as l,se as m,oe as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{m as O}from"./CTLHKFPH.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(r){return r.CF_NOT_ACTIVE_GROUP==="1"}function e(r,t){let n=typeof t=="object"&&t!==null&&"answerFormats"in t&&Array.isArray(t.answerFormats)&&t.answerFormats.includes("findings-activity");return Object.freeze({...r,CF_NOT_ACTIVE_GROUP:n&&r.CF_NOT_ACTIVE_GROUP!=="0"?"1":"0"})}export{i as a,e as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a,c as m}from"./NXHVBJL4.js";import{a as u}from"./MJGB25S5.js";import{d}from"./RQTNTIR4.js";import{h as c}from"./LMUXOKIM.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}from"./PBHHWFR6.js";import{C as p}from"./4PT5C4IT.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as m,h as u,i as b,j as f,k as d,l as p}from"./MGVIKA74.js";import{z as e}from"zod";var j=["system prompt","soul","knowledge","skill","config","tools","mcp","template","reference","code"],O=e.enum(["entry","agent","tool","store","exit"]),x=256*1024,a=r=>e.string().min(1).refine(o=>o.trim().length>0&&o.isWellFormed()&&!new RegExp("\\p{Cc}|\\u2028|\\u2029","u").test(o)&&Buffer.byteLength(o,"utf8")<=r),k=a(1024).refine(r=>!r.startsWith("/")&&!r.includes("\\")&&!r.includes(":")&&r.split("/").every(o=>o!=="."&&o!==".."&&o!=="")),v=e.strictObject({path:k,role:e.enum(j),label:a(256).optional()}),_=e.strictObject({label:a(256),source:e.literal("mcp").optional()}),w=e.strictObject({version:e.literal(1),nodes:e.array(e.strictObject({id:a(256),label:a(256),kind:O,files:e.array(v).max(256),tools:e.array(_).max(256)})).min(1).max(1e3),edges:e.array(e.strictObject({from:a(256),to:a(256),kind:m})).max(4e3)}).refine(r=>{let o=new Set(r.nodes.map(c=>c.id));return o.size===r.nodes.length&&r.edges.every(c=>o.has(c.from)&&o.has(c.to))}),R=e.unknown().refine(r=>{try{let o=JSON.stringify(r);return typeof o=="string"&&Buffer.byteLength(o,"utf8")<=x}catch{return!1}}).pipe(w),t=e.string(),n=t.nullable(),i=e.number().int().nonnegative().safe(),l=e.number().int().positive().safe(),y=e.strictObject({path:t.optional(),startLine:l,endLine:l}),s=e.number(),h=e.strictObject({subKind:e.enum(["split_monolith","single_source","fold_patches","extract_subagent","merge_subagents","move_rule","move_tool","reorder"]),kind:u,severity:b,title:t,cause:t,summary:t.optional(),evidence:e.array(e.strictObject({path:t,line:l,excerpt:t})),files:e.array(e.strictObject({path:t,action:e.enum(["create","shrink","edit","delete"]),role:e.enum(["system prompt","soul","knowledge","skill","config","tools","mcp","template","reference","log","code"]),unit:t,loadMode:e.enum(["always","on_demand","never"]),loadVia:n,purpose:t,frontmatter:e.strictObject({name:t,description:t,tools:e.array(t)}).nullable()})),segments:e.array(e.strictObject({path:t,startLine:s,endLine:s,to:t,disposition:e.enum(["move","fold_into","remove_duplicate","remove_superseded"]),into:e.strictObject({path:t,line:s}).nullable(),childRef:n,heading:n,reason:t})),additions:e.array(e.strictObject({path:t,text:t,kind:e.enum(["pointer","handoff","reference_update"]),heading:n})),reorder:e.strictObject({path:t,startLine:s,endLine:s,steps:e.array(e.strictObject({from:l,reason:n}))}).nullable(),toolMoves:e.array(e.strictObject({tool:t,fromUnit:t,toUnit:t,reason:t,fromPath:n,toPath:n})),motivation:e.array(e.strictObject({kind:t,reason:t,evidence:t})).optional(),outcomes:e.array(e.strictObject({improvement:t,measurement:t})).optional(),split:e.strictObject({root:t.optional(),frontDoor:e.strictObject({name:t.optional(),job:t,skills:e.array(t)}),subAgents:e.array(e.strictObject({name:t,job:t,description:t,path:t,handoff:t.optional(),resolves:e.array(t).optional(),skills:e.array(e.strictObject({name:t,from:t,to:t})),tools:e.array(t),noTools:e.boolean().optional(),movedKnowledge:e.array(y),neededKnowledge:e.array(y)}))}).optional()}),L=e.strictObject({nodes:e.array(d.shape.nodes.element.extend({change:e.enum(["added","edited","removed"]),label:n.optional()})),edges:e.array(d.shape.edges.element.extend({kind:e.enum(["invokes","delegates","reads","writes","emits"]),change:e.enum(["added","edited","removed"]),detail:n.optional()})),files:e.array(e.strictObject({path:t,role:h.shape.files.element.shape.role,node:t,change:e.enum(["added","removed","moved","shrunk","grown","reordered"]),fromNode:t.optional(),fromPath:t.optional(),segments:i})),tools:e.array(e.strictObject({label:t,fromNode:t,toNode:t}))}),S=e.strictObject({repo:t,children:e.array(e.strictObject({ref:t,how:t})),sourceHashes:e.record(t,t),body:h,delta:L,...f}),g=e.enum(["secret","secret-content","hidden","excluded","wrong-type","too-large","empty","out-of-scope","allowance","total","scan-limit","tool-limit","missing","unreadable"]),E=e.enum([...g.options,"coding-guide","duplicate"]),C=e.strictObject({fromProposal:i,fromRulesOnly:i,rejected:i,rejectedByReason:e.partialRecord(E,i)}),D=e.strictObject({repoKey:t,findings:e.array(p),structures:e.array(S),warnings:e.array(t),proposalCounts:C.optional(),refusedFiles:e.array(e.strictObject({path:t,reason:g})),architecture:R.optional()});export{j as a,O as b,x as c,R as d,S as e,g as f,E as g,D as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as w,e as Y,f as X,g as Z}from"./LFYTD7JF.js";import{g as V,l as K}from"./MGVIKA74.js";import{z as t}from"zod";function W(e){return{nodes:e.nodes.map(({id:s,change:n,label:i})=>({id:s,change:n,...i===void 0?{}:{label:i}})),edges:e.edges.map(({from:s,to:n,kind:i,change:o,detail:r})=>({from:s,to:n,kind:i,change:o,...r===void 0?{}:{detail:r}}))}}function Q(e,s=n=>n){let{kind:n,severity:i,title:o,cause:r,summary:u,category:_,question:p,excerpt:O}=e;return{kind:n,severity:i,title:o,cause:r,summary:u,category:_,question:p,excerpt:O,...e.activity===void 0?{}:{activity:V.parse(e.activity)},siteRepo:s(e.siteRepo),site:e.site&&{path:e.site.path,line:e.site.line},otherSites:e.otherSites.map(({repo:d,path:E,line:F,excerpt:I})=>({repo:s(d),path:E,line:F,excerpt:I})),fixes:e.fixes.map(({title:d,approach:E,kind:F,targetFiles:I,expectedOutcome:f,summary:N,impact:m,confidence:P,objective:y,status:b,blockedBy:h,alsoFixes:A,delta:L})=>({title:d,approach:E,kind:F,targetFiles:I.map(({path:D,create:U})=>({path:D,create:U})),expectedOutcome:f,summary:N,impact:m,confidence:P,objective:y,status:b,blockedBy:h,alsoFixes:A&&A.slice(),delta:L&&W(L)})),...e.sourceNotes===void 0?{}:{sourceNotes:e.sourceNotes&&{sites:e.sourceNotes.sites.map(({index:d,role:E,meaning:F,keyPhrase:I})=>({index:d,role:E,meaning:F,keyPhrase:I})),support:e.sourceNotes.support,supportNote:e.sourceNotes.supportNote,counterEvidence:e.sourceNotes.counterEvidence.map(({repo:d,path:E,line:F,excerpt:I,meaning:f})=>({repo:s(d),path:E,line:F,excerpt:I,meaning:f}))}}}}function J(e){return{...e.headline===void 0?{}:{headline:e.headline},...e.ifLeft===void 0?{}:{ifLeft:e.ifLeft}}}function Ce(e){let s=e.body;return{repo:e.repo,children:e.children.map(({ref:n,how:i})=>({ref:n,how:i})),sourceHashes:Object.fromEntries(Object.entries(e.sourceHashes)),body:{subKind:s.subKind,kind:s.kind,severity:s.severity,title:s.title,cause:s.cause,...s.summary===void 0?{}:{summary:s.summary},evidence:s.evidence.map(({path:n,line:i,excerpt:o})=>({path:n,line:i,excerpt:o})),files:s.files.map(({path:n,action:i,role:o,unit:r,loadMode:u,loadVia:_,purpose:p,frontmatter:O})=>({path:n,action:i,role:o,unit:r,loadMode:u,loadVia:_,purpose:p,frontmatter:O&&{name:O.name,description:O.description,tools:O.tools.slice()}})),segments:s.segments.map(({path:n,startLine:i,endLine:o,to:r,disposition:u,into:_,childRef:p,heading:O,reason:d})=>({path:n,startLine:i,endLine:o,to:r,disposition:u,into:_&&{path:_.path,line:_.line},childRef:p,heading:O,reason:d})),additions:s.additions.map(({path:n,text:i,kind:o,heading:r})=>({path:n,text:i,kind:o,heading:r})),reorder:s.reorder&&{path:s.reorder.path,startLine:s.reorder.startLine,endLine:s.reorder.endLine,steps:s.reorder.steps.map(({from:n,reason:i})=>({from:n,reason:i}))},toolMoves:s.toolMoves.map(({tool:n,fromUnit:i,toUnit:o,reason:r,fromPath:u,toPath:_})=>({tool:n,fromUnit:i,toUnit:o,reason:r,fromPath:u,toPath:_})),...s.motivation===void 0?{}:{motivation:s.motivation.map(({kind:n,reason:i,evidence:o})=>({kind:n,reason:i,evidence:o}))},...s.outcomes===void 0?{}:{outcomes:s.outcomes.map(({improvement:n,measurement:i})=>({improvement:n,measurement:i}))},...s.split===void 0?{}:{split:{...s.split.root===void 0?{}:{root:s.split.root},frontDoor:{...s.split.frontDoor.name===void 0?{}:{name:s.split.frontDoor.name},job:s.split.frontDoor.job,skills:s.split.frontDoor.skills.slice()},subAgents:s.split.subAgents.map(n=>({name:n.name,job:n.job,description:n.description,path:n.path,...n.handoff===void 0?{}:{handoff:n.handoff},...n.resolves===void 0?{}:{resolves:n.resolves.slice()},skills:n.skills.map(({name:i,from:o,to:r})=>({name:i,from:o,to:r})),tools:n.tools.slice(),...n.noTools===void 0?{}:{noTools:n.noTools},movedKnowledge:n.movedKnowledge.map($),neededKnowledge:n.neededKnowledge.map($)}))}}},delta:{...W(e.delta),files:e.delta.files.map(({path:n,role:i,node:o,change:r,fromNode:u,fromPath:_,segments:p})=>({path:n,role:i,node:o,change:r,segments:p,...u===void 0?{}:{fromNode:u},..._===void 0?{}:{fromPath:_}})),tools:e.delta.tools.map(({label:n,fromNode:i,toNode:o})=>({label:n,fromNode:i,toNode:o}))},...J(e)}}function $({path:e,startLine:s,endLine:n}){return{...e===void 0?{}:{path:e},startLine:s,endLine:n}}function ue(e,s){return{repoKey:e.repoKey,findings:e.findings.map(n=>({...Q(n),...J(n),...n.audience===void 0?{}:{audience:n.audience}})),structures:e.structures.map(Ce),warnings:e.warnings.slice(),...e.proposalCounts?{proposalCounts:{fromProposal:e.proposalCounts.fromProposal,fromRulesOnly:e.proposalCounts.fromRulesOnly,rejected:e.proposalCounts.rejected,rejectedByReason:Object.fromEntries(Z.options.filter(n=>e.proposalCounts.rejectedByReason[n]!==void 0).map(n=>[n,e.proposalCounts.rejectedByReason[n]]))}}:{},refusedFiles:s.map(({path:n,reason:i})=>({path:n,reason:i}))}}function de(e){if(e.redacted)throw new Error("Relay refused the request: leak_refused");return e.answer}import{z as T}from"zod";var R=1,ee=T.string().min(1).max(128),H=["file_reads","repository_listing","sealed_delivery"],v=T.strictObject({protocol:T.literal(R),bundleVersion:ee,engineVersion:ee,capabilities:T.array(T.enum(H)).refine(e=>e.length===H.length&&new Set(e).size===H.length)}),x=2;function te(){return T.strictObject({...v.shape,protocol:T.literal(x)}).refine(e=>v.safeParse({...e,protocol:R}).success)}var ne=Object.freeze(["CF_SKIPPED_FILES","CF_MECHANICAL_CHECKS","CF_MULTI_PASS","CF_SPLIT_CHECK","CF_FINDING_CHECK","CF_SOURCE_NOTES","CF_PARALLEL_PASSES","CF_PASS_CONCURRENCY","CF_PARALLEL_SCOPE_CHECK","CF_FINDING_QUALITY","CF_FINDING_FULL_CONTEXT","CF_FINDING_PRECISION_RULES","CF_PROMPT_AGREE","CF_FINDING_SECOND_OPINION","CF_FINDING_RANKING","CF_FINDING_SEMANTIC_MATCHING","CF_FINDING_CODE_INPUTS","CF_FINDING_RECALL","CF_FINDING_RECALL_VARIANT","CF_FINDING_SECOND_OPINION_MODEL","CF_FINDING_SECOND_OPINION_PROVIDER","CF_FIX_EXPECTED_OUTCOME","CF_UNTRUSTED_CONTENT_CHECK","CF_FINDING_BETTER_AS_CODE","CF_CODE_AGENTS","CF_CODE_AGENTS_MODEL","CF_FINDING_DEDUPE","CF_ANALYSIS_IMPORTED_AGENTS","CF_RECALL_SIGNALS","CF_READING_NOTE_AGENT_ONLY","CF_SPLIT_HELPER_TOOLS","CF_CODE_PROMPT_LOADERS","CF_CODE_PROMPT_FUNCTIONS","CF_READING_PRIORITY","CF_LOCAL_SYMLINK_GUARD","CF_IMPORT_EXAMPLE_FILTER","CF_IMPORT_OUTSIDE_LOADERS","CF_SECRET_SCAN","CF_RESPECT_GITIGNORE","CF_IMPORT_COVERAGE","CF_IMPORT_LEXICAL_FACTS","CF_IMPORT_PROMPT_FIELDS","CF_IMPORT_MANIFEST","CF_IMPORT_SCOPED_SCAN","CF_IMPORT_SCOPES","CF_IMPORT_AGENT_PAGES","CF_IMPORT_INCLUDE_EXAMPLES","CF_IMPORT_WEAK_CODE_FALLBACK","CF_FILE_SCOPE","CF_SCOPE_CHOICES","CF_FOLDER_PARTS","CF_PART_FILES","CF_LOCAL_IMPORT_RESOLUTION","CF_MULTI_ENTRY","CF_IMPORT_GUIDES_AS_PROMPT","CF_CONFIGURATION_GUIDE_PROMPT","CF_CHOOSE_AGENT","CF_IMPORT_PROPOSAL","CF_LOCAL_COMMITTED_ONLY","CF_LOCAL_GITIGNORE_OUTPUT","CF_LOCAL_ARCHITECTURE","CF_REFUSE_TOO_LARGE","CF_COST_FINDINGS","CF_FINDING_AUDIENCE","CF_NOT_ACTIVE_GROUP","CF_FINDING_HEADLINES","CF_IMPORT_LAYOUTS","CF_DISCOVERY_SKILLS","CF_IMPORT_CALLS","CF_PROMPT_CACHE","CF_MODEL_READER","CF_LEGACY_TOOL_LISTS","CF_RESULT_SAFETY_CHECK"]),q=ne.filter(e=>e!=="CF_SKIPPED_FILES"&&e!=="CF_RESULT_SAFETY_CHECK"&&e!=="CF_LOCAL_COMMITTED_ONLY"&&e!=="CF_LOCAL_GITIGNORE_OUTPUT"&&e!=="CF_LOCAL_ARCHITECTURE"&&e!=="CF_FOLDER_PARTS"&&e!=="CF_PART_FILES"&&e!=="CF_FILE_SCOPE"&&e!=="CF_SCOPE_CHOICES"&&e!=="CF_LOCAL_IMPORT_RESOLUTION"&&e!=="CF_MULTI_ENTRY"),ie=q.filter(e=>e!=="CF_IMPORT_OUTSIDE_LOADERS"&&e!=="CF_SECRET_SCAN"&&e!=="CF_RESPECT_GITIGNORE"&&e!=="CF_IMPORT_COVERAGE"&&e!=="CF_IMPORT_LEXICAL_FACTS"&&e!=="CF_IMPORT_PROMPT_FIELDS"&&e!=="CF_IMPORT_MANIFEST"&&e!=="CF_IMPORT_SCOPED_SCAN"&&e!=="CF_REFUSE_TOO_LARGE"&&e!=="CF_IMPORT_SCOPES"&&e!=="CF_IMPORT_AGENT_PAGES"&&e!=="CF_IMPORT_INCLUDE_EXAMPLES"&&e!=="CF_IMPORT_WEAK_CODE_FALLBACK"&&e!=="CF_IMPORT_GUIDES_AS_PROMPT"&&e!=="CF_CONFIGURATION_GUIDE_PROMPT"&&e!=="CF_CHOOSE_AGENT"&&e!=="CF_IMPORT_PROPOSAL"&&e!=="CF_FINDING_AUDIENCE"&&e!=="CF_MECHANICAL_CHECKS"&&e!=="CF_COST_FINDINGS"&&e!=="CF_NOT_ACTIVE_GROUP");function Ue(e,s="request"){return Object.freeze(Object.fromEntries((s==="saved"?ne:s==="engine"?q:ie).filter(i=>Object.hasOwn(e,i)&&e[i]!==void 0).map(i=>[i,e[i]])))}var ke=t.partialRecord(t.enum(ie),t.string()),re=t.partialRecord(t.enum(q),t.string()),C=t.string(),l=t.number().int().nonnegative().safe(),S=t.number().int().positive().safe(),G=t.enum(["bad_request","unavailable","reservation","leak_refused","cancelled"]);function Ye(e){let s=G.safeParse(e);return s.success?s.data:"unavailable"}function He(e){return Object.assign(new Error(e),{code:e})}var pe=1024*1024,se=C.min(1).max(128),M=C.regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/),g=C.regex(/^[a-f0-9]{64}$/),a={protocol:t.literal(R),analysisId:t.uuid(),nonce:C.min(16).max(256),bundleVersion:se,engineVersion:se};function c(e){return t.unknown().refine(s=>{try{let n=JSON.stringify(s);return typeof n=="string"&&new TextEncoder().encode(n).byteLength<=pe}catch{return!1}}).pipe(e)}var Oe=C.min(1).refine(e=>!/[\\\0\r\n]/.test(e)&&!/^(?:\/|[a-zA-Z]:)/.test(e)&&e.split("/").every(s=>s!==""&&s!=="."&&s!=="..")),Ee=t.strictObject({id:M,path:Oe,size:l,hash:g}),z=t.array(Ee).refine(e=>new Set(e.map(s=>s.id)).size===e.length&&new Set(e.map(s=>s.path)).size===e.length),B=t.strictObject({snapshot:g,commit:C.regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),files:z,entriesVisited:l.optional(),truncated:t.boolean().optional(),complete:t.boolean(),cursor:C.min(1).max(256).optional()}).refine(e=>e.complete?e.cursor===void 0:e.cursor!==void 0),ve=c(t.strictObject({...a,settings:re,manifest:B})),qe=t.strictObject(a),Fe=t.strictObject({startByte:l,endByte:l}).refine(e=>e.endByte>e.startByte),Ie=t.strictObject({startLine:S,endLine:S}).refine(e=>e.endLine>=e.startLine),oe=c(t.strictObject({...a,type:t.literal("need_files"),sequence:l,reads:t.array(t.strictObject({id:M,range:t.union([Fe,Ie])})).min(1)})),ce=c(t.strictObject({...a,type:t.literal("need_listing"),sequence:l,cursor:C.min(1).max(256).nullable()})),Se=c(t.discriminatedUnion("type",[t.strictObject({...a,type:t.literal("files"),sequence:l,files:t.array(t.union([t.strictObject({id:M,startByte:l,text:C,complete:t.boolean(),hash:g}),t.strictObject({id:M,refused:X})])).min(1)}),t.strictObject({...a,type:t.literal("listing"),sequence:l,manifest:B}),t.strictObject({...a,type:t.literal("reservation"),sequence:l,reservationId:t.uuid(),reservationToken:C.min(1).max(256)}),t.strictObject({...a,type:t.literal("delivery"),sequence:l,callId:t.uuid(),attemptId:t.uuid().nullable()}),t.strictObject({...a,type:t.literal("chunk"),sequence:l,callId:t.uuid(),attemptId:t.uuid(),chunk:S})])),j={chunk:l,chunks:S},Te=t.strictObject({...a,type:t.literal("result"),finalFiles:z,findings:t.array(K),structures:t.array(Y),notices:t.array(C)}),Re=c(Te.extend(j).refine(e=>e.chunk<e.chunks)),fe=c(t.strictObject({...a,type:t.literal("result_chunk"),...j,text:C,hash:g}).refine(e=>e.chunk<e.chunks)),le=c(t.strictObject({...a,type:t.literal("call_failed"),sequence:l,callId:t.uuid(),attemptId:t.uuid().nullable(),code:G}));function Ae(e){let s=c(t.strictObject({...a,type:t.literal("plan"),sequence:l,...j,plan:e.plan,finalFiles:z}).refine(r=>r.chunk<r.chunks)),n=C.regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).min(1).refine(r=>!/\s/.test(r)),i=c(t.strictObject({...a,type:t.literal("sealed_delivery"),sequence:l,callId:t.uuid(),attemptId:t.uuid(),algorithm:t.literal("AES-256-GCM"),iv:n.length(16),...j,ciphertext:n,tag:C.regex(/^[A-Za-z0-9+/]{21}[AQgw]==$/).length(24).optional(),delivery:t.strictObject({confirmation:e.deliveryConfirmation,deadlineMs:S}).optional()}).refine(r=>r.chunk<r.chunks&&(r.chunk===r.chunks-1?r.tag!==void 0&&r.delivery!==void 0&&r.delivery.confirmation.callId===r.callId&&r.delivery.confirmation.attemptId===r.attemptId:r.tag===void 0&&r.delivery===void 0))),o=t.strictObject({...a,type:t.literal("refused"),code:G});return{plan:s,sealedDelivery:i,response:t.union([oe,ce,s,i,le,Re,fe,o])}}var ze=t.strictObject({version:t.literal(1),serializedBytes:S,freeTextUtf8Bytes:S,fields:t.array(t.strictObject({pointer:C.regex(/^(?:\/(?:[^~/]|~[01])*)+$/),kind:t.enum(["string","array"]),max:S}))});function Be(e){let s={...a,protocol:t.literal(x)},n=e.context,i=c(t.strictObject({...s,settings:re,context:n.preparationContext,manifest:B})),o=t.strictObject(s),r=c(t.union([...Se.out.options.map(k=>k.extend(s)),t.strictObject({...s,type:t.literal("next"),sequence:l,stream:t.enum(["plan","result"]),chunk:S})])),u=t.strictObject({kind:t.literal("ready"),plan:e.plan,finalFiles:n.finalFiles,analysisSize:n.analysisSize,membership:n.membership}),_=t.strictObject({kind:t.literal("agent_choice"),choice:e.choice}),p=t.strictObject({kind:t.literal("proposal_refused")}),O=t.union([u,_,p]),d=t.strictObject({finalFiles:n.finalFiles,report:e.report,membership:n.membership,architecture:w.optional()}),E=d.extend({...s,type:t.literal("result")}),F=c(t.strictObject({...s,type:t.literal("plan"),sequence:l,plan:e.plan,finalFiles:n.finalFiles,analysisSize:n.analysisSize,membership:n.membership})),I=e.planChunks,f=e.resultChunks,N=c(I.chunk.safeExtend({...s,type:t.literal("plan_chunk"),sequence:l,stream:t.literal("plan")})),m=c(f.chunk.safeExtend({...s,type:t.literal("result_chunk"),sequence:l,stream:t.literal("result")})),P=Ae(e),y=c(t.strictObject({...P.sealedDelivery.out.shape,...s}).refine(k=>P.sealedDelivery.safeParse({...k,protocol:R}).success)),b=c(oe.out.extend(s)),h=c(ce.out.extend(s)),A=c(le.out.extend(s)),L=t.strictObject({...s,type:t.literal("refused"),code:G}),D=t.strictObject({...s,type:t.literal("cancelled")}),U=c(t.union([b,h,F,y,A,c(E),N,m,L,D,t.strictObject({...s,type:t.literal("agent_choice"),choice:e.choice}),t.strictObject({...s,type:t.literal("proposal_refused")})])),ae=t.union([d.extend({kind:t.literal("result")}),_,p]),_e=te();return{start:i,cancel:o,advance:r,needFiles:b,needListing:h,ready:u,preparationOutcome:O,resultBody:d,finalResult:E,plan:F,planChunk:N,resultChunk:m,sealedDelivery:y,callFailure:A,refused:L,cancelled:D,response:U,clientOutcome:ae,capabilities:_e}}export{Q as a,ue as b,de as c,R as d,v as e,x as f,ne as g,Ue as h,ke as i,re as j,G as k,Ye as l,He as m,pe as n,Ee as o,B as p,ve as q,qe as r,oe as s,ce as t,Se as u,Te as v,Re as w,fe as x,le as y,Ae as z,ze as A,Be as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as B}from"./YTHF2E2S.js";import{C as z}from"./4PT5C4IT.js";import{b as _,d as E}from"./2YREYGOG.js";import{a as A}from"./M5YWJY7P.js";import{Fb as b}from"./2AASSZRO.js";import{a as d}from"./MKYLK6DB.js";var L=t=>typeof t=="string"&&t.length>0&&!/[\\\0\r\n]/.test(t)&&!/^(?:\/|[a-zA-Z]:)/.test(t)&&t.split("/").every(n=>n!==""&&n!=="."&&n!=="..");function q(t){if(!B(t)||t.CF_PART_FILES===void 0)return;let n;try{n=JSON.parse(t.CF_PART_FILES)}catch{throw new Error("bad_request")}if(!Array.isArray(n)||!n.every(L))throw new Error("bad_request");return[...new Set(n)]}function S(t,n){let r=0,i=0,o=0;for(let c of t){let a=n.get(c);a.pool==="instruction"?r+=a.size:(i+=a.size,o++)}return{instruction:r,code:i,count:o}}function M(t,n,r){let{instruction:i,code:o,count:c}=S(t,n);return i<=d.sourceFetch.instructionBytes&&o<=d.sourceFetch.codeBytes&&c<=d.sourceFetch.codeFiles&&i+o<=d.codeAgent.importBytes&&E([...t].map(a=>({path:a,...n.get(a)})),r)!==void 0}var F=(t,n)=>new Set([...t,...n]);function N(t,n){let r=[];for(let i of t){let o=r.find(c=>M(F(c.files,i.files),n));o?(o.roots.push(i),o.files=F(o.files,i.files)):r.push({roots:[i],files:i.files})}return r}function P(t,n,r){let i=[...t].map(o=>[r.get(o).size,r.get(o).inputBytes??0]);return i.sort((o,c)=>o[0]-c[0]||o[1]-c[1]),JSON.stringify([S(t,r),i,[...t].filter(o=>n.has(o)).sort()])}function v(t,n,r,i){let o=[],c=new Set,a=t.map((f,e)=>new Set(t.slice(e).flatMap(s=>[...s.files]))),h=f=>{if(i.remaining--<=0)return!1;if(f===t.length)return!0;let e=l=>P(l,a[f],n),s=JSON.stringify([f,o.map(l=>e(l.files)).sort()]);if(c.has(s))return!1;let u=t[f],w=new Set;for(let l=0;l<=o.length&&l<r;l++){if(i.remaining<=0)return!1;let g=o[l],m=e(g?.files??new Set);if(w.has(m))continue;w.add(m);let p=g?F(g.files,u.files):u.files;if(M(p,n,i)){if(o[l]={roots:[...g?.roots??[],u],files:p},h(f+1))return!0;g?o[l]=g:o.pop()}}return c.add(s),!1};return h(0)?o:void 0}function I(t,n){if(!t.length)return[];let r=[...t].sort((e,s)=>s.weight-e.weight),i=N(r,n),o=S(new Set(t.flatMap(e=>[...e.files])),n),c=Math.max(1,Math.ceil(o.instruction/d.sourceFetch.instructionBytes),Math.ceil(o.code/d.sourceFetch.codeBytes),Math.ceil(o.count/d.sourceFetch.codeFiles)),a=_(),h=i;for(let e=c;e<i.length&&a.remaining>0;e++){let s=v(r,n,e,a);if(s){h=s;break}}let f=new Map(t.map((e,s)=>[e.path,s]));return h.map(e=>({paths:e.roots.map(s=>s.path).sort((s,u)=>f.get(s)-f.get(u)),files:[...e.files]})).sort((e,s)=>f.get(e.paths[0])-f.get(s.paths[0]))}function D(t,n){let r=new Map(n.entries.map(e=>[e.path,e])),{descriptions:i}=z(t,n.entries,{},{measureAnalysisSize:!0}),o=new Map(i.map(e=>[e.entry.path,e.analysisPool??e.pool])),c=new Map,a=new Map;for(let e of r.values()){if(!L(e.path)||!Number.isSafeInteger(e.size)||e.size<0){a.set(e.path,"unavailable");continue}let s=b(t,e,{purpose:"proposal",route:"local-folder"});if(!s.admitted){a.set(e.path,s.reason==="too-large"?"tooLarge":"unavailable");continue}let u=n.inputBytes?.[e.path];if(u!==void 0&&(!Number.isSafeInteger(u)||u<0)){a.set(e.path,"unavailable");continue}if(u!==void 0&&u>=8e5){a.set(e.path,"tooLarge");continue}c.set(e.path,{size:e.size,inputBytes:u,pool:o.get(e.path)??"code"})}let h={groups:[],tooLarge:[],unavailable:[]},f=[];for(let e of new Set(n.paths)){let s=new Set,u=[e],w=new Set,l=new Set,g;for(;u.length;){let p=u.pop();if(w.has(p))continue;w.add(p);let y=a.get(p)??(c.has(p)?void 0:"unavailable");if(y&&p!==e){l.add(p);continue}if(y){g=y;continue}s.add(p),n.dependencies&&Object.hasOwn(n.dependencies,p)&&u.push(...n.dependencies[p])}if(g){h[g].push(e);continue}if(l.size&&(h.missingContext??=[]).push({path:e,imports:[...l].sort()}),!M(s,c)){h.tooLarge.push(e);continue}let m=S(s,c);f.push({path:e,files:s,weight:Math.max(m.instruction/d.sourceFetch.instructionBytes,m.code/d.sourceFetch.codeBytes,m.count/d.sourceFetch.codeFiles)})}return h.groups=I(f,c),h}export{q as a,D as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var N=8e5,o=512,t=2e5,T=64e3;export{N as a,o as b,t as c,T as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";import{z as n}from"zod";import{z as v}from"zod";var b=v.enum(["ready","needs_review","blocked"]);var S=n.enum(["users","team"]),C=n.enum(["high","medium","low"]),j=n.enum(["added","edited","removed"]),q=n.enum(["invokes","delegates","reads","writes","emits"]),m=n.object({nodes:n.array(n.object({id:n.string().min(1),change:j,label:n.string().nullable()})),edges:n.array(n.object({from:n.string().min(1),to:n.string().min(1),kind:q,change:j,detail:n.string().nullable()}))}),F=n.object({summary:n.string().nullable(),impact:n.string().nullable(),confidence:C.nullable(),objective:n.string().nullable(),status:b.nullable(),blockedBy:n.string().nullable(),alsoFixes:n.array(n.string()).default([]),delta:m.nullable()});import{z as c}from"zod";var k=c.strictObject({state:c.enum(["active","dead","switched_off"]),gate:c.string().nullable(),reason:c.string(),evidence:c.array(c.strictObject({path:c.string(),line:c.number(),excerpt:c.string()}))});var t=e.string(),r=t.nullable(),x=e.number().int().positive().safe(),D=e.enum(["ordering","reliability","coverage","cost","safety","correctness"]),R=e.enum(["low","medium","high","critical"]),A={headline:t.optional(),ifLeft:t.optional()},I=e.strictObject({nodes:e.array(e.strictObject({id:t,change:t,label:r})),edges:e.array(e.strictObject({from:t,to:t,kind:t,change:t,detail:r}))}),E=e.strictObject({sites:e.array(e.strictObject({index:e.number().int().nonnegative().safe(),role:e.enum(["Says","But also says","Unclear","Context","Requirement","What actually happens","Why it's a gap","Evidence"]),meaning:t,keyPhrase:t})),support:e.enum(["supported","partly","not_supported"]),supportNote:t,counterEvidence:e.array(e.strictObject({repo:t,path:t,line:x,excerpt:t,meaning:t}))}),h=e.strictObject({kind:D,severity:R,title:t,cause:t,summary:r,category:r,question:r,audience:S.optional(),activity:k.optional(),siteRepo:r,site:e.strictObject({path:t,line:x.nullable()}).nullable(),excerpt:r,otherSites:e.array(e.strictObject({repo:t,path:t,line:x,excerpt:t})),fixes:e.array(e.strictObject({title:t,approach:t,kind:e.enum(["code","prompt"]),targetFiles:e.array(e.strictObject({path:t,create:e.boolean().nullable()})),expectedOutcome:t,summary:r,impact:r,confidence:r,objective:r,status:r,blockedBy:r,alsoFixes:e.array(t).nullable(),delta:I.nullable()})),sourceNotes:E.nullable().optional(),...A}),d=Object.freeze({findings:2e4,textBytes:4096,quoteBytes:2e3,freeTextBytesPerFinding:16*1024}),Z=d.freeTextBytesPerFinding*d.findings;function T(i){return typeof i=="string"?!i.includes("\0")&&!/[\uD800-\uDFFF]/u.test(i):i===null||typeof i!="object"||Object.values(i).every(T)}function B(i,o){return new TextEncoder().encode(i).byteLength<=(o?d.quoteBytes:d.textBytes)}var L=new Set(["excerpt","keyPhrase"]);function w(i){return L.has(String(i.at(-1)))}function _(i,o=[]){return typeof i=="string"?B(i,w(o)&&o[0]!=="activity"):i===null||typeof i!="object"||Object.entries(i).every(([f,u])=>_(u,[...o,f]))}var s=h.shape,O=t.min(1).refine(i=>i.trim().length>0),z=m.extend({nodes:e.array(m.shape.nodes.element.strict()),edges:e.array(m.shape.edges.element.strict())}).strict(),p=s.fixes.element.shape,P=e.strictObject({title:p.title.min(1),approach:p.approach.min(1),kind:p.kind,targetFiles:e.array(p.targetFiles.element.extend({path:t.min(1)})),...F.shape,delta:z.nullable(),expectedOutcome:p.expectedOutcome}),$=e.strictObject({...h.pick({kind:!0,severity:!0}).shape,title:s.title.min(1),cause:s.cause.min(1),summary:s.summary,site:s.site.unwrap().extend({path:t.min(1)}).nullable(),excerpt:s.excerpt,category:s.category,otherSites:e.array(e.strictObject({path:t.min(1),line:x,excerpt:t.trim().min(1),repo:O})),question:s.question,fixes:e.array(P).min(1),activity:s.activity,audience:s.audience,siteRepo:O.nullable(),sourceNotes:E.nullable().optional()}).refine(i=>_(i)),K=h.superRefine((i,o)=>{let f=0;function u(a,g){if(typeof a=="string"){let l=w(g);l||(f+=new TextEncoder().encode(a).byteLength),(!B(a,l)||!T(a))&&o.addIssue({code:"custom",path:g,message:"Invalid result text"})}else Array.isArray(a)?a.forEach((l,y)=>u(l,[...g,y])):a!==null&&typeof a=="object"&&Object.entries(a).forEach(([l,y])=>u(y,[...g,l]))}u(i,[]),f>d.freeTextBytesPerFinding&&o.addIssue({code:"custom",message:"Result text exceeds the finding budget"})}),ee=e.array(K).max(d.findings);export{b as a,S as b,C as c,j as d,q as e,F as f,k as g,D as h,R as i,A as j,I as k,h as l,d as m,Z as n,T as o,O as p,$ as q,K as r,ee as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={archive:{bytes:6e7,files:2e4},conventionImport:{fileBytes:5e4,totalBytes:12e4,skillBytes:6e5,skillFiles:60,extractionFiles:25},sourceFetch:{instructionBytes:6e5,codeBytes:3e5,htmlReferenceBytes:3e4,codeFileBytes:6e4,codeFiles:60},codeScan:{files:400,bytes:3e6,fileBytes:2e5},candidateFetch:{check:12e4,pointers:12e4},codeAgent:{extraBytes:4e4,importBytes:2e6,toolCodeFiles:5},survey:{fileBytes:5e6,files:60},localCheck:{uploadBytes:18e5},verification:{sourceBytes:12e4}};export{e as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./E7TFIHC5.js";import{f as p}from"./YTHF2E2S.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,c as a,e as g,g as h}from"./OKBK3JL3.js";import{b as o,g as f}from"./MGVIKA74.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};
|