@counterfact-labs/cli 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/client-release.json +1 -1
- package/dist/adapters/relay-plan.js +7 -5
- package/dist/analysis-core/analysis/file-analysis-plan.js +1 -1
- package/dist/analysis-core/analysis/finding-quality/policy.js +1 -1
- package/dist/analysis-core/analysis/folder-analysis-plan.js +1 -1
- package/dist/analysis-core/analysis/passes/full-file-passes.js +1 -1
- package/dist/analysis-core/analysis/project-architecture.js +1 -1
- package/dist/analysis-core/analysis/schemas.js +1 -1
- package/dist/analysis-core/chunks/{33IGHOYT.js → 2CWULBP2.js} +1 -1
- package/dist/analysis-core/chunks/{2AASSZRO.js → 2M55DR2J.js} +1 -1
- package/dist/analysis-core/chunks/33EUZF25.js +1 -0
- package/dist/analysis-core/chunks/34NVU26H.js +1 -0
- package/dist/analysis-core/chunks/{S27Y2TP5.js → 5BTATES5.js} +1 -1
- package/dist/analysis-core/chunks/{LOBIDUCA.js → 5UWDUYHF.js} +1 -1
- package/dist/analysis-core/chunks/{5B5UCWD3.js → 5VQ4VYIP.js} +1 -1
- package/dist/analysis-core/chunks/{4UDQBDDE.js → 66JRJPJC.js} +1 -1
- package/dist/analysis-core/chunks/{4RXRAB5S.js → 6JTHFDH3.js} +1 -1
- package/dist/analysis-core/chunks/{CTLHKFPH.js → 6VHZNBII.js} +1 -1
- package/dist/analysis-core/chunks/{CQQ4TTXE.js → C77LGCKF.js} +1 -1
- package/dist/analysis-core/chunks/CNQZLSAP.js +1 -0
- package/dist/analysis-core/chunks/{33HRXJ5Q.js → DHVEGIU6.js} +1 -1
- package/dist/analysis-core/chunks/I4F56VMG.js +1 -0
- package/dist/analysis-core/chunks/JAPVLU4Z.js +1 -0
- package/dist/analysis-core/chunks/{HHFDNY6V.js → KBTM5MBC.js} +1 -1
- package/dist/analysis-core/chunks/{FRXOQ2M6.js → LFJQ4YLP.js} +1 -1
- package/dist/analysis-core/chunks/{MZOKZ3N6.js → N2L4JMJE.js} +1 -1
- package/dist/analysis-core/chunks/{F54DOWKN.js → NCW5LJ5O.js} +1 -1
- package/dist/analysis-core/chunks/{4PT5C4IT.js → P253B344.js} +1 -1
- package/dist/analysis-core/chunks/{W24SFYZM.js → QPIBHTON.js} +1 -1
- package/dist/analysis-core/chunks/{RQTNTIR4.js → TA2NIQAY.js} +1 -1
- package/dist/analysis-core/chunks/{JGK37AWN.js → UKX3A6AX.js} +1 -1
- package/dist/analysis-core/chunks/{YTHF2E2S.js → VC3PYT2B.js} +1 -1
- package/dist/analysis-core/chunks/{JEWBPIQI.js → VWRFSVLI.js} +1 -1
- package/dist/analysis-core/chunks/VX6LYNXV.js +1 -0
- package/dist/analysis-core/chunks/{2YREYGOG.js → W73WF226.js} +1 -1
- package/dist/analysis-core/chunks/{HVQJKPQ4.js → XVGLY4EO.js} +1 -1
- package/dist/analysis-core/contracts/execution-request.js +1 -1
- package/dist/analysis-core/contracts/intake-finding.js +1 -1
- package/dist/analysis-core/contracts/relay-analysis.js +1 -1
- package/dist/analysis-core/contracts/requests.js +1 -1
- package/dist/analysis-core/conventions/analysis-fit.js +1 -1
- package/dist/analysis-core/conventions/file-admission.js +1 -1
- package/dist/analysis-core/import/entry-selection.js +1 -1
- package/dist/analysis-core/import/outside-loader-sources.js +1 -1
- package/dist/analysis-core/index.js +1 -1
- package/dist/analysis-core/requests/answer-formats.js +1 -1
- package/dist/analysis-core/requests/local-plan.js +1 -1
- package/dist/analysis-core/requests/registry.js +1 -1
- package/dist/analysis-core/requests/template-version.js +1 -1
- package/dist/analysis-core/requests/tools.js +1 -1
- package/dist/analysis-core/settings.js +1 -1
- package/dist/analysis-core/stages/engine-entry.js +1 -1
- package/dist/cli/commands/analyze.js +3 -6
- package/dist/cli/intake-payload.js +1 -2
- package/dist/cli/relay-check.js +3 -7
- package/dist/cli/relay-preparation.js +3 -3
- package/dist/contract/cli-version.js +1 -1
- package/dist/gatekeeper/console.js +2 -13
- package/package.json +1 -1
- package/dist/adapters/source-relay-plan.js +0 -7
- package/dist/analysis-core/chunks/LFYTD7JF.js +0 -1
- package/dist/analysis-core/chunks/LMUXOKIM.js +0 -1
- package/dist/analysis-core/chunks/MGVIKA74.js +0 -1
- package/dist/analysis-core/chunks/NXHVBJL4.js +0 -1
- package/dist/analysis-core/chunks/OKBK3JL3.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"verificationKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAbBab1PYdmBKXxCvoJ47toJhQvxPevo9nlZnb0zbDWoc=\n-----END PUBLIC KEY-----\n",
|
|
3
3
|
"relayVersion": "relay-1.0.1",
|
|
4
|
-
"localVersion": "0.2.
|
|
4
|
+
"localVersion": "0.2.10",
|
|
5
5
|
"relayUrl": "https://relay.counterfactlabs.com:8443",
|
|
6
6
|
"projectContext": "checks"
|
|
7
7
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { bundleContentHash } from "../bundle/seal/signature.js";
|
|
2
2
|
import { checkPlannedCallsAgainstBundle } from "../bundle/seal/planned-calls.js";
|
|
3
|
+
import { localSourcePlan } from "../analysis-core/requests/local-plan.js";
|
|
3
4
|
import { relayPlanSchema } from "../contract/console.js";
|
|
4
|
-
/** Callers authenticate the
|
|
5
|
-
export function
|
|
5
|
+
/** Callers authenticate the release before reading files; only this owner turns source facts into a paid plan. */
|
|
6
|
+
export function prepareRelayPlan({ bundle, tools, relayVersion, settings, source }) {
|
|
7
|
+
const { files, calls } = localSourcePlan(settings, source);
|
|
6
8
|
checkPlannedCallsAgainstBundle(bundle, calls);
|
|
7
|
-
return relayPlanSchema.parse({ bundleVersion:
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
return { files, plan: relayPlanSchema.parse({ bundleVersion: tools.bundleVersion,
|
|
10
|
+
bundleHash: bundleContentHash(bundle.sealed), relayVersion,
|
|
11
|
+
calls: calls.map(({ routeId, model, calls, maxInputBytes, maxInputTokens, maxOutputTokens }) => ({ routeId, model, calls, maxInputBytes, maxInputTokens, maxOutputTokens })) }) };
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunks/
|
|
1
|
+
import{a,b}from"../chunks/5UWDUYHF.js";import"../chunks/VC3PYT2B.js";import"../chunks/P253B344.js";import"../chunks/W73WF226.js";import"../chunks/6YCABS5T.js";import"../chunks/M5YWJY7P.js";import"../chunks/M6HYSTQD.js";import"../chunks/4H23CSUM.js";import"../chunks/VWRFSVLI.js";import"../chunks/VX6LYNXV.js";import"../chunks/MJGB25S5.js";import"../chunks/TA2NIQAY.js";import"../chunks/34NVU26H.js";import"../chunks/CNQZLSAP.js";import"../chunks/QVXARKP7.js";import"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/YUY436SM.js";import"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";export{a as fileScopeOf,b as planFileAnalyses};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as a,h as b}from"../../chunks/
|
|
1
|
+
import{g as a,h as b}from"../../chunks/NCW5LJ5O.js";import"../../chunks/QVXARKP7.js";import"../../chunks/2M55DR2J.js";import"../../chunks/74FPPPIG.js";import"../../chunks/MKYLK6DB.js";import"../../chunks/5TATKWLG.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/JAPVLU4Z.js";import"../../chunks/I4F56VMG.js";import"../../chunks/33EUZF25.js";import"../../chunks/YUY436SM.js";import"../../chunks/C6X5GDG4.js";import"../../chunks/724WZMYW.js";import"../../chunks/YWL52FVW.js";import"../../chunks/SJESFYBA.js";import"../../chunks/RUVMFAST.js";import"../../chunks/S27VIQMZ.js";import"../../chunks/INVTU73D.js";import"../../chunks/A7WJJMRY.js";import"../../chunks/Q5WR6B2H.js";import"../../chunks/VDUFPTDD.js";export{a as assessFindings,b as rankFindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as S,d as O}from"../chunks/
|
|
1
|
+
import{c as S,d as O}from"../chunks/DHVEGIU6.js";import"../chunks/2CWULBP2.js";import{b as q}from"../chunks/5UWDUYHF.js";import{i as x}from"../chunks/VC3PYT2B.js";import"../chunks/P253B344.js";import"../chunks/W73WF226.js";import"../chunks/6YCABS5T.js";import"../chunks/M5YWJY7P.js";import"../chunks/M6HYSTQD.js";import"../chunks/4H23CSUM.js";import"../chunks/VWRFSVLI.js";import"../chunks/VX6LYNXV.js";import"../chunks/MJGB25S5.js";import"../chunks/TA2NIQAY.js";import"../chunks/34NVU26H.js";import"../chunks/CNQZLSAP.js";import"../chunks/QVXARKP7.js";import"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import"../chunks/JAPVLU4Z.js";import"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/YUY436SM.js";import"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import"../chunks/INVTU73D.js";import"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";import{posix as j}from"node:path";function H(y,f){if(!x(y))return[];let b=[],p=new Set,v=new Set,a=[...new Set(f.paths)],i=new Set(a),d=new Set(f.agentPromptPaths.filter(e=>i.has(e))),r=f.fragment.nodes.filter(e=>e.kind==="agent"),E=new Set(r.flatMap(e=>e.files.map(t=>t.path).filter(t=>i.has(t)))),u=new Map(r.map(e=>[e.id,f.fragment.edges.filter(t=>t.from===e.id&&t.kind==="delegates").map(t=>t.to)])),F=e=>{let t=new Set,s=[e];for(;s.length;){let n=s.pop();t.has(n)||(t.add(n),s.push(...u.get(n)??[]))}return r.filter(n=>t.has(n.id)).flatMap(n=>n.files.map(o=>o.path).filter(o=>i.has(o)))},g=Object.assign(Object.create(null),f.dependencies),P=(e,t)=>{for(let s of e)g[s]=[...new Set([...g[s]??[],...t])]},R=e=>{let t=new Map;for(let s of e)for(let n of new Set(s.files))t.set(n,(t.get(n)??0)+1);return s=>t.get(s)===1},W=r.map(e=>({files:e.files.map(t=>t.path).filter(t=>i.has(t))})),$=R(W),A=e=>[...e.files.map(t=>t.path).filter(t=>i.has(t)).filter($),...e.sourceRef&&i.has(e.sourceRef.path)?[e.sourceRef.path]:[]],C=e=>e.sourceRef&&d.has(e.sourceRef.path)?e.sourceRef.path:e.files.find(t=>d.has(t.path))?.path;for(let e of r)P(A(e),F(e.id));let M=O(f.codeAgents??[]).map(e=>({...e,files:e.files.filter(t=>i.has(t))})),J=R(M);for(let e of M)P(e.files.filter(J),e.files);let k=(e,t,s)=>{if(!t.length)return!1;let n=q(y,{...f,dependencies:g,paths:t});if(n.groups.length!==1||n.tooLarge.length||n.unavailable.length||n.missingContext?.length)return!1;let o=[...n.groups[0].files].sort(),l=d.has(s)&&o.includes(s)?s:o.find(h=>d.has(h));if(!l||a.every(h=>o.includes(h)))return!1;let c=JSON.stringify(o);return v.has(c)||(v.add(c),o.forEach(h=>p.add(h)),b.push({label:e??S(o),files:o,reason:l})),!0},m=new Set,w=e=>{if(m.has(e))return;m.add(e);let t=r.find(n=>n.id===e);if(!t)return;let s=F(e);if(s.length){let n=A(t);if(n.length){let l=S(n);s.push(...a.filter(c=>!E.has(c)&&(l==="."||c.startsWith(`${l}/`))))}let o=C(t);if(o&&k(t.label,s,o))return}for(let n of u.get(e)??[])w(n)},L=new Set([...u.values()].flat());for(let e of r.filter(t=>!L.has(t.id)))w(e.id);for(let e of r)!m.has(e.id)&&!e.files.every(t=>p.has(t.path))&&w(e.id);let N=new Set(a.flatMap(e=>{let t=[];for(let s=j.dirname(e);s!==".";s=j.dirname(s))t.push(s);return t}));for(let e of[...N].sort()){let t=a.filter(s=>s.startsWith(`${e}/`));t.some(s=>p.has(s))||k(void 0,t,t[0])}return b}export{H as planFolderAnalyses};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as b,d as c}from"../../chunks/
|
|
1
|
+
import{b as a,c as b,d as c}from"../../chunks/W73WF226.js";import"../../chunks/6YCABS5T.js";import"../../chunks/M5YWJY7P.js";import"../../chunks/M6HYSTQD.js";import"../../chunks/4H23CSUM.js";import"../../chunks/VWRFSVLI.js";import"../../chunks/VX6LYNXV.js";import"../../chunks/MJGB25S5.js";import"../../chunks/TA2NIQAY.js";import"../../chunks/34NVU26H.js";import"../../chunks/CNQZLSAP.js";import"../../chunks/QVXARKP7.js";import"../../chunks/2M55DR2J.js";import"../../chunks/74FPPPIG.js";import"../../chunks/MKYLK6DB.js";import"../../chunks/5TATKWLG.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/JAPVLU4Z.js";import"../../chunks/I4F56VMG.js";import"../../chunks/33EUZF25.js";import"../../chunks/YUY436SM.js";import"../../chunks/C6X5GDG4.js";import"../../chunks/724WZMYW.js";import"../../chunks/YWL52FVW.js";import"../../chunks/SJESFYBA.js";import"../../chunks/RUVMFAST.js";import"../../chunks/S27VIQMZ.js";import"../../chunks/INVTU73D.js";import"../../chunks/A7WJJMRY.js";import"../../chunks/Q5WR6B2H.js";import"../../chunks/VDUFPTDD.js";export{b as fileEvidenceBytes,a as fileSearchBudget,c as fullFilePasses};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as d,d as
|
|
1
|
+
import{b as a,c as d,d as l}from"../chunks/JAPVLU4Z.js";import"../chunks/33EUZF25.js";import"../chunks/VDUFPTDD.js";import{z as r}from"zod";var f=256*1024,i=t=>r.string().min(1).refine(e=>e.trim().length>0&&e.isWellFormed()&&!new RegExp("\\p{Cc}|\\u2028|\\u2029","u").test(e)&&Buffer.byteLength(e,"utf8")<=t),m=i(1024).refine(t=>!t.startsWith("/")&&!t.includes("\\")&&!t.includes(":")&&t.split("/").every(e=>e!=="."&&e!==".."&&e!=="")),p=r.strictObject({path:m,role:a.shape.role,label:i(256).optional()}),h=r.strictObject({label:i(256),source:r.literal("mcp").optional()}),u=r.strictObject({version:r.literal(1),nodes:r.array(r.strictObject({id:i(256),label:i(256),kind:d.shape.kind,files:r.array(p).max(256),tools:r.array(h).max(256)})).min(1).max(1e3),edges:r.array(r.strictObject({from:i(256),to:i(256),kind:l.shape.kind})).max(4e3)}).refine(t=>{let e=new Set(t.nodes.map(o=>o.id));return e.size===t.nodes.length&&t.edges.every(o=>e.has(o.from)&&e.has(o.to))}),b=r.unknown().refine(t=>{try{let e=JSON.stringify(t);return typeof e=="string"&&Buffer.byteLength(e,"utf8")<=f}catch{return!1}}).pipe(u);function k(t){if(!t?.nodes.length)return;let e=new Map(t.nodes.map((s,n)=>[s.id,`node-${n+1}`])),o={version:1,nodes:t.nodes.map(s=>({id:e.get(s.id),label:s.label,kind:s.kind,files:(s.files??[]).map(n=>({path:n.path,role:n.role,...n.label===void 0?{}:{label:n.label}})),tools:(s.tools??[]).map(n=>({label:n.label,...n.source===void 0?{}:{source:n.source}}))})),edges:t.edges.map(s=>({from:e.get(s.from),to:e.get(s.to),kind:s.kind}))},c=b.safeParse(o);return c.success?c.data:void 0}export{f as PROJECT_ARCHITECTURE_BYTES,k as projectArchitecture,b as projectArchitectureSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ba as g,Ca as h,Da as i,Ea as j,Fa as l,Ka as o,Ma as p,Na as q,Oa as r,Pa as s,Qa as t,Ra as u}from"../chunks/
|
|
1
|
+
import{Ba as g,Ca as h,Da as i,Ea as j,Fa as l,Ka as o,Ma as p,Na as q,Oa as r,Pa as s,Qa as t,Ra as u}from"../chunks/2M55DR2J.js";import"../chunks/74FPPPIG.js";import"../chunks/MKYLK6DB.js";import"../chunks/5TATKWLG.js";import"../chunks/JKWTHRUR.js";import"../chunks/3GUKUEEJ.js";import{f as b,g as c,h as d,i as e,j as f}from"../chunks/JAPVLU4Z.js";import{a}from"../chunks/I4F56VMG.js";import"../chunks/33EUZF25.js";import"../chunks/YUY436SM.js";import"../chunks/C6X5GDG4.js";import"../chunks/724WZMYW.js";import"../chunks/YWL52FVW.js";import"../chunks/SJESFYBA.js";import"../chunks/RUVMFAST.js";import"../chunks/S27VIQMZ.js";import{a as m,b as n}from"../chunks/INVTU73D.js";import{a as k}from"../chunks/A7WJJMRY.js";import"../chunks/Q5WR6B2H.js";import"../chunks/VDUFPTDD.js";export{p as MAX_FINDINGS,i as attachFiles,q as cleanFindings,s as cleanFixDelta,h as cleanFragment,a as findingActivitySchema,n as findingActivitySettings,k as findingAudienceEnabled,e as findingsSchema,f as findingsSchemaFor,t as fingerprintOf,r as fixFingerprintOf,o as groupByActivity,l as groupByAudience,b as inspectFixSchema,j as mergeGraphs,g as normaliseBrand,m as notActiveEnabled,u as numberLines,c as otherSiteSchema,d as rawFindingSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as u}from"./
|
|
1
|
+
import{a as u}from"./P253B344.js";import{e as c}from"./2M55DR2J.js";function f(e){return e.prompt.kind!=="none"}function v(e,t,n){if(c(e))return n;let i=new Map(n.agentScopes?.map(r=>[r.key,r.folder])),s=Object.keys(t.files),o=new Map;return{...n,agents:n.agents.map(r=>{let p=i.get(r.key)??t.root,l=o.get(p);return l||(l=u(e,s,p,t.listedPaths??s),o.set(p,l)),{...r,definitionPaths:d(r,l)}})}}function d(e,t){if(f(e))return[e.prompt.path];let n=o=>!t.developerCompanionPaths.includes(o),i=e.subagents.filter(o=>n(o.path));if(i.length)return i.map(o=>o.path);let s=e.files.filter(o=>["skill","tools","mcp"].includes(o.role)&&n(o.path));return e.key!==null||e.plugin||s.some(o=>o.role==="tools"||o.role==="mcp")||!t.hasRepositoryGuide?s.map(o=>o.path):[]}function h(e){return!!e.definitionPaths?.length}function k(e,t,n,i){return c(e)?n!==i:(t.key!==null||f(t))&&h(t)}export{f as a,v as b,h as c,k as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as nn}from"./74FPPPIG.js";import{a as Fe}from"./MKYLK6DB.js";import{d as ho,e as ht}from"./5TATKWLG.js";import{
|
|
1
|
+
import{b as nn}from"./74FPPPIG.js";import{a as Fe}from"./MKYLK6DB.js";import{d as ho,e as ht}from"./5TATKWLG.js";import{f as ko}from"./JKWTHRUR.js";import{g as tn}from"./JAPVLU4Z.js";import{a as dt}from"./I4F56VMG.js";import{b as fo,d as Ht,e as uo}from"./33EUZF25.js";import{c as rn,d as sn,e as wt,g as wo}from"./YUY436SM.js";import{a as De,c as N,d as go,e as Be}from"./C6X5GDG4.js";import{a as ao,b as qt,c as co}from"./724WZMYW.js";import{a as G,b as S,c as _,d as J,e as Te,f as B,g as gt,h as Ne,i as he,j as Zt,k as I,l as T,m as mo,n as xe,o as z,p as Ve,q as ie,r as So,s as ee,t as Qt,u as q,v as U,w as te,x as yo,y as St}from"./YWL52FVW.js";import{a as W,b as po,d as xt,e as xo,f as ue}from"./SJESFYBA.js";import{a as kt}from"./INVTU73D.js";import{a as on}from"./A7WJJMRY.js";import{a as yt}from"./Q5WR6B2H.js";import{b as en}from"./VDUFPTDD.js";function bt(e,t,n){let o=e.split(`
|
|
2
2
|
`),r=Math.min(Math.max(t-1-3,0),o.length-1),s=0;for(let i=0;i<r;i++)s+=o[i].length+1;return{text:e.slice(s,s+n),fromLine:r+1}}var bo=/(^|\/)(?:(?:\.cursor|\.windsurf|\.claude|\.roo)\/rules\/|\.clinerules\/|\.junie\/guidelines\.md$|\.kiro\/steering\/|\.github\/instructions\/.*\.instructions\.md$)/;function Se(e){let t=e.toLowerCase(),n=t.split("/").pop();return["claude.md","agents.md","gemini.md",".cursorrules",".windsurfrules",".clinerules","copilot-instructions.md"].includes(n)||/^(claude|agents|gemini)\.(local|override)\.md$/.test(n)||bo.test(t)}function na(e){let t=e.toLowerCase();return t.includes("/")?t===".github/copilot-instructions.md"||bo.exec(t)?.index===0:Se(t)}function oa(e,t){return+(e.toLowerCase()==="agents.md")-+(t.toLowerCase()==="agents.md")||e.localeCompare(t)}var Xe=["claude.md","agents.md"];function vs(e){return!We(e)&&e.CF_CONFIGURATION_GUIDE_PROMPT!=="0"}function We(e){return e.CF_IMPORT_GUIDES_AS_PROMPT==="1"}function _o(e,t,n=!1){return n||We(e)||!Se(t)}function Eo(e,t){return We(e)?Xe.includes(t.toLowerCase()):Se(t)}function Ro({codeAgentsFound:e,folderAgentsFound:t=!1,otherDefinitions:n,agentConfiguration:o=!1,usage:r="import"},s){return We(s)?t?"background":r==="scan"?n?"prompt":"background":r==="map"?e?"background":"prompt":e&&!n?"background":"prompt":vs(s)&&o&&!e&&!t?"prompt":"background"}var $s=/\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|rb|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sh|bash|zsh|ps1|sql|tf|hcl|lock|toml|gradle)$/i,As=/\.(md|mdx|txt|json|ya?ml)$/i,Ls=/^(licen[cs]e.*|copying|notice|authors|codeowners|readme|changelog|\.gitignore|\.gitattributes|\.editorconfig|\.gitkeep|\.nvmrc|\.python-version|\.tool-versions|\.prettierrc|\.npmignore|\.dockerignore)$/i;function ln(e){return $s.test(e.trim())}function ia(e){return!ln(e)&&As.test(e.trim())}function la(e){let t=e.trim();return!Se(t)&&!Ls.test(t.split("/").at(-1))&&!/\.(md|mdx|txt|text|jsonl?|ndjson|csv|tsv|pdf|rst|adoc|ini|cfg|ya?ml|toml|lock|png|jpe?g|gif|svg|ico|webp|avif|bmp|tiff?)$/i.test(t)}function vo(e){return{salesforce:"Salesforce",slack:"Slack",s3:"S3",anthropic:"Anthropic","http-client":"HTTP client"}[e.toLowerCase()]??e}function $o(e){let t=new Map;for(let n of e)!n.unitKey||!n.scope||(t.has(n.scope)||t.set(n.scope,new Map),t.get(n.scope).set(n.unitKey,n.id));return e.flatMap(n=>!n.unitKey||!n.scope?[]:(n.links??[]).flatMap(o=>{let r=t.get(n.scope)?.get(o.to);return r?[{from:n.id,to:r,kind:"invokes",label:o.kind,sourceRef:o.source??null}]:[]}))}function _t(e){return e.CF_IMPORT_CALLS==="1"}function ye(e){return e.CF_IMPORT_LAYOUTS==="1"}import{relative as Zs,sep as Qs}from"node:path";function ne(e,t){return e.CF_IMPORT_COVERAGE==="1"&&(t===void 0||e[t]==="1")}function V(e){return ne(e,"CF_IMPORT_LAYOUTS")}var Et=["eval","evals"],Ps=new RegExp(`(^|/)(${[...Et,"evaluations?","bench(?:mark)?s?"].join("|")})/`,"i"),Os=/^(evals?|bench(?:mark)?s?)[_-].+|.+[._-](evals?|bench(?:mark)?s?)[._-]/i;function Ao(e,t){if(Ps.test(e))return!0;let n=W(e);if((n||/\.(json|ya?ml|toml)$/i.test(e))&&Os.test(e.split("/").at(-1)))return!0;if(!n||t===void 0||!/(^|\/)scripts\//i.test(e))return!1;let o=G(e,t,n),{toks:r}=o;if(r.some((u,d)=>_(u,"export")||_(u,"exports")||n==="py"&&_(u,"def")||_(u,"module")&&S(r[d+1],".")&&_(r[d+2],"exports"))||!r.some(u=>_(u)&&/^(expected|dataset|fixtures|cases)$/i.test(u.text)))return!1;let s=r.flatMap((u,d)=>_(u)&&S(r[d+1],"(")&&!["for","if","while","switch","catch"].includes(u.text)&&!["function","def","class"].includes(r[d-1]?.text)?[d]:[]),l=z(o).filter(u=>u.names.some(d=>s.some(m=>_(r[m],d)&&!S(r[m-1],".")))),a=/(^|[/._-])(scores?|scoring|graders?|grading|evals?|evaluators?|bench(?:mark)?s?)([/._-]|$)/i,c=l.filter(u=>u.source.startsWith(".")&&/(^|[/._-])(agents?|runners?)([/._-]|$)/i.test(u.source)),p=[...c,...l.filter(u=>a.test(u.source))],f=new Set(p.flatMap(u=>u.names));return s.some(u=>S(r[u-1],".")?!(_(r[u-2],"console")&&["log","table"].includes(r[u].text)):_(r[u],"require")&&r[u+2]?.kind==="string"&&p.some(d=>d.source===r[u+2].value)?!1:!f.has(r[u].text)&&!(n==="py"&&_(r[u],"print")))?!1:l.some(u=>a.test(u.source))&&c.some(u=>!a.test(u.source))}var Oo=/(^|\/)(__tests__|__snapshots__)\/|\.(test|spec)\.[jt]sx?$|_test\.(go|py)$/i,an=new Set(["test","tests","__tests__","spec","specs","testdata","test-data","test_data","test-support","mocks","fixtures","fixture","__fixtures__","__mocks__","__snapshots__"]),Io=/^(examples?|samples?)(?:[-_].+)?$|^.+[-_](examples?|samples?)$/i,Mo=/\.(test|spec)\..+|^test_.*\.py$|_test\.(py|go)$|_spec\.rb$|^conftest\.py$/i,Is=new Set([...an].filter(e=>!["test","tests","__tests__","spec","specs"].includes(e))),Ms=new Set([".github","cassettes"]),Cs=new Set,Lo=new WeakMap;function vt(e){if(!ne(e))return[];let t=Lo.get(e);if(t)return t;let n=[];try{let o=JSON.parse(e.CF_IMPORT_SCOPES??"[]");Array.isArray(o)&&o.every(r=>{if(!r||typeof r!="object"||!["runtime","example","evaluator"].includes(r.kind)||typeof r.path!="string")return!1;let s=r.path.endsWith("/**"),i=s?r.path.slice(0,-3):r.path;return!!i&&!/[\\\0:*?]/.test(i)&&!i.split("/").some(l=>!l||l==="."||l==="..")&&!(r.kind==="evaluator"&&s)})&&new Set(o.map(r=>r.path)).size===o.length&&(n=Object.freeze(o.map(({path:r,kind:s})=>Object.freeze({path:r,kind:s}))))}catch{}return Lo.set(e,n),n}function ke(e,t,n){let o=N(t,n);if(o===null)return;let r=vt(e).filter(l=>l.path.endsWith("/**")?t.startsWith(l.path.slice(0,-2)):t===l.path).sort((l,a)=>a.path.replace(/\/\*\*$/,"").length-l.path.replace(/\/\*\*$/,"").length)[0];if(!r||r.kind==="runtime")return;let s=o.split("/"),i=s.pop();if(!(s.some(l=>Is.has(l.toLowerCase())||Ms.has(l.toLowerCase()))||/^conftest\.py$/i.test(i))&&!(r.kind==="example"&&(Mo.test(i)||s.some(l=>an.has(l.toLowerCase())))))return r}function cn(e,t,n={}){return!vt(e).some(r=>r.kind!=="runtime"&&(N(r.path,n.root)!==null||r.path.endsWith("/**")&&N(`${De(n.root)}/`,r.path.slice(0,-3))!==null))||ke(e,t,n.root)?!1:Rt(t,{root:n.root??void 0,listing:n.listing??Cs})!==null}var js=new Set(["example-agents","examples","example","fixtures","__fixtures__","testdata","test","tests","__tests__","demo","demos"]),Ts=/^examples?[-_]/i;function Co(e,t,n){if(e.CF_IMPORT_INCLUDE_EXAMPLES==="1"||ke(e,t,n))return!1;let o=ne(e),r=i=>js.has(i.toLowerCase())||Ts.test(i)||o&&(i.toLowerCase()==="fixture"||Io.test(i));if(De(n).split("/").some(r))return!1;let s=N(t,n);return s!==null&&s.split("/").slice(0,-1).some(r)}var Po=new WeakMap;function Ns(e){let t=Po.get(e);if(t)return t;let n={exact:new Set,foldedNames:new Set};for(let o of e.keys()){let r=0;for(let s=o.indexOf("/");s!==-1;s=o.indexOf("/",r))n.exact.add(o.slice(0,s)),n.foldedNames.add(o.slice(0,r)+o.slice(r,s).toLowerCase()),r=s+1}return Po.set(e,n),n}function Fs(e,t,n){let o=e.some(r=>Rt(t(r),n)===null);return r=>{if(n.settings&&ke(n.settings,r,n.root))return!1;if(n.settings&&cn(n.settings,r,n))return!0;let s=Rt(r,n);return s==="test"||s==="example"&&o}}function jo(e,t,n){let o=Fs(e,t,n),r=[],s=[];for(let i of e)(o(t(i))?s:r).push(i);return{kept:r,skipped:s}}function fn(e,t){return Rt(e,t)!==null}function Rt(e,t){let n=N(e,t.root);return n?Ds(e,n,t):null}function Ds(e,t,n){let o=Ns(n.listing),r=e.endsWith("/")||o.exact.has(e),s=t.split("/").filter(Boolean),i=r?"":s.pop()??"";return Mo.test(i)||s.some(a=>an.has(a.toLowerCase()))?"test":s.some((a,c)=>{let p=a.toLowerCase();if(Io.test(p))return!0;if(p!=="before"&&p!=="after")return!1;let f=De(Be(s.slice(0,c).join("/"),n.root)),u=f?`${f}/`:"",d=p==="before"?"after":"before";return o.foldedNames.has(u+d)})?"example":null}var Bs=new Set,To=new WeakMap;function No(e,t){let n={root:t.root,listing:t.listing??Bs};if(!fn(e,n))return!1;let o=t.listing;if(!o?.has(e))return!0;let r=To.get(o);r||To.set(o,r=new WeakMap);let s=r.get(t.settings);s||r.set(t.settings,s=new Map);let i=s.get(t.key);if(!i){let l=[...o.keys()].filter(a=>fn(a,n)||t.readable(a,"get"in o?o.get(a):void 0));i=new Set(jo(l,a=>a,n).skipped),s.set(t.key,i)}return i.has(e)}function Fo(e){return e.CF_IMPORT_EXAMPLE_FILTER!=="0"}import{posix as un}from"node:path";var pn=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function le(e,t={}){let n=`(?:${Je.map(pn).join("|")})`,o=`(?:${$t.map(pn).join("|")})`,s=new RegExp(`^(${t.nested?"(?:.*?/)??":""}(?:(${n}/[^/]+)/${we}|${o})/([^/]+))/(.+)$`,t.caseSensitive?"":"i").exec(e);if(!s)return null;let i=t.caseSensitive?s[4]:s[4].toLowerCase(),l=t.caseSensitive?F.skill:F.skill.toLowerCase();return{folder:s[1],name:s[3],definition:i===l,reference:i.startsWith("references/"),...s[2]?{ownerPath:s[1].replace(/\/skills\/[^/]+$/i,".md")}:{}}}function mn(e){return le(e)?.reference??!1}function Ws(e){return ne(e,"CF_DISCOVERY_SKILLS")}function Ks(e){return!/[\\:\0]/.test(e)&&e.split("/").every(t=>t&&t!=="."&&t!=="..")}function Us(e){let t=[],n;for(let[o,r]of e.split(/\r?\n/).entries()){let s=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec(r);if(n){if(s&&s[1][0]===n.marker[0]&&s[1].length>=n.marker.length&&!s[2].trim()){n=void 0;continue}if(!n.shell||!/^\s*(?:\$\s+)?(?:cat|less|more|head|tail)\s+/.test(r))continue}if(!n&&s){n={marker:s[1],shell:/^(?:sh|bash|shell|console)?$/i.test(s[2].trim())};continue}let i=/!?\[[^\]\n]*\]\(\s*(?:<([^>\n]+)>|([^\s)\n]+))(?:\s+["'][^"'\n]*["'])?\s*\)|^\s*\[[^\]]+\]:\s*(?:<([^>]+)>|(\S+))|`([^`\n]+)`|([^\s`<>"'()[\],;]+)/g;for(let l of r.matchAll(i)){let a=l.slice(1,5).some(d=>d!==void 0),c=l[1]??l[2]??l[3]??l[4]??l[5]??l[6],p=a?c:c.replace(/[.,;:]+$/,""),f=/^[^.\s][^\s]*\.(?:md|mdx|rst|txt|html?|json|ya?ml|toml|csv|ts|tsx|js|jsx|mjs|cjs|py|go|java|rb|rs|sh|prompt)(?:#.*)?$/i.test(p.split(/[/\\]/).at(-1)??""),u=l[5]!==void 0&&/[/\\]/.test(p)||/^\.{1,2}[/\\]/.test(p);p.startsWith("#")||!a&&(/\s/.test(p)||!(u||f))||t.push({target:p,span:{from:o+1,to:o+1},explicit:a||l[5]!==void 0,fileLike:f||u})}}return t}function Gs(e,t,n,o=!1){let r=t.split("#")[0];if(!r||/[\\:\0*?[\]$]/.test(r)||r.startsWith("/")||/[{}]/.test(r.replace(/(?:^|\/)\{lang\}(?=\/)/g,""))||o&&/[\s<>{}%~]/.test(r))return{reason:"unsupported"};let s=un.normalize(un.join(un.dirname(e),r));return s===".."||s.startsWith("../")||N(s,n)===null?{reason:"out-of-scope"}:{path:s}}function Aa(e,t){let n={references:[],cycles:[],unresolved:[]};if(!Ws(e))return n;let o=[...new Set(t.paths)].filter(s=>Ks(s)&&N(s,t.root)!==null).sort(),r=new Set(o);for(let s of[...new Set(t.skillPaths)].sort()){if(!r.has(s)||!le(s,{nested:!0})?.definition)continue;let i=new Set,l=new Set,a=c=>{if(!(i.has(c)||!Object.hasOwn(t.files,c))){i.add(c),l.add(c);for(let{target:p,span:f}of Us(t.files[c])){let u=k=>n.unresolved.push({ownerPath:s,fromPath:c,target:p,span:f,reason:k}),d=Gs(c,p,t.root);if(d.reason){u(d.reason);continue}let m=d.path,g=new RegExp(`^${m.split("/").map(k=>k==="{lang}"?"[^/]+":pn(k)).join("/")}$`),h=m.includes("{lang}")?o.filter(k=>g.test(k)):r.has(m)?[m]:[];if(!h.length){u("missing");continue}for(let k of h){let y={ownerPath:s,fromPath:c,path:k,span:f};l.has(k)?n.cycles.push(y):(n.references.push(y),a(k))}}l.delete(c)}};a(s)}return n}var be=/\.(?:md|txt|j2|hbs|mustache|prompt)$/i,Do=/(?:^|[/\\])(?:prompts?|templates?|instructions)(?=$|[/\\])/i,zs=/prompt|instructions|system/i,Vs=200;function At(e){if(!be.test(e))return!1;let t=e.split("/"),n=t[t.length-1];return t.slice(0,-1).some(r=>r.toLowerCase()==="prompts")||zs.test(n)}function Bo(e,t){return!At(e)||Buffer.byteLength(t)<Vs?null:Xs(e,t)}function Xs(e,t){let n=Buffer.byteLength(t),o=t.split(`
|
|
3
3
|
`).length;return{kind:"file",named:!1,prose:!1,path:e,start:0,line:1,endLine:o,span:{from:1,to:o},symbol:null,chars:n,excerpt:xe(t),enclosing:null}}function Oa(e,t){let n=e.toks[t.from];return t.to!==t.from+1||n?.kind!=="string"||!Te(n).closed?null:{kind:"named",named:!0,prose:!1,path:e.path,start:n.start,line:n.line,endLine:n.endLine,span:{from:n.line,to:n.endLine},symbol:null,chars:n.value.length,excerpt:xe(n.value),enclosing:null}}function dn(e){return/(?:^|\/)(?:pyproject\.toml|requirements\.txt)$/i.test(e)}function Ma(e,t){if(!dn(e))return!1;let n=t.split(/\r?\n/).map(s=>s.replace(/("(?:\\.|[^"\\])*"|'[^']*')|#.*/g,(i,l)=>l??""));if(/(?:^|\/)requirements\.txt$/i.test(e))return n.some(s=>/^\s*openai[-_.]agents(?:\[[^\]]*\])?(?=\s*(?:$|[<>=!~;@#]))/i.test(s));let o="",r=new Map;for(let s of n){let i=/^\s*\[([^\]]+)\]/.exec(s);i?o=i[1]:(r.has(o)||r.set(o,[]),r.get(o).push(s))}for(let[s,i]of r){let l=i.join(`
|
|
4
4
|
`);if(/^tool\.poetry(?:\.group\.[^.]+)?\.dependencies$/.test(s)){if(/^\s*["']?openai[-_.]agents["']?\s*=/im.test(l))return!0}else if(["project","project.optional-dependencies","dependency-groups"].includes(s)){let a=/^\s*([\w."'-]+)\s*=\s*\[((?:"(?:\\.|[^"\\])*"|'[^']*'|[^\]"'])*)\]/gm;for(let c of l.matchAll(a))if(!(s==="project"&&c[1].replace(/["']/g,"")!=="dependencies")&&/["']openai[-_.]agents(?=["'[<>=!~ ;@])/i.test(c[2]))return!0}}return!1}function Wo(e){return/\.json$/i.test(e)?"json":/\.ya?ml$/i.test(e)?"yaml":W(e)||/\.(cs|go|rb|java)$/i.test(e)?"code":/\.(md|markdown)$/i.test(e)?"markdown":"text"}import{posix as Y}from"node:path";function Ko(e,t){if(t==="markdown"){let l=e.startsWith("---")?e.indexOf(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";import{z as a}from"zod";var t=a.enum(["ready","needs_review","blocked"]);var d=e.enum(["users","team"]),i=e.enum(["high","medium","low"]),n=e.enum(["added","edited","removed"]),l=e.enum(["invokes","delegates","reads","writes","emits"]),r=e.object({nodes:e.array(e.object({id:e.string().min(1),change:n,label:e.string().nullable()})),edges:e.array(e.object({from:e.string().min(1),to:e.string().min(1),kind:l,change:n,detail:e.string().nullable()}))}),u=e.object({summary:e.string().nullable(),impact:e.string().nullable(),confidence:i.nullable(),objective:e.string().nullable(),status:t.nullable(),blockedBy:e.string().nullable(),alsoFixes:e.array(e.string()).default([]),delta:r.nullable()});export{t as a,d as b,i as c,n as d,l as e,r as f,u as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ne,b as se,c as ie,d as X,e as T}from"./CNQZLSAP.js";import{a as te}from"./I4F56VMG.js";import{z as t}from"zod";import{z as i}from"zod";var r=i.string(),S=r.nullable(),P=i.number().int().nonnegative().safe(),U=i.number().int().positive().safe(),re=i.strictObject({path:r.optional(),startLine:U,endLine:U}),h=i.number(),oe=i.strictObject({subKind:i.enum(["split_monolith","single_source","fold_patches","extract_subagent","merge_subagents","move_rule","move_tool","reorder"]),kind:ne,severity:se,title:r,cause:r,summary:r.optional(),evidence:i.array(i.strictObject({path:r,line:U,excerpt:r})),files:i.array(i.strictObject({path:r,action:i.enum(["create","shrink","edit","delete"]),role:i.enum(["system prompt","soul","knowledge","skill","config","tools","mcp","template","reference","log","code"]),unit:r,loadMode:i.enum(["always","on_demand","never"]),loadVia:S,purpose:r,frontmatter:i.strictObject({name:r,description:r,tools:i.array(r)}).nullable()})),segments:i.array(i.strictObject({path:r,startLine:h,endLine:h,to:r,disposition:i.enum(["move","fold_into","remove_duplicate","remove_superseded"]),into:i.strictObject({path:r,line:h}).nullable(),childRef:S,heading:S,reason:r})),additions:i.array(i.strictObject({path:r,text:r,kind:i.enum(["pointer","handoff","reference_update"]),heading:S})),reorder:i.strictObject({path:r,startLine:h,endLine:h,steps:i.array(i.strictObject({from:U,reason:S}))}).nullable(),toolMoves:i.array(i.strictObject({tool:r,fromUnit:r,toUnit:r,reason:r,fromPath:S,toPath:S})),motivation:i.array(i.strictObject({kind:r,reason:r,evidence:r})).optional(),outcomes:i.array(i.strictObject({improvement:r,measurement:r})).optional(),split:i.strictObject({root:r.optional(),frontDoor:i.strictObject({name:r.optional(),job:r,skills:i.array(r)}),subAgents:i.array(i.strictObject({name:r,job:r,description:r,path:r,handoff:r.optional(),resolves:i.array(r).optional(),skills:i.array(i.strictObject({name:r,from:r,to:r})),tools:i.array(r),noTools:i.boolean().optional(),movedKnowledge:i.array(re),neededKnowledge:i.array(re)}))}).optional()}),ye=i.strictObject({nodes:i.array(X.shape.nodes.element.extend({change:i.enum(["added","edited","removed"]),label:S.optional()})),edges:i.array(X.shape.edges.element.extend({kind:i.enum(["invokes","delegates","reads","writes","emits"]),change:i.enum(["added","edited","removed"]),detail:S.optional()})),files:i.array(i.strictObject({path:r,role:oe.shape.files.element.shape.role,node:r,change:i.enum(["added","removed","moved","shrunk","grown","reordered"]),fromNode:r.optional(),fromPath:r.optional(),segments:P})),tools:i.array(i.strictObject({label:r,fromNode:r,toNode:r}))}),v=i.strictObject({repo:r,children:i.array(i.strictObject({ref:r,how:r})),sourceHashes:i.record(r,r),body:oe,delta:ye,...ie}),K=i.enum(["secret","secret-content","hidden","excluded","wrong-type","too-large","empty","out-of-scope","allowance","total","scan-limit","tool-limit","missing","unreadable"]),Z=i.enum([...K.options,"coding-guide","duplicate"]),Re=i.strictObject({fromProposal:P,fromRulesOnly:P,rejected:P,rejectedByReason:i.partialRecord(Z,P)}),Te=i.strictObject({repoKey:r,findings:i.array(T),structures:i.array(v),warnings:i.array(r),proposalCounts:Re.optional(),refusedFiles:i.array(i.strictObject({path:r,reason:K}))});function ce(e){return{nodes:e.nodes.map(({id:n,change:s,label:o})=>({id:n,change:s,...o===void 0?{}:{label:o}})),edges:e.edges.map(({from:n,to:s,kind:o,change:c,detail:a})=>({from:n,to:s,kind:o,change:c,...a===void 0?{}:{detail:a}}))}}function le(e,n=s=>s){let{kind:s,severity:o,title:c,cause:a,summary:C,category:p,question:E,excerpt:m}=e;return{kind:s,severity:o,title:c,cause:a,summary:C,category:p,question:E,excerpt:m,...e.activity===void 0?{}:{activity:te.parse(e.activity)},siteRepo:n(e.siteRepo),site:e.site&&{path:e.site.path,line:e.site.line},otherSites:e.otherSites.map(({repo:O,path:F,line:f,excerpt:I})=>({repo:n(O),path:F,line:f,excerpt:I})),fixes:e.fixes.map(({title:O,approach:F,kind:f,targetFiles:I,expectedOutcome:A,summary:j,impact:D,confidence:g,objective:x,status:M,blockedBy:G,alsoFixes:L,delta:N})=>({title:O,approach:F,kind:f,targetFiles:I.map(({path:k,create:B})=>({path:k,create:B})),expectedOutcome:A,summary:j,impact:D,confidence:g,objective:x,status:M,blockedBy:G,alsoFixes:L&&L.slice(),delta:N&&ce(N)})),...e.sourceNotes===void 0?{}:{sourceNotes:e.sourceNotes&&{sites:e.sourceNotes.sites.map(({index:O,role:F,meaning:f,keyPhrase:I})=>({index:O,role:F,meaning:f,keyPhrase:I})),support:e.sourceNotes.support,supportNote:e.sourceNotes.supportNote,counterEvidence:e.sourceNotes.counterEvidence.map(({repo:O,path:F,line:f,excerpt:I,meaning:A})=>({repo:n(O),path:F,line:f,excerpt:I,meaning:A}))}}}}function de(e){return{...e.headline===void 0?{}:{headline:e.headline},...e.ifLeft===void 0?{}:{ifLeft:e.ifLeft}}}function be(e){let n=e.body;return{repo:e.repo,children:e.children.map(({ref:s,how:o})=>({ref:s,how:o})),sourceHashes:Object.fromEntries(Object.entries(e.sourceHashes)),body:{subKind:n.subKind,kind:n.kind,severity:n.severity,title:n.title,cause:n.cause,...n.summary===void 0?{}:{summary:n.summary},evidence:n.evidence.map(({path:s,line:o,excerpt:c})=>({path:s,line:o,excerpt:c})),files:n.files.map(({path:s,action:o,role:c,unit:a,loadMode:C,loadVia:p,purpose:E,frontmatter:m})=>({path:s,action:o,role:c,unit:a,loadMode:C,loadVia:p,purpose:E,frontmatter:m&&{name:m.name,description:m.description,tools:m.tools.slice()}})),segments:n.segments.map(({path:s,startLine:o,endLine:c,to:a,disposition:C,into:p,childRef:E,heading:m,reason:O})=>({path:s,startLine:o,endLine:c,to:a,disposition:C,into:p&&{path:p.path,line:p.line},childRef:E,heading:m,reason:O})),additions:n.additions.map(({path:s,text:o,kind:c,heading:a})=>({path:s,text:o,kind:c,heading:a})),reorder:n.reorder&&{path:n.reorder.path,startLine:n.reorder.startLine,endLine:n.reorder.endLine,steps:n.reorder.steps.map(({from:s,reason:o})=>({from:s,reason:o}))},toolMoves:n.toolMoves.map(({tool:s,fromUnit:o,toUnit:c,reason:a,fromPath:C,toPath:p})=>({tool:s,fromUnit:o,toUnit:c,reason:a,fromPath:C,toPath:p})),...n.motivation===void 0?{}:{motivation:n.motivation.map(({kind:s,reason:o,evidence:c})=>({kind:s,reason:o,evidence:c}))},...n.outcomes===void 0?{}:{outcomes:n.outcomes.map(({improvement:s,measurement:o})=>({improvement:s,measurement:o}))},...n.split===void 0?{}:{split:{...n.split.root===void 0?{}:{root:n.split.root},frontDoor:{...n.split.frontDoor.name===void 0?{}:{name:n.split.frontDoor.name},job:n.split.frontDoor.job,skills:n.split.frontDoor.skills.slice()},subAgents:n.split.subAgents.map(s=>({name:s.name,job:s.job,description:s.description,path:s.path,...s.handoff===void 0?{}:{handoff:s.handoff},...s.resolves===void 0?{}:{resolves:s.resolves.slice()},skills:s.skills.map(({name:o,from:c,to:a})=>({name:o,from:c,to:a})),tools:s.tools.slice(),...s.noTools===void 0?{}:{noTools:s.noTools},movedKnowledge:s.movedKnowledge.map(ae),neededKnowledge:s.neededKnowledge.map(ae)}))}}},delta:{...ce(e.delta),files:e.delta.files.map(({path:s,role:o,node:c,change:a,fromNode:C,fromPath:p,segments:E})=>({path:s,role:o,node:c,change:a,segments:E,...C===void 0?{}:{fromNode:C},...p===void 0?{}:{fromPath:p}})),tools:e.delta.tools.map(({label:s,fromNode:o,toNode:c})=>({label:s,fromNode:o,toNode:c}))},...de(e)}}function ae({path:e,startLine:n,endLine:s}){return{...e===void 0?{}:{path:e},startLine:n,endLine:s}}function Ae(e,n){return{repoKey:e.repoKey,findings:e.findings.map(s=>({...le(s),...de(s),...s.audience===void 0?{}:{audience:s.audience}})),structures:e.structures.map(be),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(s=>e.proposalCounts.rejectedByReason[s]!==void 0).map(s=>[s,e.proposalCounts.rejectedByReason[s]]))}}:{},refusedFiles:n.map(({path:s,reason:o})=>({path:s,reason:o}))}}function Le(e){if(e.redacted)throw new Error("Relay refused the request: leak_refused");return e.answer}import{z as R}from"zod";var b=1,_e=R.string().min(1).max(128),$=["file_reads","repository_listing","sealed_delivery"],W=R.strictObject({protocol:R.literal(b),bundleVersion:_e,engineVersion:_e,capabilities:R.array(R.enum($)).refine(e=>e.length===$.length&&new Set(e).size===$.length)}),H=2;function pe(){return R.strictObject({...W.shape,protocol:R.literal(H)}).refine(e=>W.safeParse({...e,protocol:b}).success)}var Ce=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=Ce.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"),Oe=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 et(e,n="request"){return Object.freeze(Object.fromEntries((n==="saved"?Ce:n==="engine"?Q:Oe).filter(o=>Object.hasOwn(e,o)&&e[o]!==void 0).map(o=>[o,e[o]])))}var tt=t.partialRecord(t.enum(Oe),t.string()),Ee=t.partialRecord(t.enum(Q),t.string()),u=t.string(),d=t.number().int().nonnegative().safe(),y=t.number().int().positive().safe(),z=t.enum(["bad_request","unavailable","reservation","leak_refused","cancelled"]);function st(e){let n=z.safeParse(e);return n.success?n.data:"unavailable"}function it(e){return Object.assign(new Error(e),{code:e})}var Ne=1024*1024,ue=u.min(1).max(128),Y=u.regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/),q=u.regex(/^[a-f0-9]{64}$/),_={protocol:t.literal(b),analysisId:t.uuid(),nonce:u.min(16).max(256),bundleVersion:ue,engineVersion:ue};function l(e){return t.unknown().refine(n=>{try{let s=JSON.stringify(n);return typeof s=="string"&&new TextEncoder().encode(s).byteLength<=Ne}catch{return!1}}).pipe(e)}var he=u.min(1).refine(e=>!/[\\\0\r\n]/.test(e)&&!/^(?:\/|[a-zA-Z]:)/.test(e)&&e.split("/").every(n=>n!==""&&n!=="."&&n!=="..")),Pe=t.strictObject({id:Y,path:he,size:d,hash:q}),J=t.array(Pe).refine(e=>new Set(e.map(n=>n.id)).size===e.length&&new Set(e.map(n=>n.path)).size===e.length),ee=t.strictObject({snapshot:q,commit:u.regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),files:J,entriesVisited:d.optional(),truncated:t.boolean().optional(),complete:t.boolean(),cursor:u.min(1).max(256).optional()}).refine(e=>e.complete?e.cursor===void 0:e.cursor!==void 0),rt=l(t.strictObject({..._,settings:Ee,manifest:ee})),ot=t.strictObject(_),je=t.strictObject({startByte:d,endByte:d}).refine(e=>e.endByte>e.startByte),De=t.strictObject({startLine:y,endLine:y}).refine(e=>e.endLine>=e.startLine),me=l(t.strictObject({..._,type:t.literal("need_files"),sequence:d,reads:t.array(t.strictObject({id:Y,range:t.union([je,De])})).min(1)})),Fe=l(t.strictObject({..._,type:t.literal("need_listing"),sequence:d,cursor:u.min(1).max(256).nullable()})),ge=l(t.discriminatedUnion("type",[t.strictObject({..._,type:t.literal("files"),sequence:d,files:t.array(t.union([t.strictObject({id:Y,startByte:d,text:u,complete:t.boolean(),hash:q}),t.strictObject({id:Y,refused:K})])).min(1)}),t.strictObject({..._,type:t.literal("listing"),sequence:d,manifest:ee}),t.strictObject({..._,type:t.literal("reservation"),sequence:d,reservationId:t.uuid(),reservationToken:u.min(1).max(256)}),t.strictObject({..._,type:t.literal("delivery"),sequence:d,callId:t.uuid(),attemptId:t.uuid().nullable()}),t.strictObject({..._,type:t.literal("chunk"),sequence:d,callId:t.uuid(),attemptId:t.uuid(),chunk:y})])),w={chunk:d,chunks:y},xe=t.strictObject({..._,type:t.literal("result"),finalFiles:J,findings:t.array(T),structures:t.array(v),notices:t.array(u)}),Me=l(xe.extend(w).refine(e=>e.chunk<e.chunks)),Ge=l(t.strictObject({..._,type:t.literal("result_chunk"),...w,text:u,hash:q}).refine(e=>e.chunk<e.chunks)),fe=l(t.strictObject({..._,type:t.literal("call_failed"),sequence:d,callId:t.uuid(),attemptId:t.uuid().nullable(),code:z}));function ke(e){let n=l(t.strictObject({..._,type:t.literal("plan"),sequence:d,...w,plan:e.plan,finalFiles:J}).refine(a=>a.chunk<a.chunks)),s=u.regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).min(1).refine(a=>!/\s/.test(a)),o=l(t.strictObject({..._,type:t.literal("sealed_delivery"),sequence:d,callId:t.uuid(),attemptId:t.uuid(),algorithm:t.literal("AES-256-GCM"),iv:s.length(16),...w,ciphertext:s,tag:u.regex(/^[A-Za-z0-9+/]{21}[AQgw]==$/).length(24).optional(),delivery:t.strictObject({confirmation:e.deliveryConfirmation,deadlineMs:y}).optional()}).refine(a=>a.chunk<a.chunks&&(a.chunk===a.chunks-1?a.tag!==void 0&&a.delivery!==void 0&&a.delivery.confirmation.callId===a.callId&&a.delivery.confirmation.attemptId===a.attemptId:a.tag===void 0&&a.delivery===void 0))),c=t.strictObject({..._,type:t.literal("refused"),code:z});return{plan:n,sealedDelivery:o,response:t.union([me,Fe,n,o,fe,Me,Ge,c])}}var at=t.strictObject({version:t.literal(1),serializedBytes:y,freeTextUtf8Bytes:y,fields:t.array(t.strictObject({pointer:u.regex(/^(?:\/(?:[^~/]|~[01])*)+$/),kind:t.enum(["string","array"]),max:y}))});function ct(e){let n={..._,protocol:t.literal(H)},s=e.context,o=l(t.strictObject({...n,settings:Ee,context:s.preparationContext,manifest:ee})),c=t.strictObject(n),a=l(t.union([...ge.out.options.map(V=>V.extend(n)),t.strictObject({...n,type:t.literal("next"),sequence:d,stream:t.enum(["plan","result"]),chunk:y})])),C=t.strictObject({kind:t.literal("ready"),plan:e.plan,finalFiles:s.finalFiles,analysisSize:s.analysisSize,membership:s.membership}),p=t.strictObject({kind:t.literal("agent_choice"),choice:e.choice}),E=t.strictObject({kind:t.literal("proposal_refused")}),m=t.union([C,p,E]),O=t.strictObject({finalFiles:s.finalFiles,report:e.report,membership:s.membership}),F=O.extend({...n,type:t.literal("result")}),f=l(t.strictObject({...n,type:t.literal("plan"),sequence:d,plan:e.plan,finalFiles:s.finalFiles,analysisSize:s.analysisSize,membership:s.membership})),I=e.planChunks,A=e.resultChunks,j=l(I.chunk.safeExtend({...n,type:t.literal("plan_chunk"),sequence:d,stream:t.literal("plan")})),D=l(A.chunk.safeExtend({...n,type:t.literal("result_chunk"),sequence:d,stream:t.literal("result")})),g=ke(e),x=l(t.strictObject({...g.sealedDelivery.out.shape,...n}).refine(V=>g.sealedDelivery.safeParse({...V,protocol:b}).success)),M=l(me.out.extend(n)),G=l(Fe.out.extend(n)),L=l(fe.out.extend(n)),N=t.strictObject({...n,type:t.literal("refused"),code:z}),k=t.strictObject({...n,type:t.literal("cancelled")}),B=l(t.union([M,G,f,x,L,l(F),j,D,N,k,t.strictObject({...n,type:t.literal("agent_choice"),choice:e.choice}),t.strictObject({...n,type:t.literal("proposal_refused")})])),Ie=t.union([O.extend({kind:t.literal("result")}),p,E]),Se=pe();return{start:o,cancel:c,advance:a,needFiles:M,needListing:G,ready:C,preparationOutcome:m,resultBody:O,finalResult:F,plan:f,planChunk:j,resultChunk:D,sealedDelivery:x,callFailure:L,refused:N,cancelled:k,response:B,clientOutcome:Ie,capabilities:Se}}export{v as a,Te as b,le as c,Ae as d,Le as e,b as f,W as g,H as h,Ce as i,et as j,tt as k,Ee as l,z as m,st as n,it as o,Ne as p,Pe as q,ee as r,rt as s,ot as t,me as u,Fe as v,ge as w,xe as x,Me as y,Ge as z,fe as A,ke as B,at as C,ct as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pa as t,ra as o,va as a,xa as p}from"./
|
|
1
|
+
import{pa as t,ra as o,va as a,xa as p}from"./QPIBHTON.js";function m(e,l,n={}){let r=t(e,l,n.structureState);return[...r.calls,...o(e,r.findings),...p(e,l,n),...a(e)]}function C(e,l){let n=Object.entries(l.files).map(([f,i])=>({path:f,size:Buffer.byteLength(i)})),r=m(e,n,{structureState:{repos:[{key:l.repoKey,kind:"fs",files:l.files,...l.root===void 0?{}:{root:l.root}}],mapped:[l.fragment]}});return{files:n,calls:r}}export{m as a,C as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as B}from"./
|
|
1
|
+
import{h as B}from"./VC3PYT2B.js";import{C as z}from"./P253B344.js";import{b as _,d as E}from"./W73WF226.js";import{a as A}from"./M5YWJY7P.js";import{Fb as b}from"./2M55DR2J.js";import{a as d}from"./MKYLK6DB.js";var L=t=>typeof t=="string"&&t.length>0&&!/[\\\0\r\n]/.test(t)&&!/^(?:\/|[a-zA-Z]:)/.test(t)&&t.split("/").every(n=>n!==""&&n!=="."&&n!=="..");function q(t){if(!B(t)||t.CF_PART_FILES===void 0)return;let n;try{n=JSON.parse(t.CF_PART_FILES)}catch{throw new Error("bad_request")}if(!Array.isArray(n)||!n.every(L))throw new Error("bad_request");return[...new Set(n)]}function S(t,n){let r=0,i=0,o=0;for(let c of t){let a=n.get(c);a.pool==="instruction"?r+=a.size:(i+=a.size,o++)}return{instruction:r,code:i,count:o}}function M(t,n,r){let{instruction:i,code:o,count:c}=S(t,n);return i<=d.sourceFetch.instructionBytes&&o<=d.sourceFetch.codeBytes&&c<=d.sourceFetch.codeFiles&&i+o<=d.codeAgent.importBytes&&E([...t].map(a=>({path:a,...n.get(a)})),r)!==void 0}var F=(t,n)=>new Set([...t,...n]);function N(t,n){let r=[];for(let i of t){let o=r.find(c=>M(F(c.files,i.files),n));o?(o.roots.push(i),o.files=F(o.files,i.files)):r.push({roots:[i],files:i.files})}return r}function P(t,n,r){let i=[...t].map(o=>[r.get(o).size,r.get(o).inputBytes??0]);return i.sort((o,c)=>o[0]-c[0]||o[1]-c[1]),JSON.stringify([S(t,r),i,[...t].filter(o=>n.has(o)).sort()])}function v(t,n,r,i){let o=[],c=new Set,a=t.map((f,e)=>new Set(t.slice(e).flatMap(s=>[...s.files]))),h=f=>{if(i.remaining--<=0)return!1;if(f===t.length)return!0;let e=l=>P(l,a[f],n),s=JSON.stringify([f,o.map(l=>e(l.files)).sort()]);if(c.has(s))return!1;let u=t[f],w=new Set;for(let l=0;l<=o.length&&l<r;l++){if(i.remaining<=0)return!1;let g=o[l],m=e(g?.files??new Set);if(w.has(m))continue;w.add(m);let p=g?F(g.files,u.files):u.files;if(M(p,n,i)){if(o[l]={roots:[...g?.roots??[],u],files:p},h(f+1))return!0;g?o[l]=g:o.pop()}}return c.add(s),!1};return h(0)?o:void 0}function I(t,n){if(!t.length)return[];let r=[...t].sort((e,s)=>s.weight-e.weight),i=N(r,n),o=S(new Set(t.flatMap(e=>[...e.files])),n),c=Math.max(1,Math.ceil(o.instruction/d.sourceFetch.instructionBytes),Math.ceil(o.code/d.sourceFetch.codeBytes),Math.ceil(o.count/d.sourceFetch.codeFiles)),a=_(),h=i;for(let e=c;e<i.length&&a.remaining>0;e++){let s=v(r,n,e,a);if(s){h=s;break}}let f=new Map(t.map((e,s)=>[e.path,s]));return h.map(e=>({paths:e.roots.map(s=>s.path).sort((s,u)=>f.get(s)-f.get(u)),files:[...e.files]})).sort((e,s)=>f.get(e.paths[0])-f.get(s.paths[0]))}function D(t,n){let r=new Map(n.entries.map(e=>[e.path,e])),{descriptions:i}=z(t,n.entries,{},{measureAnalysisSize:!0}),o=new Map(i.map(e=>[e.entry.path,e.analysisPool??e.pool])),c=new Map,a=new Map;for(let e of r.values()){if(!L(e.path)||!Number.isSafeInteger(e.size)||e.size<0){a.set(e.path,"unavailable");continue}let s=b(t,e,{purpose:"proposal",route:"local-folder"});if(!s.admitted){a.set(e.path,s.reason==="too-large"?"tooLarge":"unavailable");continue}let u=n.inputBytes?.[e.path];if(u!==void 0&&(!Number.isSafeInteger(u)||u<0)){a.set(e.path,"unavailable");continue}if(u!==void 0&&u>=8e5){a.set(e.path,"tooLarge");continue}c.set(e.path,{size:e.size,inputBytes:u,pool:o.get(e.path)??"code"})}let h={groups:[],tooLarge:[],unavailable:[]},f=[];for(let e of new Set(n.paths)){let s=new Set,u=[e],w=new Set,l=new Set,g;for(;u.length;){let p=u.pop();if(w.has(p))continue;w.add(p);let y=a.get(p)??(c.has(p)?void 0:"unavailable");if(y&&p!==e){l.add(p);continue}if(y){g=y;continue}s.add(p),n.dependencies&&Object.hasOwn(n.dependencies,p)&&u.push(...n.dependencies[p])}if(g){h[g].push(e);continue}if(l.size&&(h.missingContext??=[]).push({path:e,imports:[...l].sort()}),!M(s,c)){h.tooLarge.push(e);continue}let m=S(s,c);f.push({path:e,files:s,weight:Math.max(m.instruction/d.sourceFetch.instructionBytes,m.code/d.sourceFetch.codeBytes,m.count/d.sourceFetch.codeFiles)})}return h.groups=I(f,c),h}export{q as a,D as b};
|
|
@@ -1 +1 @@
|
|
|
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"./
|
|
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"./KBTM5MBC.js";import{d as s}from"./3MTXB4MK.js";import{a as S}from"./N2L4JMJE.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};
|
|
@@ -1 +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
|
+
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"./QPIBHTON.js";import{a as Ye}from"./5VQ4VYIP.js";import{i as $e}from"./6JTHFDH3.js";import{a as J}from"./QDYMR6KS.js";import{a as We}from"./XVGLY4EO.js";import{g as _}from"./6VHZNBII.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"./LFJQ4YLP.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"./DHVEGIU6.js";import{a as je,b as re}from"./5UWDUYHF.js";import{e as ke,g as Se}from"./VC3PYT2B.js";import{n as $}from"./P253B344.js";import{c as Ie}from"./W73WF226.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"./2M55DR2J.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{c as b,d as l}from"./
|
|
1
|
+
import{c as b,d as l}from"./VX6LYNXV.js";import{a as u,b as o,c as g}from"./QVXARKP7.js";import{a as r}from"./JAPVLU4Z.js";import{z as _}from"zod";import{z as c}from"zod";function h(a=r){return c.object({rows:c.array(c.object({key:c.string().describe(a("finding-headlines-key")),headline:c.string().nullable().describe(a("finding-headlines-headline")),ifLeft:c.string().nullable().describe(a("finding-headlines-if-left"))}).strict())}).strict()}var A=h();import{z as n}from"zod";var p=n.object({verdicts:n.array(n.object({id:n.string(),inScope:n.boolean(),reason:n.string()}))});import{z as e}from"zod";var z=3,F=64e3,C=8,H=60,E=e.object({subKind:e.string().describe(r("analysis-structure-schema-1")),kind:e.string().describe(r("analysis-structure-schema-2")),severity:e.string().describe(r("analysis-structure-schema-3")),title:e.string(),cause:e.string(),evidence:e.array(e.object({path:e.string(),line:e.number(),excerpt:e.string()})),children:e.array(e.object({ref:e.string().describe(r("analysis-structure-schema-4")),how:e.string()})),files:e.array(e.object({path:e.string(),action:e.string().describe(r("analysis-structure-schema-5")),role:e.string().describe(r("analysis-structure-schema-6")),unit:e.string().describe(r("analysis-structure-schema-7")),loadMode:e.string().describe(r("analysis-structure-schema-8")),loadVia:e.string().describe(r("analysis-structure-schema-9")),purpose:e.string(),fmName:e.string().describe(r("analysis-structure-schema-10")),fmDescription:e.string(),fmTools:e.array(e.string())})),segments:e.array(e.object({path:e.string(),startLine:e.number(),endLine:e.number(),to:e.string().describe(r("analysis-structure-schema-11")),disposition:e.string().describe(r("analysis-structure-schema-12")),intoPath:e.string().describe(r("analysis-structure-schema-13")),intoLine:e.number().describe(r("analysis-structure-schema-14")),childRef:e.string().describe(r("analysis-structure-schema-15")),heading:e.string().describe(r("analysis-structure-schema-16")),reason:e.string()})),additions:e.array(e.object({path:e.string(),text:e.string(),kind:e.string().describe(r("analysis-structure-schema-17")),heading:e.string()})),reorders:e.array(e.object({path:e.string(),startLine:e.number(),endLine:e.number(),order:e.array(e.number()).describe(r("analysis-structure-schema-reorder-order")),reasons:e.array(e.string()).describe(r("analysis-structure-schema-reorder-reasons"))})).describe(r("analysis-structure-schema-18")),toolMoves:e.array(e.object({tool:e.string(),fromUnit:e.string(),toUnit:e.string(),reason:e.string()}))}),y=e.object({structures:e.array(E)}),f=e.object({verdict:e.string().describe(r("structure-recheck-verdict")),reason:e.string()}),S=e.object({verdicts:e.array(e.object({index:e.number(),inScope:e.boolean(),reason:e.string()}))});import{z as t}from"zod";var j=t.object({verdicts:t.array(o.shape.verdicts.element.extend({decisive:t.boolean(),quotes:t.array(t.object({side:t.enum(["against","for"]),repo:t.string(),path:t.string(),line:t.number().int().positive(),quote:t.string()}))}))});import{z as s}from"zod";var q=4,K=1,J=16e3,k=s.object({path:s.string(),startLine:s.number(),endLine:s.number()}),x=s.object({decision:s.string().describe(r("analysis-split-check-schema-1")),reason:s.string(),frontDoor:s.object({job:s.string().describe(r("analysis-split-check-schema-2")),skills:s.array(s.string()).describe(r("analysis-split-check-schema-3"))}),subAgents:s.array(s.object({name:s.string().describe(r("analysis-split-check-schema-4")),job:s.string().describe(r("analysis-split-check-schema-5")),description:s.string().describe(r("analysis-split-check-schema-6")),skills:s.array(s.string()),tools:s.array(s.string()).describe(r("analysis-split-check-schema-7")),promptSections:s.array(k),knowledgeSections:s.array(k).describe(r("analysis-split-check-schema-8")),resolves:s.array(s.string()).describe(r("analysis-split-check-schema-9")),evidence:s.array(s.object({path:s.string(),line:s.number(),excerpt:s.string()})),handoff:s.string().describe(r("analysis-split-check-schema-10"))}))});function ie(a=m=>m,T){let m={codeJudge:u,findings:l({}),scope:p,structures:y,structureScope:S,check:o,opinion:j,sourceNotes:g,shape:x,recheck:f,findingHeadlines:h(i=>T?.(i)??r(i)),judge:_.object({row:_.string().min(1).nullable()}).strict()},U=b().map(({name:i,schema:d})=>[i,d]);return Object.fromEntries([...Object.entries(m),...U].map(([i,d])=>[i,a(d)]))}export{A as a,z as b,F as c,C as d,H as e,j as f,q as g,K as h,J as i,ie as j};
|
|
@@ -1,4 +1,4 @@
|
|
|
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(`
|
|
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"./LFJQ4YLP.js";import{b as st}from"./2CWULBP2.js";import{e as te,g as Ce}from"./VC3PYT2B.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"./P253B344.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"./2M55DR2J.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
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
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
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(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as T,K as A,y as F,z as L}from"./
|
|
1
|
+
import{C as T,K as A,y as F,z as L}from"./LFJQ4YLP.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"./VC3PYT2B.js";import{Fb as x}from"./2M55DR2J.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 @@
|
|
|
1
|
+
import{a as h}from"./I4F56VMG.js";import{b as g,f as y,g as b}from"./33EUZF25.js";import{z as e}from"zod";var t=e.string(),n=t.nullable(),m=e.number().int().positive().safe(),T=e.enum(["ordering","reliability","coverage","cost","safety","correctness"]),B=e.enum(["low","medium","high","critical"]),q={headline:t.optional(),ifLeft:t.optional()},R=e.strictObject({nodes:e.array(e.strictObject({id:t,change:t,label:n})),edges:e.array(e.strictObject({from:t,to:t,kind:t,change:t,detail:n}))}),j=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:m,excerpt:t,meaning:t}))}),x=e.strictObject({kind:T,severity:B,title:t,cause:t,summary:n,category:n,question:n,audience:g.optional(),activity:h.optional(),siteRepo:n,site:e.strictObject({path:t,line:m.nullable()}).nullable(),excerpt:n,otherSites:e.array(e.strictObject({repo:t,path:t,line:m,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:n,impact:n,confidence:n,objective:n,status:n,blockedBy:n,alsoFixes:e.array(t).nullable(),delta:R.nullable()})),sourceNotes:j.nullable().optional(),...q}),a=Object.freeze({findings:2e4,textBytes:4096,quoteBytes:2e3,freeTextBytesPerFinding:16*1024}),A=a.freeTextBytesPerFinding*a.findings;function O(i){return typeof i=="string"?!i.includes("\0")&&!/[\uD800-\uDFFF]/u.test(i):i===null||typeof i!="object"||Object.values(i).every(O)}function k(i,c){return new TextEncoder().encode(i).byteLength<=(c?a.quoteBytes:a.textBytes)}var _=new Set(["excerpt","keyPhrase"]);function E(i){return _.has(String(i.at(-1)))}function S(i,c=[]){return typeof i=="string"?k(i,E(c)&&c[0]!=="activity"):i===null||typeof i!="object"||Object.entries(i).every(([p,l])=>S(l,[...c,p]))}var r=x.shape,F=t.min(1).refine(i=>i.trim().length>0),w=y.extend({nodes:e.array(y.shape.nodes.element.strict()),edges:e.array(y.shape.edges.element.strict())}).strict(),d=r.fixes.element.shape,C=e.strictObject({title:d.title.min(1),approach:d.approach.min(1),kind:d.kind,targetFiles:e.array(d.targetFiles.element.extend({path:t.min(1)})),...b.shape,delta:w.nullable(),expectedOutcome:d.expectedOutcome}),N=e.strictObject({...x.pick({kind:!0,severity:!0}).shape,title:r.title.min(1),cause:r.cause.min(1),summary:r.summary,site:r.site.unwrap().extend({path:t.min(1)}).nullable(),excerpt:r.excerpt,category:r.category,otherSites:e.array(e.strictObject({path:t.min(1),line:m,excerpt:t.trim().min(1),repo:F})),question:r.question,fixes:e.array(C).min(1),activity:r.activity,audience:r.audience,siteRepo:F.nullable(),sourceNotes:j.nullable().optional()}).refine(i=>S(i)),I=x.superRefine((i,c)=>{let p=0;function l(s,u){if(typeof s=="string"){let o=E(u);o||(p+=new TextEncoder().encode(s).byteLength),(!k(s,o)||!O(s))&&c.addIssue({code:"custom",path:u,message:"Invalid result text"})}else Array.isArray(s)?s.forEach((o,f)=>l(o,[...u,f])):s!==null&&typeof s=="object"&&Object.entries(s).forEach(([o,f])=>l(f,[...u,o]))}l(i,[]),p>a.freeTextBytesPerFinding&&c.addIssue({code:"custom",message:"Result text exceeds the finding budget"})}),K=e.array(I).max(a.findings);export{T as a,B as b,q as c,R as d,x as e,a as f,A as g,O as h,F as i,N as j,I as k,K as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./
|
|
1
|
+
import{a as c}from"./2CWULBP2.js";import{e as w}from"./2M55DR2J.js";import{posix as d}from"node:path";function _({codeAgents:t,conventions:e}){return[...new Set([...t.map(r=>r.prompt.path),...e.agents.flatMap(r=>[...c(r)?[r.prompt.path]:[],...r.subagents.map(s=>s.path)])])]}function S(t,e={}){return(t.CF_CHOOSE_AGENT??e.CF_CHOOSE_AGENT)!=="0"}function b(t,{codeAgents:e,conventions:r,root:s,selection:u}){if(u?.kind==="file"||w(t)||!S(t))return;let l=new Set(e.map(n=>n.prompt.path)),i=new Map(r.agentScopes?.map(n=>[n.key,n.folder])),o=A(e).map(({folder:n,reason:p})=>({folder:n,reason:p}));if(o.push(...r.agents.flatMap(n=>c(n)?(n.definitionPaths??[]).filter(p=>n.key===null||!l.has(p)).map(p=>({folder:P(n,p,i,s),reason:p})):[])),o.some(n=>o.every(p=>y(n.folder,p.folder))))return;let f=o.filter((n,p)=>!o.some((m,h)=>h!==p&&y(m.folder,n.folder)&&(m.folder!==n.folder||h<p)));return{kind:f.length?"choose_agent":"no_agent",candidates:f}}function y(t,e){return t==="."||e===t||e.startsWith(`${t}/`)}function k(t){let e=d.dirname(t[0]);for(let r of t.slice(1))for(;e!=="."&&r!==e&&!r.startsWith(`${e}/`);)e=d.dirname(e);return e}function A(t){let e=t.map(()=>new Set),r=new Map(t.map((i,o)=>[i.unitKey,o])),s=new Map,u=(i,o)=>{o!==void 0&&(e[i].add(o),e[o].add(i))};t.forEach((i,o)=>{u(o,s.get(i.prompt.path)),s.set(i.prompt.path,o);for(let a of i.links??[])u(o,r.get(a.to))});let l=new Set;return t.flatMap((i,o)=>{if(l.has(o))return[];let a=[o],f=[];for(;a.length;){let n=a.pop();l.has(n)||(l.add(n),f.push(t[n].prompt.path,...t[n].ownFiles.map(p=>p.path)),a.push(...e[n]))}return[{folder:k(f),reason:i.prompt.path,files:[...new Set(f)]}]})}function P(t,e,r,s){return t.key!==null?r.get(t.key)||d.dirname(e):(r.get(null)??s)||"."}export{_ as a,b,k as c,A as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as t}from"zod";var i=t.strictObject({state:t.enum(["active","dead","switched_off"]),gate:t.string().nullable(),reason:t.string(),evidence:t.array(t.strictObject({path:t.string(),line:t.number(),excerpt:t.string()}))});export{i as a};
|