@counterfact-labs/cli 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/bundle/client-release.json +1 -1
- package/dist/adapters/analysis-results.js +10 -5
- package/dist/adapters/completion.js +75 -41
- package/dist/adapters/config-directory.js +5 -0
- package/dist/adapters/files.js +25 -10
- package/dist/adapters/legacy-reports.js +48 -0
- package/dist/adapters/output-paths.js +85 -5
- package/dist/adapters/relay-plan.js +7 -5
- package/dist/adapters/result-receipt.js +78 -0
- package/dist/adapters/results.js +5 -8
- package/dist/adapters/settings.js +10 -4
- package/dist/adapters/storage-identity.js +27 -0
- package/dist/analysis-core/analysis/code-agents/skipped-files.js +1 -1
- package/dist/analysis-core/analysis/file-analysis-plan.js +1 -1
- package/dist/analysis-core/analysis/file-dependencies.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/{5B5UCWD3.js → 2IQN26TC.js} +1 -1
- package/dist/analysis-core/chunks/{MZOKZ3N6.js → 2J3PWUPG.js} +1 -1
- package/dist/analysis-core/chunks/33EUZF25.js +1 -0
- package/dist/analysis-core/chunks/{3GUKUEEJ.js → 5JG3ZRNJ.js} +1 -1
- package/dist/analysis-core/chunks/{FRXOQ2M6.js → 6E4K7JTI.js} +1 -1
- package/dist/analysis-core/chunks/{4RXRAB5S.js → 6JTHFDH3.js} +1 -1
- package/dist/analysis-core/chunks/{4UDQBDDE.js → 6W6B7VSP.js} +1 -1
- package/dist/analysis-core/chunks/{4PT5C4IT.js → AIS3FHQR.js} +7 -7
- package/dist/analysis-core/chunks/CNQZLSAP.js +1 -0
- package/dist/analysis-core/chunks/{YWL52FVW.js → EJ2IZUN2.js} +2 -2
- package/dist/analysis-core/chunks/{LOBIDUCA.js → GOBOE2SC.js} +1 -1
- package/dist/analysis-core/chunks/GYXDN5W4.js +1 -0
- package/dist/analysis-core/chunks/GZSUTDGX.js +1 -0
- package/dist/analysis-core/chunks/HB5BTGTI.js +6 -0
- package/dist/analysis-core/chunks/HH3HDT5K.js +73 -0
- package/dist/analysis-core/chunks/I4F56VMG.js +1 -0
- package/dist/analysis-core/chunks/{RQTNTIR4.js → I5F7S63K.js} +1 -1
- package/dist/analysis-core/chunks/ICJV6KIZ.js +11 -0
- package/dist/analysis-core/chunks/JAPVLU4Z.js +1 -0
- package/dist/analysis-core/chunks/{33IGHOYT.js → JCVB6IC4.js} +1 -1
- package/dist/analysis-core/chunks/{33HRXJ5Q.js → JLW44GIU.js} +1 -1
- package/dist/analysis-core/chunks/JS6HTVYX.js +1 -0
- package/dist/analysis-core/chunks/{JGK37AWN.js → JWQXG5RB.js} +1 -1
- package/dist/analysis-core/chunks/LOODGUMW.js +1 -0
- package/dist/analysis-core/chunks/{HVQJKPQ4.js → NWYNJHY4.js} +1 -1
- package/dist/analysis-core/chunks/{HHFDNY6V.js → OHDC3L6V.js} +1 -1
- package/dist/analysis-core/chunks/OXGKALKM.js +1 -0
- package/dist/analysis-core/chunks/{MJGB25S5.js → P5FCHJ7W.js} +1 -1
- package/dist/analysis-core/chunks/PISOGSJF.js +1 -0
- package/dist/analysis-core/chunks/{CTLHKFPH.js → QENYFKG3.js} +8 -8
- package/dist/analysis-core/chunks/{2YREYGOG.js → QY57UR6E.js} +1 -1
- package/dist/analysis-core/chunks/QYYN4YKB.js +35 -0
- package/dist/analysis-core/chunks/UYG422QR.js +0 -0
- package/dist/analysis-core/chunks/V7GZHSVR.js +1 -0
- package/dist/analysis-core/chunks/{JEWBPIQI.js → VBGQKYIT.js} +1 -1
- package/dist/analysis-core/chunks/{S27Y2TP5.js → VVSHUUWX.js} +1 -1
- package/dist/analysis-core/chunks/VX6LYNXV.js +1 -0
- package/dist/analysis-core/chunks/{JKWTHRUR.js → YDSB7UOR.js} +1 -1
- package/dist/analysis-core/chunks/ZLUI3EHB.js +1 -0
- 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/model-errors.js +1 -0
- package/dist/analysis-core/contracts/relay-analysis.js +1 -1
- package/dist/analysis-core/contracts/requests.js +1 -1
- package/dist/analysis-core/conventions/analysis-fit.js +1 -1
- package/dist/analysis-core/conventions/file-admission.js +1 -1
- package/dist/analysis-core/errors.js +1 -1
- package/dist/analysis-core/import/calls/modules.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/llm/cache-policy.js +1 -1
- package/dist/analysis-core/llm/cost.js +1 -1
- package/dist/analysis-core/llm/structured-output-error.js +1 -1
- package/dist/analysis-core/requests/answer-formats.js +1 -1
- package/dist/analysis-core/requests/frame-budget.js +1 -0
- package/dist/analysis-core/requests/local-plan.js +1 -1
- package/dist/analysis-core/requests/planned-limits.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/analysis-core/wording.js +1 -0
- package/dist/cli/analysis-preview.js +22 -0
- package/dist/cli/analysis-selection.js +6 -8
- package/dist/cli/commands/analyze.js +29 -26
- package/dist/cli/commands/login.js +5 -0
- package/dist/cli/compatibility.js +39 -0
- package/dist/cli/completion-delivery.js +4 -3
- package/dist/cli/completion-recovery.js +25 -23
- package/dist/cli/credentials.js +3 -2
- package/dist/cli/finding-display.js +3 -2
- package/dist/cli/git.js +5 -2
- package/dist/cli/intake-payload.js +1 -2
- package/dist/cli/main.js +8 -2
- package/dist/cli/mcp.js +35 -10
- package/dist/cli/prior-completion.js +1 -1
- package/dist/cli/relay-check.js +88 -30
- package/dist/cli/relay-failure.js +19 -11
- package/dist/cli/relay-preparation.js +9 -6
- package/dist/cli/scope-choices.js +5 -4
- package/dist/cli/skipped-files.js +2 -1
- package/dist/cli/suggested-email.js +6 -1
- package/dist/cli/summary.js +2 -1
- package/dist/contract/agent-choice.js +2 -0
- package/dist/contract/cli-refusals.js +105 -9
- package/dist/contract/cli-version.js +1 -1
- package/dist/contract/console.js +2 -1
- package/dist/contract/email-sign-in-messages.js +2 -1
- package/dist/contract/scope-choice.js +4 -1
- package/dist/gatekeeper/client.js +11 -2
- package/dist/gatekeeper/connection-exchange.js +19 -4
- package/dist/gatekeeper/connection.js +15 -6
- package/dist/gatekeeper/console.js +10 -17
- package/dist/gatekeeper/model.js +13 -3
- package/package.json +1 -1
- package/dist/adapters/gitignore-output.js +0 -41
- package/dist/adapters/source-relay-plan.js +0 -7
- package/dist/analysis-core/chunks/2AASSZRO.js +0 -35
- package/dist/analysis-core/chunks/CQQ4TTXE.js +0 -1
- package/dist/analysis-core/chunks/F54DOWKN.js +0 -6
- package/dist/analysis-core/chunks/HCPO6QPU.js +0 -1
- package/dist/analysis-core/chunks/J4AXGE5W.js +0 -1
- package/dist/analysis-core/chunks/LFYTD7JF.js +0 -1
- package/dist/analysis-core/chunks/LMUXOKIM.js +0 -1
- package/dist/analysis-core/chunks/M5YWJY7P.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
- package/dist/analysis-core/chunks/SJESFYBA.js +0 -10
- package/dist/analysis-core/chunks/W24SFYZM.js +0 -67
- package/dist/analysis-core/chunks/YTHF2E2S.js +0 -1
|
@@ -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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as e}from"./OXGKALKM.js";import{z as t}from"zod";var o=t.lazy(()=>t.union([t.string(),t.number(),t.boolean(),t.null(),t.array(o),t.record(t.string(),o)])),n=t.object({data:t.record(t.string(),o),settings:e,maxInputBytes:t.number().int().positive().optional()}).strict(),i=t.string().min(1).max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/),r=t.object({maxTokens:t.number().int().positive().optional(),effort:t.enum(["low","medium","high","max"]).optional(),thinking:t.literal("disabled").optional(),promptCache:t.boolean().optional()}).strict(),m=t.object({template:t.string().min(1),inputs:n,answerFormat:t.string().min(1),model:i,limits:r.optional()}).strict();export{n as a,i as b,r as c,m as d};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as F}from"./RUVMFAST.js";import{a as lt}from"./S27VIQMZ.js";import{posix as J}from"node:path";var R=class{text;tokens=[];lineStarts=[0];constructor(n){this.text=n;for(let t=0;t<n.length;t++)n.charCodeAt(t)===10&&this.lineStarts.push(t+1)}push(n,t,s,r,i=!1){this.tokens.push({kind:n,text:this.text.slice(t,s),value:r??this.text.slice(t,s),start:t,end:s,line:this.lineAt(t),endLine:this.lineAt(s-1),...i?{formatted:!0}:{}})}lineAt(n){let t=0,s=this.lineStarts.length-1;for(;t<s;){let r=t+s+1>>1;this.lineStarts[r]<=n?t=r:s=r-1}return t+1}},Ct=/[\p{L}_$]/u,Rt=/[\p{L}\p{N}_$]/u;function N(e){return Ct.test(e)}function at(e){return Rt.test(e)}function W(e){return e>="0"&&e<="9"}function P(e){return e===" "||e===" "||e===`
|
|
2
|
+
`||e==="\r"||e==="\f"||e==="\v"}function T(e,n){return e[n+1]==="\r"&&e[n+2]===`
|
|
3
|
+
`?3:2}function z(e,n){let t=n+1;for(;t<e.length&&at(e[t]);)t++;return t}function B(e,n){let t=n+1;for(;t<e.length&&(at(e[t])||e[t]===".");)t++;return t}function D(e,n){for(;n<e.length&&e[n]!==`
|
|
4
|
+
`&&e[n]!=="\r";)n++;return n}var ct={n:`
|
|
5
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",v:"\v"},ft=/^[0-9a-fA-F]+$/;function Tt(e,n,t){let s=e[n+1];if(s==="\r"&&e[n+2]===`
|
|
6
|
+
`)return["",n+3];if(s===`
|
|
7
|
+
`||s==="\r")return["",n+2];if(s in ct)return[ct[s],n+2];let r=s==="x"?2:s==="u"?4:s==="U"&&t==="py"?8:0;if(r){let i=e.slice(n+2,n+2+r);if(i.length===r&&ft.test(i)){let l=parseInt(i,16);if(l<=1114111)return[String.fromCodePoint(l),n+2+r]}}if(s==="u"&&t==="js"&&e[n+2]==="{"){let i=e.indexOf("}",n+3),l=i===-1?"":e.slice(n+3,i);if(ft.test(l)&&parseInt(l,16)<=1114111)return[String.fromCodePoint(parseInt(l,16)),i+1]}if(t==="py"){if(s==="a")return["\x07",n+2];if(s>="0"&&s<="7"){let i=n+1;for(;i<n+4&&e[i]>="0"&&e[i]<="7";)i++;return[String.fromCharCode(parseInt(e.slice(n+1,i),8)),i]}if(s==="N"&&e[n+2]==="{"){let i=e.indexOf("}",n+3);if(i!==-1)return[e.slice(n,i+1),i+1]}}return t==="js"&&s==="0"?["\0",n+2]:[s,n+2]}function L(e,n){let t="",s=0;for(;s<e.length;){if(e[s]!=="\\"||s+1>=e.length){t+=e[s++];continue}let[r,i]=Tt(e,s,n);t+=r,s=i}return t}var Lt=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function ut(e,n){let t=e[n],s=n+1;for(;s<e.length;){let r=e[s];if(r==="\\")s+=T(e,s);else{if(r===t)return s+1;if(r===`
|
|
8
|
+
`||r==="\r")return s;s++}}return e.length}function Ut(e,n,t=!1){let s=["t"],r=[],i=-1,l,f,c=(a,u,d)=>{f=l,l={kind:a,text:e.slice(u,d),start:u,end:d}},o=n+1;for(;o<e.length;){let a=s[s.length-1],u=e[o];if(a==="t")if(u==="\\")o+=T(e,o);else if(u==="`"){if(t&&c("template",o,o+1),o++,s.pop(),s.length===0)return{end:o,closed:!0,interpolations:r}}else u==="$"&&e[o+1]==="{"?(l=f=void 0,s.length===1&&(i=o),s.push(1),o+=2):o++;else if(u==="'"||u==='"'){let d=ut(e,o);t&&c("string",o,d),o=d}else if(u==="`")s.push("t"),o++;else if(u==="/"&&e[o+1]==="/")o=D(e,o);else if(u==="/"&&e[o+1]==="*")o=dt(e,o);else if(t&&u==="/"&&ht(l,f)){let d=pt(e,o);c("regex",o,d),o=d}else if(u==="{")t&&c("punct",o,o+1),s[s.length-1]=a+1,o++;else if(u==="}")t&&c("punct",o,o+1),o++,a===1?(s.pop(),s.length===1&&r.push([i,o])):s[s.length-1]=a-1;else if(t&&(N(u)||W(u))){let d=W(u)?B(e,o):z(e,o);c(W(u)?"number":"ident",o,d),o=d}else t&&!P(u)&&c("punct",o,o+1),o++}return i!==-1&&s.length>1&&r.push([i,e.length]),{end:e.length,closed:!1,interpolations:r}}function Ft(e,n,t){let s=t.closed?t.end-1:t.end,r="",i=n+1;for(let[l,f]of t.interpolations)r+=L(e.slice(i,l),"js")+e.slice(l,Math.min(f,s)),i=f;return r+L(e.slice(i,s),"js")}function dt(e,n){let t=e.indexOf("*/",n+2);return t===-1?e.length:t+2}function pt(e,n){let t=n+1,s=!1;for(;t<e.length;){let r=e[t];if(r===`
|
|
9
|
+
`||r==="\r")return t;if(r==="\\")t+=T(e,t);else if(r==="[")s=!0,t++;else if(r==="]")s=!1,t++;else if(r==="/"&&!s){t++;break}else t++}for(;t<e.length&&/[a-z]/i.test(e[t]);)t++;return Math.min(t,e.length)}function Nt(e,n){return e.kind==="punct"&&(e.text==="+"||e.text==="-")&&n?.text===e.text&&n.end===e.start}function ht(e,n){if(!e)return!0;if(Nt(e,n))return!1;switch(e.kind){case"ident":return Lt.has(e.text);case"number":case"string":case"template":case"regex":return!1;case"punct":return e.text!==")"&&e.text!=="]"&&e.text!=="}";default:return!0}}function gt(e){let n=new R(e),t,s,r=(l,f,c,o,a=!1)=>{n.push(l,f,c,o,a),l!=="comment"&&(s=t,t=n.tokens[n.tokens.length-1])},i=0;for(;i<e.length;){let l=e[i],f=e[i+1];if(P(l)){i++;continue}let c;if(l==="/"&&f==="/")c=D(e,i),r("comment",i,c);else if(l==="/"&&f==="*")c=dt(e,i),r("comment",i,c);else if(l==="'"||l==='"')c=ut(e,i),r("string",i,c,L(Pt(e,i,c,l),"js"));else if(l==="`"){let o=Ut(e,i);c=o.end,r("template",i,c,Ft(e,i,o),o.interpolations.length>0)}else l==="/"&&ht(t,s)?(c=pt(e,i),r("regex",i,c)):W(l)||l==="."&&W(f??"")?(c=B(e,i),r("number",i,c)):N(l)?(c=z(e,i),r("ident",i,c)):(c=i+1,r("punct",i,c));i=c}return n.tokens}function Pt(e,n,t,s){let r=0;for(let l=t-2;l>n&&e[l]==="\\";l--)r++;let i=t-n>1&&e[t-1]===s&&r%2===0;return e.slice(n+1,i?t-1:t)}var zt=new Set(["r","b","f","u","rb","br","fr","rf"]);function tt(e,n,t=!1,s){let r=e[n],i=e.startsWith(r.repeat(3),n),f=n+(i?3:1),c=f,o=0,a=[];for(;c<e.length;){let u=e[c];if(u==="\\")c+=T(e,c);else if(t&&u==="{"&&o===0&&e[c+1]==="{")c+=2;else if(t&&u==="{"){let d=a.at(-1);s&&(o===0||d?.format&&o===d.depth?a.push({start:c+1,depth:o+1,nesting:0,format:!1}):d&&!d.format&&d.nesting++),o++,c++}else if(t&&u==="}"&&o>0){let d=a.at(-1);d?.depth===o?(d.format||s?.push([d.start,c]),a.pop()):d&&!d.format&&d.nesting--,o--,c++}else if(s&&a.length&&!a.at(-1).format&&"()[]".includes(u))a.at(-1).nesting+="([".includes(u)?1:-1,c++;else if(s&&u===":"&&a.length&&!a.at(-1).format&&a.at(-1).nesting===0){let d=a.at(-1);s.push([d.start,c]),d.format=!0,c++}else if(o>0&&!a.at(-1)?.format&&(u==='"'||u==="'")&&!e.startsWith(u.repeat(3),c)&&mt(e,c)!==-1)c=mt(e,c);else{if(i&&e.startsWith(r.repeat(3),c))return{end:c+3,bodyStart:f,bodyEnd:c};if(!i&&u===r)return{end:c+1,bodyStart:f,bodyEnd:c};if(!i&&(u===`
|
|
10
|
+
`||u==="\r"))return{end:c,bodyStart:f,bodyEnd:c};c++}}return{end:e.length,bodyStart:f,bodyEnd:e.length}}function Kt(e){let n=/^[A-Za-z]*/.exec(e)[0];if(!n.toLowerCase().includes("f"))return[];let t=[];return tt(e,n.length,!0,t),t.map(([s,r])=>e.slice(s,r))}function mt(e,n){let t=tt(e,n);return t.end>t.bodyEnd?t.end:-1}function xt(e){let n=new R(e),t=0;for(;t<e.length;){let s=e[t];if(P(s)){t++;continue}if(s==="#"){let r=D(e,t);n.push("comment",t,r),t=r}else if(s==='"'||s==="'")t=yt(n,t,t,"");else if(W(s)||s==="."&&W(e[t+1]??"")){let r=B(e,t);n.push("number",t,r),t=r}else if(N(s)){let r=z(e,t),i=e.slice(t,r).toLowerCase();(e[r]==='"'||e[r]==="'")&&zt.has(i)?t=yt(n,t,r,i):(n.push("ident",t,r),t=r)}else n.push("punct",t,t+1),t++}return n.tokens}function yt(e,n,t,s){let r=tt(e.text,t,s.includes("f")),i=e.text.slice(r.bodyStart,r.bodyEnd);return e.push("string",n,r.end,s.includes("r")?i:L(i,"py"),s.includes("f")),r.end}var Bt={ts:"js",tsx:"js",js:"js",jsx:"js",mjs:"js",cjs:"js",mts:"js",cts:"js",py:"py"};function Z(e){let n=e.slice(e.lastIndexOf("/")+1),t=n.lastIndexOf(".");return t===-1?null:Bt[n.slice(t+1).toLowerCase()]??null}function bt(e,n){return n==="py"?xt(e):gt(e)}var _={inventoryEntries:1e4,metadataTextUnits:1e6,workspaceTextUnits:2e6,settingsFiles:128,settingsBytes:2e6,metadataDepth:32,workspacePatterns:128,patternTextUnits:512,patternSegments:64};function O(e){return lt.safeParse(e).success&&!e.split("/").includes("node_modules")}function M(e,n){return/^(?:\/|[A-Za-z][A-Za-z\d+.-]*:)|[\\\p{C}]/u.test(n)?null:H(e==="."?"":e,n)}function H(e,n){let t=e?e.split("/"):[];for(let s of n.split("/"))if(!(s===""||s==="."))if(s===".."){if(t.pop()===void 0)return null}else t.push(s);return t.join("/")}var et=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function jt(e){let n=bt(e.replace(/^\uFEFF/,""),"js").filter(s=>s.kind!=="comment"),t=n.filter((s,r)=>s.text!==","||!["}","]"].includes(n[r+1]?.text)).map(s=>s.text).join(" ");try{let s=JSON.parse(t);return et(s)?s:null}catch{return null}}function wt(e,n){if(!n.startsWith(".")||n.split("/").includes("node_modules"))return[];let t=M(J.dirname(e),n);return t!==null&&O(t)?[t,`${t}.json`,`${t}/tsconfig.json`]:[]}function _t(e,n){let t=J.dirname(e);for(;;){let s=J.join(t,"tsconfig.json");if(n.has(s)&&O(s))return s;if(t===".")return;t=J.dirname(t)}}var X=class{files;static settingsFiles(n,t,s){let r=[...new Set(s.filter(l=>Z(l)==="js").flatMap(l=>_t(l,n)??[]))],i=new Set(r);for(let l=0;l<r.length;l++){let f=r[l],c=t.get(f);if(c===void 0||c.length>_.metadataTextUnits)continue;let o=jt(c)?.extends;if(typeof o!="string")continue;let a=wt(f,o).find(u=>n.has(u));a&&!i.has(a)&&(i.add(a),r.splice(l+1,0,a))}return r}configs=new Map;constructor(n){this.files=n}config(n){let t=this.configs.get(n);if(t)return t;let s=this.readConfig(n);return this.configs.set(n,s),s}readConfig(n,t=new Set){if(t.has(n))return"invalid-config";if(t.size>=_.metadataDepth)return"over-limit";let s=this.files.get(n);if(s===void 0)return"invalid-config";if(s.length>_.metadataTextUnits)return"over-limit";let r=jt(s);if(!r)return"invalid-config";let i=J.dirname(n),l={base:i==="."?"":i,baseUrl:!1,paths:{}};if(r.extends!==void 0){if(typeof r.extends!="string"||!r.extends.startsWith("."))return"unsupported";if(r.extends.split("/").includes("node_modules"))return"excluded";let o=M(i,r.extends);if(o===null)return"out-of-scope";if(!O(o))return"excluded";let a=wt(n,r.extends).find(d=>this.files.has(d));if(!a)return"invalid-config";let u=this.readConfig(a,new Set([...t,n]));if(typeof u=="string")return u;l=u}let f=r.compilerOptions===void 0?{}:r.compilerOptions;if(!et(f)||f.paths!==void 0&&!et(f.paths)||f.baseUrl!==void 0&&typeof f.baseUrl!="string")return"invalid-config";if(typeof f.baseUrl=="string"&&f.baseUrl.split("/").includes("node_modules"))return"excluded";let c=typeof f.baseUrl=="string"?M(i,f.baseUrl):f.paths!==void 0&&!l.baseUrl?i==="."?"":i:l.base;return c===null?"out-of-scope":c&&!O(c)?"excluded":{base:c,baseUrl:f.baseUrl!==void 0||l.baseUrl,paths:f.paths??l.paths}}bases(n,t){let s=_t(n,this.files);if(!s)return null;let r=this.config(s);if(typeof r=="string")return r;let i=Object.entries(r.paths).flatMap(([o,a])=>{let u=o.indexOf("*");if(u<0)return o===t?[{targets:a,capture:"",rank:1/0,suffix:0}]:[];let d=o.slice(0,u),h=o.slice(u+1);return t.length>=d.length+h.length&&t.startsWith(d)&&t.endsWith(h)?[{targets:a,capture:t.slice(d.length,t.length-h.length),rank:d.length,suffix:h.length}]:[]}).sort((o,a)=>a.rank-o.rank||a.suffix-o.suffix);if(i.length>1&&i[0].rank===i[1].rank&&i[0].suffix===i[1].suffix)return"ambiguous";let l=i[0];if(l&&(!Array.isArray(l.targets)||!l.targets.length||!l.targets.every(o=>typeof o=="string")))return"invalid-config";let f=l?l.targets:r.baseUrl?[t]:[];if(!f.length)return null;let c=[];for(let o of f){if((o.match(/\*/g)?.length??0)>1||l?.rank===1/0&&o.includes("*"))return"unsupported";let a=o.replace(/\*/,()=>l?.capture??"");if(a.split("/").includes("node_modules"))return"excluded";let u=M(r.base,a);if(u===null)return"out-of-scope";if(!O(u))return"excluded";c.push(u)}return{bases:c,fallback:!l}}};import{posix as vt}from"node:path";var q=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Ot(e){try{let n=JSON.parse(e);return q(n)?n:null}catch{return null}}function Dt(e){let n=[],t=!1;for(let s of e.split(/\r?\n/)){if(/^packages:\s*(?:#.*)?$/.test(s)){t=!0;continue}if(!t||/^\s*(?:#.*)?$/.test(s))continue;if(/^\S/.test(s)){t=!1;continue}let r=/^\s+-\s+(?:'([^']*)'|"([^"]*)"|([^#\s]+))\s*(?:#.*)?$/.exec(s);if(!r)return null;n.push(r[1]??r[2]??r[3])}return t||n.length?n:null}function nt(e){if(!e||e.length>_.patternTextUnits||/[\\\p{C}{}[\]?]|^(?:\/|[A-Za-z]:)/u.test(e)||e.split("/").some(s=>s===".."||s==="node_modules"))return null;let n=e.replace(/^\.\//,"").replace(/\/$/,"").split("/");if(n.length>_.patternSegments||n.filter(s=>s==="**").length>1||n.some(s=>s!=="**"&&(s.match(/\*/g)?.length??0)>1))return null;let t=(s,r)=>{let i=s.indexOf("*");return i<0?s===r:r.length>=s.length-1&&r.startsWith(s.slice(0,i))&&r.endsWith(s.slice(i+1))};return s=>{let r=s.split("/"),i=n.indexOf("**");if(i<0)return r.length===n.length&&n.every((f,c)=>t(f,r[c]));let l=n.length-i-1;return r.length>=n.length-1&&n.slice(0,i).every((f,c)=>t(f,r[c]))&&n.slice(i+1).every((f,c)=>t(f,r[r.length-l+c]))}}function kt(e){let n=e.get("package.json"),t=e.get("pnpm-workspace.yaml");if((n?.length??0)>_.metadataTextUnits||(t?.length??0)>_.metadataTextUnits)return"over-limit";let s=n===void 0?{}:Ot(n);if(!s)return"invalid-config";let r=q(s.workspaces)?s.workspaces.packages:s.workspaces;if(r!==void 0&&(!Array.isArray(r)||!r.every(c=>typeof c=="string")))return"invalid-config";let i=t===void 0?[]:Dt(t);if(!i)return"unsupported";let l=[...r??[],...i];if(l.length>_.workspacePatterns)return"over-limit";let f=[];for(let c of l){let o=nt(c.replace(/^!/,""));if(!o)return"unsupported";f.push({excluded:c.startsWith("!"),matches:o})}return f}function St(e,n){if(e==="package.json"||!e.endsWith("/package.json")||!O(e))return!1;let t=vt.dirname(e);return n.some(s=>!s.excluded&&s.matches(t))&&!n.some(s=>s.excluded&&s.matches(t))}function $t(e,n=0){if(n>=_.metadataDepth)return{reason:"over-limit"};if(typeof e=="string")return{target:e};if(!q(e))return{reason:"unsupported"};for(let t of["source","import","default"])if(Object.hasOwn(e,t))return $t(e[t],n+1);return{reason:"unsupported"}}var G=class{files;static settingsFiles(n,t){let s=["package.json","pnpm-workspace.yaml"].filter(i=>n.has(i));if(s.some(i=>!t.has(i)))return s;let r=kt(t);return typeof r=="string"?s:[...s,...[...n].filter(i=>St(i,r))]}packages;constructor(n){this.files=n}inventory(){return this.packages??=this.readInventory()}readInventory(){let n=kt(this.files);if(typeof n=="string")return n;let t=[],s=(this.files.get("package.json")?.length??0)+(this.files.get("pnpm-workspace.yaml")?.length??0);for(let[r,i]of this.files){if(!St(r,n))continue;let l=vt.dirname(r);if(s+=i.length,i.length>_.metadataTextUnits||s>_.workspaceTextUnits)return"over-limit";let f=Ot(i);if(!f||typeof f.name!="string")return"invalid-config";t.push({root:l,data:f})}return t}bases(n){let t=/^(@[^/]+\/[^/]+|[^/@][^/]*)(?:\/(.+))?$/.exec(n);if(!t)return"unsupported";let s=this.inventory();if(typeof s=="string")return s;let r=s.filter(u=>u.data.name===t[1]);if(!r.length)return null;if(r.length>1)return"ambiguous";let i=r[0],l=t[2]?`./${t[2]}`:".",f;if(i.data.exports!==void 0){let u=i.data.exports;if(q(u)&&Object.keys(u).some(d=>d.includes("*")))return"unsupported";if(q(u)&&Object.keys(u).some(d=>d.startsWith("."))){if(Object.keys(u).some(d=>!d.startsWith(".")))return"ambiguous";f=u[l]}else l==="."&&(f=u);if(f===void 0)return"missing"}else f=l!=="."?l:i.data.source??i.data.module??i.data.main??"./index";let c=$t(f);if("reason"in c)return c.reason;let{target:o}=c;if(o.split("/").includes("node_modules"))return"excluded";if(/^(?:\/|[A-Za-z]:)|[\\\p{C}]/u.test(o)||i.data.exports!==void 0&&!o.startsWith("./"))return"out-of-scope";let a=M(i.root,o);return a===null||!a.startsWith(`${i.root}/`)?"out-of-scope":O(a)?{bases:[a]}:"excluded"}};import{posix as Y}from"node:path";var I=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function It(e){let n=/\r?\n|[ \t]+|#[^\r\n]*|"""(?:\\[\s\S]|"(?!"")|[^"\\])*"{3,5}|'''(?:'(?!'')|[^'])*'{3,5}|"(?:\\.|[^"\\\r\n])*"|'[^'\r\n]*'|[.\][{}=,]|[^\s#[\]{}=,."']+/gy,t=[],s=0;for(;s<e.length;){n.lastIndex=s;let p=n.exec(e);if(!p)throw new Error("invalid-config");t.push(p[0]),s=n.lastIndex}let r=0,i=()=>t[r],l=()=>{throw new Error("invalid-config")},f=p=>{t[r++]!==p&&l()},c=(p=!1)=>{for(;/^(?:[ \t]+|#)/.test(i()??"")||p&&/^\r?\n$/.test(i()??"");)r++},o=p=>{if(p.startsWith("'''"))return p.slice(3,-3).replace(/^\r?\n/,"");if(p.startsWith('"""')){let g=p.slice(3,-3).replace(/^\r?\n/,"").replace(/\\\r?\n\s*/g,"");return a(g)}return p.startsWith("'")?p.slice(1,-1):a(p.slice(1,-1))},a=p=>{let g={b:"\b",t:" ",n:`
|
|
11
|
+
`,f:"\f",r:"\r",'"':'"',"\\":"\\"},y="";for(let j=0;j<p.length;j++){if(p[j]!=="\\"){y+=p[j];continue}let w=p[++j];if(w==="u"||w==="U"){let v=w==="u"?4:8,$=p.slice(j+1,j+1+v);($.length!==v||!/^[\da-f]+$/i.test($))&&l();let E=Number.parseInt($,16);(E>1114111||E>=55296&&E<=57343)&&l(),y+=String.fromCodePoint(E),j+=v}else Object.hasOwn(g,w)||l(),y+=g[w]}return y},u=()=>{let p=[];do{p.length&&(f("."),c());let g=t[r++]??l();/^(?:[\w-]+|".*"|'.*')$/.test(g)||l(),p.push(/^["']/.test(g)?o(g):g),c()}while(i()===".");return p},d=new WeakSet,h=new WeakSet,b=new WeakSet,S=(p,g,y)=>{for(let w of g.slice(0,-1)){if(d.has(p)&&l(),!Object.hasOwn(p,w)){let v=Object.create(null);h.add(v),p[w]=v}I(p[w])||l(),p=p[w]}let j=g.at(-1);(d.has(p)||Object.hasOwn(p,j))&&l(),p[j]=y},k=(p=0)=>{p>_.metadataDepth&&l(),c(!0);let g=t[r++]??l();if(/^["']/.test(g))return o(g);if(g==="["||g==="{"){let j=[],w=Object.create(null),v=g==="["?"]":"}";for(c(!0);i()!==v;){if(g==="[")j.push(k(p+1));else{let $=u();f("="),S(w,$,k(p+1))}if(c(!0),i()===v)break;f(","),c(!0),g==="{"&&i()===v&&l()}return f(v),g==="{"&&d.add(w),g==="["?j:w}if(g==="true"||g==="false")return g==="true";let y=g;for(;i()===".";)y+=t[r++],y+=t[r++]??l();return/^[+-]?(?:(?:0|[1-9](?:_?\d)*)(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|inf|nan)$/.test(y)?Number(y.replaceAll("_","")):/^0(?:x[\da-fA-F_]+|o[0-7_]+|b[01_]+)$/.test(y)||/^\d\d:\d\d:\d\d(?:\.\d+)?$/.test(y)?0:/^\d{4}-\d\d-\d\d(?:[Tt].*)?$/.test(y)?(/^[ \t]+$/.test(i()??"")&&/^\d\d:\d\d:\d\d/.test(t[r+1]??"")&&(r+=2,i()==="."&&(r+=2)),0):l()},x=Object.create(null),m=x;for(;r<t.length&&(c(!0),r!==t.length);){if(i()==="["){f("[");let p=i()==="[";p&&f("["),c();let g=u();f("]"),p&&f("]"),m=x;for(let[y,j]of g.entries()){if(!Object.hasOwn(m,j))if(p&&y===g.length-1){let v=[];b.add(v),m[j]=v}else m[j]=Object.create(null);let w=m[j];if(Array.isArray(w)){b.has(w)||l(),p&&y===g.length-1&&w.push(Object.create(null));let v=w.at(-1);if(!I(v))return l();m=v}else{if(!I(w)||d.has(w))return l();m=w}}!p&&h.has(m)&&l(),h.add(m)}else{let p=u();f("="),S(m,p,k())}c(),r<t.length&&!/^\r?\n$/.test(t[r++])&&l()}return x}function Et(e){if(e.length>_.metadataTextUnits)return"over-limit";try{let n=It(e),t=[],s=(...a)=>a.reduce((u,d)=>I(u)?u[d]:void 0,n),r=a=>{if(!Array.isArray(a)||!a.every(u=>typeof u=="string"))throw new Error("invalid-config");return a},i=(a,u="")=>{if(typeof a!="string"||typeof u!="string")throw new Error("invalid-config");t.push({path:a,prefix:u})},l=s("tool","poetry","packages");if(l!==void 0){if(!Array.isArray(l))return"invalid-config";for(let a of l){if(!I(a)||typeof a.include!="string"||a.to!==void 0&&typeof a.to!="string")return"invalid-config";i(a.from??".")}}{let a=["tool","hatch","build"],u=[...a,"targets","wheel"],d=s(...u,"sources")??s(...a,"sources"),h=s(...u,"packages")??s(...a,"packages");if(d!==void 0)if(I(d))for(let[b,S]of Object.entries(d))i(b,S);else for(let b of r(d))i(b);else if(h!==void 0)for(let b of r(h))i(b.includes("/")?b.slice(0,b.lastIndexOf("/")):".")}let f=s("tool","setuptools","package-dir");if(f!==void 0){if(!I(f))return"invalid-config";for(let[a,u]of Object.entries(f))i(u,a.replaceAll(".","/"))}let c=s("tool","setuptools","packages","find","where");if(c!==void 0)for(let a of r(c))i(a);for(let a of[["tool","uv","build-backend","module-root"],["tool","pdm","build","package-dir"]]){let u=s(...a);u!==void 0&&i(u)}let o=s("tool","uv","workspace");return o!==void 0&&!I(o)?"invalid-config":t.length>_.workspacePatterns?"over-limit":{roots:t,...I(o)&&o.members!==void 0?{members:r(o.members)}:{},...I(o)&&o.exclude!==void 0?{exclude:r(o.exclude)}:{}}}catch{return"invalid-config"}}var C=(e,n)=>!n||e===n||e.startsWith(`${n}/`),A=e=>Y.dirname(e)==="."?"":Y.dirname(e);function V(e){if(!e)return()=>!0;let n=[...e.config.members??[],...e.config.exclude??[]];if(n.length>_.workspacePatterns)return"over-limit";let t=n.map(nt);if(t.some(r=>!r))return"unsupported";let s=e.config.members?.length??0;return r=>{if(r===e.dir)return!0;if(!C(r,e.dir))return!1;let i=Y.relative(e.dir||".",r);return t.slice(0,s).some(l=>l(i))&&!t.slice(s).some(l=>l(i))}}function At(e,n){if(e.config.members===void 0)return;if(n!==e.dir){let s=V({...e,config:{...e.config,exclude:[]}});if(typeof s=="string")return s;if(!s(n))return}let t=V(e);return typeof t=="string"?t:t(n)?e:void 0}var U=class e{files;admitted;static isSettingsFile(n){return Y.basename(n)==="pyproject.toml"&&O(n)}static settingsFiles(n,t,s){let r=[...n].filter(e.isSettingsFile).sort((c,o)=>c.split("/").length-o.split("/").length||c.localeCompare(o));if(!t||!s)return r;let i=new e(t,t),l=new Set,f=new Set;for(let c of s.filter(o=>o.endsWith(".py"))){let o,a=!0,u=r.filter(h=>C(c,A(h))).reverse();for(let h of u){l.add(h);let b=i.project(h);if(typeof b=="string"){a=!1;break}let S=At({dir:A(h),config:b},A(u[0]));if(typeof S=="string"){a=!1;break}if(S){o=S;break}}if(!a)continue;let d=V(o);if(typeof d!="string")for(let h of r)d(A(h))&&f.add(h)}return[...l,...r.filter(c=>f.has(c)&&!l.has(c))]}sourceRoots;metadata;names=new Map;parsed=new Map;cached=new Map;constructor(n,t=n){this.files=n,this.admitted=t,this.metadata=e.settingsFiles(new Set(n.keys()));let s=new Map;for(let r of[...n.keys()].filter(i=>i.endsWith(".py"))){let i=r.split("/");for(let l=0;l<i.length;l++){let f=i.slice(0,l).join("/"),c=l===i.length-1?i[l].slice(0,-3):i[l];if(this.names.has(f)||this.names.set(f,new Set),this.names.get(f).add(c),i[l]==="src"&&l<i.length-1){let o=i.slice(0,l+1).join("/");s.set(o,{dir:f,path:o})}}}this.sourceRoots=[...s.values()]}hasRoot(n,t){let s=n.split("/");s.pop();for(let r=s.length;r>=0;r--){let i=s.slice(0,r).join("/");if(this.names.get(i)?.has(t)||this.names.get(i?`${i}/src`:"src")?.has(t))return!0}return!1}ancestorBase(n,t){let s=n.split("/");s.pop();let r=t.split(".")[0],i=s.lastIndexOf("src")+1;for(let l=i||s.length;l>=i;l--){let f=s.slice(0,l).join("/");if(!this.files.has([f,"__init__.py"].filter(Boolean).join("/"))&&this.names.has([f,r].filter(Boolean).join("/")))return[f,t.replaceAll(".","/")].filter(Boolean).join("/")}}project(n){let t=this.admitted.get(n);if(t===void 0)return"invalid-config";let s=this.parsed.get(t);return s||(s=Et(t),this.parsed.set(t,s)),s}roots(n){let t=this.metadata.filter(d=>C(n,A(d))).reverse(),s=t[0],r=s===void 0?void 0:A(s),i=n.split("/"),l=i.lastIndexOf("src"),f=l<0?void 0:i.slice(0,l).join("/"),c=JSON.stringify([s,f??A(n)]),o=this.cached.get(c);if(o)return o;let u=(()=>{let d;for(let x of t){let m=this.project(x);if(typeof m=="string"){if(x===s)return m;continue}let p=At({dir:A(x),config:m},r);if(typeof p=="string")return p;if(p){d=p;break}}let h=V(d);if(typeof h=="string")return h;let b=[],S=[],k=0;t:for(let x of this.metadata.filter(m=>h(A(m)))){let m=A(x),p=x===s||!!d,g=this.admitted.get(x),y=this.project(x);if(p){if(k+=g?.length??0,k>_.workspaceTextUnits)return"over-limit";if(typeof y=="string")return y}if(typeof y=="string")continue;let j=m===r?0:d?1:2,w=[],v=m===r?[{path:".",prefix:""}]:d&&m!==d.dir?[{path:".",prefix:"",packages:[...this.names.get(m)??[]].filter($=>$!=="src"&&this.names.has(`${m}/${$}`))}]:[];for(let $ of y.roots.length?y.roots:v){let E=M(m,$.path),ot=E===null||!C(E,m)?"out-of-scope":E&&!O(E)||$.prefix&&(!O($.prefix)||$.prefix.includes("."))?"unsupported":null;if(ot){if(p)return ot;continue t}w.push({...$,path:E,owner:m,binding:p,tier:j})}S.push({dir:m,config:y}),b.push(...w)}for(let{dir:x,path:m}of this.sourceRoots){if(!h(x))continue;let p=S.filter(y=>C(x,y.dir)).sort((y,j)=>j.dir.length-y.dir.length)[0];if(p?.config.roots.length&&(!d||p.dir!==d.dir||x===d.dir))continue;let g=f!==void 0?x===f:r===void 0?C(n,x):x===r;b.push({path:m,prefix:"",owner:x,binding:g||!!d,tier:g?0:d?1:2})}return[...new Map(b.map(x=>[JSON.stringify(x),x])).values()]})();return this.cached.set(c,u),u}bases(n,t){let s=this.roots(n);if(typeof s=="string")return s;let r=t.replaceAll(".","/"),i=t.split(".")[0],l=[[],[],[]],f=new Map;for(let o of s)(!o.packages||o.packages.includes(i))&&(!o.prefix||C(r,o.prefix))&&f.set(o.owner,Math.max(f.get(o.owner)??0,o.prefix.length));let c=!1;for(let o of s){if(o.packages&&!o.packages.includes(i)||o.prefix&&!C(r,o.prefix)||o.prefix.length!==f.get(o.owner))continue;let a=o.prefix?r.slice(o.prefix.length).replace(/^\//,""):r;l[o.tier].push([o.path,a].filter(Boolean).join("/")),c||=o.binding&&(r.includes("/")||!!o.prefix)&&(!!o.prefix||this.names.get(o.path)?.has(i)===!0)}return{tiers:l.map(o=>[...new Set(o)]),local:c}}};function Zt(e){return e.replace(/\.(tsx?|jsx?|mjs|cjs|py)$/,"").replace(/^(\.{1,2}\/)+/,"").replace(/^[@~]?\//,"").replace(/^\.+/,"").replace(/\./g,"/")}function Jt(e,n){let t=Zt(n),s=e.replace(/\.[^./]+$/,"").replace(/\/index$/,"").replace(/\/__init__$/,"");return t.length>0&&(s===t||s.endsWith(`/${t}`))}function Wt(e,n=!1){let t=n?[".ts",".tsx",".js",".jsx",".mts",".cts",".mjs",".cjs"]:[".ts",".tsx",".js"],s=e.replace(n?/\.(js|jsx|mjs|cjs)$/:/\.(js|jsx|mjs)$/,""),r=n&&e.endsWith(".mjs")?[".mts"]:n&&e.endsWith(".cjs")?[".cts"]:[".ts",".tsx"];return[e,...t.map(i=>e+i),...s===e?[]:r.map(i=>s+i),...t.map(i=>`${e}/index${i}`)]}function Q(e,n,t=!0){return[...n.flatMap(s=>[`${e}/${s}.py`,`${e}/${s}/__init__.py`]),...t?[`${e}.py`]:[],`${e}/__init__.py`].map(s=>s.replace(/^\//,""))}function it(e,n){let t=n.length-n.replace(/^\.+/,"").length,s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",r="../".repeat(t-1),i=n.slice(t).split(".").join("/");return{base:H(s,r+i),rest:i}}function Xt(e,n,t){let{base:s,rest:r}=it(e,n);return s===null?[]:r?Q(s,[]):[...t.map(i=>s?`${s}/${i}.py`:`${i}.py`),s?`${s}/__init__.py`:"__init__.py"]}function rt(e,n,t,s,r=!1){if(!n.startsWith("."))return[];if(s==="py")return Xt(e,n,t);let i=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",l=H(i,n);return l===null?[]:Wt(l,r)}function qt(e,n,t,s,r,i=!1){return rt(e,n,t,s,i).find(l=>r.has(l))}function Mt(e,n){let t=e.split("/").slice(0,-1),s=[];for(let r=t.length;r>0;r--){let i=`${t.slice(0,r).join("/")}/__init__.py`;n.has(i)&&s.push(i)}return s}function K(e,n,t,s,r){let i=rt(e,n,t,s,!0),l=i.find(h=>r.has(h));if(s!=="py")return[l??i[0]??n];let{base:f,rest:c}=it(e,n);if(f===null)return[n];let o=f?`${f}/__init__.py`:"__init__.py",a=r.has(o),u=t.flatMap(h=>{let b=f?`${f}/${h}`:h,S=Q(b,[]).find(k=>r.has(k));return S?[S]:!c&&!a?[`${b}.py`]:[]}),d=[...a?[o]:[],...c?[l??i[0]??n]:[],...u];return[...new Set([...d,...d.flatMap(h=>Mt(h,r))])]}function Ee(e,n,t,s,r,i){if(s==="py"&&i?.pythonSourceImports){let f=t.length?t.flatMap(a=>i.bindings(e,n,[a])):i.bindings(e,n),c=i.bindings(e,n)[0],o=f.flatMap(a=>a.status==="resolved"?[a.path]:[]);if(o.length){let a=[...c?.status==="resolved"&&c.path.endsWith("/__init__.py")?[c.path]:[],...o],u=f.flatMap((d,h)=>d.status==="refused"&&d.reason!=="external"?n.startsWith(".")?K(e,n,t.length?[t[h]]:[],s,r):[n]:[]);return[...new Set([...a,...a.flatMap(d=>Mt(d,r)),...u])]}return n.startsWith(".")?K(e,n,t,s,r):f.some(a=>a.status==="refused"&&a.reason!=="external"&&(a.reason!=="missing"||i.pythonMissingNeedsContext(e,n)))?[n]:[]}if(s==="js"&&i){let f=i.bindings(e,n,t)[0];if(f?.status==="resolved")return[f.path];if(!n.startsWith(".")&&f?.status==="refused"&&(f.provenance==="alias"||f.provenance==="workspace"))return[n]}if(n.startsWith("."))return K(e,n,t,s,r);if(s!=="py")return/^(?:@\/|~\/|#)/.test(n)?[n]:[];let l=["",...e.includes("/")?[e.split("/")[0]]:[]];for(let f of l){let c=`${f?`${f}/`:""}${n.replaceAll(".","/")}`;if(!(!r.has(`${c}.py`)&&!r.has(`${c}/__init__.py`)))return K(f?`${f}/_.py`:"_.py",`.${n}`,t,s,r)}return[]}function Ae(e,n,t,s={},r){return new st(t,s).resolve(e,n,r)}var st=class{repo;static isPythonSettingsFile=U.isSettingsFile;static settingsFiles(n,t,s,r={}){return[...X.settingsFiles(n,t,s),...r.CF_PYTHON_SRC_IMPORTS!=="0"&&r.CF_LOCAL_IMPORT_RESOLUTION!=="0"&&s.some(i=>Z(i)==="py")?U.settingsFiles(n,t,s):[],...s.some(i=>Z(i)==="js")?G.settingsFiles(n,t):[]]}legacy;pythonSourceImports;files;aliases;workspaces;pythonRoots;constructor(n,t={}){this.repo=n,this.legacy=t.CF_LOCAL_IMPORT_RESOLUTION==="0",this.pythonSourceImports=!this.legacy&&t.CF_PYTHON_SRC_IMPORTS!=="0",this.files=n.files.size>_.inventoryEntries&&!this.legacy?new Map:new Map([...n.files].filter(([s])=>O(s))),this.aliases=new X(this.files),this.workspaces=new G(this.files),this.legacy||(this.pythonRoots=new U(this.files,n.metadata))}pythonMissingNeedsContext(n,t){if(!this.pythonSourceImports||!t.includes("."))return!1;if(this.pythonRoots.ancestorBase(n,t)!==void 0)return!0;let s=this.pythonRoots.bases(n,t);return typeof s!="string"&&s.local}bindings(n,t,s){return!F.shape.from.safeParse(n).success||!F.shape.specifier.safeParse(t).success?[]:[this.resolve(n,t,s)]}resolve(n,t,s=[]){F.shape.from.parse(n),F.shape.specifier.parse(t);let r=n.endsWith(".py"),i=(a,u=null)=>({status:"refused",from:n,specifier:t,provenance:u,reason:a}),l=(a,u)=>({status:"resolved",from:n,specifier:t,provenance:u,path:a});if(this.legacy){let a=qt(n,t,s,r?"py":"js",new Set(this.files.keys()));return a?l(a,"relative"):i(t.startsWith(".")?"missing":"external")}if(!O(n))return i("out-of-scope");if(/[\\\p{C}\p{Zl}\p{Zp}]/u.test(t))return i("unsupported");if(/^(?:\/|[A-Za-z]:)/.test(t))return i("out-of-scope");if(t.split("/").includes("node_modules"))return i("excluded");if(this.repo.files.size>_.inventoryEntries)return i("over-limit");if(r&&!/^\.*(?:[\p{L}_][\p{L}\p{N}_]*(?:\.[\p{L}_][\p{L}\p{N}_]*)*)?$/u.test(t)||r&&s.some(a=>!/^[\p{L}_][\p{L}\p{N}_]*$/u.test(a)))return i("unsupported");if(r&&!t.startsWith(".")&&this.pythonSourceImports){let a=t.replaceAll(".","/"),u=n.slice(0,Math.max(0,n.lastIndexOf("/"))),d=m=>{let p=new Set(m.map(y=>Q(y,s).find(j=>this.files.has(j))).filter(y=>y!==void 0));if(p.size>1)return i("ambiguous","relative");let g=[...p][0];return g?l(g,"relative"):void 0},h=d([...new Set([a,[u,a].filter(Boolean).join("/")])]);if(h)return h;let b=this.pythonRoots.ancestorBase(n,t),S=b===void 0?void 0:d([b]);if(S)return S;let k=this.pythonRoots.bases(n,t),x=this.pythonRoots.hasRoot(n,t.split(".")[0]);if(typeof k=="string")return i(x?k:"external","relative");for(let m of k.tiers){let p=d(m);if(p)return p}return i(k.local||x?"missing":"external","relative")}if(t.startsWith(".")||r){let a=r&&!t.startsWith(".")?`.${t}`:t,d=(r&&!t.startsWith(".")?["__root__.py",n]:[n]).map(k=>{if(!r)return rt(k,a,s,"js",!0).map(p=>p.replace(/^\//,""));let{base:x,rest:m}=it(k,a);return x===null?[]:Q(x,s,!!m)});if(d.every(k=>!k.length))return i("out-of-scope","relative");let h=new Set(d.map(k=>k.find(x=>this.files.has(x))).filter(k=>k!==void 0));if(h.size>1)return i("ambiguous","relative");let b=[...h][0],S=r&&!t.startsWith(".")&&!this.pythonRoots?.hasRoot(n,t.split(".")[0]);return b?l(b,"relative"):i(S?"external":"missing","relative")}let f=(a,u)=>{if(a===null)return null;if(typeof a=="string")return i(a,u);for(let d of a.bases){let h=Wt(d,!0).find(b=>this.files.has(b));if(h)return l(h,u)}return i("missing",u)},c=this.aliases.bases(n,t),o=f(c,"alias");return o&&(o.status==="resolved"||typeof c=="string"||!c?.fallback)?o:f(this.workspaces.bases(t),"workspace")??i("external")}};export{Kt as a,Z as b,bt as c,_ as d,Jt as e,rt as f,qt as g,K as h,Ee as i,Ae as j,st as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,c as l,d as s,e as m,g as i}from"./33EUZF25.js";import{c as u,d as p}from"./VDUFPTDD.js";function n(a,d={}){return JSON.stringify({bundleDescription:a,inputs:d})}import{z as e}from"zod";import{z as t}from"zod";var r=t.object({motivation:t.array(t.object({kind:t.string(),reason:t.string(),evidence:t.string()})),outcomes:t.array(t.object({improvement:t.string(),measurement:t.string()}))}),O=r.extend({motivation:r.shape.motivation.default([]),outcomes:r.shape.outcomes.default([])});var h=e.object({path:e.string().min(1),line:e.number().int().positive().nullable()}),f=e.object({label:e.string(),source:e.literal("mcp").optional(),brand:e.string().nullable().default(()=>null)}),x=["system prompt","soul","knowledge","skill","config","tools","mcp","template","reference","code"],y=e.object({filledAtRunTime:e.boolean().optional(),role:e.enum(x),label:e.string().nullable().default(()=>null),path:e.string().min(1),span:e.object({from:e.number().int(),to:e.number().int()}).optional()}),S=e.object({id:e.string().min(1),label:e.string().min(1),kind:e.enum(["entry","agent","tool","store","exit"]),desc:e.string(),meta:e.string().nullable(),sourceRef:h.nullable(),sourcePaths:e.array(e.string()).optional(),files:e.array(y).default(()=>[]),tools:e.array(f).default(()=>[])}),j=e.object({from:e.string().min(1),to:e.string().min(1),kind:e.enum(["invokes","delegates","reads","writes","emits"]),label:e.string().nullable(),sourceRef:h.nullable()}),_=e.object({nodes:e.array(S),edges:e.array(j),warnings:e.array(e.string())}),v=e.object({...r.shape,title:e.string().min(1).describe(n("analysis-wire-schemas-1")),approach:e.string().min(1).describe(n("analysis-wire-schemas-2")),kind:e.enum(["code","prompt"]),targetFiles:e.array(e.object({path:e.string().min(1),create:e.boolean().nullable()})),...i.shape});function o(a){return e.string().describe(n("analysis-wire-schemas-3",{v0:Object.values(a.enum).join(", ")}))}var w=e.object({nodes:e.array(e.object({id:e.string().min(1),change:o(s),label:e.string().nullable()})),edges:e.array(e.object({from:e.string().min(1),to:e.string().min(1),kind:o(m),change:o(s),detail:e.string().nullable()}))}),k=v.omit({motivation:!0,outcomes:!0}).extend({expectedOutcome:e.string().describe(n("analysis-wire-schemas-4")),summary:i.shape.summary.catch(null),impact:i.shape.impact.catch(null),objective:i.shape.objective.catch(null),blockedBy:i.shape.blockedBy.catch(null),confidence:o(l).nullable().catch(null),status:o(c).nullable().catch(null),alsoFixes:e.array(e.string()).nullable().default([]).catch(()=>[]),delta:w.nullable().catch(null)}),q=e.object({path:e.string().min(1),line:e.number().int().positive(),excerpt:e.string().trim().min(1)}),F=e.object({path:e.string(),line:e.number(),excerpt:e.string()}),b=a=>e.string().describe(n("analysis-wire-schemas-5",{v0:u(a).join(", ")})).nullable().catch(null),g=e.object({kind:e.enum(["ordering","reliability","coverage","cost","safety","correctness"]),severity:e.enum(["low","medium","high","critical"]),title:e.string().min(1).describe(n("analysis-wire-schemas-6")),cause:e.string().min(1),summary:e.string().describe(n("analysis-wire-schemas-7")).catch(""),site:e.object({path:e.string().min(1),line:e.number().int().positive().nullable()}).nullable(),excerpt:e.string().nullable(),category:b({}),otherSites:e.array(F).nullable().default([]).catch(()=>[]),question:e.string().describe(n("analysis-wire-schemas-8")).catch(""),fixes:e.array(k).min(1)}),E=e.object({findings:e.array(g)});function A(a){return p(a)?E:e.object({findings:e.array(g.extend({category:b(a)}))})}export{n as a,y as b,S as c,j as d,_ as e,k as f,q as g,g as h,E as i,A as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as u}from"./
|
|
1
|
+
import{a as u}from"./AIS3FHQR.js";import{e as c}from"./QYYN4YKB.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 +1 @@
|
|
|
1
|
-
import{a as c}from"./
|
|
1
|
+
import{a as c}from"./JCVB6IC4.js";import{e as w}from"./QYYN4YKB.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
|
+
function r(t,o,n=`${o}s`){return t===1?o:n}export{r as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./PBHHWFR6.js";import{C as p}from"./
|
|
1
|
+
import{a}from"./PBHHWFR6.js";import{C as p}from"./AIS3FHQR.js";import{a as y}from"./MKYLK6DB.js";import{posix as d}from"node:path";var m=Object.freeze({totalLimitBytes:y.codeAgent.importBytes,instructionLimitBytes:y.sourceFetch.instructionBytes}),A=["totalBytes","instructionBytes","fileCount"],u=()=>new Error("Invalid analysis size"),z=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function g(e){let i=a(e);return i.totalBytes>m.totalLimitBytes?{fits:!1,measure:"total_text"}:i.instructionBytes>m.instructionLimitBytes?{fits:!1,measure:"instruction_text"}:{fits:!0,measure:null}}function v(e,i,n={}){return h(e,i,n,!1)}function b(e,i,n={}){return h(e,i,n,!0)}function h(e,i,n,c){let f=new Map;for(let t of i){if(!z(t.size)||typeof t.path!="string"||!t.path||t.path.includes("\0"))throw u();let s=d.normalize(t.path.replace(/\\/g,"/"));if(s==="."||s===".."||s.startsWith("../")||s.startsWith("/"))throw u();let r=f.get(s);if(r&&r.size!==t.size)throw u();f.set(s,{path:s,size:t.size,ref:s})}let S=[...f.values()],{descriptions:B}=p(e,S,n,{measureAnalysisSize:!0,measureAnalysisSizeLowerBound:c}),l=n.paths?new Set(n.paths):void 0,o={totalBytes:0,instructionBytes:0,fileCount:0};for(let t of B){if(!(c?t.countsTowardAnalysisSizeWithoutInventory:t.countsTowardAnalysisSize)||l&&!l.has(t.entry.path))continue;let{entry:s}=t;if(o.totalBytes+=s.size,(c?t.countsTowardInstructionSizeWithoutInventory:t.analysisPool==="instruction")&&(o.instructionBytes+=s.size),o.fileCount+=1,!A.every(r=>z(o[r])))throw u()}return a(o)}export{m as a,g as b,v as c,b as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./OXGKALKM.js";function F(e){return e.CF_HISTORY_CONTEXT!=="0"}function u(e){return e.CF_REPOSITORY_PROJECTS==="1"}function C(e){return e.CF_FILE_SCOPE==="1"&&e.CF_LOCAL_IMPORT_RESOLUTION!=="0"}function S(e){return C(e)&&e.CF_SCOPE_CHOICES!=="0"&&e.CF_MULTI_ENTRY!=="0"}function i(e){return e.CF_FINDING_HEADLINES==="1"}function O(e){return e.CF_CODE_SCAN_PRIORITY==="1"}function R(e){return e.CF_RESULT_SAFETY_CHECK==="1"}function I(e){return e.CF_IMPORT_OUTSIDE_LOADERS==="1"}function P(e){return e.CF_CODE_PROMPT_SENT!=="0"}function f(e){return e.CF_PROMPT_AGREE==="1"}function T(e){return t(e,"saved")}function E(e){return e.CF_SKIPPED_FILES!=="0"}function c(e){return e.CF_FOLDER_PARTS==="1"&&E(e)}function l(e,n){let _=Object.fromEntries(Object.entries(t(n,"request")).filter(([r])=>/^(?:CF_FINDING_|CF_READING_|CF_RECALL_|CF_MULTI_PASS$|CF_SPLIT_CHECK$|CF_SOURCE_NOTES$|CF_PARALLEL_|CF_PASS_CONCURRENCY$|CF_PROMPT_AGREE$)/.test(r)&&r!=="CF_FINDING_AUDIENCE"));return Object.freeze({...e,..._,CF_CODE_SCAN_PRIORITY:n.CF_CODE_SCAN_PRIORITY,CF_PART_FILES:void 0})}export{F as a,u as b,C as c,S as d,i as e,O as f,R as g,I as h,P as i,f as j,T as k,E as l,c as m,l as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as O}from"./
|
|
1
|
+
import{m as O}from"./QENYFKG3.js";import{a as N}from"./326F4XNG.js";import{b as F}from"./PISOGSJF.js";import{a as P}from"./MKYLK6DB.js";import{e as x}from"./C6X5GDG4.js";async function H(S,t){let a={entriesVisited:0,filesRead:0,bytesRead:0,truncated:!1},d=[],R=()=>({files:t.selected.files,selection:t.selection,skippedFiles:F(d),search:a});if(O(S,{selected:t.selected,codeAgentsFound:t.codeAgentsFound}).kind==="none")return R();let h=await t.port.context();if(!h)return R();let E=[];try{let r=e=>x(e,h.selectedRoot),L=e=>Object.fromEntries(Object.entries(e).map(([c,I])=>[r(c),I])),A={...t.selected,files:L(t.selected.files),root:h.selectedRoot,...t.selected.listedPaths?{listedPaths:t.selected.listedPaths.map(r)}:{},...t.selected.pointerFiles?{pointerFiles:L(t.selected.pointerFiles)}:{},...typeof t.selected.explicitPrompt=="string"?{explicitPrompt:r(t.selected.explicitPrompt)}:{}},l=await t.port.list();a.entriesVisited=l.entriesVisited,a.truncated=l.truncated;let w=new Map(l.entries.map(e=>[e.path,e])),u=new Set,p={},m=P.codeScan,b=()=>O(S,{selected:A,codeAgentsFound:t.codeAgentsFound,entries:l.entries,bodies:p,attemptedPaths:[...u],completeListing:!l.truncated}),n=b();for(;n.kind==="search"&&n.paths.length;){let e=[],c=0;for(let s of n.paths){let i=w.get(s);if(i.size>m.fileBytes){d.push({path:s,reason:"too-large"}),u.add(s);continue}let o=i.size+1;if(e.length>=4||a.filesRead+e.length>=m.files||a.bytesRead+c+o>m.bytes)break;e.push({entry:i,allowance:o}),c+=o}if(!e.length){if(n=b(),n.kind==="none"||!n.paths.length)break;a.truncated=!0,d.push(...n.paths.map(s=>({path:s,reason:"scan-limit"})));break}(await N(e,4,async({entry:s,allowance:i})=>{u.add(s.path),a.filesRead++;try{return await t.port.read(s,i)}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{text:null,bytesRead:i,refusal:"unreadable"}}},{settleStartedOnError:!0})).forEach((s,i)=>{let{entry:o,allowance:k}=e[i],z=Number.isSafeInteger(s.bytesRead)&&s.bytesRead>=0&&s.bytesRead<=k;a.bytesRead+=z?s.bytesRead:k,z&&s.text!==null&&!s.refusal&&s.bytesRead<=m.fileBytes&&s.bytesRead<k&&Buffer.byteLength(s.text)===s.bytesRead?p[o.path]=s.text:d.push({path:o.path,reason:s.refusal??"unreadable"})}),n=b()}let g=b();if(g.kind==="none"||!g.ownedPaths.length)return R();let f={...A.files};for(let e of g.ownedPaths)Object.hasOwn(p,e)&&(f[e]=p[e]);let v=e=>({...e,path:r(e.path),...e.ref===e.path?{ref:r(e.ref)}:{}}),B=t.selection.selected.map(v),M=new Set(B.map(e=>e.path)),j=g.ownedPaths.filter(e=>!M.has(e)&&Object.hasOwn(f,e)).map(e=>({...w.get(e),path:e,size:Buffer.byteLength(f[e]),ref:w.get(e)?.ref??e})),y=t.selection.readingNotes,V={files:f,root:h.selectedRoot,search:a,skippedFiles:F(d),selection:{...t.selection,selected:[...B,...j],totalBytes:t.selection.totalBytes+j.reduce((e,c)=>e+c.size,0),refused:t.selection.refused.map(e=>({...e,path:r(e.path)})),...y?{readingNotes:{instruction:y.instruction.map(r),code:y.code.map(r),agents:y.agents.map(r)}}:{}}};return E=Object.keys(f),V}finally{t.port.finish?.(E)}}export{H as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./Y7JGSUOA.js";import{d as J}from"./3MTXB4MK.js";import{j as U}from"./
|
|
1
|
+
import{a as M}from"./Y7JGSUOA.js";import{d as J}from"./3MTXB4MK.js";import{j as U}from"./6JTHFDH3.js";import{a as K}from"./HTLIRVP7.js";import{a as G}from"./QDYMR6KS.js";import{b as T}from"./E7TFIHC5.js";import{b as P}from"./6YCABS5T.js";import{a as N,b as v,c as D,d as $}from"./VBGQKYIT.js";import{a as E,b as R}from"./P5FCHJ7W.js";import{d as A}from"./I5F7S63K.js";import{a as L}from"./74FPPPIG.js";import{j as x}from"./LOODGUMW.js";import{a as w}from"./INVTU73D.js";import{c as I}from"./VDUFPTDD.js";import{z as b}from"zod";function _(t,e){if(Buffer.byteLength(t)<=e)return t;let r=0,i=Math.min(t.length,e);for(;r<i;){let a=Math.ceil((r+i)/2);Buffer.byteLength(t.slice(0,a))<=e?r=a:i=a-1}return i>0&&/[\uD800-\uDBFF]/.test(t[i-1])&&i--,t.slice(0,i)}function H(t){let{bundleText:e}=t,r=s=>Buffer.byteLength(JSON.stringify(s));function i(s){let n=[];for(let o of s){if(r([...n,""])>4e3)break;let p=0,l=Buffer.byteLength(o);for(;p<l;){let d=Math.ceil((p+l)/2);r([...n,_(o,d)])<=4e3?p=d:l=d-1}n.push(_(o,p))}return n}function a(s,n=!1){return s.map(o=>typeof o!="string"&&o.kind==="no-core"&&n?e("analysis-check-input-1"):K([o])[0])}function m(s){let n=s.citedFiles===void 0?"":',"citedFiles":'+JSON.stringify(s.citedFiles),o=a(s.diagnostics,!0),p=s.citedFiles===void 0?o:i(o),l=[{text:'{"coreFiles":'+JSON.stringify(s.coreFiles)},{text:n+',"findings":'+JSON.stringify(s.findings)+',"diagnostics":'+JSON.stringify(p)+"}"}];return R(l,E({},{template:"check-findings"}).breakpoints)}function c(s){return Buffer.byteLength(m(s).map(n=>n.text).join(""))}return{checkDiagnosticsText:a,checkPromptBlocks:m,checkPayloadBytes:c}}function O(t,e={}){return t.length?t.map(r=>{let i=e.includeFiles===!1?"":`; files ${r.files.join(", ")||"none"}`;return`${r.ref} "${r.title}" (${r.subKind}): frozen ${r.frozen.join(", ")||"none"}; declined ${r.declined.join(", ")||"none"}${i}`}).join(`
|
|
2
2
|
`):"none"}function F(t){let{bundleText:e}=t,r=e("analysis-scope-check-1"),i=e("analysis-split-check-scope-rule-1"),a=[e("analysis-derive-structures-1"),e("analysis-derive-structures-2"),e("analysis-derive-structures-3"),e("analysis-derive-structures-4"),e("analysis-derive-structures-5"),e("analysis-derive-structures-6"),e("analysis-derive-structures-7"),e("analysis-derive-structures-8")].join(`
|
|
3
3
|
`),m=e("analysis-derive-structures-10");function c(n){return n.map(o=>({unit:JSON.stringify(o.unitKey),kind:o.kind,name:JSON.stringify(o.name),location:JSON.stringify(`${o.sourcePath}:${o.sourceLine}${o.sourceEndLine?`\u2013${o.sourceEndLine}`:""}`)}))}function s(n){return e("code-finding-note",{codeSources:c(n)})}return{RULE:r,SPLIT_SCOPE_RULE:i,SUB_KIND_DEFS:a,STRUCTURE_SCOPE_RULE:m,codeSourceLabels:c,codeFindingNote:s}}import{posix as W}from"node:path";function V(t){let{bundleText:e}=t,r=.25,i=4;function a(c){let s=new Set(c.map(l=>l.name)),n=new Map(c.map(l=>[l.name,new Set(l.skills.filter(d=>d!==l.name&&s.has(d)))])),o=new Map;for(let l of n.values())for(let d of l)o.set(d,(o.get(d)??0)+1);let p=Math.max(i,(c.length-1)*r);return c.map(l=>({name:l.name,linkedFrom:o.get(l.name)??0,linksTo:n.get(l.name).size})).filter(l=>l.linkedFrom>=p||l.linksTo>=p)}function m(c){let s=a(c);if(!s.length)return null;let n=s.map(o=>e("shape-shared-skill",o));return e("analysis-split-check-shared-skills-1",{v0:n.join(`
|
|
4
4
|
`)})}return{sharedSkillsOf:a,sharedSkillsText:m}}function Q(t){let{bundleText:e}=t,{shapeFindingsText:r}=J(t),{sharedSkillsText:i}=V(t);function a(c){let s=new Map(c.map((n,o)=>[n.name,`s${o+1}`]));return e("shape-skills",{skills:c.map(n=>({...n,id:s.get(n.name),refs:n.references.map(o=>W.relative(W.dirname(n.path),o)).join(","),tools:n.tools.join(","),links:n.skills.map(o=>s.get(o)).join(","),hasRefs:n.references.length>0,hasTools:n.tools.length>0,hasLinks:n.skills.length>0,hasDetails:n.references.length>0||n.tools.length>0||n.skills.length>0}))})}function m(c){return e("shape-inventory",{agent:c.agent,v0:a(c.skills),shared:i(c.skills),tools:c.tools.map(s=>({...s,skills:s.skills.join(", ")})),subAgents:c.subAgents.map(s=>({...s,tools:s.tools.join(", "),skills:a(s.skills)})),prompts:c.prompts,knowledge:c.knowledge.map(s=>({...s,headings:s.sections.map(n=>`${n.startLine}-${n.endLine} ${n.heading}`).join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as se,b as ne,c as ie,d as X,e as y}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(),T=r.nullable(),h=i.number().int().nonnegative().safe(),U=i.number().int().positive().safe(),re=i.strictObject({path:r.optional(),startLine:U,endLine:U}),P=i.number(),oe=i.strictObject({subKind:i.enum(["split_monolith","single_source","fold_patches","extract_subagent","merge_subagents","move_rule","move_tool","reorder"]),kind:se,severity:ne,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:T,purpose:r,frontmatter:i.strictObject({name:r,description:r,tools:i.array(r)}).nullable()})),segments:i.array(i.strictObject({path:r,startLine:P,endLine:P,to:r,disposition:i.enum(["move","fold_into","remove_duplicate","remove_superseded"]),into:i.strictObject({path:r,line:P}).nullable(),childRef:T,heading:T,reason:r})),additions:i.array(i.strictObject({path:r,text:r,kind:i.enum(["pointer","handoff","reference_update"]),heading:T})),reorder:i.strictObject({path:r,startLine:P,endLine:P,steps:i.array(i.strictObject({from:U,reason:T}))}).nullable(),toolMoves:i.array(i.strictObject({tool:r,fromUnit:r,toUnit:r,reason:r,fromPath:T,toPath:T})),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()}),Re=i.strictObject({nodes:i.array(X.shape.nodes.element.extend({change:i.enum(["added","edited","removed"]),label:T.optional()})),edges:i.array(X.shape.edges.element.extend({kind:i.enum(["invokes","delegates","reads","writes","emits"]),change:i.enum(["added","edited","removed"]),detail:T.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:h})),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:Re,...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"]),Se=i.strictObject({fromProposal:h,fromRulesOnly:h,rejected:h,rejectedByReason:i.partialRecord(Z,h)}),ye=i.strictObject({repoKey:r,findings:i.array(y),structures:i.array(v),warnings:i.array(r),proposalCounts:Se.optional(),refusedFiles:i.array(i.strictObject({path:r,reason:K}))});function ce(e){return{nodes:e.nodes.map(({id:s,change:n,label:o})=>({id:s,change:n,...o===void 0?{}:{label:o}})),edges:e.edges.map(({from:s,to:n,kind:o,change:c,detail:a})=>({from:s,to:n,kind:o,change:c,...a===void 0?{}:{detail:a}}))}}function le(e,s=n=>n){let{kind:n,severity:o,title:c,cause:a,summary:C,category:p,question:E,excerpt:F}=e;return{kind:n,severity:o,title:c,cause:a,summary:C,category:p,question:E,excerpt:F,...e.activity===void 0?{}:{activity:te.parse(e.activity)},siteRepo:s(e.siteRepo),site:e.site&&{path:e.site.path,line:e.site.line},otherSites:e.otherSites.map(({repo:O,path:I,line:m,excerpt:f})=>({repo:s(O),path:I,line:m,excerpt:f})),fixes:e.fixes.map(({title:O,approach:I,kind:m,targetFiles:f,expectedOutcome:A,summary:j,impact:D,confidence:g,objective:x,status:M,blockedBy:G,alsoFixes:N,delta:L})=>({title:O,approach:I,kind:m,targetFiles:f.map(({path:k,create:B})=>({path:k,create:B})),expectedOutcome:A,summary:j,impact:D,confidence:g,objective:x,status:M,blockedBy:G,alsoFixes:N&&N.slice(),delta:L&&ce(L)})),...e.sourceNotes===void 0?{}:{sourceNotes:e.sourceNotes&&{sites:e.sourceNotes.sites.map(({index:O,role:I,meaning:m,keyPhrase:f})=>({index:O,role:I,meaning:m,keyPhrase:f})),support:e.sourceNotes.support,supportNote:e.sourceNotes.supportNote,counterEvidence:e.sourceNotes.counterEvidence.map(({repo:O,path:I,line:m,excerpt:f,meaning:A})=>({repo:s(O),path:I,line:m,excerpt:f,meaning:A}))}}}}function _e(e){return{...e.headline===void 0?{}:{headline:e.headline},...e.ifLeft===void 0?{}:{ifLeft:e.ifLeft}}}function be(e){let s=e.body;return{repo:e.repo,children:e.children.map(({ref:n,how:o})=>({ref:n,how:o})),sourceHashes:Object.fromEntries(Object.entries(e.sourceHashes)),body:{subKind:s.subKind,kind:s.kind,severity:s.severity,title:s.title,cause:s.cause,...s.summary===void 0?{}:{summary:s.summary},evidence:s.evidence.map(({path:n,line:o,excerpt:c})=>({path:n,line:o,excerpt:c})),files:s.files.map(({path:n,action:o,role:c,unit:a,loadMode:C,loadVia:p,purpose:E,frontmatter:F})=>({path:n,action:o,role:c,unit:a,loadMode:C,loadVia:p,purpose:E,frontmatter:F&&{name:F.name,description:F.description,tools:F.tools.slice()}})),segments:s.segments.map(({path:n,startLine:o,endLine:c,to:a,disposition:C,into:p,childRef:E,heading:F,reason:O})=>({path:n,startLine:o,endLine:c,to:a,disposition:C,into:p&&{path:p.path,line:p.line},childRef:E,heading:F,reason:O})),additions:s.additions.map(({path:n,text:o,kind:c,heading:a})=>({path:n,text:o,kind:c,heading:a})),reorder:s.reorder&&{path:s.reorder.path,startLine:s.reorder.startLine,endLine:s.reorder.endLine,steps:s.reorder.steps.map(({from:n,reason:o})=>({from:n,reason:o}))},toolMoves:s.toolMoves.map(({tool:n,fromUnit:o,toUnit:c,reason:a,fromPath:C,toPath:p})=>({tool:n,fromUnit:o,toUnit:c,reason:a,fromPath:C,toPath:p})),...s.motivation===void 0?{}:{motivation:s.motivation.map(({kind:n,reason:o,evidence:c})=>({kind:n,reason:o,evidence:c}))},...s.outcomes===void 0?{}:{outcomes:s.outcomes.map(({improvement:n,measurement:o})=>({improvement:n,measurement:o}))},...s.split===void 0?{}:{split:{...s.split.root===void 0?{}:{root:s.split.root},frontDoor:{...s.split.frontDoor.name===void 0?{}:{name:s.split.frontDoor.name},job:s.split.frontDoor.job,skills:s.split.frontDoor.skills.slice()},subAgents:s.split.subAgents.map(n=>({name:n.name,job:n.job,description:n.description,path:n.path,...n.handoff===void 0?{}:{handoff:n.handoff},...n.resolves===void 0?{}:{resolves:n.resolves.slice()},skills:n.skills.map(({name:o,from:c,to:a})=>({name:o,from:c,to:a})),tools:n.tools.slice(),...n.noTools===void 0?{}:{noTools:n.noTools},movedKnowledge:n.movedKnowledge.map(ae),neededKnowledge:n.neededKnowledge.map(ae)}))}}},delta:{...ce(e.delta),files:e.delta.files.map(({path:n,role:o,node:c,change:a,fromNode:C,fromPath:p,segments:E})=>({path:n,role:o,node:c,change:a,segments:E,...C===void 0?{}:{fromNode:C},...p===void 0?{}:{fromPath:p}})),tools:e.delta.tools.map(({label:n,fromNode:o,toNode:c})=>({label:n,fromNode:o,toNode:c}))},..._e(e)}}function ae({path:e,startLine:s,endLine:n}){return{...e===void 0?{}:{path:e},startLine:s,endLine:n}}function Ae(e,s){return{repoKey:e.repoKey,findings:e.findings.map(n=>({...le(n),..._e(n),...n.audience===void 0?{}:{audience:n.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(n=>e.proposalCounts.rejectedByReason[n]!==void 0).map(n=>[n,e.proposalCounts.rejectedByReason[n]]))}}:{},refusedFiles:s.map(({path:n,reason:o})=>({path:n,reason:o}))}}function Ne(e){if(e.redacted)throw new Error("Relay refused the request: leak_refused");return e.answer}import{z as S}from"zod";var b=1,de=S.string().min(1).max(128),$=["file_reads","repository_listing","sealed_delivery"],Q=S.strictObject({protocol:S.literal(b),bundleVersion:de,engineVersion:de,capabilities:S.array(S.enum($)).refine(e=>e.length===$.length&&new Set(e).size===$.length)}),Y=2;function pe(){return S.strictObject({...Q.shape,protocol:S.literal(Y)}).refine(e=>Q.safeParse({...e,protocol:b}).success)}var Ce=Object.freeze(["CF_HISTORY_CONTEXT","CF_REPOSITORY_PROJECTS","CF_REQUEST_FRAME_BUDGET","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_SCAN_PRIORITY","CF_CODE_PROMPT_LOADERS","CF_CODE_PROMPT_FUNCTIONS","CF_CODE_PROMPT_SENT","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_PYTHON_SRC_IMPORTS","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"]),J=Ce.filter(e=>e!=="CF_REQUEST_FRAME_BUDGET"&&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_HISTORY_CONTEXT"&&e!=="CF_REPOSITORY_PROJECTS"&&e!=="CF_CODE_SCAN_PRIORITY"&&e!=="CF_CODE_PROMPT_SENT"&&e!=="CF_PYTHON_SRC_IMPORTS"&&e!=="CF_MULTI_ENTRY"),Oe=J.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,s="request"){return Object.freeze(Object.fromEntries((s==="saved"?Ce:s==="engine"?J: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(J),t.string()),u=t.string(),_=t.number().int().nonnegative().safe(),R=t.number().int().positive().safe(),z=t.enum(["bad_request","unavailable","reservation","leak_refused","cancelled"]);function nt(e){let s=z.safeParse(e);return s.success?s.data:"unavailable"}function it(e){return Object.assign(new Error(e),{code:e})}var Le=1024*1024,ue=u.min(1).max(128),H=u.regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/),q=u.regex(/^[a-f0-9]{64}$/),d={protocol:t.literal(b),analysisId:t.uuid(),nonce:u.min(16).max(256),bundleVersion:ue,engineVersion:ue};function l(e){return t.unknown().refine(s=>{try{let n=JSON.stringify(s);return typeof n=="string"&&new TextEncoder().encode(n).byteLength<=Le}catch{return!1}}).pipe(e)}var Pe=u.min(1).refine(e=>!/[\\\0\r\n]/.test(e)&&!/^(?:\/|[a-zA-Z]:)/.test(e)&&e.split("/").every(s=>s!==""&&s!=="."&&s!=="..")),he=t.strictObject({id:H,path:Pe,size:_,hash:q}),W=t.array(he).refine(e=>new Set(e.map(s=>s.id)).size===e.length&&new Set(e.map(s=>s.path)).size===e.length),ee=t.strictObject({snapshot:q,commit:u.regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),files:W,entriesVisited:_.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({...d,settings:Ee,manifest:ee})),ot=t.strictObject(d),je=t.strictObject({startByte:_,endByte:_}).refine(e=>e.endByte>e.startByte),De=t.strictObject({startLine:R,endLine:R}).refine(e=>e.endLine>=e.startLine),Fe=l(t.strictObject({...d,type:t.literal("need_files"),sequence:_,reads:t.array(t.strictObject({id:H,range:t.union([je,De])})).min(1)})),Ie=l(t.strictObject({...d,type:t.literal("need_listing"),sequence:_,cursor:u.min(1).max(256).nullable()})),ge=l(t.discriminatedUnion("type",[t.strictObject({...d,type:t.literal("files"),sequence:_,files:t.array(t.union([t.strictObject({id:H,startByte:_,text:u,complete:t.boolean(),hash:q}),t.strictObject({id:H,refused:K})])).min(1)}),t.strictObject({...d,type:t.literal("listing"),sequence:_,manifest:ee}),t.strictObject({...d,type:t.literal("reservation"),sequence:_,reservationId:t.uuid(),reservationToken:u.min(1).max(256)}),t.strictObject({...d,type:t.literal("delivery"),sequence:_,callId:t.uuid(),attemptId:t.uuid().nullable()}),t.strictObject({...d,type:t.literal("chunk"),sequence:_,callId:t.uuid(),attemptId:t.uuid(),chunk:R})])),w={chunk:_,chunks:R},xe=t.strictObject({...d,type:t.literal("result"),finalFiles:W,findings:t.array(y),structures:t.array(v),notices:t.array(u)}),Me=l(xe.extend(w).refine(e=>e.chunk<e.chunks)),Ge=l(t.strictObject({...d,type:t.literal("result_chunk"),...w,text:u,hash:q}).refine(e=>e.chunk<e.chunks)),me=l(t.strictObject({...d,type:t.literal("call_failed"),sequence:_,callId:t.uuid(),attemptId:t.uuid().nullable(),code:z}));function ke(e){let s=l(t.strictObject({...d,type:t.literal("plan"),sequence:_,...w,plan:e.plan,finalFiles:W}).refine(a=>a.chunk<a.chunks)),n=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({...d,type:t.literal("sealed_delivery"),sequence:_,callId:t.uuid(),attemptId:t.uuid(),algorithm:t.literal("AES-256-GCM"),iv:n.length(16),...w,ciphertext:n,tag:u.regex(/^[A-Za-z0-9+/]{21}[AQgw]==$/).length(24).optional(),delivery:t.strictObject({confirmation:e.deliveryConfirmation,deadlineMs:R}).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({...d,type:t.literal("refused"),code:z});return{plan:s,sealedDelivery:o,response:t.union([Fe,Ie,s,o,me,Me,Ge,c])}}var at=t.strictObject({version:t.literal(1),serializedBytes:R,freeTextUtf8Bytes:R,fields:t.array(t.strictObject({pointer:u.regex(/^(?:\/(?:[^~/]|~[01])*)+$/),kind:t.enum(["string","array"]),max:R}))});function ct(e){let s={...d,protocol:t.literal(Y)},n=e.context,o=l(t.strictObject({...s,settings:Ee,context:n.preparationContext,manifest:ee})),c=t.strictObject(s),a=l(t.union([...ge.out.options.map(V=>V.extend(s)),t.strictObject({...s,type:t.literal("next"),sequence:_,stream:t.enum(["plan","result"]),chunk:R})])),C=t.strictObject({kind:t.literal("ready"),plan:e.plan,finalFiles:n.finalFiles,analysisSize:n.analysisSize,membership:n.membership}),p=t.strictObject({kind:t.literal("agent_choice"),choice:e.choice}),E=t.strictObject({kind:t.literal("proposal_refused")}),F=t.union([C,p,E]),O=t.strictObject({finalFiles:n.finalFiles,report:e.report,membership:n.membership}),I=O.extend({...s,type:t.literal("result")}),m=l(t.strictObject({...s,type:t.literal("plan"),sequence:_,plan:e.plan,finalFiles:n.finalFiles,analysisSize:n.analysisSize,membership:n.membership})),f=e.planChunks,A=e.resultChunks,j=l(f.chunk.safeExtend({...s,type:t.literal("plan_chunk"),sequence:_,stream:t.literal("plan")})),D=l(A.chunk.safeExtend({...s,type:t.literal("result_chunk"),sequence:_,stream:t.literal("result")})),g=ke(e),x=l(t.strictObject({...g.sealedDelivery.out.shape,...s}).refine(V=>g.sealedDelivery.safeParse({...V,protocol:b}).success)),M=l(Fe.out.extend(s)),G=l(Ie.out.extend(s)),N=l(me.out.extend(s)),L=t.strictObject({...s,type:t.literal("refused"),code:z}),k=t.strictObject({...s,type:t.literal("cancelled")}),B=l(t.union([M,G,m,x,N,l(I),j,D,L,k,t.strictObject({...s,type:t.literal("agent_choice"),choice:e.choice}),t.strictObject({...s,type:t.literal("proposal_refused")})])),fe=t.union([O.extend({kind:t.literal("result")}),p,E]),Te=pe();return{start:o,cancel:c,advance:a,needFiles:M,needListing:G,ready:C,preparationOutcome:F,resultBody:O,finalResult:I,plan:m,planChunk:j,resultChunk:D,sealedDelivery:x,callFailure:N,refused:L,cancelled:k,response:B,clientOutcome:fe,capabilities:Te}}export{v as a,ye as b,le as c,Ae as d,Ne as e,b as f,Q as g,Y as h,Ce as i,et as j,tt as k,Ee as l,z as m,nt as n,it as o,Le as p,he as q,ee as r,rt as s,ot as t,Fe as u,Ie as v,ge as w,xe as x,Me as y,Ge as z,me as A,ke as B,at as C,ct as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as p,e as o,h as a}from"./
|
|
1
|
+
import{d as p,e as o,h as a}from"./YDSB7UOR.js";var s=new Set(["check-findings","check-findings-precision-v1","second-opinion"]);function l(t,n,r=p){let e=t.CF_PROMPT_CACHE!=="0",i="template"in n?s.has(n.template)?[0]:[]:(n.promptBlocks??[]).flatMap((u,h)=>u.cache?[h]:[]),c=e&&i.length>0?"5m":null;return{enabled:e,breakpoints:i,ttl:c,inputMultiplier:c===null?1:o(r,c)}}function f(t,n){for(let e of n)if(!Number.isInteger(e)||e<0||e>=t.length)throw new RangeError("Invalid cache breakpoint index");let r=new Set(n);return t.map((e,i)=>({text:e.text,...r.has(i)?{cache:!0}:{}}))}function d(t,n,r,e,i,c){return a(r,e,i,c,l(t,n,e).inputMultiplier)}function x(t){return o(t,"1h")}function C(t){return l(t,{}).enabled}export{l as a,f as b,d as c,x as d,C as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as u}from"./724WZMYW.js";import{a as i}from"./JS6HTVYX.js";function $(t){return t.skippedFiles??(t.notRead??[]).map(({path:e,kind:n})=>({path:e,reason:n==="prompt-too-large"?"too-large":"allowance"}))}function f(...t){let e={"secret-content":-7,secret:-6,hidden:-5,excluded:-4,"wrong-type":-3,empty:-2,"out-of-scope":-1,"too-large":0,allowance:1,"tool-limit":2,"scan-limit":3,total:4,unreadable:5,missing:6},n=new Map;for(let r of t)for(let o of r??[]){let s=n.get(o.path);(!s||e[o.reason]<e[s.reason])&&n.set(o.path,o)}return[...n.values()]}function d(t,e=0){let n=f(t),r=(...a)=>n.filter(({reason:m})=>a.includes(m)).length,o=n.filter(a=>a.reason==="secret-content").map(a=>u(a.path)),s=r("too-large"),l=r("allowance","tool-limit"),c=r("total","scan-limit"),p=r("missing","unreadable");return s&&o.push(`${s} ${i(s,"file was","files were")} too big to read.`),l&&o.push(`${l} ${i(l,"file wasn't","files weren't")} read because the file allowance was reached.`),c&&o.push(`${c} ${i(c,"file wasn't","files weren't")} read because the repository is large.`),p&&o.push(`${p} ${i(p,"file couldn't","files couldn't")} be read, so some tools may be missing.`),e>0&&o.push(`${e} more ${i(e,"file wasn't","files weren't")} read.`),o}function F(t,e){return e?[...t.filter(r=>{let o=/^(\d+) more (?:file wasn't|files weren't) read\.$/.exec(r);return o?(e+=Number(o[1]),!1):!0}),...d([],e)]:[...t]}var b="Analyze them separately?";function g(t){return f(t).filter(e=>["too-large","total","allowance","scan-limit","tool-limit"].includes(e.reason))}function x(t){let e=g(t).length;return e?`${e} ${i(e,"file was","files were")} too large to read, so findings in ${i(e,"it","them")} may be missing.`:void 0}function y(t,e){return f(t,e.map(n=>({path:n,reason:"total"})))}export{$ as a,f as b,d as c,F as d,b as e,g as f,x as g,y as h};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{J as ct,K as pt,d as rt,h as at,j as lt,k as it,m as ft,r as re}from"./FRXOQ2M6.js";import{b as st}from"./33IGHOYT.js";import{e as te,g as Ce}from"./YTHF2E2S.js";import{a as W,b as he,c as Qe,e as He,f as Ze,g as et,h as tt,i as ge,j as ot,k as nt,n as V}from"./4PT5C4IT.js";import{Fb as _,K as Ie,X,a as Me,aa as ze,b as je,ba as ue,ca as Ge,d as de,db as Q,e as K,f as Ae,fb as se,g as Ee,h as oe,i as I,k as _e,ka as Ke,kb as De,l as Ne,la as qe,lb as Ue,mb as Ye,n as Te,na as Je,nb as Ve,r as Le,u as ne,wb as Xe,za as J}from"./2AASSZRO.js";import{b as G,c as L}from"./C6X5GDG4.js";import{a as Re,b as R,c as B,k as z,l as q,v as Be}from"./YWL52FVW.js";import{a as Fe,f as We}from"./SJESFYBA.js";function ye(e,t,n){if(!oe(e)||!t.filenameReferences?.length)return n;let f=n.agents.flatMap(l=>l.prompt.kind==="dedicated"?[{path:l.prompt.path}]:[]),i=Ge(t.filenameReferences,f);return{...n,agents:n.agents.map(l=>{if(l.prompt.kind!=="dedicated")return l;let m=l.prompt.path,p=i.filter(d=>d.promptPath===m&&!l.files.some(y=>y.path===d.readerPath)&&_(e,{path:d.readerPath},{purpose:"override",route:"github",root:t.root}).admitted);return p.length?{...l,files:[...l.files,...p.map(d=>({path:d.readerPath,role:"reference",label:"prompt filename reference"}))]}:l})}}function D(e,t,n){return e.filter(f=>t.some(i=>i.includes(n(f))))}function mt(e,t,n){if(!e.length||n&&!I(n.settings))return;let f;if(n&&!K(n.settings)){let i=Object.keys(n.files).filter(p=>L(p,n.root)!==null&&_(n.settings,{path:p},{purpose:"override",route:"github",root:n.root}).admitted),l=i.filter(p=>Me(L(p,n.root))).sort((p,d)=>je(L(p,n.root),L(d,n.root)));if(!l.length)return;let m=D(i.filter(p=>!l.includes(p)&&J(p)).sort(),l.map(p=>n.files[p]),p=>L(p,n.root));f=[...l.map(p=>({path:p,role:"reference",label:"developer guidance"})),...m.map(p=>({path:p,role:"reference",label:null}))]}else{if(!t||t.prompt.kind!=="fallback")return;let i=t.prompt.path;if(e.some(l=>l.files.some(m=>m.path===i)))return;f=t.files.map(l=>({...l,role:"reference",label:l.role==="system prompt"?"developer guidance":l.label}))}f=f.filter(i=>!e.some(l=>l.files.some(m=>m.path===i.path))),f.length&&(e[0]={...e[0],files:[...e[0].files,...f],sharedReferencePaths:[...e[0].sharedReferencePaths??[],...f.map(i=>i.path)]})}function ke(e,t){return["[","{"].some(n=>R(e.source.toks[t.from],n))&&z(e.source.toks,t.from)===t.to?{...t,to:t.to+1}:e.calls.find(n=>n.from===t.from&&n.to===t.to+1&&R(e.source.toks[t.to],")"))??t}function N(e,t,n=new Set){let{toks:f}=e.source;if(t.to!==t.from+1||!B(f[t.from])||["True","False","None"].includes(f[t.from].text))return t;let i=e.binding(f[t.from].text,t.from);return!i||i.append||!e.bindingIsCertain(i,t.from)||n.has(i.at)||e.functions.some(l=>l.from<t.from&&t.from<l.to&&l.params?.includes(i.name))?null:N(e,ke(e,i),new Set([...n,i.at]))}import{posix as dt}from"node:path";function ut(e,t,n,f,i){let{source:{path:l,toks:m}}=e,p=[],d=[],y=[],a=[],k=(u,o)=>a.push({path:u,reason:o}),c=(u,o,b,S=null)=>({path:o,role:u,label:S,...b?{span:b}:{}}),r=(u,o)=>{let b=e.importBinding(u,o),S=t.filter(g=>g.name===u&&g.from<o&&(g.params!==null||g.kind==="class")&&(!e.owner(g.from)||e.owner(g.from)===e.owner(o)));if(!b)return S.length===1?{path:l,span:{from:m[S[0].from].line,to:m[S[0].to-1].endLine}}:null;let x=b.module.source,O=i.length===1?dt.dirname(dt.dirname(i[0])):"",s=We(x.startsWith(".")?l:`${O?`${O}/`:""}__root__.py`,x.startsWith(".")?x:`.${x}`,[b.name],"py",f);return s?{path:s}:null},h=n&&N(e,n);if(h&&R(m[h.from],"[")&&z(m,h.from)===h.to-1)for(let u of q(m,h.from)){let o=u.to===u.from+1&&B(m[u.from])&&!e.binding(m[u.from].text,u.from)?u:N(e,u);if(!o||!B(m[o.from])){k(l,"dynamic");continue}let b=m[o.from].text;if(!(o.to===o.from+1||R(m[o.from+1],"(")&&z(m,o.from+1)===o.to-1)){k(l,"dynamic");continue}if(e.functions.some(O=>O.from<o.from&&o.from<O.to&&O.params?.includes(b))){k(l,"dynamic");continue}if(!e.importBinding(b,o.from)&&!t.some(O=>O.name===b&&(O.params!==null||O.kind==="class")&&O.from<o.from)){k(l,"dynamic");continue}p.push(b);let x=r(b,o.from);x&&(y.push(c("tools",x.path,x.span,b)),d.push(x.path))}else n&&k(l,"dynamic");return{names:p,files:y,proofPaths:d,refused:a}}function ht(e,t,n,f,i,l){let m=t.source,{path:p,toks:d}=m,{files:y,paths:a,frameworks:k,defaultsByPath:c}=l,r={prompt:{kind:"none"},files:[]},h=[],u,o=(s,g)=>h.push({path:s,reason:g}),b=(s,g,P,w=null)=>({path:g,role:s,label:w,...P?{span:P}:{}});c.has(p)||c.set(p,ge(p,m.text,a));let S=c.get(p),x=s=>{r.layoutProof??={kind:"outside-loader",paths:[]},r.layoutProof.paths.push(s);let g=y[s];if(g===void 0){r.files.push(b("template",s)),o(s,"missing");return}let P=tt(g,e);if(P.unresolved.length||!P.fields.some(w=>w.key==="system_prompt"&&w.value!==null)){o(s,"invalid");return}for(let w of P.fields.filter(v=>v.value!==null))r.files.push(b(w.key==="system_prompt"?"system prompt":"template",s,w.span,w.key)),w.key==="system_prompt"&&(r.prompt={kind:"entry",path:s,span:w.span,text:w.value})},O=n.get("prompt_templates")??n.get("system_prompt");if(O){let s=N(t,O),g=s&&X(m,s);if(g&&n.has("system_prompt"))r.prompt={kind:"entry",path:p,span:g.span,text:d[s.from].value},u={path:p,start:g.start},r.files.push(b("system prompt",p,g.span));else if(s&&R(d[s.from],"{")&&z(d,s.from)===s.to-1){let P=!1,w=(v,C="")=>{let $=new Set;for(let j of q(d,v.from)){let M=d[j.from]?.kind==="string"?d[j.from].value:null;if(!M||$.has(M)||!R(d[j.from+1],":")){o(p,"invalid"),P=!0;return}$.add(M);let A=N(t,{from:j.from+2,to:j.to}),T=A&&X(m,A);T?(r.files.push(b(M==="system_prompt"?"system prompt":"template",p,T.span,C+M)),M==="system_prompt"&&!C&&(r.prompt={kind:"entry",path:p,span:T.span,text:d[A.from].value},u={path:p,start:T.start})):A&&R(d[A.from],"{")?w(A,`${C}${M}.`):o(p,"dynamic")}};w(s),P&&(r.prompt={kind:"none"},r.files=[])}else{let P=s&&S.find(w=>w.start===d[s.from].start&&w.end===d[s.to-1].end);P?.path&&!P.reason?x(P.path):o(p,"dynamic")}}else if(f.args.some(s=>!B(d[s.from])||!R(d[s.from+1],"=")))o(p,"dynamic");else if(k.length===1){let s=k[0],g=y[s];if(g===void 0)r.files.push(b("config",s)),r.layoutProof={kind:"outside-loader",paths:[s]};else{c.has(s)||c.set(s,ge(s,g,a));let P=c.get(s).filter(M=>M.className===i&&M.binding==="prompt_templates"&&M.forwarded),w=n.get("use_structured_outputs_internally"),v=w?N(t,w):null,C=v&&v.to===v.from+1&&["True","False"].includes(d[v.from].text)?d[v.from].text==="True":null,$=P.filter(M=>M.when?.every(A=>A.parameter==="use_structured_outputs_internally"&&A.value===(w?C:A.defaultValue))),j=$.length===1?$[0]:null;j?.path&&(!j.reason||j.reason==="missing")?x(j.path):o(s,"dynamic")}}else o(p,k.length>1?"dynamic":"missing");return{...r,promptSite:u,refused:h}}function gt(e,t,n=t.files){let f={agents:[],refused:[]};if(!I(e))return f;let i={...n,...t.files},l=new Set([...Object.keys(i),...t.listedPaths??[]]),m=new Set(Ke(e,[...l],t.root)),p=[...l].filter(a=>/(?:^|\/)smolagents\/agents\.py$/.test(a)),d=new Map,y=(a,k)=>f.refused.push({path:a,reason:k});for(let[a,k]of Object.entries(t.files)){if(!k.includes("smolagents")||Le(a,{listing:l,root:t.root})&&!Te(e,a,t.root)||!/\.py$/i.test(a)&&!m.has(a)||!_(e,{path:a,size:Buffer.byteLength(k)},{purpose:"code-scan",route:"github",root:t.root,listing:l}).admitted)continue;let c=m.has(a)?qe(a,k).filter(s=>s.lang==="py"):null,r=c?Je(k,c):k,h=Re(a,r,"py"),u=Be(h,{includeMembers:!0}),o=ze(h,u,{enclosingBindings:!0}),{toks:b}=h,S=[],x=s=>{let g=s&&N(o,s);return g&&X(h,g)?b[g.from].value:null},O=(s,g,P,w=null)=>({path:g,role:s,label:w,...P?{span:P}:{}});for(let s of o.calls){let g=o.importBinding(s.callee,s.from);if(!g||!["smolagents","smolagents.agents"].includes(g.module.source)||!["CodeAgent","ToolCallingAgent"].includes(g.name))continue;let P=new Map(s.args.flatMap(E=>B(b[E.from])&&R(b[E.from+1],"=")?[[b[E.from].text,{from:E.from+2,to:E.to}]]:[])),w=c?.find(E=>E.span.from<=b[s.from].line&&b[s.from].line<=E.span.to);if(w&&(g.module.line<w.span.from||w.span.to<g.module.line)){let E=P.get("managed_agents"),Y=E&&N(o,E);if(!(Y&&R(b[Y.from],"[")&&q(b,Y.from).some(me=>{let $e=N(o,me);return $e&&S.some(Bt=>Bt.at===$e.from)})))continue}let C=o.assignments.find(E=>E.from===s.from&&ke(o,E).to===s.to)?.name??`line-${b[s.from].line}`,$=`smolagents:${JSON.stringify([a,b[s.from].start])}`,j={from:b[s.from].line,to:b[s.to-1].endLine},M={key:$,name:x(P.get("name"))??C,model:null,description:x(P.get("description")),prompt:{kind:"none"},files:[],skills:[],tools:[],subagents:[],layoutCall:{path:a,callStart:b[s.from].start,line:j.from,loadedPrompt:!0}},A=ht(e,o,P,s,g.name,{files:i,paths:l,frameworks:p,defaultsByPath:d});M.prompt=A.prompt,M.files.push(...A.files),A.layoutProof&&(M.layoutProof=A.layoutProof),A.promptSite&&(M.layoutCall.promptPath=A.promptSite.path,M.layoutCall.promptStart=A.promptSite.start),f.refused.push(...A.refused),M.files.push(O(c?"system prompt":"config",a,j));let T=ut(o,u,P.get("tools"),l,p);M.tools=T.names,M.files.push(...T.files),T.proofPaths.length&&(M.layoutProof??={kind:"outside-loader",paths:[]},M.layoutProof.paths.push(...T.proofPaths)),f.refused.push(...T.refused),f.agents.push(M),S.push({agent:M,name:C,at:s.from,children:P.get("managed_agents")})}for(let s of S){if(!s.children)continue;let g=N(o,s.children);if(!g||!R(b[g.from],"[")||z(b,g.from)!==g.to-1){y(a,"dynamic");continue}for(let P of q(b,g.from)){let w=N(o,P),v=w&&S.find($=>$.at===w.from&&w.to===o.calls.find(j=>j.from===$.at)?.to);if(!v||v===s){y(a,"dynamic");continue}let C=v.agent.prompt;s.agent.subagents.push({key:v.agent.key,path:C.kind==="none"?a:C.path,name:v.agent.name,description:v.agent.description,prompt:C.kind==="entry"?C.text:"",tools:v.agent.tools,skillPaths:[],files:v.agent.files})}}}return f}import{basename as Dt}from"node:path";import{basename as Kt}from"node:path";var kt=/^[\w.*:/()-]+$/,bt=/^(?:true|false|null|~|[-+]?(?:\d[\d_.eExXoObB+-]*|\.\d[\d_eE+-]*|\.inf|\.nan)|\d{4}-\d{1,2}-\d{1,2}(?:[Tt].*)?)$/i,le=e=>kt.test(e)&&!e.startsWith("*")&&!bt.test(e);function ae(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e}return e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function Z(e,t=!1,n=!1){let f=[],i="",l=0,m=-1,p=0,d=()=>{m>=0&&f.push([m,p]),m=-1};for(let y=0;y<e.length;y++){let a=e[y];if(i){i==='"'&&a==="\\"?y++:a===i&&(i==="'"&&e[y+1]==="'"?y++:i=""),p=y+1;continue}if(!n&&a==="#"&&(y===0||/\s/.test(e[y-1]))){if(!t)return d(),{spans:f,end:y,comment:e.slice(y)};let k=e.indexOf(`
|
|
2
|
-
`,y);y=k<0?e.length:k;continue}if(t&&a==="]"&&l===0)return d(),{spans:f,end:y,comment:""};if(a===","&&l===0){d();continue}/\s/.test(a)||(m<0&&(m=y),(a==='"'||a==="'")&&(m===y||l>0)?i=a:a==="("?l++:a===")"&&l>0&&l--,p=y+1)}if(t)throw new Error("Unclosed frontmatter tool list");return d(),{spans:f,end:e.length,comment:""}}function
|
|
1
|
+
import{J as pt,K as mt,d as at,h as lt,j as it,k as ft,m as ct,r as re}from"./6E4K7JTI.js";import{b as rt}from"./JCVB6IC4.js";import{a as W,b as ge,c as He,e as Ze,f as et,g as tt,h as ot,i as ye,j as nt,k as st,n as V}from"./AIS3FHQR.js";import{Fb as _,K as We,X,a as je,aa as Ge,b as Ae,ba as he,d as ue,da as Ke,db as Q,e as K,f as Ee,fb as se,g as Fe,h as oe,i as I,k as Ne,kb as Ue,l as Te,la as qe,lb as Ye,ma as Je,mb as Ve,n as Le,nb as Xe,oa as De,r as Ie,u as ne,wb as Qe,za as J}from"./QYYN4YKB.js";import{h as te,k as Me}from"./LOODGUMW.js";import{b as G,c as L}from"./C6X5GDG4.js";import{a as de}from"./JS6HTVYX.js";import{a as _e,b as R,c as B,k as z,l as q,v as ze}from"./EJ2IZUN2.js";import{b as Re,g as Be}from"./ICJV6KIZ.js";function ke(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=Ke(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 dt(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=>je(L(p,n.root))).sort((p,d)=>Ae(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 be(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,be(e,i),new Set([...n,i.at]))}import{posix as ut}from"node:path";function ht(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?ut.dirname(ut.dirname(i[0])):"",s=Be(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 gt(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,ye(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=ot(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,ye(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 yt(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(qe(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")||Ie(a,{listing:l,root:t.root})&&!Le(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)?Je(a,k).filter(s=>s.lang==="py"):null,r=c?De(k,c):k,h=_e(a,r,"py"),u=ze(h,{includeMembers:!0}),o=Ge(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 Ce=N(o,me);return Ce&&S.some(zt=>zt.at===Ce.from)})))continue}let C=o.assignments.find(E=>E.from===s.from&&be(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=gt(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=ht(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 Ut}from"node:path";import{basename as qt}from"node:path";var bt=/^[\w.*:/()-]+$/,Pt=/^(?:true|false|null|~|[-+]?(?:\d[\d_.eExXoObB+-]*|\.\d[\d_eE+-]*|\.inf|\.nan)|\d{4}-\d{1,2}-\d{1,2}(?:[Tt].*)?)$/i,le=e=>bt.test(e)&&!e.startsWith("*")&&!Pt.test(e);function ae(e){if(e.startsWith('"'))try{return JSON.parse(e)}catch{return e}return e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1).replace(/''/g,"'"):e}function Z(e,t=!1,n=!1){let f=[],i="",l=0,m=-1,p=0,d=()=>{m>=0&&f.push([m,p]),m=-1};for(let y=0;y<e.length;y++){let a=e[y];if(i){i==='"'&&a==="\\"?y++:a===i&&(i==="'"&&e[y+1]==="'"?y++:i=""),p=y+1;continue}if(!n&&a==="#"&&(y===0||/\s/.test(e[y-1]))){if(!t)return d(),{spans:f,end:y,comment:e.slice(y)};let k=e.indexOf(`
|
|
2
|
+
`,y);y=k<0?e.length:k;continue}if(t&&a==="]"&&l===0)return d(),{spans:f,end:y,comment:""};if(a===","&&l===0){d();continue}/\s/.test(a)||(m<0&&(m=y),(a==='"'||a==="'")&&(m===y||l>0)?i=a:a==="("?l++:a===")"&&l>0&&l--,p=y+1)}if(t)throw new Error("Unclosed frontmatter tool list");return d(),{spans:f,end:e.length,comment:""}}function kt(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(`
|
|
5
5
|
`)?`,
|
|
6
6
|
${m.match(/\n([^\S\n]*)/)[1]}`:", "),entries:y,first:t,last:t+e.slice(0,n?f.end+2:e.length).split(`
|
|
7
|
-
`).length-1,indent:" - ",blockComments:[]}}function
|
|
8
|
-
`).slice(d[1].length),p):a=
|
|
7
|
+
`).length-1,indent:" - ",blockComments:[]}}function Gt(e){let t=Q(e),n=t?.raw.map(p=>p.replace(/\r$/,""))??null,f=[],i=[],l={},m=[];if(n)for(let p=0;p<n.length;p++){let d=/^([A-Za-z_][\w-]*\s*:[^\S\n]*)(.*)$/.exec(n[p]);if(!d||!/^tools\s*:/i.test(d[1]))continue;let y=Z(d[2]),a;d[2].startsWith("[")?a=kt(n.slice(p).join(`
|
|
8
|
+
`).slice(d[1].length),p):a=kt(d[2],p),a.prefix=d[1];let k=a.style==="flow"?Z(a.suffix).comment:y.comment;if(k&&(l[a.style==="flow"?a.last:p]=k),a.style==="flow")for(let c of a.entries)c.note&&m.push({tool:c.name,comment:c.note.trim()});if(!d[2].slice(0,y.end).trim()){a.style="block",a.suffix=d[2];for(let c=p+1;c<n.length;c++){if(!n[c].trim()||/^\s*#/.test(n[c])){/^\s+#/.test(n[c])&&a.blockComments.push(c);continue}let r=/^(\s*-\s+)(.*)$/.exec(n[c]);if(!r)break;let h=Z(r[2]),u=r[2].slice(0,h.end).trimEnd(),o=ae(u);a.indent=r[1],o&&a.entries.push({name:o,raw:u,before:"",note:"",noteAfterComma:!1,row:n[c]}),h.comment&&o&&m.push({tool:o,comment:h.comment}),i.push(c),a.last=c}a.quote=a.entries.map(c=>c.raw).find(c=>/^["']/.test(c))?.[0]??""}for(let c=p;c<=(a.style==="block"?p:a.last);c++)i.push(c);f.push(a),p=a.last}return{header:t,lists:f,tools:f.length?f.flatMap(p=>p.entries.map(d=>d.name)):null,lines:n,toolLines:i,toolComments:l,itemComments:m}}function wt(e){try{return Gt(e)}catch{let t=Q(e);return{header:t,lists:[],tools:[],lines:t.raw.map(n=>n.replace(/\r$/,"")),toolLines:[],toolComments:{},itemComments:[],error:"Unclosed frontmatter tool list"}}}function Kt(e){let{tools:t,lines:n,toolLines:f,toolComments:i,itemComments:l,error:m}=wt(e);return{tools:t,lines:n,toolLines:f,toolComments:i,itemComments:l,...m?{error:m}:{}}}function St(e){let t=Kt(e);if(t.error)throw new Error(t.error);let{tools:n,lines:f,toolLines:i,toolComments:l,itemComments:m}=t;return{tools:n,lines:f,toolLines:i,toolComments:l,itemComments:m}}function ie(e){return e.every(t=>bt.test(t)&&!t.startsWith("*"))&&(e.length!==1||le(e[0]))?e.join(", "):`[${e.map(t=>JSON.stringify(t)).join(", ")}]`}function H(e,t){return t==="'"&&!/[\r\n]/.test(e)?`'${e.replace(/'/g,"''")}'`:t==='"'||!le(e)?JSON.stringify(e):e}function zo(e,t){let n=wt(e);if(n.error)return e;let f=n.tools??[],i=t([...f]);if(i.length===f.length&&i.every((h,u)=>h===f[u]))return e;if(!n.header){let h=e.startsWith("\uFEFF")?"\uFEFF":"";return`${h}---
|
|
9
9
|
tools: ${ie(i)}
|
|
10
10
|
---
|
|
11
|
-
${e.slice(h.length)}`}let{header:l,lists:m,toolLines:p,toolComments:d}=n,y=new Map,a=m[0];if(a){let h=m.flatMap(b=>b.entries),u=i.map(b=>{let S=h.findIndex(x=>x.name===b);return S<0?{name:b,raw:H(b,a.quote),before:a.separator,note:"",noteAfterComma:!1}:h.splice(S,1)[0]}),o=a.prefix.endsWith(" ")?a.prefix:`${a.prefix} `;if(!i.length)y.set(a.first,`${o}[]${a.style==="block"&&a.suffix?` ${a.suffix}`:a.suffix}`);else if(a.style==="block"){y.set(a.first,`${a.prefix}${a.suffix}`);let b=p.filter(S=>S>a.first&&S<=a.last).sort((S,x)=>S-x);for(let S=0;S<u.length;S++){let x=u[S],O=a.entries.includes(x)&&x.row?le(x.raw)||/^["']/.test(x.raw)?x.row:x.row.replace(x.raw,H(x.name,a.quote)):`${a.indent}${H(x.name,a.quote)}`,s=b[Math.min(S,b.length-1)]??a.first;y.set(s,`${y.has(s)?`${y.get(s)}${l.newline}`:""}${O}`)}}else{let b=a.style==="flow"||i.length===1&&
|
|
11
|
+
${e.slice(h.length)}`}let{header:l,lists:m,toolLines:p,toolComments:d}=n,y=new Map,a=m[0];if(a){let h=m.flatMap(b=>b.entries),u=i.map(b=>{let S=h.findIndex(x=>x.name===b);return S<0?{name:b,raw:H(b,a.quote),before:a.separator,note:"",noteAfterComma:!1}:h.splice(S,1)[0]}),o=a.prefix.endsWith(" ")?a.prefix:`${a.prefix} `;if(!i.length)y.set(a.first,`${o}[]${a.style==="block"&&a.suffix?` ${a.suffix}`:a.suffix}`);else if(a.style==="block"){y.set(a.first,`${a.prefix}${a.suffix}`);let b=p.filter(S=>S>a.first&&S<=a.last).sort((S,x)=>S-x);for(let S=0;S<u.length;S++){let x=u[S],O=a.entries.includes(x)&&x.row?le(x.raw)||/^["']/.test(x.raw)?x.row:x.row.replace(x.raw,H(x.name,a.quote)):`${a.indent}${H(x.name,a.quote)}`,s=b[Math.min(S,b.length-1)]??a.first;y.set(s,`${y.has(s)?`${y.get(s)}${l.newline}`:""}${O}`)}}else{let b=a.style==="flow"||i.length===1&&Pt.test(i[0])||i.some(s=>s.includes(",")||s!==s.trim()||/[\r\n]|(?:^|\s)#|:\s|^[[\]{}&*!|>'"%@`]/.test(s)),S=a.head;for(let[s,g]of u.entries()){if(s){let P=g.before||a.separator,w=u[s-1];w.note&&(w.noteAfterComma?(P=P.replace(/,[^\S\n]*/,`,${w.note}`),P.includes(`
|
|
12
12
|
`)||(P+=`
|
|
13
13
|
`)):P=`${w.note}${/^[^\S\n]*\n/.test(P)?"":`
|
|
14
14
|
`}${P}`),S+=P}S+=b?/^["']/.test(g.raw)||le(g.raw)?g.raw:H(g.name,a.quote):g.name}let x=u[u.length-1];x.note?(S+=x.noteAfterComma&&!a.tail.includes(",")?",":"",S+=x.noteAfterComma&&a.tail.includes(",")?a.tail.replace(",",`,${x.note}`):`${x.note}${a.tail}`,a.tail.includes(`
|
|
15
15
|
`)||(S+=`
|
|
16
16
|
`)):S+=a.tail;let O=b?`[${S}]`:a.outerQuote?H(S,a.outerQuote):S;y.set(a.first,`${a.prefix}${O}${a.suffix}`.replace(/\n/g,l.newline))}}let k=new Set(p),c=l.raw.map((h,u)=>y.has(u)?`${y.get(u)}${l.newline}`:k.has(u)?d[u]&&u>a.last?`${d[u]}${l.newline}`:"":`${!i.length&&m.some(b=>b.blockComments.includes(u))?h.trimStart():h}
|
|
17
|
-
`).join(""),r=a?"":`tools: ${ie(i)}${l.newline}`;return`${e.slice(0,l.start)}${c}${r}${e.slice(l.end)}`}function
|
|
18
|
-
`).trim()}else m=x;else S==="model"?p=x:S==="tools"&&!i&&(y=!0,d=x.replace(/^\[|\]$/g,"").split(",").map(O=>O.trim()).filter(Boolean))}}if(i)try{let h=
|
|
19
|
-
`)}function At(e,t,n={},f=Object.keys(t)){return I(n)?Vt(e,t,f):e.kind!=="crew"?{agents:[],notes:[],registry:!1}:Et(e,t)}function Et(e,t){let n=[],f=[],i=(p,d)=>f.push({code:"unreadable-crew",path:p,detail:d?`${d} could not be read; some instructions may be missing.`:"could not be read; some instructions may be missing."}),l=se(t[e.agentsPath]??""),m=e.tasksPath?se(t[e.tasksPath]??""):[];l?.length||i(e.agentsPath),m===null&&i(e.tasksPath);for(let{key:p,value:d,span:y}of l??[]){if(!U(d)){i(e.agentsPath,p);continue}let{llm:a,tools:k,...c}=d,r=we(c);if(r===null&&Object.keys(c).length){i(e.agentsPath,p);continue}let h=[{role:"system prompt",path:e.agentsPath,label:p,span:y}];for(let u of m??[])U(u.value)&&u.value.agent===p&&h.push({role:"knowledge",path:e.tasksPath,label:u.key,span:u.span});n.push({key:`${fe}${e.agentsPath}#${p}`,name:p,model:typeof a=="string"?a:null,description:typeof d.goal=="string"?d.goal:null,entry:{path:e.agentsPath,span:y,text:r},files:h,tools:Array.isArray(k)?[...new Set(k.filter(u=>typeof u=="string"&&!!u.trim()))]:[],skills:[],subagents:[]})}return{agents:n,notes:f,registry:!1}}function U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Vt(e,t,n){let f=new Set([...n,...Object.keys(t)]),i=Object.entries(t).filter(([r])=>r.endsWith(".py")).map(([r,h])=>nt(r,h,f,e.folder)),l=i.flatMap(r=>r.agents),m=i.flatMap(r=>r.refused);if(!l.length)return e.kind==="crew"&&/\.ya?ml$/i.test(e.agentsPath)?{...Et(e,t),refused:m}:{agents:[],notes:[],refused:m,registry:!1};let p=new Map,d=r=>{if(!p.has(r)){let h=t[r]===void 0?null:se(t[r]);p.set(r,h),h===null&&m.push({path:r,reason:t[r]===void 0?"missing":"invalid"})}return p.get(r)??[]},y=i.flatMap(r=>r.tasks).flatMap(r=>{let h=r.config?.path?d(r.config.path).find(b=>b.key===r.config.key):void 0;if(r.config&&(!r.config.path||!h||!U(h.value)))return r.config.path&&m.push({path:r.config.path,reason:h?"invalid":"missing"}),[];let u=U(h?.value)?h.value:{},o=r.factory.includes(".")?r.factory.slice(0,r.factory.lastIndexOf(".")):null;return[{fact:r,path:r.config?.path??r.path,key:r.config?.key??r.factory,span:h?.span??r.span,agent:r.agent??(typeof u.agent=="string"?o?`${o}.${u.agent}`:u.agent:null),context:[...r.context,...Array.isArray(u.context)?u.context.filter(b=>typeof b=="string"):[]],tools:r.tools}]}),a=i.flatMap(r=>r.tasks).filter(r=>r.config),k=a.flatMap(r=>r.config?.path?[{path:r.config.path,source:r.path,owner:r.factory.includes(".")?r.factory.slice(0,r.factory.lastIndexOf(".")):null}]:[]);!a.length&&e.kind==="crew"&&e.tasksPath&&k.push({path:e.tasksPath,source:e.tasksPath,owner:null});for(let{path:r,source:h,owner:u}of k)for(let o of d(r)){if(y.some(S=>S.path===r&&S.key===o.key&&S.fact.path===h&&(S.fact.factory.includes(".")?S.fact.factory.slice(0,S.fact.factory.lastIndexOf(".")):null)===u)||!U(o.value))continue;let b=o.value;y.push({fact:{path:h,factory:u?`${u}.${o.key}`:o.key,span:o.span,callStart:0,agent:null,context:[],tools:[]},path:r,key:o.key,span:o.span,agent:typeof b.agent=="string"?u?`${u}.${b.agent}`:b.agent:null,context:Array.isArray(b.context)?b.context.filter(S=>typeof S=="string"):[],tools:[]})}let c=[];for(let r of l){let h=r.config?.path?d(r.config.path).find(v=>v.key===r.config.key):void 0;if(r.config&&(!r.config.path||!h||!U(h.value))){r.config.path&&m.push({path:r.config.path,reason:h?"invalid":"missing"});continue}let u=U(h?.value)?h.value:{},o={...Object.fromEntries(Object.entries(u).filter(([v,C])=>!["llm","tools"].includes(v)&&typeof C=="string")),...r.instructions},b=we(o);if(!b){m.push({path:r.path,reason:"dynamic"});continue}let S=r.config?.key??r.factory.split(".").at(-1),x=r.config?.path??r.path,O=h?.span??r.span,s=[{path:x,role:"system prompt",label:S,span:O}];x!==r.path&&s.push({path:r.path,role:"config",label:r.factory,span:r.span});let g=y.filter(v=>v.fact.path===r.path?v.agent===r.factory||v.agent===S:/\.ya?ml$/i.test(v.fact.path)&&v.agent===S&&l.filter(C=>(C.config?.key??C.factory)===S).length===1),P=new Set,w=[...r.tools];for(let v=0;v<g.length;v++){let C=g[v];if(!P.has(C)&&(P.add(C),!(C.fact.config&&!C.fact.config.path))){s.push({path:C.path,role:"knowledge",label:C.key,span:C.span}),w.push(...C.tools);for(let $ of C.context){let j=y.filter(M=>M.fact.path===C.fact.path&&M.fact.factory===$||M.path===C.path&&M.key===$);j.length===1?g.push(j[0]):m.push({path:C.path,reason:j.length?"dynamic":"missing"})}}}for(let v of w)v.path&&v.path!==r.path&&!s.some(C=>C.path===v.path)&&(t[v.path]===void 0&&m.push({path:v.path,reason:"missing"}),s.push({path:v.path,role:"tools",label:v.name}));c.push({key:`${fe}${r.path}#${r.factory}`,name:S,model:typeof u.llm=="string"?u.llm:null,description:typeof o.goal=="string"?o.goal:null,entry:{path:x,span:O,text:b},files:s,tools:[...new Set([...w.map(v=>v.name),...Array.isArray(u.tools)?u.tools.filter(v=>typeof v=="string"):[]])],skills:[],subagents:[],crewCall:{path:r.path,callStart:r.callStart}})}return{agents:c,notes:[],refused:m,registry:!1}}import{basename as Ft,posix as ce}from"node:path";function Rt(e,t,n){let f={...t.selected,codeAgentsFound:t.codeAgentsFound||t.selected.codeAgentsFound};if(!Se(e,f,n))return{kind:"none"};let i={...t.bodies,...f.files},l=W(e,Object.keys(i),G(f.root)).templatePaths,m=ve(e,{...f,files:i},l);if(!t.entries)return{kind:"search",paths:[],ownedPaths:m.ownedPaths};let p=new Set([...Object.keys(i),...t.attemptedPaths??[]]),d=new Set(m.facts.dependencies);for(let h of m.relatedReads)h.target.kind==="file"&&d.add(h.target.path);for(let h of t.entries)m.relatedReads.some(u=>u.target.kind==="directory"&&pe(u,h.path))&&d.add(h.path);let y=(h,u)=>{let o=_(e,h,{purpose:u,route:"local-folder"});return o.admitted||o.reason==="too-large"},a=[...new Set(t.entries.filter(h=>!p.has(h.path)&&(d.has(h.path)?y(h,"pointer"):L(h.path,f.root)===null&&Fe(h.path)!==null&&y(h,"code-support"))).map(h=>h.path))],k=G(f.root)??"",c=h=>ce.parse(h).name===(k?Ft(k):f.fallbackName)?0:Xe.test(Ft(h))?1:2,r=h=>ce.relative(k||".",ce.dirname(h)).split("/").filter(u=>u&&u!==".").length;return a.sort((h,u)=>Number(d.has(u))-Number(d.has(h))||c(h)-c(u)||r(h)-r(u)||(h<u?-1:h>u?1:0)),{kind:"search",paths:a,ownedPaths:m.ownedPaths}}function pe(e,t){return e.target.kind==="file"?e.target.path===t:ce.dirname(t)===e.target.path&&(!e.target.extension||t.endsWith(e.target.extension))}function Se(e,t,n){if(!te(e)||t.codeAgentsFound||t.explicitPrompt!==void 0||n.agents.length||t.listedPaths&&W(e,[...t.listedPaths],G(t.root)).configPath)return null;let f=W(e,Object.keys(t.files),G(t.root)).templatePaths;if(!f.length)return null;let i=Object.fromEntries(Object.entries(t.files).filter(([l])=>L(l,t.root)!==null&&_(e,{path:l},{purpose:"override",route:"github"}).admitted));return ue(e,i).reads.some(l=>f.some(m=>pe(l,m)))?null:f}function ve(e,t,n){let f=Object.fromEntries(Object.entries(t.files).filter(([c])=>_(e,{path:c},{purpose:"override",route:"github"}).admitted)),i=ue(e,f),l=i.reads.filter(c=>L(c.sourcePath,t.root)===null&&n.some(r=>pe(c,r))),m=n.filter(c=>l.some(r=>pe(r,c))).sort(),p=[...new Set(l.map(c=>c.sourcePath))].sort(),d=i.reads.filter(c=>p.includes(c.sourcePath)),y=d.flatMap(c=>c.target.kind==="file"&&Object.hasOwn(f,c.target.path)&&L(c.target.path,t.root)!==null&&!n.includes(c.target.path)?[c.target.path]:[]).sort(),a=l.flatMap(c=>c.consumerPaths).sort(),k=m.length?[...new Set([m[0],...n.filter(c=>c!==m[0]),...y,...p,...a])]:[];return{facts:i,relatedReads:d,provenTemplates:m,ownedPaths:k}}function cs(e,t,n={}){return de(e)&&!t.agentConfigurations&&(t={...t,agentConfigurations:Ze(e,t.listedPaths??Object.keys(t.files),t.root)}),st(e,t,Xt(e,t,n))}function Xt(e,t,n){let f=It(e,t),{answer:i,scopeProof:l}=Qt(e,t,f),m=rt(e);if(!m&&!i.agents.some(o=>o.crewCall||o.layoutCall))return ye(e,t,i);let p=[...new Set([...Object.keys(t.files),...t.listedPaths??[],...i.scopePaths??[]])],d=V(e,p,t.root,{files:t.files,agentConfigurations:t.agentConfigurations,listedPaths:t.listedPaths}),y=i.agents.filter(o=>m||o.crewCall||o.layoutCall).map(o=>{let b=f.agents.find($=>$.key===o.key),S=Oe(b?.files??[]),x=i.agentScopes?.find($=>$.key===o.key)?.folder,O=d.scopes.find($=>x===void 0?$.key===o.key:$.folder===x)??d.scopes[0],s=W(e,p.filter($=>d.ownerOf($)===O),O.folder),g=new Set([...o.files.filter($=>$.role!=="reference"||$.label!==null).map($=>$.path),...o.subagents.flatMap($=>[$.path,...b?.subagents.find(j=>j.path===$.path)?.skillPaths??$.skillPaths]),...i.notes.filter($=>$.code==="orphan-skill").map($=>$.path)]),P=s.scoped.filter($=>!g.has($)&&J($)).sort(),w=`convention:${JSON.stringify(o.key)}`,v=o.files.map($=>o.prompt.kind!=="none"&&o.prompt.path===$.path&&"span"in o.prompt?{...$,span:$.span??o.prompt.span}:$),C=o.subagents.map($=>{let j=b?.subagents.find(F=>F.path===$.path),M=$.files??$.skillPaths.map(F=>({path:F,role:s.skillNames[F]?"skill":"reference",label:s.skillNames[F]??s.skillRefNames[F]??null})),A=ne(e)?Oe(j?.files??[]):M.map(F=>F.path),T=$.files&&!s.subagentPaths.includes($.path)?[]:D(P,[$.path,...A].map(F=>t.files[F]??""),s.stripRoot),E=T.filter(F=>!M.some(me=>me.path===F)).map(F=>({path:F,role:"reference",label:null})),Y=i.agents.find(F=>"key"in $&&F.key===$.key);return{child:$,id:`${w}:${JSON.stringify("key"in $?$.key:$.path)}`,scopeProof:Y?.layoutProof??l,toolCall:Y?.layoutCall,independentReferences:[...Oe(j?.files??[]),...T],ownFiles:"key"in $?[...M,...E]:[{path:$.path,role:"system prompt",label:null},...M,...E]}});return{agent:o,id:w,scope:O,ownFiles:v,independentReferences:S,children:C,scopeProof:o.layoutProof??l,toolCall:o.crewCall??o.layoutCall}}),a=y.flatMap(({agent:o,id:b,scope:S,ownFiles:x,independentReferences:O,children:s,scopeProof:g,toolCall:P})=>[{id:b,scope:S,ownFiles:x,independentReferences:O,scopeProof:g,toolCall:P,sharedReferencePaths:o.sharedReferencePaths,fileProfile:o.crewCall||o.layoutCall?"layout":"convention",skillManifests:o.skills.flatMap(w=>w.manifest?[w.manifest]:[])},...s.map(({child:w,id:v,ownFiles:C,independentReferences:$,scopeProof:j,toolCall:M})=>({id:v,scope:S,ownFiles:C,independentReferences:$,scopeProof:j,toolCall:M,fileProfile:"key"in w?"layout":"convention",skillManifests:w.skillManifests}))]),k=pt(e,a,{files:t.files,sizes:n.sizes??new Map(Object.entries(t.files).map(([o,b])=>[o,Buffer.byteLength(b)])),total:n.total,root:t.root,scopes:d}),c=new Map(k.map(o=>[o.agentId,o])),{complete:r,...h}=i,u=new Map(y.map(({agent:o,id:b,children:S})=>{let x=c.get(b);return[o.key,{...o,manifest:x,files:_t(x,o.files),skills:o.skills.filter(O=>x.files.some(s=>s.path===O.path)),subagents:S.flatMap(({child:O,id:s,ownFiles:g})=>{let P=c.get(s);if(!P.files.some(C=>C.path===O.path))return[];let w=_t(P,g),v="key"in O?w:w.filter(C=>C.path!==O.path);return[{...O,files:v,skillPaths:O.skillPaths.filter(C=>v.some($=>$.path===C))}]})}]}));return ye(e,t,{...h,...r&&!k.some(o=>o.refused.length)?{complete:r}:{},scopePaths:p,manifests:k,agents:i.agents.map(o=>u.get(o.key)??o)})}function _t(e,t){return e.files.flatMap(n=>t.some(f=>f.path===n.path)?t.filter(f=>f.path===n.path):[{path:n.path,role:n.roles.includes("config")?"config":"tools",label:null,...n.spans.length===1?{span:n.spans[0]}:{}}])}function Oe(e){return e.filter(t=>t.role==="reference"&&t.label===null).map(t=>t.path)}function Qt(e,t,n){let f=Ot(e,t,n);if(!K(e)&&t.codeAgentsFound)return{answer:{...f,projection:"code"}};let i=Se(e,t,f);if(!i)return{answer:f};let l=ve(e,t,i);if(!l.provenTemplates.length)return{answer:f};let m=l.provenTemplates[0],p=new Set(f.agentScopes?.find(y=>y.key===null)?.notes),d=y=>!(y.code==="no-prompt"&&y.detail==="no-conventions"&&y.path===(G(t.root)??""));return{scopeProof:{kind:"outside-loader",paths:l.ownedPaths},answer:{...f,projection:"conventions",notes:f.notes.filter(d),...f.agentScopes?{agentScopes:f.agentScopes.map(y=>({...y,notes:y.notes.filter(d)}))}:{},...f.unassignedNotes?{unassignedNotes:f.unassignedNotes.filter(y=>!p.has(y))}:{},agents:[{key:null,name:t.fallbackName,model:null,description:null,prompt:{kind:"dedicated",path:m},files:l.ownedPaths.map(y=>({path:y,role:y===m?"system prompt":i.includes(y)?"template":"reference",label:null})),skills:[],subagents:[]}]}}}function ps(e,t){return te(e)?Rt(e,t,It(e,t.selected)):{kind:"none"}}function It(e,t){if(!Ne(e)){let{agents:s,notes:g}=xe(e,t,null);return{agents:s,notes:g}}let n=De(e,t.listedPaths??[]).flatMap(s=>[...s.agents,...s.configs]),f=[...new Set([...Object.keys(t.files),...n,...I(e)?t.listedPaths??[]:[]])],{scopes:i,ownerOf:l,ignoredPaths:m,pluginFolders:p}=V(e,f,t.root,{files:t.files,agentConfigurations:t.agentConfigurations,listedPaths:t.listedPaths}),d=new Set(m),y=new Map(i.map(s=>[s,{}]));for(let[s,g]of Object.entries(t.files)){if(d.has(s))continue;let P=l(s);P&&(y.get(P)[s]=g)}let a=i.map(s=>{let g=y.get(s),P={...t,files:g,root:s.folder,fallbackName:s.key===null?t.fallbackName:Lt(s.folder),explicitPrompt:s.key===null?t.explicitPrompt:void 0,...t.pointerFiles?{pointerFiles:Object.fromEntries(Object.entries(t.pointerFiles).filter(([w])=>!d.has(w)&&l(w)===s))}:{}};return{scope:s,input:P,answer:Nt(e,s,P,!1,t.files)}}),k=[],c=new Map,r=a.filter(({scope:s,input:g,answer:P})=>{let w=P.agents[0];if(!w)return!0;let v=Object.entries(g.files).map(([j,M])=>[L(j,s.folder),M]).sort(([j],[M])=>j<M?-1:j>M?1:0),C=JSON.stringify([w.name,v,...s.managed||I(e)&&(s.kind==="crew"||p.includes(s.folder))?[s.folder]:[]]),$=c.get(C);return $!==void 0?(k.push({code:"duplicate-agent",path:s.folder,detail:$}),!1):(c.set(C,s.folder),!0)}),h=r.find(({scope:s})=>s.key===null),u=h.answer.agents[0];r.some(({scope:s,answer:g})=>s.key!==null&&g.agents.length)&&(h.answer=Nt(e,h.scope,h.input,!0,t.files),h.answer.notes=h.answer.notes.filter(s=>s.detail!=="no-conventions"));for(let{scope:s,answer:g}of K(e)?[]:r)p.includes(s.folder)&&(g.agents=g.agents.map(P=>({...P,plugin:!0})));let{kept:o,leftOut:b}=Mt(e,r.flatMap(({answer:s})=>s.agents));mt(o,u,{settings:e,files:t.files,root:t.root});let S=[...k,...b.length?[{code:"agent-cap",detail:jt({kind:"layout",leftOut:b.length})}]:[]],x=new Set(o.map(s=>s.key));return{...!t.definitionsOmitted&&r.some(({scope:s})=>s.kind==="crew")&&r.every(({scope:s,answer:g})=>g.notes.length===0&&!g.refused?.length&&(s.kind==="crew"?g.agents.length>0&&g.agents.every(P=>Pe(P.key??"")):g.agents.length===0))&&(!t.listedPaths||V(e,t.listedPaths,t.root,{agentConfigurations:t.agentConfigurations}).files.every(s=>Object.hasOwn(t.files,s.path)))?{complete:!0}:{},...r.some(({scope:s,answer:g})=>s.miniSwe&&g.agents.length)&&!t.codeAgentsFound?{projection:"conventions"}:{},agents:o.map(s=>s.layoutCall?{...s,subagents:s.subagents.filter(g=>"key"in g&&x.has(g.key))}:s),notes:[...r.flatMap(({answer:s})=>s.notes),...S],...n.length?{scopePaths:f}:{},...r.some(({answer:s})=>s.refused?.length)?{refused:r.flatMap(({answer:s})=>s.refused??[])}:{},...i.length>1||i.some(s=>s.kind==="crew"||s.managed||s.miniSwe)||r.some(({answer:s})=>s.agents.some(g=>g.layoutCall))?{agentScopes:r.flatMap(({scope:s,answer:g})=>(g.agents.length?g.agents:[{key:s.key}]).map((P,w)=>({key:P.key,folder:s.folder,registry:g.registry&&!Pe(P.key??""),notes:g.notes.filter(v=>v.code!=="unreadable-crew"||w===0)}))),unassignedNotes:[...r.filter(({answer:s})=>!s.agents.some(g=>x.has(g.key))).flatMap(({answer:s})=>s.notes),...S]}:{}}}function Nt(e,t,n,f=!1,i){if(t.managed)return St(e,t,n);if(t.miniSwe&&n.explicitPrompt===void 0)return vt(e,t,n);if(t.kind!=="crew"&&!I(e))return xe(e,n,t.key,f);let l=gt(e,n,i),m=Ht(e,t,n.files,n.listedPaths),p=xe(e,n,t.key,f||t.key===null&&(m.agents.length>0||l.agents.length>0));return{agents:[...p.agents,...m.agents,...l.agents],notes:[...p.notes.filter(d=>d.detail!=="no-conventions"||t.kind!=="crew"&&m.agents.length===0&&l.agents.length===0),...m.notes],registry:p.registry,...m.refused?.length||l.refused.length?{refused:[...m.refused??[],...l.refused]}:{}}}function Ht(e,t,n,f){let i=At(t,n,e,f),{agents:l,notes:m,registry:p}=i;return{agents:l.map(({entry:d,...y})=>({...y,prompt:Wt(e,{entry:d},m)})),notes:m,registry:p,...i.refused?.length?{refused:i.refused}:{}}}function xe(e,t,n,f=!1){let{files:i,skills:l,fallbackName:m}=t,p=G(t.root),d=W(e,Object.keys(i),p,t.listedPaths),y=[],a=typeof t.explicitPrompt=="string"&&!Ae(e,t.explicitPrompt);a&&y.push({code:"explicit-guide",path:t.explicitPrompt});let k=a?null:t.explicitPrompt,c=typeof k=="string"&&Object.hasOwn(i,k)&&_(e,{path:k},{purpose:"override",route:"github"}).admitted?k:null,r={...d,skillPaths:l?d.skillPaths:[]},h=Qe(r),u=Zt(i,d.configPath,y),o=!K(e)&&!u?.prompt&&!u?.agents?.length?et(e,t):null,b=Ee({codeAgentsFound:!K(e)&&!!t.codeAgentsFound,folderAgentsFound:f,otherDefinitions:h,agentConfiguration:o!==null},e);if(o&&b==="prompt"&&(d=o),!(k===null||c!==null||He({...r,claudePath:d.claudePath},b)))return Tt(he(d),l,y),{agents:[],notes:[...y,{code:"no-prompt",path:p??"",detail:"no-conventions"}],registry:d.registry};let x=Wt(e,{files:i,c:d,guideRole:b,folderAgentsFound:f,root:p,config:u,explicitPath:k===null?null:c??void 0,pointerFiles:t.pointerFiles},y);x.kind==="none"&&(d=he(d));let O=l?d.skillPaths.map(P=>{let w=ee(e,`${d.skillNames[P]}.md`,i[P]);return y.push(...(w.warnings??[]).map(v=>({code:"frontmatter",path:P,detail:v}))),{path:P,name:w.name,description:w.description??"",body:w.prompt??""}}):[];Tt(d,l,y);let s=l?[...d.subagentSkillPaths,...d.subagentSkillRefPaths]:[],g=d.subagentPaths.map(P=>{let w=ee(e,Lt(P),i[P],{preserveToolAbsence:!0});return y.push(...(w.warnings??[]).map(v=>({code:"frontmatter",path:P,detail:v}))),{path:P,name:w.name,description:w.description??null,prompt:w.prompt??"",...w.tools!==void 0?{tools:w.tools}:{},...w.model!==void 0?{model:w.model}:{},skillPaths:s.filter(v=>d.subagentSkillOwners[v]===P)}});return{agents:[{key:n,name:u?.name??m,model:u?.model??null,description:u?.description??null,prompt:x,files:eo(e,i,d,x,l),skills:O,subagents:g}],notes:y,registry:d.registry}}function ms(e,t,n,f){let i=W(e,Object.keys(n),G(f));return Object.hasOwn(i.subagentSkillOwners,t)?!0:re(e,{skillPaths:i.subagentSkillPaths,paths:i.scoped,files:n,root:f})?.some(l=>l.files.some(m=>m.path===t))??!1}function Zt(e,t,n){if(!t)return null;let f=at(e[t]);if(f.invalid)try{JSON.parse(e[t])}catch{n.push({code:"invalid-config",path:t})}return f.config}function Wt(e,t,n){if("entry"in t)return t.entry.text?{kind:"entry",...t.entry,text:t.entry.text}:(n.push({code:"no-prompt",path:t.entry.path}),{kind:"none"});let{files:f,c:i,guideRole:l,folderAgentsFound:m,root:p,config:d,explicitPath:y,pointerFiles:a}=t;if(y===null)return{kind:"none"};if(y!==void 0)return{kind:"explicit",path:y};let k=d?lt(d)[0]?.prompt:void 0,c=d?it(e,d,p??"")[0]:void 0,r=k?ft(e,k,{repoKey:"",markerDir:p??"",files:a??f}):null,h=c!==void 0&&Object.hasOwn(f,c),u=h&&!!f[c];if(h&&(u||a!==void 0)&&Object.hasOwn(i.subagentSkillOwners,c))n.push({code:"pointer-owned-by-subagent",path:c});else if(h&&(a===void 0?u:r?.kind==="resolved")){let o=r?.kind==="resolved"?r.prompt:null;return{kind:"pointer",path:c,...o&&o.kind!=="file"?{span:{...o.span},site:{kind:o.kind,start:o.start,symbol:o.symbol}}:{}}}else k&&n.push(a!==void 0&&r?.kind==="secret"?{code:"secret-file",path:r.path}:{code:"pointer-missed",...c?{path:c}:{},detail:k});return i.promptPath?{kind:"dedicated",path:i.promptPath}:i.registry&&i.soulPath?{kind:"registry",path:i.soulPath}:i.claudePath&&l==="prompt"?(n.push({code:"claude-fallback",...de(e)?{path:i.claudePath}:{}}),{kind:"fallback",path:i.claudePath}):(n.push({code:"no-prompt",path:p??"",...m?{folderAgentsFound:!0}:{}}),{kind:"none"})}function Tt(e,t,n){if(t)for(let f of[...e.subagentSkillPaths,...e.subagentSkillRefPaths])e.subagentSkillOwners[f]||n.push({code:"orphan-skill",path:f})}function eo(e,t,n,f,i){let l=[],m=(a,k,c=null)=>({role:a,label:c,path:k});if(f.kind!=="none"&&f.kind!=="registry"&&l.push(m("system prompt",f.path)),n.soulPath&&l.push(m("soul",n.soulPath)),n.knowledgePath&&l.push(m("knowledge",n.knowledgePath)),i)for(let a of n.skillPaths)l.push(m("skill",a,n.skillNames[a]));for(let a of n.templatePaths)l.push(m("template",a));if(i)for(let a of n.skillRefPaths)l.push(m("reference",a,n.skillRefNames[a]));let p=[];n.configPath&&p.push(m("config",n.configPath));for(let a of[n.toolsPath,n.toolsTsPath,n.cliPath])a&&p.push(m("tools",a));n.mcpPath&&p.push(m("mcp",n.mcpPath));let d=new Set([...l.map(a=>a.path),...p.map(a=>a.path),...n.subagentPaths,...Object.keys(n.subagentSkillOwners),...n.skillPaths,...n.skillRefPaths]),y=n.scoped.filter(a=>!d.has(a)&&J(a)).sort();return l.push(...D(y,l.map(a=>t[a.path]),n.stripRoot).map(a=>m("reference",a)),...p),l}export{D as a,Gt as b,Bo as c,be as d,Ko as e,ee as f,Yt as g,yn as h,$t as i,Mt as j,jt as k,cs as l,ps as m,ms as n};
|
|
17
|
+
`).join(""),r=a?"":`tools: ${ie(i)}${l.newline}`;return`${e.slice(0,l.start)}${c}${r}${e.slice(l.end)}`}function Pe(e){return e.CF_LEGACY_TOOL_LISTS!=="1"}function qo(e,t){return Pe(e)?ie(t):t.join(", ")}var Jt=/^\s*(name|description|tools|model)\s*:\s*(.+?)\s*$/i;function Dt(e){if(e.startsWith('"')&&e.endsWith('"'))try{return JSON.parse(e)}catch{}return e.replace(/^["']|["']$/g,"")}function ee(e,t,n,f){let i=Pe(e),l=qt(t).replace(/\.md$/i,""),m,p,d=[],y=!1,a=n,k=[],c=Q(n,i?void 0:"markdown");if(c){a=n.slice(c.bodyStart).trim();let h=i?c.raw.map(u=>u.replace(/\r$/,"")):c.raw;for(let u=0;u<h.length;u++){let b=h[u].match(Jt);if(!b)continue;let S=b[1].toLowerCase(),x=Dt(b[2]);if(S==="name")l=x;else if(S==="description")if(/^[>|][+-]?$/.test(b[2])){let O=[];for(;u+1<h.length&&(/^\s+\S/.test(h[u+1])||h[u+1].trim()==="");)O.push(h[++u].trim());m=O.join(x[0]===">"?" ":`
|
|
18
|
+
`).trim()}else m=x;else S==="model"?p=x:S==="tools"&&!i&&(y=!0,d=x.replace(/^\[|\]$/g,"").split(",").map(O=>O.trim()).filter(Boolean))}}if(i)try{let h=St(n);d=h.tools??[],y=h.tools!==null}catch{y=!0,k.push("tools could not be read; check the tool list")}let r=a.trim();return{name:l,...m!==void 0?{description:m}:{},...r?{prompt:r}:{},...!f?.preserveToolAbsence||y?{tools:d}:{},...p!==void 0?{model:p}:{},...k.length?{warnings:k}:{}}}function vt(e,t,n){let f=t.managed,i=[],l=new Set([...f.agents,...f.configs,...Object.keys(n.files),...n.listedPaths??[]]),m=new Set(Ye(e,[...l],n.files)),p=Object.fromEntries(Object.entries(n.files).filter(([c,r])=>{if(m.has(c))return!1;let h=_(e,{path:c,text:r},{purpose:"override",route:"github",root:t.folder,listing:l,managedFiles:n.files});return!h.admitted&&h.reason==="secret"&&i.push({path:c,reason:"secret"}),h.admitted})),d=new Map;for(let c of f.agents){if(p[c]===void 0){i.some(h=>h.path===c)||i.push({path:c,reason:"missing"});continue}let r=Ve(c,p[c],f,n.listedPaths??Object.keys(n.files));i.push(...r.refused),d.set(c,r)}let y=new Set([...d.values()].flatMap(c=>c.relationships.filter(r=>r.kind==="agent").map(r=>r.path))),a=[...d.values()].filter(c=>!y.has(c.path));return!a.length&&d.size&&a.push(d.values().next().value),{agents:a.map(c=>{let r=[{path:c.path,role:"system prompt",label:null}],h=[],u=[],o=(b,S,x)=>{for(let O of b.relationships){if(p[O.path]===void 0){i.some(s=>s.path===O.path)||i.push({path:O.path,reason:"missing"});continue}if(O.kind==="agent"){if(S.has(O.path)){i.push({path:O.path,reason:"cycle"});continue}let s=d.get(O.path);if(!s||u.some(P=>P.path===s.path))continue;let g=[];u.push({path:s.path,name:s.name,description:s.description,prompt:s.prompt,...s.model?{model:s.model}:{},tools:[],skillPaths:[],files:g}),o(s,new Set([...S,s.path]),g)}else if(O.kind==="skill"&&n.skills&&We(e)||O.kind==="config"&&Xe(p[O.path])){if(x.some(s=>s.path===O.path))continue;if(x.push({path:O.path,role:O.kind==="skill"?"skill":"config",label:null}),O.kind==="skill"&&b===c){let s=ee(e,Ut(O.path),p[O.path]);h.push({path:O.path,name:s.name,description:s.description??"",body:s.prompt??""})}}}};return o(c,new Set([c.path]),r),{key:`managed:${c.path}`,name:c.name,model:c.model,description:c.description,prompt:{kind:"dedicated",path:c.path},files:r,tools:[],skills:h,subagents:u}}),notes:[],registry:!1,refused:i}}function Ot(e,t,n){let f=t.miniSwe,i=n.templateSelection?.agentPath===f.agentPath?n.templateSelection.configPaths:void 0,l=nt(e,f,n.files,i),m=l.unresolved.filter(o=>o.reason!=="runtime-variable").map(o=>({path:o.target??o.path,reason:o.reason==="duplicate"?"invalid":o.reason})),p=l.fields.find(o=>o.key==="agent.system_template"&&o.value!==null),d=l.fields.find(o=>o.key==="agent.instance_template"&&o.value!==null),y=l.unresolved.some(o=>l.selectedPaths.includes(o.path)&&o.source===o.path);if(!p||!d||y||m.some(o=>o.reason==="invalid"))return{agents:[],notes:[],registry:!1,refused:m};let a=[p,...l.fields.filter(o=>o!==p)].map(o=>({path:o.path,span:o.span,label:o.key,role:o===p?"system prompt":o.key.endsWith("_template")?"template":"config"}));a.push(...l.loaded.map(o=>({path:o.path,role:"template",label:null})));let k=[];for(let o of a){let b=k.find(S=>S.path===o.path);b?b.span&&o.span&&(b.span={from:Math.min(b.span.from,o.span.from),to:Math.max(b.span.to,o.span.to)}):k.push({...o})}let c=[...new Set(k.map(o=>o.path))],r=Object.fromEntries(c.map(o=>[o,n.files[o]])),h=new Map(c.map(o=>[o,Buffer.byteLength(r[o])])),u=pt(e,{ownPaths:c},{files:r,sizes:h,root:t.folder});return m.push(...u.refused,...u.skipped),l.fields.some(o=>!u.paths.includes(o.path))?{agents:[],notes:[],registry:!1,refused:m}:(l.loaded=l.loaded.filter(o=>u.paths.includes(o.path)),l.edges=l.edges.filter(o=>u.paths.includes(o.from)&&u.paths.includes(o.to)),{agents:[{key:t.key,name:n.fallbackName,model:l.model,description:null,prompt:{kind:"entry",path:p.path,span:p.span,text:p.value},files:k.filter(o=>u.paths.includes(o.path)),tools:[],skills:[],subagents:[],templateVariants:l}],notes:[],registry:!1,refused:m})}function xt(e,t,n){if(!t.skills||!ne(e))return n;let f=[...new Set([...Object.keys(t.files),...t.listedPaths??[]])],i=V(e,f,t.root,{files:t.files,listedPaths:t.listedPaths,agentConfigurations:t.agentConfigurations}),l=new Set(i.files.filter(k=>k.role==="skill").map(k=>k.path)),m=k=>[...new Set([...k.skillPaths.filter(c=>l.has(c)),...k.files?.filter(c=>c.role==="skill").map(c=>c.path)??[]])],p=n.agents.flatMap(k=>[...k.skills.map(c=>c.path),...k.subagents.flatMap(m)]),d=re(e,{skillPaths:p,paths:f,files:t.files,root:t.root});for(let k of d)k.files=k.files.filter(c=>Object.hasOwn(t.files,c.path));let y=new Map(d.map(k=>[k.ownerPath,k])),a=(k,c)=>{let r=new Set(c.flatMap(u=>u.refused.map(o=>o.path))),h=k.filter(u=>u.role!=="reference"||!r.has(u.path));for(let u of c)for(let o of u.files)h.some(b=>b.path===o.path)||h.push({path:o.path,role:"reference",label:null});return h};return{...n,agents:n.agents.map(k=>{let c=k.skills.flatMap(r=>y.has(r.path)?[y.get(r.path)]:[]);return{...k,files:a(k.files,c),skills:k.skills.map(r=>({...r,...y.has(r.path)?{manifest:y.get(r.path)}:{}})),subagents:k.subagents.map(r=>{let h=m(r).flatMap(g=>y.has(g)?[y.get(g)]:[]);if(!h.length)return r;let u=i.ownerOf(r.path),o=W(e,f.filter(g=>i.ownerOf(g)===u),u?.folder),b=r.files??r.skillPaths.map(g=>({path:g,role:l.has(g)?"skill":"reference",label:o.skillNames[g]??o.skillRefNames[g]??null})),S=new Set([...k.files.map(g=>g.path),...o.subagentPaths,...Object.keys(o.subagentSkillOwners)]),x=o.scoped.filter(g=>!S.has(g)&&J(g)&&Object.hasOwn(t.files,g)).sort(),O=r.files?[]:D(x,[t.files[r.path],...b.filter(g=>g.role==="reference").map(g=>t.files[g.path])],o.stripRoot).map(g=>({path:g,role:"reference",label:null})),s=a([...b,...O],h);return{...r,files:s,skillPaths:[...new Set([...r.skillPaths,...m(r),...h.flatMap(g=>g.files.map(P=>P.path))])].filter(g=>s.some(P=>P.path===g)),skillManifests:h}})}})}}import{basename as It}from"node:path";import{createHash as Yt}from"node:crypto";var $t=25,Vt=e=>oe(e,"CF_IMPORT_AGENT_PAGES");function bn(e,t,n,f,i=$t,l){if(!Vt(e))return null;let m=f?.pageSize??i,p=f?.offset??0;if(![8,25,400].includes(m)||!Number.isSafeInteger(p)||p<0)throw new Error("invalid-agent-page");let d=[...new Map(t.map(P=>[P.id,P])).values()],y=Yt("sha256").update(JSON.stringify({version:1,context:{commit:n.commit,scope:n.scope},size:m,budgets:l,settings:Object.entries(Me(e)).filter(([,P])=>P!==void 0).sort(([P],[w])=>P.localeCompare(w)),rows:d.map(({id:P,path:w,groupKey:v,pool:C})=>({id:P,path:w,groupKey:v,pool:C}))})).digest("hex");if(f&&(f.version!==1||f.binding!==y))throw new Error("stale-agent-page");let a=d.map((P,w)=>{let v=Mt(e,P,w);return typeof v=="string"?`group:${v}`:`agent:${P.id}`}),k=[...new Set(a)];if(p>0&&p>=k.length)throw new Error("invalid-agent-page");let c=f?.end;if(c!==void 0&&(!Number.isSafeInteger(c)||c<p||c>k.length||c>p+m||c===p&&k.length>0))throw new Error("invalid-agent-page");let r=new Set,h=new Set,u=l?{...l}:null,o=p,b=!1;for(let P of k.slice(p,c??p+m)){let w=new Map(d.filter((C,$)=>a[$]===P&&!h.has(d[$].path)).map(C=>[C.path,C])),v={strong:0,possible:0};for(let C of w.values())v[C.pool??"strong"]+=C.bytes;if(c===void 0&&u&&r.size&&(v.strong>u.strong||v.possible>u.possible)){b=!0;break}r.add(P),o++;for(let C of w.keys())h.add(C);u&&(u.strong=Math.max(0,u.strong-v.strong),u.possible=Math.max(0,u.possible-v.possible))}c!==void 0&&(b=o<k.length&&o-p<m);let S=new Set(k.slice(o)),x=d.filter((P,w)=>r.has(a[w])),O=d.filter((P,w)=>S.has(a[w])).map(P=>P.id),s={version:1,binding:y,offset:p,pageSize:m,end:o},g=new Map(x.map(P=>[P.path,P.bytes]));return{context:{...n},current:s,continuation:O.length?{version:1,binding:y,offset:o,pageSize:m}:null,detected:d.length,detectedGroups:k.length,selected:x.map(P=>P.id),remaining:O,refusals:O.map(P=>({id:P,reason:b?"prompt-over-limit":"page"})),partial:O.length>0,estimatedInputBytes:[...g.values()].reduce((P,w)=>P+w,0)}}function Ct(){return $t}function Mt(e,t,n){return Ne(e)&&t!==null&&typeof t=="object"&&"groupKey"in t&&typeof t.groupKey=="string"&&t.groupKey?t.groupKey:n}function jt(e,t){let n=Ct(),f=new Set,i=[],l=[];return t.forEach((m,p)=>{let d=Mt(e,m,p);f.has(d)||f.size<n?(f.add(d),i.push(m)):l.push(m)}),{kept:i,leftOut:l}}function At(e){let t=Ct();if(e.kind==="layout")return`Only ${t} agents can be added per import, so ${e.leftOut} ${de(e.leftOut,"was","were")} left out.`;if(e.kind==="scan"){let f=e.found-t;return`${f} ${de(f,"agent wasn't","agents weren't")} read because the repository is large.`}let n=e.kind==="import"?`Not added: this import already has ${t} agents.`:`Only the ${t} strongest agents of a repository are added.`;return e.kind==="model"?`${e.name}: ${n}`:n}var fe="crew:";function we(e){return e.startsWith(fe)}function Se(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=Object.entries(e);return!t.length||t.some(([,n])=>typeof n!="string"||n.length>=2e3)?null:t.map(([n,f])=>`${n}: ${f}`).join(`
|
|
19
|
+
`)}function Et(e,t,n={},f=Object.keys(t)){return I(n)?Xt(e,t,f):e.kind!=="crew"?{agents:[],notes:[],registry:!1}:Ft(e,t)}function Ft(e,t){let n=[],f=[],i=(p,d)=>f.push({code:"unreadable-crew",path:p,detail:d?`${d} could not be read; some instructions may be missing.`:"could not be read; some instructions may be missing."}),l=se(t[e.agentsPath]??""),m=e.tasksPath?se(t[e.tasksPath]??""):[];l?.length||i(e.agentsPath),m===null&&i(e.tasksPath);for(let{key:p,value:d,span:y}of l??[]){if(!U(d)){i(e.agentsPath,p);continue}let{llm:a,tools:k,...c}=d,r=Se(c);if(r===null&&Object.keys(c).length){i(e.agentsPath,p);continue}let h=[{role:"system prompt",path:e.agentsPath,label:p,span:y}];for(let u of m??[])U(u.value)&&u.value.agent===p&&h.push({role:"knowledge",path:e.tasksPath,label:u.key,span:u.span});n.push({key:`${fe}${e.agentsPath}#${p}`,name:p,model:typeof a=="string"?a:null,description:typeof d.goal=="string"?d.goal:null,entry:{path:e.agentsPath,span:y,text:r},files:h,tools:Array.isArray(k)?[...new Set(k.filter(u=>typeof u=="string"&&!!u.trim()))]:[],skills:[],subagents:[]})}return{agents:n,notes:f,registry:!1}}function U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Xt(e,t,n){let f=new Set([...n,...Object.keys(t)]),i=Object.entries(t).filter(([r])=>r.endsWith(".py")).map(([r,h])=>st(r,h,f,e.folder)),l=i.flatMap(r=>r.agents),m=i.flatMap(r=>r.refused);if(!l.length)return e.kind==="crew"&&/\.ya?ml$/i.test(e.agentsPath)?{...Ft(e,t),refused:m}:{agents:[],notes:[],refused:m,registry:!1};let p=new Map,d=r=>{if(!p.has(r)){let h=t[r]===void 0?null:se(t[r]);p.set(r,h),h===null&&m.push({path:r,reason:t[r]===void 0?"missing":"invalid"})}return p.get(r)??[]},y=i.flatMap(r=>r.tasks).flatMap(r=>{let h=r.config?.path?d(r.config.path).find(b=>b.key===r.config.key):void 0;if(r.config&&(!r.config.path||!h||!U(h.value)))return r.config.path&&m.push({path:r.config.path,reason:h?"invalid":"missing"}),[];let u=U(h?.value)?h.value:{},o=r.factory.includes(".")?r.factory.slice(0,r.factory.lastIndexOf(".")):null;return[{fact:r,path:r.config?.path??r.path,key:r.config?.key??r.factory,span:h?.span??r.span,agent:r.agent??(typeof u.agent=="string"?o?`${o}.${u.agent}`:u.agent:null),context:[...r.context,...Array.isArray(u.context)?u.context.filter(b=>typeof b=="string"):[]],tools:r.tools}]}),a=i.flatMap(r=>r.tasks).filter(r=>r.config),k=a.flatMap(r=>r.config?.path?[{path:r.config.path,source:r.path,owner:r.factory.includes(".")?r.factory.slice(0,r.factory.lastIndexOf(".")):null}]:[]);!a.length&&e.kind==="crew"&&e.tasksPath&&k.push({path:e.tasksPath,source:e.tasksPath,owner:null});for(let{path:r,source:h,owner:u}of k)for(let o of d(r)){if(y.some(S=>S.path===r&&S.key===o.key&&S.fact.path===h&&(S.fact.factory.includes(".")?S.fact.factory.slice(0,S.fact.factory.lastIndexOf(".")):null)===u)||!U(o.value))continue;let b=o.value;y.push({fact:{path:h,factory:u?`${u}.${o.key}`:o.key,span:o.span,callStart:0,agent:null,context:[],tools:[]},path:r,key:o.key,span:o.span,agent:typeof b.agent=="string"?u?`${u}.${b.agent}`:b.agent:null,context:Array.isArray(b.context)?b.context.filter(S=>typeof S=="string"):[],tools:[]})}let c=[];for(let r of l){let h=r.config?.path?d(r.config.path).find(v=>v.key===r.config.key):void 0;if(r.config&&(!r.config.path||!h||!U(h.value))){r.config.path&&m.push({path:r.config.path,reason:h?"invalid":"missing"});continue}let u=U(h?.value)?h.value:{},o={...Object.fromEntries(Object.entries(u).filter(([v,C])=>!["llm","tools"].includes(v)&&typeof C=="string")),...r.instructions},b=Se(o);if(!b){m.push({path:r.path,reason:"dynamic"});continue}let S=r.config?.key??r.factory.split(".").at(-1),x=r.config?.path??r.path,O=h?.span??r.span,s=[{path:x,role:"system prompt",label:S,span:O}];x!==r.path&&s.push({path:r.path,role:"config",label:r.factory,span:r.span});let g=y.filter(v=>v.fact.path===r.path?v.agent===r.factory||v.agent===S:/\.ya?ml$/i.test(v.fact.path)&&v.agent===S&&l.filter(C=>(C.config?.key??C.factory)===S).length===1),P=new Set,w=[...r.tools];for(let v=0;v<g.length;v++){let C=g[v];if(!P.has(C)&&(P.add(C),!(C.fact.config&&!C.fact.config.path))){s.push({path:C.path,role:"knowledge",label:C.key,span:C.span}),w.push(...C.tools);for(let $ of C.context){let j=y.filter(M=>M.fact.path===C.fact.path&&M.fact.factory===$||M.path===C.path&&M.key===$);j.length===1?g.push(j[0]):m.push({path:C.path,reason:j.length?"dynamic":"missing"})}}}for(let v of w)v.path&&v.path!==r.path&&!s.some(C=>C.path===v.path)&&(t[v.path]===void 0&&m.push({path:v.path,reason:"missing"}),s.push({path:v.path,role:"tools",label:v.name}));c.push({key:`${fe}${r.path}#${r.factory}`,name:S,model:typeof u.llm=="string"?u.llm:null,description:typeof o.goal=="string"?o.goal:null,entry:{path:x,span:O,text:b},files:s,tools:[...new Set([...w.map(v=>v.name),...Array.isArray(u.tools)?u.tools.filter(v=>typeof v=="string"):[]])],skills:[],subagents:[],crewCall:{path:r.path,callStart:r.callStart}})}return{agents:c,notes:[],refused:m,registry:!1}}import{basename as Rt,posix as ce}from"node:path";function _t(e,t,n){let f={...t.selected,codeAgentsFound:t.codeAgentsFound||t.selected.codeAgentsFound};if(!ve(e,f,n))return{kind:"none"};let i={...t.bodies,...f.files},l=W(e,Object.keys(i),G(f.root)).templatePaths,m=Oe(e,{...f,files:i},l);if(!t.entries)return{kind:"search",paths:[],ownedPaths:m.ownedPaths};let p=new Set([...Object.keys(i),...t.attemptedPaths??[]]),d=new Set(m.facts.dependencies);for(let h of m.relatedReads)h.target.kind==="file"&&d.add(h.target.path);for(let h of t.entries)m.relatedReads.some(u=>u.target.kind==="directory"&&pe(u,h.path))&&d.add(h.path);let y=(h,u)=>{let o=_(e,h,{purpose:u,route:"local-folder"});return o.admitted||o.reason==="too-large"},a=[...new Set(t.entries.filter(h=>!p.has(h.path)&&(d.has(h.path)?y(h,"pointer"):L(h.path,f.root)===null&&Re(h.path)!==null&&y(h,"code-support"))).map(h=>h.path))],k=G(f.root)??"",c=h=>ce.parse(h).name===(k?Rt(k):f.fallbackName)?0:Qe.test(Rt(h))?1:2,r=h=>ce.relative(k||".",ce.dirname(h)).split("/").filter(u=>u&&u!==".").length;return a.sort((h,u)=>Number(d.has(u))-Number(d.has(h))||c(h)-c(u)||r(h)-r(u)||(h<u?-1:h>u?1:0)),{kind:"search",paths:a,ownedPaths:m.ownedPaths}}function pe(e,t){return e.target.kind==="file"?e.target.path===t:ce.dirname(t)===e.target.path&&(!e.target.extension||t.endsWith(e.target.extension))}function ve(e,t,n){if(!te(e)||t.codeAgentsFound||t.explicitPrompt!==void 0||n.agents.length||t.listedPaths&&W(e,[...t.listedPaths],G(t.root)).configPath)return null;let f=W(e,Object.keys(t.files),G(t.root)).templatePaths;if(!f.length)return null;let i=Object.fromEntries(Object.entries(t.files).filter(([l])=>L(l,t.root)!==null&&_(e,{path:l},{purpose:"override",route:"github"}).admitted));return he(e,i).reads.some(l=>f.some(m=>pe(l,m)))?null:f}function Oe(e,t,n){let f=Object.fromEntries(Object.entries(t.files).filter(([c])=>_(e,{path:c},{purpose:"override",route:"github"}).admitted)),i=he(e,f),l=i.reads.filter(c=>L(c.sourcePath,t.root)===null&&n.some(r=>pe(c,r))),m=n.filter(c=>l.some(r=>pe(r,c))).sort(),p=[...new Set(l.map(c=>c.sourcePath))].sort(),d=i.reads.filter(c=>p.includes(c.sourcePath)),y=d.flatMap(c=>c.target.kind==="file"&&Object.hasOwn(f,c.target.path)&&L(c.target.path,t.root)!==null&&!n.includes(c.target.path)?[c.target.path]:[]).sort(),a=l.flatMap(c=>c.consumerPaths).sort(),k=m.length?[...new Set([m[0],...n.filter(c=>c!==m[0]),...y,...p,...a])]:[];return{facts:i,relatedReads:d,provenTemplates:m,ownedPaths:k}}function ms(e,t,n={}){return ue(e)&&!t.agentConfigurations&&(t={...t,agentConfigurations:et(e,t.listedPaths??Object.keys(t.files),t.root)}),rt(e,t,Qt(e,t,n))}function Qt(e,t,n){let f=Wt(e,t),{answer:i,scopeProof:l}=Ht(e,t,f),m=at(e);if(!m&&!i.agents.some(o=>o.crewCall||o.layoutCall))return ke(e,t,i);let p=[...new Set([...Object.keys(t.files),...t.listedPaths??[],...i.scopePaths??[]])],d=V(e,p,t.root,{files:t.files,agentConfigurations:t.agentConfigurations,listedPaths:t.listedPaths}),y=i.agents.filter(o=>m||o.crewCall||o.layoutCall).map(o=>{let b=f.agents.find($=>$.key===o.key),S=xe(b?.files??[]),x=i.agentScopes?.find($=>$.key===o.key)?.folder,O=d.scopes.find($=>x===void 0?$.key===o.key:$.folder===x)??d.scopes[0],s=W(e,p.filter($=>d.ownerOf($)===O),O.folder),g=new Set([...o.files.filter($=>$.role!=="reference"||$.label!==null).map($=>$.path),...o.subagents.flatMap($=>[$.path,...b?.subagents.find(j=>j.path===$.path)?.skillPaths??$.skillPaths]),...i.notes.filter($=>$.code==="orphan-skill").map($=>$.path)]),P=s.scoped.filter($=>!g.has($)&&J($)).sort(),w=`convention:${JSON.stringify(o.key)}`,v=o.files.map($=>o.prompt.kind!=="none"&&o.prompt.path===$.path&&"span"in o.prompt?{...$,span:$.span??o.prompt.span}:$),C=o.subagents.map($=>{let j=b?.subagents.find(F=>F.path===$.path),M=$.files??$.skillPaths.map(F=>({path:F,role:s.skillNames[F]?"skill":"reference",label:s.skillNames[F]??s.skillRefNames[F]??null})),A=ne(e)?xe(j?.files??[]):M.map(F=>F.path),T=$.files&&!s.subagentPaths.includes($.path)?[]:D(P,[$.path,...A].map(F=>t.files[F]??""),s.stripRoot),E=T.filter(F=>!M.some(me=>me.path===F)).map(F=>({path:F,role:"reference",label:null})),Y=i.agents.find(F=>"key"in $&&F.key===$.key);return{child:$,id:`${w}:${JSON.stringify("key"in $?$.key:$.path)}`,scopeProof:Y?.layoutProof??l,toolCall:Y?.layoutCall,independentReferences:[...xe(j?.files??[]),...T],ownFiles:"key"in $?[...M,...E]:[{path:$.path,role:"system prompt",label:null},...M,...E]}});return{agent:o,id:w,scope:O,ownFiles:v,independentReferences:S,children:C,scopeProof:o.layoutProof??l,toolCall:o.crewCall??o.layoutCall}}),a=y.flatMap(({agent:o,id:b,scope:S,ownFiles:x,independentReferences:O,children:s,scopeProof:g,toolCall:P})=>[{id:b,scope:S,ownFiles:x,independentReferences:O,scopeProof:g,toolCall:P,sharedReferencePaths:o.sharedReferencePaths,fileProfile:o.crewCall||o.layoutCall?"layout":"convention",skillManifests:o.skills.flatMap(w=>w.manifest?[w.manifest]:[])},...s.map(({child:w,id:v,ownFiles:C,independentReferences:$,scopeProof:j,toolCall:M})=>({id:v,scope:S,ownFiles:C,independentReferences:$,scopeProof:j,toolCall:M,fileProfile:"key"in w?"layout":"convention",skillManifests:w.skillManifests}))]),k=mt(e,a,{files:t.files,sizes:n.sizes??new Map(Object.entries(t.files).map(([o,b])=>[o,Buffer.byteLength(b)])),total:n.total,root:t.root,scopes:d}),c=new Map(k.map(o=>[o.agentId,o])),{complete:r,...h}=i,u=new Map(y.map(({agent:o,id:b,children:S})=>{let x=c.get(b);return[o.key,{...o,manifest:x,files:Nt(x,o.files),skills:o.skills.filter(O=>x.files.some(s=>s.path===O.path)),subagents:S.flatMap(({child:O,id:s,ownFiles:g})=>{let P=c.get(s);if(!P.files.some(C=>C.path===O.path))return[];let w=Nt(P,g),v="key"in O?w:w.filter(C=>C.path!==O.path);return[{...O,files:v,skillPaths:O.skillPaths.filter(C=>v.some($=>$.path===C))}]})}]}));return ke(e,t,{...h,...r&&!k.some(o=>o.refused.length)?{complete:r}:{},scopePaths:p,manifests:k,agents:i.agents.map(o=>u.get(o.key)??o)})}function Nt(e,t){return e.files.flatMap(n=>t.some(f=>f.path===n.path)?t.filter(f=>f.path===n.path):[{path:n.path,role:n.roles.includes("config")?"config":"tools",label:null,...n.spans.length===1?{span:n.spans[0]}:{}}])}function xe(e){return e.filter(t=>t.role==="reference"&&t.label===null).map(t=>t.path)}function Ht(e,t,n){let f=xt(e,t,n);if(!K(e)&&t.codeAgentsFound)return{answer:{...f,projection:"code"}};let i=ve(e,t,f);if(!i)return{answer:f};let l=Oe(e,t,i);if(!l.provenTemplates.length)return{answer:f};let m=l.provenTemplates[0],p=new Set(f.agentScopes?.find(y=>y.key===null)?.notes),d=y=>!(y.code==="no-prompt"&&y.detail==="no-conventions"&&y.path===(G(t.root)??""));return{scopeProof:{kind:"outside-loader",paths:l.ownedPaths},answer:{...f,projection:"conventions",notes:f.notes.filter(d),...f.agentScopes?{agentScopes:f.agentScopes.map(y=>({...y,notes:y.notes.filter(d)}))}:{},...f.unassignedNotes?{unassignedNotes:f.unassignedNotes.filter(y=>!p.has(y))}:{},agents:[{key:null,name:t.fallbackName,model:null,description:null,prompt:{kind:"dedicated",path:m},files:l.ownedPaths.map(y=>({path:y,role:y===m?"system prompt":i.includes(y)?"template":"reference",label:null})),skills:[],subagents:[]}]}}}function ds(e,t){return te(e)?_t(e,t,Wt(e,t.selected)):{kind:"none"}}function Wt(e,t){if(!Te(e)){let{agents:s,notes:g}=$e(e,t,null);return{agents:s,notes:g}}let n=Ue(e,t.listedPaths??[]).flatMap(s=>[...s.agents,...s.configs]),f=[...new Set([...Object.keys(t.files),...n,...I(e)?t.listedPaths??[]:[]])],{scopes:i,ownerOf:l,ignoredPaths:m,pluginFolders:p}=V(e,f,t.root,{files:t.files,agentConfigurations:t.agentConfigurations,listedPaths:t.listedPaths}),d=new Set(m),y=new Map(i.map(s=>[s,{}]));for(let[s,g]of Object.entries(t.files)){if(d.has(s))continue;let P=l(s);P&&(y.get(P)[s]=g)}let a=i.map(s=>{let g=y.get(s),P={...t,files:g,root:s.folder,fallbackName:s.key===null?t.fallbackName:It(s.folder),explicitPrompt:s.key===null?t.explicitPrompt:void 0,...t.pointerFiles?{pointerFiles:Object.fromEntries(Object.entries(t.pointerFiles).filter(([w])=>!d.has(w)&&l(w)===s))}:{}};return{scope:s,input:P,answer:Tt(e,s,P,!1,t.files)}}),k=[],c=new Map,r=a.filter(({scope:s,input:g,answer:P})=>{let w=P.agents[0];if(!w)return!0;let v=Object.entries(g.files).map(([j,M])=>[L(j,s.folder),M]).sort(([j],[M])=>j<M?-1:j>M?1:0),C=JSON.stringify([w.name,v,...s.managed||I(e)&&(s.kind==="crew"||p.includes(s.folder))?[s.folder]:[]]),$=c.get(C);return $!==void 0?(k.push({code:"duplicate-agent",path:s.folder,detail:$}),!1):(c.set(C,s.folder),!0)}),h=r.find(({scope:s})=>s.key===null),u=h.answer.agents[0];r.some(({scope:s,answer:g})=>s.key!==null&&g.agents.length)&&(h.answer=Tt(e,h.scope,h.input,!0,t.files),h.answer.notes=h.answer.notes.filter(s=>s.detail!=="no-conventions"));for(let{scope:s,answer:g}of K(e)?[]:r)p.includes(s.folder)&&(g.agents=g.agents.map(P=>({...P,plugin:!0})));let{kept:o,leftOut:b}=jt(e,r.flatMap(({answer:s})=>s.agents));dt(o,u,{settings:e,files:t.files,root:t.root});let S=[...k,...b.length?[{code:"agent-cap",detail:At({kind:"layout",leftOut:b.length})}]:[]],x=new Set(o.map(s=>s.key));return{...!t.definitionsOmitted&&r.some(({scope:s})=>s.kind==="crew")&&r.every(({scope:s,answer:g})=>g.notes.length===0&&!g.refused?.length&&(s.kind==="crew"?g.agents.length>0&&g.agents.every(P=>we(P.key??"")):g.agents.length===0))&&(!t.listedPaths||V(e,t.listedPaths,t.root,{agentConfigurations:t.agentConfigurations}).files.every(s=>Object.hasOwn(t.files,s.path)))?{complete:!0}:{},...r.some(({scope:s,answer:g})=>s.miniSwe&&g.agents.length)&&!t.codeAgentsFound?{projection:"conventions"}:{},agents:o.map(s=>s.layoutCall?{...s,subagents:s.subagents.filter(g=>"key"in g&&x.has(g.key))}:s),notes:[...r.flatMap(({answer:s})=>s.notes),...S],...n.length?{scopePaths:f}:{},...r.some(({answer:s})=>s.refused?.length)?{refused:r.flatMap(({answer:s})=>s.refused??[])}:{},...i.length>1||i.some(s=>s.kind==="crew"||s.managed||s.miniSwe)||r.some(({answer:s})=>s.agents.some(g=>g.layoutCall))?{agentScopes:r.flatMap(({scope:s,answer:g})=>(g.agents.length?g.agents:[{key:s.key}]).map((P,w)=>({key:P.key,folder:s.folder,registry:g.registry&&!we(P.key??""),notes:g.notes.filter(v=>v.code!=="unreadable-crew"||w===0)}))),unassignedNotes:[...r.filter(({answer:s})=>!s.agents.some(g=>x.has(g.key))).flatMap(({answer:s})=>s.notes),...S]}:{}}}function Tt(e,t,n,f=!1,i){if(t.managed)return vt(e,t,n);if(t.miniSwe&&n.explicitPrompt===void 0)return Ot(e,t,n);if(t.kind!=="crew"&&!I(e))return $e(e,n,t.key,f);let l=yt(e,n,i),m=Zt(e,t,n.files,n.listedPaths),p=$e(e,n,t.key,f||t.key===null&&(m.agents.length>0||l.agents.length>0));return{agents:[...p.agents,...m.agents,...l.agents],notes:[...p.notes.filter(d=>d.detail!=="no-conventions"||t.kind!=="crew"&&m.agents.length===0&&l.agents.length===0),...m.notes],registry:p.registry,...m.refused?.length||l.refused.length?{refused:[...m.refused??[],...l.refused]}:{}}}function Zt(e,t,n,f){let i=Et(t,n,e,f),{agents:l,notes:m,registry:p}=i;return{agents:l.map(({entry:d,...y})=>({...y,prompt:Bt(e,{entry:d},m)})),notes:m,registry:p,...i.refused?.length?{refused:i.refused}:{}}}function $e(e,t,n,f=!1){let{files:i,skills:l,fallbackName:m}=t,p=G(t.root),d=W(e,Object.keys(i),p,t.listedPaths),y=[],a=typeof t.explicitPrompt=="string"&&!Ee(e,t.explicitPrompt);a&&y.push({code:"explicit-guide",path:t.explicitPrompt});let k=a?null:t.explicitPrompt,c=typeof k=="string"&&Object.hasOwn(i,k)&&_(e,{path:k},{purpose:"override",route:"github"}).admitted?k:null,r={...d,skillPaths:l?d.skillPaths:[]},h=He(r),u=eo(i,d.configPath,y),o=!K(e)&&!u?.prompt&&!u?.agents?.length?tt(e,t):null,b=Fe({codeAgentsFound:!K(e)&&!!t.codeAgentsFound,folderAgentsFound:f,otherDefinitions:h,agentConfiguration:o!==null},e);if(o&&b==="prompt"&&(d=o),!(k===null||c!==null||Ze({...r,claudePath:d.claudePath},b)))return Lt(ge(d),l,y),{agents:[],notes:[...y,{code:"no-prompt",path:p??"",detail:"no-conventions"}],registry:d.registry};let x=Bt(e,{files:i,c:d,guideRole:b,folderAgentsFound:f,root:p,config:u,explicitPath:k===null?null:c??void 0,pointerFiles:t.pointerFiles},y);x.kind==="none"&&(d=ge(d));let O=l?d.skillPaths.map(P=>{let w=ee(e,`${d.skillNames[P]}.md`,i[P]);return y.push(...(w.warnings??[]).map(v=>({code:"frontmatter",path:P,detail:v}))),{path:P,name:w.name,description:w.description??"",body:w.prompt??""}}):[];Lt(d,l,y);let s=l?[...d.subagentSkillPaths,...d.subagentSkillRefPaths]:[],g=d.subagentPaths.map(P=>{let w=ee(e,It(P),i[P],{preserveToolAbsence:!0});return y.push(...(w.warnings??[]).map(v=>({code:"frontmatter",path:P,detail:v}))),{path:P,name:w.name,description:w.description??null,prompt:w.prompt??"",...w.tools!==void 0?{tools:w.tools}:{},...w.model!==void 0?{model:w.model}:{},skillPaths:s.filter(v=>d.subagentSkillOwners[v]===P)}});return{agents:[{key:n,name:u?.name??m,model:u?.model??null,description:u?.description??null,prompt:x,files:to(e,i,d,x,l),skills:O,subagents:g}],notes:y,registry:d.registry}}function us(e,t,n,f){let i=W(e,Object.keys(n),G(f));return Object.hasOwn(i.subagentSkillOwners,t)?!0:re(e,{skillPaths:i.subagentSkillPaths,paths:i.scoped,files:n,root:f})?.some(l=>l.files.some(m=>m.path===t))??!1}function eo(e,t,n){if(!t)return null;let f=lt(e[t]);if(f.invalid)try{JSON.parse(e[t])}catch{n.push({code:"invalid-config",path:t})}return f.config}function Bt(e,t,n){if("entry"in t)return t.entry.text?{kind:"entry",...t.entry,text:t.entry.text}:(n.push({code:"no-prompt",path:t.entry.path}),{kind:"none"});let{files:f,c:i,guideRole:l,folderAgentsFound:m,root:p,config:d,explicitPath:y,pointerFiles:a}=t;if(y===null)return{kind:"none"};if(y!==void 0)return{kind:"explicit",path:y};let k=d?it(d)[0]?.prompt:void 0,c=d?ft(e,d,p??"")[0]:void 0,r=k?ct(e,k,{repoKey:"",markerDir:p??"",files:a??f}):null,h=c!==void 0&&Object.hasOwn(f,c),u=h&&!!f[c];if(h&&(u||a!==void 0)&&Object.hasOwn(i.subagentSkillOwners,c))n.push({code:"pointer-owned-by-subagent",path:c});else if(h&&(a===void 0?u:r?.kind==="resolved")){let o=r?.kind==="resolved"?r.prompt:null;return{kind:"pointer",path:c,...o&&o.kind!=="file"?{span:{...o.span},site:{kind:o.kind,start:o.start,symbol:o.symbol}}:{}}}else k&&n.push(a!==void 0&&r?.kind==="secret"?{code:"secret-file",path:r.path}:{code:"pointer-missed",...c?{path:c}:{},detail:k});return i.promptPath?{kind:"dedicated",path:i.promptPath}:i.registry&&i.soulPath?{kind:"registry",path:i.soulPath}:i.claudePath&&l==="prompt"?(n.push({code:"claude-fallback",...ue(e)?{path:i.claudePath}:{}}),{kind:"fallback",path:i.claudePath}):(n.push({code:"no-prompt",path:p??"",...m?{folderAgentsFound:!0}:{}}),{kind:"none"})}function Lt(e,t,n){if(t)for(let f of[...e.subagentSkillPaths,...e.subagentSkillRefPaths])e.subagentSkillOwners[f]||n.push({code:"orphan-skill",path:f})}function to(e,t,n,f,i){let l=[],m=(a,k,c=null)=>({role:a,label:c,path:k});if(f.kind!=="none"&&f.kind!=="registry"&&l.push(m("system prompt",f.path)),n.soulPath&&l.push(m("soul",n.soulPath)),n.knowledgePath&&l.push(m("knowledge",n.knowledgePath)),i)for(let a of n.skillPaths)l.push(m("skill",a,n.skillNames[a]));for(let a of n.templatePaths)l.push(m("template",a));if(i)for(let a of n.skillRefPaths)l.push(m("reference",a,n.skillRefNames[a]));let p=[];n.configPath&&p.push(m("config",n.configPath));for(let a of[n.toolsPath,n.toolsTsPath,n.cliPath])a&&p.push(m("tools",a));n.mcpPath&&p.push(m("mcp",n.mcpPath));let d=new Set([...l.map(a=>a.path),...p.map(a=>a.path),...n.subagentPaths,...Object.keys(n.subagentSkillOwners),...n.skillPaths,...n.skillRefPaths]),y=n.scoped.filter(a=>!d.has(a)&&J(a)).sort();return l.push(...D(y,l.map(a=>t[a.path]),n.stripRoot).map(a=>m("reference",a)),...p),l}export{D as a,Kt as b,zo as c,Pe as d,qo as e,ee as f,Vt as g,bn as h,Ct as i,jt as j,At as k,ms as l,ds as m,us as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as h}from"./6YCABS5T.js";import{a as S,c as _}from"./
|
|
1
|
+
import{a as h}from"./6YCABS5T.js";import{a as S,c as _}from"./GZSUTDGX.js";import{c as B}from"./M6HYSTQD.js";import{d as A}from"./VBGQKYIT.js";import{Ra as T}from"./QYYN4YKB.js";function I(p,u,f,d,i,c,N){return{routeId:h(u),templateId:u,answerFormatId:A(u,f,p),model:d,calls:i,maxInputBytes:c,maxInputTokens:2e5,maxOutputTokens:N??B({model:d})}}var E=()=>({remaining:2e3});function C(p,u){return Buffer.byteLength(JSON.stringify({path:p,text:T(u)}))}function F(p,u=E()){let f=[...p].sort((e,t)=>t.size-e.size),d=(e,t,s)=>{let r=e[t],n=(r?.inputBytes??0)+(s.inputBytes??0);if(r&&r.size+s.size>15e4||n>=8e5)return;let o=[...e];return o[t]={own:[...r?.own??[],s.path],size:(r?.size??0)+s.size,inputBytes:n},o},i=[];for(let e of f){let t=i.findIndex(s=>s.size+e.size<=15e4&&s.inputBytes+(e.inputBytes??0)<8e5);if(t>=0)i[t].own.push(e.path),i[t].size+=e.size,i[t].inputBytes+=e.inputBytes??0;else if((e.inputBytes??0)<8e5)i.push({own:[e.path],size:e.size,inputBytes:e.inputBytes??0});else return}if(i.length<=4)return i.length?i.map(({own:e})=>({own:e})):[{own:[]}];let c=[{index:0,groups:[]}],N=new Set;for(;c.length;){if(u.remaining--<=0)return;let{index:e,groups:t}=c.pop();if(e===f.length)return t.map(({own:n})=>({own:n}));let s=JSON.stringify([e,t.map(n=>[n.size,n.inputBytes]).sort((n,o)=>n[0]-o[0]||n[1]-o[1])]);if(N.has(s))continue;N.add(s);let r=new Set;for(let n=Math.min(t.length,3);n>=0;n--){let o=t[n],a=`${o?.size??0}:${o?.inputBytes??0}`;if(r.has(a))continue;r.add(a);let m=d(t,n,f[e]);m&&c.push({index:e+1,groups:m})}}}export{I as a,E as b,C as c,F as d};
|